<template>
  <a-modal
    centered
    class="chooseImport-modal"
    :footer="null"
    :maskClosable="false"
    title="结算明细"
    v-model="isShow"
    @cancle="isShow=false"
    width="70%">
    <div class="chooseImport-con">
      <a-descriptions :column="3">
        <a-descriptions-item label="结算时间">
          Zhou Maomao
        </a-descriptions-item>
        <a-descriptions-item label="结算金额">
          1810000000
        </a-descriptions-item>
        <a-descriptions-item label="支付方式">
          Hangzhou, Zhejiang
        </a-descriptions-item>
      </a-descriptions>
      <!-- 可导入数据 -->
      <a-table
        class="sTable"
        ref="table"
        size="small"
        :rowKey="(record) => record.allocateSn"
        :columns="nowColumns"
        :dataSource="loadData"
        :loading="loading"
        :scroll="{ y: 200 }"
        :pagination="false"
        bordered>
      </a-table>
    </div>
  </a-modal>
</template>

<script>
// import { hdExportExcel } from '@/libs/exportExcel'
// import { sparePartsDetailParseProducts, sparePartsDetailFailExcel } from '@/api/spareParts'
export default {
  name: 'ChooseImportModal',
  props: {
    openModal: { //  弹框显示状态
      type: Boolean,
      default: false
    },
    paramsData: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data () {
    return {
      isShow: this.openModal, //  是否打开弹框
      nowColumns: [
        { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
        { title: '取货时间', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '订单编号', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '取货号', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品名称', dataIndex: 'productCode', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品售价', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '下单数量', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '合计金额', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
      ],
      loadData: [],
      loading: false
    }
  },
  methods: {
    getData () {
      const _this = this
      this.loading = true
      const params = {
        sparePartsSn: this.paramsData.sparePartsSn,
        path: this.paramsData.path
      }
      // sparePartsDetailParseProducts(params).then(res => {
      //   this.loading = false
      //   if (res.status == 200) {
      //     if (res.data.okList && res.data.okList.length > 0) {
      //       res.data.okList.map((item, index) => {
      //         item.no = index + 1
      //       })
      //     }
      //     if (res.data.failList && res.data.failList.length > 0) {
      //       res.data.failList.map((item, index) => {
      //         item.no = index + 1
      //       })
      //     }
      //     _this.loadData = res.data.okList || []
      //     _this.unLoadData = res.data.failList || []
      //   }
      // })
    },
    // 确认导入
    handleSubmit () {
      if (this.loadData.length == 0) {
        this.$message.warning('无可导入产品！')
      } else {
        this.$emit('ok', this.loadData)
        this.isShow = false
      }
    },
    // 导出
    handleError () {
      // const _this = this
      // if (_this.unLoadData.length < 1) {
      //   _this.$message.info('暂无可导出错误项~')
      //   return
      // }
      // _this.spinning = true
      // const params = {
      //   list: _this.unLoadData
      // }
      // hdExportExcel(sparePartsDetailFailExcel, params, '产品导入错误项', function () {
      //   _this.spinning = false
      // })
    }
  },
  watch: {
    //  父页面传过来的弹框状态
    openModal (newValue, oldValue) {
      this.isShow = newValue
    },
    //  重定义的弹框状态
    isShow (newValue, oldValue) {
      if (!newValue) {
        this.$emit('close')
        this.loadData = []
        this.unLoadData = []
      } else {
        this.getData()
      }
    }
  }
}
</script>

<style lang="less" scoped>
  .chooseImport-modal{
    .chooseImport-con{
      .red{
        color: #f30;
      }
      .btn-con{
        text-align: center;
        margin: 30px 0 20px;
        .button-cancel,.button-error{
          font-size: 12px;
        }
      }
    }
  }
</style>
