From 4d5e975ce21256b1ba64206c5deb79b94bceb0ba Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 23 十月 2025 11:14:59 +0800
Subject: [PATCH] 设备监控前端页面
---
src/components/Table/EtableModify.vue | 67 +++++++++++++++------------------
1 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/src/components/Table/EtableModify.vue b/src/components/Table/EtableModify.vue
index cf21bc2..5c6d032 100644
--- a/src/components/Table/EtableModify.vue
+++ b/src/components/Table/EtableModify.vue
@@ -30,14 +30,15 @@
align="center"
/>
<template v-for="col in columns" :key="col.prop">
- <el-table-column
- v-bind="col"
- :show-overflow-tooltip="shouldShowTooltip(col, tableData)"
- align="center"
- >
+ <el-table-column v-bind="col" align="center">
<template #default="scope">
<template v-if="col.slot">
- <slot></slot>
+ <slot
+ :name="col.prop"
+ :row="scope.row"
+ :column="scope.column"
+ :index="scope.$index"
+ ></slot>
</template>
<template v-else>
<div
@@ -45,16 +46,21 @@
@dblclick="handleCellEdit(scope.row, col.prop)"
:class="{ editable: isColumnEditable(col.prop) }"
>
+ <!-- 鏄剧ず鐘舵�侊細浣跨敤鏍煎紡鍖栫殑鍊� -->
<span
v-if="!scope.row.editing || !scope.row.editing[col.prop]"
class="cell-text"
>
{{
- scope.row[col.prop] == null || scope.row[col.prop] === ""
- ? "--"
- : scope.row[col.prop]
+ formatCellValue(
+ scope.row,
+ scope.column,
+ scope.row[col.prop],
+ col
+ )
}}
</span>
+ <!-- 缂栬緫鐘舵�侊細浣跨敤鍘熷鍊硷紝涓嶇粡杩囨牸寮忓寲 -->
<el-input
v-else
v-model="scope.row[col.prop]"
@@ -69,34 +75,6 @@
</template>
</el-table-column>
</template>
- <!-- 鎿嶄綔鍒� -->
- <el-table-column
- v-if="showOperations"
- :label="operationsLabel"
- :width="operationsWidth"
- fixed="right"
- align="center"
- >
- <template #default="scope">
- <slot name="operations" :row="scope.row">
- <el-button
- v-if="operations.includes('edit')"
- link
- type="primary"
- size="small"
- @click="handleEdit(scope.row)"
- >缂栬緫</el-button
- >
- <!-- <el-button-->
- <!-- v-if="operations.includes('delete')"-->
- <!-- link-->
- <!-- type="danger"-->
- <!-- size="small"-->
- <!-- @click="handleDelete(scope.row)"-->
- <!-- >鍒犻櫎</el-button>-->
- </slot>
- </template>
- </el-table-column>
</el-table>
</template>
@@ -217,7 +195,22 @@
// 妫�鏌ヨ鍒楀湪鎵�鏈夋暟鎹腑鏄惁鏈夐潪绌哄��
return data.some((row) => row[col.prop] != null && row[col.prop] !== "");
};
+// 榛樿鐨勬牸寮忓寲鍑芥暟
+const defaultFormatter = (row, column, cellValue) => {
+ return cellValue == null || cellValue === "" || cellValue === 0
+ ? "0"
+ : cellValue;
+};
+// 鏍煎紡鍖栧崟鍏冩牸鍊�
+const formatCellValue = (row, column, cellValue, col) => {
+ // 濡傛灉鍒楁湁鑷畾涔夋牸寮忓寲鍣紝浣跨敤鑷畾涔夋牸寮忓寲鍣�
+ if (col.formatter && typeof col.formatter === "function") {
+ return col.formatter(row, column, cellValue);
+ }
+ // 鍚﹀垯浣跨敤榛樿鏍煎紡鍖栧櫒
+ return defaultFormatter(row, column, cellValue);
+};
// 澶勭悊鍗曞厓鏍肩紪杈�
const handleCellEdit = (row, prop) => {
// 濡傛灉涓嶅厑璁哥紪杈戝崟鍏冩牸锛岀洿鎺ヨ繑鍥�
--
Gitblit v1.9.3