<template>
  <!-- 详情 预装箱单-成衣 单证-->
  <a-drawer title="详情" width="89%" placement="right" :closable="true" :visible="visible" @close="onClose">
    <!-- 主表信息 展示 -->
    <a-card :bordered="true">
      <div class="table-page-search-wrapper">
        <a-form-model layout="inline" ref="form">
          <a-row :gutter="24">
            <a-col :md="6" :sm="8">
              <a-form-model-item label="订单号" prop="orderNumber">
                {{ detailsAdpacking.orderNumber }}
              </a-form-model-item>
            </a-col>

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

            <a-col :md="6" :sm="8">
              <a-form-model-item label="品名" prop="productName">
                {{ detailsAdpacking.productName }}
              </a-form-model-item>
            </a-col>

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

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

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

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

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

            <a-col :md="6" :sm="8">
              <a-form-model-item label="成衣工厂" prop="garmentFactory">
                {{ detailsAdpacking.garmentFactory }}
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
    </a-card>
    <!-- 子表 ipagination-->
    <a-card :bordered="true" style="margin:10px 0">
      <a-table
        bordered
        rowKey="id"
        :columns="columns"
        :data-source="data"
        :loading="loading"
        :pagination="false"
        :scroll="{ x: 1500 }"
        @change="handleTableChange"
      >
      </a-table>
    </a-card>
  </a-drawer>
</template>

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

import { itemByMainId } from '@api/document/advance-packingList.js'

export default {
  name: 'DetailsAdpackingDrawer', // 详情
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment },
  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
    return {
      detailsAdpacking: {}, //主表信息
      // 表头
      columns: [
        {
          title: '账套',
          dataIndex: 'acSetNo',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },
        {
          title: '成衣工厂',
          dataIndex: 'garmentFactory',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },
        {
          title: 'HOD',
          dataIndex: 'hod',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },
        {
          title: 'STYLE NO.',
          dataIndex: 'styleNo',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: 'PO NO.',
          dataIndex: 'poNo',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: 'ITEM NO./SKU NO./UPC NO./PACKS CODE',
          dataIndex: 'itemCode',
          width: 340,
          className: 'replacecolor'
        },
        {
          title: '分销点/DC/LABEL',
          dataIndex: 'distributionPoint',
          width: 180,
          className: 'replacecolor'
        },

        {
          title: 'PREPACK SKU',
          dataIndex: 'prepackSku',
          width: 140,
          className: 'replacecolor'
        },

        {
          title: 'S',
          dataIndex: 's',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: 'M',
          dataIndex: 'm',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: 'L',
          dataIndex: 'l',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: 'XL',
          dataIndex: 'xl',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: 'XXL',
          dataIndex: 'xxl',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '3XL',
          dataIndex: 'xxxl',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '起始箱号',
          dataIndex: ' startingBoxNumber.',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '结束箱号',
          dataIndex: 'endCaseNumber.',
          width: 140,
          className: 'replacecolor'
        },

        {
          title: '颜色(中英文)',
          dataIndex: 'colour',
          width: 140,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '配码--根据U8订单来显示',
          dataIndex: 'withCode',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '件数/箱',
          dataIndex: 'piecesBox',
          width: 90,
          className: 'replacecolor'
        },
        {
          title: '箱数',
          dataIndex: 'boxNumber',
          width: 140,
          className: 'replacecolor'
        },

        {
          title: '总件数',
          dataIndex: 'total',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '净重/箱',
          dataIndex: 'netWeight',
          width: 90,
          className: 'replacecolor'
        },
        {
          title: '总净重',
          dataIndex: 'totalNetWeight',
          width: 140,
          className: 'replacecolor'
        },

        {
          title: '毛重/箱',
          dataIndex: 'grossWeight',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '总毛重',
          dataIndex: 'totalGrossWeight',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '外箱长度',
          dataIndex: 'outerBoxLength',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '外箱宽度',
          dataIndex: 'outerBoxWidth',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '外箱高度',
          dataIndex: 'outerBoxHeight',
          width: 140,
          className: 'replacecolor'
        },

        {
          title: '总体积',
          dataIndex: 'totalVolume',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '净净重',
          dataIndex: 'netWeightToo',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '单价',
          dataIndex: 'unitPrice',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '总价',
          dataIndex: 'totalPrice',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '备注(U8)',
          dataIndex: 'u8Remarks',
          width: 140,
          fixed: 'right',
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        }
      ],
      data: [], //子表信息

      loading: false, // 表格加载
      pagination: {
        pageNo: ''
        // total: '',
        // current: '',
        // pageSize: ''
      },

      visible: false,
      dateFormat: 'YYYY-MM-DD',
      record: {} //点击的对象
    }
  },
  created() {
    this.getDetailsById()
  },
  methods: {
    // 回显数据
    getDetailsById() {
      this.$nextTick(() => {
        itemByMainId({ id: this.record.id }).then(res => {
          if (res.success) {
            console.log('点击的对象', res.result)
            this.detailsAdpacking = res.result; //主表信息
            this.data = [];
            if (res.result.syPreAssembledPackingListItemList != null){
              this.data = res.result.syPreAssembledPackingListItemList; //子表信息
            }
          }
        })
      })
    },
    handleTableChange(pagination, filters, sorter) {
      this.pagination.pageNo = pagination.current
      this.getDetailsById()
    },
    onClose() {
      this.visible = false
    }
  },

  modalFormOk() {}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.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;
}
// 回显label文字
/deep/.ant-form-item-label > label {
  font-weight: 700;
}
</style>
