<template>
  <div>
    555Z
    <ImportDialog :name="importData.importDialog"
      :visible="importData.importDialog"
      ref="importDialog"
      :show-close="true"
      :title="importData.importDialogTitle"
      :tablename="itemName"
      :main-table="tableName"
      :main-id="itemId"
      :action-id="actionId"
      :webconf="webConfSingle"></ImportDialog>
  </div>
</template>

<script>
  
   const { ImportDialog} = window.R3.components;
   console.log('ImportDialogCustomization component loaded', ImportDialog);
  export default {
    name: 'ImportDialogCustomization',
    components: {
      ImportDialog
    },
    props: {
      // Define any props if needed
       tablename: {// /p/cs/downloadImportTemplate 用于下载模版,上传文件参数
        // 子表名
        type: String,
        default: ''
      },
      mainTable: {// 用于/p/cs/import参数上传文件
        // 主表名
        type: String,
        default: ''
      },
      mainId: {// 用于/p/cs/import参数上传文件
        // 主表id
        type: [Number, String],
        default: -1
      },
      options: {
        type: Object,
        default: () => {}
      }
    },
    data() {
      return {
       importData:{
          importDialog:true,
          importDialogTitle:'导入数据',
       },
       itemName:'',
        tableName:'',
        itemId:'',
        actionId:'',
        webConfSingle:{},
        downloadConf:{
          'T_V_IESSHOP':'已发货订单.xlsx'
        }
      };
    },
    methods:{
      downloadTemplate(){
        const link = document.createElement('a');
            link.style.display = 'none';
            link.href = `../../../static/importExcel/${this.downloadConf[this.tableName]}`;
            link.setAttribute('download', `${this.downloadConf[this.tableName]}`);
            document.body.appendChild(link);
            link.click();
      }
    },
    mounted() {
      // document.querySelector('.ark-modal-close').click();
      // this.importData.importDialog = true;
      this.itemName= this.$route.query.tableName
      this.tableName = this.$route.query.tableName
      this.itemId = this.$route.query.tableId
      this.$nextTick(()=>{
        const downloadTemplate = this.$refs.importDialog.downloadTemplate
          console.log(downloadTemplate,'ImportDialog ref:', this.$refs);
        this.$refs.importDialog.componentsName = ''
        this.$refs.importDialog.downloadTemplate = () => {
          const yunqueIsZhuque = window.localStorage.getItem('yunque_is_zhuque');
          if(yunqueIsZhuque == true){
            this.downloadTemplate();
          }else{
            return downloadTemplate();
          }
        };
      })
    },
   
  };
</script>
