<template>
  <div>
    <drag-modal :title="dialogTitle" :width="dialogWidth" :visible="visible" :isFooter="operateBizBtn.length > 0 ? true : false" :confirmLoading="confirmLoading" @ok="handleOk" @cancel="handleClose" :canClickMask="canClickMask" :leftPosition="leftPosition" :topPosition="topPosition" :initPosition="initPosition" okText="保存" cancelText="关闭" wrapClassName="ant-modal-cust-warp" style="top: 5%; height: 70%; overflow-y: hidden" >
    <a-spin :spinning="confirmLoading" size="large">
      <a-config-provider :locale="locale">
        <a-form class="k-form-build-9136076486841527" layout="horizontal" :hideRequiredMark="undefined" :form="form" @submit="handleSubmit" >
          <div class="build-block" >
            <!-- uploadFile_1658302509147 - 上传文件 -->
            <a-form-item :colon="true" :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_filePath_record.options.hidden ? 'display: none' : 'display: flex'" >
              <span slot="label">
                <a-tooltip>
                  <span>上传文件</span>
                </a-tooltip>
              </span>
              <div>
                <UploadFile style="width:100%" :model="'filePath'" :width="'100%'" :placeholder="'上传'" :config="config" :dynamicData="dynamicData" :parentDisabled="disabled" @invokeGetFormData="invokeGetFormData" @change="handleChange($event, 'filePath')" v-decorator="[ 'filePath', { rules: [{'message':'必填项','required':true}] }, ]" />
              </div>
            </a-form-item>
          </div>
          <div class="build-block" >
            <!-- button_1658302532721 - 确认 -->
            <a-form-item :wrapper-col="{'offset':0,'span':24}" :style="data_1_record.options.hidden ? 'display: none' : 'display: flex'" >
              <a-button @click=" dynamicData['commonFunc']( 'import', {} ) " type="primary" :block="false" :style="{'verticalAlign':'middle','textAlign':'center'}" > 确认 </a-button>
            </a-form-item>
          </div>
        </a-form>
      </a-config-provider>
    </a-spin>
    <template slot="footer">
      <a-button v-for="(item, index) in operateBizBtn" :key="index" :type="item.type ? item.type : 'primary'" :icon="item.icon" @click="handleBusiness(item.operation, item)" >{{ item.label }}</a-button >
    </template>
  </drag-modal>
  </div>
  </template>
  
    <script>
    import baseModalMixin from './baseModalMixin'
    import formBuildMixin from './formBuildMixin'
  
    export default {
      mixins: [formBuildMixin, baseModalMixin],
      data() {
        return {
          pageId: 'EXCEL_IMPORT_DANGER',
          operateBizBtn: [{'hidden':false,'icon':'','hotKey':'','permission':'','label':'关闭','operationMethod':'','type':'primary','params':[],'operation':'cancel','displayTab':'','displayMode':'flat','direction':'right'}],
          dialogTitle: '',
          dialogServiceName: '',
          dialogWidth: '50%',
          dialogBaseCodeType: '',
          dialogModalType: 'dialog',
          dialogUrl: {'add':'save','update':'updateTemplateById'},
  
          data_filePath_record: {"options":{"placeholder":"上传"},"model":"filePath","rules":[{"message":"必填项","required":true}],"label":"上传文件","type":"uploadFile","key":"uploadFile_1658302509147"},
          data_1_record: {"options":{"type":"primary","dynamicFun":"import"},"model":"1","label":"确认","type":"button","key":"button_1658302532721"}
        }
      },
      methods: {
        dynamicFuncCustom(operation){
      if (operation == 'import') {
          this.getData().then((res) => {
              debugger
              let fileName = res.filePath[0].name
              if (this.voyageId == undefined) {
                  this.$message.error('请先选中航次')
                  return
              }
              const wheres = []
              wheres.push(res.filePath[0].url)
              wheres.push(res.filePath[0].name)
              wheres.push(this.voyageId)
              this.ctos3CommonApi('ifcsumTempService', 'importDangerExcel', wheres).then((
              result) => {
                  var data = result.responseData.resultData
                  if (data.code == "0000") {
                      var res = data.result
                      if (res.length == 0) {
                          this.$message.success('导入成功')
                      } else {
                          this.$message.success('导入成功，箱号' + res.join(',') + '不存在')
                      }
                  } else {
                      this.$message.error('导入失败')
                  }
              })
          })
      }
  },
  callInMountedCustom(ctos3CommonApi, packageRpcParam){
      this.loading = false
  },
  handleBusinessCustom(operation){
      if (operation === 'cancel') {
          this.visible = false
      }
  }
      }
    }
    </script>