<template>
  <a-modal
    :title="modalTitle"
    :width="850"
    :visible="visible"
    :confirmLoading="confirmLoading"
    class="ant-modal2"
    @cancel="handleCancel"
  >
    <a-layout>
      <a-layout-content style="background-color: rgb(255, 255, 255)">
        <a-divider orientation="left">报修详情</a-divider>
        <detail-list title="" :col="2">
          <detail-list-item term="报修单号">{{ model.applicationNo }}</detail-list-item>
          <detail-list-item term="设备名称">{{ model.sbName }}</detail-list-item>
          <detail-list-item term="部件名称">{{ model.partName }}</detail-list-item>
          <detail-list-item term="是否停机">{{ BaseTool.Object.getField(needStopMap,model.needStop) }}</detail-list-item>
          <detail-list-item term="报修人">{{ model.repairUserName }}</detail-list-item>
          <detail-list-item term="报修来源">{{ BaseTool.Object.getField(this.sourceMap, model.applicationSource) }}</detail-list-item>
          <detail-list-item term="紧急等级"><badge :text="BaseTool.Object.getField(levelMap,model.applicationLevel)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[model.applicationLevel]"/></detail-list-item>
          <detail-list-item term="报修时间">{{ model.applicationApplyTime }}</detail-list-item>
        </detail-list>
        <a-divider orientation="left">维修详情</a-divider>
        <detail-list title="" :col="2">
          <detail-list-item term="维修单号">{{ model.no }}</detail-list-item>
          <detail-list-item term="报修单">{{ model.applicationNo }}</detail-list-item>
          <detail-list-item term="故障类别">{{ model.errorTypeName }}</detail-list-item>
          <detail-list-item term="维修开始时间">{{ model.startTime }}</detail-list-item>
          <detail-list-item term="维修结束时间">{{ model.endTime }}</detail-list-item>
          <detail-list-item term="维修耗时">{{ model.minutes }}</detail-list-item>
          <detail-list-item term="维修人员">{{ model.repairPersonName }}</detail-list-item>
          <detail-list-item term="维修状态"><badge :text="BaseTool.Object.getField(statusMap,model.status)" :status="DictCache.COLOR.REPAIR_FORM_STATUS[model.status]"/></detail-list-item>
          <detail-list-item term="维修次数">{{ model.times }}</detail-list-item>
        </detail-list>

        <a-divider orientation="left">转派详情</a-divider>
        <detail-list v-for="item in model.dispatchList" title="" :col="2">
          <detail-list-item term="转派人">{{ item.username }}</detail-list-item>
          <detail-list-item term="转派时间">{{ item.time }}</detail-list-item>
          <detail-list-item term="转派备注">{{ item.remark }}</detail-list-item>
        </detail-list>

        <a-divider orientation="left">验收详情</a-divider>
          <detail-list title="" :col="2">
            <detail-list-item term="验收开始时间">{{ model.startTime }}</detail-list-item>
            <detail-list-item term="验收结束时间">{{ model.endTime }}</detail-list-item>
            <detail-list-item term="维修人员">{{ model.checkUserName }}</detail-list-item>
            <detail-list-item term="验收描述">{{ model.descripition }}</detail-list-item>
            <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
            <detail-list-item term="验收状态"><badge :text="BaseTool.Object.getField(statusMap,model.status)" :status="DictCache.COLOR.REPAIR_CHECK_STATUS[model.status]"/></detail-list-item>
        </detail-list>
      </a-layout-content>
      <a-layout-sider style="background-color: rgb(255, 255, 255)">
        <div style="margin-top: 30px;margin-left: 30px;">
          <a-steps progress-dot :current="6" direction="vertical">
            <a-step title="报修时间:" :description="''+model.applicationApplyTime?model.applicationApplyTime:''" />
            <a-step title="派工时间:" :description="''+model.applicationApplyTime?model.applicationApplyTime:''" />
            <a-step title="维修开始时间:" :description="''+model.startTime?model.startTime:''" />
            <a-step title="维修结束时间:" :description="''+model.endTime?model.endTime:''" />
            <a-step title="验收开始时间:" :description="''+model.checkStartTime?model.checkStartTime:''" />
            <a-step title="验收结束时间:" :description="''+model.checkEndTime?model.checkEndTime:''" />
          </a-steps>
        </div>
      </a-layout-sider>
    </a-layout>

    <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: 'RepairFormDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      needStopMap: {},
      statusMap: {},
      sourceMap: {},
      levelMap: {},
      model: {
        'no': null,
        'applicationId': null,
        'errorTypeId': null,
        'needStop': null,
        'startTime': null,
        'dispatchList': null,
        'endTime': null,
        'minutes': null,
        'repairPersonId': null,
        'descripition': null,
        'status': null,
        'times': null,
        'remark': null,
        'updateTime': null,
        'createdUserId': null,
        'updateUserId': null,
        'createdUserName': null,
        'updateUserName': null
      }
    }
  },
  created () {
    // 下拉框map
    this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_FORM_STATUS)
    this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
    }

  }
}
</script>
