fix: 优化日计划日志展示
This commit is contained in:
@@ -123,6 +123,7 @@ export namespace LmsDailyPlanApi {
|
||||
operationTime: number;
|
||||
operationType: string;
|
||||
operator: string;
|
||||
operatorName?: string;
|
||||
}
|
||||
|
||||
export interface Strategy {
|
||||
|
||||
@@ -124,10 +124,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
type: 'link',
|
||||
auth: ['lms:daily-plan:start'],
|
||||
ifShow: row.orderStatus === ORDER_NOT_STARTED,
|
||||
popConfirm: {
|
||||
title: `确认开始日计划「${row.planCode}」吗?`,
|
||||
confirm: handleStart.bind(null, row),
|
||||
},
|
||||
onClick: handleStart.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ref } from 'vue';
|
||||
|
||||
import { useVbenDrawer } from '@vben/common-ui';
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictLabel } from '@vben/hooks';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import {
|
||||
@@ -21,11 +22,51 @@ const DAILY_PLAN_DICT_TYPE = DICT_TYPE as typeof DICT_TYPE & {
|
||||
LMS_DAILY_PLAN_SOURCE_TYPE: string;
|
||||
LMS_DAILY_PLAN_WORK_STATUS: string;
|
||||
};
|
||||
const TARGET_LABELS: Record<string, string> = {
|
||||
ORDER: '订单',
|
||||
QUANTITY: '数量',
|
||||
SLEEVING: '套管',
|
||||
SORT: '顺序',
|
||||
STOCKING: '备货',
|
||||
STRATEGY: '策略',
|
||||
WEIGHT: '权重',
|
||||
};
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
APPEND: '追加数量',
|
||||
CANCEL: '取消',
|
||||
CREATE: '创建',
|
||||
FINISH: '结束',
|
||||
PROGRESS: '更新进度',
|
||||
RESTORE: '恢复',
|
||||
START: '开始',
|
||||
STOP: '停止',
|
||||
UPDATE: '修改',
|
||||
};
|
||||
const STATUS_OPERATION_TYPES = new Set(['CANCEL', 'FINISH', 'RESTORE', 'START', 'STOP']);
|
||||
|
||||
function showTime(value?: number) {
|
||||
return value ? formatDateTime(value) : '-';
|
||||
}
|
||||
|
||||
function showTarget(value: string) {
|
||||
return TARGET_LABELS[value] ?? '其他';
|
||||
}
|
||||
|
||||
function showType(value: string) {
|
||||
return TYPE_LABELS[value] ?? '操作';
|
||||
}
|
||||
|
||||
function showLogValue(log: LmsDailyPlanApi.OperationLog, value?: string) {
|
||||
if (!value) return '-';
|
||||
if (!STATUS_OPERATION_TYPES.has(log.operationType)) return value;
|
||||
const dictType = log.operationTarget === 'ORDER'
|
||||
? DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_ORDER_STATUS
|
||||
: ['SLEEVING', 'STOCKING'].includes(log.operationTarget)
|
||||
? DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_WORK_STATUS
|
||||
: undefined;
|
||||
return dictType ? (getDictLabel(dictType, value) || '未知状态') : value;
|
||||
}
|
||||
|
||||
const [Drawer, drawerApi] = useVbenDrawer({
|
||||
showConfirmButton: false,
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
@@ -84,12 +125,12 @@ const [Drawer, drawerApi] = useVbenDrawer({
|
||||
<Empty v-if="logs.length === 0" description="暂无操作记录" />
|
||||
<Timeline v-else>
|
||||
<TimelineItem v-for="log in logs" :key="String(log.operationLogId)">
|
||||
<div class="font-medium">{{ log.operationType }} · {{ log.operationTarget }}</div>
|
||||
<div class="text-sm text-gray-500">{{ showTime(log.operationTime) }} · {{ log.operator || '-' }}</div>
|
||||
<div class="font-medium">{{ showType(log.operationType) }} · {{ showTarget(log.operationTarget) }}</div>
|
||||
<div class="text-sm text-gray-500">{{ showTime(log.operationTime) }} · {{ log.operatorName || '系统' }}</div>
|
||||
<div v-if="log.beforeValue || log.afterValue" class="mt-1">
|
||||
{{ log.beforeValue || '-' }} → {{ log.afterValue || '-' }}
|
||||
变更:{{ showLogValue(log, log.beforeValue) }} → {{ showLogValue(log, log.afterValue) }}
|
||||
</div>
|
||||
<div v-if="log.changeQty" class="mt-1">数量变化:{{ log.changeQty > 0 ? '+' : '' }}{{ log.changeQty }}</div>
|
||||
<div v-if="log.changeQty" class="mt-1">数量变化:{{ log.changeQty > 0 ? '+' : '' }}{{ log.changeQty }} 根</div>
|
||||
<div v-if="log.operationReason" class="mt-1 whitespace-pre-wrap">原因:{{ log.operationReason }}</div>
|
||||
</TimelineItem>
|
||||
</Timeline>
|
||||
|
||||
Reference in New Issue
Block a user