<!-- 表格里的管理弹出框 -->
<template>
  <div>
    <MOSTY.PageTree :pageTitle="'岗位检查详情'" :isShowLeftTree="false">
      <template #serach>
        <div class="btnBox">
          <el-button type="primary" @click="handleClose">
            <el-icon>
              <Close />
            </el-icon>
            <span>关闭</span>
          </el-button>
        </div>

      </template>
      <template #table>
        <div style="height: calc(100vh - 280px);">
          <el-table :data="tableData" border stripe height="100%">
            <el-table-column property="orgname" label="所属单位" show-overflow-tooltip />
            <el-table-column property="deptname" label="所属部门" show-overflow-tooltip />
            <el-table-column property="username" label="检查人" />
            <el-table-column property="objname" label="被检查的对象" show-overflow-tooltip />
            <el-table-column property="addtime" label="检查时间" show-overflow-tooltip />
            <el-table-column property="ctype" label="类型">
              <template #default="{ row }">
                <dict-tag :options="D_TB_BMJCLX" :value="row.ctype" :tag="false" />
              </template>
            </el-table-column>

            <el-table-column label="检查类型" prop="checktype">
              <template #default="{ row }">
                <dict-tag :options="D_BZ_YHLX" :value="row.checktype" :tag="false" />
              </template>
            </el-table-column>
            <el-table-column property="dangercount" label="隐患数量" />
            <el-table-column property="finishCount" label="整改完成" />
            <el-table-column label="操作">
              <template #default="scope">
                <span class="operesee" @click="handleEdit(scope.row)"><el-icon>
                    <Compass />
                  </el-icon>隐患清单</span>

              </template>
            </el-table-column>
          </el-table>
          <div class="fenye">
            <MOSTY.Pages :pageConfiger="listQuery" @changeNo="handleCurrentChange" @changeSize="handleSizeChange">
            </MOSTY.Pages>
          </div>
        </div>
      </template>
    </MOSTY.PageTree>

    <div v-if="Showrzqd" class="dialog-box">
      <Yhlb @close="changeShow" :rowid="rowId" />
    </div>

  </div>
</template>

<script setup>
// 引入
import {
  ref,
  onMounted,
  defineProps,
  defineEmits,
  getCurrentInstance,
  watch
} from "vue";
import Yjjcrzqd from './yjjcrzqd.vue'
import * as MOSTY from "@/components/MyComponents/index";
import { getApi, deleteApi, putApi, postApi } from "@/api/tobAcco_api.js";
import Yhlb from "../../jcss/components/yhlb.vue";
const { proxy } = getCurrentInstance();
const { D_BZ_YHLX, D_TB_BMJCLX } = proxy.$dict(
  "D_BZ_YHLX",
  "D_TB_BMJCLX",
);
const Showrzqd = ref(false)
// 数据
const props = defineProps({
  qwjcxqShow: {
    type: Boolean,
    default: true
  },
  listId: {
    type: String,
    default: ""
  },
  checktype: {
    type: String,
    default: ""
  },
  userid: {
    type: String,
    default: ""
  },
  itemlist: Object

});
watch(
  () => props.itemlist,
  (val) => {
  }
)

const emits = defineEmits(["changeVi2"]);
const tableData = ref([
]);
// 分页
const listQuery = ref({
  time: props.listId,
  pageCurrent: 1,
  pageSize: 20,
  total: 0,
  checktype: props.checktype
});

const xqId = ref("");
const rowId = ref({})
onMounted(() => {
  if (props.checktype == '2') {
    listQuery.value.depid = props.userid
  } else {
    listQuery.value.userid = props.userid
  }
  getPcxData();
});
// 关闭
const handleClose = () => {
  emits("changeVi2", false);
};
// 修改子组件的值
const changeShow = (val) => {
  Showrzqd.value = val;
  getPcxData(props.listId);

};
//点击清单
function handleEdit(row) {
  Showrzqd.value = true;
  rowId.value.id = row.id
  rowId.value.objid = row.objid
}

// 获取排查项列表
const getPcxData = () => {
  listQuery.value.pageNum = listQuery.value.pageCurrent
  listQuery.value.pageSize = listQuery.value.pageSize
  getApi(listQuery.value, "/mosty-jcgl/jctj/checkDetailList").then((res) => {
    tableData.value = res.records;
    listQuery.value.total = res.total
  });
};
//页码发生变化
const handleCurrentChange = val => {
  listQuery.value.pageCurrent = val
  getPcxData()
}
//查询条数发生变化
const handleSizeChange = val => {
  listQuery.value.pageSize = val
  getPcxData()
}

</script>

<style lang="scss" scoped>
.newAdd {
  margin-top: 6px;
  position: absolute;
  right: 20px;
}


.btnBox {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
}
</style>