diff --git a/src/components/PreApprovalFlowPicker.vue b/src/components/PreApprovalFlowPicker.vue index ad6f06d..8460a5f 100644 --- a/src/components/PreApprovalFlowPicker.vue +++ b/src/components/PreApprovalFlowPicker.vue @@ -34,11 +34,11 @@ - - 添加流程 + + 重新选择 @@ -104,7 +104,7 @@ @@ -368,6 +369,7 @@ const searchKeyword = ref('') const availableYears = ref([]) // 可用年份列表 const selectedYear = ref(null) // 选中的年份 const flowTableRef = ref(null) // 表格引用 +const selectionMode = ref('replace') // replace=替换当前选择,append=追加到当前选择 // 分页 const pagination = ref({ @@ -394,6 +396,23 @@ const detailFields = computed(() => { return [] }) +const dialogTitle = computed(() => { + return selectionMode.value === 'append' ? '追加事前流程实例' : '选择事前流程实例' +}) + +const dialogFooterTip = computed(() => { + const selectedCount = selectedRows.value.length + const existingCount = selectedFlows.value.length + return selectedRows.value.length > 0 + ? `本次勾选 ${selectedCount} 条。可选择替换已有流程,或追加到已有 ${existingCount} 条流程后面(重复自动忽略)。` + : `请选择流程。可替换已有流程,或追加到已有 ${existingCount} 条流程后面。` +}) + +const openSelectDialog = (mode = 'replace') => { + selectionMode.value = mode + showSelectDialog.value = true +} + // 获取流程显示名称 const getFlowDisplayName = (flow) => { if (!flow) return '' @@ -772,14 +791,18 @@ const handleSelectionChange = (selection) => { } // 确认选择(多选) -const confirmSelect = () => { +const confirmSelect = (mode = selectionMode.value) => { if (selectedRows.value.length === 0) { ElMessage.warning('请至少选择一条流程') return } + const nextSelectedFlows = mode === 'append' + ? dedupeFlows([...selectedFlows.value, ...selectedRows.value]) + : [...selectedRows.value] + // 更新已选择的流程列表 - selectedFlows.value = [...selectedRows.value] + selectedFlows.value = nextSelectedFlows // 提取流程ID数组 const flowIds = selectedFlows.value.map(flow => flow.id) @@ -792,6 +815,23 @@ const confirmSelect = () => { showSelectDialog.value = false } +const dedupeFlows = (flows) => { + const seen = new Set() + const result = [] + flows.forEach(flow => { + if (!flow || flow.id === null || flow.id === undefined) { + return + } + const key = String(flow.id) + if (seen.has(key)) { + return + } + seen.add(key) + result.push(flow) + }) + return result +} + // 移除单个流程 const removeFlow = (flowId) => { selectedFlows.value = selectedFlows.value.filter(flow => flow.id !== flowId) diff --git a/src/views/funds/Budget.vue b/src/views/funds/Budget.vue index 82c7a80..bc7b197 100644 --- a/src/views/funds/Budget.vue +++ b/src/views/funds/Budget.vue @@ -303,7 +303,18 @@ >