<template>
  <a-modal
    title="参照订单数据"
    v-model="referOrderDataModVis"
    :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-select placeholder="请选择账套" v-model="queryParam.accountSet">
                  <a-select-option value="">请选择</a-select-option>
                  <a-select-option :value="0">香港森语(101)</a-select-option>
                  <a-select-option :value="1">宁波森语(102)</a-select-option>
                  <a-select-option :value="2">宁波马菲羊(103)</a-select-option>
                </a-select>
              </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>

      <!-- 勾选表    size="small"-->
      <div>
        <a-table
          bordered
          rowKey="id"
          :columns="referOerderColumns"
          :data-source="referOerderData"
          :loading="loading"
          :pagination="ipagination"
          :row-key="record => record.id"
          :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
          @change="handleTableChange"
          :scroll="{ x: 1500, y: 300 }"
        >
        </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: 'ReferOrderDataModal', // 参照订单数据弹框
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment },

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

    return {
      selectedRowKeys: [], // 勾选航
      loading: false, // 表格加载
      // 表头
      referOerderColumns: [
        {
          title: '订单号',
          dataIndex: 'orderNum',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },
        {
          title: '款号',
          dataIndex: 'styleNum',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },

        {
          title: '小po',
          dataIndex: 'smallPo',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '账套',
          dataIndex: 'accountSet',
          width: 120,
          className: 'replacecolor'
        },
        //         {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        {
          title: '订单日期',
          dataIndex: 'orderDate',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '存货名称',
          dataIndex: 'inventoryName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '颜色',
          dataIndex: 'color',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '尺码',
          dataIndex: 'size',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '配码规格',
          dataIndex: 'specificationSize',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '数量',
          dataIndex: 'quantity',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '业务类型',
          dataIndex: 'businessType',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '客户订单',
          dataIndex: 'customerOrder',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '销售类型',
          dataIndex: 'saleType',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '客户简称',
          dataIndex: 'customerShortName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '客户名称',
          dataIndex: 'customerName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '供应商',
          dataIndex: 'supplier',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '汇率',
          dataIndex: 'exchangeRate',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '整单合计',
          dataIndex: 'wholeSingleCombined',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '销售部门',
          dataIndex: 'salesDepartment',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '业务员',
          dataIndex: 'salesman',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '币种',
          dataIndex: 'currency',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '品牌方',
          dataIndex: 'brand',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '第三方',
          dataIndex: 'thirdParty',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '定金比例(%)',
          dataIndex: 'depositRate',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '定金',
          dataIndex: 'deposit',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '协同路线',
          dataIndex: 'collaborativeRoute',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '付款条件',
          dataIndex: 'paymentClause',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '最终客户',
          dataIndex: 'finalCustomer',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '订单备注',
          dataIndex: 'OrderNote',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },

        {
          title: '价格备注',
          dataIndex: 'priceNote',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '订单变更说明',
          dataIndex: 'OrderChangeDesc',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        }
      ],
      referOerderData: [{ orderNum: '26449845' }, {}, {}],
      // orderDataform: this.$form.createForm(this),
      confirmLoading: false,
      referOrderDataModVis: false,

      // 查询条件
      queryParam: {
        orderNum: '', // 订单号
        accountSet: '' // 账套
      }
    }
  },
  // 接收父组件 方法
  props: {
    father: {
      type: Function,
      default: null
    }
  },
  created() {},
  methods: {
    // 弹框查询按钮
    searchQuery() {},
    // 重置
    searchReset() {
      this.queryParam = {}
      // this.getShipmentList()
    },
    // 弹框确定
    onSubmit() {
      console.log('参照订单数据弹框确定,重新渲染【新增发运明细】')
      this.referOrderDataModVis = false
    },

    close() {
      this.$emit('close')
      this.referOrderDataModVis = false
    },
    handleCancel() {
      this.close()
    },
    handleTableChange() {
      console.log('??这是啥')
    },
    // 选中行
    onSelectChange(keys, rows) {
      this.selectedRowKeys = keys
      this.selectedRows = rows
      console.log('选中行keys:', keys, '选中行rows:', rows)
    }
  },
  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';
/deep/ .ant-table-thead > tr > th {
  text-align: center;
  // font-weight: 700;
}
/deep/ .ant-table-tbody {
  text-align: center;
}
// th.replacecolor {
// background-color:  #ccc;
// }
</style>
