<template>
  <!-- 发运明细列表 -->
  <div id="ShipmentList">
    <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.documentNum"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="开始时间">
                <a-date-picker
                  placeholder="请选择开始时间"
                  @change="startTimeChange"
                  style="width: 100%"
                  v-model="queryParam.startTime"
                />
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="结束时间" style="width:100%;">
                <a-month-picker
                  placeholder="请选择结束时间"
                  @change="endTimeChange"
                  style="width: 100%"
                  v-model="queryParam.endTime"
                />
              </a-form-item>
            </a-col>

            <template v-if="toggleSearchStatus">
              <a-col :md="6" :sm="8">
                <a-form-item label="发货日期">
                  <a-date-picker
                    placeholder="请选择发货日期"
                    @change="shipDateChange"
                    style="width: 100%"
                    v-model="queryParam.deliveryDate"
                  />
                </a-form-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-item label="业务员">
                  <a-input placeholder="请输入业务员" v-model="queryParam.salesman"></a-input>
                </a-form-item>
              </a-col>

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

              <a-col :md="6" :sm="8">
                <a-form-item label="是否被参照">
                  <a-select v-model="queryParam.refer">
                    <a-select-option value="">请选择</a-select-option>
                    <a-select-option :value="0">否</a-select-option>
                    <a-select-option :value="1">是</a-select-option>
                  </a-select>
                </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>
    </a-card>

    <!-- 操作按钮区域 -->
    <a-card :bordered="false" style=" marginTop:10px;">
      <div class="table-operator">
        <a-button type="primary" @click="addShipDet" icon="plus">新增</a-button>
      </div>

      <!-- table  y: 300 -->
      <div>
        <a-row>
          <a-table
            bordered
            :row-key="record => record.id"
            :columns="shipmentListColumns"
            :data-source="shipmentListData"
            :loading="loading"
            :pagination="ipagination"
            :scroll="{ x: 1500 }"
            @change="handleTableChange"
          >
            <!-- 推送状态 -->
            <!-- slot-scope="text, record" -->
            <span slot="pushStateSlot">
              <!-- v-if="record.isRelease == '0'" -->
              <a-tag color="#f50">失败</a-tag>
              <!-- <a-tag color="#87d068" v-else>已发布</a-tag> -->
            </span>

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

            <!-- 操作 -->
            <span slot="operationSlot" slot-scope="text, record">
              <a href="javascript:void(0);" @click="declareElements(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="details(record)">详情</a>
                  </a-menu-item>

                  <a-menu-item>
                    <a @click="submit(record)">提交</a>
                  </a-menu-item>
                  <a-menu-item>
                    <a @click="edit(record)">编辑</a>
                  </a-menu-item>
                  <a-menu-item>
                    <a @click="push(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>
        </a-row>
      </div>
    </a-card>
    <!-- 新增 详情 修改 抽屉 -->
    <addShipDet-drawer ref="addShipDetDrawer" :father="aa" @ok="modalFormOk"></addShipDet-drawer>
    <detailsShipDet-drawer ref="detailsShipDetDrawer" :father="bb" @ok="modalFormOk"></detailsShipDet-drawer>
    <editShipDet-drawer ref="editShipDetDrawer" :father="cc" @ok="modalFormOk"></editShipDet-drawer>
  </div>
</template>

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

