From f6c198c774f1278f97f2d6b01fcf8fca6bfaf815 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 15 四月 2026 11:16:08 +0800
Subject: [PATCH] 新疆马铃薯 1.环境检测数据展示修改
---
src/views/equipmentManagement/inspectionManagement/index.vue | 551 +++++++++++++++++++++++++++---------------------------
1 files changed, 279 insertions(+), 272 deletions(-)
diff --git a/src/views/equipmentManagement/inspectionManagement/index.vue b/src/views/equipmentManagement/inspectionManagement/index.vue
index 245f3d2..86e9289 100644
--- a/src/views/equipmentManagement/inspectionManagement/index.vue
+++ b/src/views/equipmentManagement/inspectionManagement/index.vue
@@ -1,354 +1,361 @@
<template>
- <div class="app-container">
- <el-form :inline="true" :model="queryParams" class="search-form">
- <el-form-item label="宸℃浠诲姟鍚嶇О">
- <el-input
- v-model="queryParams.taskName"
- placeholder="璇疯緭鍏ュ贰妫�浠诲姟鍚嶇О"
- clearable
- :style="{ width: '100%' }"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="handleQuery">鏌ヨ</el-button>
- <el-button @click="resetQuery">閲嶇疆</el-button>
- </el-form-item>
- </el-form>
- <el-card>
- <div style="display: flex;flex-direction: row;justify-content: space-between;margin-bottom: 10px;">
- <el-radio-group v-model="activeRadio" @change="radioChange">
- <el-radio-button v-for="tab in radios"
- :key="tab.name"
- :label="tab.label"
- :value="tab.name"/>
- </el-radio-group>
- <!-- 鎿嶄綔鎸夐挳鍖� -->
- <el-space v-if="activeRadio !== 'task'">
- <el-button type="primary" :icon="Plus" @click="handleAdd(undefined)">鏂板缓</el-button>
- <el-button type="danger" :icon="Delete" @click="handleDelete">鍒犻櫎</el-button>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- </el-space>
- <el-space v-else>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- </el-space>
- </div>
- <div>
- <div>
- <PIMTable :table-loading="tableLoading"
- :table-data="tableData"
- :column="tableColumns"
- @selection-change="handleSelectionChange"
- :is-selection="true"
- :border="true"
- :table-style="{ width: '100%', height: 'calc(100vh - 23em)' }"
- :page="{
+ <div class="app-container">
+ <el-form :inline="true" :model="queryParams" class="search-form">
+ <el-form-item label="宸℃浠诲姟鍚嶇О">
+ <el-input
+ v-model="queryParams.taskName"
+ placeholder="璇疯緭鍏ュ贰妫�浠诲姟鍚嶇О"
+ clearable
+ style="width: 200px"
+ />
+ </el-form-item>
+ <el-form-item label="鎵�灞炲尯鍩�">
+ <el-tree-select
+ v-model="queryParams.areaId"
+ :data="areaOptions"
+ :props="areaTreeProps"
+ node-key="id"
+ value-key="id"
+ check-strictly
+ clearable
+ filterable
+ placeholder="璇烽�夋嫨鎵�灞炲尯鍩�"
+ style="width: 220px"
+ />
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" @click="handleQuery">鏌ヨ</el-button>
+ <el-button @click="resetQuery">閲嶇疆</el-button>
+ </el-form-item>
+ </el-form>
+ <el-card>
+ <div class="toolbar">
+ <el-radio-group v-model="activeRadio" @change="radioChange">
+ <el-radio-button
+ v-for="tab in radios"
+ :key="tab.name"
+ :label="tab.label"
+ :value="tab.name"
+ />
+ </el-radio-group>
+ <el-space v-if="activeRadio !== 'task'">
+ <el-button type="primary" :icon="Plus" @click="handleAdd(undefined)">鏂板缓</el-button>
+ <el-button type="danger" :icon="Delete" @click="handleDelete">鍒犻櫎</el-button>
+ <el-button @click="handleOut">瀵煎嚭</el-button>
+ </el-space>
+ <el-space v-else>
+ <el-button @click="handleOut">瀵煎嚭</el-button>
+ </el-space>
+ </div>
+ <PIMTable
+ :table-loading="tableLoading"
+ :table-data="tableData"
+ :column="tableColumns"
+ :is-selection="true"
+ :border="true"
+ :page="{
current: pageNum,
size: pageSize,
- total: total,
+ total,
+ layout: 'total, sizes, prev, pager, next, jumper',
}"
- @pagination="pagination"
- >
- <template #inspector="{ row }">
- <div class="person-tags">
- <!-- 璋冭瘯淇℃伅锛屼笂绾挎椂鍒犻櫎 -->
- <!-- {{ console.log('inspector data:', row.inspector) }} -->
- <template v-if="row.inspector && row.inspector.length > 0">
- <el-tag
- v-for="(person, index) in row.inspector"
- :key="index"
- size="small"
- type="primary"
- class="person-tag"
- >
- {{ person }}
- </el-tag>
- </template>
- <span v-else class="no-data">--</span>
- </div>
- </template>
- </PIMTable>
- </div>
- </div>
- </el-card>
- <form-dia ref="formDia" @closeDia="handleQuery"></form-dia>
- <view-files ref="viewFiles"></view-files>
- </div>
+ :table-style="{ width: '100%', height: 'calc(100vh - 23em)' }"
+ @selection-change="handleSelectionChange"
+ @pagination="handlePagination"
+ >
+ <template #inspector="{ row }">
+ <div class="person-tags">
+ <template v-if="row.inspector && row.inspector.length > 0">
+ <el-tag
+ v-for="(person, index) in row.inspector"
+ :key="index"
+ size="small"
+ type="primary"
+ class="person-tag"
+ >
+ {{ person }}
+ </el-tag>
+ </template>
+ <span v-else class="no-data">--</span>
+ </div>
+ </template>
+ </PIMTable>
+ </el-card>
+ <form-dia ref="formDia" @closeDia="handleQuery" />
+ <view-files ref="viewFiles" />
+ </div>
</template>
<script setup>
import { Delete, Plus } from "@element-plus/icons-vue";
-import { onMounted, ref, reactive, getCurrentInstance, nextTick } from "vue";
import { ElMessageBox } from "element-plus";
-
-// 缁勪欢寮曞叆
-import Pagination from "@/components/Pagination/index.vue";
+import { getCurrentInstance, nextTick, onMounted, reactive, ref } from "vue";
import PIMTable from "@/components/PIMTable/PIMTable.vue";
import FormDia from "@/views/equipmentManagement/inspectionManagement/components/formDia.vue";
import ViewFiles from "@/views/equipmentManagement/inspectionManagement/components/viewFiles.vue";
-
-// 鎺ュ彛寮曞叆
import {
- delTimingTask,
- inspectionTaskList,
- timingTaskList
+ delTimingTask,
+ inspectionTaskList,
+ timingTaskList,
} from "@/api/inspectionManagement/index.js";
+import { getDeviceAreaTree } from "@/api/equipmentManagement/deviceArea";
-// 鍏ㄥ眬鍙橀噺
const { proxy } = getCurrentInstance();
const formDia = ref();
const viewFiles = ref();
-// 鏌ヨ鍙傛暟
const queryParams = reactive({
- taskName: "",
+ taskName: "",
+ areaId: undefined,
});
-// 鍗曢�夋閰嶇疆
+const areaOptions = ref([]);
+const areaTreeProps = {
+ label: "areaName",
+ children: "children",
+};
+
const activeRadio = ref("taskManage");
const radios = reactive([
- { name: "taskManage", label: "瀹氭椂浠诲姟绠$悊" },
- { name: "task", label: "瀹氭椂浠诲姟璁板綍" },
+ { name: "taskManage", label: "瀹氭椂浠诲姟绠$悊" },
+ { name: "task", label: "瀹氭椂浠诲姟璁板綍" },
]);
-// 琛ㄦ牸鏁版嵁
const selectedRows = ref([]);
const tableData = ref([]);
-const operationsArr = ref([]);
const tableColumns = ref([]);
const tableLoading = ref(false);
const total = ref(0);
const pageNum = ref(1);
const pageSize = ref(10);
-// 鍒楅厤缃�
const columns = ref([
- { prop: "taskName", label: "宸℃浠诲姟鍚嶇О", minWidth: 160 },
- { prop: "remarks", label: "澶囨敞", minWidth: 150 },
- { prop: "inspector", label: "鎵ц宸℃浜�", minWidth: 150, slot: "inspector" },
{
- prop: "frequencyType",
- label: "棰戞",
- minWidth: 150,
- formatData: (cell) => ({
- DAILY: "姣忔棩",
- WEEKLY: "姣忓懆",
- MONTHLY: "姣忔湀",
- QUARTERLY: "瀛e害"
- }[cell] || "")
+ label: "鎵�鍦ㄥ尯鍩�",
+ prop: "areaName",
},
- {
- prop: "frequencyDetail",
- label: "寮�濮嬫棩鏈熶笌鏃堕棿",
- minWidth: 150,
- formatter: (row, column, cellValue) => {
- // 鍏堝垽鏂槸鍚︽槸瀛楃涓�
- if (typeof cellValue !== 'string') return '';
- let val = cellValue;
- const replacements = {
- MON: '鍛ㄤ竴',
- TUE: '鍛ㄤ簩',
- WED: '鍛ㄤ笁',
- THU: '鍛ㄥ洓',
- FRI: '鍛ㄤ簲',
- SAT: '鍛ㄥ叚',
- SUN: '鍛ㄦ棩'
- };
- // 浣跨敤姝e垯涓�娆℃�ф浛鎹㈡墍鏈夊尮閰嶉」
- return val.replace(/MON|TUE|WED|THU|FRI|SAT|SUN/g, match => replacements[match]);
- }
- },
- { prop: "registrant", label: "鐧昏浜�", minWidth: 100 },
- { prop: "dateStr", label: "鐧昏鏃ユ湡", minWidth: 100 },
+ { prop: "taskName", label: "宸℃浠诲姟鍚嶇О", minWidth: 160 },
+ { prop: "remarks", label: "澶囨敞", minWidth: 150 },
+ { prop: "inspector", label: "鎵ц宸℃浜�", minWidth: 150, slot: "inspector" },
+ {
+ prop: "frequencyType",
+ label: "棰戞",
+ minWidth: 150,
+ formatData: (value) =>
+ ({
+ DAILY: "姣忔棩",
+ WEEKLY: "姣忓懆",
+ MONTHLY: "姣忔湀",
+ QUARTERLY: "瀛e害",
+ YEARLY: "姣忓勾",
+ }[value] || ""),
+ },
+ {
+ prop: "frequencyDetail",
+ label: "寮�濮嬫棩鏈熶笌鏃堕棿",
+ minWidth: 150,
+ formatter: (row, column, cellValue) => {
+ if (typeof cellValue !== "string") {
+ return "";
+ }
+ const replacements = {
+ MON: "鍛ㄤ竴",
+ TUE: "鍛ㄤ簩",
+ WED: "鍛ㄤ笁",
+ THU: "鍛ㄥ洓",
+ FRI: "鍛ㄤ簲",
+ SAT: "鍛ㄥ叚",
+ SUN: "鍛ㄦ棩",
+ };
+ return cellValue.replace(/MON|TUE|WED|THU|FRI|SAT|SUN/g, (match) => replacements[match]);
+ },
+ },
+ { prop: "registrant", label: "鐧昏浜�", minWidth: 100 },
+ { prop: "createTime", label: "鐧昏鏃ユ湡", minWidth: 100 },
]);
-// 鎿嶄綔鍒楅厤缃�
const getOperationColumn = (operations) => {
- if (!operations || operations.length === 0) return null;
-
- const operationConfig = {
- label: "鎿嶄綔",
- width: 130,
- fixed: "right",
- dataType: "action",
- operation: operations.map(op => {
- switch (op) {
- case 'edit':
- return {
- name: "缂栬緫",
- clickFun: handleAdd,
- color: "#409EFF"
- };
- case 'viewFile':
- return {
- name: "鏌ョ湅闄勪欢",
- clickFun: viewFile,
- color: "#67C23A"
- };
- default:
- return null;
- }
- }).filter(Boolean)
- };
-
- return operationConfig;
+ if (!operations || operations.length === 0) {
+ return null;
+ }
+ return {
+ label: "鎿嶄綔",
+ width: 130,
+ fixed: "right",
+ dataType: "action",
+ operation: operations
+ .map((op) => {
+ switch (op) {
+ case "edit":
+ return {
+ name: "缂栬緫",
+ clickFun: handleAdd,
+ color: "#409EFF",
+ };
+ case "viewFile":
+ return {
+ name: "鏌ョ湅闄勪欢",
+ clickFun: viewFile,
+ color: "#67C23A",
+ };
+ default:
+ return null;
+ }
+ })
+ .filter(Boolean),
+ };
+};
+
+const loadAreaTree = async () => {
+ const { data } = await getDeviceAreaTree();
+ areaOptions.value = Array.isArray(data) ? data : [];
};
onMounted(() => {
- radioChange('taskManage');
+ loadAreaTree();
+ radioChange("taskManage");
});
-// 鍗曢�夊彉鍖�
const radioChange = (value) => {
- if (value === "taskManage") {
- const operationColumn = getOperationColumn(['edit']);
- tableColumns.value = [...columns.value, ...(operationColumn ? [operationColumn] : [])];
- operationsArr.value = ['edit'];
- } else if (value === "task") {
- const operationColumn = getOperationColumn(['viewFile']);
- tableColumns.value = [...columns.value, ...(operationColumn ? [operationColumn] : [])];
- operationsArr.value = ['viewFile'];
- }
- pageNum.value = 1;
- pageSize.value = 10;
- getList();
+ if (value === "taskManage") {
+ const operationColumn = getOperationColumn(["edit"]);
+ tableColumns.value = [...columns.value, ...(operationColumn ? [operationColumn] : [])];
+ } else {
+ const operationColumn = getOperationColumn(["viewFile"]);
+ tableColumns.value = [...columns.value, ...(operationColumn ? [operationColumn] : [])];
+ }
+ pageNum.value = 1;
+ pageSize.value = 10;
+ getList();
};
-// 鏌ヨ鎿嶄綔
const handleQuery = () => {
- pageNum.value = 1;
- pageSize.value = 10;
- getList();
+ pageNum.value = 1;
+ pageSize.value = 10;
+ getList();
};
-const pagination = (obj) => {
- pageNum.value = obj.page;
- pageSize.value = obj.limit;
- getList();
+
+const handlePagination = (val) => {
+ pageNum.value = val.page;
+ pageSize.value = val.limit;
+ getList();
};
-// 鑾峰彇鍒楄〃鏁版嵁
+
const getList = () => {
- tableLoading.value = true;
-
- const params = { ...queryParams, size: pageSize.value, current: pageNum.value };
-
- let apiCall;
- if (activeRadio.value === "task") {
- apiCall = inspectionTaskList(params);
- } else {
- apiCall = timingTaskList(params);
- }
-
- apiCall.then(res => {
- const rawData = res.data.records || [];
- // 澶勭悊 inspector 瀛楁锛屽皢瀛楃涓茶浆鎹负鏁扮粍锛堥�傜敤浜庢墍鏈夋儏鍐碉級
- tableData.value = rawData.map(item => {
- const processedItem = { ...item };
-
- // 澶勭悊 inspector 瀛楁
- if (processedItem.inspector) {
- if (typeof processedItem.inspector === 'string') {
- // 瀛楃涓叉寜閫楀彿鍒嗗壊
- processedItem.inspector = processedItem.inspector.split(',').map(s => s.trim()).filter(s => s);
- } else if (!Array.isArray(processedItem.inspector)) {
- // 闈炴暟缁勮浆涓烘暟缁�
- processedItem.inspector = [processedItem.inspector];
- }
- } else {
- // 绌哄�艰涓虹┖鏁扮粍
- processedItem.inspector = [];
- }
-
- return processedItem;
- });
- total.value = res.data.total || 0;
- }).finally(() => {
- tableLoading.value = false;
- });
+ tableLoading.value = true;
+ const params = {
+ ...queryParams,
+ size: pageSize.value,
+ current: pageNum.value,
+ };
+ const apiCall =
+ activeRadio.value === "task" ? inspectionTaskList(params) : timingTaskList(params);
+
+ apiCall
+ .then((res) => {
+ const rawData = res?.data?.records || [];
+ tableData.value = rawData.map((item) => {
+ const processedItem = { ...item };
+ if (processedItem.inspector) {
+ if (typeof processedItem.inspector === "string") {
+ processedItem.inspector = processedItem.inspector
+ .split(",")
+ .map((text) => text.trim())
+ .filter(Boolean);
+ } else if (!Array.isArray(processedItem.inspector)) {
+ processedItem.inspector = [processedItem.inspector];
+ }
+ } else {
+ processedItem.inspector = [];
+ }
+ return processedItem;
+ });
+ total.value = res?.data?.total || 0;
+ })
+ .finally(() => {
+ tableLoading.value = false;
+ });
};
-// 閲嶇疆鏌ヨ
const resetQuery = () => {
- for (const key in queryParams) {
- if (!["pageNum", "pageSize"].includes(key)) {
- queryParams[key] = "";
- }
- }
- handleQuery();
+ queryParams.taskName = "";
+ queryParams.areaId = undefined;
+ handleQuery();
};
-// 鏂板 / 缂栬緫
const handleAdd = (row) => {
- const type = row ? 'edit' : 'add';
- nextTick(() => {
- formDia.value?.openDialog(type, row);
- });
+ const type = row ? "edit" : "add";
+ nextTick(() => {
+ formDia.value?.openDialog(type, row);
+ });
};
-// 鏌ョ湅闄勪欢
const viewFile = (row) => {
- nextTick(() => {
- viewFiles.value?.openDialog(row);
- });
+ nextTick(() => {
+ viewFiles.value?.openDialog(row);
+ });
};
-// 鍒犻櫎鎿嶄綔
const handleDelete = () => {
- if (!selectedRows.value.length) {
- proxy.$modal.msgWarning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
- return;
- }
-
- const deleteIds = selectedRows.value.map(item => item.id);
-
- proxy.$modal.confirm('鏄惁纭鍒犻櫎鎵�閫夋暟鎹」锛�').then(() => {
- return delTimingTask(deleteIds);
- }).then(() => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- handleQuery();
- }).catch(() => {});
+ if (!selectedRows.value.length) {
+ proxy.$modal.msgWarning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
+ return;
+ }
+ const deleteIds = selectedRows.value.map((item) => item.id);
+ proxy.$modal
+ .confirm("鏄惁纭鍒犻櫎鎵�閫夋暟鎹」锛�")
+ .then(() => delTimingTask(deleteIds))
+ .then(() => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ handleQuery();
+ })
+ .catch(() => {});
};
-// 澶氶�夊彉鏇�
const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
+ selectedRows.value = selection;
};
-// 瀵煎嚭
const handleOut = () => {
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- // 鏍规嵁褰撳墠閫変腑鐨勬爣绛鹃〉璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
- if (activeRadio.value === "taskManage") {
- // 瀹氭椂浠诲姟绠$悊
- proxy.download("/timingTask/export", {}, "瀹氭椂浠诲姟绠$悊.xlsx");
- } else if (activeRadio.value === "task") {
- // 瀹氭椂浠诲姟璁板綍
- proxy.download("/inspectionTask/export", {}, "瀹氭椂浠诲姟璁板綍.xlsx");
- }
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ if (activeRadio.value === "taskManage") {
+ proxy.download("/timingTask/export", {}, "瀹氭椂浠诲姟绠$悊.xlsx");
+ } else {
+ proxy.download("/inspectionTask/export", {}, "瀹氭椂浠诲姟璁板綍.xlsx");
+ }
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
};
</script>
<style scoped>
+.toolbar {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ margin-bottom: 10px;
+}
+
.person-tags {
- display: flex;
- flex-wrap: wrap;
- gap: 4px;
+ display: flex;
+ flex-wrap: wrap;
+ gap: 4px;
}
.person-tag {
- margin-right: 4px;
- margin-bottom: 2px;
+ margin-right: 4px;
+ margin-bottom: 2px;
}
.no-data {
- color: #909399;
- font-size: 14px;
+ color: #909399;
+ font-size: 14px;
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3