diff --git a/web-admin/src/utils/pl-plan-action-guards.ts b/web-admin/src/utils/pl-plan-action-guards.ts new file mode 100644 index 000000000..f2e17d30b --- /dev/null +++ b/web-admin/src/utils/pl-plan-action-guards.ts @@ -0,0 +1,34 @@ +export function canEditPlan(row: { archiveStatus?: string; followStatus?: string }) { + return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled' +} + +export function canArrangeTransport(row: { + transportStatus?: string + archiveStatus?: string + followStatus?: string +}) { + return ( + (row.transportStatus === 'pending' || row.transportStatus === 'arranged') && + row.archiveStatus !== 'archived' && + row.followStatus !== 'cancelled' + ) +} + +export function arrangeTransportLabel(row: { transportStatus?: string }) { + return row.transportStatus === 'arranged' ? '调整运输' : '安排运输' +} + +export function canVoidPlan(row: { archiveStatus?: string; followStatus?: string }) { + return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled' +} + +export function canWaitNotice(row: { followStatus?: string; archiveStatus?: string }) { + return ( + (row.followStatus === 'pending_arrange' || row.followStatus === 'drafting') && + row.archiveStatus !== 'archived' + ) +} + +export function canCancelWaitNotice(row: { followStatus?: string; archiveStatus?: string }) { + return row.followStatus === 'wait_notice' && row.archiveStatus !== 'archived' +} diff --git a/web-admin/src/views/m/pl/plan/detail.vue b/web-admin/src/views/m/pl/plan/detail.vue index c970fbc76..be989b154 100644 --- a/web-admin/src/views/m/pl/plan/detail.vue +++ b/web-admin/src/views/m/pl/plan/detail.vue @@ -1,18 +1,160 @@ + import { planApi, type Plan } from '@/api/pl' + import { buildPlanCard } from '@/utils/mp-pl-plan-card' + import { + arrangeTransportLabel, + canArrangeTransport, + canEditPlan, + canVoidPlan, + canWaitNotice + } from '@/utils/pl-plan-action-guards' + import '@/styles/mp-webview.scss' - + + function goList() { + void router.push('/m/pl/plan') + } + + function goEdit() { + if (!plan.value) return + void router.push(`/m/pl/plan/${plan.value.id}/edit`) + } + + function goArrange() { + if (!plan.value) return + void router.push(`/m/pl/plan/${plan.value.id}/arrange`) + } + + function goCopy() { + if (!plan.value) return + void router.push({ path: '/m/pl/plan/new', query: { copyFrom: plan.value.id } }) + } + + function goPrint() { + if (!plan.value) return + void router.push(`/m/pl/plan/${plan.value.id}/print`) + } + + async function doWaitNotice() { + if (!plan.value) return + await ElMessageBox.confirm('确认将该计划标记为等客户通知?', '等客户通知', { + type: 'warning' + }) + acting.value = true + try { + const res = await planApi.waitNotice(plan.value.id) + plan.value = ((res as { data?: Plan }).data ?? res) as Plan + ElMessage.success('已标记为等客户通知') + } finally { + acting.value = false + } + } + + async function doVoid() { + if (!plan.value) return + await ElMessageBox.confirm('确认作废该运输计划?此操作不可恢复。', '作废', { type: 'warning' }) + acting.value = true + try { + const res = await planApi.cancel(plan.value.id) + plan.value = ((res as { data?: Plan }).data ?? res) as Plan + ElMessage.success('已作废') + } finally { + acting.value = false + } + } + + onMounted(() => { + void loadDetail() + }) + diff --git a/web-admin/src/views/pl/plan/index.vue b/web-admin/src/views/pl/plan/index.vue index 740f85dea..09b5a6e1d 100644 --- a/web-admin/src/views/pl/plan/index.vue +++ b/web-admin/src/views/pl/plan/index.vue @@ -870,6 +870,14 @@ import { useListTableViewportHeight } from '@/composables/useListTableViewportHe import { canBatchPrintSlip } from '@/utils/pl-batch-print' import { listDeliveryPrintCustomers } from '@/utils/pl-delivery-slip-print' import { isPlInternalCustomerName } from '@/utils/pl-internal-customer' + import { + arrangeTransportLabel, + canArrangeTransport, + canCancelWaitNotice, + canEditPlan, + canVoidPlan, + canWaitNotice + } from '@/utils/pl-plan-action-guards' import { buildPlPlanListSpanMethod, flattenPlanListRows, @@ -1433,37 +1441,6 @@ tableEl: planTableWrapRef, handleCopy(selectedPlan.value) } - function canEditPlan(row: Plan) { - return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled' - } - - function canArrangeTransport(row: Plan) { - return ( - (row.transportStatus === 'pending' || row.transportStatus === 'arranged') && - row.archiveStatus !== 'archived' && - row.followStatus !== 'cancelled' - ) - } - - function arrangeTransportLabel(row: Plan) { - return row.transportStatus === 'arranged' ? '调整运输' : '安排运输' - } - - function canVoidPlan(row: Plan) { - return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled' - } - - function canWaitNotice(row: Plan) { - return ( - (row.followStatus === 'pending_arrange' || row.followStatus === 'drafting') && - row.archiveStatus !== 'archived' - ) - } - - function canCancelWaitNotice(row: Plan) { - return row.followStatus === 'wait_notice' && row.archiveStatus !== 'archived' - } - function syncViewingPlan(updated: Plan) { if (viewingPlan.value?.id === updated.id) { viewingPlan.value = { ...viewingPlan.value, ...updated }