<template>
  <layout-card>
    <div id="printContent">
      <layout-hidden-view :hidden-id="HIDDEN_ID" :list-type="LIST_TYPE" />
    </div>
    <div class="tc mt-10">
      <el-button v-if="type === 'confirm'" type="primary" @click="fnConfirm">
        确认为重大隐患
      </el-button>
      <el-button v-else v-print="'#printContent'" type="primary">
        打印
      </el-button>
    </div>
  </layout-card>
</template>

<script setup>
import LayoutHiddenView from "@/components/hidden_view/index.vue";
import { useRoute, useRouter } from "vue-router";
import { debounce } from "throttle-debounce";
import { ElMessage } from "element-plus";
import {
  setCustomHiddenDangerConfirmMajorHazards,
  setHiddenDangerConfirmMajorHazards,
} from "@/request/hidden_danger_government.js";

const route = useRoute();
const router = useRouter();
const { HIDDEN_ID, type, LIST_TYPE } = route.query;
const fnConfirm = debounce(
  1000,
  async () => {
    LIST_TYPE === "1"
      ? await setHiddenDangerConfirmMajorHazards({
          ISCONFIRM: "1",
          HIDDEN_ID,
        })
      : await setCustomHiddenDangerConfirmMajorHazards({
          ISCONFIRM: "1",
          HIDDEN_ID,
        });
    ElMessage.success("确认成功");
    router.back();
  },
  { atBegin: true }
);
</script>

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