import addShipDetDrawer from '@views/shipment-details/addShipDetDrawer.vue'
import detailsShipDetDrawer from '@views/shipment-details/detailsShipDetDrawer.vue'
import editShipDetDrawer from '@views/shipment-details/editShipDetDrawer.vue'
export default {
  name: 'ShipmentList', // 发运明细列表
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment, addShipDetDrawer, detailsShipDetDrawer, editShipDetDrawer },

  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
    return {
      loading: false, // 表格加载
      id: '',
      // 表头
      shipmentListColumns: [
        {
          title: '单据号',
          dataIndex: 'documentNum',
          fixed: 'left',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '订单号',
          dataIndex: 'orderNum',
          fixed: 'left',
          width: 120,
          className: 'replacecolor'
        },
        //         {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        {
          title: '单据日期',
          dataIndex: 'billDate',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '客户',
          dataIndex: 'customer',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '小po',
          dataIndex: 'smallPo',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '款号',
          dataIndex: 'styleNum',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '报关品名',
          dataIndex: 'declarationName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: 'hscode',
          dataIndex: 'hscode',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '英文品名',
          dataIndex: 'englishProName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '账套',
          dataIndex: 'accountSet',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '订单日期',
          dataIndex: 'orderDate',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '业务类型',
          dataIndex: 'businessType',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '客户订单',
          dataIndex: 'customerOrder',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: 'Pack Id',
          dataIndex: 'packId',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '订单数据',
          dataIndex: 'orderData',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '订单剩余数量',
          dataIndex: 'orderRemaQuantity',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '发货数量',
          dataIndex: 'shipQuantity',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '是否TC功能',
          dataIndex: 'isTC',
          width: 90,
          className: 'replacecolor'
        },

        {
          title: '物料成分',
          dataIndex: 'materialComposition',
          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: 'exchangeRate',
          width: 90,
          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: 160,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '价格备注',
          dataIndex: 'priceNote',
          width: 160,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '订单变更说明',
          dataIndex: 'orderChangeDesc',
          width: 160,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },

        {
          title: '预发货日期',
          dataIndex: 'scheduledShipDate',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '预完工日期',
          dataIndex: 'scheduledDoneDate',
          width: 140,
          className: 'replacecolor'
        },
        {
          title: '推送状态',
          dataIndex: 'pushState',
          scopedSlots: { customRender: 'pushStateSlot' },
          fixed: 'right',
          width: 90,
          className: 'replacecolor'
        },
        {
          title: '单据状态',
          dataIndex: 'documentState',
          scopedSlots: { customRender: 'documentStateSlot' },
          fixed: 'right',
          width: 90,
          className: 'replacecolor'
        },
        {
          title: '操作',
          dataIndex: 'operation',
          scopedSlots: { customRender: 'operationSlot' },
          fixed: 'right',
          width: 220,
          className: 'replacecolor'
        }
      ],
      shipmentListData: [{}, {}, {}, {}],

      // 查询条件
      queryParam: {
        pageNo: '', // 页码
        documentNum: '', // 单据号
        startTime: '',
        endTime: '',
        deliveryDate: '',
        salesman: '',
        styleNum: '',
        refer: ''
      }
    }
  },
  created() {
    // this.getShipmentList() // 发运明细列表
  },
  methods: {
    // 开始时间
    startTimeChange() {},
    // 结束时间
    endTimeChange() {},
    // 发货日期
    shipDateChange() {},
    // --------------------------------------

    // 查询按钮
    searchQuery() {
      // this.getAnnList() // 渲染公告
    },
    // 重置
    searchReset() {
      console.log('>>>>重置')
      this.queryParam = {}
      // this.getAnnList()
    },
    // --------------------------------------

    // 新增 按钮
    addShipDet() {
      console.log('新增发运明细')
      this.$refs.addShipDetDrawer.visible = true
    },

    // --------------------------------------
    // 操作 申报要素
    declareElements() {},
    // 操作 详情
    details(record) {
      console.log('查看发运明细')
      this.$refs.detailsShipDetDrawer.visible = true
    },
    // 操作 提交
    submit() {},
    // 操作 编辑
    edit(record) {
      console.log('编辑发运明细')
      this.$refs.editShipDetDrawer.visible = true
    },
    // 操作 推送
    push(record) {},
    // 操作 删除
    handleDelete(id) {
      console.log('id:', id)
    },

    // 分页、排序、筛选变化时触发
    // handleTableChange(pagination, filters, sorter) {
    //   // console.log('当前页信息>>>>',pagination)
    //   this.queryParam.pageNo = pagination.current
    //   // this.getAnnList()
    // }

    // father方法
    aa() {},
    bb() {},
    cc() {}
  },
  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>
