feat: 收敛AI资源发布审批生命周期
- 统一工作流、知识库、聊天助手的发布、重新发布、下线与删除链路 - 收敛审批编排、生命周期状态机与展示态,补齐审批管理和快照预览 - 调整审批管理权限模型为单入口页面加内部按钮权限
This commit is contained in:
@@ -26,7 +26,11 @@ import {
|
||||
} from 'element-plus';
|
||||
import { tryit } from 'radash';
|
||||
|
||||
import { submitBotDeleteApproval, submitBotPublishApproval } from '#/api';
|
||||
import {
|
||||
submitBotDeleteApproval,
|
||||
submitBotOfflineApproval,
|
||||
submitBotPublishApproval,
|
||||
} from '#/api';
|
||||
import { api } from '#/api/request';
|
||||
import defaultAvatar from '#/assets/ai/bot/defaultBotAvatar.png';
|
||||
import HeaderSearch from '#/components/headerSearch/HeaderSearch.vue';
|
||||
@@ -34,9 +38,12 @@ import CardList from '#/components/page/CardList.vue';
|
||||
import PageData from '#/components/page/PageData.vue';
|
||||
import PageSide from '#/components/page/PageSide.vue';
|
||||
import {
|
||||
canAiResourceDelete,
|
||||
canAiResourceOffline,
|
||||
canAiResourcePublish,
|
||||
canAiResourceRepublish,
|
||||
isAiResourceApprovalPending,
|
||||
isAiResourcePublished,
|
||||
normalizeAiPublishStatus,
|
||||
resolveAiResourceDisplayStatus,
|
||||
} from '#/views/ai/shared/publish-status';
|
||||
import { useDictStore } from '#/store';
|
||||
|
||||
@@ -105,35 +112,57 @@ const actions: ActionButton[] = [
|
||||
{
|
||||
icon: Promotion,
|
||||
text: (row: BotInfo) =>
|
||||
isAiResourcePublished(row.publishStatus)
|
||||
canAiResourceRepublish(row.displayPublishStatus, row.publishStatus)
|
||||
? $t('button.republish')
|
||||
: $t('button.submitPublishApproval'),
|
||||
: $t('button.publish'),
|
||||
permission: '/api/v1/bot/save',
|
||||
placement: 'inline',
|
||||
visible: (row: BotInfo) =>
|
||||
canAiResourcePublish(row.displayPublishStatus, row.publishStatus) ||
|
||||
canAiResourceRepublish(row.displayPublishStatus, row.publishStatus),
|
||||
onClick(row: BotInfo) {
|
||||
handleSubmitPublishApproval(row);
|
||||
handlePublishAction(row);
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: Promotion,
|
||||
text: $t('button.offline'),
|
||||
permission: '/api/v1/bot/save',
|
||||
placement: 'menu',
|
||||
visible: (row: BotInfo) => canAiResourceOffline(row.displayPublishStatus, row.publishStatus),
|
||||
onClick(row: BotInfo) {
|
||||
handleOfflineAction(row);
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: Delete,
|
||||
text: $t('button.submitDeleteApproval'),
|
||||
text: $t('button.delete'),
|
||||
tone: 'danger',
|
||||
permission: '/api/v1/bot/remove',
|
||||
placement: 'menu',
|
||||
visible: (row: BotInfo) => canAiResourceDelete(row.displayPublishStatus, row.publishStatus),
|
||||
onClick(row: BotInfo) {
|
||||
handleSubmitDeleteApproval(row);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const handleSubmitPublishApproval = async (bot: BotInfo) => {
|
||||
if (isAiResourceApprovalPending(bot.publishStatus)) {
|
||||
function isRepublishAction(bot: BotInfo) {
|
||||
return canAiResourceRepublish(bot.displayPublishStatus, bot.publishStatus);
|
||||
}
|
||||
|
||||
const handlePublishAction = async (bot: BotInfo) => {
|
||||
if (
|
||||
isAiResourceApprovalPending(bot.displayPublishStatus, bot.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('bot.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
$t('bot.submitPublishApprovalConfirm'),
|
||||
isRepublishAction(bot)
|
||||
? $t('bot.submitRepublishApprovalConfirm')
|
||||
: $t('bot.submitPublishApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
@@ -150,8 +179,36 @@ const handleSubmitPublishApproval = async (bot: BotInfo) => {
|
||||
pageDataRef.value?.reload?.();
|
||||
}
|
||||
};
|
||||
const handleOfflineAction = async (bot: BotInfo) => {
|
||||
if (
|
||||
isAiResourceApprovalPending(bot.displayPublishStatus, bot.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('bot.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
$t('bot.submitOfflineApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
cancelButtonText: $t('button.cancel'),
|
||||
type: 'warning',
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const res = await submitBotOfflineApproval(String(bot.id));
|
||||
if (res.errorCode === 0) {
|
||||
ElMessage.success(res.message || $t('message.saveOkMessage'));
|
||||
pageDataRef.value?.reload?.();
|
||||
}
|
||||
};
|
||||
const handleSubmitDeleteApproval = async (bot: BotInfo) => {
|
||||
if (isAiResourceApprovalPending(bot.publishStatus)) {
|
||||
if (
|
||||
isAiResourceApprovalPending(bot.displayPublishStatus, bot.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('bot.deletePendingHint'));
|
||||
return;
|
||||
}
|
||||
@@ -174,8 +231,11 @@ const handleSubmitDeleteApproval = async (bot: BotInfo) => {
|
||||
pageDataRef.value?.reload?.();
|
||||
}
|
||||
};
|
||||
function resolvePublishStatusMeta(status?: string) {
|
||||
switch (normalizeAiPublishStatus(status)) {
|
||||
function resolvePublishStatusMetaByInstance(
|
||||
displayPublishStatus?: string,
|
||||
publishStatus?: string,
|
||||
) {
|
||||
switch (resolveAiResourceDisplayStatus(displayPublishStatus, publishStatus)) {
|
||||
case 'PUBLISHED':
|
||||
return {
|
||||
label: $t('bot.publishStatusPublished'),
|
||||
@@ -186,6 +246,16 @@ function resolvePublishStatusMeta(status?: string) {
|
||||
label: $t('bot.publishStatusPublishPending'),
|
||||
type: 'warning' as const,
|
||||
};
|
||||
case 'OFFLINE_PENDING':
|
||||
return {
|
||||
label: $t('bot.publishStatusOfflinePending'),
|
||||
type: 'warning' as const,
|
||||
};
|
||||
case 'OFFLINE':
|
||||
return {
|
||||
label: $t('bot.publishStatusOffline'),
|
||||
type: 'info' as const,
|
||||
};
|
||||
case 'DELETE_PENDING':
|
||||
return {
|
||||
label: $t('bot.publishStatusDeletePending'),
|
||||
@@ -378,9 +448,9 @@ const getSideList = async () => {
|
||||
size="small"
|
||||
effect="plain"
|
||||
round
|
||||
:type="resolvePublishStatusMeta(item.publishStatus).type"
|
||||
:type="resolvePublishStatusMetaByInstance(item.displayPublishStatus, item.publishStatus).type"
|
||||
>
|
||||
{{ resolvePublishStatusMeta(item.publishStatus).label }}
|
||||
{{ resolvePublishStatusMetaByInstance(item.displayPublishStatus, item.publishStatus).label }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</CardList>
|
||||
|
||||
@@ -42,6 +42,7 @@ import { tryit } from 'radash';
|
||||
import {
|
||||
getPerQuestions,
|
||||
submitBotDeleteApproval,
|
||||
submitBotOfflineApproval,
|
||||
submitBotPublishApproval,
|
||||
updateBotApi,
|
||||
updateBotOptions,
|
||||
@@ -56,10 +57,13 @@ import CommonSelectDataModal from '#/components/commonSelectModal/CommonSelectDa
|
||||
import DictSelect from '#/components/dict/DictSelect.vue';
|
||||
import UploadAvatar from '#/components/upload/UploadAvatar.vue';
|
||||
import {
|
||||
canAiResourceDelete,
|
||||
canAiResourceOffline,
|
||||
canAiResourcePublish,
|
||||
canAiResourceRepublish,
|
||||
isAiResourceApprovalPending,
|
||||
isAiResourceExternallyVisible,
|
||||
isAiResourcePublished,
|
||||
normalizeAiPublishStatus,
|
||||
resolveAiResourceDisplayStatus,
|
||||
} from '#/views/ai/shared/publish-status';
|
||||
|
||||
interface SelectedMcpTool {
|
||||
@@ -163,18 +167,42 @@ const publicChatUrl = computed(() => {
|
||||
const publicChatEmbedUrl = computed(() => {
|
||||
return buildPublicChatUrl(true);
|
||||
});
|
||||
const botDisplayPublishStatus = computed(() =>
|
||||
resolveAiResourceDisplayStatus(
|
||||
botInfo.value?.displayPublishStatus,
|
||||
botInfo.value?.publishStatus,
|
||||
),
|
||||
);
|
||||
const botApprovalPending = computed(() =>
|
||||
isAiResourceApprovalPending(
|
||||
botInfo.value?.displayPublishStatus,
|
||||
botInfo.value?.publishStatus,
|
||||
),
|
||||
);
|
||||
const publishStatusMeta = computed<{
|
||||
description: string;
|
||||
label: string;
|
||||
type: 'danger' | 'info' | 'success' | 'warning';
|
||||
}>(() => {
|
||||
switch (normalizeAiPublishStatus(botInfo.value?.publishStatus)) {
|
||||
switch (botDisplayPublishStatus.value) {
|
||||
case 'PUBLISHED':
|
||||
return {
|
||||
label: $t('bot.publishStatusPublished'),
|
||||
type: 'success',
|
||||
description: $t('bot.publishStatusPublishedDesc'),
|
||||
};
|
||||
case 'OFFLINE_PENDING':
|
||||
return {
|
||||
label: $t('bot.publishStatusOfflinePending'),
|
||||
type: 'warning',
|
||||
description: $t('bot.publishStatusOfflinePendingDesc'),
|
||||
};
|
||||
case 'OFFLINE':
|
||||
return {
|
||||
label: $t('bot.publishStatusOffline'),
|
||||
type: 'info',
|
||||
description: $t('bot.publishStatusOfflineDesc'),
|
||||
};
|
||||
case 'PUBLISH_PENDING':
|
||||
return {
|
||||
label: $t('bot.publishStatusPublishPending'),
|
||||
@@ -199,9 +227,44 @@ const canUsePublicAccess = computed(() =>
|
||||
isAiResourceExternallyVisible(botInfo.value?.publishStatus),
|
||||
);
|
||||
const publishPrimaryActionLabel = computed(() =>
|
||||
isAiResourcePublished(botInfo.value?.publishStatus)
|
||||
canAiResourceRepublish(
|
||||
botInfo.value?.displayPublishStatus,
|
||||
botInfo.value?.publishStatus,
|
||||
)
|
||||
? $t('button.republish')
|
||||
: $t('button.submitPublishApproval'),
|
||||
: $t('button.publish'),
|
||||
);
|
||||
const canShowPublishPrimaryAction = computed(() =>
|
||||
canAiResourcePublish(
|
||||
botInfo.value?.displayPublishStatus,
|
||||
botInfo.value?.publishStatus,
|
||||
) ||
|
||||
canAiResourceRepublish(
|
||||
botInfo.value?.displayPublishStatus,
|
||||
botInfo.value?.publishStatus,
|
||||
),
|
||||
);
|
||||
const secondaryActionLabel = computed(() => {
|
||||
if (
|
||||
canAiResourceOffline(
|
||||
botInfo.value?.displayPublishStatus,
|
||||
botInfo.value?.publishStatus,
|
||||
)
|
||||
) {
|
||||
return $t('button.offline');
|
||||
}
|
||||
if (
|
||||
canAiResourceDelete(
|
||||
botInfo.value?.displayPublishStatus,
|
||||
botInfo.value?.publishStatus,
|
||||
)
|
||||
) {
|
||||
return $t('button.delete');
|
||||
}
|
||||
return '';
|
||||
});
|
||||
const canShowSecondaryAction = computed(() =>
|
||||
Boolean(secondaryActionLabel.value),
|
||||
);
|
||||
const iframeCode = computed(() => {
|
||||
if (!publicChatEmbedUrl.value) {
|
||||
@@ -820,17 +883,24 @@ const handleDeletePresetQuestion = (item: any) => {
|
||||
const handlePublishWx = () => {
|
||||
publishWxRef.value.openDialog(botId.value, botInfo.value?.options || {});
|
||||
};
|
||||
const handleSubmitPublishApproval = async () => {
|
||||
const handleLifecycleAction = async () => {
|
||||
if (!botInfo.value) {
|
||||
return;
|
||||
}
|
||||
if (isAiResourceApprovalPending(botInfo.value.publishStatus)) {
|
||||
if (
|
||||
botApprovalPending.value
|
||||
) {
|
||||
ElMessage.warning($t('bot.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
$t('bot.submitPublishApprovalConfirm'),
|
||||
canAiResourceRepublish(
|
||||
botInfo.value.displayPublishStatus,
|
||||
botInfo.value.publishStatus,
|
||||
)
|
||||
? $t('bot.submitRepublishApprovalConfirm')
|
||||
: $t('bot.submitPublishApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
@@ -849,17 +919,32 @@ const handleSubmitPublishApproval = async () => {
|
||||
ElMessage.error(res.message || $t('message.saveFailMessage'));
|
||||
}
|
||||
};
|
||||
const handleSubmitDeleteApproval = async () => {
|
||||
const handleSecondaryAction = async () => {
|
||||
if (!botInfo.value) {
|
||||
return;
|
||||
}
|
||||
if (isAiResourceApprovalPending(botInfo.value.publishStatus)) {
|
||||
ElMessage.warning($t('bot.deletePendingHint'));
|
||||
if (
|
||||
botApprovalPending.value
|
||||
) {
|
||||
ElMessage.warning($t('bot.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
const canOffline = canAiResourceOffline(
|
||||
botInfo.value.displayPublishStatus,
|
||||
botInfo.value.publishStatus,
|
||||
);
|
||||
const canDelete = canAiResourceDelete(
|
||||
botInfo.value.displayPublishStatus,
|
||||
botInfo.value.publishStatus,
|
||||
);
|
||||
if (!canOffline && !canDelete) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
$t('bot.submitDeleteApprovalConfirm'),
|
||||
canOffline
|
||||
? $t('bot.submitOfflineApprovalConfirm')
|
||||
: $t('bot.submitDeleteApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
@@ -870,7 +955,9 @@ const handleSubmitDeleteApproval = async () => {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const res = await submitBotDeleteApproval(String(botInfo.value.id));
|
||||
const res = canOffline
|
||||
? await submitBotOfflineApproval(String(botInfo.value.id))
|
||||
: await submitBotDeleteApproval(String(botInfo.value.id));
|
||||
if (res.errorCode === 0) {
|
||||
ElMessage.success(res.message || $t('message.saveOkMessage'));
|
||||
getBotDetail();
|
||||
@@ -1485,19 +1572,21 @@ const handleBasicInfoChange = async (
|
||||
</div>
|
||||
<div class="publish-summary-actions">
|
||||
<ElButton
|
||||
v-if="canShowPublishPrimaryAction"
|
||||
type="primary"
|
||||
:disabled="!hasSavePermission"
|
||||
@click="handleSubmitPublishApproval"
|
||||
@click="handleLifecycleAction"
|
||||
>
|
||||
{{ publishPrimaryActionLabel }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="canShowSecondaryAction"
|
||||
plain
|
||||
type="danger"
|
||||
:type="secondaryActionLabel === $t('button.delete') ? 'danger' : 'default'"
|
||||
:disabled="!hasSavePermission"
|
||||
@click="handleSubmitDeleteApproval"
|
||||
@click="handleSecondaryAction"
|
||||
>
|
||||
{{ $t('button.submitDeleteApproval') }}
|
||||
{{ secondaryActionLabel }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -46,9 +46,16 @@ import PageSide from '#/components/page/PageSide.vue';
|
||||
import DocumentCollectionModal from '#/views/ai/documentCollection/DocumentCollectionModal.vue';
|
||||
import AiResourceCornerMeta from '#/views/ai/shared/AiResourceCornerMeta.vue';
|
||||
import {
|
||||
buildOfflineImpactMessage,
|
||||
type OfflineImpactCheck,
|
||||
} from '#/views/ai/shared/offline-impact';
|
||||
import {
|
||||
canAiResourceDelete,
|
||||
canAiResourceOffline,
|
||||
canAiResourcePublish,
|
||||
canAiResourceRepublish,
|
||||
isAiResourceApprovalPending,
|
||||
isAiResourcePublished,
|
||||
normalizeAiPublishStatus,
|
||||
resolveAiResourceDisplayStatus,
|
||||
} from '#/views/ai/shared/publish-status';
|
||||
|
||||
const router = useRouter();
|
||||
@@ -186,24 +193,41 @@ const actions: ActionButton[] = [
|
||||
{
|
||||
icon: Promotion,
|
||||
text: (row) =>
|
||||
isAiResourcePublished(row.publishStatus)
|
||||
canAiResourceRepublish(row.displayPublishStatus, row.publishStatus)
|
||||
? $t('button.republish')
|
||||
: $t('button.submitPublishApproval'),
|
||||
: $t('button.publish'),
|
||||
permission: '/api/v1/documentCollection/save',
|
||||
placement: 'inline',
|
||||
visible: (row) =>
|
||||
canAiResourcePublish(row.displayPublishStatus, row.publishStatus) ||
|
||||
canAiResourceRepublish(row.displayPublishStatus, row.publishStatus),
|
||||
onClick(row) {
|
||||
if (!ensureManageKnowledgeItem(row)) {
|
||||
return;
|
||||
}
|
||||
submitPublishApproval(row);
|
||||
submitPublishAction(row);
|
||||
},
|
||||
},
|
||||
{
|
||||
text: $t('button.submitDeleteApproval'),
|
||||
icon: Promotion,
|
||||
text: $t('button.offline'),
|
||||
permission: '/api/v1/documentCollection/save',
|
||||
placement: 'menu',
|
||||
visible: (row) => canAiResourceOffline(row.displayPublishStatus, row.publishStatus),
|
||||
onClick(row) {
|
||||
if (!ensureManageKnowledgeItem(row)) {
|
||||
return;
|
||||
}
|
||||
submitOfflineAction(row);
|
||||
},
|
||||
},
|
||||
{
|
||||
text: $t('button.delete'),
|
||||
icon: Delete,
|
||||
tone: 'danger',
|
||||
permission: '/api/v1/documentCollection/remove',
|
||||
placement: 'menu',
|
||||
visible: (row) => canAiResourceDelete(row.displayPublishStatus, row.publishStatus),
|
||||
onClick(row) {
|
||||
if (!ensureManageKnowledgeItem(row)) {
|
||||
return;
|
||||
@@ -216,14 +240,22 @@ const actions: ActionButton[] = [
|
||||
onMounted(() => {
|
||||
getCategoryList();
|
||||
});
|
||||
const submitPublishApproval = async (item: any) => {
|
||||
if (isAiResourceApprovalPending(item.publishStatus)) {
|
||||
function isRepublishAction(item: any) {
|
||||
return canAiResourceRepublish(item.displayPublishStatus, item.publishStatus);
|
||||
}
|
||||
|
||||
const submitPublishAction = async (item: any) => {
|
||||
if (
|
||||
isAiResourceApprovalPending(item.displayPublishStatus, item.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('documentCollection.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
$t('documentCollection.submitPublishApprovalConfirm'),
|
||||
isRepublishAction(item)
|
||||
? $t('documentCollection.submitRepublishApprovalConfirm')
|
||||
: $t('documentCollection.submitPublishApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
@@ -245,8 +277,71 @@ const submitPublishApproval = async (item: any) => {
|
||||
reloadKnowledgeList();
|
||||
}
|
||||
};
|
||||
const submitOfflineAction = async (item: any) => {
|
||||
if (
|
||||
isAiResourceApprovalPending(item.displayPublishStatus, item.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('documentCollection.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
const impactRes = await api.get<{
|
||||
data: OfflineImpactCheck;
|
||||
errorCode: number;
|
||||
}>(
|
||||
'/api/v1/documentCollection/offlineImpactCheck',
|
||||
{
|
||||
params: { id: item.id },
|
||||
},
|
||||
);
|
||||
if (impactRes.errorCode !== 0) {
|
||||
return;
|
||||
}
|
||||
if (impactRes.data?.hasWorkflowUsages) {
|
||||
await ElMessageBox.alert(
|
||||
buildOfflineImpactMessage(
|
||||
$t('documentCollection.offlineImpactWorkflowBlockedIntro'),
|
||||
impactRes.data.workflowUsages,
|
||||
$t('documentCollection.offlineImpactWorkflowBlockedFooter'),
|
||||
),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
type: 'warning',
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
impactRes.data?.hasBotBindings
|
||||
? buildOfflineImpactMessage(
|
||||
$t('documentCollection.offlineImpactBoundBotsIntro'),
|
||||
impactRes.data.botBindings,
|
||||
$t('documentCollection.offlineImpactBoundBotsFooter'),
|
||||
)
|
||||
: $t('documentCollection.submitOfflineApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
cancelButtonText: $t('button.cancel'),
|
||||
type: 'warning',
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const res = await api.post('/api/v1/documentCollection/submitOfflineApproval', {
|
||||
id: item.id,
|
||||
});
|
||||
if (res.errorCode === 0) {
|
||||
ElMessage.success(res.message || $t('message.saveOkMessage'));
|
||||
reloadKnowledgeList();
|
||||
}
|
||||
};
|
||||
const submitDeleteApproval = async (item: any) => {
|
||||
if (isAiResourceApprovalPending(item.publishStatus)) {
|
||||
if (
|
||||
isAiResourceApprovalPending(item.displayPublishStatus, item.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('documentCollection.deletePendingHint'));
|
||||
return;
|
||||
}
|
||||
@@ -274,14 +369,29 @@ const submitDeleteApproval = async (item: any) => {
|
||||
reloadKnowledgeList();
|
||||
}
|
||||
};
|
||||
function resolvePublishStatusMeta(status?: string) {
|
||||
switch (normalizeAiPublishStatus(status)) {
|
||||
function resolvePublishStatusMeta(
|
||||
displayPublishStatus?: string,
|
||||
publishStatus?: string,
|
||||
) {
|
||||
switch (resolveAiResourceDisplayStatus(displayPublishStatus, publishStatus)) {
|
||||
case 'DELETE_PENDING': {
|
||||
return {
|
||||
label: $t('documentCollection.publishStatusDeletePending'),
|
||||
tone: 'danger',
|
||||
};
|
||||
}
|
||||
case 'OFFLINE_PENDING': {
|
||||
return {
|
||||
label: $t('documentCollection.publishStatusOfflinePending'),
|
||||
tone: 'pending',
|
||||
};
|
||||
}
|
||||
case 'OFFLINE': {
|
||||
return {
|
||||
label: $t('documentCollection.publishStatusOffline'),
|
||||
tone: 'draft',
|
||||
};
|
||||
}
|
||||
case 'PUBLISH_PENDING': {
|
||||
return {
|
||||
label: $t('documentCollection.publishStatusPublishPending'),
|
||||
@@ -553,11 +663,11 @@ function changeCategory(category: any) {
|
||||
<template #publish>
|
||||
<div
|
||||
class="knowledge-publish-chip"
|
||||
:class="`knowledge-publish-chip--${resolvePublishStatusMeta(item.publishStatus).tone}`"
|
||||
:class="`knowledge-publish-chip--${resolvePublishStatusMeta(item.displayPublishStatus, item.publishStatus).tone}`"
|
||||
>
|
||||
<span class="knowledge-publish-chip__dot"></span>
|
||||
<span>{{
|
||||
resolvePublishStatusMeta(item.publishStatus).label
|
||||
resolvePublishStatusMeta(item.displayPublishStatus, item.publishStatus).label
|
||||
}}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,22 +1,87 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { EasyFlowPanelModal } from '@easyflow/common-ui';
|
||||
|
||||
import { ElImage } from 'element-plus';
|
||||
import { ElButton, ElEmpty, ElImage, ElScrollbar } from 'element-plus';
|
||||
|
||||
import { api } from '#/api/request';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
const dialogVisible = ref(false);
|
||||
const data = ref<any>();
|
||||
function openDialog(row: any) {
|
||||
const docPreviewLoading = ref(false);
|
||||
const docPreviewContent = ref('');
|
||||
const docPreviewTruncated = ref(false);
|
||||
const docPreviewError = ref('');
|
||||
let previewRequestId = 0;
|
||||
|
||||
const isDocument = computed(() => data.value?.resourceType === 3);
|
||||
const fileName = computed(() => {
|
||||
const resourceName = data.value?.resourceName || '';
|
||||
const suffix = data.value?.suffix || '';
|
||||
return suffix ? `${resourceName}.${suffix}` : resourceName;
|
||||
});
|
||||
const previewWidth = computed(() => (isDocument.value ? 'xl' : 'md'));
|
||||
|
||||
async function openDialog(row: any) {
|
||||
data.value = row;
|
||||
dialogVisible.value = true;
|
||||
resetDocumentPreview();
|
||||
if (row?.resourceType === 3) {
|
||||
await loadDocumentPreview(row);
|
||||
}
|
||||
}
|
||||
function closeDialog() {
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
|
||||
function resetDocumentPreview() {
|
||||
docPreviewLoading.value = false;
|
||||
docPreviewContent.value = '';
|
||||
docPreviewTruncated.value = false;
|
||||
docPreviewError.value = '';
|
||||
}
|
||||
|
||||
async function loadDocumentPreview(row: any) {
|
||||
if (!row?.id) {
|
||||
docPreviewError.value = '当前素材缺少预览标识,请下载后查看';
|
||||
return;
|
||||
}
|
||||
const currentRequestId = ++previewRequestId;
|
||||
docPreviewLoading.value = true;
|
||||
try {
|
||||
const res = await api.get('/api/v1/resource/previewContent', {
|
||||
params: { id: row.id },
|
||||
});
|
||||
if (currentRequestId !== previewRequestId) {
|
||||
return;
|
||||
}
|
||||
docPreviewContent.value = res.data?.content || '';
|
||||
docPreviewTruncated.value = !!res.data?.truncated;
|
||||
if (!docPreviewContent.value) {
|
||||
docPreviewError.value = '暂未提取到可预览内容,请下载后查看';
|
||||
}
|
||||
} catch {
|
||||
if (currentRequestId !== previewRequestId) {
|
||||
return;
|
||||
}
|
||||
docPreviewError.value = '文档预览加载失败,请下载后查看';
|
||||
} finally {
|
||||
if (currentRequestId === previewRequestId) {
|
||||
docPreviewLoading.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openSourceFile() {
|
||||
if (data.value?.resourceUrl) {
|
||||
window.open(data.value.resourceUrl, '_blank');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -24,25 +89,119 @@ function closeDialog() {
|
||||
v-model:open="dialogVisible"
|
||||
:title="$t('message.preview')"
|
||||
:before-close="closeDialog"
|
||||
width="md"
|
||||
:width="previewWidth"
|
||||
:show-footer="false"
|
||||
>
|
||||
<div class="flex justify-center">
|
||||
<div class="resource-preview flex justify-center">
|
||||
<ElImage
|
||||
v-if="data.resourceType === 0"
|
||||
style="width: 200px"
|
||||
:preview-src-list="[data.resourceUrl]"
|
||||
:src="data.resourceUrl"
|
||||
/>
|
||||
<video v-if="data.resourceType === 1" controls width="640" height="360">
|
||||
<video
|
||||
v-else-if="data.resourceType === 1"
|
||||
controls
|
||||
width="640"
|
||||
height="360"
|
||||
>
|
||||
<source :src="data.resourceUrl" type="video/mp4" />
|
||||
{{ $t('message.notVideo') }}
|
||||
</video>
|
||||
<audio v-if="data.resourceType === 2" controls :src="data.resourceUrl">
|
||||
<audio
|
||||
v-else-if="data.resourceType === 2"
|
||||
controls
|
||||
class="mt-8 w-full max-w-[640px]"
|
||||
:src="data.resourceUrl"
|
||||
>
|
||||
{{ $t('message.notAudio') }}
|
||||
</audio>
|
||||
<div
|
||||
v-else-if="isDocument"
|
||||
v-loading="docPreviewLoading"
|
||||
:element-loading-text="$t('message.loading')"
|
||||
class="resource-preview__document bg-background border-border w-full rounded-xl border"
|
||||
>
|
||||
<div
|
||||
class="resource-preview__toolbar border-border flex items-center justify-between gap-3 border-b px-5 py-4"
|
||||
>
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-medium">{{ fileName }}</div>
|
||||
<div
|
||||
v-if="docPreviewTruncated"
|
||||
class="text-muted-foreground mt-1 text-xs"
|
||||
>
|
||||
内容较长,当前仅展示前 20000 个字符
|
||||
</div>
|
||||
</div>
|
||||
<ElButton link type="primary" @click="openSourceFile">
|
||||
{{ $t('button.download') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="resource-preview__body">
|
||||
<ElEmpty
|
||||
v-if="docPreviewError"
|
||||
:description="docPreviewError"
|
||||
class="resource-preview__empty"
|
||||
>
|
||||
<ElButton link type="primary" @click="openSourceFile">
|
||||
{{ $t('button.download') }}
|
||||
</ElButton>
|
||||
</ElEmpty>
|
||||
<ElScrollbar
|
||||
v-else
|
||||
class="resource-preview__scrollbar"
|
||||
wrap-class="resource-preview__scrollbar-wrap"
|
||||
>
|
||||
<pre class="resource-preview__content">{{
|
||||
docPreviewContent
|
||||
}}</pre>
|
||||
</ElScrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</EasyFlowPanelModal>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
<style scoped>
|
||||
.resource-preview {
|
||||
min-height: 220px;
|
||||
}
|
||||
|
||||
.resource-preview__document {
|
||||
min-height: 540px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.resource-preview__toolbar {
|
||||
min-height: 72px;
|
||||
}
|
||||
|
||||
.resource-preview__body {
|
||||
height: 468px;
|
||||
}
|
||||
|
||||
.resource-preview__scrollbar {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
:deep(.resource-preview__scrollbar-wrap) {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.resource-preview__content {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-family:
|
||||
'SFMono-Regular', 'JetBrains Mono', 'Fira Code', Consolas, 'Liberation Mono',
|
||||
monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.75;
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
|
||||
.resource-preview__empty {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
38
easyflow-ui-admin/app/src/views/ai/shared/offline-impact.ts
Normal file
38
easyflow-ui-admin/app/src/views/ai/shared/offline-impact.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { h } from 'vue';
|
||||
|
||||
export interface OfflineImpactBinding {
|
||||
id?: number | string;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export interface OfflineImpactCheck {
|
||||
canProceed: boolean;
|
||||
hasBotBindings: boolean;
|
||||
hasWorkflowUsages: boolean;
|
||||
botBindings: OfflineImpactBinding[];
|
||||
workflowUsages: OfflineImpactBinding[];
|
||||
message?: string;
|
||||
}
|
||||
|
||||
function resolveTitle(item: OfflineImpactBinding) {
|
||||
return item.title || String(item.id || '');
|
||||
}
|
||||
|
||||
export function joinOfflineImpactTitles(items: OfflineImpactBinding[] = []) {
|
||||
return items.map(resolveTitle).filter(Boolean).join('、');
|
||||
}
|
||||
|
||||
export function buildOfflineImpactMessage(
|
||||
intro: string,
|
||||
items: OfflineImpactBinding[] = [],
|
||||
footer?: string,
|
||||
) {
|
||||
return h('div', [
|
||||
h('p', intro),
|
||||
h(
|
||||
'ul',
|
||||
items.map((item) => h('li', { key: String(item.id || item.title || '') }, resolveTitle(item))),
|
||||
),
|
||||
footer ? h('p', footer) : null,
|
||||
]);
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
export type AiPublishStatus =
|
||||
| 'DELETE_PENDING'
|
||||
| 'DRAFT'
|
||||
| 'OFFLINE'
|
||||
| 'OFFLINE_PENDING'
|
||||
| 'PUBLISHED'
|
||||
| 'PUBLISH_PENDING';
|
||||
|
||||
@@ -13,6 +15,8 @@ export function normalizeAiPublishStatus(
|
||||
switch (value) {
|
||||
case 'PUBLISHED':
|
||||
case 'PUBLISH_PENDING':
|
||||
case 'OFFLINE':
|
||||
case 'OFFLINE_PENDING':
|
||||
case 'DELETE_PENDING':
|
||||
return value;
|
||||
default:
|
||||
@@ -20,6 +24,17 @@ export function normalizeAiPublishStatus(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析用于页面展示的发布状态。
|
||||
* 已发布资源若存在当前审批实例,则视为“发布审批中”,用于统一状态文案与动作禁用。
|
||||
*/
|
||||
export function resolveAiResourceDisplayStatus(
|
||||
displayValue?: null | string,
|
||||
_fallbackValue?: null | string,
|
||||
): AiPublishStatus {
|
||||
return normalizeAiPublishStatus(displayValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前资源是否已有正式线上版本。
|
||||
*/
|
||||
@@ -27,12 +42,23 @@ export function isAiResourcePublished(value?: null | string) {
|
||||
return normalizeAiPublishStatus(value) === 'PUBLISHED';
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前资源是否处于已下线状态。
|
||||
*/
|
||||
export function isAiResourceOffline(value?: null | string) {
|
||||
return normalizeAiPublishStatus(value) === 'OFFLINE';
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前资源是否允许对外可见。
|
||||
*/
|
||||
export function isAiResourceExternallyVisible(value?: null | string) {
|
||||
const normalized = normalizeAiPublishStatus(value);
|
||||
return normalized === 'PUBLISHED' || normalized === 'DELETE_PENDING';
|
||||
return (
|
||||
normalized === 'PUBLISHED' ||
|
||||
normalized === 'DELETE_PENDING' ||
|
||||
normalized === 'OFFLINE_PENDING'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +71,68 @@ export function isAiResourceSelectableForBot(value?: null | string) {
|
||||
/**
|
||||
* 当前资源是否处于审批处理中。
|
||||
*/
|
||||
export function isAiResourceApprovalPending(value?: null | string) {
|
||||
const normalized = normalizeAiPublishStatus(value);
|
||||
return normalized === 'PUBLISH_PENDING' || normalized === 'DELETE_PENDING';
|
||||
export function isAiResourceApprovalPending(
|
||||
displayValue?: null | string,
|
||||
_fallbackValue?: null | string,
|
||||
) {
|
||||
const normalized = resolveAiResourceDisplayStatus(displayValue);
|
||||
return (
|
||||
normalized === 'PUBLISH_PENDING' ||
|
||||
normalized === 'OFFLINE_PENDING' ||
|
||||
normalized === 'DELETE_PENDING'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前资源是否允许发起发布。
|
||||
*/
|
||||
export function canAiResourcePublish(
|
||||
displayValue?: null | string,
|
||||
_fallbackValue?: null | string,
|
||||
) {
|
||||
if (isAiResourceApprovalPending(displayValue)) {
|
||||
return false;
|
||||
}
|
||||
const normalized = resolveAiResourceDisplayStatus(displayValue);
|
||||
return normalized === 'DRAFT' || normalized === 'OFFLINE';
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前资源是否允许重新发布。
|
||||
*/
|
||||
export function canAiResourceRepublish(
|
||||
displayValue?: null | string,
|
||||
_fallbackValue?: null | string,
|
||||
) {
|
||||
if (isAiResourceApprovalPending(displayValue)) {
|
||||
return false;
|
||||
}
|
||||
return resolveAiResourceDisplayStatus(displayValue) === 'PUBLISHED';
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前资源是否允许发起下线。
|
||||
*/
|
||||
export function canAiResourceOffline(
|
||||
displayValue?: null | string,
|
||||
_fallbackValue?: null | string,
|
||||
) {
|
||||
if (isAiResourceApprovalPending(displayValue)) {
|
||||
return false;
|
||||
}
|
||||
return resolveAiResourceDisplayStatus(displayValue) === 'PUBLISHED';
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前资源是否允许发起删除。
|
||||
*/
|
||||
export function canAiResourceDelete(
|
||||
displayValue?: null | string,
|
||||
_fallbackValue?: null | string,
|
||||
) {
|
||||
if (isAiResourceApprovalPending(displayValue)) {
|
||||
return false;
|
||||
}
|
||||
const normalized = resolveAiResourceDisplayStatus(displayValue);
|
||||
return normalized === 'DRAFT' || normalized === 'OFFLINE';
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ import { $t } from '#/locales';
|
||||
import { router } from '#/router';
|
||||
import { getIconByValue } from '#/views/ai/model/modelUtils/defaultIcon';
|
||||
import {
|
||||
canAiResourceRepublish,
|
||||
isAiResourceApprovalPending,
|
||||
normalizeAiPublishStatus,
|
||||
resolveAiResourceDisplayStatus,
|
||||
} from '#/views/ai/shared/publish-status';
|
||||
import ExecResult from '#/views/ai/workflow/components/ExecResult.vue';
|
||||
import SingleRun from '#/views/ai/workflow/components/SingleRun.vue';
|
||||
@@ -251,18 +252,26 @@ const updatePluginNode = ref<any>(null);
|
||||
const pageLoading = ref(false);
|
||||
const chainInfo = ref<any>(null);
|
||||
const publishActionText = computed(() => {
|
||||
switch (normalizeAiPublishStatus(workflowInfo.value?.publishStatus)) {
|
||||
switch (
|
||||
resolveAiResourceDisplayStatus(
|
||||
workflowInfo.value?.displayPublishStatus,
|
||||
workflowInfo.value?.publishStatus,
|
||||
)
|
||||
) {
|
||||
case 'DELETE_PENDING': {
|
||||
return $t('aiWorkflow.publishStatusDeletePending');
|
||||
}
|
||||
case 'OFFLINE_PENDING': {
|
||||
return $t('aiWorkflow.publishStatusOfflinePending');
|
||||
}
|
||||
case 'PUBLISH_PENDING': {
|
||||
return $t('aiWorkflow.publishStatusPublishPending');
|
||||
}
|
||||
case 'PUBLISHED': {
|
||||
return `${$t('aiWorkflow.publishStatusPublished')} · ${$t('button.republish')}`;
|
||||
return $t('button.republish');
|
||||
}
|
||||
default: {
|
||||
return `${$t('aiWorkflow.publishStatusDraft')} · ${$t('button.submitPublishApproval')}`;
|
||||
return $t('button.publish');
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -272,7 +281,10 @@ const publishActionDisabled = computed(
|
||||
saveLoading.value ||
|
||||
checkLoading.value ||
|
||||
publishLoading.value ||
|
||||
isAiResourceApprovalPending(workflowInfo.value?.publishStatus),
|
||||
isAiResourceApprovalPending(
|
||||
workflowInfo.value?.displayPublishStatus,
|
||||
workflowInfo.value?.publishStatus,
|
||||
),
|
||||
);
|
||||
|
||||
function syncNavTitle(title: string) {
|
||||
@@ -498,17 +510,27 @@ function closeCheckIssues() {
|
||||
async function handleCheck() {
|
||||
await runCheck('PRE_EXECUTE');
|
||||
}
|
||||
async function handlePublish() {
|
||||
async function handlePublishAction() {
|
||||
if (publishLoading.value) {
|
||||
return;
|
||||
}
|
||||
if (isAiResourceApprovalPending(workflowInfo.value?.publishStatus)) {
|
||||
if (
|
||||
isAiResourceApprovalPending(
|
||||
workflowInfo.value?.displayPublishStatus,
|
||||
workflowInfo.value?.publishStatus,
|
||||
)
|
||||
) {
|
||||
ElMessage.warning($t('aiWorkflow.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
$t('aiWorkflow.submitPublishApprovalConfirm'),
|
||||
canAiResourceRepublish(
|
||||
workflowInfo.value?.displayPublishStatus,
|
||||
workflowInfo.value?.publishStatus,
|
||||
)
|
||||
? $t('aiWorkflow.submitRepublishApprovalConfirm')
|
||||
: $t('aiWorkflow.submitPublishApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
@@ -680,8 +702,8 @@ function onAsyncExecute(info: any) {
|
||||
:loading="publishLoading"
|
||||
:disabled="publishActionDisabled"
|
||||
class="workflow-publish-button"
|
||||
:class="`workflow-publish-button--${normalizeAiPublishStatus(workflowInfo?.publishStatus)}`"
|
||||
@click="handlePublish"
|
||||
:class="`workflow-publish-button--${resolveAiResourceDisplayStatus(workflowInfo?.displayPublishStatus, workflowInfo?.publishStatus)}`"
|
||||
@click="handlePublishAction"
|
||||
>
|
||||
{{ publishActionText }}
|
||||
</ElButton>
|
||||
@@ -809,12 +831,24 @@ function onAsyncExecute(info: any) {
|
||||
border-color: hsl(var(--warning) / 24%);
|
||||
}
|
||||
|
||||
:deep(.workflow-publish-button--OFFLINE_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--OFFLINE.el-button) {
|
||||
color: hsl(var(--foreground) / 78%);
|
||||
background: hsl(var(--muted) / 62%);
|
||||
border-color: hsl(var(--foreground) / 14%);
|
||||
}
|
||||
|
||||
:deep(.workflow-publish-button--DELETE_PENDING.el-button) {
|
||||
color: hsl(var(--destructive));
|
||||
background: hsl(var(--destructive) / 16%);
|
||||
|
||||
@@ -50,9 +50,16 @@ import { router } from '#/router';
|
||||
import { useDictStore } from '#/store';
|
||||
import AiResourceCornerMeta from '#/views/ai/shared/AiResourceCornerMeta.vue';
|
||||
import {
|
||||
buildOfflineImpactMessage,
|
||||
type OfflineImpactCheck,
|
||||
} from '#/views/ai/shared/offline-impact';
|
||||
import {
|
||||
canAiResourceDelete,
|
||||
canAiResourceOffline,
|
||||
canAiResourcePublish,
|
||||
canAiResourceRepublish,
|
||||
isAiResourceApprovalPending,
|
||||
isAiResourcePublished,
|
||||
normalizeAiPublishStatus,
|
||||
resolveAiResourceDisplayStatus,
|
||||
} from '#/views/ai/shared/publish-status';
|
||||
|
||||
import WorkflowModal from './WorkflowModal.vue';
|
||||
@@ -175,21 +182,35 @@ const actions: ActionButton[] = [
|
||||
{
|
||||
icon: Promotion,
|
||||
text: (row: any) =>
|
||||
isAiResourcePublished(row.publishStatus)
|
||||
canAiResourceRepublish(row.displayPublishStatus, row.publishStatus)
|
||||
? $t('button.republish')
|
||||
: $t('button.submitPublishApproval'),
|
||||
: $t('button.publish'),
|
||||
permission: '/api/v1/workflow/save',
|
||||
placement: 'inline',
|
||||
visible: (row: any) =>
|
||||
canAiResourcePublish(row.displayPublishStatus, row.publishStatus) ||
|
||||
canAiResourceRepublish(row.displayPublishStatus, row.publishStatus),
|
||||
onClick: (row: any) => {
|
||||
submitPublishApproval(row);
|
||||
submitPublishAction(row);
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: Promotion,
|
||||
text: $t('button.offline'),
|
||||
permission: '/api/v1/workflow/save',
|
||||
placement: 'menu',
|
||||
visible: (row: any) => canAiResourceOffline(row.displayPublishStatus, row.publishStatus),
|
||||
onClick: (row: any) => {
|
||||
submitOfflineAction(row);
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: Delete,
|
||||
text: $t('button.submitDeleteApproval'),
|
||||
text: $t('button.delete'),
|
||||
tone: 'danger',
|
||||
permission: '/api/v1/workflow/remove',
|
||||
placement: 'menu',
|
||||
visible: (row: any) => canAiResourceDelete(row.displayPublishStatus, row.publishStatus),
|
||||
onClick: (row: any) => {
|
||||
submitDeleteApproval(row);
|
||||
},
|
||||
@@ -282,14 +303,22 @@ function showDialog(row: any, importMode = false) {
|
||||
function resolveNavTitle(row: any) {
|
||||
return row?.title || row?.name || '';
|
||||
}
|
||||
async function submitPublishApproval(row: any) {
|
||||
if (isAiResourceApprovalPending(row.publishStatus)) {
|
||||
function isRepublishAction(row: any) {
|
||||
return canAiResourceRepublish(row.displayPublishStatus, row.publishStatus);
|
||||
}
|
||||
|
||||
async function submitPublishAction(row: any) {
|
||||
if (
|
||||
isAiResourceApprovalPending(row.displayPublishStatus, row.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('aiWorkflow.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
$t('aiWorkflow.submitPublishApprovalConfirm'),
|
||||
isRepublishAction(row)
|
||||
? $t('aiWorkflow.submitRepublishApprovalConfirm')
|
||||
: $t('aiWorkflow.submitPublishApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
@@ -300,7 +329,56 @@ async function submitPublishApproval(row: any) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const res = await api.post('/api/v1/workflow/submitPublishApproval', {
|
||||
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 submitOfflineAction(row: any) {
|
||||
if (
|
||||
isAiResourceApprovalPending(row.displayPublishStatus, row.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('aiWorkflow.publishPendingHint'));
|
||||
return;
|
||||
}
|
||||
const impactRes = await api.get<{
|
||||
data: OfflineImpactCheck;
|
||||
errorCode: number;
|
||||
}>(
|
||||
'/api/v1/workflow/offlineImpactCheck',
|
||||
{
|
||||
params: { id: row.id },
|
||||
},
|
||||
);
|
||||
if (impactRes.errorCode !== 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
impactRes.data?.hasBotBindings
|
||||
? buildOfflineImpactMessage(
|
||||
$t('aiWorkflow.offlineImpactBoundBotsIntro'),
|
||||
impactRes.data.botBindings,
|
||||
$t('aiWorkflow.offlineImpactBoundBotsFooter'),
|
||||
)
|
||||
: $t('aiWorkflow.submitOfflineApprovalConfirm'),
|
||||
$t('message.noticeTitle'),
|
||||
{
|
||||
confirmButtonText: $t('button.confirm'),
|
||||
cancelButtonText: $t('button.cancel'),
|
||||
type: 'warning',
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const res = await api.post('/api/v1/workflow/submitOfflineApproval', {
|
||||
id: row.id,
|
||||
});
|
||||
if (res.errorCode === 0) {
|
||||
@@ -309,7 +387,9 @@ async function submitPublishApproval(row: any) {
|
||||
}
|
||||
}
|
||||
async function submitDeleteApproval(row: any) {
|
||||
if (isAiResourceApprovalPending(row.publishStatus)) {
|
||||
if (
|
||||
isAiResourceApprovalPending(row.displayPublishStatus, row.publishStatus)
|
||||
) {
|
||||
ElMessage.warning($t('aiWorkflow.deletePendingHint'));
|
||||
return;
|
||||
}
|
||||
@@ -334,14 +414,29 @@ async function submitDeleteApproval(row: any) {
|
||||
pageDataRef.value?.reload?.();
|
||||
}
|
||||
}
|
||||
function resolvePublishStatusMeta(status?: string) {
|
||||
switch (normalizeAiPublishStatus(status)) {
|
||||
function resolvePublishStatusMetaByInstance(
|
||||
displayPublishStatus?: string,
|
||||
publishStatus?: string,
|
||||
) {
|
||||
switch (resolveAiResourceDisplayStatus(displayPublishStatus, publishStatus)) {
|
||||
case 'DELETE_PENDING': {
|
||||
return {
|
||||
label: $t('aiWorkflow.publishStatusDeletePending'),
|
||||
tone: 'danger',
|
||||
};
|
||||
}
|
||||
case 'OFFLINE_PENDING': {
|
||||
return {
|
||||
label: $t('aiWorkflow.publishStatusOfflinePending'),
|
||||
tone: 'pending',
|
||||
};
|
||||
}
|
||||
case 'OFFLINE': {
|
||||
return {
|
||||
label: $t('aiWorkflow.publishStatusOffline'),
|
||||
tone: 'draft',
|
||||
};
|
||||
}
|
||||
case 'PUBLISH_PENDING': {
|
||||
return {
|
||||
label: $t('aiWorkflow.publishStatusPublishPending'),
|
||||
@@ -572,11 +667,11 @@ function handleHeaderButtonClick(data: any) {
|
||||
<template #publish>
|
||||
<div
|
||||
class="workflow-publish-chip"
|
||||
:class="`workflow-publish-chip--${resolvePublishStatusMeta(item.publishStatus).tone}`"
|
||||
:class="`workflow-publish-chip--${resolvePublishStatusMetaByInstance(item.displayPublishStatus, item.publishStatus).tone}`"
|
||||
>
|
||||
<span class="workflow-publish-chip__dot"></span>
|
||||
<span>{{
|
||||
resolvePublishStatusMeta(item.publishStatus).label
|
||||
resolvePublishStatusMetaByInstance(item.displayPublishStatus, item.publishStatus).label
|
||||
}}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user