diff --git a/frontend/src/api/operationLog.ts b/frontend/src/api/operationLog.ts new file mode 100644 index 0000000..4967dd1 --- /dev/null +++ b/frontend/src/api/operationLog.ts @@ -0,0 +1,53 @@ +import { get } from '@/utils/request' + +/** 日志对象类型:店铺商品 / 系统商品 / 组合商品 */ +export type OperationLogTargetType = 'shop_product' | 'product' | 'combo_product' + +/** 一条操作记录 */ +export interface OperationLogItem { + id: number + principal_id: number + target_type: OperationLogTargetType + target_id: number + /** 动作码:create / update / bind / unbind / remove / offline / delete */ + action: string + /** 操作说明(已包含对象名称,可直接展示) */ + title: string + detail?: Record | null + /** ui 界面操作 / sync 自动同步 / system 系统任务 */ + source: string + operator_id: number | null + operator_name: string | null + created_at: string +} + +/** 动作码 → 中文标签 */ +export const ACTION_LABELS: Record = { + create: '新增', + update: '修改', + bind: '绑定', + unbind: '解绑', + remove: '移出', + offline: '下架', + delete: '删除', +} + +/** 来源 → 中文标签 */ +export const SOURCE_LABELS: Record = { + ui: '界面操作', + sync: '自动同步', + system: '系统任务', +} + +/** 分页查询某个对象的操作记录 */ +export function getOperationLogs(params: { + target_type: OperationLogTargetType + target_id: number + page?: number + pageSize?: number +}) { + return get<{ list: OperationLogItem[]; total: number; page: number; pageSize: number }>( + '/operation-logs', + params, + ) +} diff --git a/frontend/src/components/OperationLogPanel.vue b/frontend/src/components/OperationLogPanel.vue new file mode 100644 index 0000000..27de884 --- /dev/null +++ b/frontend/src/components/OperationLogPanel.vue @@ -0,0 +1,178 @@ + + + + + diff --git a/frontend/src/views/ComboProduct/Index.vue b/frontend/src/views/ComboProduct/Index.vue index c40db00..eaf0286 100644 --- a/frontend/src/views/ComboProduct/Index.vue +++ b/frontend/src/views/ComboProduct/Index.vue @@ -12,6 +12,7 @@ import { searchProducts, type ProductSearchItem } from '@/api/product' import DataTable from '@/components/DataTable.vue' import ExportButton from '@/components/ExportButton.vue' import ListPager from '@/components/ListPager.vue' +import OperationLogPanel from '@/components/OperationLogPanel.vue' import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage' const query = reactive({ @@ -220,11 +221,26 @@ async function handleDelete(row: ComboProductItem) { } } +/* -------------------- 操作记录 -------------------- */ +const logVisible = ref(false) +const logRow = ref(null) + +function openLog(row: ComboProductItem) { + logRow.value = row + logVisible.value = true +} + +const logTitle = computed(() => { + const row = logRow.value + if (!row) return '操作记录' + return `操作记录:${row.name || ''}(${row.code || ''})` +}) + onMounted(fetchList)