From 26e0f4997558b60eda9dcb8979b777b47b31675e Mon Sep 17 00:00:00 2001 From: zhang_12370 <z2864490065@outlook.com> Date: 星期六, 19 七月 2025 17:14:43 +0800 Subject: [PATCH] 优化巡检管理显示及数据处理 --- src/views/inspectionManagement/index.vue | 72 ++++++++++++++++++++++++++++++++--- 1 files changed, 65 insertions(+), 7 deletions(-) diff --git a/src/views/inspectionManagement/index.vue b/src/views/inspectionManagement/index.vue index e95753e..7e5edc0 100644 --- a/src/views/inspectionManagement/index.vue +++ b/src/views/inspectionManagement/index.vue @@ -56,7 +56,26 @@ @edit="handleAdd" @viewFile="viewFile" v-if="tabName === 'task'" - ></ETable> + > + <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> + </ETable> <el-table ref="table" :data="tableData" height="480" v-loading="tableLoading" border v-else style="width: 100%;height: calc(100vh - 25em)"> <el-table-column label="搴忓彿" type="index" width="60" align="center" /> <el-table-column prop="deviceName" label="璁惧鍚嶇О" :show-overflow-tooltip="true"> @@ -80,10 +99,10 @@ </div> <pagination v-if="total>0" - :page-num="pageNum" - :page-size="pageSize" + :page="pageNum" + :limit="pageSize" :total="total" - @pagination="handleQuery" + @pagination="handlePagination" :layout="'total, prev, pager, next, jumper'" /> </div> @@ -162,7 +181,7 @@ { prop: "taskName", label: "宸℃浠诲姟鍚嶇О", minWidth: 160 }, { prop: "inspectionLocation", label: "鍦扮偣", minWidth: 120 }, { prop: "remarks", label: "澶囨敞", minWidth: 150 }, - { prop: "inspector", label: "鎵ц宸℃浜�", minWidth: 150 }, + { prop: "inspector", label: "鎵ц宸℃浜�", minWidth: 150, slot: "inspector" }, { prop: "frequencyType", label: "棰戞", @@ -240,7 +259,12 @@ pageSize.value = 10; getList(); }; - +// 鍒嗛〉澶勭悊 +const handlePagination = (val) => { + pageNum.value = val.page; + pageSize.value = val.limit; + getList(); +}; // 鑾峰彇鍒楄〃鏁版嵁 const getList = () => { tableLoading.value = true; @@ -264,7 +288,27 @@ } apiCall.then(res => { - tableData.value = res.data.records || []; + 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; @@ -329,5 +373,19 @@ </script> <style scoped> +.person-tags { + display: flex; + flex-wrap: wrap; + gap: 4px; +} +.person-tag { + margin-right: 4px; + margin-bottom: 2px; +} + +.no-data { + color: #909399; + font-size: 14px; +} </style> \ No newline at end of file -- Gitblit v1.9.3