<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="false" :form="form" @submit="handleSubmit" >
          <div class="build-block" >
            <!-- batch_1629790711297 - 动态表格 -->
            <a-form-item label="" :label-col="{}" :wrapper-col="{}" :style="{}" >
              <KBatch v-if="!data_goodsList_record.options.hidden" ref="KBatch" style="width:100%" v-bind="data_goodsList_record.options" :recordKey="data_goodsList_record.key" :optionsKey="data_goodsList_record.options.key" :baseColumnConfigList="data_goodsList_BaseColumnList" :model="'goodsList'" :config="config" :parentDisabled="disabled" :dynamicData="dynamicData" :selectMode="selectMode" :selectDeferred="selectDeferred" :excelName="excelName" :pageId="pageId" @invokeGetFormData="invokeGetFormData" @change="handleChange($event, 'goodsList')" @logEvent="logEvent($event, 'goodsList', data_goodsList_record)" v-decorator="[ 'goodsList', { }, ]" />
            </a-form-item>
          </div>
          <div class="build-block" >
            <!-- input_1635760915684 - 输入框 -->
            <a-form-item :colon="true" :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_正式库_record.options.hidden ? 'display: none' : 'display: flex'" >
              <span slot="label">
                <a-tooltip>
                  <span>输入框</span>
                </a-tooltip>
              </span>
              <JInput ref="正式库" :recordModel="'正式库'" style="width:100%;" placeholder="请输入" type="text" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ '正式库', { rules: [{'message':'必填项','required':false}], validateTrigger: 'blur' }, ]" />
            </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: 'MANIFEST_MAINTENANCE_DETAIL_GOODS_ZKS',
          operateBizBtn: [{'hidden':false,'icon':'','hotKey':'','permission':'','label':'关闭','operationMethod':'','sort':0,'type':'primary','params':[],'operation':'close','displayTab':''}],
          dialogTitle: '',
          dialogServiceName: 'codeService',
          dialogWidth: '40%',
          dialogBaseCodeType: '',
          dialogModalType: 'dialog',
          dialogUrl: {'add':'save','update':'updateTemplateById'},
  
          data_goodsList_record: {"label":"动态表格","type":"batch","options":{"mode":"row","adding":false,"columnChooser":false,"lazyNoPaging":true,"hasPaging":false,"key":"id","deleting":false},"model":"goodsList","key":"batch_1629790711297"},
          data_goodsList_BaseColumnList: [{"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"100px"},"model":"marksStr","rules":[{"message":"必填项","required":false}],"label":"唛头","type":"input","key":"input_1629790714900"},{"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"140px"},"model":"eCargoNam","rules":[{"message":"必填项","required":false}],"label":"英文货名","type":"input","key":"input_1629790716738"},{"icon":"icon-write","options":{"type":"text","width":"100px","disabled":true,"placeholder":"请输入"},"rules":[{"message":"必填项","required":false}],"model":"packageCod","label":"包装代码","type":"input","key":"input_1630662545127"},{"icon":"icon-write","options":{"type":"text","width":"100px","disabled":true,"placeholder":"请输入"},"rules":[{"message":"必填项","required":false}],"model":"packageStr","label":"包装名称","type":"input","key":"input_1652972959452"},{"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"80px"},"model":"pieceNum","rules":[{"message":"必填项","required":false}],"label":"件数","type":"input","key":"input_1629790717421"},{"icon":"icon-number","options":{"precision":3,"placeholder":"请输入","width":"80px"},"model":"gweightTon","label":"重量","type":"number","key":"number_1634199276230"},{"icon":"icon-number","options":{"precision":3,"placeholder":"请输入","width":"80px"},"model":"gvolNum","label":"体积","type":"number","key":"number_1634199335381"},{"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"140px"},"model":"remark","rules":[{"message":"必填项","required":false}],"label":"备注","type":"input","key":"input_1629790717976"},{"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px"},"model":"dangUnNo","rules":[{"message":"必填项","required":false}],"label":"危险品编号","type":"input","key":"input_1629790718260"},{"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px"},"model":"dangClassNam","rules":[{"message":"必填项","required":false}],"label":"危险品类别","type":"input","key":"input_1629790869109"},{"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px"},"model":"customProcedureCod","rules":[{"message":"必填项","required":false}],"label":"海关手续代码","type":"input","key":"input_1629791119176"},{"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px"},"model":"cargoHsCod","rules":[{"message":"必填项","required":false}],"label":"海关税则编号","type":"input","key":"input_1629791119474"},{"icon":"icon-write","rules":[{"message":"必填项","required":false}],"label":"原产国","type":"input","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px"},"model":"originCountryCod","key":"input_1629791119693"},{"options":{"options":[],"dynamic":3,"placeholder":"请选择","dynamicKey":"1","width":"150px"},"model":"cntrNo","label":"箱号","type":"select","key":"select_1658479988283"}],
          data_正式库_record: {"options":{"hidden":true,"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入"},"model":"正式库","rules":[{"message":"必填项","required":false}],"label":"输入框","type":"input","key":"input_1635760915684"}
        }
      },
      methods: {
        callInMountedCustom(ctos3CommonApi, packageRpcParam){
      this.getGoodsList()
      setTimeout(() => {
                  const wheres2 = []
          const where2 = {}
                  where2.column = 'BILL_ID'
                  where2.condition = 'andeq'
                  where2.v1 = this.billId
          wheres2.push(where2)
          this.ctos3CommonApi('codeService', 'getListWhere', [wheres2, null, '', this.type ==
              'zsk' ? 'IfcsumICtn' : 'IfcsumShutOutCtn'
          ]).then(response => {
              if (response.responseData.statusCode === 0) {
                  var result = response.responseData.resultData
                  var caseNumberList = result
                  caseNumberList.forEach((item) => {
                      item.label = item.cntrNo
                      item.value = item.cntrNo
                  })
                  console.log("caseNumberList", caseNumberList)
                  this.EventBus.$emit('getBatchlookup', ['goodsList', caseNumberList, null,
                      'cntrNo'
                  ])
              }
          })
      }, 200)
  },
  getGoodsList(){
          const wheres = []
      const where1 = {}
      where1.column = 'BILL_ID'
      where1.condition = 'andeq'
      where1.v1 = this.billId
      wheres.push(where1)
      const wheres2 = []
      const where2 = {}
      where2.condition = "leftJoin"
      where2.fieldNames = ["BILL_ID", "SEQ_NO"]
      where2.model = this.type == 'zsk' ? 'IfcsumIGoodsCtn' : 'IfcsumShutOutGoodsCtn'
      where2.modelRefs = ["BILL_ID", "SEQ_NO"]
      where2.refColumns = ["SEQ_NO", 'CNTR_SIZE_COD', 'CNTR_EF_ID', 'CNTR_NO']
      wheres2.push(where2)
      this.ctos3CommonApi('codeService', 'getAndOrm', [wheres, [],
          [], {
              pageNumber: 1,
              pageSize: 1000
          },
          wheres2, this.type == 'zsk' ? 'IfcsumIGoodsBil' : 'IfcsumShutOutGoodsBil'
      ]).then(response => {
          if (response.responseData.statusCode === 0) {
              var result = response.responseData.resultData.list
              var preViewData = {}
              var preViewList = []
              result.forEach(item2 => {
                  if (!preViewData[item2.seqNo]) {
                      preViewList.push(item2);
                      preViewData[item2.seqNo] = item2;
                  }
              })
              preViewList.forEach(item3 => {
                  let cntrNoList = result.filter(item => item3.seqNo == (this.type == 'zsk' ?
                      item.tailInfos.ifcsumIGoodsCtn.seqNo : item.tailInfos
                      .ifcsumShutOutGoodsCtn.seqNo) && item3.seqNo == item.seqNo)
                  item3.cntrNo = cntrNoList.map(item => this.type == 'zsk' ? item.tailInfos
                      .ifcsumIGoodsCtn.cntrNo : item.tailInfos.ifcsumShutOutGoodsCtn.cntrNo)
              })
              this.result = preViewList
              this.setData({
                  'goodsList': preViewList
              })
          }
      })
  },
  handleBusinessCustom(operation){
      if (operation == "close") {
          this.visible = false
      }
  },
  handleChangeCustom(value, key){
  
  
  
  },
  logEventCustom(value, key){
    
  },
  dynamicFuncCustom(operation){
  
  },
  handleDialogBusinessCustom(operation){
  
  }
      }
    }
    </script>