feat(def): 流程定义列表增「编辑信息」弹窗(原地改名称/归属应用)+ 编辑器非草稿进入提示

- 弹窗限 name+appKey(当前 appKey 不在启用集时兜底选项提示);保存后 version 不变
- 编辑器打开已发布/停用时提示:结构改动将升版本,仅改属性请用「编辑信息」
This commit is contained in:
chenxing
2026-10-10 19:23:45 +08:00
parent e8f9af534b
commit f835965e29
3 changed files with 78 additions and 2 deletions
+4
View File
@@ -143,6 +143,10 @@ class FlowApi {
defSave(body: { id?: number; code: string; name: string; contentJson: string; baseGuid?: string; appKey?: string }) {
return post(`${ROOT}/admin/def/save`, body);
}
/** 元数据原地编辑(2026-10-10 议题2):只改 name/appKey 不升版本;已发布亦可 */
defUpdateMeta(body: { id: number; name: string; appKey?: string }) {
return post(`${ROOT}/admin/def/updateMeta`, body);
}
defPublish(id: number | string) {
return post(`${ROOT}/admin/def/publish/${id}`);
}
+70 -2
View File
@@ -2,7 +2,7 @@
// 流程定义管理:列表 + 发布/启用/停用/升版本/版本历史/图示/源码。
// 新建与编辑走独立的全屏可视化编辑器(/admin/defs/editor,钉钉式卡片流,见《流程编辑器方案.md》);
// 本页不再直接编辑 JSON 文本(编辑器内置"源码"高级模式兜底);行内「源码」为只读查看+复制。
import { ref, onMounted } from "vue";
import { ref, computed, onMounted } from "vue";
import { useRouter } from "vue-router";
import { Message } from "view-ui-plus";
import MyConfirm from "@/components/MyConfirm";
@@ -40,7 +40,7 @@ const columns = [
} },
{ title: "GUID", key: "flowGuid", width: 200 },
{ title: "发布时间", width: 160, render: (h: any, p: any) => h("span", (p.row.publishTime || "").replace("T", " ") || "-") },
{ title: "操作", width: 250, align: "center", fixed: "right", render: (h: any, p: any) => {
{ title: "操作", width: 310, align: "center", fixed: "right", render: (h: any, p: any) => {
const btns: any[] = [];
if (p.row.status === 0) {
btns.push(Utils.operatingHandle(h, "编辑", "icon-edit", () => onEdit(p.row)));
@@ -53,6 +53,8 @@ const columns = [
// 草稿不走这里,草稿用「发布」)
btns.push(Utils.operatingHandle(h, "启用", "icon-play", () => onEnable(p.row)));
}
// 元数据原地编辑(2026-10-10 议题2):改名称/归属应用不升版本(含已发布/停用)
btns.push(Utils.operatingHandle(h, "编辑信息", "icon-bianji", () => onEditMeta(p.row)));
btns.push(Utils.operatingHandle(h, "图示", "icon-tupian", () => onDiagram(p.row)));
btns.push(Utils.operatingHandle(h, "源码", "icon-liebiao", () => onSource(p.row)));
btns.push(Utils.operatingHandle(h, "版本历史", "icon-shijian", () => onVersions(p.row)));
@@ -168,6 +170,50 @@ function onDiagram(row: any) {
router.push({ path: "/diagram", query: { defId: row.id } });
}
// ---- 编辑信息(元数据原地编辑,2026-10-10 议题2:改名称/归属应用不升版本) ----
const metaVisible = ref(false);
const metaSaving = ref(false);
const metaForm = ref<{ id: number; name: string; appKey: string; version: number; status: number }>({
id: 0, name: "", appKey: "", version: 0, status: 0,
});
function onEditMeta(row: any) {
metaForm.value = { id: row.id, name: row.name || "", appKey: row.appKey || "", version: row.version, status: row.status };
metaVisible.value = true;
}
/** 当前 appKey 不在启用集合时兜底插入(保存会被后端拦,提示用户先开启或清空) */
const metaAppOptions = computed(() => {
const list = apps.value.map((a) => ({ value: a.appKey, label: a.appName }));
const cur = metaForm.value.appKey;
if (cur && !list.some((o) => o.value === cur)) {
list.unshift({ value: cur, label: `${cur}(未开启,保存将被拦)` });
}
return list;
});
async function onMetaSave() {
if (!metaForm.value.name.trim()) {
Message.warning("流程名称不能为空");
return;
}
metaSaving.value = true;
try {
await flowApi.defUpdateMeta({
id: metaForm.value.id,
name: metaForm.value.name.trim(),
appKey: metaForm.value.appKey || undefined,
}).send();
Message.success("已更新(版本不变)");
metaVisible.value = false;
load();
} catch (e: any) {
Message.error(e?.message || "保存失败");
} finally {
metaSaving.value = false;
}
}
onMounted(() => {
load();
loadAppKeys();
@@ -199,6 +245,28 @@ onMounted(() => {
</Modal>
<SourceDrawer v-model="sourceVisible" :text="sourceText" :subtitle="sourceTitle" />
<Modal v-model="metaVisible" title="编辑流程信息(不升版本)" :mask-closable="false" width="460">
<p style="color: #808695; font-size: 12px; line-height: 1.6; margin-bottom: 10px">
只修改名称与归属应用,版本与流程内容保持不变(v{{ metaForm.version }},{{
DEF_STATUS[metaForm.status] || metaForm.status }})。结构改动请走「{{
metaForm.status === 0 ? "编辑" : "升版本" }}」进编辑器。
</p>
<Form :label-width="90">
<FormItem label="流程名称">
<Input v-model="metaForm.name" placeholder="流程名称" :maxlength="30" />
</FormItem>
<FormItem label="归属应用">
<Select v-model="metaForm.appKey" clearable filterable placeholder="归属应用,可空">
<Option v-for="o in metaAppOptions" :key="o.value" :value="o.value">{{ o.label }}</Option>
</Select>
</FormItem>
</Form>
<template #footer>
<Button @click="metaVisible = false">取消</Button>
<Button type="primary" :loading="metaSaving" @click="onMetaSave">保存</Button>
</template>
</Modal>
</div>
</div>
</template>
@@ -200,6 +200,10 @@ async function load(): Promise<void> {
const d: any = await flowApi.defGet(queryId).send();
sourceStatus.value = d?.status ?? 0;
sourceVersion.value = d?.version ?? 0;
// 非草稿进入提示(2026-10-10 议题2):结构改动保存将升版本;仅改名称/归属应用请回列表用「编辑信息」
if (d?.status === 1 || d?.status === 2) {
Message.info("结构改动保存将升版本;仅改名称/归属应用请返回列表用「编辑信息」(不升版本)");
}
model.code = d?.code || "";
model.name = d?.name || "";
appKey.value = d?.appKey || "";