<template>
  <div data-key="IMPORT_ZHANGDAN">
    <ImportDialog
      :tablename="tablename"
      :title="title"
      :visible="visible"
      :main-id="mainId"
      :custom-import="customImport"
      :account-list="accountList"
      :father-method="fatherClose"
    />
  </div>
</template>
<script>

  import ImportDialog from '../customizedContent/ImportDialogAddOther.vue';

  const R3 = window.R3;
  const { network, urlSearchParams, store } = R3;

  export default {
    components: { ImportDialog },
    data() {
      return {
        tablename: window.location.href.indexOf("T_OMSALIPAYBILLDETAIL") > -1?"T_OMSALIPAYBILLDETAIL":"T_OMSSTATEACCOUNTTOPOSITEM",
        title: '账单',
        visible: true,
        customImport: true, // 自定义导入接口
        accountList: [],
        mainId: ''
      };
    },
    created() {
      if(window.location.href.indexOf("T_OMSALIPAYBILLDETAIL") > -1){
        this.getAccountList();
      }
    },
    methods: {
      getAccountList() { // 获取账户列表
        network.post('/p/cs/QueryList', urlSearchParams({
          searchdata: {
            table: 'T_OMSBANKINFO',
            startindex: 0,
            range: 1000,
            fixedcolumns: {},
            column_include_uicontroller: true,
            isolr: false
          }
        })).then(res => {
          let list = [];
          res.data.data.row.forEach(item => {
            let obj = {
              label: item.ACCOUNTNAME.val,
              value: item.ID.val,
              shopId: item.SHOPID.refobjid
            };
            list.push(obj);
          });
          this.accountList = list;
        });
      },
      fatherClose() {
        this.$emit('closeActionDialog', true);
      }
    }
  };
</script>
