<template>
  <a-card :bordered="false" :title="modalTitle" v-show="visible">
    <a-row :gutter="48" slot="extra">
      <a-col :md="48" :sm="48">
        <span class="table-page-search-submitButtons" style="float: right">
          <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
        </span>
      </a-col>
    </a-row>
    <title-divider title="备件信息" width="90px"></title-divider>
    <detail-list title="" :col="3">
      <detail-list-item v-for="item in model.applicationFileList" term="">
        <img :src="BaseTool.Constant.FILE_URL + item.url" width="200px" height="200px"/>
      </detail-list-item>
      <detail-list-item term=""><img-code :src="model.qrCode" :type="2" :code-id="model.id" :width="200"></img-code></detail-list-item>
    </detail-list>
    <title-divider title="基础信息" width="90px"></title-divider>
    <detail-list title="" :col="3">
      <detail-list-item term="id">{{ model.id }}</detail-list-item>
      <detail-list-item term="集团统一编码">{{ model.uniteNo }}</detail-list-item>
      <detail-list-item term="自编号">{{ model.zbh }}</detail-list-item>
      <detail-list-item term="备件编码">{{ model.no }}</detail-list-item>
      <detail-list-item term="备件名称">{{ model.name }}</detail-list-item>
      <detail-list-item term="名称编码">{{ model.nameNo }}</detail-list-item>
      <detail-list-item term="规格型号">{{ model.ggxh }}</detail-list-item>
      <detail-list-item term="规格编码">{{ model.ggNo }}</detail-list-item>
      <detail-list-item term="备件类别">{{ model.typeName }}</detail-list-item>
      <detail-list-item term="备件等级">{{ BaseTool.Object.getField(levelMap,model.level) }}</detail-list-item>
      <detail-list-item term="备件价值">{{ BaseTool.Amount.formatter(model.initialValue) }}</detail-list-item>
      <detail-list-item term="生产商">{{ model.producerName }}</detail-list-item>
      <detail-list-item term="原厂编号">{{ model.initNo }}</detail-list-item>
      <detail-list-item term="计量单位">{{ model.unit }}</detail-list-item>
      <detail-list-item term="包装单位">{{ model.unitBz }}</detail-list-item>
      <detail-list-item term="折算系数">{{ model.unitRate }}</detail-list-item>
      <detail-list-item term="当前库存">{{ model.currentStock }}</detail-list-item>
      <detail-list-item term="最高库存">{{ model.maxStock }}</detail-list-item>
      <detail-list-item term="最低库存">{{ model.minStock }}</detail-list-item>
      <detail-list-item term="英文名称">{{ model.englishName }}</detail-list-item>
      <detail-list-item term="助记码">{{ model.zjm }}</detail-list-item>
      <detail-list-item term="产地">{{ BaseTool.Object.getField(cdMap,model.cd) }}</detail-list-item>
      <!--<detail-list-item term="用途">{{ BaseTool.Object.getField(ytMap,model.yt) }}</detail-list-item>-->
      <detail-list-item term="备注">{{ model.remark }}</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>

    <template slot="footer">
      <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">返回</a-button>
    </template>
  </a-card>
</template>

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

export default {
  name: 'SparePartInfoDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      levelMap: {},
      unitMap: {},
      cdMap: {},
      ytMap: {},
      model: {
        'no': null,
        'name': null,
        'ggxh': null,
        'typeId': null,
        'level': null,
        'initialValue': null,
        'producerId': null,
        'unit': null,
        'unitBz': null,
        'unitRate': null,
        'currentStock': null,
        'maxStock': null,
        'qrCode': null,
        'applicationFileList': [],
        'minStock': null,
        'remark': null,
        'createdUserId': null,
        'updateUserId': null,
        'updateTime': null,
        'createdUserName': null,
        'updateUserName': null,
        'producerName': null,
        'typeName': null

      }
    }
  },
  created () {
    // 下拉框map
    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
    this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
    this.cdMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PRODUCER_AREA)
    this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
      this.$emit('ok')
    }

  }
}
</script>
