<template>
  <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
    <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" type="default" @click="handleCancel()">返回</a-button>
        </span>
      </a-col>
    </a-row>
    <detail-list title="" :col="2">
      <detail-list-item term="单号">{{ model.no }}</detail-list-item>
      <detail-list-item term="设备Id"><a @click="sbIdhandleDetail">{{ model.sbId }}</a></detail-list-item>
      <detail-list-item term="维修id">{{ model.repairId }}</detail-list-item>
      <detail-list-item term="申请人">{{ model.userId }}</detail-list-item>
      <detail-list-item term="类型">{{ BaseTool.Object.getField(this.typeMap,model.type) }}</detail-list-item>
      <detail-list-item term="申请日期">{{ model.applyDate }}</detail-list-item>
      <detail-list-item term="启用日期">{{ model.startDate }}</detail-list-item>
      <detail-list-item term="停用日期">{{ model.stopDate }}</detail-list-item>
      <detail-list-item term="停用原因">{{ model.content }}</detail-list-item>
      <detail-list-item term="状态">{{ BaseTool.Object.getField(this.statusMap,model.status) }}</detail-list-item>
      <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
      <detail-list-item term="更新时间">{{ model.updateTime }}</detail-list-item>
      <detail-list-item term="更新人">{{ model.updateUserName }}</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: 'SbInfoStopDetailDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      typeMap: {},
      statusMap: {},
      model: {
        'no': null,
        'sbId': null,
        'repairId': null,
        'userId': null,
        'type': null,
        'applyDate': null,
        'startDate': null,
        'stopDate': null,
        'content': null,
        'status': null,
        'remark': null,
        'updateTime': null,
        'createdUserId': null,
        'updateUserId': null,
        'updateUserName': null
      }
    }
  },
  created () {
    // 下拉框map

    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STOP_DETAIL_TYPE)
    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STOP_DETAIL_STATUS)
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
    },
    handleCancel () {
      this.visible = false
      this.$emit('ok')
    },
    sbIdhandleDetail () {
      const text = this.$router.resolve({
        name: 'SbInfo',
        query: { id: this.model.sbId }
      })
      // 打开一个新的页面
      window.open(text.href, '_blank')
    }
  }
}
</script>
