<template>
  <a-modal
    centered
    class="bulkWarehousingOrder-auditNo-modal"
    :footer="null"
    :maskClosable="false"
    title="提示"
    v-model="isShow"
    @cancel="isShow=false"
    :width="960">
    <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
      <!-- 总计 -->
      <a-alert style="margin-bottom:10px" type="error" message="对不起，审核失败! OCS和金蝶上产品成本不一致。请确保成本价格一致后再进行审核。" />
      <!-- 列表 -->
      <a-table
        class="sTable"
        ref="table"
        size="small"
        :rowKey="(record) => record.id"
        :columns="columns"
        :dataSource="list"
        :scroll="{ y: 400 }"
        :pagination="false"
        bordered>
      </a-table>
    </a-card>
    <div class="btn-cont">
      <a-button id="bulkWarehousingOrder-auditNo-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
    </div>
  </a-modal>
</template>

<script>
export default {
  name: 'AuditNoPassModal',
  props: {
    openModal: { //  弹框显示状态
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      isShow: this.openModal, //  是否打开弹框
      list: []
    }
  },
  computed: {
    columns () {
      const arr = [
        { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
        { title: '产品编码', dataIndex: 'productCode', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品名称', dataIndex: 'productName', width: '40%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
      ]
      if (this.$hasPermissions('B_isShowCost')) { //  成本价权限
        arr.splice(5, 0, { title: 'OCS成本价', dataIndex: 'verifyCost', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
        arr.splice(5, 0, { title: '金蝶成本价', dataIndex: 'productCost', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
      }
      return arr
    }
  },
  methods: {
    //  返回列表
    handleBack () {
      this.isShow = false
    },
    setData (data) {
      this.list = data
      this.list.map((item, i) => {
        item.no = i + 1
      })
    }
  },
  watch: {
    //  父页面传过来的弹框状态
    openModal (newValue, oldValue) {
      this.isShow = newValue
    },
    //  重定义的弹框状态
    isShow (newValue, oldValue) {
      if (!newValue) {
        this.$emit('close')
      }
    }
  }
}
</script>

<style lang="less">
  .bulkWarehousingOrder-auditNo-modal{
    .ant-modal-body {
      padding: 10px 10px 20px;
    }
    .btn-cont {
      text-align: center;
      margin: 5px 0 10px;
    }
  }
</style>
