From 9f3bc47b98cbc51df7cfcea94d4aa0c35f40cbc5 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期二, 13 十月 2026 14:09:06 +0800
Subject: [PATCH] feat: 添加数字格式化工具,支持去掉小数末尾多余的 0 和四舍五入功能
---
src/views/officeProcessAutomation/ApproveManage/approve-template/components/TemplateFlowEditor.vue | 68 ++++++++++++++++++++++++++++------
1 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-template/components/TemplateFlowEditor.vue b/src/views/officeProcessAutomation/ApproveManage/approve-template/components/TemplateFlowEditor.vue
index 45b32c0..d82448b 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-template/components/TemplateFlowEditor.vue
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-template/components/TemplateFlowEditor.vue
@@ -6,14 +6,21 @@
<div class="tfe-card" :class="{ 'tfe-card--empty': !item.approvers?.length }">
<div class="tfe-badge">{{ index + 1 }}</div>
<div class="tfe-head">
- <span class="tfe-level">{{ levelText(index) }}</span>
- <el-radio-group v-model="item.signMode" size="small" @change="emitOut">
+ <span class="tfe-level">{{ levelText(index) }}</span> <el-radio-group
+ v-if="!readonly"
+ v-model="item.signMode"
+ size="small"
+ @change="emitOut"
+ >
<el-radio-button value="countersign">浼氱</el-radio-button>
<el-radio-button value="or_sign">鎴栫</el-radio-button>
</el-radio-group>
+ <el-tag v-else size="small" type="info" effect="plain">
+ {{ signModeLabel(item.signMode) }}
+ </el-tag>
</div>
<p class="tfe-mode-tip">{{ signModeTip(item.signMode) }}</p>
- <div class="tfe-select">
+ <div v-if="!readonly" class="tfe-select">
<el-select
v-model="item.approverIds"
multiple
@@ -33,7 +40,7 @@
/>
</el-select>
</div>
- <div v-if="item.approvers?.length" class="tfe-chips">
+ <div v-if="item.approvers?.length" class="tfe-chips" :class="{ 'tfe-chips--readonly': readonly }">
<el-tag
v-for="a in item.approvers"
:key="String(a.approverId)"
@@ -44,7 +51,7 @@
{{ a.approverName || "鈥�" }}
</el-tag>
</div>
- <div class="tfe-actions">
+ <div v-if="!readonly" class="tfe-actions">
<el-button type="primary" circle size="small" :disabled="index === 0" title="鍓嶇Щ" @click="moveLeft(index)">
<el-icon><ArrowLeft /></el-icon>
</el-button>
@@ -62,6 +69,7 @@
<el-icon><Delete /></el-icon>
</el-button>
</div>
+ <p v-else-if="!item.approvers?.length" class="tfe-empty-approver">鏆傛棤瀹℃壒浜�</p>
</div>
<div v-if="index < innerList.length - 1" class="tfe-conn">
<div class="tfe-conn-line"></div>
@@ -69,7 +77,7 @@
</div>
</div>
- <div class="tfe-add-wrap">
+ <div v-if="!readonly" class="tfe-add-wrap">
<div v-if="innerList.length" class="tfe-conn">
<div class="tfe-conn-line"></div>
<el-icon class="tfe-conn-icon"><ArrowRight /></el-icon>
@@ -84,7 +92,7 @@
<div v-else class="tfe-empty">
<el-icon :size="44" color="#c0c4cc"><User /></el-icon>
<p>鏆傛棤瀹℃壒鑺傜偣</p>
- <el-button type="primary" @click="addNode">娣诲姞绗竴涓妭鐐�</el-button>
+ <el-button v-if="!readonly" type="primary" @click="addNode">娣诲姞绗竴涓妭鐐�</el-button>
</div>
</div>
</template>
@@ -92,11 +100,15 @@
<script setup>
import { ArrowLeft, ArrowRight, Delete, Plus, User } from "@element-plus/icons-vue";
import { ref, watch } from "vue";
-import { NODE_SIGN_MODE_OPTIONS, normalizeFlowNodes } from "../approveTemplateConstants.js";
+import { NODE_SIGN_MODE_OPTIONS, normalizeFlowNodes, nodeDisplayName } from "../approveTemplateConstants.js";
const props = defineProps({
modelValue: { type: Array, default: () => [] },
userOptions: { type: Array, default: () => [] },
+ /** 瀹℃壒绫诲瀷/妯℃澘鍚嶇О锛岀敤浜庢嫾鑺傜偣鍚嶏紙濡傘�屽彂璐у鎵孤蜂竴绾с�嶏級 */
+ typeName: { type: String, default: "" },
+ /** 閫夋嫨妯℃澘鍚庣敵璇峰満鏅細浠呭睍绀猴紝涓嶅彲鏀瑰鎵逛汉/鑺傜偣 */
+ readonly: { type: Boolean, default: false },
});
const emit = defineEmits(["update:modelValue"]);
@@ -107,9 +119,16 @@
return NODE_SIGN_MODE_OPTIONS.find((x) => x.value === mode)?.desc || "";
}
+function signModeLabel(mode) {
+ return (
+ NODE_SIGN_MODE_OPTIONS.find((x) => x.value === mode)?.label ||
+ (mode === "or_sign" ? "鎴栫" : "浼氱")
+ );
+}
+
function levelText(i) {
- const t = ["绗竴绾�", "绗簩绾�", "绗笁绾�", "绗洓绾�", "绗簲绾�", "绗叚绾�", "绗竷绾�", "绗叓绾�"];
- return t[i] || `绗�${i + 1}绾;
+ // 鑺傜偣鍚嶆寜瀹℃壒绫诲瀷 + 灞傜骇鏄剧ず锛屽銆屽彂璐у鎵孤蜂竴绾с��
+ return nodeDisplayName(props.typeName, i);
}
function optionLabel(u) {
@@ -127,6 +146,8 @@
const normalized = normalizeFlowNodes(rows);
return normalized.map((n) => ({
_uid: newUid(),
+ id: n.id,
+ templateId: n.templateId,
nodeOrder: n.nodeOrder,
signMode: n.signMode,
approverIds: n.approvers.map((a) => a.approverId),
@@ -137,6 +158,8 @@
function publicShape(rows) {
return normalizeFlowNodes(
(rows || []).map((r) => ({
+ id: r.id,
+ templateId: r.templateId,
nodeOrder: r.nodeOrder,
signMode: r.signMode,
approvers: r.approvers || [],
@@ -165,18 +188,27 @@
function onApproversChange(ids, row) {
const idList = Array.isArray(ids) ? ids : [];
+ const prevById = new Map((row.approvers || []).map((a) => [String(a.approverId), a]));
row.approverIds = idList;
row.approvers = idList.map((id) => {
+ const prev = prevById.get(String(id));
const u = findUser(id);
- return {
+ const item = {
approverId: id,
- approverName: u ? u.nickName || u.userName || "" : "",
+ approverName: u ? u.nickName || u.userName || "" : prev?.approverName || "",
};
+ if (prev?.id != null) item.id = prev.id;
+ if (prev?.nodeId != null) item.nodeId = prev.nodeId;
+ else if (row.id != null) item.nodeId = row.id;
+ if (prev?.templateId != null) item.templateId = prev.templateId;
+ else if (row.templateId != null) item.templateId = row.templateId;
+ return item;
});
emitOut();
}
function addNode() {
+ if (props.readonly) return;
innerList.value.push({
_uid: newUid(),
nodeOrder: innerList.value.length + 1,
@@ -188,11 +220,13 @@
}
function remove(index) {
+ if (props.readonly) return;
innerList.value.splice(index, 1);
emitOut();
}
function moveLeft(index) {
+ if (props.readonly) return;
if (index < 1) return;
const t = innerList.value[index];
innerList.value[index] = innerList.value[index - 1];
@@ -201,6 +235,7 @@
}
function moveRight(index) {
+ if (props.readonly) return;
if (index >= innerList.value.length - 1) return;
const t = innerList.value[index];
innerList.value[index] = innerList.value[index + 1];
@@ -281,6 +316,15 @@
margin-bottom: 8px;
min-height: 24px;
}
+.tfe-chips--readonly {
+ margin-top: 4px;
+ margin-bottom: 0;
+}
+.tfe-empty-approver {
+ font-size: 12px;
+ color: var(--el-text-color-placeholder);
+ margin: 4px 0 0;
+}
.tfe-actions {
display: flex;
justify-content: center;
--
Gitblit v1.9.3