<template>
  <layout-card>
    <div id="printContainer">
      <el-divider content-position="left">清单信息</el-divider>
      <el-descriptions :column="2" border>
        <el-descriptions-item label="清单名称">
          {{ info.NAME }}
        </el-descriptions-item>
        <el-descriptions-item label="排查清单类型">
          {{ info.SCREENTYPENAME }}
        </el-descriptions-item>
        <el-descriptions-item
          :label="info.BAO_BAO_TYPE !== '1' ? '所属部门' : '包保责任人部门'"
        >
          {{ info.DEPARTMENT_NAME }}
        </el-descriptions-item>
        <el-descriptions-item
          :label="info.BAO_BAO_TYPE !== '1' ? '所属岗位' : '包保责任人岗位'"
        >
          {{ info.POST_NAME }}
        </el-descriptions-item>
        <el-descriptions-item label="排查周期">
          {{ info.PERIODNAME }}
        </el-descriptions-item>
        <el-descriptions-item label="清单类型">
          {{ info.TYPENAME }}
        </el-descriptions-item>
        <el-descriptions-item
          label="排查日期"
          :span="2"
          v-if="info.TYPE === 'listType0006'"
        >
          {{ info.START_DATE }} - {{ info.END_DATE }}
        </el-descriptions-item>
        <template v-if="info.BAO_BAO_TYPE === '1'">
          <el-descriptions-item label="是否包保责任人任务">
            是
          </el-descriptions-item>
          <el-descriptions-item label="包保责任人">
            {{ info.USER_NAME }}
          </el-descriptions-item>
        </template>
      </el-descriptions>
      <el-divider content-position="left">检查内容</el-divider>
      <div class="print_no_use">
        <layout-table :data="list" :show-pagination="false">
          <el-table-column type="index" label="序号" width="55" />
          <el-table-column label="排查类型" prop="RISKUNITNAME" />
          <el-table-column label="排查项目" prop="PARTSNAME" />
          <el-table-column
            label="风险管控措施(排查标准)"
            prop="CHECK_CONTENT"
          />
          <el-table-column label="失职部门/人员">
            <template #default="{ row }">
              {{ row.DEPARTMENT_NAME }}/{{ row.USERNAME }}
            </template>
          </el-table-column>
          <el-table-column label="风险失控表现" />
          <el-table-column label="备注" />
        </layout-table>
      </div>
      <table class="print_use">
        <thead>
          <tr>
            <th width="55">序号</th>
            <th width="85">排查类型</th>
            <th width="85">排查项目</th>
            <th>风险管控措施(排查标准)</th>
            <th width="120">失职部门/人员</th>
            <th width="115">风险失控表现</th>
            <th width="55">备注</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item, index) in list" :key="index">
            <td>{{ index + 1 }}</td>
            <td>{{ item.RISKUNITNAME }}</td>
            <td>{{ item.PARTSNAME }}</td>
            <td>{{ item.CHECK_CONTENT }}</td>
            <td>{{ item.DEPARTMENT_NAME }}/{{ item.USERNAME }}</td>
            <td />
            <td />
          </tr>
        </tbody>
      </table>
    </div>
    <div class="tc mt-10">
      <el-button v-print="'#printContainer'" type="primary">打 印</el-button>
    </div>
    <div v-html="PRINT_STYLE" />
  </layout-card>
</template>

<script setup>
import { getInventoryManagementView } from "@/request/hazard_investigation.js";
import { useRoute } from "vue-router";
import { ref } from "vue";
import { PRINT_STYLE } from "@/assets/js/constant.js";
import useListData from "@/assets/js/useListData.js";

const route = useRoute();
const { LISTMANAGER_ID } = route.query;
const info = ref({});
const { list } = useListData(getInventoryManagementView, {
  otherParams: {
    LISTMANAGER_ID,
  },
  usePagination: false,
  callbackFn: (list, responseData) => {
    info.value = responseData.pd;
  },
});
</script>

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