<template>
  <a-modal
    title="参照托书"
    v-model="selectBookModVis"
    :confirmLoading="confirmLoading"
    @ok="onSubmit"
    @cancel="handleCancel"
    width="86%"
    style="top:330px;left:100px;"
  >
    <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.exportInvoiceNo"></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>

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

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'
export default {
  name: 'SelectBookModal', // 参照托书（选择托书）
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment },

  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略
    return {
      selectedRowKeys: [], // 勾选航
      loading: false, // 表格加载
      // 表头
      selectBookColumns: [
        {
          title: '订单号',
          dataIndex: 'orderNum',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },
        // {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        {
          title: '预约号',
          dataIndex: 'reservationDate',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },

        {
          title: '外销发票号码',
          dataIndex: 'exportInvoiceNo',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '经营单位',
          dataIndex: 'unitOperation',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '金额',
          dataIndex: 'money',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '收汇方式',
          dataIndex: 'collectionMethod',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '收货人',
          dataIndex: 'consignee',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '提单或承运收据',
          dataIndex: 'billLadingOrCarriageReceipt',
          width: 140,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '抬头人',
          dataIndex: 'headPerson',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        { title: '贸易国别', dataIndex: 'tradeCountry', width: 100, className: 'replacecolor' },
        { title: '运抵国别', dataIndex: 'arriveCountry', width: 100, className: 'replacecolor' },
        { title: '出口口岸', dataIndex: 'exportPort', width: 100, className: 'replacecolor' },
        {
          title: '通知人',
          dataIndex: 'notifier',
          width: 100,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        { title: 'NOTIFY', dataIndex: 'NOTIFY', width: 150, className: 'replacecolor' },
        { title: '目的港', dataIndex: 'destinationPort', width: 100, className: 'replacecolor' },
        // {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        { title: '装运期限', dataIndex: 'latestShipmentDate', width: 100, className: 'replacecolor' }
      ],
      selectBookData: [
        { orderNum: '98347445', reservationDate: '2022-04-26' },
        { orderNum: '72643547', reservationDate: '2022-04-26' }
      ],
      confirmLoading: false,
      selectBookModVis: false,

      // 查询条件
      queryParam: {
        orderNum: '',
        exportInvoiceNo: ''
      }
    }
  },
  // 接收父组件 方法
  props: {
    father: {
      type: Function,
      default: null
    }
  },
  created() {},
  methods: {
    // 弹框查询按钮
    searchQuery() {},
    // 重置
    searchReset() {
      this.queryParam = {}
      // 刷新托书
    },
    // 弹框确定
    onSubmit() {
      console.log('已选择好托书,选择的托书信息保存到申报列表中')
      this.close()
    },
    close() {
      this.$emit('close')
      this.selectBookModVis = false
    },
    handleCancel() {
      this.close()
    },
    // 选中行
    onSelectChange(keys, rows) {
      this.selectedRowKeys = keys
      console.log('this.selectedRowKeys:', this.selectedRowKeys)
      this.selectedRows = rows
      console.log('this.selectedRows', this.selectedRows)
    }
    // 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>
