<template>
  <div>
    <!-- 检查标准查询 -->
    <div class='tabox'>
      <div class="headBox3">
        <el-input placeholder="请输入排查内容进行查询" v-model="pageData.listQuery.keywords" clearable
          style='width:337px;margin-left: 6px;'></el-input>
        <el-button type="primary" @click="Searchdata" class="ml6">
          <el-icon>
            <Search />
          </el-icon>
          <span>查询</span>
        </el-button>
      </div>
      <MOSTY.Table :table-columns="pageData.tableColumns" :tableData="pageData.tableData" :tableloading="tableloading"
        :tableHeight="'40vh'">
        <template #yhLv="{ row }">
          <dict-tag v-if="row.yhLv" :options="D_DBZ_YHDJ" :value="row.yhLv" :tag="false" />
          <span v-else>无</span>
        </template>
        <template #actions="{ row }">
          <span class="operesee" @click="setFn(row)">
            <el-icon>
              <Compass />
            </el-icon>
            查看
          </span>
        </template>
      </MOSTY.Table>
      <div class="fenye">
        <MOSTY.Pages :pageConfiger="pageData.pageConfiger" @changeNo="handleCurrentChange"
          @changeSize="handleSizeChange" />
      </div>
    </div>
  </div>
  <!--检查标准详情-->
  <div v-if="showdialogjzw" class="dialog-box">
    <Addjcbz :id="id" @saveSuccess="saveSuccess" :dict="{ D_DBZ_YHDJ, NYHBZ }" />
  </div>
</template>
<script setup>
import * as MOSTY from "@/components/MyComponents/index";
import { reactive, ref, onMounted, getCurrentInstance } from "vue"
import { getApi, postApi } from "@/api/tobAcco_api.js";
import Addjcbz from "@/components/dialog/Addjcbz.vue";
const { proxy } = getCurrentInstance();
const { D_DBZ_YHDJ, NYHBZ } = proxy.$dict("D_DBZ_YHDJ", 'NYHBZ');
const tableloading = ref(false);
const showdialogjzw = ref(false);
const id = ref(null)
const props = defineProps({
  obj: {
    default: () => { },
    type: Object
  },
  type: {
    default: '',
    type: String
  }
});
const pageData = reactive({
  pageConfiger: {
    pageCurrent: 1,
    pageSize: 10,
    total: 0
  },
  listQuery: {
    pageCurrent: 1,
    pageSize: 10,
    keywords: '',
    deptId: props.obj.responsibilitydeptid
  },
  tableColumns: [
    {
      title: "排查内容",
      prop: "itemName"
    },
    {
      title: "隐患等级",
      prop: "yhLv",
      slot: true
    },
    {
      title: "隐患说明",
      prop: "yhNote"
    },
    {
      title: "依据",
      prop: "checkRate"
    },
    {
      title: "操作",
      prop: "actions",
      slot: true
    }
  ],
  tableData: []
})
onMounted(() => {
  getTableData()
})

function setFn(row) {
  id.value = row.id
  showdialogjzw.value = true
}
const getTableData = () => {
  tableloading.value = true
  getApi(pageData.listQuery, '/mosty-jcgl/dynamic/checkList').then(res => {
    tableloading.value = false
    pageData.tableData = res.records
      ? res.records : [];
    pageData.pageConfiger.total = res.total
  })
}
const saveSuccess = (val) => {
  showdialogjzw.value = false
}
//查询
function Searchdata() {
  getTableData()
}
//页码发生变化
const handleCurrentChange = (val) => {
  pageData.listQuery.pageCurrent = val;
  pageData.pageConfiger.pageCurrent = val;
  getTableData()
};
//查询条数发生变化
const handleSizeChange = (val) => {
  pageData.listQuery.pageSize = val;
  pageData.pageConfiger.pageSize = val;
  getTableData()
};
</script>

<style lang="scss" scoped>
.headBox3 {
  display: flex;
  justify-content: end;
  width: 100%;
  margin-bottom: 10px;
}

.top_ul {
  display: flex;
  justify-content: start;
  flex-wrap: wrap;

  >li {
    width: 15%;
    height: 83px;
    margin: 6px 32px;
  }
}
</style>
