<template>
  <div>
    <div id="printTest" class="app-container print-work">
      <el-page-header content="审批表详情" class="no-print" @back="goBack"/>
      <table class="table-ui">
        <thead>
        <tr>
          <td colspan="6" style="border: none">
            <div class="level-title mt-20">
              <h1>动土安全作业票</h1>
              <div class="level-code">编号:{{ pd.CHECK_NO }}</div>
            </div>
          </td>
        </tr>
        </thead>
        <tr>
          <td class="bbg">申请单位</td>
          <td>{{ pd.APPLY_DEPARTMENT_NAME }}</td>
          <td class="bbg" colspan="2">作业申请时间</td>
          <td colspan="2">{{ pd.CREATTIME }}</td>
        </tr>
        <tr>
          <td class="bbg">作业单位</td>
          <td>{{ pd.CONSTRUCTION_DEPARTMENT_NAME }}</td>
          <td class="bbg">作业地点</td>
          <td>{{ pd.WORK_PLACE }}</td>
          <td class="bbg">作业内容</td>
          <td>{{ pd.JOB_CONTENT }}</td>
        </tr>
        <tr>
          <td class="bbg">监护人</td>
          <td>
            <div v-if="pd.GUARDIAN_USER_SIGNER_PATH" style="text-align: right">
              <span>签字：</span>
              <img v-viewer :src="config.fileUrl + pd.GUARDIAN_USER_SIGNER_PATH" alt="" width="100" height="100">
              <span>{{ pd.GUARDIAN_USER_SIGNER_TIME }}</span>
            </div>
          </td>
          <td class="bbg" colspan="2">作业负责人</td>
          <td colspan="2">{{ pd.CONSTRUCTION_USER_NAME }}</td>
        </tr>
        <tr>
          <td class="bbg">关联的其他特殊作业及安全作业票编号</td>
          <td colspan="5">{{ pd.SPECIAL_WORK }}</td>
        </tr>
        <tr>
          <td colspan="6">
            <div>作业内容、范围、方式（包括深度、面积，并附简图）：{{ pd.WORK_CONTENT }}</div>
            <div style="display: flex;justify-content: space-between;margin-top: 20px;">
              <img v-viewer :src="config.fileUrl + pd.CONTENT_IMG_PATH" alt="" width="100" height="100">
              <div>
                编制人：
                <img v-viewer :src="config.fileUrl + pd.APPLY_USER_SIGNER_PATH" alt="" width="100" height="100">
                {{ pd.APPLY_USER_SIGNER_TIME }}
              </div>
            </div>
          </td>
        </tr>
        <tr>
          <td class="bbg">风险辨识结果</td>
          <td colspan="5">{{ pd.HAZARD_IDENTIFICATION.split(";_;")[0] }}</td>
        </tr>
        <tr>
          <td class="bbg">作业实施时间</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>是否涉及</td>
                <td>确认人</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.APPLY_USER_MEASURES || pd.CONSTRUCTION_USER_MEASURES || pd.PRODUCTION_USER_MEASURES || pd.SAFETY_USER_MEASURES || pd.LEADER_USER_MEASURES">
                <td>{{ measuresList.length + 1 }}</td>
                <td colspan="3">
                  <div v-if="pd.APPLY_USER_MEASURES" style="display: flex;justify-content: space-between;">
                    <span>其他安全措施：{{ pd.APPLY_USER_MEASURES }}</span>
                    <span>编制人：{{ pd.APPLY_USER_NAME }}</span>
                  </div>
                  <div v-if="pd.CONSTRUCTION_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                    <span>其他安全措施：{{ pd.CONSTRUCTION_USER_MEASURES }}</span>
                    <span>编制人：{{ pd.CONSTRUCTION_USER_NAME }}</span>
                  </div>
                  <div v-if="pd.PRODUCTION_USER_ID && pd.PRODUCTION_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                    <span>其他安全措施：{{ pd.PRODUCTION_USER_MEASURES }}</span>
                    <span>编制人：{{ pd.PRODUCTION_USER_NAME }}</span>
                  </div>
                  <div v-if="pd.SAFETY_USER_ID && pd.SAFETY_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                    <span>其他安全措施：{{ pd.SAFETY_USER_MEASURES }}</span>
                    <span>编制人：{{ pd.SAFETY_USER_NAME }}</span>
                  </div>
                  <div v-if="pd.LEADER_USER_ID && pd.LEADER_USER_MEASURES" style="display: flex;justify-content: space-between;margin-top: 10px;">
                    <span>其他安全措施：{{ pd.LEADER_USER_MEASURES }}</span>
                    <span>编制人：{{ pd.LEADER_USER_NAME }}</span>
                  </div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td class="bbg">安全交底人</td>
          <td colspan="10">
            <div v-if="pd.CONFESS_USER_SIGNER_PATH" style="text-align: right">
              <span>签字：</span>
              <img v-viewer :src="config.fileUrl + pd.CONFESS_USER_SIGNER_PATH" alt="" width="100" height="100">
              <span>{{ pd.CONFESS_USER_SIGNER_TIME }}</span>
            </div>
          </td>
        </tr>
        <tr>
          <td class="bbg">接受交底人</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.fileUrl + 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.CONSTRUCTION_USER_SIGNER_PATH">
          <td colspan="6">
            <div>作业负责人意见：{{ pd.CONSTRUCTION_CONTENT }}</div>
            <div style="text-align: right">
              <span>签字：</span>
              <img v-viewer :src="config.fileUrl + pd.CONSTRUCTION_USER_SIGNER_PATH" alt="" width="100" height="100">
              <span>{{ pd.CONSTRUCTION_USER_SIGNER_TIME }}</span>
            </div>
          </td>
        </tr>
        <tr v-if="pd.PRODUCTION_USER_SIGNER_PATH">
          <td colspan="6">
            <div>所在单位意见：{{ pd.PRODUCTION_CONTENT }}</div>
            <div style="text-align: right">
              <span>签字：</span>
              <img v-viewer :src="config.fileUrl + pd.PRODUCTION_USER_SIGNER_PATH" alt="" width="100" height="100">
              <span>{{ pd.PRODUCTION_USER_SIGNER_TIME }}</span>
            </div>
          </td>
        </tr>
        <tr v-if="pd.SAFETY_USER_SIGNER_PATH">
          <td colspan="6">
            <div>有关水、电、汽、工艺、设备、消防、安全等部门会签意见：{{ pd.SAFETY_CONTENT }}</div>
            <div style="text-align: right">
              <span>签字：</span>
              <img v-viewer :src="config.fileUrl + pd.SAFETY_USER_SIGNER_PATH" alt="" width="100" height="100">
              <span>{{ pd.SAFETY_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.fileUrl + pd.LEADER_USER_SIGNER_PATH" alt="" width="100" height="100">
              <span>{{ pd.LEADER_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.fileUrl + item.ACCEPT_USER_SIGNER_PATH" alt="" width="100" height="100">
              <span>{{ item.ACCEPT_USER_SIGNER_TIME }}</span>
            </div>
          </td>
        </tr>
      </table>
    </div>
    <div style="padding-top: 100px"/>
    <div class="ui-foot">
      <el-button icon="el-icon-arrow-left" @click="goBack">返 回</el-button>
    </div>
  </div>
</template>

<script>
import { requestFN } from '@/utils/request'
import dateformat from '@/utils/dateformat'
export default {
  data() {
    return {
      config: config,
      BREAKGROUND_ID: this.$parent.BREAKGROUND_ID, // 主键ID
      pd: [], // 存放字段参数
      measuresList: [],
      imgList: [],
      imgList1: [],
      otherProtectiveMeasures: [],
      hazardIdentification: []
    }
  },
  created() {
    this.getData()
  },
  methods: {
    validStr(str) {
      if (str != null && str != '' && typeof (str) != 'undefined' && str != 0) { return true }
      return false
    },
    formatTime(date, column) {
      if (date) {
        return dateformat(date, 'YYYY年MM月DD日HH时mm分')
      } else {
        return ''
      }
    },
    formatDate(date, column) {
      if (date) {
        return dateformat(date, 'YYYY-MM-DD')
      } else {
        return ''
      }
    },
    getRowKey(row) {
      return row.BREAKGROUND_ID
    },
    getData() {
      this.listLoading = true
      requestFN(
        '/gfBreakGround/goEdit',
        {
          BREAKGROUND_ID: this.BREAKGROUND_ID
        }
      ).then((data) => {
        this.listLoading = false
        this.pd = data.pd // 参数map
        this.imgList = data.imgList
        this.imgList1 = data.imgList
        this.measuresList = data.measuresList // 参数map
        this.pd.APPLY_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[0]
        this.pd.CONSTRUCTION_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[1]
        this.pd.PRODUCTION_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[2]
        this.pd.SAFETY_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[3]
        this.pd.LEADER_USER_MEASURES = this.pd.OTHER_PROTECTIVE_MEASURES.split(';_;')[4]
      }).catch((e) => {
        this.listLoading = false
      })
    },
    goBack() {
      this.$parent.activeName = 'Breakground'
    }

  }
}
</script>

<style lang="sass" scoped>
.print-approval-p10
  padding: 20px 0
  span
    vertical-align: middle
.bbg
  width: 270px
.print-approval-img
  width: 200px
  height: 97px
  display: inline-block
  img
    width: 100%
    height: 100%
.level-code
  margin-left: auto
</style>
