feat: 流程配置页恢复提交环节开关,与节点开关同一心智

This commit is contained in:
2026-11-01 16:31:07 +08:00
parent 0f147ec952
commit c152f0cfbd
2 changed files with 82 additions and 11 deletions
+10 -1
View File
@@ -9,6 +9,15 @@ export const NODE_TYPE_OPTIONS = [
{ value: 'ARCHIVE', label: '归档' }
];
/** 提交环节:链首只读节点,不在可添加类型里 */
export const NODE_SUBMIT = 'SUBMIT';
/** 节点类型显示用(比可选项多一个提交环节) */
export const NODE_TYPE_LABELS = [
...NODE_TYPE_OPTIONS,
{ value: NODE_SUBMIT, label: '提交' }
];
/** 需要固定组织编码的解析器 */
export const ORG_RESOLVERS = ['orgLeaderByCode', 'orgDeputyByCode'];
@@ -17,6 +26,6 @@ export const WRITABLE_TYPES = ['APPROVE', 'COUNTERSIGN', 'CONFIRM'];
/** 节点类型显示名 */
export function nodeTypeLabel(type?: string) {
const item = NODE_TYPE_OPTIONS.find((option) => option.value === type);
const item = NODE_TYPE_LABELS.find((option) => option.value === type);
return item ? item.label : type || '';
}
+72 -10
View File
@@ -61,6 +61,19 @@
</a-button>
</a-space>
</div>
<div class="submit-stage">
<div class="submit-stage-header">
<span class="submit-stage-title">提交环节</span>
<a-radio-group v-model:value="submitMode" size="small">
<a-radio-button value="FOLLOW">跟随代码</a-radio-button>
<a-radio-button value="ON">必须上传附件</a-radio-button>
<a-radio-button value="OFF">不必上传附件</a-radio-button>
</a-radio-group>
</div>
<div class="submit-stage-tip">
「跟随代码」沿用单据实现里声明的附件要求;选定后本环节作为链首只读节点发布,不产生待办。
</div>
</div>
<a-empty
v-if="!nodes.length"
description="该流程尚未发布,点击「载入出厂模板」开始编辑"
@@ -157,17 +170,43 @@
const historyLoading = ref(false);
const history = ref<ApprovalFlowVersion[]>([]);
/* 深拷贝节点:编辑区不能直接改列表里的对象 */
const cloneNodes = (nodes?: ApprovalFlowNode[]) => {
return JSON.parse(JSON.stringify(nodes || [])) as ApprovalFlowNode[];
/* 提交环节:FOLLOW 沿用代码声明,ON/OFF 会以链首 SUBMIT 节点发布(ADR 0016) */
const submitMode = ref('FOLLOW');
/* 加载一条节点链:链首 SUBMIT 拆成独立的提交环节开关 */
const setChain = (chain?: ApprovalFlowNode[]) => {
const list = chain || [];
const head = list.length && list[0].type === 'SUBMIT' ? list[0] : null;
submitMode.value = head
? head.attachmentRequired
? 'ON'
: 'OFF'
: 'FOLLOW';
nodes.value = list.filter((node) => node.type !== 'SUBMIT');
editorRevision.value = editorRevision.value + 1;
};
/* 发布时拼回完整链:提交环节固定在最前 */
const buildChain = () => {
if (submitMode.value === 'FOLLOW') {
return nodes.value;
}
return [
{
key: 'submit',
type: 'SUBMIT',
name: '提交',
attachmentRequired: submitMode.value === 'ON'
},
...nodes.value
];
};
/* 加载编辑区:整链替换时递增 revision,强制节点卡片重新初始化 */
const applyFlow = (flow: ApprovalFlow) => {
current.value = flow;
flowCode.value = flow.flowCode;
nodes.value = cloneNodes(flow.nodes);
editorRevision.value = editorRevision.value + 1;
setChain(flow.nodes);
};
const refreshFlows = (keepCode?: string) => {
@@ -236,8 +275,7 @@
okText: '载入',
cancelText: '取消',
onOk: () => {
nodes.value = cloneNodes(current.value?.factoryNodes);
editorRevision.value = editorRevision.value + 1;
setChain(current.value?.factoryNodes);
}
});
};
@@ -260,8 +298,7 @@
};
const loadVersion = (item: ApprovalFlowVersion) => {
nodes.value = cloneNodes(item.nodes);
editorRevision.value = editorRevision.value + 1;
setChain(item.nodes);
historyVisible.value = false;
message.info('已载入 v' + item.version + ',确认后点「保存并发布」');
};
@@ -284,7 +321,7 @@
saving.value = true;
return publishFlowConfig({
flowCode: current.value!.flowCode,
nodes: nodes.value
nodes: buildChain()
})
.then((data) => {
saving.value = false;
@@ -349,6 +386,31 @@
font-weight: 400;
}
.submit-stage {
margin-bottom: 12px;
padding: 12px;
background: rgba(0, 0, 0, 0.02);
border: 1px dashed rgba(0, 0, 0, 0.12);
border-radius: 6px;
}
.submit-stage-header {
display: flex;
align-items: center;
justify-content: space-between;
}
.submit-stage-title {
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
}
.submit-stage-tip {
margin-top: 6px;
color: rgba(0, 0, 0, 0.45);
font-size: 12px;
}
.flow-add {
margin-bottom: 12px;
}