feat: 价格审批失败态支持重新提交与重试执行
Some checks failed
Build and Deploy Front / deploy (push) Failing after 7s

卖价页展示驳回/撤回/执行失败徽章与操作入口,抽屉可重试业务执行。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zzh 2026-11-09 09:35:46 +08:00
parent 77642cdc94
commit 63d8d25f51
6 changed files with 183 additions and 23 deletions

View File

@ -216,12 +216,16 @@ export async function getSalesProductPublishSyncStatus(params: {
onlineContentHash?: string | null
approvalPending?: boolean
ApprovalPending?: boolean
approvalFailed?: boolean
ApprovalFailed?: boolean
approvalInstanceId?: number | null
ApprovalInstanceId?: number | null
approvalInstanceNo?: string | null
ApprovalInstanceNo?: string | null
approvalStatusName?: string | null
ApprovalStatusName?: string | null
approvalComment?: string | null
ApprovalComment?: string | null
}>(res.data)
}

View File

@ -290,6 +290,16 @@ export async function withdrawApproval(body: {
}
}
/** 终审后业务执行失败 / 历史空跑:重试 Handler(落发布、入账等) */
export async function retryApprovalExecute(id: number) {
try {
const res = await axiosInstance.post(omsUrl('/system/approval/engine/retry-execute'), { id })
assertBusinessOk(res.data)
} catch (e) {
throw new Error(extractOmsRequestError(e))
}
}
export async function simulateApprovalSubmit(body: {
operationCode?: string
bizKey?: string

View File

@ -164,6 +164,15 @@
<a-button v-if="detail?.canWithdraw" @click="doWithdraw">
{{ t('system.approval.inbox.withdraw') }}
</a-button>
<a-button
v-if="canRetryExecute"
type="primary"
class="app-btn-primary-soft"
:loading="actionLoading"
@click="doRetryExecute"
>
{{ t('system.approval.inbox.retryExecute') }}
</a-button>
<a-button
v-if="detail?.canApprove && hasPermission('System.ApprovalTask.Approve')"
type="primary"
@ -215,6 +224,7 @@ import {
approveApproval,
getApprovalDetail,
rejectApproval,
retryApprovalExecute,
withdrawApproval,
type ApprovalInstanceDto,
} from '@/api/system/approval'
@ -242,6 +252,16 @@ const previewImageUrl = ref('')
const PRICE_OP = 'Channel.SalesProduct.PublishPrice'
const RECHARGE_OP = 'Finance.Recharge.Credit'
/** 6=Executed 7=ExecuteFailed:可重试 Handler 落业务 */
const canRetryExecute = computed(() => {
const status = detail.value?.status
if (status !== 6 && status !== 7) return false
return (
hasPermission('System.ApprovalTask.Approve') ||
hasPermission('System.ApprovalDefinition.Enable')
)
})
const showFooter = computed(
() =>
!!(
@ -249,7 +269,8 @@ const showFooter = computed(
((detail.value.canApprove &&
(hasPermission('System.ApprovalTask.Approve') ||
hasPermission('System.ApprovalTask.Reject'))) ||
detail.value.canWithdraw)
detail.value.canWithdraw ||
canRetryExecute.value)
),
)
@ -604,6 +625,29 @@ async function doApprove() {
})
}
function doRetryExecute() {
const row = detail.value
if (!row?.id) return
Modal.warning({
title: t('system.approval.inbox.retryExecute'),
content: t('system.approval.inbox.retryExecuteConfirm', { no: row.instanceNo }),
hideCancel: false,
onOk: async () => {
actionLoading.value = true
try {
await retryApprovalExecute(row.id)
Message.success(t('common.success'))
emit('changed')
await loadDetail(row.id)
} catch (e: unknown) {
Message.error((e as Error)?.message || t('common.failed'))
} finally {
actionLoading.value = false
}
},
})
}
function openReject() {
rejectComment.value = ''
rejectVisible.value = true

View File

@ -1501,6 +1501,9 @@ export default {
'system.approval.inbox.approve': 'Approve',
'system.approval.inbox.reject': 'Reject',
'system.approval.inbox.withdraw': 'Withdraw',
'system.approval.inbox.retryExecute': 'Retry business execute',
'system.approval.inbox.retryExecuteConfirm':
'Retry execute for {no}? This re-runs the frozen payload (e.g. price publish).',
'system.approval.inbox.payload': 'Payload',
'system.approval.inbox.basicInfo': 'Basics',
'system.approval.inbox.bizSummary': 'Business content',
@ -5422,6 +5425,8 @@ export default {
'channel.salesProducts.actions.publishRules': 'Publish rules',
'channel.salesProducts.actions.publishPrice': 'Publish prices',
'channel.salesProducts.actions.viewPriceApproval': 'View approval',
'channel.salesProducts.actions.resubmitPriceApproval': 'Resubmit approval',
'channel.salesProducts.actions.retryPriceApprovalExecute': 'Retry business execute',
'channel.salesProducts.actions.add': 'Add',
'channel.salesProducts.actions.edit': 'Edit',
'channel.salesProducts.actions.delete': 'Delete',
@ -5516,6 +5521,7 @@ export default {
'channel.salesProducts.publish.legend.same': 'Unchanged',
'channel.salesProducts.publish.badge.pending': 'Pending publish',
'channel.salesProducts.publish.badge.pendingApproval': 'Pending approval',
'channel.salesProducts.publish.badge.failed': 'Approval failed',
'channel.salesProducts.publish.badge.synced': 'Published',
'channel.salesProducts.publish.badge.checking': 'Checking…',
'channel.salesProducts.publish.approvalNo': 'Approval No. {no}',

View File

@ -1492,6 +1492,8 @@ export default {
'system.approval.inbox.approve': '通过',
'system.approval.inbox.reject': '驳回',
'system.approval.inbox.withdraw': '撤回',
'system.approval.inbox.retryExecute': '重试业务执行',
'system.approval.inbox.retryExecuteConfirm': '确认重试执行审批单 {no}?将按冻结载荷重新落业务(如价格发布)。',
'system.approval.inbox.payload': '业务载荷',
'system.approval.inbox.basicInfo': '基本信息',
'system.approval.inbox.bizSummary': '业务内容',
@ -5445,6 +5447,8 @@ export default {
'channel.salesProducts.actions.publishRules': '发布规则',
'channel.salesProducts.actions.publishPrice': '价格发布',
'channel.salesProducts.actions.viewPriceApproval': '查看审批',
'channel.salesProducts.actions.resubmitPriceApproval': '重新提交审批',
'channel.salesProducts.actions.retryPriceApprovalExecute': '重试业务执行',
'channel.salesProducts.actions.add': '新增',
'channel.salesProducts.actions.edit': '编辑',
'channel.salesProducts.actions.delete': '删除',
@ -5539,6 +5543,7 @@ export default {
'channel.salesProducts.publish.legend.same': '不变',
'channel.salesProducts.publish.badge.pending': '待发布',
'channel.salesProducts.publish.badge.pendingApproval': '待审批',
'channel.salesProducts.publish.badge.failed': '审批失败',
'channel.salesProducts.publish.badge.synced': '已发布',
'channel.salesProducts.publish.badge.checking': '检测中…',
'channel.salesProducts.publish.approvalNo': '审批号 {no}',

View File

@ -53,6 +53,7 @@
import type { PricePublishAiAdoptPayload } from './components/PricePublishAiAssistDrawer.vue';
import BillingSimulateDrawer from './components/BillingSimulateDrawer.vue';
import ApprovalDetailDrawer from '@/components/ApprovalDetailDrawer/index.vue';
import { retryApprovalExecute } from '@/api/system/approval';
import { buildPricePublishAiSkipReport, type PricePublishRiskLevel } from './pricePublishAiSkill';
import { pickResolvedAudit } from '@/utils/auditFields';
import { useUserStore } from '@/store';
@ -1453,15 +1454,23 @@
return detail?.content ?? detail?.Content ?? null;
}
/** 同步态:待发布 / 待审批(+审批号) / 已发布 */
/** 同步态:待发布 / 待审批 / 失败可重提 / 已发布 */
function clearPriceApprovalSyncState() {
priceApprovalPending.value = false;
priceApprovalFailed.value = false;
priceApprovalExecuteFailed.value = false;
priceApprovalInstanceId.value = null;
priceApprovalInstanceNo.value = '';
priceApprovalStatusName.value = '';
priceApprovalComment.value = '';
}
async function refreshPricePublishSyncStatus(productId?: number) {
const pid = productId ?? selectedProduct.value;
if (pid == null) {
pricePublishChecking.value = false;
pricePublishPending.value = null;
priceApprovalPending.value = false;
priceApprovalInstanceId.value = null;
priceApprovalInstanceNo.value = '';
clearPriceApprovalSyncState();
return;
}
const seq = priceTabLoadSeq;
@ -1477,7 +1486,17 @@
const approvalPending = Boolean(
status?.approvalPending ?? status?.ApprovalPending,
);
const approvalFailed = Boolean(
status?.approvalFailed ?? status?.ApprovalFailed,
);
priceApprovalPending.value = approvalPending;
priceApprovalFailed.value = approvalFailed && !approvalPending;
const statusName = String(
status?.approvalStatusName ?? status?.ApprovalStatusName ?? '',
).trim();
priceApprovalStatusName.value = statusName;
priceApprovalExecuteFailed.value =
priceApprovalFailed.value && statusName === '执行失败';
const instanceId =
status?.approvalInstanceId ?? status?.ApprovalInstanceId ?? null;
priceApprovalInstanceId.value =
@ -1485,12 +1504,13 @@
priceApprovalInstanceNo.value = String(
status?.approvalInstanceNo ?? status?.ApprovalInstanceNo ?? '',
).trim();
priceApprovalComment.value = String(
status?.approvalComment ?? status?.ApprovalComment ?? '',
).trim();
} catch {
if (seq === priceTabLoadSeq) {
pricePublishPending.value = null;
priceApprovalPending.value = false;
priceApprovalInstanceId.value = null;
priceApprovalInstanceNo.value = '';
clearPriceApprovalSyncState();
}
} finally {
if (seq === priceTabLoadSeq) pricePublishChecking.value = false;
@ -1498,6 +1518,7 @@
}
const priceApprovalDrawerVisible = ref(false);
const priceApprovalRetryLoading = ref(false);
function openPriceApprovalDrawer() {
if (!priceApprovalInstanceId.value) {
@ -1507,11 +1528,35 @@
priceApprovalDrawerVisible.value = true;
}
async function retryPriceApprovalExecute() {
const id = priceApprovalInstanceId.value;
if (!id) {
Message.warning(t('channel.salesProducts.publish.approvalDetailMissing'));
return;
}
priceApprovalRetryLoading.value = true;
try {
await retryApprovalExecute(id);
Message.success(t('common.success'));
const pid = selectedProduct.value;
if (pid != null) {
await refreshPricePublishSyncStatus(pid);
await loadPriceTabData(pid, { force: true });
await loadRecordsTabData(pid, true);
}
} catch (e: unknown) {
Message.error((e as Error)?.message || t('common.failed'));
} finally {
priceApprovalRetryLoading.value = false;
}
}
async function onPriceApprovalChanged() {
const pid = selectedProduct.value;
if (pid == null) return;
await refreshPricePublishSyncStatus(pid);
await loadPriceTabData(pid, { force: true });
await loadRecordsTabData(pid, true);
}
let recordsTabLoadedProductId: number | null = null;
@ -1672,18 +1717,14 @@
priceTabLoadedProductId = null;
pricePublishPending.value = null;
pricePublishChecking.value = false;
priceApprovalPending.value = false;
priceApprovalInstanceId.value = null;
priceApprovalInstanceNo.value = '';
clearPriceApprovalSyncState();
effectiveVersion.value = '--';
effectiveTime.value = '--';
} else if (activeTab.value === 'price') {
// 切到卖价 tab / 换产品:先清空徽章,等 sync-status 回来再显示
pricePublishPending.value = null;
pricePublishChecking.value = false;
priceApprovalPending.value = false;
priceApprovalInstanceId.value = null;
priceApprovalInstanceNo.value = '';
clearPriceApprovalSyncState();
}
if (productChanged && activeTab.value !== 'rules') {
rulesTabLoadedProductId = null;
@ -1951,8 +1992,18 @@
const pricePublishPending = ref<boolean | null>(null);
const pricePublishChecking = ref(false);
const priceApprovalPending = ref(false);
const priceApprovalFailed = ref(false);
const priceApprovalExecuteFailed = ref(false);
const priceApprovalInstanceId = ref<number | null>(null);
const priceApprovalInstanceNo = ref('');
const priceApprovalStatusName = ref('');
const priceApprovalComment = ref('');
const priceApprovalFailedBadgeText = computed(() => {
const name = priceApprovalStatusName.value || t('channel.salesProducts.publish.badge.failed');
return priceApprovalInstanceNo.value
? `${name} · ${priceApprovalInstanceNo.value}`
: name;
});
const publishDiffStatus = computed(() => {
if (!publishHasOnlineSnapshot.value) return 'first';
@ -4581,14 +4632,44 @@
</div>
<div v-else-if="selectedProduct != null && activeTab === 'price'" class="tabs-toolbar">
<a-space :size="8">
<a-button
v-if="priceApprovalPending"
type="primary"
size="small"
@click="openPriceApprovalDrawer"
>
{{ t('channel.salesProducts.actions.viewPriceApproval') }}
</a-button>
<template v-if="priceApprovalPending">
<a-button type="primary" size="small" @click="openPriceApprovalDrawer">
{{ t('channel.salesProducts.actions.viewPriceApproval') }}
</a-button>
</template>
<template v-else-if="priceApprovalExecuteFailed">
<a-button
type="primary"
size="small"
:loading="priceApprovalRetryLoading"
@click="retryPriceApprovalExecute"
>
{{ t('channel.salesProducts.actions.retryPriceApprovalExecute') }}
</a-button>
<a-button size="small" @click="openPriceApprovalDrawer">
{{ t('channel.salesProducts.actions.viewPriceApproval') }}
</a-button>
<a-button
size="small"
:loading="publishModalLoading"
@click="handlePublishPrice"
>
{{ t('channel.salesProducts.actions.resubmitPriceApproval') }}
</a-button>
</template>
<template v-else-if="priceApprovalFailed">
<a-button
type="primary"
size="small"
:loading="publishModalLoading"
@click="handlePublishPrice"
>
{{ t('channel.salesProducts.actions.resubmitPriceApproval') }}
</a-button>
<a-button size="small" @click="openPriceApprovalDrawer">
{{ t('channel.salesProducts.actions.viewPriceApproval') }}
</a-button>
</template>
<a-button
v-else
type="primary"
@ -4663,7 +4744,7 @@
{{ t('channel.salesProducts.price.effectiveVersion', { version: effectiveVersion }) }}
<span style="margin-left: 16px; color: var(--color-text-3);">生效时间:{{ effectiveTime }}</span>
<a-tag
v-if="pricePublishChecking && pricePublishPending == null && !priceApprovalPending"
v-if="pricePublishChecking && pricePublishPending == null && !priceApprovalPending && !priceApprovalFailed"
color="gray"
size="small"
class="price-sync-tag"
@ -4682,6 +4763,16 @@
· {{ priceApprovalInstanceNo }}
</template>
</a-tag>
<a-tag
v-else-if="priceApprovalFailed"
color="red"
size="small"
class="price-sync-tag price-approval-tag"
:title="priceApprovalComment || undefined"
@click="openPriceApprovalDrawer"
>
{{ priceApprovalFailedBadgeText }}
</a-tag>
<a-tag
v-else-if="pricePublishPending === true"
color="orangered"