<template>
  <a-modal
    :title="modalTitle"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    class="ant-modal2"
    @cancel="handleCancel"
  >
      <detail-list title="" :col="3">
        <detail-list-item term="型号库id">{{ model.id }}</detail-list-item>
        <detail-list-item term="型号">{{ model.model }}</detail-list-item>
        <detail-list-item term="设备名称">{{ model.name }}</detail-list-item>
        <detail-list-item term="名称型号">{{ model.nameModel }}</detail-list-item>
        <detail-list-item term="价格">{{ model.value }}</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="生产商">{{ model.producerName }}</detail-list-item>
        <detail-list-item term="计量单位">{{ model.unit }}</detail-list-item>
        <detail-list-item term="自定义类别">{{ BaseTool.Object.getField(useTypeMap,model.useType) }}</detail-list-item>
        <detail-list-item term="创建人">{{ model.createdUserName }}</detail-list-item>
        <detail-list-item term="状态"><badge :status="DictCache.COLOR.SB_INFO_STATUS[model.status]" :text="statusMap[model.status]"></badge></detail-list-item>
      </detail-list>

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

<script>
import DetailList from '@/components/tools/DetailList'
import PartInfoTable from '@/views/part/info/modules/PartInfoTable'
import RepairApplicationFormTable from '@/views/repair/application-form/modules/RepairApplicationFormTable'
import RepairFormTable from '@/views/repair/form/modules/RepairFormTable'
import CheckJobTable from '@/views/check/checkjob/modules/CheckJobTable'
import { fetchFirmProducer } from '@/api/firm/producer'
import RepairPartUsedTable from '@/views/repair/part-used/modules/RepairPartUsedTable'
const DetailListItem = DetailList.Item

export default {
  name: 'SbInfoDetail',
  components: {
    DetailList,
    DetailListItem,
    RepairApplicationFormTable,
    RepairFormTable,
    CheckJobTable,
    PartInfoTable,
    RepairPartUsedTable
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      activeKey: '1',
      collapseActiveKey: '1',
      model: {
        'no': null,
        'financingNo': null,
        'name': null,
        'typeId': null,
        'level': null,
        'useType': null,
        'initialValue': null,
        'guigeId': null,
        'status': null,
        'remark': null,
        'typeName': null,
        'producerName': null,
        'guigeName': null,
      },
      depreciationTypeMap: {},
      levelMap: {},
      firmProducerLevelMap: {},
      firmSupplier: {},
      firmProducer: {},
      statusMap: {},
      useTypeMap: {},
      unitMap: {},
      sourceTypeMap: {}
    }
  },
  created () {
    this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
    this.firmProducerLevelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.FIRM_PRODUCER_LEVEL)
    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_MODEL_RECOMMEND)
    this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
    this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
    this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  },
  computed: {
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
      this.activeKey = '1'
      this.collapseActiveKey = '1'
      fetchFirmProducer({ id: this.model.producerId }).then(res => {
        this.firmProducer = res.data
      })
      // this.$refs.partInfoList.base({ sbId: record.id }, { sbId: record.id })
    },

    handleCancel () {
      this.visible = false
      this.confirmLoading = false
    }

  }
}
</script>
