<template>
  <a-modal
    :title="modalTitle"
    :width="850"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
  >
    <detail-list title="" :col="2">
      <detail-list-item term="入库单号">{{ model.inNo }}</detail-list-item>
      <detail-list-item term="入库类型">{{ BaseTool.Object.getField(typeMap,model.type) }}</detail-list-item>
      <detail-list-item term="采购/发运单号">{{ BaseTool.Object.getField(typeMap,model.type) }}</detail-list-item>
      <detail-list-item term="仓库">{{ model.storeName }}</detail-list-item>
      <detail-list-item term="状态"><badge :text="BaseTool.Object.getField(statusMap,model.status)" :status="statusMap[model.status]"/></detail-list-item>
      <detail-list-item term="创建人">{{ model.createdUserName }}</detail-list-item>
<!--      <detail-list-item term="更新人">{{ model.updateUserName }}</detail-list-item>-->
      <detail-list-item term="更新日期">{{ model.updateTime }}</detail-list-item>
    </detail-list>
    <detail-list title="" :col="1">
      <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
    </detail-list>
    <a-row>
      <a-col :span="2">总价：</a-col>
      <a-col :span="12" style="color: red">{{ model.totalPrice }}</a-col>
    </a-row>
    <title-divider title="备件明细" width="90px"></title-divider>
    <a-table
      bordered
      :data-source="data"
      :columns="columns"
      tableLayout="auto"
      rowKey="id"
    >
    </a-table>
    <template slot="footer">
      <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">返回</a-button>
    </template>
  </a-modal>
</template>

<script>
import DetailList from '@/components/tools/DetailList'
const DetailListItem = DetailList.Item

export default {
  name: 'InStoreFormDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      typeMap: {},
      statusMap: {},
      model: {
        'inNo': null,
        'type': null,
        'storeId':null,
        'storeName':null,
        'totalPrice': null,
        'remark': null,
        'createdUserId': null,
        'updateUserId': null,
        'updateTime': null,
        'createdUserName': null,
        'updateUserName': null
      },
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: 'index',
          customRender: (text, record, index) => {
            return index + 1
          }
        },
       // {
         // title: '入库仓库',
          //dataIndex: 'storeId',
          //customRender: (text, record, index) => {
           // return record.storeName
          //}
       // },
        {
          title: '备件名称',
          dataIndex: 'spareId',
          customRender: (text, record, index) => {
            return record.spareName
          }
        },
        {
          title: '编号',
          dataIndex: 'no'
        },
        {
          title: '备件规格',
          dataIndex: 'ggxh'
        },
        {
          title: '原厂编号',
          dataIndex: 'initNo'
        },
        {
          title: '数量',
          dataIndex: 'num'
        },
        {
          title: '单价',
          dataIndex: 'price'
        },
        {
          title: '总价',
          dataIndex: 'totalPrice'
        }
      ],
      data: []
    }
  },
  created () {
    // 下拉框map
    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.IN_STORE_FORM_TYPE)
    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.IN_STORE_FORM_STATUS)

  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
      this.data = record.detailList
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
    }

  }
}
</script>
