<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_1627292793520 - 动态表格 -->
              <a-form-item label="" :label-col="{}" :wrapper-col="{}" :style="{}" >
                <KBatch v-if="!data_ifcsumCtnTemp_record.options.hidden" ref="KBatch" style="width:100%" v-bind="data_ifcsumCtnTemp_record.options" :recordKey="data_ifcsumCtnTemp_record.key" :optionsKey="data_ifcsumCtnTemp_record.options.key" :baseColumnConfigList="data_ifcsumCtnTemp_BaseColumnList" :model="'ifcsumCtnTemp'" :config="config" :parentDisabled="disabled" :dynamicData="dynamicData" :selectMode="selectMode" :selectDeferred="selectDeferred" :excelName="excelName" :pageId="pageId" @invokeGetFormData="invokeGetFormData" @change="handleChange($event, 'ifcsumCtnTemp')" @logEvent="logEvent($event, 'ifcsumCtnTemp', data_ifcsumCtnTemp_record)" v-decorator="[ 'ifcsumCtnTemp', { }, ]" />
              </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_BATCH_UPDATE_CTN',
            operateBizBtn: [{'hidden':false,'icon':'','hotKey':'','permission':'','label':'关闭','operationMethod':'','sort':0,'params':[],'operation':'close','displayTab':'','displayMode':'flat','direction':'right'},{'hidden':false,'icon':'','hotKey':'','permission':'','label':'修改','operationMethod':'','sort':1,'type':'primary','params':[],'operation':'save','displayTab':''}],
            dialogTitle: '舱单维护_详情',
            dialogServiceName: '',
            dialogWidth: '60%',
            dialogBaseCodeType: '',
            dialogModalType: 'dialog',
            dialogUrl: {'add':'save','update':'updateById'},
    
            data_ifcsumCtnTemp_record: {"icon":"icon-biaoge","label":"动态表格","type":"batch","options":{"mode":"cell","hasPaging":false,"adding":false,"selectType":"none","key":"key","height":"92px","editable":true,"noSerial":true,"deleting":false,"filterPanel":true},"model":"ifcsumCtnTemp","key":"batch_1627292793520"},
            data_ifcsumCtnTemp_BaseColumnList: [{"icon":"icon-write","rules":[{"message":"必填项","required":false}],"label":"箱号","type":"input","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入"},"model":"cntrNo","key":"input_1658300396873"},{"icon":"icon-write","rules":[{"message":"必填项","required":false}],"label":"箱主","type":"input","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入"},"model":"ctnOwner","key":"input_1660555669394"},{"icon":"icon-xiala","options":{"options":[],"dynamic":1,"placeholder":"请选择","dynamicKey":"BasCtnSize,/,cntrSizeCod,cntrSizeCod,,10,,"},"model":"cntrSizeCod","label":"尺寸","type":"select","key":"select_1630653087773"},{"icon":"icon-xiala","options":{"options":[],"dynamic":1,"placeholder":"请选择","dynamicKey":"BasCtnType,/,CntrTypeCod,CntrTypeCod|cCntrTypeNam,,10,,"},"model":"cntrTypeCod","label":"箱型","type":"select","key":"select_1630653195754"},{"icon":"icon-xiala","options":{"options":[],"dynamic":2,"placeholder":"请选择","dynamicKey":"CNTR_EF"},"model":"cntrEfId","label":"空重","type":"select","key":"select_1630653243111"},{"icon":"icon-write","rules":[{"message":"必填项","required":false}],"label":"铅封号","type":"input","options":{"type":"text","placeholder":"请输入"},"model":"sealNo","key":"input_1627292994000"},{"icon":"icon-number","options":{"placeholder":"请输入"},"model":"pieceNum","label":"件数","type":"number","key":"number_1630678743652"},{"icon":"icon-number","label":"重量","type":"number","options":{"precision":3,"step":0.001,"placeholder":"请输入"},"model":"gweightTon","key":"number_1628060041725"},{"icon":"icon-number","label":"体积","type":"number","options":{"precision":3,"step":0.001,"placeholder":"请输入"},"model":"gvolNum","key":"number_1628060043241"}]
          }
        },
        methods: {
          callInMountedCustom(ctos3CommonApi, packageRpcParam){
        setTimeout(function () {
            this.setData({
                'ifcsumCtnTemp': [{
                    'key': '1',
                }]
            })
        }, 200);
    },
    handleBusinessCustom(operation){
            if (operation == 'close') {
            this.visible = false
            console.log(" this.checkIds", this.checkIds)
        }
            if (operation == 'save') {
            this.$confirm({
                title: '请确认',
                content: '确定要修改吗？',
                okText: '确认',
                cancelText: '取消',
                onOk() {
                    setTimeout(function () {
                        this.getData().then((res) => {
                            this.confirmLoading = true
                            const updateObj = []
                            const ifcsumTemp = JSON.parse(JSON.stringify(res
                                .ifcsumCtnTemp[0]))
                            delete ifcsumTemp.key
                            const rpcParamsE = []
                            rpcParamsE.push(this.checkIds)
                            rpcParamsE.push(ifcsumTemp)
                            this.ctos3CommonApi('ifcsumTempService', 'batchUpdCtn',
                                rpcParamsE).then((result) => {
                                if (result.responseData.statusCode === 0) {
                                    this.$message.success('箱信息修改成功')
                                    this.$emit('ok', operation)
                                    this.confirmLoading = false
                                    this.visible = false
                                }
                            }).catch(res => {
                                this.confirmLoading = false
                            })
                        })
                    }, 50);
                },
                onCancel() {},
            })
        }
    },
    handleChangeCustom(value, key){
        if (key == "loadPortCod") {
            if (value && value.indexOf('-') != -1) {
                this.setData({
                    loadPortNam: value.split("-")[0]
                })
            }
        }
        if (key == "dischrgPortCod") {
            if (value && value.indexOf('-') != -1) {
                this.setData({
                    dischrgPortNam: value.split("-")[0]
                })
            }
        }
        if (key == "destPortCod") {
            if (value && value.indexOf('-') != -1) {
                this.setData({
                    destPortNam: value.split("-")[0]
                })
            }
        }
        if (key == "transPortCod") {
            if (value && value.indexOf('-') != -1) {
                this.setData({
                    transPortNam: value.split("-")[0]
                })
            }
        }
        if (key == "packageStr") {
            if (value && value.indexOf('-') != -1) {
                this.setData({
                    packageCod: value.split("-")[1]
                })
            }
        }
        if (key == "changeReasonOne") {
            this.setData({
                changeReasonDesc: value.split("/")[1]
            })
        }
        if (key == "shareId2") {
            if (value.length == 0) {
                this.disable(['shareMarksStr'])
            } else {
                this.enable(['shareMarksStr'])
            }
        }
    },
    logEventCustom(value, key){
       
    },
    dynamicFuncCustom(operation){
        if (operation == "test") {
            if (this.showSign == "0") {
                this.show(["shoufatong"])
                console.log("shoufatong", this.resultData1)
                setTimeout(() => {
                    this.setData(this.resultData1)
                }, 200)
                this.showSign = "1"
            } else {
                this.hide(["shoufatong"])
                this.showSign = "0"
            }
        }
            if (operation == "goodsInfoTemp") {
            this.$emit('ok', operation)
        }
    },
    handleBlurCustom(value, key){
    console.log("wenben",value,key)
    },
    handleDialogBusinessCustom(operation){
    
    }
        }
      }
      </script>