<template>
  <div class="intelligentReplenishmentImport-wrap">
    <a-page-header :ghost="false" :backIcon="false" class="intelligentReplenishmentImport-back">
      <!-- 自定义的二级文字标题 -->
      <template slot="subTitle">
        <a id="intelligentReplenishmentImport-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
      </template>
    </a-page-header>
    <a-card size="small" :bordered="false" class="intelligentReplenishmentImport-cont">
      <div>
        <p class="total">共 <span>50</span> 条数据，红色字体表示数据不符合规范，请返回上一步修改文件后重新上传</p>
        <s-table
          class="sTable"
          ref="table"
          size="small"
          :rowKey="(record) => record.id"
          :columns="columns"
          :data="loadData"
          :scroll="{ x: 1440 }"
          bordered>
        </s-table>
        <div class="btn-cont">
          <a-button type="primary" class="button-error" id="intelligentReplenishmentLevel-submit" @click="handleSubmit">确认导入</a-button>
          <a-button type="primary" class="button-error" id="intelligentReplenishmentLevel-back" @click="handleBackSet">上一步</a-button>
          <a-button id="intelligentReplenishmentLevel-back" @click="isShow = false" class="button-cancel">取消</a-button>
        </div>
      </div>
    </a-card>
  </div>
</template>

<script>
import { STable } from '@/components'
export default {
  components: { STable },
  data () {
    return {
      columns: [
        { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
        { title: '产品编码', dataIndex: 'purchaseNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品名称', dataIndex: 'creatDate', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '产品状态', dataIndex: 'purchaseNos', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '订货周期（天）', dataIndex: 'purchaseNoa', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '是否淘汰', dataIndex: 'purchaseNod', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '淘汰描述', dataIndex: 'purchaseNof', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '备注', dataIndex: 'purchaseNog', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '错误原因', dataIndex: 'purchaseNoh', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        // return custTypeList(Object.assign(parameter, this.queryParam)).then(res => {
        //   const data = res.data
        //   const no = (data.pageNo - 1) * data.pageSize
        //   for (var i = 0; i < data.list.length; i++) {
        //     data.list[i].no = no + i + 1
        //   }
        //   return data
        // })
        return new Promise(function (resolve, reject) {
          const data = {
            pageNo: 1,
            pageSize: 10,
            list: [
              { id: '1', state: 1, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
              { id: '2', state: 2, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
              { id: '3', state: 3, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
              { id: '4', state: 4, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' },
              { id: '5', state: 5, purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' }
            ],
            count: 10
          }
          resolve(data)
        })
      }
    }
  },
  methods: {
    // 返回
    handleBack () {
      this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/list` })
    },
    // 返回基础设置页
    handleBackSet () {
      this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/set/${this.$route.params.sn}` })
    },
    // 确认导入
    handleSubmit () {}
  }
}
</script>
<style lang="less">
  .intelligentReplenishmentImport-wrap{
    .intelligentReplenishmentImport-back{
      margin-bottom: 10px;
    }
    .intelligentReplenishmentImport-cont{
      .total{
        margin: 20px 0 30px;
        span{
          font-weight: bold;
        }
      }
      .btn-cont{
        margin: 30px 0 20px;
        text-align: center;
        .button-cancel{
          font-size: 12px;
          margin-left: 15px;
        }
      }
    }
  }
</style>
