<template>
  <div class="app-container print-work">
    <div class="level-title">
      <h1>动火申请审批许可证</h1>
    </div>
    <table class="table-ui">
      <tr>
        <td class="bbg-transparent" rowspan="2">动火申请人</td>
        <td rowspan="2">{{ info.APPLY_USER_NAME }}</td>
        <td class="bbg-transparent" rowspan="2">动火申请单位/部门</td>
        <td rowspan="2">{{ info.APPLY_DEPARTMENT_NAME }}</td>
        <td class="bbg-transparent" colspan="2" style="text-align: center;">动火许可证编号</td>
      </tr>
      <tr>
        <td colspan="2" style="text-align: center;">{{ info.JOB_NUMBER }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">动火部位</td>
        <td>{{ info.HOT_WORK_POSITION }}</td>
        <td class="bbg-transparent">动火方法</td>
        <td>{{ info.HOT_WORK_METHOD_NAME }}</td>
        <td class="bbg-transparent">动火等级</td>
        <td>
          <template v-if="info.HOT_WORK_LEVEL_INDEX == '0'">特级</template>
          <template v-else-if="info.HOT_WORK_LEVEL_INDEX == '1'">一级</template>
          <template v-else-if="info.HOT_WORK_LEVEL_INDEX == '2'">二级</template>
          <template v-else-if="info.HOT_WORK_LEVEL_INDEX == '3'">三级</template>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">作业内容</td>
        <td colspan="5">{{ info.JOB_CONTENT }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent" rowspan="2">现场负责人</td>
        <td>姓名：{{ info.SITE_LEADER_NAME }}</td>
        <td class="bbg-transparent" rowspan="2">动火操作人</td>
        <td rowspan="2">{{ info.HOT_WORK_OPERATOR_NAME }}</td>
        <td class="bbg-transparent" rowspan="2">动火监火人</td>
        <td rowspan="2">{{ info.SUPERVISOR_OF_HOT_WORK_UNIT }}</td>
      </tr>
      <tr>
        <td>电话:{{ info.SITE_LEADER_PHONE }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">动火时间</td>
        <td colspan="5">{{ info.HOT_WORK_TIME_START }} 至 {{ info.HOT_WORK_TIME_END }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">
          动火要求<br>
          安全措施<br>
          安全提示
        </td>
        <td colspan="5">
          <table class="table-vi">
            <tr v-for="item in measuresList" :key="item.BUS_HOTWORK_MEASURES_ID">
              <td>
                {{ item.PROTECTIVE_MEASURES }}
                <template v-if="item.ANSWER1">及({{ item.ANSWER1 }}){{ item.QUESTION1 }}</template>
                <template v-if="item.QUESTION2">
                  、{{ item.QUESTION2 }}({{ item.ANSWER2 }}) 、{{ item.QUESTION3 }}({{ item.ANSWER3 }}) 、{{ item.QUESTION4 }}({{ item.ANSWER4 }})
                </template>
              </td>
            </tr>
            <tr v-for="item in safetymethodrecordList" :key="item.HOTWORKSAFETYMETHODRECORD_ID">
              <td>{{ item.CONTENT }}</td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">动火单位(部门)负责人意见</td>
        <td colspan="5">
          <img v-viewer v-if="info.HOT_WORK_USER_PRINCIPAL" :src="config.fileUrl+info.HOT_WORK_USER_PRINCIPAL" width="50px" height="50px">
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">现场管辖单位(部门)负责人意见</td>
        <td colspan="5">
          <img v-viewer v-if="info.UNIT_LEADER_PRINCIPAL" :src="config.fileUrl+info.UNIT_LEADER_PRINCIPAL" width="50px" height="50px">
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">动火许可证签发单位意见</td>
        <td colspan="5">
          <img v-viewer v-if="info.ISSUING_PRINCIPAL" :src="config.fileUrl+info.ISSUING_PRINCIPAL" width="50px" height="50px">
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent" rowspan="2">动火前管辖单位现场人员许可</td>
        <td colspan="2">
          姓名：
          <img v-viewer v-if="info.HOT_WORK_PERSON_PRINCIPAL" :src="config.fileUrl+info.HOT_WORK_PERSON_PRINCIPAL" width="50px" height="50px">
        </td>
        <td class="bbg-transparent" rowspan="2">动火后管辖单位现场人员验收</td>
        <td colspan="2">
          姓名：
          <img v-viewer v-if="info.HOT_WORK_AFTER_PRINCIPAL" :src="config.fileUrl+info.HOT_WORK_AFTER_PRINCIPAL" width="50px" height="50px">
        </td>
      </tr>
      <tr>
        <td colspan="2">时间：{{ info.HOT_WORK_PERSON_PRINCIPAL == ''?'':info.HOT_WORK_PERSON_PRINCIPAL_TIME }}</td>
        <td colspan="2">时间：{{ info.HOT_WORK_AFTER_PRINCIPAL == ''?'':info.HOT_WORK_AFTER_PRINCIPAL_TIME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">延时监火记录</td>
        <td colspan="5">
          <table class="table-ui">
            <tr>
              <td>监火人</td>
              <td>时间</td>
              <td>照片</td>
            </tr>
            <tr v-for="item in delayedList" :key="item.HOTWORKAPPLICATIONDELAYED_ID">
              <td>{{ item.userName }}</td>
              <td>{{ item.TIME }}</td>
              <td>
                <img v-viewer v-if="item.FILEPATH" :src="config.fileUrl+item.FILEPATH" width="50px" height="50px">
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
import { requestFN } from '@/utils/request'

export default {
  props: {
    id: {
      type: String,
      default() {
        return ''
      }
    },
    type: {
      type: String,
      default() {
        return ''
      }
    },
    gangkou: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      config: config,
      info: {},
      measuresList: [],
      hImgs: [],
      safetymethodrecordList: [],
      delayedList: []
    }
  },
  created() {
    this.getData()
    this.getListAllMeasures()
    this.getDelayed()
  },
  methods: {
    getData() {
      requestFN(
        '/map/Eight/getById',
        {
          id: this.id,
          TYPE: this.type,
          GANGKOU: this.gangkou
        }
      ).then((data) => {
        if (data.pd && data.pd.HOT_WORK_OPERATOR_NAME && data.pd.HOT_WORK_OPERATOR_NAME.length > 0) {
          data.pd.HOT_WORK_OPERATOR_NAME = data.pd.HOT_WORK_OPERATOR_NAME.substring(0, data.pd.HOT_WORK_OPERATOR_NAME.length - 1)
        }
        this.info = data.pd
        this.safetymethodrecordList = data.safetymethodrecordList
        this.delayedList = data.delayedList
      }).catch((e) => {
      })
    },
    getListAllMeasures() {
      requestFN(
        '/map/Eight/listAllMeasures',
        {
          HOTWORKAPPLICATION_ID: this.id,
          GANGKOU: this.gangkou
        }
      ).then((data) => {
        this.measuresList = data.varList
      }).catch((e) => {
      })
    },
    getDelayed() {
      requestFN(
        '/map/Eight/list',
        {
          HOTWORKAPPLICATION_ID: this.id,
          GANGKOU: this.gangkou
        }
      ).then((data) => {
        this.hImgs = data.varList
      }).catch((e) => {
      })
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
