<template>
  <MOSTY.PageTree :pageTitle="'部门待处理隐患列表'" :isShowLeftTree="false">
    <template #serach>
      <el-divider />
      <MOSTY.Search :searchArr="searchArr" @submit="onSearch" />
    </template>
    <template #table>
      <section class="eltab7">
        <MOSTY.Table :table-columns="tableColumns" :tableData="tableData" :tableloading="tableloading" :isSelect="true"
          :isSort="true">
          <template #pitfallLevel="{ row }">
            <dict-tag :options="D_DBZ_YHDJ" :value="row.pitfallLevel" :tag="false" />
          </template>

          <template #actions="{ row }">
            <span class="operedit" v-if="row.zhflag == 'Y'" @click="handlezdfa(row)"> <el-icon>
                <EditPen />
              </el-icon> 制定方案</span>
            <!-- <span class="operedit" v-if="row.zhflag != 'Y' && row.processStatus == 'W' && row.state == '08'"
              @click="handlexg(row)"> <el-icon>
                <EditPen />
              </el-icon> 审核</span> -->
            <span class="operedit"
              v-if="row.zhflag != 'Y' && row.processStatus == 'W' && row.state != '08' && row.state != '16' && row.state != '17' && row.state != '18' && row.state != '19'"
              @click="handlecl(row)"> <el-icon>
                <EditPen />
              </el-icon> 处理</span>
            <span class="operesee" @click="handleManage(row)"
              v-if="row.zhflag != 'Y' && row.processStatus != 'W'"><el-icon>
                <Compass />
              </el-icon>查看</span>
          </template>
        </MOSTY.Table>
      </section>
      <div class="fenye">
        <MOSTY.Pages :pageConfiger="listQuery" @changeNo="handleCurrentChange" @changeSize="handleSizeChange">
        </MOSTY.Pages>
      </div>
    </template>
  </MOSTY.PageTree>
  <!-- 综合编辑配置 -->

  <div v-if="comprehensiveShow" class="dialog-box">
    <Ckyhjd @changePage="changePage" :editObj="editObj.editObj" />
    <!-- <YhInfo @close="closeEvent" /> -->
  </div>
  <div v-if="showzdfa" class="dialog-box">
    <Zdfa @changePage="closezdfa" :Rowobj="Rowobj" :type="type" />
  </div>
  <div v-if="showclzdfa" class="dialog-box">
    <Clzgfa @changePage="closeclzgfa" :Rowobj="Rowobj" :type="type" />
  </div>
</template>

<script setup>
// 引入
import * as MOSTY from "@/components/MyComponents/index";
import { reactive, onMounted, ref, getCurrentInstance } from "vue";
// import YhInfo from "./components/yhInfo.vue";
import Ckyhjd from "./components/ckyhjd.vue";
import Clzgfa from "./components/clzgfa.vue";
import Zdfa from "./components/zdfa.vue";
import { getApi, deleteApi, putApi, postApi } from "@/api/tobAcco_api.js";
import { useRouter, useRoute } from "vue-router";

const { proxy } = getCurrentInstance();
const { D_DBZ_YHDJ } = proxy.$dict("D_DBZ_YHDJ");
const router = useRouter();
const route = useRoute();

const tableloading = ref(false)
const Rowobj = ref(null)
const emits = defineEmits(["close"]);
const type = ref(null)
const editObj = reactive({
  editObj: null
})
const showzdfa = ref(false)
const showclzdfa = ref(false)
const tableData = ref([]);
const comprehensiveShow = ref(false);
const searchArr = reactive([
  {
    showType: "select",
    prop: "type",
    width: '250px',
    options: [
      {
        label: "待处理",
        value: "01"
      },
      {
        label: "全部参与",
        value: "02"
      }
    ]
  },
  {
    showType: "input",
    prop: "shorid",
    width: '250px',
    placeholder: '请输入隐患编号'
  }
])
const tableColumns = reactive([
  {
    title: "隐患编号",
    prop: "shortid",
  },
  {
    title: "发现人",
    prop: "founderName",
  },
  {
    title: "发现时间",
    prop: "founderTime",
  },
  {
    title: "隐患等级",
    prop: "pitfallLevel",
    slot: true
  },
  {
    title: "隐患描述",
    prop: "pitfallDescribe",
  },
  {
    title: "所属单位",
    prop: "becheckedOrgname",
  },
  {
    title: "所属部门",
    prop: "belongDeptname",
  },
  {
    title: "进度",
    prop: "nextstaename",
  },
  {
    title: "操作",
    prop: "actions",
    slot: true
  }
])

// 分页
const listQuery = ref({
  pageCurrent: 1,
  pageSize: 10,
  total: 0,
  shortid: "",
  type: '01'
});

//制定方案
function handlezdfa(row) {
  Rowobj.value = row;
  type.value = '01';
  showzdfa.value = true;
}
//处理
function handlecl(row) {
  Rowobj.value = row;
  type.value = '01';
  showclzdfa.value = true;
}
//查看
function handleManage(row) {
  editObj.editObj = row
  comprehensiveShow.value = true
}
function changePage(e) {
  comprehensiveShow.value = false
}
function closeclzgfa(val) {
  showclzdfa.value = false;
  Rowobj.value = null;
  getdclData();
  if (route.query.id) router.replace({ path: '/fxgk/jcss/dclyh' })//地址还原
}
// 关闭页面
const closeEvent = () => {
  comprehensiveShow.value = false;
};
const closezdfa = () => {
  showzdfa.value = false;
  Rowobj.value = null;
  getdclData();
};
onMounted(() => {
  getdclData();
  // 去审核
  if (route.query.id) goToAudit(route.query)
});

// 	待处理隐患列表
const getdclData = () => {
  postApi(listQuery.value, "/mosty-jcgl/overallCheckPitfallHz/getWPitfallPage").then(
    (res) => {
      tableData.value = res.records;
      listQuery.value.total = res.total;
    }
  );
};
// 分页
const handleSizeChange = (val) => {
  listQuery.value.pageSize = val;
  getdclData();
};
// 分页码
const handleCurrentChange = (cur) => {
  listQuery.value.pageCurrent = cur;
  getdclData();
};
// 查询
const onSearch = (obj) => {
  listQuery.value.shortid = obj.shortid
  listQuery.value.pageCurrent = 1
  getdclData();
};

const goToAudit = (query) => {
  getApi({ id: query.id }, `/mosty-jcgl/yhb/getYhInfo`).then((res) => {
    if (res) {
      Rowobj.value = res;
      Rowobj.value.isAudit = true;
      Rowobj.value.rwlx = query.rwlx;
      Rowobj.value.rwid = query.rwid;
      type.value = '01';
      showclzdfa.value = true;
    }
  });

};

</script>

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