<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">
            <a-row :gutter="24">
              <a-col :md="6" :sm="8">
                <a-form-model-item label="订单号" prop="orderNum">
                  {{clothesAdd.orderNum}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="款号" prop="styleNum">
                  {{clothesAdd.styleNum}}
                </a-form-model-item>
              </a-col>

             <a-col :md="6" :sm="8">
                <a-form-model-item label="中文品名" prop="name">
                  {{clothesAdd.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="englishProductName">
                  {{clothesAdd.englishProductName}}
                  <!-- <a-input placeholder="请输入英文品名" v-model="clothesAdd.englishProductName"></a-input> -->
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="尺码范围" prop="sizeRange">
                  {{clothesAdd.sizeRange}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="客户" prop="customer">
                  {{clothesAdd.customer | ellipsis}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="集装箱代号" prop="containerCode">
                  {{clothesAdd.containerCode}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="集装箱号" prop="containerNo">
                  {{clothesAdd.containerNo}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="备注" prop="note">
                  {{clothesAdd.note}}
                </a-form-model-item>
              </a-col>

              <!-- <a-col :md="6" :sm="8">
                <a-form-model-item label="成衣工厂" prop="clothesFactory">
                  {{clothesAdd.clothesFactory}}
                </a-form-model-item>
              </a-col> -->

              <a-col :md="6" :sm="8">
                <a-form-model-item label="外销发票号" prop="exportInvoiceNo">
                  {{clothesAdd.exportInvoiceNo}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="托书号" prop="bookNum">
                  {{clothesAdd.bookNum}}
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="8">
                <a-form-model-item label="总箱数" prop="totalBoxes">
                  {{clothesAdd.totalBoxes}}
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="8">
                <a-form-model-item label="总毛重" prop="totalGrossWeight">
                  {{clothesAdd.totalGrossWeight}}
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="8">
                <a-form-model-item label="总净重" prop="totalNetWeight">
                  {{clothesAdd.totalNetWeight}}
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="8">
                <a-form-model-item label="总体积" prop="totalVolume">
                  {{clothesAdd.totalVolume}}
                </a-form-model-item>
              </a-col>
              <!-- <a-col :md="6" :sm="8">
                <a-form-model-item label="总价" prop="totalPrice">
                  {{clothesAdd.totalPrice}}
                </a-form-model-item>
              </a-col> -->
              <a-col :md="6" :sm="8">
                <a-form-model-item label="总件数" prop="total">
                  {{clothesAdd.total}}
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-form-model>
        </div>
      </a-card>

      <a-card :bordered="true" style="margin:10px 0 60px 0;">
        <!-- 子表 :pagination="ipagination"  -->
        <a-spin :spinning="confirmLoading">
          <a-form-model ref="formRef">
            <j-vxe-table
              ref="vTable"
              :height="300"
              :loading="loading"
              :dataSource="clothesAddData"
              :columns="clothesAddColumns"
              :bordered=true
              :scroll="{ x: 1500,y: 400 }"
              style="margin-top: 5px;"
            >
            </j-vxe-table>
          </a-form-model>
        </a-spin>
      </a-card>
    </a-drawer>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import JEllipsis from '@/components/jeecg/JEllipsis'


export default {
  name: 'detailsClothesDrawer', //  详情-装箱单 -成衣
  mixins: [JeecgListMixin],
  computed: {},
  components: { 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: 'PREPACK SKU',
          key: 'prepackSku',
          width: 200,
          type: JVXETypes.normal,
        },
         {
          title: '分销点/DC/LABEL',
          key: 'distributionPoint',
          width: 200,
          type: JVXETypes.normal,
          insertAfter:true,
        },
        {
          title: '启始箱号',
          key: 'startingBoxNumber',
          type: JVXETypes.normal ,
          width: 120,
        },

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

        {
          title: '颜色（中英文）',
          key: 'colour',
          width: 140,
         type: JVXETypes.normal,
        },
        {
          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.normal 
        },
        {
          title: '总净重',
          key: 'totalNetWeight',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '毛重/箱',
          key: 'grossWeight',
          width: 120,
          type: JVXETypes.normal 
        },
        {
          title: '总毛重',
          key: 'totalGrossWeight',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '外箱长度',
          key: 'outerBoxLength',
          width: 120,
         type: JVXETypes.normal 
        },
        {
          title: '外箱宽度',
          key: 'outerBoxWidth',
          width: 120,
          type: JVXETypes.normal 
        },
        {
          title: '外箱高度',
          key: 'outerBoxHeight',
          width: 120,
          type: JVXETypes.normal 
        },
        {
          title: '总体积',
          key: 'totalVolume',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '净净重',
          key: 'netWeightToo',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '备注',
          key: 'remarks',
          width: 140,
          customRender: t => ellipsis(t),
          // fixed: 'right',
          type: JVXETypes.normal,
        },
      ],
      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: {
    dynamicColumns(sizeTables){
       var newColumns = this.clothesAddColumns
        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.normal ,
              width: 80,
              isSize:true,
          };
          newColumns.splice(i+1+j,0,field);
        }
        }
        this.clothesAddColumns = newColumns
    },

    // 抽屉 取消
    handleCancel() {
      console.log('点击抽屉取消')
      this.close()
    },
  

    // -------------------------------------
    close() {
      this.$emit('close')
      this.visible = false
      this.clothesAdd = {}
      this.clothesAddData = []
      this.sizeFields = []
      this.initializationColumns()
      // 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: 'PREPACK SKU',
          key: 'prepackSku',
          width: 200,
          type: JVXETypes.input,
        },
        {
          title: '分销点/DC/LABEL',
          key: 'distributionPoint',
          width: 200,
          type: JVXETypes.normal,
          insertAfter:true,
        },
        {
          title: '启始箱号',
          key: 'startingBoxNumber',
          type: JVXETypes.normal ,
          width: 120,
        },

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

        {
          title: '颜色（中英文）',
          key: 'colour',
          width: 140,
         type: JVXETypes.normal,
        },
        {
          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.normal 
        },
        {
          title: '总净重',
          key: 'totalNetWeight',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '毛重/箱',
          key: 'grossWeight',
          width: 120,
          type: JVXETypes.normal 
        },
        {
          title: '总毛重',
          key: 'totalGrossWeight',
          width: 90,
          type: JVXETypes.normal,
        },
        {
          title: '外箱长度',
          key: 'outerBoxLength',
          width: 120,
         type: JVXETypes.normal 
        },
        {
          title: '外箱宽度',
          key: 'outerBoxWidth',
          width: 120,
          type: JVXETypes.normal 
        },
        {
          title: '外箱高度',
          key: 'outerBoxHeight',
          width: 120,
          type: JVXETypes.normal 
        },
        {
          title: '总体积',
          key: 'totalVolume',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '净净重',
          key: 'netWeightToo',
          width: 120,
          type: JVXETypes.normal,
        },
        {
          title: '备注',
          key: 'remarks',
          width: 140,
          customRender: t => ellipsis(t),
          fixed: 'right',
          type: JVXETypes.normal,
        },
      ]
    },
    // - father------------------------------------
    aa() {},
    modalFormOk() {},
  }
}
</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>
