This commit is contained in:
@@ -79,7 +79,7 @@
|
|||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
<ElTableColumn label="变更内容" min-width="250">
|
<ElTableColumn label="变更内容" min-width="250">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div v-if="getChangeContent(row)" class="change-content">
|
<div v-if="getChangeContent(row).length" class="change-content">
|
||||||
<span
|
<span
|
||||||
v-for="(change, index) in getChangeContent(row)"
|
v-for="(change, index) in getChangeContent(row)"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -87,14 +87,7 @@
|
|||||||
>
|
>
|
||||||
<span class="field-name">{{ change.fieldName }}</span>
|
<span class="field-name">{{ change.fieldName }}</span>
|
||||||
<span class="field-value">
|
<span class="field-value">
|
||||||
<template v-if="change.beforeValue !== undefined">
|
<span class="new-value">{{ formatFieldValue(change.key, change.afterValue) }}</span>
|
||||||
<span class="old-value">{{ formatValue(change.beforeValue) }}</span>
|
|
||||||
<span class="arrow">→</span>
|
|
||||||
<span class="new-value">{{ formatValue(change.afterValue) }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span class="new-value">{{ formatValue(change.afterValue) }}</span>
|
|
||||||
</template>
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -121,17 +114,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, watch } from 'vue'
|
import { reactive, ref, watch } from 'vue'
|
||||||
import {
|
import {
|
||||||
ElCard,
|
|
||||||
ElTable,
|
|
||||||
ElTableColumn,
|
|
||||||
ElTag,
|
|
||||||
ElButton,
|
ElButton,
|
||||||
ElSelect,
|
ElCard,
|
||||||
|
ElMessage,
|
||||||
ElOption,
|
ElOption,
|
||||||
ElPagination,
|
ElPagination,
|
||||||
ElMessage
|
ElSelect,
|
||||||
|
ElTable,
|
||||||
|
ElTableColumn,
|
||||||
|
ElTag
|
||||||
} from 'element-plus'
|
} from 'element-plus'
|
||||||
import { AssetService } from '@/api/modules'
|
import { AssetService } from '@/api/modules'
|
||||||
import type { AssetOperationLogItem } from '@/types/api'
|
import type { AssetOperationLogItem } from '@/types/api'
|
||||||
@@ -143,8 +136,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ChangeItem {
|
interface ChangeItem {
|
||||||
|
key: string
|
||||||
fieldName: string
|
fieldName: string
|
||||||
beforeValue?: any
|
|
||||||
afterValue?: any
|
afterValue?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,19 +284,50 @@
|
|||||||
return formatValue(value)
|
return formatValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sanitizeFieldName = (fieldName: string): string => {
|
||||||
|
return fieldName.trim().replace(/([^)]*)/g, '').trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
const shouldHideIdField = (key: string, fieldName: string): boolean => {
|
||||||
|
const normalizedKey = key.trim()
|
||||||
|
const normalizedKeyLower = normalizedKey.toLowerCase()
|
||||||
|
const normalizedFieldName = sanitizeFieldName(fieldName)
|
||||||
|
const normalizedFieldNameUpper = normalizedFieldName.toUpperCase()
|
||||||
|
|
||||||
|
const visibleIdentifierKeys = new Set(['iccid', 'msisdn', 'imei', 'imsi', 'sn'])
|
||||||
|
const visibleIdentifierNames = ['ICCID', 'MSISDN', 'IMEI', 'IMSI', 'SN']
|
||||||
|
|
||||||
|
if (
|
||||||
|
visibleIdentifierKeys.has(normalizedKeyLower) ||
|
||||||
|
visibleIdentifierNames.some((name) => normalizedFieldNameUpper.endsWith(name))
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
normalizedKeyLower === 'id' ||
|
||||||
|
normalizedKeyLower.endsWith('_id') ||
|
||||||
|
/^[a-z][a-z0-9]*Id$/.test(normalizedKey) ||
|
||||||
|
normalizedFieldName === '绑定记录ID' ||
|
||||||
|
normalizedFieldName === 'ID' ||
|
||||||
|
normalizedFieldName.endsWith('ID')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const getChangeContent = (row: AssetOperationLogItem): ChangeItem[] => {
|
const getChangeContent = (row: AssetOperationLogItem): ChangeItem[] => {
|
||||||
const after = row.operation_content_after
|
const after = row.operation_content_after
|
||||||
const before = row.operation_content_before
|
|
||||||
const desc = row.operation_fields_desc || {}
|
const desc = row.operation_fields_desc || {}
|
||||||
|
|
||||||
if (!after || Object.keys(after).length === 0) return []
|
if (!after || Object.keys(after).length === 0) return []
|
||||||
|
|
||||||
const changes: ChangeItem[] = []
|
const changes: ChangeItem[] = []
|
||||||
for (const key of Object.keys(after)) {
|
for (const key of Object.keys(after)) {
|
||||||
const fieldName = desc[key] || key
|
const fieldName = sanitizeFieldName(desc[key] || key)
|
||||||
|
if (shouldHideIdField(key, fieldName)) continue
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
|
key,
|
||||||
fieldName,
|
fieldName,
|
||||||
beforeValue: before?.[key],
|
|
||||||
afterValue: after[key]
|
afterValue: after[key]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -368,16 +392,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.field-value {
|
.field-value {
|
||||||
.old-value {
|
|
||||||
text-decoration: line-through;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.arrow {
|
|
||||||
color: var(--el-text-color-light);
|
|
||||||
margin: 0 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.new-value {
|
.new-value {
|
||||||
color: var(--el-color-success);
|
color: var(--el-color-success);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user