<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">
                {{ orderDetail.orderNumber }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="订单日期" prop="orderDate">
                {{ orderDetail.orderDate }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="业务类型" prop="businessTypeValue">
                {{ orderDetail.businessTypeValue }}
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-model-item label="销售类型" prop="salesTypeValue">
                {{ orderDetail.salesTypeValue }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="客户简称" prop="customerAbbreviation">
                {{ orderDetail.customerAbbreviation }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="客户名称" prop="customerName">
                {{ orderDetail.customerName }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="汇率" prop="exchangeRate">
                {{ orderDetail.exchangeRate }}
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-model-item label="销售部门" prop="salesDepartment">
                {{ orderDetail.salesDepartment }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="业务员" prop="salesman">
                {{ orderDetail.salesman }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="币种" prop="currencyValue">
                {{ orderDetail.currencyValue }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="品牌方" prop="brandSide">
                {{ orderDetail.brandSide }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="第三方" prop="thirdParty">
                {{ orderDetail.thirdParty }}
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-model-item label="定金比例(%)" prop="depositRatio">
                {{ orderDetail.depositRatio }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="定金" prop="deposit">
                {{ orderDetail.deposit }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="协同路线" prop="collaborativeRoute">
                {{ orderDetail.collaborativeRoute }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="订单备注" prop="orderRemarks">
                {{ orderDetail.orderRemarks }}
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-model-item label="价格备注" prop="priceRemarks">
                {{ orderDetail.priceRemarks }}
              </a-form-model-item>
            </a-col>
            <!-- TODO:缺少该字段 -->
            <a-col :md="6" :sm="8">
              <a-form-model-item label="客户订单号" prop="customerOrderNum">
                {{ orderDetail.customerOrderNumber }}
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-model-item label="整单合计" prop="wholeOrderTotal">
                {{ orderDetail.wholeOrderTotal }}
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-model-item label="最终客户" prop="endCustomer">
                {{ orderDetail.endCustomer }}
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="付款条件" prop="termOfPayment">
                {{ orderDetail.termOfPayment }}
              </a-form-model-item>
            </a-col>

            <a-col :md="18" :sm="12">
              <a-form-model-item label="订单变更说明" prop="orderChangeDescription">
                {{ orderDetail.orderChangeDescription }}
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
    </a-card>

    <!-- 子表  -->
    <a-card :bordered="true" style="margin:10px 0">
      <a-table
        bordered
        :columns="childColumns"
        :data-source="childData"
        :pagination="ipagination"
        :loading="loading"
        :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'
export default {
  name: 'OrderList',
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment },
  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略
    return {
      description: '订单数据详情 抽屉',
      visible: false, // 抽屉

      // 表头
      childColumns: [
        { title: '款号', width: 120, dataIndex: 'itemNumber', fixed: 'left', className: 'replacecolor' },
        {
          title: '预发货日期',
          width: 120,
          dataIndex: 'preDeliveryDate',
          fixed: 'left',
          customRender: text => {
            return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        {
          title: '预完工日期',
          width: 120,
          dataIndex: 'preCompletionDate',
          customRender: text => {
            return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        { title: 'Pack Id', width: 100, dataIndex: 'packId', className: 'replacecolor' },
        { title: '小po', width: 100, dataIndex: 'smallPo', className: 'replacecolor' },
        { title: '分销点', width: 150, dataIndex: 'distributionPoint', className: 'replacecolor' },
        { title: '存货编码', width: 120, dataIndex: 'inventoryCode', className: 'replacecolor' },
        { title: '存货名称', width: 120, dataIndex: 'inventoryName', className: 'replacecolor' },
        { title: '规格型号', width: 100, dataIndex: 'specificationAndModel', className: 'replacecolor' },
        { title: '颜色', width: 100, dataIndex: 'colour', className: 'replacecolor' },
        { title: '尺码', width: 100, dataIndex: 'size', className: 'replacecolor' },
        { title: '配码规则', width: 100, dataIndex: 'codingRules', className: 'replacecolor' },
        { title: '光坯毛门幅CM', width: 140, dataIndex: 'guangpeiGateWidth', className: 'replacecolor' },
        { title: '箱数', width: 100, dataIndex: 'boxNumber', className: 'replacecolor' },
        { title: '数量', width: 100, dataIndex: 'quantity', className: 'replacecolor' },
        { title: '主计量', width: 100, dataIndex: 'masterMetering', className: 'replacecolor' },
        { title: '含税单价', width: 100, dataIndex: 'unitPriceIncludingTax', className: 'replacecolor' },
        { title: '价税合计', width: 100, dataIndex: 'totalPriceAndTax', className: 'replacecolor' },
        { title: '税率(%)', width: 100, dataIndex: 'taxRate', className: 'replacecolor' },
        {
          title: '备注',
          width: 150,
          dataIndex: 'remarks',
          customRender: t => ellipsis(t),
          className: 'replacecolor',
          scopedSlots: { customRender: 'remarks' }
        },
        { title: '行关闭人', width: 100, dataIndex: 'bankClosedBy', className: 'replacecolor' }
      ],
      orderDetail: [], // 主表信息
      childData: [], // 子表数据
      loading: false, // 表格加载

      dateFormat: 'YYYY-MM-DD'
    }
  },
  created() {},
  methods: {
    // 回显主表信息 正常应该通过id查询
    onClose() {
      // 关闭抽屉
      this.visible = false
    }
  },
  computed: {},
  mounted() {}
}
</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;
}
</style>
