|
@@ -42,7 +42,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import { onMounted, reactive, ref, watch } from 'vue';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
-import { deptList, patrolNum } from '@/api/inspectionWork/inspector';
|
|
|
+import { inspectorDivision, patrolNum } from '@/api/inspectionWork/inspector';
|
|
|
|
|
|
const router = useRouter();
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
@@ -75,7 +75,7 @@ const data = reactive({
|
|
|
});
|
|
|
|
|
|
const { queryParams, form } = toRefs(data);
|
|
|
-
|
|
|
+data.queryParams.area_code = '';
|
|
|
const formatStatus = (status) => {
|
|
|
return Number(status) === 1 ? '已完成' : '未完成';
|
|
|
};
|
|
@@ -86,15 +86,26 @@ const filterNode = (value: string, data: any) => {
|
|
|
};
|
|
|
|
|
|
const getTreeSelect = async () => {
|
|
|
- const res = await deptList();
|
|
|
- deptOptions.value = res.data; // 直接赋值给 deptOptions
|
|
|
- queryParams.value.area_code = res.data.code;
|
|
|
+ const res = await inspectorDivision();
|
|
|
+ if (res.code === 200) {
|
|
|
+ deptOptions.value = res.data; // 将部门树数据赋值给deptOptions
|
|
|
+ } else {
|
|
|
+ console.error(res.msg);
|
|
|
+ }
|
|
|
loading.value = false; // 加载完成后关闭加载提示
|
|
|
};
|
|
|
|
|
|
const fetchUserData = async () => {
|
|
|
loading.value = true; // 开始加载
|
|
|
- return patrolNum(props.eventId, queryParams.value)
|
|
|
+
|
|
|
+ // 构造请求参数
|
|
|
+ const params = {
|
|
|
+ ...queryParams.value,
|
|
|
+ // 只在area_code有值时添加到请求参数中
|
|
|
+ ...(queryParams.value.area_code ? { area_code: queryParams.value.area_code } : {})
|
|
|
+ };
|
|
|
+
|
|
|
+ return patrolNum(props.eventId, params)
|
|
|
.then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
tableData.value = res.data; // 确保tableData是一个数组
|
|
@@ -116,6 +127,7 @@ watch(queryParams, () => {
|
|
|
|
|
|
const handleNodeClick = (data: any) => {
|
|
|
queryParams.value.deptId = data.id;
|
|
|
+ queryParams.value.area_code = data.code; // 设置area_code为点击节点的code值
|
|
|
fetchUserData();
|
|
|
};
|
|
|
|