<template>
  <div class="white_bg burt-container">
    <a-tabs v-model="activeKey" @change="paneChange">
        <a-tab-pane v-for="pane in panes" :key="pane.key" :tab="pane.title">
            <component v-if="pane.show" :is="pane.content" 
              :companyOptions="companyOptions" :expressList="expressList"></component>
        </a-tab-pane>
    </a-tabs>
  </div>
</template>

<script>
import PayBill from "./components/PayBill.vue";

export default {
  data() {
    return {
      activeKey: '0',
      panes: [
        { title: "财务账单", key: '0', show: true, content: 'PayBill'},
      ],
      companyOptions: [], //保险公司
      expressList: [], //快递公司
    };
  },
  components: {
    PayBill
  },
  created() {
    let type = this.$route.query.type;
    if(type){
      this.activeKey = type;
      this.paneChange();
    }
    this._getCompanyOptions();
    this.getRefcdByRefgrp();
  },
  methods: {
    paneChange(){
      this.panes.forEach((item)=>{
          item.show = false;
      });
      this.panes[Number(this.activeKey)].show = true;
    },
    // 获取保险公司下拉选项
    _getCompanyOptions() {
      this.$apis.getCompanyOptions().then((res) => {
        this.companyOptions = res.content || [];
      });
    },
    // 获取快递列表
    getRefcdByRefgrp() {
      this.$apis.getRefcdByRefgrp({
        modid: "CI",
        refgrp: "SEND_COMPANY"
      }).then((res) => {
        this.expressList = res.content || [];
      });
    },
  },
};
</script>

<style lang="less" scoped></style>
