<template>
  <a-modal
    :title="modalTitle"
    :width="850"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
  >
    <detail-list title="" :col="2">
      <detail-list-item term="设备名称">{{ model.sbName }}</detail-list-item>
      <!--<detail-list-item term="部件名称">{{ model.partName }}</detail-list-item>-->
      <detail-list-item term="备件名称">{{ model.spareName }}</detail-list-item>
      <detail-list-item term="投用日期">{{ model.startDate }}</detail-list-item>
      <detail-list-item term="预计报废日期">{{ model.changeDate }}</detail-list-item>
      <detail-list-item term="实际更换日期">{{ model.realChangeDate }}</detail-list-item>
      <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
      <detail-list-item term="使用状态"><badge :status="DictCache.COLOR.SPARE_PART_USED_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'
const DetailListItem = DetailList.Item

export default {
  name: 'SparePartUsedDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      statusMap: {},
      model: {
        'sbId': null,
        'partId': null,
        'spareId': null,
        'startDate': null,
        'status': null,
        'changeDate': null,
        'realChangeDate': null,
        'remark': null,
        'createdUserId': null,
        'updateUserId': null,
        'updateTime': null,
        'createdUserName': null,
        'updateUserName': null,
        'partName': null,
        'spareName': null,
        'sbName': null
      }
    }
  },
  created () {
    // 下拉框map
    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_USED_STATUS)
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
    }

  }
}
</script>
