<template>
  <layout-card>
    <div id="printContent">
      <layout-hidden-view :hidden-id="HIDDEN_ID" />
    </div>
    <div class="tc mt-10">
      <el-button type="primary" @click="fnConfirm" v-if="type === 'confirm'">
        确认为重大隐患
      </el-button>
      <el-button type="primary" v-print="'#printContent'" v-else>
        打印
      </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 { setHiddenDangerConfirmMajorHazards } from "@/request/hidden_danger_government.js";

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

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