日志记录修改

This commit is contained in:
luojiaquan
2026-09-30 16:57:44 +08:00
parent 02c281fd07
commit 903d19cad1
9 changed files with 794 additions and 101 deletions
@@ -0,0 +1,133 @@
<template>
<el-dialog
:model-value="modelValue"
@update:model-value="$emit('update:modelValue', $event)"
:title="`业务日志 - ${customerName || ''}`"
width="900px"
append-to-body
@open="handleOpen"
>
<div style="margin-bottom: 10px; color: #909399; font-size: 13px;">
客户编码:{{ customerCode || '-' }}
<span style="margin-left: 16px;">共 {{ logList.length }} 条日志(按操作时间倒序)</span>
</div>
<el-table v-loading="loading" :data="logList" border size="small" row-key="logId" :empty-text="'暂无业务日志'">
<el-table-column type="expand">
<template #default="scope">
<div style="padding: 8px 16px; background: #fafafa;">
<div v-if="!scope.row.changes || !scope.row.changes.length" style="color:#909399;">无字段明细</div>
<el-table v-else :data="scope.row.changes" border size="small">
<el-table-column label="字段" prop="fieldLabel" width="180" align="center" />
<el-table-column label="修改前" align="center">
<template #default="cell">
<span :style="{ color: cell.row.oldValue === '' ? '#909399' : '' }">{{ cell.row.oldValue === '' ? '(空)' : cell.row.oldValue }}</span>
</template>
</el-table-column>
<el-table-column label="修改后" align="center">
<template #default="cell">
<span :style="{ color: cell.row.newValue === '' ? '#909399' : '' }">{{ cell.row.newValue === '' ? '(空)' : cell.row.newValue }}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
</el-table-column>
<el-table-column label="模块" align="center" width="92">
<template #default="scope">
<el-tag :type="moduleTagType(scope.row.bizModule)" size="small" effect="plain">{{ moduleLabel(scope.row.bizModule) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="76">
<template #default="scope">
<el-tag :type="opTagType(scope.row.operationType)" size="small">{{ opLabel(scope.row.operationType) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="对象" align="center" width="150" show-overflow-tooltip>
<template #default="scope">
<span :title="scope.row.bizName">{{ scope.row.bizName || '客户档案' }}</span>
</template>
</el-table-column>
<el-table-column label="操作人" align="center" width="130">
<template #default="scope">{{ scope.row.createByName || scope.row.createBy || '-' }}</template>
</el-table-column>
<el-table-column label="操作时间" align="center" width="160">
<template #default="scope">{{ fmtTime(scope.row.createTime) }}</template>
</el-table-column>
<el-table-column label="变更摘要" align="center">
<template #default="scope">
<span>{{ rowSummary(scope.row) }}</span>
</template>
</el-table-column>
</el-table>
<template #footer>
<el-button @click="$emit('update:modelValue', false)">关 闭</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { listCustomerLog } from "@/api/customersuppliermanagement/customerinfo/customer.js"
const { proxy } = getCurrentInstance()
const props = defineProps({
modelValue: { type: Boolean, default: false },
customerId: { type: [Number, String], default: null },
customerName: { type: String, default: '' },
customerCode: { type: String, default: '' }
})
defineEmits(['update:modelValue'])
const loading = ref(false)
const logList = ref([])
const MODULE_META = {
main: { label: '客户档案', tag: '' },
company: { label: '公司主体', tag: 'success' },
contact: { label: '联系人', tag: 'warning' },
attachment: { label: '附件', tag: 'info' },
priceset: { label: '绑定套餐', tag: 'danger' }
}
const OP_META = {
'1': { label: '新建', tag: 'success' },
'2': { label: '修改', tag: 'warning' },
'3': { label: '删除', tag: 'danger' }
}
const moduleLabel = (m) => MODULE_META[m]?.label || '客户档案'
const moduleTagType = (m) => MODULE_META[m]?.tag ?? ''
const opLabel = (op) => OP_META[op]?.label || op
const opTagType = (op) => OP_META[op]?.tag || 'info'
const fmtTime = (t) => t ? proxy.parseTime(t, '{y}-{m}-{d} {h}:{i}:{s}') : '-'
const changeSummary = (changes) => {
if (!changes || !changes.length) return '-'
return changes.slice(0, 3).map(c => c.fieldLabel).join('、') + (changes.length > 3 ? ` 等${changes.length}项` : '')
}
const rowSummary = (row) => {
const mod = moduleLabel(row.bizModule)
const obj = row.bizName ? `「${row.bizName}」` : ''
if (row.operationType === '1') {
return `新建${mod}${obj},录入 ${row.changes?.length || 0} 项信息`
}
if (row.operationType === '2') {
return changeSummary(row.changes)
}
return `${mod}${obj}被删除`
}
const handleOpen = async () => {
if (!props.customerId) return
loading.value = true
try {
const res = await listCustomerLog(props.customerId)
logList.value = res.data || []
} finally {
loading.value = false
}
}
</script>