From 6ff8faad4a183eaa35fac526e4e29a1c6176ff15 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 08 十月 2026 17:43:18 +0800
Subject: [PATCH] 采购管理系统模块优化
---
src/views/collaborativeApproval/approvalProcess/components/flowDefinitionDia.vue | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 100 insertions(+), 0 deletions(-)
diff --git a/src/views/collaborativeApproval/approvalProcess/components/flowDefinitionDia.vue b/src/views/collaborativeApproval/approvalProcess/components/flowDefinitionDia.vue
new file mode 100644
index 0000000..bb0a408
--- /dev/null
+++ b/src/views/collaborativeApproval/approvalProcess/components/flowDefinitionDia.vue
@@ -0,0 +1,100 @@
+<template>
+ <el-dialog v-model="visible" title="棰勮瀹℃壒娴佺▼" width="820px">
+ <div class="toolbar"><el-button type="primary" @click="editFlow()">鏂板娴佺▼</el-button></div>
+ <el-table :data="flowList" border>
+ <el-table-column prop="flowName" label="娴佺▼鍚嶇О" />
+ <el-table-column label="榛樿娴佺▼" width="100"><template #default="{ row }">{{ row.isDefault === 1 ? '鏄�' : '鍚�' }}</template></el-table-column>
+ <el-table-column label="鐘舵��" width="90"><template #default="{ row }"><el-tag :type="row.enabled === 1 ? 'success' : 'info'">{{ row.enabled === 1 ? '鍚敤' : '鍋滅敤' }}</el-tag></template></el-table-column>
+ <el-table-column label="鎿嶄綔" width="250">
+ <template #default="{ row }">
+ <el-button link type="primary" @click="editFlow(row)">缂栬緫</el-button>
+ <el-button link type="primary" @click="toggleEnabled(row)">{{ row.enabled === 1 ? '鍋滅敤' : '鍚敤' }}</el-button>
+ <el-button link type="danger" @click="removeFlow(row)">鍒犻櫎</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+
+ <el-dialog v-model="editorVisible" :title="editor.definition.id ? '缂栬緫娴佺▼' : '鏂板娴佺▼'" width="720px" append-to-body>
+ <el-form label-width="100px">
+ <el-form-item label="娴佺▼鍚嶇О"><el-input v-model="editor.definition.flowName" /></el-form-item>
+ <el-form-item label="璁句负榛樿"><el-switch v-model="editor.definition.isDefault" :active-value="1" :inactive-value="0" /></el-form-item>
+ <el-form-item label="鍚敤"><el-switch v-model="editor.definition.enabled" :active-value="1" :inactive-value="0" /></el-form-item>
+ </el-form>
+ <el-divider content-position="left">瀹℃壒鑺傜偣</el-divider>
+ <div v-for="(node, index) in editor.nodes" :key="node.key" class="node-row">
+ <span>{{ index + 1 }}</span>
+ <el-input v-model="node.nodeName" placeholder="鑺傜偣鍚嶇О" style="width: 150px" />
+ <el-select v-model="node.approverValue" filterable placeholder="瀹℃壒浜�" style="width: 150px">
+ <el-option v-for="user in users" :key="user.userId" :label="user.nickName" :value="String(user.userId)" />
+ </el-select>
+ <el-select v-model="node.conditionOperator" style="width: 130px">
+ <el-option label="濮嬬粓鎵ц" value="ALWAYS" /><el-option label="閲戦澶т簬" value="GT" /><el-option label="閲戦澶т簬绛変簬" value="GTE" />
+ </el-select>
+ <el-input-number v-if="node.conditionOperator !== 'ALWAYS'" v-model="node.conditionValue" :min="0" :precision="2" style="width: 120px" />
+ <el-button link type="danger" :disabled="editor.nodes.length === 1" @click="editor.nodes.splice(index, 1)">鍒犻櫎</el-button>
+ </div>
+ <el-button type="primary" plain @click="editor.nodes.push(createNode())">鏂板鑺傜偣</el-button>
+ <template #footer><el-button @click="editorVisible = false">鍙栨秷</el-button><el-button type="primary" :loading="saving" @click="saveFlow">淇濆瓨</el-button></template>
+ </el-dialog>
+ </el-dialog>
+</template>
+
+<script setup>
+import { getCurrentInstance, reactive, ref } from 'vue'
+import { approveFlowDefinitionAdd, approveFlowDefinitionDelete, approveFlowDefinitionEnabled, approveFlowDefinitionGet, approveFlowDefinitionList, approveFlowDefinitionUpdate } from '@/api/collaborativeApproval/approvalProcess'
+import { userListNoPageByTenantId } from '@/api/system/user'
+
+const { proxy } = getCurrentInstance()
+const visible = ref(false)
+const editorVisible = ref(false)
+const saving = ref(false)
+const approveType = ref(3)
+const flowList = ref([])
+const users = ref([])
+let key = 1
+const createNode = (data = {}) => ({ key: key++, nodeName: data.nodeName || '', approverType: 'USER', approverValue: data.approverValue ? String(data.approverValue) : '', conditionField: data.conditionField || null, conditionOperator: data.conditionOperator || 'ALWAYS', conditionValue: data.conditionValue == null ? null : Number(data.conditionValue) })
+const editor = reactive({ definition: {}, nodes: [] })
+
+const load = async () => {
+ const [flows, userRes] = await Promise.all([approveFlowDefinitionList({ approveType: approveType.value }), userListNoPageByTenantId()])
+ flowList.value = flows.data || []
+ users.value = userRes.data || []
+}
+const open = async type => { approveType.value = Number(type); visible.value = true; await load() }
+const editFlow = async row => {
+ if (row?.id) {
+ const res = await approveFlowDefinitionGet(row.id)
+ editor.definition = { ...res.data.definition }
+ editor.nodes = (res.data.nodes || []).map(createNode)
+ } else {
+ editor.definition = { id: null, flowName: '', approveType: approveType.value, enabled: 1, isDefault: 0 }
+ editor.nodes = [createNode()]
+ }
+ editorVisible.value = true
+}
+const saveFlow = async () => {
+ if (!editor.definition.flowName?.trim()) return proxy.$modal.msgError('璇疯緭鍏ユ祦绋嬪悕绉�')
+ if (editor.nodes.some(node => !node.nodeName?.trim() || !node.approverValue)) return proxy.$modal.msgError('璇峰畬鏁村~鍐欏鎵硅妭鐐�')
+ const payload = { definition: { ...editor.definition, approveType: approveType.value }, nodes: editor.nodes.map((node, index) => ({ ...node, id: null, nodeOrder: index + 1, conditionField: node.conditionOperator === 'ALWAYS' ? null : 'amount', conditionValue: node.conditionValue == null ? null : String(node.conditionValue) })) }
+ saving.value = true
+ try {
+ if (editor.definition.id) await approveFlowDefinitionUpdate(editor.definition.id, payload)
+ else await approveFlowDefinitionAdd(payload)
+ proxy.$modal.msgSuccess('淇濆瓨鎴愬姛')
+ editorVisible.value = false
+ await load()
+ } finally { saving.value = false }
+}
+const toggleEnabled = async row => { await approveFlowDefinitionEnabled(row.id, row.enabled === 1 ? 0 : 1); await load() }
+const removeFlow = async row => {
+ await proxy.$modal.confirm(`纭鍒犻櫎娴佺▼鈥�${row.flowName}鈥濆悧锛焋)
+ await approveFlowDefinitionDelete(row.id)
+ await load()
+}
+defineExpose({ open })
+</script>
+
+<style scoped>
+.toolbar { margin-bottom: 12px; text-align: right; }
+.node-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
+</style>
--
Gitblit v1.9.3