<template>
  <!-- 新增成衣 -->
  <div id="clothesAddDrawer">
    <a-drawer
      title="新增成衣"
      width="89%"
      placement="right"
      :closable="true"
      :visible="visible"
      @close="handleCancel">
      <!-- 主表信息 填写-->
      <a-card :bordered="true">
        <div class="table-page-search-wrapper">
          <a-form-model layout="inline" ref="formModel" :model="clothesAdd" :rules="validatorRules">
            <a-row :gutter="24">
              <a-col :md="6" :sm="8">
                <a-form-model-item label="订单号" prop="orderNum">
                  <a-input placeholder="请输入订单号" v-model="clothesAdd.orderNum"></a-input>
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="款号" prop="styleNum">
                  <a-input placeholder="请输入款号" v-model="clothesAdd.styleNum"></a-input>
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="品名" prop="name">
                  <a-input placeholder="请输入品名" v-model="clothesAdd.name"></a-input>
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="尺码范围" prop="sizeRange">
                  <a-input placeholder="请输入尺码范围" v-model="clothesAdd.sizeRange"></a-input>
                  <!-- <a-select placeholder="请选择尺码范围">
                <a-select-option value="">请选择</a-select-option>
                <a-select-option value="0">客户1</a-select-option>
                <a-select-option value="1">客户2</a-select-option>
                <a-select-option value="2">客户3</a-select-option>
              </a-select> -->
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="客户" prop="customer">
                  <a-input placeholder="请输入客户" v-model="clothesAdd.customer"></a-input>
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="集装箱代号" prop="containerCode">
                  <a-input placeholder="请输入集装箱代号" v-model="clothesAdd.containerCode"></a-input>
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="集装箱号" prop="containerNo">
                  <a-input placeholder="请输入集装箱号" v-model="clothesAdd.containerNo"></a-input>
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="备注" prop="note">
                  <a-input placeholder="请输入备注" v-model="clothesAdd.note"></a-input>
                </a-form-model-item>
              </a-col>

              <!-- <a-col :md="6" :sm="8">
                <a-form-model-item label="成衣工厂" prop="clothesFactory">
                  <a-input placeholder="请输入成衣工厂" v-model="clothesAdd.clothesFactory"></a-input>
                </a-form-model-item>
              </a-col> -->

              <a-col :md="6" :sm="8">
                <a-form-model-item label="外销发票号" prop="exportInvoiceNo">
                  <a-input placeholder="请输入外销发票号" v-model="clothesAdd.exportInvoiceNo"></a-input>
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="托书号" prop="bookNum">
                  <a-input placeholder="请输入托书号" v-model="clothesAdd.bookNum"></a-input>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-form-model>
        </div>
      </a-card>

      <!--操作按钮区域 参照预装箱单 増行-->
      <a-card :bordered="true" style="margin:10px 0 60px 0;">
        <!-- <div class="table-operator">
          <a-button type="primary" @click="referadvancePackingList" icon="ordered-list">参照预装箱单</a-button>
          <a-button type="primary" @click="handleAddColumn" icon="plus" style="margin-left: 20px">増行</a-button>
        </div> -->

        <!-- 子表 :pagination="ipagination"  -->
        <a-spin :spinning="confirmLoading">
          <a-form-model ref="formRef">
            <j-vxe-table
              ref="vTable"
              toolbar
              row-number
              row-selection
              drag-sort
              keep-source
              :height="300"
              :loading="loading"
              :dataSource="clothesAddData"
              :columns="clothesAddColumns"
              :alwaysEdit=true
              :bordered=true
              :scroll="{ x: 1500 }"
              style="margin-top: 5px;"
              :toolbarConfig="toolbarConfig"
              @valueChange="handleValueChange"
            >
            <template v-slot:action="props">
              <a @click="copy(props)">复制</a>
              <a-divider type="vertical"/>
              <a-popconfirm title="确定删除吗？" @confirm="handleDelete(props)">
                <a>删除</a>
              </a-popconfirm>
            </template>
            <template v-slot:toolbarSuffix>
              <a-button type="primary" @click="referadvancePackingList" icon="ordered-list">参照预装箱单</a-button>
            </template>
            </j-vxe-table>
          </a-form-model>
          <!-- <a-form-model ref="formRef" :rules="validatorRules">
            <a-table
              bordered
              :row-key="record => record.id"
              :columns="clothesAddColumns"
              :data-source="clothesAddData"
              :loading="loading"
              :pagination="pagination"
              :scroll="{ x: 1500 }"
              @change="handleTableChange"
            > -->
              <!-- 启始箱号 输入框-->
              <!-- <template slot="inceptionBoxNo" slot-scope="text, record, index">
                <a-form-model-item prop="inceptionBoxNo" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.startingBoxNumber" />
                </a-form-model-item>
              </template> -->

              <!-- 结束箱号 输入框-->
              <!-- <template slot="endBoxNo" slot-scope="text, record, index">
                <a-form-model-item prop="endBoxNo" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.endCaseNumber" />
                </a-form-model-item>
              </template> -->

              <!-- 件数/箱 输入框-->

              <!-- <template slot="packagesBox" slot-scope="text, record, index">
                <a-form-model-item prop="packagesBox" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.piecesBox" />
                </a-form-model-item>
              </template> -->

              <!--箱数 输入框-->
              <!-- <template slot="boxes" slot-scope="text, record, index">
                <a-form-model-item prop="boxes" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.boxNumber" />
                </a-form-model-item>
              </template> -->

              <!--净重/箱 输入框-->
              <!-- <template slot="suttle" slot-scope="text, record, index">
                <a-form-model-item prop="suttle" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.netWeight" />
                </a-form-model-item>
              </template> -->

              <!--毛重/箱 输入框-->
              <!-- <template slot="roughWeight" slot-scope="text, record, index">
                <a-form-model-item prop="roughWeight" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.grossWeight" />
                </a-form-model-item>
              </template> -->

              <!--外箱长度 输入框-->
              <!-- <template slot="boxLength" slot-scope="text, record, index">
                <a-form-model-item prop="boxLength" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.outerBoxLength" />
                </a-form-model-item>
              </template> -->

              <!--外箱宽度 输入框-->
              <!-- <template slot="boxWidth" slot-scope="text, record, index">
                <a-form-model-item prop="boxWidth" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.outerBoxWidth" />
                </a-form-model-item>
              </template> -->

              <!--外箱高度 输入框-->

              <!-- <template slot="boxHeight" slot-scope="text, record, index">
                <a-form-model-item prop="boxHeight" :rules="rules.styleNum" required>
                  <a-input style="width:100%" type="text" v-model="record.outerBoxHeight" />
                </a-form-model-item>
              </template> -->

              <!-- 操作 -->
              <!-- <span slot="operationSlot" slot-scope="text, record">
                <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete(record.id)">
                  <a href="javascript:void(0);" style="color:red;">删除</a>
                </a-popconfirm>
                <a-divider type="vertical" />
                <a @click="copy(record)">复制</a>
              </span>
            </a-table>
          </a-form-model> -->
        </a-spin>
      </a-card>
      <!-- 页面底部提交取消 -->
      <div
        :style="{
          position: 'absolute',
          right: 0,
          bottom: 0,
          width: '100%',
          borderTop: '1px solid #e9e9e9',
          padding: '10px 16px',
          background: '#fff',
          textAlign: 'right',
          zIndex: 1
        }"
      >
        <a-popconfirm title="确定放弃新增？" @confirm="handleCancel" okText="确定" cancelText="取消">
          <a-button :style="{ marginRight: '8px' }">取消</a-button>
        </a-popconfirm>
        <a-button type="primary" @click="submitAdd">
          保存
        </a-button>
      </div>
    </a-drawer>

    <!-- 参照预装箱单 -->
    <reference-pre-packlist ref="ReferencePrePacklist" @callback='referCallback' :father="aa" @ok="modalFormOk"></reference-pre-packlist>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import JEllipsis from '@/components/jeecg/JEllipsis'
