<template>
  <!-- 预托书列表 -->
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <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="订单日期" has-feedback>
              <a-date-picker style="width: 100%" v-model="queryParam.orderDate"> </a-date-picker>
            </a-form-item>
          </a-col>

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

          <template v-if="toggleSearchStatus">
            <a-col :md="6" :sm="8">
              <a-form-item label="箱号">
                <a-input placeholder="请输入箱号" v-model="queryParam.boxNo"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="小po号">
                <a-input placeholder="请输入小po号" v-model="queryParam.smallPo"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="预托书号">
                <a-input placeholder="请输入预托书号" v-model="queryParam.preBookNum"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <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>

    <!-- 操作按钮区域 新增-->
    <div class="table-operator">
      <a-button type="primary" @click="addPreBook" icon="plus">新增</a-button>
    </div>

    <!-- table , y: 300 -->
    <div>
      <a-table
        bordered
        rowKey="id"
        :columns="preBookListColumns"
        :data-source="preBookListData"
        :loading="loading"
        :pagination="ipagination"
        @change="handleTableChange"
        :scroll="{ x: 1500 }"
      >
        <!-- 金额 -->
        <a-form-model
          slot="money"
          slot-scope="text, record"
          :ref="record.index"
          :model="record"
          style="width:100%;height:40px"
        >
          <a-form-model-item prop="money">
            <a-input style="width:100%" v-model="record.money" />
          </a-form-model-item>
        </a-form-model>

        <!-- 单据状态 -->
        <span slot="documentStateSlot">
          <a-tag color="#2db7f5">已保存</a-tag>
        </span>
        <!-- if  已提交 -->
        <!-- <span slot="documentStateSlot">
          <a-tag color="#2db7f5">已提交</a-tag>
        </span> -->

        <!-- 操作 -->
        <span slot="operationSlot" slot-scope="text, record">
          <a @click="submit(record)" style="color:green;">提交</a>
          <a-divider type="vertical" />

          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay">
              <a-menu-item><a @click="checke(record)">查看</a></a-menu-item>
              <a-menu-item><a @click="edit(record)">修改</a></a-menu-item>
              <a-menu-item><a @click="print(record)">打印</a></a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete(record.id)">
                  <a href="javascript:void(0);" style="color:red;">删除</a>
                </a-popconfirm></a-menu-item
              >
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

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

export default {
  name: 'PreBookList', // 预托书列表
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment },
  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略

    return {
      // 表头
      preBookListColumns: [
        { title: '预托书号', width: 120, dataIndex: 'preBookNum', fixed: 'left', className: 'replacecolor' },
        { title: '订单号', width: 120, dataIndex: 'orderNum', fixed: 'left', className: 'replacecolor' },
        { title: '外销发票号码', dataIndex: 'exportInvoiceNo', width: 120, className: 'replacecolor' },
        { title: '客户简称', dataIndex: 'customerShortName', width: 120, className: 'replacecolor' },
        {
          title: '分销点',
          dataIndex: 'distributionPoint',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '经营单位',
          dataIndex: 'unitOperation',
          width: 150,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        { title: '总箱数', dataIndex: 'totalBoxes', width: 120, className: 'replacecolor' },
        { title: '总毛重', dataIndex: 'totalRoughWeigh', width: 120, className: 'replacecolor' },
        { title: '总体积', dataIndex: 'totalVolume', width: 100, className: 'replacecolor' },
        {
          title: '金额',
          dataIndex: 'money',
          scopedSlots: { customRender: 'money' },
          width: 140,
          className: 'replacecolor'
        },
        //  {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        { title: '实际船期', dataIndex: 'actualShipDate', width: 120, className: 'replacecolor' },
        { title: '收汇方式', dataIndex: 'collectionMethod', width: 120, className: 'replacecolor' },
        {
          title: '收货人',
          dataIndex: 'consignee',
          width: 100,
          customRender: t => ellipsis(t),
          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: 'latestShipmentDate', width: 100, className: 'replacecolor' },
        {
          title: '单据状态',
          dataIndex: 'documentState',
          width: 90,
          scopedSlots: { customRender: 'documentStateSlot' },
          fixed: 'right',
          className: 'replacecolor'
        },
        {
          title: '操作',
          dataIndex: 'operation',
          scopedSlots: { customRender: 'operationSlot' },
          width: 160,
          fixed: 'right',
          className: 'replacecolor'
        }
      ],
      preBookListData: [{ orderNum: 'AA002200001' }, {}, {}],
      id: '', //
      loading: false, // 表格加载

      // 查询条件
      queryParam: {
        orderNum: '',
        orderDate: '',
        customerShortName: '',
        boxNo: '',
        smallPo: '',
        preBookNum: ''
      }
    }
  },

  created() {
    // this.getOrderList() // 渲染预托书
  },
  methods: {
    // 查询按钮
    searchQuery() {
      // this.getpreBookList() // 渲染渲染预托书
    },
    // 重置
    searchReset() {
      // console.log('>>>>重置')
      this.queryParam = {}
      // this.getpreBookList()
    },
    // 新增
    addPreBook() {
      this.$router.push('addPreBook')
    },

    // 操作 提交
    submit() {},
    // 操作 查看
    checke() {},
    // 操作 修改
    edit() {},
    // 操作 打印
    print() {},
    // 操作 删除
    handleDelete() {}

    // // 分页、排序、筛选变化时触发
    // handleTableChange(pagination, filters, sorter) {
    //   // console.log('当前页信息>>>>',pagination)
    //   this.queryParam.pageNo = pagination.current
    //   this.getOrderList()
    // }
  },
  computed: {},
  mounted() {}
}
</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>
