<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" >
            <!-- grid_1636624319693 - 栅格布局 -->
            <a-row v-if="!data_add_record.options.hidden" class="grid-row" :gutter="0" >
              <a-col class="grid-col" :span="24" >
                <div class="build-block" >
                  <!-- grid_1636624130669 - 栅格布局 -->
                  <a-row v-if="!data_grid_1636624130669_record.options.hidden" class="grid-row" :gutter="0" >
                    <a-col class="grid-col" :span="6" >
                      <div class="build-block" >
                        <!-- input_1636624293817 - 唛头 -->
                        <a-form-item :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_marksStr_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>唛头</span>
                            </a-tooltip>
                          </span>
                          <JInput ref="marksStr" :recordModel="'marksStr'" style="width:100px;" placeholder="请输入" type="text" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'marksStr', { rules: [{'message':'必填项','required':true}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- input_1636624336846 - 件数 -->
                        <a-form-item :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_pieceNum_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>件数</span>
                            </a-tooltip>
                          </span>
                          <JInput ref="pieceNum" :recordModel="'pieceNum'" style="width:80px;" placeholder="请输入" type="text" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'pieceNum', { rules: [{'message':'必填项','required':true}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- number_1636624342190 - 重量 -->
                        <a-form-item :colon="true" :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_gweightTon_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>重量</span>
                            </a-tooltip>
                          </span>
                          <a-input-number v-if="!data_gweightTon_record.options.hidden" ref="number_1636624342190" :min=" -Infinity " :max=" Infinity " :precision=" 3 " style="width:80px" placeholder="请输入" @change="handleChange($event, 'gweightTon')" @blur="handleBlur($event.target.value, 'gweightTon')" v-decorator="[ 'gweightTon', { rules: [{'message':'必填项','required':true}] }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- number_1636624363588 - 体积 -->
                        <a-form-item :colon="true" :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_gvolNum_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>体积</span>
                            </a-tooltip>
                          </span>
                          <a-input-number v-if="!data_gvolNum_record.options.hidden" ref="number_1636624363588" :min=" -Infinity " :max=" Infinity " :precision=" 3 " style="width:80px" placeholder="请输入" @change="handleChange($event, 'gvolNum')" @blur="handleBlur($event.target.value, 'gvolNum')" v-decorator="[ 'gvolNum', { rules: [{'message':'必填项','required':true}] }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- select_1634200070484 - 箱号 -->
                        <a-form-item :colon="true" :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_cntrNo2_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>箱号</span>
                            </a-tooltip>
                          </span>
                          <j-dict-select-tag v-if="!data_cntrNo2_record.options.hidden" :options=" dynamicData['caseNumberList'] " :dynamic="3" :dictCode="`caseNumberList`" style="width:120px" :multiple="true" placeholder="请选择" @change="handleChange($event, 'cntrNo2')" v-decorator="[ 'cntrNo2', { rules: [{'message':'必填项','required':true}] }, ]" />
                        </a-form-item>
                      </div>
                    </a-col>
                    <a-col class="grid-col" :span="6" >
                      <div class="build-block" >
                        <!-- textarea_1656902454430 - 英文货名 -->
                        <a-form-item :colon="true" :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_eCargoNam_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>英文货名</span>
                            </a-tooltip>
                          </span>
                          <JTextArea v-if="!data_eCargoNam_record.options.hidden" ref="textarea_1656902454430" style="width:100%;" placeholder="请输入" :rows="3" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'eCargoNam', { rules: [{'message':'必填项','required':true}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- textarea_1656902587385 - 备注 -->
                        <a-form-item :colon="true" :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_remark_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>备注</span>
                            </a-tooltip>
                          </span>
                          <JTextArea v-if="!data_remark_record.options.hidden" ref="textarea_1656902587385" style="width:100%;" placeholder="请输入" :rows="3" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'remark', { }, ]" />
                        </a-form-item>
                      </div>
                    </a-col>
                    <a-col class="grid-col" :span="6" >
                      <div class="build-block" >
                        <!-- input_1636624299665 - 包装代码 -->
                        <a-form-item :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_packageCod_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>包装代码</span>
                            </a-tooltip>
                          </span>
                          <JInput ref="packageCod" :recordModel="'packageCod'" style="width:100px;" :disabled="true" placeholder="请输入" type="text" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'packageCod', { rules: [{'message':'必填项','required':true}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- input_1629790869109 - 危险品类别 -->
                        <a-form-item :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_dangClassNam_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>危险品类别</span>
                            </a-tooltip>
                          </span>
                          <JInput ref="dangClassNam" :recordModel="'dangClassNam'" style="width:120px;" placeholder="请输入" type="text" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'dangClassNam', { rules: [{'message':'必填项','required':false}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- input_1636624388337 - 海关手续代码 -->
                        <a-form-item :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_customProcedureCod_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>海关手续代码</span>
                            </a-tooltip>
                          </span>
                          <JInput ref="customProcedureCod" :recordModel="'customProcedureCod'" style="width:120px;" placeholder="请输入" type="text" :maxLength="1" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'customProcedureCod', { rules: [{'message':'必填项','required':false}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- input_1636624395629 - 原产国 -->
                        <a-form-item :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_originCountryCod_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>原产国</span>
                            </a-tooltip>
                          </span>
                          <JInput ref="originCountryCod" :recordModel="'originCountryCod'" style="width:120px;" placeholder="请输入" type="text" :maxLength="2" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'originCountryCod', { rules: [{'message':'必填项','required':false}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                    </a-col>
                    <a-col class="grid-col" :span="6" >
                      <div class="build-block" >
                        <!-- select_1636624302533 - 包装名称 -->
                        <a-form-item :colon="true" :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_packageStr_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>包装名称</span>
                            </a-tooltip>
                          </span>
                          <!--dict-->
                          <!--model,joinSymbol,valueField,labelField,wheres,limit,order,orderColumn-->
                          <!--wheres-->
                          <!--column|operation|value%column|operation|value%...-->
                          <j-search-select-tag v-if="!data_packageStr_record.options.hidden" style="width:100px" placeholder="请选择" :getFieldItemValue="getFieldItemValue" @change="handleChange($event, 'packageStr')" @handleSelectChange= "handleSelectChange" v-decorator="[ 'packageStr', { rules: [{'message':'必填项','required':true}] }, ]" :dict="`BasPackage,-,ePackageNam|packageCod,ePackageNam,,200,,`" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- input_1636624380860 - 危险品编号 -->
                        <a-form-item :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_dangUnNo_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>危险品编号</span>
                            </a-tooltip>
                          </span>
                          <JInput ref="dangUnNo" :recordModel="'dangUnNo'" style="width:120px;" placeholder="请输入" type="text" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'dangUnNo', { rules: [{'message':'必填项','required':false}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                      <div class="build-block" >
                        <!-- input_1636628054683 - 海关税则编号 -->
                        <a-form-item :label-col="{'style':'width:100px'}" :wrapper-col="{'style':'width:auto; flex:1'}" :style="data_cargoHsCod_record.options.hidden ? 'display: none' : 'display: flex'" >
                          <span slot="label">
                            <a-tooltip>
                              <span>海关税则编号</span>
                            </a-tooltip>
                          </span>
                          <JInput ref="cargoHsCod" :recordModel="'cargoHsCod'" style="width:120px;" placeholder="请输入" type="text" :maxLength="8" @focus="handleFocus" @change="handleChange" @blur="handleBlur" @enter="handleEnter" v-decorator="[ 'cargoHsCod', { rules: [{'message':'必填项','required':false}], validateTrigger: 'blur' }, ]" />
                        </a-form-item>
                      </div>
                    </a-col>
                  </a-row>
                </div>
                <div class="build-block" >
                  <!-- grid_1636625628669 - 栅格布局 -->
                  <a-row class="grid-row" :gutter="0" >
                    <a-col class="grid-col" :span="10" >
                    </a-col>
                    <a-col class="grid-col" :span="12" >
                      <div class="build-block" >
                        <!-- buttonGroup_1636625050484 - 按钮组 -->
                        <a-button-group v-if="!data_buttonGroup_1636625050484_record.options.hidden" class="grid-row" >
                          <div class="build-block" >
                            <!-- button_1636625055989 - 保存 -->
                            <a-form-item :wrapper-col="{'offset':0,'span':24}" :style="data_save_record.options.hidden ? 'display: none' : 'display: flex'" >
                              <a-button @click=" dynamicData['commonFunc']( 'save', {} ) " type="primary" :block="false" :style="{'verticalAlign':'middle','textAlign':'center'}" > 保存 </a-button>
                            </a-form-item>
                          </div>
                          <div class="build-block" >
                            <!-- button_1636625072970 - 取消 -->
                            <a-form-item :wrapper-col="{'offset':0,'span':24}" :style="data_cancel_record.options.hidden ? 'display: none' : 'display: flex'" >
                              <a-button @click=" dynamicData['commonFunc']( 'cancel', {} ) " type="primary" :block="false" :style="{'verticalAlign':'middle','textAlign':'center'}" > 取消 </a-button>
                            </a-form-item>
                          </div>
                        </a-button-group>
                      </div>
                    </a-col>
                  </a-row>
                </div>
              </a-col>
            </a-row>
          </div>
          <div class="build-block" >
            <!-- buttonGroup_1642579353357 - 按钮组 -->
            <a-button-group v-if="!data_buttonGroup_1642579353357_record.options.hidden" class="grid-row" >
              <div class="build-block" >
                <!-- button_1636625156790 - 新增 -->
                <a-form-item :wrapper-col="{'offset':0,'span':24}" :style="data_addBtn_record.options.hidden ? 'display: none' : 'display: flex'" >
                  <a-button @click=" dynamicData['commonFunc']( 'add', {} ) " type="primary" :block="false" :style="{'verticalAlign':'middle','textAlign':'center'}" > 新增 </a-button>
                </a-form-item>
              </div>
            </a-button-group>
          </div>
          <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_1636625242729 - 舱单维护 -->
            <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',
          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_add_record: {'key':'grid_1636624319693','type':'grid','model':'add','options':{'gutter':0,'hidden':true}},
          data_grid_1636624130669_record: {'key':'grid_1636624130669','type':'grid','model':'grid_1636624130669','options':{'gutter':0,'hidden':false}},
          data_marksStr_record: {"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"100px"},"model":"marksStr","rules":[{"message":"必填项","required":true}],"label":"唛头","type":"input","key":"input_1636624293817"},
          data_pieceNum_record: {"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"80px"},"model":"pieceNum","rules":[{"message":"必填项","required":true}],"label":"件数","type":"input","key":"input_1636624336846"},
          data_gweightTon_record: {"icon":"icon-number","options":{"precision":3,"placeholder":"请输入","width":"80px"},"model":"gweightTon","rules":[{"message":"必填项","required":true}],"label":"重量","type":"number","key":"number_1636624342190"},
          data_gvolNum_record: {"icon":"icon-number","options":{"precision":3,"placeholder":"请输入","width":"80px"},"model":"gvolNum","rules":[{"message":"必填项","required":true}],"label":"体积","type":"number","key":"number_1636624363588"},
          data_cntrNo2_record: {"options":{"options":[],"dynamic":3,"placeholder":"请选择","dynamicKey":"caseNumberList","multiple":true,"width":"120px"},"model":"cntrNo2","rules":[{"message":"必填项","required":true}],"label":"箱号","type":"select","key":"select_1634200070484"},
          data_eCargoNam_record: {"icon":"icon-edit","options":{"maxRows":3,"placeholder":"请输入","minRows":2,"customClass":""},"model":"eCargoNam","rules":[{"message":"必填项","required":true}],"label":"英文货名","type":"textarea","key":"textarea_1656902454430"},
          data_remark_record: {"icon":"icon-edit","options":{"maxRows":3,"placeholder":"请输入","minRows":2,"customClass":""},"model":"remark","label":"备注","type":"textarea","key":"textarea_1656902587385"},
          data_packageCod_record: {"icon":"icon-write","options":{"type":"text","width":"100px","disabled":true,"placeholder":"请输入"},"rules":[{"message":"必填项","required":true}],"model":"packageCod","label":"包装代码","type":"input","key":"input_1636624299665"},
          data_dangClassNam_record: {"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"},
          data_customProcedureCod_record: {"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px","maxLength":1},"model":"customProcedureCod","rules":[{"message":"必填项","required":false}],"label":"海关手续代码","type":"input","key":"input_1636624388337"},
          data_originCountryCod_record: {"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px","maxLength":2},"model":"originCountryCod","rules":[{"message":"必填项","required":false}],"label":"原产国","type":"input","key":"input_1636624395629"},
          data_packageStr_record: {"icon":"icon-xiala","options":{"options":[],"dynamic":1,"placeholder":"请选择","labelCol":{"span":2},"dynamicKey":"BasPackage,-,ePackageNam|packageCod,ePackageNam,,200,,","wrapperCol":{"span":22},"width":"100px"},"model":"packageStr","rules":[{"message":"必填项","required":true}],"label":"包装名称","type":"select","key":"select_1636624302533"},
          data_dangUnNo_record: {"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_1636624380860"},
          data_cargoHsCod_record: {"icon":"icon-write","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px","maxLength":8},"model":"cargoHsCod","rules":[{"message":"必填项","required":false}],"label":"海关税则编号","type":"input","key":"input_1636628054683"},
          data_buttonGroup_1636625050484_record: {'key':'buttonGroup_1636625050484','type':'buttonGroup','model':'buttonGroup_1636625050484','options':{'gutter':0,'hidden':false}},
          data_save_record: {"icon":"icon-button-remove","options":{"type":"primary","dynamicFun":"save"},"model":"save","label":"保存","type":"button","key":"button_1636625055989"},
          data_cancel_record: {"icon":"icon-button-remove","options":{"type":"primary","dynamicFun":"cancel"},"model":"cancel","label":"取消","type":"button","key":"button_1636625072970"},
          data_buttonGroup_1642579353357_record: {'key':'buttonGroup_1642579353357','type':'buttonGroup','model':'buttonGroup_1642579353357','options':{'gutter':0,'hidden':false}},
          data_addBtn_record: {"options":{"type":"primary","dynamicFun":"add"},"model":"addBtn","label":"新增","type":"button","key":"button_1636625156790"},
          data_goodsList_record: {"label":"动态表格","type":"batch","options":{"mode":"row","updating":false,"adding":false,"height":"40vh","columnChooser":false,"lazyNoPaging":true,"hasPaging":false,"showDeleteBtn":true,"key":"id","editable":true},"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_1652972987356"},{"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_1636624382298"},{"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","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px"},"model":"originCountryCod","rules":[{"message":"必填项","required":false}],"label":"原产国","type":"input","key":"input_1629791119693"},{"icon":"icon-write","label":"箱号","type":"input","options":{"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入","width":"120px","customClass":""},"model":"cntrNo","key":"input_1652972623843"}],
          data_舱单维护_record: {"options":{"hidden":true,"filterOperations":["contains","notcontains","startswith","endswith","=","<>"],"type":"text","placeholder":"请输入"},"model":"舱单维护","rules":[{"message":"必填项","required":false}],"label":"舱单维护","type":"input","key":"input_1636625242729"}
        }
      },
      methods: {
        callInMountedCustom(ctos3CommonApi, packageRpcParam){
      this.result = []
      this.getDataList()
          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, '', 'IfcsumTempCtn'])
              .then(response => {
                  if (response.responseData.statusCode === 0) {
                      var result = response.responseData.resultData
                      var caseNumberList = []
                      result.forEach((item) => {
                          if (!caseNumberList.find(item2 => item2.label == item.cntrNo)) {
                              caseNumberList.push({
                                  label: item.cntrNo,
                                  value: item.id
                              })
                          }
                      })
                      this.ctnList = result
                      this.$set(this.dynamicData, 'caseNumberList', caseNumberList)
                      this.EventBus.$emit('getBatchlookup', ['goodsList', caseNumberList, null,
                          'cntrNo'
                      ])
                  }
              })
      }, 200)
  },
  getDataList(){
          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"]
      where2.model = "IfcsumTempGoodsCtn"
      where2.modelRefs = ["BILL_ID"]
      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, 'IfcsumTempGoodsBil'
      ]).then(response => {
          if (response.responseData.statusCode === 0) {
              var result = response.responseData.resultData.list
              result = result.filter(item => item.seqNo == item.tailInfos.ifcsumTempGoodsCtn.seqNo)
              for (var i = 0; i < result.length; i++) {
                  var seqNo = result[i].seqNo
                  result[i].cntrNo2 = []
                  result.forEach((item2, index) => {
                      if (item2.seqNo == seqNo) {
                          let ctn = this.ctnList.find(item => item.cntrNo = item2.tailInfos
                              .ifcsumTempGoodsCtn.cntrNo)
                          result[i].cntrNo2.push(ctn.id)
                      }
                  })
                  result[i].cntrNo = result[i].cntrNo2.toString()
              }
              result = result.filter((item, index) => {
                  return result.findIndex(item1 => item1.id == item.id) == index
              })
              this.result = result
              console.log("result", result)
              this.setData({
                  'goodsList': result
              })
          }
      })
  },
  handleBusinessCustom(operation){
      if (operation == 'close') {
          this.visible = false
      }
  },
  handleChangeCustom(value, key){
      if (key == "packageStr") {
          this.setData({
              packageCod: value.split("-")[1]
          })
      }
  },
  logEventCustom(value, key){
          if (value.event === 'onRowRemoved' && key === 'goodsList') {
          const removeId = [value.data.id]
          this.ctos3CommonApi('ifcsumTempService', 'deleteIfcsumTempGoodsByIds', [removeId]).then((
          result) => {
              if (result.responseData.statusCode === 0) {
                  this.$message.success('数据删除成功')
                  this.getDataList()
              } else {
                  this.$message.error('数据删除失败')
              }
          })
      }
          if (value.event === 'onRowClick' && key === 'goodsList') {
          this.sign = "edit"
          this.updateObj = value.data
          this.show(['add'])
          setTimeout(() => {
              this.setData(value.data)
              this.setData({
                  'cntrNo2': value.data.cntrNo2
              })
          }, 400)
      }
          if (value.event == "deleteSelection" && key == "goodsList") {
          var ids = this.result.filter(item => !value.data.includes(item))
          const removeIds = ids.map(item2 => item2.id)
          if (removeIds.length > 0) {
              this.ctos3CommonApi('ifcsumTempService', 'deleteIfcsumTempGoodsByIds', [removeIds]).then((
                  result) => {
                  if (result.responseData.statusCode === 0) {
                      this.$message.success('数据删除成功')
                      this.getDataList()
                  } else {
                      this.$message.error('数据删除失败')
                  }
              })
          }
      }
  },
  dynamicFuncCustom(operation){
      if (operation == "add") {
          this.sign = "add"
          this.show(["add"])
      }
      if (operation == "save") {
          this.getData().then(res => {
              if (this.sign == "add") {
                  var insertObj = JSON.parse(JSON.stringify(res))
                  insertObj.packageStr = res.packageStr.split('-')[0]
                  insertObj.billId = this.billId
                  delete insertObj.id
                  const wheres = []
                  const where1 = {}
                  where1.column = 'BILL_ID'
                  where1.condition = 'andeq'
                  where1.v1 = this.billId
                  wheres.push(where1)
                  this.ctos3CommonApi('codeService', 'getListWhere', [
                      wheres, "", "", 'IfcsumTempGoodsBil'
                  ]).then(response => {
                      if (response.responseData.statusCode === 0) {
                          const result = response.responseData.resultData
                          var seqNo = 0
                          if (result.length > 0) {
                              seqNo = Math.max.apply(null, result.map((item) => item.seqNo))
                          }
                          insertObj.seqNo = seqNo + 1
                          this.ctos3CommonApi('codeService', 'insert', [insertObj,
                              'IfcsumTempGoodsBil'
                          ]).then((result) => {
                              if (result.responseData.statusCode === 0) {
                                  var res = result.responseData.resultData
                                  let key = []
                                  insertObj.cntrNo2.forEach(item2 => {
                                      let ctn = this.ctnList.find(i => i
                                          .id == item2)
                                      let obj = {}
                                      obj.cntrNo = ctn.cntrNo
                                      obj.billId = this.billId
                                      obj.seqNo = res.seqNo
                                      obj.cntrTypeCod = ctn.cntrTypeCod
                                      obj.cntrEfId = ctn.cntrEfId
                                      obj.cntrSizeCod = ctn.cntrSizeCod
                                      key.push(obj)
                                  })
                                  setTimeout(function () {
                                      this.insertCtn(key, res.id)
                                  }, 50);
                              }
                          })
                      }
                  })
              } else if (this.sign == "edit") {
                  var updateObj = JSON.parse(JSON.stringify(this.updateObj))
                  if (res.packageStr.indexOf("-") != -1) {
                      updateObj.packageStr = res.packageStr.split('-')[0]
                  } else {
                      updateObj.packageStr = res.packageStr
                  }
                  updateObj.marksStr = res.marksStr
                  updateObj.remark = res.remark
                  updateObj.ecargoNam = res.ecargoNam
                  updateObj.packageCod = res.packageCod
                  updateObj.pieceNum = res.pieceNum
                  updateObj.gweightTon = res.gweightTon
                  updateObj.gvolNum = res.gvolNum
                  updateObj.dangUnNo = res.dangUnNo
                  updateObj.dangClassNam = res.dangClassNam
                  updateObj.customProcedureCod = res.customProcedureCod
                  updateObj.cargoHsCod = res.cargoHsCod
                  updateObj.originCountryCod = res.originCountryCod
                  this.ctos3CommonApi('codeService', 'updateTemplateById', [updateObj,
                      'IfcsumTempGoodsBil'
                  ]).then((result) => {
                      if (result.responseData.statusCode === 0) {
                          const wheres = []
                          const where1 = {}
                          where1.column = 'BILL_ID'
                          where1.condition = 'andeq'
                          where1.v1 = this.updateObj.billId
                          wheres.push(where1)
                          const where2 = {}
                          where2.column = 'SEQ_NO'
                          where2.condition = 'andeq'
                          where2.v1 = this.updateObj.seqNo
                          wheres.push(where2)
                          this.ctos3CommonApi('codeService', 'delete', [wheres,
                              'IfcsumTempGoodsCtn'
                          ]).then((result) => {
                              if (result.responseData.statusCode === 0) {
                                  let key = []
                                  res.cntrNo2.forEach(item2 => {
                                      let ctn = this.ctnList.find(i => i
                                          .id == item2)
                                      let obj = {}
                                      debugger
                                      obj.cntrNo = ctn.cntrNo
                                      obj.billId = this.updateObj.billId
                                      obj.seqNo = this.updateObj.seqNo
                                      obj.cntrTypeCod = ctn.cntrTypeCod
                                      obj.cntrEfId = ctn.cntrEfId
                                      obj.cntrSizeCod = ctn.cntrSizeCod
                                      key.push(obj)
                                  })
                                  setTimeout(function () {
                                      this.insertCtn(key, context
                                          .updateObj.billId)
                                  }, 50);
                              }
                          })
                      } else {
                          this.$message.error('数据更新失败')
                      }
                  })
              }
          })
      }
      if (operation == "cancel") {
          this.hide(["add"])
      }
  },
  insertCtn(obj, goodsBilId){
      this.ctos3CommonApi('codeService', 'insertBatch', [obj, 'IfcsumTempGoodsCtn']).then((result) => {
          if (result.responseData.statusCode === 0) {
              var res = result.responseData.resultData
              this.$message.success('数据保存成功')
              this.reset(['marksStr', 'eCargoNam', 'packageCod', 'pieceNum', 'gweightTon',
                  'gvolNum', 'remark', 'dangUnNo', 'dangClassNam', 'customProcedureCod',
                  'cargoHsCod', 'originCountryCod', 'cntrNo'
              ])
              this.hide(["add"])
              this.getDataList()
          }
      }).catch((res) => {
          ctos3CommonApi('codeService', 'deleteById', [goodsBilId, 'IfcsumTempGoodsBil']).then((
              result) => {})
      })
  },
  handleDialogBusinessCustom(operation){
  
  }
      }
    }
    </script>