<template>
  <layout-print-table-package :entrance="entrance">
    <table>
      <thead>
        <tr>
          <td colspan="10" style="border: none">
            <el-divider content-position="left">
              盲板抽堵安全作业票
            </el-divider>
            <div class="tr">编号:{{ data.info.CHECK_NO }}</div>
          </td>
        </tr>
      </thead>
      <tr>
        <td class="title">申请单位</td>
        <td colspan="2">{{ data.info.APPLY_DEPARTMENT_NAME }}</td>
        <td class="title">作业单位</td>
        <td colspan="2">{{ data.info.CONSTRUCTION_DEPARTMENT_NAME }}</td>
        <td class="title">作业类别</td>
        <td>
          <input
            :checked="data.info.WORK_TYPE === 1"
            type="checkbox"
            disabled
          />堵盲板
          <input
            :checked="data.info.WORK_TYPE === 2"
            type="checkbox"
            disabled
          />抽盲板
        </td>
      </tr>
      <tr>
        <td rowspan="2" class="title">设备、管道名称</td>
        <td colspan="3" class="title">管道参数</td>
        <td colspan="3" class="title">盲板参数</td>
        <td rowspan="2" class="title">实际作业开始时间</td>
      </tr>
      <tr>
        <td class="title">介质</td>
        <td class="title">温度</td>
        <td class="title">压力</td>
        <td class="title">材质</td>
        <td class="title">规格</td>
        <td class="title">编号</td>
      </tr>
      <tr v-for="(item, index) in data.boardList" :key="index">
        <td v-if="index === 0" :rowspan="data.boardList.length">
          {{ data.info.NAME }}
        </td>
        <td v-if="index === 0" :rowspan="data.boardList.length">
          {{ data.info.MEDIUM }}
        </td>
        <td v-if="index === 0" :rowspan="data.boardList.length">
          {{ data.info.TEMPERATURE }}
        </td>
        <td v-if="index === 0" :rowspan="data.boardList.length">
          {{ data.info.PRESSURE }}
        </td>
        <td>{{ item.BOARD_MATERIAL }}</td>
        <td>{{ item.BOARD_SPECIFICATION }}</td>
        <td>{{ item.BOARD_NO }}</td>
        <td v-if="index === 0" :rowspan="data.boardList.length">
          {{ data.info.BOARD_INSTALL_TIME }}
        </td>
      </tr>
      <tr>
        <td colspan="8">
          <div>盲板位置图（可另附图）及编号：</div>
          <div
            style="
              display: flex;
              justify-content: space-between;
              margin-top: 20px;
            "
          >
            <img
              v-viewer
              :src="VITE_FILE_URL + data.info.BOARD_PATH"
              alt=""
              width="100"
              height="100"
            />
            <div>
              编制人：
              <img
                v-viewer
                :src="VITE_FILE_URL + data.info.APPLY_USER_SIGNER_PATH"
                alt=""
                width="100"
                height="100"
              />
              {{ data.info.APPLY_USER_SIGNER_TIME }}
            </div>
          </div>
        </td>
      </tr>
      <tr>
        <td colspan="2" class="title">作业负责人</td>
        <td colspan="2">{{ data.info.CONSTRUCTION_USER_NAME }}</td>
        <td class="title">作业人</td>
        <td>{{ data.info.WORK_USER }}</td>
        <td class="title">监护人</td>
        <td v-if="data.info.GUARDIAN_USER_SIGNER_PATH" colspan="5">
          <div class="tr">
            <span>签字：</span>
            <img
              v-viewer
              :src="VITE_FILE_URL + data.info.GUARDIAN_USER_SIGNER_PATH"
              alt=""
              width="100"
              height="100"
            />
            <span>{{ data.info.GUARDIAN_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr>
        <td colspan="2" class="title">关联的其他特殊作业及安全作业票编号</td>
        <td colspan="6">{{ data.info.SPECIAL_WORK }}</td>
      </tr>
      <tr>
        <td colspan="2" class="title">风险辨识结果</td>
        <td colspan="6">{{ data.info.BOARD_HARM }}</td>
      </tr>
      <tr>
        <td colspan="8">
          <table>
            <tr>
              <td style="width: 80px">序号</td>
              <td>安全措施</td>
              <td style="width: 100px">是否涉及</td>
              <td style="width: 100px">确认人</td>
            </tr>
            <tr v-for="(item, index) in data.measuresList" :key="index">
              <td>{{ index + 1 }}</td>
              <td>{{ item.PROTECTIVE_MEASURES }}</td>
              <td>
                <span v-if="item.STATUS === '1'">
                  <input type="radio" checked disabled /> 涉&nbsp;&nbsp;&nbsp;及
                </span>
                <span v-if="item.STATUS === '-1'">
                  <input type="radio" checked disabled /> 不涉及
                </span>
              </td>
              <td>
                {{ item.CONFIRM_NAME }}
              </td>
            </tr>
            <tr
              v-if="
                data.info.APPLY_USER_MEASURES ||
                data.info.CONSTRUCTION_USER_MEASURES ||
                data.info.LEADER_USER_MEASURES
              "
            >
              <td>{{ data.measuresList.length + 1 }}</td>
              <td colspan="3">
                <div
                  v-if="data.info.APPLY_USER_MEASURES"
                  style="display: flex; justify-content: space-between"
                >
                  <span>其他安全措施：{{ data.info.APPLY_USER_MEASURES }}</span>
                  <span>编制人：{{ data.info.APPLY_USER_NAME }}</span>
                </div>
                <div
                  v-if="data.info.CONSTRUCTION_USER_MEASURES"
                  style="
                    display: flex;
                    justify-content: space-between;
                    margin-top: 10px;
                  "
                >
                  <span>
                    其他安全措施：{{ data.info.CONSTRUCTION_USER_MEASURES }}
                  </span>
                  <span>编制人：{{ data.info.CONSTRUCTION_USER_NAME }}</span>
                </div>
                <div
                  v-if="data.info.LEADER_USER_MEASURES"
                  style="
                    display: flex;
                    justify-content: space-between;
                    margin-top: 10px;
                  "
                >
                  <span>
                    其他安全措施：{{ data.info.LEADER_USER_MEASURES }}
                  </span>
                  <span>编制人：{{ data.info.LEADER_USER_NAME }}</span>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="title">安全交底人</td>
        <td colspan="10">
          <div v-if="data.info.CONFESS_USER_SIGNER_PATH" class="tr">
            <span>签字：</span>
            <img
              v-viewer
              :src="VITE_FILE_URL + data.info.CONFESS_USER_SIGNER_PATH"
              alt=""
              width="100"
              height="100"
            />
            <span>{{ data.info.CONFESS_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr>
        <td class="title">接受交底人</td>
        <td colspan="10">
          <div
            v-for="item in data.imgList"
            :key="item.ACCEPT_CONFESS_ID"
            class="tr"
          >
            <span>签字：</span>
            <img
              v-viewer
              :src="VITE_FILE_URL + 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="data.info.CONSTRUCTION_USER_SIGNER_PATH">
        <td colspan="8">
          <div>作业负责人意见：{{ data.info.CONSTRUCTION_CONTENT }}</div>
          <div class="tr">
            <span>签字：</span>
            <img
              v-viewer
              :src="VITE_FILE_URL + data.info.CONSTRUCTION_USER_SIGNER_PATH"
              alt=""
              width="100"
              height="100"
            />
            <span>{{ data.info.CONSTRUCTION_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="data.info.LEADER_USER_SIGNER_PATH">
        <td colspan="8">
          <div>所在单位意见：{{ data.info.LEADER_CONTENT }}</div>
          <div class="tr">
            <span>签字：</span>
            <img
              v-viewer
              :src="VITE_FILE_URL + data.info.LEADER_USER_SIGNER_PATH"
              alt=""
              width="100"
              height="100"
            />
            <span>{{ data.info.LEADER_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
      <tr v-if="data.imgList1.length > 0">
        <td colspan="10">
          <div>完工验收：{{ data.info.ACCEPT_CONTENT }}</div>
          <div
            v-for="item in data.imgList1"
            :key="item.ACCEPT_CONFESS_ID"
            class="tr"
          >
            <span>签字：</span>
            <img
              v-viewer
              :src="VITE_FILE_URL + item.ACCEPT_USER_SIGNER_PATH"
              alt=""
              width="100"
              height="100"
            />
            <span>{{ item.ACCEPT_USER_SIGNER_TIME }}</span>
          </div>
        </td>
      </tr>
    </table>
  </layout-print-table-package>
</template>

<script setup>
import LayoutPrintTablePackage from "@/components/print_table_package/index.vue";
import { reactive } from "vue";
import { useRoute } from "vue-router";
import { getBlindPlatePluggingView } from "@/request/blind_plate_plugging.js";

const VITE_FILE_URL = import.meta.env.VITE_FILE_URL;
const route = useRoute();
const { BLINDBOARD_ID, entrance } = route.query;
const data = reactive({
  info: {},
  imgList: [],
  imgList1: [],
  boardList: [],
  measuresList: [],
});
const fnGetData = async () => {
  const resData = await getBlindPlatePluggingView({ BLINDBOARD_ID });
  data.info = resData.pd;
  data.imgList = resData.imgList;
  data.imgList1 = resData.imgList1;
  data.boardList = resData.boardList;
  data.measuresList = resData.measuresList;
  data.info.APPLY_USER_MEASURES =
    data.info.OTHER_PROTECTIVE_MEASURES.split(";_;")[0];
  data.info.CONSTRUCTION_USER_MEASURES =
    data.info.OTHER_PROTECTIVE_MEASURES.split(";_;")[1];
  data.info.LEADER_USER_MEASURES =
    data.info.OTHER_PROTECTIVE_MEASURES.split(";_;")[2];
};
fnGetData();
</script>

<style scoped lang="scss"></style>
