feat: 归档L03与L09审批发布能力

- 新增统一审批中心与审批管理页面,支持流程配置、审批详情与角色/用户审批对象

- 接入聊天助手、知识库、工作流的发布与删除审批,并补齐发布态校验与快照展示
This commit is contained in:
2026-04-07 14:41:52 +08:00
parent 7e7c236c2a
commit 3f128e977a
138 changed files with 13035 additions and 346 deletions

View File

@@ -5,15 +5,30 @@ import { useRoute } from 'vue-router';
import { usePreferences } from '@easyflow/preferences';
import { getOptions, sortNodes } from '@easyflow/utils';
import { ArrowLeft, CircleCheck, Close } from '@element-plus/icons-vue';
import {
ArrowLeft,
CircleCheck,
Close,
Promotion,
} from '@element-plus/icons-vue';
import { Tinyflow } from '@tinyflow-ai/vue';
import { ElButton, ElDrawer, ElMessage, ElSkeleton } from 'element-plus';
import {
ElButton,
ElDrawer,
ElMessage,
ElMessageBox,
ElSkeleton,
} from 'element-plus';
import { api } from '#/api/request';
import CommonSelectDataModal from '#/components/commonSelectModal/CommonSelectDataModal.vue';
import { $t } from '#/locales';
import { router } from '#/router';
import { getIconByValue } from '#/views/ai/model/modelUtils/defaultIcon';
import {
isAiResourceApprovalPending,
normalizeAiPublishStatus,
} from '#/views/ai/shared/publish-status';
import ExecResult from '#/views/ai/workflow/components/ExecResult.vue';
import SingleRun from '#/views/ai/workflow/components/SingleRun.vue';
import WorkflowForm from '#/views/ai/workflow/components/WorkflowForm.vue';
@@ -135,6 +150,7 @@ const customNode = ref();
const showTinyFlow = ref(false);
const saveLoading = ref(false);
const checkLoading = ref(false);
const publishLoading = ref(false);
const checkIssuesVisible = ref(false);
const checkResult = ref<any>(null);
const checkContentSnapshot = ref<any>(null);
@@ -234,6 +250,30 @@ const pluginSelectRef = ref();
const updatePluginNode = ref<any>(null);
const pageLoading = ref(false);
const chainInfo = ref<any>(null);
const publishActionText = computed(() => {
switch (normalizeAiPublishStatus(workflowInfo.value?.publishStatus)) {
case 'DELETE_PENDING': {
return $t('aiWorkflow.publishStatusDeletePending');
}
case 'PUBLISH_PENDING': {
return $t('aiWorkflow.publishStatusPublishPending');
}
case 'PUBLISHED': {
return `${$t('aiWorkflow.publishStatusPublished')} · ${$t('button.republish')}`;
}
default: {
return `${$t('aiWorkflow.publishStatusDraft')} · ${$t('button.submitPublishApproval')}`;
}
}
});
const publishActionDisabled = computed(
() =>
!workflowId.value ||
saveLoading.value ||
checkLoading.value ||
publishLoading.value ||
isAiResourceApprovalPending(workflowInfo.value?.publishStatus),
);
function syncNavTitle(title: string) {
if (!title) {
@@ -458,6 +498,44 @@ function closeCheckIssues() {
async function handleCheck() {
await runCheck('PRE_EXECUTE');
}
async function handlePublish() {
if (publishLoading.value) {
return;
}
if (isAiResourceApprovalPending(workflowInfo.value?.publishStatus)) {
ElMessage.warning($t('aiWorkflow.publishPendingHint'));
return;
}
try {
await ElMessageBox.confirm(
$t('aiWorkflow.submitPublishApprovalConfirm'),
$t('message.noticeTitle'),
{
confirmButtonText: $t('button.confirm'),
cancelButtonText: $t('button.cancel'),
type: 'info',
},
);
} catch {
return;
}
const saved = await handleSave();
if (!saved) {
return;
}
publishLoading.value = true;
try {
const res = await api.post('/api/v1/workflow/submitPublishApproval', {
id: workflowId.value,
});
if (res.errorCode === 0) {
ElMessage.success(res.message || $t('message.saveOkMessage'));
await getWorkflowInfo(workflowId.value);
}
} finally {
publishLoading.value = false;
}
}
function onSubmit() {
initState.value = !initState.value;
}
@@ -584,7 +662,7 @@ function onAsyncExecute(info: any) {
<div class="workflow-head-actions">
<ElButton
:loading="checkLoading"
:disabled="saveLoading"
:disabled="saveLoading || publishLoading"
:icon="CircleCheck"
@click="handleCheck"
>
@@ -592,11 +670,21 @@ function onAsyncExecute(info: any) {
</ElButton>
<ElButton
type="primary"
:disabled="saveLoading || checkLoading"
:disabled="saveLoading || checkLoading || publishLoading"
@click="handleSave(true)"
>
{{ $t('button.save') }}(ctrl+s)
</ElButton>
<ElButton
:icon="Promotion"
:loading="publishLoading"
:disabled="publishActionDisabled"
class="workflow-publish-button"
:class="`workflow-publish-button--${normalizeAiPublishStatus(workflowInfo?.publishStatus)}`"
@click="handlePublish"
>
{{ publishActionText }}
</ElButton>
</div>
</div>
<Tinyflow
@@ -695,8 +783,42 @@ function onAsyncExecute(info: any) {
.workflow-head-actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
justify-content: flex-end;
}
:deep(.workflow-publish-button.el-button) {
box-shadow: none;
}
:deep(.workflow-publish-button.el-button:not(.is-disabled)) {
background: transparent;
}
:deep(.workflow-publish-button--DRAFT.el-button) {
color: hsl(var(--foreground) / 72%);
background: hsl(var(--muted) / 68%);
border-color: hsl(var(--foreground) / 14%);
}
:deep(.workflow-publish-button--PUBLISH_PENDING.el-button) {
color: hsl(var(--warning));
background: hsl(var(--warning) / 18%);
border-color: hsl(var(--warning) / 24%);
}
:deep(.workflow-publish-button--PUBLISHED.el-button) {
color: hsl(var(--success));
background: hsl(var(--success) / 18%);
border-color: hsl(var(--success) / 24%);
}
:deep(.workflow-publish-button--DELETE_PENDING.el-button) {
color: hsl(var(--destructive));
background: hsl(var(--destructive) / 16%);
border-color: hsl(var(--destructive) / 24%);
}
.tiny-flow-container {

View File

@@ -48,6 +48,12 @@ import PageSide from '#/components/page/PageSide.vue';
import { $t } from '#/locales';
import { router } from '#/router';
import { useDictStore } from '#/store';
import AiResourceCornerMeta from '#/views/ai/shared/AiResourceCornerMeta.vue';
import {
isAiResourceApprovalPending,
isAiResourcePublished,
normalizeAiPublishStatus,
} from '#/views/ai/shared/publish-status';
import WorkflowModal from './WorkflowModal.vue';
@@ -167,12 +173,25 @@ const actions: ActionButton[] = [
},
},
{
icon: Delete,
text: $t('button.delete'),
tone: 'danger',
icon: Promotion,
text: (row: any) =>
isAiResourcePublished(row.publishStatus)
? $t('button.republish')
: $t('button.submitPublishApproval'),
permission: '/api/v1/workflow/save',
placement: 'inline',
onClick: (row: any) => {
remove(row);
submitPublishApproval(row);
},
},
{
icon: Delete,
text: $t('button.submitDeleteApproval'),
tone: 'danger',
permission: '/api/v1/workflow/remove',
placement: 'menu',
onClick: (row: any) => {
submitDeleteApproval(row);
},
},
];
@@ -263,32 +282,85 @@ function showDialog(row: any, importMode = false) {
function resolveNavTitle(row: any) {
return row?.title || row?.name || '';
}
function remove(row: any) {
ElMessageBox.confirm($t('message.deleteAlert'), $t('message.noticeTitle'), {
confirmButtonText: $t('message.ok'),
cancelButtonText: $t('message.cancel'),
type: 'warning',
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
instance.confirmButtonLoading = true;
api
.post('/api/v1/workflow/remove', { id: row.id })
.then((res) => {
instance.confirmButtonLoading = false;
if (res.errorCode === 0) {
ElMessage.success(res.message);
reset();
done();
}
})
.catch(() => {
instance.confirmButtonLoading = false;
});
} else {
done();
}
},
}).catch(() => {});
async function submitPublishApproval(row: any) {
if (isAiResourceApprovalPending(row.publishStatus)) {
ElMessage.warning($t('aiWorkflow.publishPendingHint'));
return;
}
try {
await ElMessageBox.confirm(
$t('aiWorkflow.submitPublishApprovalConfirm'),
$t('message.noticeTitle'),
{
confirmButtonText: $t('button.confirm'),
cancelButtonText: $t('button.cancel'),
type: 'info',
},
);
} catch {
return;
}
const res = await api.post('/api/v1/workflow/submitPublishApproval', {
id: row.id,
});
if (res.errorCode === 0) {
ElMessage.success(res.message || $t('message.saveOkMessage'));
pageDataRef.value?.reload?.();
}
}
async function submitDeleteApproval(row: any) {
if (isAiResourceApprovalPending(row.publishStatus)) {
ElMessage.warning($t('aiWorkflow.deletePendingHint'));
return;
}
try {
await ElMessageBox.confirm(
$t('aiWorkflow.submitDeleteApprovalConfirm'),
$t('message.noticeTitle'),
{
confirmButtonText: $t('button.confirm'),
cancelButtonText: $t('button.cancel'),
type: 'warning',
},
);
} catch {
return;
}
const res = await api.post('/api/v1/workflow/submitDeleteApproval', {
id: row.id,
});
if (res.errorCode === 0) {
ElMessage.success(res.message || $t('message.saveOkMessage'));
pageDataRef.value?.reload?.();
}
}
function resolvePublishStatusMeta(status?: string) {
switch (normalizeAiPublishStatus(status)) {
case 'DELETE_PENDING': {
return {
label: $t('aiWorkflow.publishStatusDeletePending'),
tone: 'danger',
};
}
case 'PUBLISH_PENDING': {
return {
label: $t('aiWorkflow.publishStatusPublishPending'),
tone: 'pending',
};
}
case 'PUBLISHED': {
return {
label: $t('aiWorkflow.publishStatusPublished'),
tone: 'published',
};
}
default: {
return {
label: $t('aiWorkflow.publishStatusDraft'),
tone: 'draft',
};
}
}
}
function toDesignPage(row: any) {
router.push({
@@ -496,21 +568,97 @@ function handleHeaderButtonClick(data: any) {
:actions="actions"
>
<template #corner="{ item }">
<ElPopover
v-if="canManageWorkflow"
:ref="(el) => setVisibilityScopePopoverRef(item.id, el)"
trigger="click"
placement="bottom-end"
:width="208"
popper-class="workflow-visibility-popover"
>
<template #reference>
<button
type="button"
class="workflow-scope-chip"
<AiResourceCornerMeta>
<template #publish>
<div
class="workflow-publish-chip"
:class="`workflow-publish-chip--${resolvePublishStatusMeta(item.publishStatus).tone}`"
>
<span class="workflow-publish-chip__dot"></span>
<span>{{
resolvePublishStatusMeta(item.publishStatus).label
}}</span>
</div>
</template>
<template #scope>
<ElPopover
v-if="canManageWorkflow"
:ref="(el) => setVisibilityScopePopoverRef(item.id, el)"
trigger="click"
placement="bottom-end"
:width="208"
popper-class="workflow-visibility-popover"
>
<template #reference>
<button
type="button"
class="workflow-scope-chip"
:class="`workflow-scope-chip--${resolveVisibilityScopeMeta(item.visibilityScope).tone}`"
:disabled="updatingScopeId === item.id"
@click.stop
>
<ElIcon class="workflow-scope-chip__icon">
<component
:is="
resolveVisibilityScopeMeta(item.visibilityScope)
.icon
"
/>
</ElIcon>
<span class="workflow-scope-chip__label">
{{
resolveVisibilityScopeMeta(item.visibilityScope)
.label
}}
</span>
</button>
</template>
<div class="workflow-scope-panel" @click.stop>
<button
v-for="option in visibilityScopeOptions"
:key="option.value"
type="button"
class="workflow-scope-option"
:class="[
`workflow-scope-option--${option.tone}`,
{
'workflow-scope-option--active':
item.visibilityScope === option.value,
},
]"
:disabled="updatingScopeId === item.id"
@click.stop="
updateVisibilityScope(item, option.value)
"
>
<span class="workflow-scope-option__leading">
<span class="workflow-scope-option__icon-wrap">
<ElIcon class="workflow-scope-option__icon">
<component :is="option.icon" />
</ElIcon>
</span>
<span class="workflow-scope-option__text">
<span class="workflow-scope-option__label">
{{ option.label }}
</span>
<span class="workflow-scope-option__desc">
{{ option.description }}
</span>
</span>
</span>
<ElIcon
v-if="item.visibilityScope === option.value"
class="workflow-scope-option__check"
>
<Check />
</ElIcon>
</button>
</div>
</ElPopover>
<div
v-else
class="workflow-scope-chip workflow-scope-chip--readonly"
:class="`workflow-scope-chip--${resolveVisibilityScopeMeta(item.visibilityScope).tone}`"
:disabled="updatingScopeId === item.id"
@click.stop
>
<ElIcon class="workflow-scope-chip__icon">
<component
@@ -525,64 +673,9 @@ function handleHeaderButtonClick(data: any) {
resolveVisibilityScopeMeta(item.visibilityScope).label
}}
</span>
</button>
</div>
</template>
<div class="workflow-scope-panel" @click.stop>
<button
v-for="option in visibilityScopeOptions"
:key="option.value"
type="button"
class="workflow-scope-option"
:class="[
`workflow-scope-option--${option.tone}`,
{
'workflow-scope-option--active':
item.visibilityScope === option.value,
},
]"
:disabled="updatingScopeId === item.id"
@click.stop="updateVisibilityScope(item, option.value)"
>
<span class="workflow-scope-option__leading">
<span class="workflow-scope-option__icon-wrap">
<ElIcon class="workflow-scope-option__icon">
<component :is="option.icon" />
</ElIcon>
</span>
<span class="workflow-scope-option__text">
<span class="workflow-scope-option__label">
{{ option.label }}
</span>
<span class="workflow-scope-option__desc">
{{ option.description }}
</span>
</span>
</span>
<ElIcon
v-if="item.visibilityScope === option.value"
class="workflow-scope-option__check"
>
<Check />
</ElIcon>
</button>
</div>
</ElPopover>
<div
v-else
class="workflow-scope-chip workflow-scope-chip--readonly"
:class="`workflow-scope-chip--${resolveVisibilityScopeMeta(item.visibilityScope).tone}`"
>
<ElIcon class="workflow-scope-chip__icon">
<component
:is="
resolveVisibilityScopeMeta(item.visibilityScope).icon
"
/>
</ElIcon>
<span class="workflow-scope-chip__label">
{{ resolveVisibilityScopeMeta(item.visibilityScope).label }}
</span>
</div>
</AiResourceCornerMeta>
</template>
</CardList>
</template>
@@ -631,18 +724,68 @@ function handleHeaderButtonClick(data: any) {
</template>
<style scoped>
.workflow-publish-chip {
display: inline-flex;
gap: 6px;
align-items: center;
justify-content: center;
min-height: 22px;
min-width: 70px;
padding: 0 9px;
font-size: 11px;
font-weight: 600;
line-height: 1;
border: 1px solid transparent;
border-radius: 999px;
box-shadow: inset 0 1px 0 hsl(var(--card) / 46%);
}
.workflow-publish-chip__dot {
width: 6px;
height: 6px;
background: currentColor;
border-radius: 999px;
opacity: 0.88;
}
.workflow-publish-chip--draft {
color: hsl(var(--muted-foreground));
background: hsl(var(--muted) / 42%);
border-color: hsl(var(--line-subtle));
}
.workflow-publish-chip--pending {
color: hsl(var(--warning));
background: hsl(var(--warning) / 12%);
border-color: hsl(var(--warning) / 14%);
}
.workflow-publish-chip--published {
color: hsl(var(--success));
background: hsl(var(--success) / 12%);
border-color: hsl(var(--success) / 14%);
}
.workflow-publish-chip--danger {
color: hsl(var(--destructive));
background: hsl(var(--destructive) / 10%);
border-color: hsl(var(--destructive) / 14%);
}
.workflow-scope-chip {
display: inline-flex;
gap: 8px;
gap: 6px;
align-items: center;
min-height: 30px;
padding: 0 12px;
font-size: 12px;
justify-content: center;
min-height: 22px;
min-width: 70px;
padding: 0 9px;
font-size: 11px;
font-weight: 600;
line-height: 1;
color: hsl(var(--text-strong));
background: hsl(var(--surface-subtle) / 92%);
border: 1px solid hsl(var(--line-subtle));
background: transparent;
border: 1px solid transparent;
border-radius: 999px;
transition:
border-color 0.18s ease,
@@ -657,8 +800,8 @@ button.workflow-scope-chip {
}
button.workflow-scope-chip:hover {
box-shadow: 0 10px 22px -18px hsl(var(--foreground) / 32%);
transform: translateY(-1px);
background: hsl(var(--card) / 76%);
box-shadow: 0 8px 16px -16px hsl(var(--foreground) / 28%);
}
button.workflow-scope-chip:focus-visible {
@@ -671,7 +814,6 @@ button.workflow-scope-chip:focus-visible {
button.workflow-scope-chip:disabled {
cursor: not-allowed;
opacity: 0.72;
transform: none;
}
.workflow-scope-chip--readonly {
@@ -679,7 +821,7 @@ button.workflow-scope-chip:disabled {
}
.workflow-scope-chip__icon {
font-size: 14px;
font-size: 12px;
}
.workflow-scope-chip__label {
@@ -688,20 +830,20 @@ button.workflow-scope-chip:disabled {
.workflow-scope-chip--private {
color: hsl(var(--primary));
background: hsl(var(--primary) / 9%);
border-color: hsl(var(--primary) / 20%);
background: hsl(var(--primary) / 10%);
border-color: hsl(var(--primary) / 14%);
}
.workflow-scope-chip--dept {
color: hsl(var(--warning));
background: hsl(var(--warning) / 12%);
border-color: hsl(var(--warning) / 20%);
border-color: hsl(var(--warning) / 14%);
}
.workflow-scope-chip--public {
color: hsl(var(--success));
background: hsl(var(--success) / 12%);
border-color: hsl(var(--success) / 20%);
border-color: hsl(var(--success) / 14%);
}
.workflow-scope-panel {