<template>
  <div class="app-container print-work">
    <div class="level-title">
      <h1>高处作业许可证</h1>
      <div class="level-btns">编号:{{ info.CHECK_NO }}</div>
    </div>

    <table class="table-ui">
      <tr>
        <td class="bbg-transparent" style="width: 20%">作业申请单位</td>
        <td style="width: 30%">{{ info.APPLY_DEPARTMENT_NAME }}</td>
        <td class="bbg-transparent" style="width: 20%">作业申请时间</td>
        <td style="width: 30%">{{ info.CREATTIME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">作业地点</td>
        <td>{{ info.WORK_PLACE }}</td>
        <td class="bbg-transparent">作业内容</td>
        <td>{{ info.WORK_CONTENT }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">作业高度</td>
        <td>{{ info.WORK_HIGH }}</td>
        <td class="bbg-transparent">高处作业级别</td>
        <td>
          {{ info.WORK_LEVEL == '1' ? 'I级高处作业' : '' }}
          {{ info.WORK_LEVEL == '2' ? 'II级高处作业' : '' }}
          {{ info.WORK_LEVEL == '3' ? 'III级高处作业' : '' }}
          {{ info.WORK_LEVEL == '4' ? 'IV级高处作业' : '' }}
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">作业单位</td>
        <td>{{ info.CONSTRUCTION_DEPARTMENT_NAME }}</td>
        <td class="bbg-transparent">监护人</td>
        <td>
          <div v-if="info.GUARDIAN_USER_SIGNER_PATH" style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.fileUrl + info.GUARDIAN_USER_SIGNER_PATH" alt="" width="80" height="80">
            <span style="width: 200px;display: inline-block">{{ info.GUARDIAN_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">作业人</td>
        <td>{{ info.PROJECT_MANAGER }}</td>
        <td class="bbg-transparent">作业负责人</td>
        <td>{{ info.CONSTRUCTION_USER_NAME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">关联的其他特殊作业及安全作业票编号</td>
        <td colspan="3">{{ info.SPECIAL_WORK }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">风险辨识结果</td>
        <td colspan="3">{{ info.HAZARD_IDENTIFICATION }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">作业实施时间</td>
        <td colspan="3">自 {{ formatDate(info.WORK_START_DATE,'YYYY年MM月DD日HH时mm分') }} 至 {{ formatDate(info.WORK_END_DATE,'YYYY年MM月DD日HH时mm分') }} 止</td>
      </tr>
      <tr>
        <td colspan="4">
          <table class="table-vi">
            <tr class="bbg-transparent">
              <td>序号</td>
              <td>安全措施</td>
              <td style="width: 100px;">是否涉及</td>
              <td style="width: 100px;">确认人</td>
            </tr>
            <tr v-for="(item,index) in measuresList" :key="index">
              <td style="text-align: center">{{ index + 1 }}</td>
              <td>{{ item.PROTECTIVE_MEASURES }}</td>
              <td style="text-align: center">
                <span v-if="item.STATUS=='1'"><input type="radio" disabled checked>涉&nbsp;&nbsp;&nbsp;&nbsp;及</span>
                <span v-if="item.STATUS=='-1'"><input type="radio" disabled checked>不涉及</span>
              </td>
              <td style="text-align: center">
                {{ item.CONFIRM_NAME }}
              </td>
            </tr>
            <tr v-if="info.CONFIRM_USER_MEASURES || info.LEADER_USER_MEASURES || info.AUDIT_USER_MEASURES || info.APPROVE_USER_MEASURES ">
              <td>{{ measuresList.length + 1 }}</td>
              <td colspan="3">
                <div v-if="info.CONFIRM_USER_MEASURES" style="display: flex;justify-content: space-between;">
                  <span>其他安全措施：{{ info.CONFIRM_USER_MEASURES }}</span>
                  <span>编制人：{{ info.CONSTRUCTION_USER_NAME }}</span>
                </div>
                <div v-if="info.LEADER_USER_ID && info.CONFIRM_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                  <span>其他安全措施：{{ info.LEADER_USER_MEASURES }}</span>
                  <span>编制人：{{ info.LEADER_USER_NAME }}</span>
                </div>
                <div v-if="info.AUDIT_USER_ID && info.AUDIT_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                  <span>其他安全措施：{{ info.AUDIT_USER_MEASURES }}</span>
                  <span>编制人：{{ info.AUDIT_USER_NAME }}</span>
                </div>
                <div v-if="info.APPROVE_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                  <span>其他安全措施：{{ info.APPROVE_USER_MEASURES }}</span>
                  <span>编制人：{{ info.APPROVE_USER_NAME }}</span>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">安全交底人</td>
        <td colspan="4">
          <div v-if="info.CONFESS_USER_SIGNER_PATH" style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.fileUrl + info.CONFESS_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ info.CONFESS_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">接受交底人</td>
        <td colspan="4">
          <div v-if="info.ACCEPT_CONFESS_USER_SIGNER_PATH" style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.fileUrl + info.ACCEPT_CONFESS_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ info.ACCEPT_CONFESS_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>

      <tr>
        <td colspan="4">
          <div>作业负责人意见：{{ info.CONSTRUCTION_CONTENT }}</div>
          <div style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.fileUrl + info.CONSTRUCTION_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ info.CONSTRUCTION_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="info.LEADER_USER_ID">
        <td colspan="4">
          <div>所在单位意见：{{ info.LEADER_CONTENT }}</div>
          <div style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.fileUrl + info.LEADER_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ info.LEADER_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="info.AUDIT_USER_ID">
        <td colspan="4">
          <div>审核部门意见：{{ info.AUDIT_CONTENT }}</div>
          <div style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.fileUrl + info.AUDIT_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ info.AUDIT_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="info.APPROVE_USER_ID">
        <td colspan="4">
          <div>审批部门意见：{{ info.APPROVE_CONTENT }}</div>
          <div style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.fileUrl + info.APPROVE_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ info.APPROVE_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
    </table>
  </div>
</template>

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

export default {
  props: {
    id: {
      type: String,
      default() {
        return ''
      }
    },
    type: {
      type: String,
      default() {
        return ''
      }
    },
    gangkou: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      config: config,
      ISOTHER: false,
      info: {
        OTHER_PROTECTIVE_MEASURES: []
      },
      measuresList: []
    }
  },
  created() {
    this.getData()
  },
  methods: {
    formatDate(date, format) {
      if (date) {
        return moment(date).format(format)
      } else {
        return ''
      }
    },
    getData() {
      requestFN(
        '/map/Eight/getByIdOrder',
        {
          id: this.id,
          TYPE: this.type,
          GANGKOU: this.gangkou
        }
      ).then((data) => {
        this.info = data.pd
        this.measuresList = data.measuresList

        if (!this.info.OTHER_PROTECTIVE_MEASURES) {
          this.info.OTHER_PROTECTIVE_MEASURES = []
        } else {
          this.info.OTHER_PROTECTIVE_MEASURES = this.info.OTHER_PROTECTIVE_MEASURES.split(';_;')
        }
        this.info.OTHER_PROTECTIVE_MEASURES.some((item, index) => {
          if (this.validStr(item)) {
            this.ISOTHER = true
            return true
          }
        })
      }).catch((e) => {
      })
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
