<template>
  <a-modal
    title="参照发运明细"
    v-model="referShipmentDetailsModVis"
    :confirmLoading="confirmLoading"
    @ok="onSubmit"
    @cancel="handleCancel"
    width="86%"
    style="top:330px;left:100px;"
  >
    <!-- tabel 加载 -->
    <a-spin :spinning="confirmLoading">
      <!-- 查询  -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="6" :sm="8">
              <a-form-item label="单据号">
                <a-input placeholder="请输入单据号" v-model="queryParam.orderNum"></a-input>
              </a-form-item>
            </a-col>

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

            <a-col :md="6" :sm="8">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                <a @click="handleToggleSearch" style="margin-left: 8px">
                  {{ toggleSearchStatus ? '收起' : '展开' }}
                  <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>

      <!-- table , y: 300 -->
      <div>
        <a-table
          :columns="referShipmentDetailsColumns"
          :data-source="referShipmentDetailsData"
          :loading="loading"
          :pagination="ipagination"
          :row-key="record => record.id"
          :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
          @change="handleTableChange"
          bordered
          :scroll="{ x: 1500 }"
        >
        </a-table>
      </div>
    </a-spin>
  </a-modal>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'
export default {
  name: 'ReferShipmentDetailsModal',
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment },

  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略

    return {
      selectedRowKeys: [], // 勾选航
      loading: false, // 表格加载
      // 表头
      referShipmentDetailsColumns: [
        {
          title: '单据号',
          dataIndex: 'documentNum',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },
        {
          title: '销售订单号',
          dataIndex: 'saleOrderNo',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },

        {
          title: '客户简称',
          dataIndex: 'customerShortName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '部门',
          dataIndex: 'department',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '业务员',
          dataIndex: 'salesman',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '小po',
          dataIndex: 'smallPo',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: 'Pack Id',
          dataIndex: 'packId',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '分销点',
          dataIndex: 'distributionPoint',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '款号',
          dataIndex: 'styleNum',
          width: 120,
          className: 'replacecolor'
        },
        //         {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        {
          title: '预发货日期',
          dataIndex: 'scheduledShipDate',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '计划到货日期',
          dataIndex: 'plannedArrivalDate',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '存货名称',
          dataIndex: 'inventoryName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '数量(合计)',
          dataIndex: 'quantity',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '单价(销售)',
          dataIndex: 'price',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '采购/委外订单号',
          dataIndex: 'purchaseAboardOrderNum',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '订单类型',
          dataIndex: 'orderType',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '工厂单价(采购/委外单价)',
          dataIndex: 'factoryPrice',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '申报要素(单证维护)',
          dataIndex: 'declareElements',
          width: 140,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },

        {
          title: '套装件数(存货自定义项)',
          dataIndex: 'suitQuantity',
          width: 120,

          className: 'replacecolor'
        },
        {
          title: '是否TC功能',
          dataIndex: 'isTC',
          width: 90,
          className: 'replacecolor'
        },
        {
          title: 'HScode',
          dataIndex: 'HScode',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '中文品名',
          dataIndex: 'chineseProName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '英文品名',
          dataIndex: 'englishProName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '成衣工厂',
          dataIndex: 'clothesFactory',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '报关单价',
          dataIndex: 'declarationPrice',
          width: 120,
          className: 'replacecolor'
        }
      ],
      referShipmentDetailsData: [{}, {}, {}],
      confirmLoading: false,
      referShipmentDetailsModVis: false,

      // 查询条件
      queryParam: {
        orderNum: '',
        customer: ''
      }
    }
  },
  // 接收父组件 方法
  props: {
    father: {
      type: Function,
      default: null
    }
  },
  created() {},
  methods: {
    // 弹框查询按钮
    searchQuery() {},
    // 重置
    searchReset() {
      this.queryParam = {}
      // this.getShipmentList()
    },
    // 弹框确定
    onSubmit() {},
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleCancel() {
      this.close()
    },
    // 选中行
    onSelectChange(keys, rows) {
      this.selectedRowKeys = keys
      this.selectedRows = rows
    }
    // handleTableChange(pagination, filters, sorter) {
    //   // console.log('当前页信息>>>>',pagination)
    //   this.queryParam.pageNo = pagination.current
    //   this.getAnnList()
    // }
  },
  computed: {
    // 选中项
    rowSelection() {
      return {
        onChange: (selectedRowKeys, selectedRows) => {
          console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
        },
        getCheckboxProps: record => ({
          props: {
            disabled: record.title === 'Disabled User',
            // Column configuration not to be checked
            title: record.title
          }
        })
      }
    }
  }
}
</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;
// }
</style>
