<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.orderData"
                placeholder="请选择订单日期"
              ></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-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">
              <a-form-item label="发货状态">
                <a-select placeholder="请选择发货状态" v-model="queryParam.shippingStatu">
                  <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>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" @click="synchronization" icon="reload">同步</a-button>
    </div>

    <!-- table区域  rowKey="id" -->
    <div>
      <a-table
        bordered
        :row-key="record => record.id"
        :columns="orderLIstColumns"
        :data-source="orderListData"
        :loading="loading"
        :pagination="ipagination"
        :scroll="{ x: 1500 }"
        @change="handleTableChange"
      >
        <!-- 订单号 链接-->
        <span slot="orderNum" slot-scope="text">
          <a>{{ text }}</a>
        </span>

        <!-- 同步状态 -->
        <!-- slot-scope="text, record" -->
        <span slot="synchronousStats">
          <!-- v-if="record.isRelease == '0'" -->
          <a-tag color="green">同步成功</a-tag>
          <!-- <a-tag color="red" v-else>同步失败</a-tag> -->
          <!-- <a-tag color="orange" v-else>未同步</a-tag> -->
        </span>
      </a-table>
    </div>

    <!-- 订单数据明细 抽屉 -->
    <orderDetail-drawer ref="orderDetailDrawer" :father="aa" @ok="modalFormOk"></orderDetail-drawer>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'
import OrderDetailDrawer from '@views/order/orderDetailDrawer.vue'

export default {
  name: 'OrderList',
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment, OrderDetailDrawer },

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

    return {
      description: '订单销售列表页面',
      // 表头
      orderLIstColumns: [
        {
          title: '订单号',
          width: 140,
          dataIndex: 'orderNum',
          fixed: 'left',
          className: 'replacecolor',
          customCell: this.showDrawer,
          scopedSlots: { customRender: 'orderNum' }
        },
        //  {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        { title: '订单日期', width: 120, dataIndex: 'orderData', fixed: 'left', className: 'replacecolor' },
        { title: '业务类型', width: 120, dataIndex: 'businessType', className: 'replacecolor' },
        { title: '客户订单', width: 120, dataIndex: 'customerorder', className: 'replacecolor' },
        {
          title: '销售类型',
          width: 120,
          dataIndex: 'saleType',

          className: 'replacecolor',
          customRender: function(text) {
            if (text == '1') {
              return '销售类型1'
            }
            if (text == '2') {
              return '销售类型2'
            }
            if (text == '3') {
              return '销售类型3'
            }
            if (text == '4') {
              return '销售类型4'
            }
          }
        },
        { title: '客户简称', width: 150, dataIndex: 'customerShortName', className: 'replacecolor' },
        { title: '客户名称', width: 120, dataIndex: 'customerName', className: 'replacecolor' },
        { title: '供应商', width: 120, dataIndex: 'supplier', className: 'replacecolor' },
        { title: '汇率', width: 90, dataIndex: 'exchangeRate', className: 'replacecolor' },
        { title: '整单合计', width: 120, dataIndex: 'documentTotal', className: 'replacecolor' },
        { title: '销售部门', width: 120, dataIndex: 'salesDepartment', className: 'replacecolor' },
        { title: '业务员', width: 120, dataIndex: 'salesman', className: 'replacecolor' },
        { title: '币种', width: 120, dataIndex: 'currency', className: 'replacecolor' },
        { title: '品牌方', width: 120, dataIndex: 'brand', className: 'replacecolor' },
        { title: '第三方', width: 120, dataIndex: 'thirdparty', className: 'replacecolor' },
        { title: '定金比例(%)', width: 120, dataIndex: 'depositRatio', className: 'replacecolor' },
        { title: '定金', width: 120, dataIndex: 'deposit', className: 'replacecolor' },
        { title: '协同路线', width: 120, dataIndex: 'collaborativeRoute', className: 'replacecolor' },
        { title: '付款条件', width: 180, dataIndex: 'paymentClause', className: 'replacecolor' },
        { title: '最终客户', width: 120, dataIndex: 'finalCustomer', className: 'replacecolor' },
        {
          title: '订单备注',
          width: 180,
          dataIndex: 'orderNote',
          customRender: t => ellipsis(t),
          className: 'replacecolor',
          scopedSlots: { customRender: 'orderNote' }
        },
        {
          title: '价格备注',
          width: 120,
          dataIndex: 'priceNote',
          customRender: t => ellipsis(t),
          className: 'replacecolor',
          scopedSlots: { customRender: 'priceNote' }
        },
        {
          title: '同步状态',
          width: 120,
          dataIndex: 'synchronousStats',
          fixed: 'right',
          className: 'replacecolor',
          scopedSlots: { customRender: 'synchronousStats' }
        },
        {
          title: '订单变更说明',
          width: 180,
          dataIndex: 'orderChangeDesc',
          fixed: 'right',
          customRender: t => ellipsis(t),
          className: 'replacecolor',
          scopedSlots: { customRender: 'orderChangeDesc' }
        }
      ],
      orderListData: [
        { orderNum: 'AA002200001' },
        { orderNum: 'AA002204502' },
        { orderNum: 'AA002206503' },
        { orderNum: 'AA002200004' }
      ],
      loading: false, // 表格加载
      // 查询条件
      queryParam: {
        index: '',
        planNum: '',
        customerShortName: ''
      }
    }
  },
  created() {
    // 渲染订单销售列表
  },
  methods: {
    // 同步
    synchronization() {},

    // 查询按钮
    searchQuery() {
      // 渲染订单销售列表
    },
    searchReset() {
      // console.log('>>>>重置')
      this.queryParam = {}
      // 重新渲染订单销售列表
    },

    // 【订单号】 抽屉
    showDrawer(record) {
      return {
        on: {
          click: event => {
            console.log('点击了单元格')
            // this.$router.push('orderDetail')
            this.$refs.orderDetailDrawer.visible = true
          }
        }
      }
    },
    // father 抽屉方法
    aa() {}

    // 分页、排序、筛选变化时触发
    // 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>