import ReferencePrePacklist from '@views/packing-list/packinglist-clothes/referencePrePacklist'
import { orderSpltListId,addSpltList,editSpltList } from '@api/document/packing-list/packinglist-clothes.js'


export default {
  name: 'ClothesAddDrawer', //  新增-装箱单 -成衣
  mixins: [JeecgListMixin],
  computed: {},
  components: { ReferencePrePacklist, JEllipsis }, // 参照预装箱单 弹框
  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />

    return {

      toolbarConfig: {
          // add 新增按钮；remove 删除按钮；clearSelection 清空选择按钮
          btn: []
        },
      // 表头
      clothesAddColumns: [
        {
          title: '账套',
          key: 'acSetNo',
          width: 160,
          fixed: 'left',
           type: JVXETypes.normal,
        },
        {
          title: '成衣工厂',
          key: 'garmentFactory',
          width: 120,
          fixed: 'left',
           type: JVXETypes.normal,
        },
        {
          title: 'HOD',
          key: 'hod',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: 'STYLE NO.',
          key: 'styleNo',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: 'PO NO.',
          key: 'poNo',
          width: 90,
           type: JVXETypes.normal,
        },

        {
          title: 'ITEM NO./SKU NO./UPC NO./PACKS CODE',
          key: 'itemCode',
          width: 340,
          type: JVXETypes.normal,
        },
        {
          title: '分销点/DC/LABEL',
          key: 'distributionPoint',
          width: 200,
          type: JVXETypes.normal,
          insertAfter:true,
        },
        {
          title: '启始箱号',
          key: 'startingBoxNumber',
          type: JVXETypes.inputNumber ,
          width: 120,
        },

        {
          title: '结束箱号',
          key: 'endCaseNumber',
          width: 120,
          type: JVXETypes.inputNumber 
        },

        {
          title: '颜色（中英文）',
          key: 'colour',
          width: 140,
         type: JVXETypes.input,
        },
        {
          title: '配码',
          key: 'withCode',
          width: 120,
         type: JVXETypes.normal,
        },
        {
          title: '件数/箱',
          key: 'piecesBox',
          width: 120,
          type: JVXETypes.normal 
        },
        {
          title: '箱数',
          key: 'boxNumber',
          width: 120,
          type: JVXETypes.normal 
        },
         {
          title: '计划尺码数量',
          key: 'planSize',
          width: 240,
          type: JVXETypes.normal ,
        },
        {
          title: '计划装箱数量',
          key: 'planQuantity',
          width: 240,
          type: JVXETypes.normal ,
        },

        {
          title: '总件数',
          key: 'total',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '净重/箱',
          key: 'netWeight',
          width: 120,
          type: JVXETypes.inputNumber 
        },
        {
          title: '总净重',
          key: 'totalNetWeight',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '毛重/箱',
          key: 'grossWeight',
          width: 120,
          type: JVXETypes.inputNumber 
        },
        {
          title: '总毛重',
          key: 'totalGrossWeight',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '外箱长度',
          key: 'outerBoxLength',
          width: 120,
         type: JVXETypes.inputNumber 
        },
        {
          title: '外箱宽度',
          key: 'outerBoxWidth',
          width: 120,
          type: JVXETypes.inputNumber 
        },
        {
          title: '外箱高度',
          key: 'outerBoxHeight',
          width: 120,
          type: JVXETypes.inputNumber 
        },
        {
          title: '总体积',
          key: 'totalVolume',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '净净重',
          key: 'netWeightToo',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '单价',
          key: 'unitPrice',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '总价',
          key: 'totalPrice',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '备注',
          key: 'remarks',
          width: 140,
          customRender: t => ellipsis(t),
          fixed: 'right',
          type: JVXETypes.normal,
        },
        {
          title: '操作',
          key: 'operation',
          type: JVXETypes.slot,
          width: 160,
          fixed: 'right',
          align: 'center',
            slotName: 'action',
        }
      ],
      clothesAddData: [],
      loading: false, // 表格加载
      clothesAdd: {},
       pagination: {
        // total: '',
        // current: 0,
        // pageSize: 0
      },
      editDecide:'add',
      visible: false,
      sizeFields:[], // 尺码字段
      confirmLoading: false,
      validatorRules: {
        orderNum: [{ required: true, message: '订单号不能为空', trigger: 'blur' }],
        styleNum: [{ required: true, message: '款号不能为空', trigger: 'blur' }],
        name: [{ required: true, message: '品名不能为空', trigger: 'blur' }]
        // 待确定还有哪些必填信息
      }
      // dateFormat: 'YYYY-MM-DD'
    }
  },
   // 接收父组件查询方法
  props: {
    fatherList: {
      type: Function,
      default: null
    }
  },
  created() {},
  mounted() {},
  methods: {
    // 参照回调
    referCallback(idArr){
     this.clothesAdd = {}
     this.clothesAddData = []
     var preId = idArr[0]
     orderSpltListId({id:preId}).then(res => {
          var data = res.result
          if (res.success) {
            this.clothesAdd = {
              orderNum: data.orderNumber,
              styleNum: data.itemNumber,
              name: data.productName,
              sizeRange: data.sizeRange,
              customer:  data.customer,
              containerCode: data.containerCode,
              containerNo: data.containerNumber,
              note: data.u8Remarks,
              // clothesFactory: data.garmentFactory,
              exportInvoiceNo: data.exportInvoiceNo,
              bookNum: data.depositaryReceiptNo
            }
          this.dynamicColumns(data.sizeTables)
          this.clothesAddData = data.syPackingListTailoringItemList
          this.clothesAddData.map(item =>{
              var str =item.hod
              var n=str.split(" ");
              item.hod = n[0]
              var row = item;
              var sizeTables = row.sizeTables;
              for (var j=0; j<sizeTables.length;j++){
               row['size-'+sizeTables[j].size] = sizeTables[j].proportion;
              }
            })
          }else {
            this.$message.error(res.message);
          }
        })
    },

    dynamicColumns(sizeTables){
       var newColumns = this.clothesAddColumns
       this.sizeFields = [];
        if (sizeTables != null){
          var i = 0
        for(;i < newColumns.length ; i++){
         if(newColumns[i].insertAfter){
           break;
         }
       }
        // 插入数据
        for (var j=0;j<sizeTables.length;j++){
          this.sizeFields.push('size-'+sizeTables[j].size);
          var field = {
              title: sizeTables[j].size,
              key: 'size-'+sizeTables[j].size,
              type: JVXETypes.inputNumber ,
              width: 80,
              isSize:true,
          };
          newColumns.splice(i+1+j,0,field);
        }
        this.clothesAddColumns = newColumns
        }
    },
     
    // 参照预装箱单
    referadvancePackingList() {
      console.log('打开参照订单数据')
      // 打开订单数据弹框
      this.$refs.ReferencePrePacklist.referencePrePacklist = true
      this.$refs.ReferencePrePacklist.queryParam = {}
      this.$refs.ReferencePrePacklist.searchQuery()
    },
    // 増行
    handleAddColumn() {
      console.log('増行')
      const addrow = {
        accountSet: '',
        garmentFactory: '',
        hod: '',
        styleNo: '',
        poNo: '',
        itemCode: '',
        distributionPoint: '',
        s: '',
        m: '',
        l: '',
        xl: '',
        xxl: '',
        xxxl: '',
        startingBoxNumber: '',
        endCaseNumber: '',
        colour: '',
        withCode: '',
        piecesBox: '',
        boxNumber: '',
        total: '',
        netWeight: '',
        totalNetWeight: '',
        grossWeight: '',
        totalGrossWeight: '',
        outerBoxLength: '',
        outerBoxWidth: '',
        outerBoxHeight: '',
        totalVolume: '',
        netWeightToo: '',
        unitPrice: '',
        totalPrices: '',
        remarks: '',
        operation: ''
      }
      this.clothesAddData.push(addrow)
    },

    // -------------------------------------
    // 操作 删除
    handleDelete(ind) {
     var delectId = ind.rowIndex
     this.clothesAddData.splice(delectId, 1);
     console.log(this.clothesAddData)
    },

     handleValueChange(event) {
       var dataRow = event.row
       console.log(dataRow)
       if (dataRow.startingBoxNumber != undefined && dataRow.startingBoxNumber != "" &&
        dataRow.endCaseNumber != undefined && dataRow.endCaseNumber != ""){
          dataRow.boxNumber = dataRow.endCaseNumber*1-dataRow.startingBoxNumber*1+1;
      }
      var allSizeSum = this.getAllSizeSum(dataRow);
      dataRow.piecesBox = allSizeSum
      dataRow.total = dataRow.piecesBox*dataRow.boxNumber
      if (dataRow.netWeight != "" && dataRow.netWeight != undefined){
        dataRow.totalNetWeight = dataRow.netWeight * dataRow.boxNumber;
      }
      if (dataRow.grossWeight != "" && dataRow.grossWeight != undefined){
        dataRow.totalGrossWeight = dataRow.grossWeight * dataRow.boxNumber;
      }
      if (dataRow.outerBoxLength != "" && dataRow.outerBoxLength != undefined &&
      dataRow.outerBoxWidth != "" && dataRow.outerBoxWidth != undefined &&
      dataRow.outerBoxHeight != "" && dataRow.outerBoxHeight != undefined){
      dataRow.totalVolume = (dataRow.outerBoxLength * dataRow.outerBoxWidth * dataRow.outerBoxHeight * dataRow.boxNumber).toFixed(3)
       console.log(dataRow)
      }
      if (dataRow.unitPrice != undefined && dataRow.unitPrice != ""){
        dataRow.totalPrice = (dataRow.unitPrice*dataRow.total).toFixed(2)
      }
     },

    // 操作按钮 复制
    copy(record) {
      var newRow = JSON.parse(JSON.stringify(record.row));
      newRow.isAdd = 1
      this.clothesAddData.push(newRow);
    },
    // -------------------------------------

    // 抽屉 取消
    handleCancel() {
      console.log('点击抽屉取消')
      this.close()
    },
    // 抽屉 提交
    submitAdd() {
      const that = this;
      // 触发表单验证
      that.$refs.formModel.validate(valid => {
        if (valid) {
          if (this.sizeFields.length == 0){
          this.$message.error('当前记录没有尺码字段，无法保存');
          return;
          }
          // that.confirmLoading = true
          var newObj = {}
          newObj.itemNumber = this.clothesAdd.styleNum
          newObj.orderNumber = this.clothesAdd.orderNum
          newObj.productName = this.clothesAdd.name
          newObj.sizeRange = this.clothesAdd.sizeRange
          newObj.customer = this.clothesAdd.customer
          newObj.containerCode = this.clothesAdd.containerCode
          newObj.containerNumber = this.clothesAdd.containerNo
          newObj.u8Remarks = this.clothesAdd.note
          // newObj.garmentFactory = this.clothesAdd.clothesFactory
          newObj.exportInvoiceNo = this.clothesAdd.exportInvoiceNo
          newObj.shippingOrderNumber = this.clothesAdd.bookNum
          newObj.id = this.clothesAdd.id
          newObj.syPackingListTailoringItemList = this.clothesAddData
          var sort = 0;
          for (var i=0; i<newObj.syPackingListTailoringItemList.length;i++){
             var tableRow = newObj.syPackingListTailoringItemList[i];
             var allSizeSum = this.getAllSizeSum(tableRow);
             if (allSizeSum == 0){
               this.$message.error('第'+(i+1)+'行所有尺码数量为0,无法保存');
               return;
             }
            if(tableRow.startingBoxNumber > tableRow.endCaseNumber) {
              this.$message.error('第'+(i+1)+'行起始箱号大于结束箱号，无法保存');
              return;
            }
            if (tableRow.startingBoxNumber == ""){
              this.$message.error('第'+(i+1)+'行起始箱号未填，无法保存');
              return;
           }
           if (tableRow.endCaseNumber == ""){
               this.$message.error('第'+(i+1)+'行结束箱号未填，无法保存');
                return;
            }
           if (tableRow.boxNumber == "" || tableRow.boxNumber == 0){
              this.$message.error('第'+(i+1)+'行箱数，无法保存');
              return;
           }
           if (tableRow.netWeight == null || tableRow.netWeight == "" || tableRow.netWeight == undefined){
             this.$message.error('第'+(i+1)+'行净重/箱未填，无法保存');
             return;
           }
           if (tableRow.piecesBox == null || tableRow.piecesBox == "" || tableRow.piecesBox == undefined){
             this.$message.error('第'+(i+1)+'行件数/箱未填，无法保存');
             return;
           }
          if (tableRow.grossWeight == null || tableRow.grossWeight == "" || tableRow.grossWeight == undefined){
            this.$message.error('第'+(i+1)+'行毛重/箱未填，无法保存');
             return;
            } 
          if (tableRow.outerBoxLength == null || tableRow.outerBoxLength == "" || tableRow.outerBoxLength == undefined){
             this.$message.error('第'+(i+1)+'行外箱长度未填，无法保存');
             return;
           }
          if (tableRow.outerBoxWidth == null || tableRow.outerBoxWidth == "" || tableRow.outerBoxWidth == undefined){
            this.$message.error('第'+(i+1)+'行外箱宽度未填，无法保存');
            return;
          }
          if (tableRow.outerBoxHeight == null || tableRow.outerBoxHeight == "" || tableRow.outerBoxHeight == undefined){
            this.$message.error('第'+(i+1)+'行外箱高度未填，无法保存');
            return;
           }
          if (tableRow.netWeightToo == null || tableRow.netWeightToo == "" || tableRow.netWeightToo == undefined){
             this.$message.error('第'+(i+1)+'行净净重未填，无法保存');
            return;
          }
          for (var j=0; j<tableRow.sizeTables.length; j++){
           var sizeTable = tableRow.sizeTables[j];
            var field = 'size-'+sizeTable.size;
            tableRow.sizeTables[j].proportion = tableRow[field];
          }
           tableRow.sort = ++sort;
         } 
         if(this.editDecide === 'edit'){
           editSpltList(newObj).then(res => {
             if (res.success) {
             this.$message.success('编辑成功')
             this.close()
             //清空信息
             newObj = {};
             that.fatherList() // 调用父组件 查询方法
             }else{
              this.$message.error(res.message)
            }
           })
        }else {
          addSpltList(newObj).then(res => {
             if (res.success) {
              this.$message.success('新增成功')
              this.close()
              //清空信息
              newObj = {};
             that.fatherList() // 调用父组件 查询方法
           }else{
             this.$message.error(res.message)
           }
         })
       }
        }
      })
    },

    // 获取不同尺码数量之和
    getAllSizeSum(record){
      var ret = 0;
      for (var i=0; i<this.sizeFields.length; i++){
        if (record[this.sizeFields[i]] != undefined && record[this.sizeFields[i]] != ""){
          ret += record[this.sizeFields[i]]*1;
        }
      }
      return ret;
    },

    // -------------------------------------
    close() {
      this.$emit('close')
      this.visible = false
      this.clothesAdd = {}
      this.clothesAddData = []
      this.sizeFields = []
      this.initializationColumns()
      this.editDecide = 'add'
      // this.$refs.form.resetFields()
    }, 

    //初始化表头
    initializationColumns(){
     this.clothesAddColumns= [
        {
          title: '账套',
          key: 'acSetNo',
          width: 160,
          fixed: 'left',
           type: JVXETypes.normal,
        },
        {
          title: '成衣工厂',
          key: 'garmentFactory',
          width: 120,
          fixed: 'left',
           type: JVXETypes.normal,
        },
        {
          title: 'HOD',
          key: 'hod',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: 'STYLE NO.',
          key: 'styleNo',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: 'PO NO.',
          key: 'poNo',
          width: 90,
           type: JVXETypes.normal,
        },

        {
          title: 'ITEM NO./SKU NO./UPC NO./PACKS CODE',
          key: 'itemCode',
          width: 340,
          type: JVXETypes.normal,
        },
        {
          title: '分销点/DC/LABEL',
          key: 'distributionPoint',
          width: 200,
          type: JVXETypes.normal,
          insertAfter:true,
        },
        {
          title: '启始箱号',
          key: 'startingBoxNumber',
          type: JVXETypes.inputNumber ,
          width: 120,
        },

        {
          title: '结束箱号',
          key: 'endCaseNumber',
          width: 120,
          type: JVXETypes.inputNumber 
        },

        {
          title: '颜色（中英文）',
          key: 'colour',
          width: 140,
         type: JVXETypes.input,
        },
        {
          title: '配码',
          key: 'withCode',
          width: 120,
         type: JVXETypes.normal,
        },
        {
          title: '件数/箱',
          key: 'piecesBox',
          width: 120,
          type: JVXETypes.normal 
        },
        {
          title: '箱数',
          key: 'boxNumber',
          width: 120,
          type: JVXETypes.normal 
        },

        {
          title: '总件数',
          key: 'total',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '净重/箱',
          key: 'netWeight',
          width: 120,
          type: JVXETypes.inputNumber 
        },
        {
          title: '总净重',
          key: 'totalNetWeight',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '毛重/箱',
          key: 'grossWeight',
          width: 120,
          type: JVXETypes.inputNumber 
        },
        {
          title: '总毛重',
          key: 'totalGrossWeight',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '外箱长度',
          key: 'outerBoxLength',
          width: 120,
         type: JVXETypes.inputNumber 
        },
        {
          title: '外箱宽度',
          key: 'outerBoxWidth',
          width: 120,
          type: JVXETypes.inputNumber 
        },
        {
          title: '外箱高度',
          key: 'outerBoxHeight',
          width: 120,
          type: JVXETypes.inputNumber 
        },
        {
          title: '总体积',
          key: 'totalVolume',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '净净重',
          key: 'netWeightToo',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '单价',
          key: 'unitPrice',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '总价',
          key: 'totalPrice',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '备注',
          key: 'remarks',
          width: 140,
          customRender: t => ellipsis(t),
          fixed: 'right',
          type: JVXETypes.normal,
        },
        {
          title: '操作',
          key: 'operation',
          type: JVXETypes.slot,
          width: 160,
          fixed: 'right',
          align: 'center',
            slotName: 'action',
        }
      ]
    },
    // - father------------------------------------
    aa() {},
    modalFormOk() {},

    // 分页、排序、筛选变化时触发
    handleTableChange(pagination, filters, sorter) {
      this.queryParam.pageNo = pagination.current
      this.getAnnList()
    }
  }
}
</script>

<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/overwriter.less';
/deep/ .ant-table-thead > tr > th {
  text-align: center;
  // font-weight: 700;
}

/deep/ .ant-table-tbody {
  text-align: center;
}

// /deep/ th.replacecolor {
//   background-color: #ccc;
// }

// 抽屉里的card样式
/deep/ .ant-drawer-content {
  background-color: #f0f2f5;
}
/deep/ .ant-drawer-body {
  padding: 10px;
}
</style>
