<template>
  <div class="app-container print-work">
    <div class="level-title">
      <h1>吊装安全作业证</h1>
      <div class="level-btns">编号:{{ pd.CHECK_NO }}</div>
    </div>
    <table class="table-ui">

      <tr>
        <td class="bbg-transparent">作业申请单位</td>
        <td>{{ pd.APPLY_DEPARTMENT_NAME }}</td>
        <td class="bbg-transparent">作业单位</td>
        <td>{{ pd.LEADER_DEPARTMENT_NAME }}</td>
        <td class="bbg-transparent">作业申请时间</td>
        <td>{{ pd.CREATTIME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">吊装地点</td>
        <td>{{ pd.WORK_PLACE }}</td>
        <td class="bbg-transparent">吊具名称</td>
        <td>{{ pd.TOOL_NAME }}</td>
        <td class="bbg-transparent">吊物内容</td>
        <td>{{ pd.WORK_CONTENT }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">吊装作业人</td>
        <td>{{ pd.WORK_USER }}</td>
        <td class="bbg-transparent">司索人</td>
        <td>{{ pd.SISUO_USER }}</td>
        <td class="bbg-transparent">监护人</td>
        <td>
          <div v-if="pd.GUARDIAN_USER_SIGNER_PATH" style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.cfdfileUrl + pd.GUARDIAN_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ pd.GUARDIAN_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">指挥人员</td>
        <td>{{ pd.PROJECT_MANAGER }}</td>
        <td class="bbg-transparent" colspan="2">吊物质量（t）及作业级别</td>
        <td colspan="2">
          <span>{{ pd.PART_WEIGHT }}t</span>
          <span style="margin-left: 20px;">
            {{ pd.WORK_LEVEL == '1' ? '一级作业级别' : '' }}
            {{ pd.WORK_LEVEL == '2' ? '二级作业级别' : '' }}
            {{ pd.WORK_LEVEL == '3' ? '三级作业级别' : '' }}
          </span>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">风险辨识结果</td>
        <td colspan="5">{{ pd.HAZARD_IDENTIFICATION }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">作业实施时间</td>
        <td colspan="5">{{ pd.WORK_START_DATE }}至{{ pd.WORK_END_DATE }}止</td>
      </tr>
      <tr>
        <td colspan="6">
          <table class="table-ui">
            <tr>
              <td>序号</td>
              <td>安全措施</td>
              <td style="width: 80px; text-align: center">是否涉及</td>
              <td style="width: 60px">确认人</td>
            </tr>
            <tr v-for="(item,index) in measuresList" :key="index">
              <td>{{ index + 1 }}</td>
              <td>{{ item.PROTECTIVE_MEASURES }}

              </td>
              <td>
                <span v-if="item.STATUS=='1'"><input type="radio" disabled checked>涉&nbsp;&nbsp;&nbsp;及</span>
                <span v-if="item.STATUS=='-1'"><input type="radio" disabled checked>不涉及</span>
              </td>
              <td>
                {{ item.CONFIRM_NAME }}
              </td>
            </tr>
            <tr v-if="pd.LEADER_USER_MEASURES || pd.CONFIRM_USER_MEASURES || pd.AUDIT_USER_MEASURES || pd.APPROVE_USER_MEASURES">
              <td>{{ measuresList.length + 1 }}</td>
              <td colspan="3">
                <div v-if="pd.LEADER_USER_MEASURES" style="display: flex;justify-content: space-between;">
                  <span>其他安全措施：{{ pd.LEADER_USER_MEASURES }}</span>
                  <span>编制人：{{ pd.LEADER_USER_NAME }}</span>
                </div>
                <div v-if="pd.CONSTRUCTION_USER_ID && pd.CONFIRM_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                  <span>其他安全措施：{{ pd.CONFIRM_USER_MEASURES }}</span>
                  <span>编制人：{{ pd.CONSTRUCTION_USER_NAME }}</span>
                </div>
                <div v-if="pd.AUDIT_USER_ID && pd.AUDIT_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                  <span>其他安全措施：{{ pd.AUDIT_USER_MEASURES }}</span>
                  <span>编制人：{{ pd.AUDIT_USER_NAME }}</span>
                </div>
                <div v-if="pd.APPROVE_USER_ID && pd.APPROVE_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                  <span>其他安全措施：{{ pd.APPROVE_USER_MEASURES }}</span>
                  <span>编制人：{{ pd.APPROVE_USER_NAME }}</span>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">安全交底人</td>
        <td colspan="10">
          <div v-if="pd.CONFESS_USER_SIGNER_PATH" style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.cfdfileUrl + pd.CONFESS_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ pd.CONFESS_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr>
        <td class="bbg-transparent">接受交底人</td>
        <td colspan="10">
          <div v-for="item in imgList" :key="item.ACCEPT_CONFESS_ID" style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.cfdfileUrl + item.ACCEPT_CONFESS_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ item.ACCEPT_CONFESS_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="pd.LEADER_USER_SIGNER_PATH">
        <td colspan="6">
          <div>作业指挥意见：{{ pd.LEADER_CONTENT }}</div>
          <div style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.cfdfileUrl + pd.LEADER_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ pd.LEADER_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="pd.CONSTRUCTION_USER_SIGNER_PATH">
        <td colspan="6">
          <div>所在单位意见：{{ pd.CONSTRUCTION_CONTENT }}</div>
          <div style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.cfdfileUrl + pd.CONSTRUCTION_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ pd.CONSTRUCTION_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="pd.AUDIT_USER_SIGNER_PATH">
        <td colspan="6">
          <div>审核部门意见：{{ pd.AUDIT_CONTENT }}</div>
          <div style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.cfdfileUrl + pd.AUDIT_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ pd.AUDIT_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="pd.APPROVE_USER_SIGNER_PATH">
        <td colspan="6">
          <div>审批部门意见：{{ pd.APPROVE_CONTENT }}</div>
          <div style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.cfdfileUrl + pd.APPROVE_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ pd.APPROVE_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="imgList1.length>0">
        <td colspan="10">
          <div>完工验收：{{ pd.ACCEPT_CONTENT }}</div>
          <div v-for="item in imgList1" :key="item.ACCEPT_CONFESS_ID" style="text-align: right">
            <span>签字：</span>
            <img v-viewer :src="config.cfdfileUrl + item.ACCEPT_USER_SIGNER_PATH" alt="" width="100" height="100">
            <span>{{ item.ACCEPT_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
    </table>

  </div>
</template>

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

export default {
  props: {
    id: {
      type: String,
      default() {
        return ''
      }
    },
    type: {
      type: String,
      default() {
        return ''
      }
    }
  },
  data() {
    return {
      config: config,
      info: {
        CRANE_DRIVER_NAME: [],
        CRANE_DRIVER_NUMBER: []
      },
      measuresList: [],
      oldSupplementaryMeasures: [],
      pd: {}
    }
  },
  created() {
    this.getData()
  },
  methods: {
    formatDate(date, format) {
      if (date) {
        return moment(date).format(format)
      } else {
        return ''
      }
    },
    getData() {
      this.listLoading = true
      requestFN(
        '/map/Eight/getByIdCfdD',
        {
          id: this.id,
          TYPE: this.type,
          HOISTING_ID: this.id
        }
      ).then((data) => {
        this.listLoading = false
        this.pd = data.pd // 参数map
        this.imgList = data.imgList
        this.imgList1 = data.imgList1
        this.measuresList = data.measuresList // 参数map
        this.pd.LEADER_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[0]
        this.pd.CONFIRM_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[1]
        this.pd.AUDIT_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[2]
        this.pd.APPROVE_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[3]
      }).catch((e) => {
        this.listLoading = false
      })
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
