去掉监控的价格日志

This commit is contained in:
wuweihua
2026-11-06 10:28:55 +08:00
parent e415843b14
commit 7807534e5d
2 changed files with 26 additions and 284 deletions
+26 -19
View File
@@ -1,4 +1,4 @@
-- Price change log under system monitor
-- Price change log: remove monitor page menu; keep query permission for package version change log
SET NAMES utf8mb4;
SET @monitorParent := (
@@ -8,29 +8,36 @@ SET @monitorParent := (
LIMIT 1
);
INSERT INTO sys_menu (
menu_id, menu_name, parent_id, order_num, path, component, query, route_name,
is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark
)
SELECT 2350, N'价格日志', IFNULL(@monitorParent, 2), 10,
'priceLog', 'monitor/priceLog/index', '', 'PriceLog',
1, 0, 'C', '0', '0', 'monitor:priceLog:list', 'log', 'admin', sysdate(),
N'销售价/产品价/红线价改前改后(ES)'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2350 OR perms = 'monitor:priceLog:list');
-- Drop legacy monitor page menu
DELETE FROM sys_role_menu WHERE menu_id = 2350;
DELETE FROM sys_menu WHERE menu_id = 2350
OR (menu_type = 'C' AND (path = 'priceLog' OR component = 'monitor/priceLog/index'));
-- Normalize existing permission row to button (F), no page component
UPDATE sys_menu
SET parent_id = IFNULL(@monitorParent, parent_id),
menu_type = 'F',
path = '',
component = NULL,
visible = '0',
status = '0',
menu_name = N'价格变更日志查询',
remark = N'套餐版本变更记录等查询权限(无监控页面)'
WHERE menu_id = 2351
OR perms = 'monitor:priceLog:list';
INSERT INTO sys_menu (
menu_id, menu_name, parent_id, order_num, path, component,
is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time
is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark
)
SELECT 2351, N'查询', 2350, 1, '', NULL,
1, 0, 'F', '0', '0', 'monitor:priceLog:list', '#', 'admin', sysdate()
SELECT 2351, N'价格变更日志查询', IFNULL(@monitorParent, 2), 10, '', NULL,
1, 0, 'F', '0', '0', 'monitor:priceLog:list', '#', 'admin', sysdate(),
N'套餐版本变更记录等查询权限(无监控页面)'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2351);
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2351 OR perms = 'monitor:priceLog:list');
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, m.menu_id
FROM (SELECT 2350 AS menu_id UNION SELECT 2351) m
WHERE NOT EXISTS (
SELECT 1 FROM sys_role_menu rm WHERE rm.role_id = 1 AND rm.menu_id = m.menu_id
);
FROM sys_menu m
WHERE m.perms = 'monitor:priceLog:list'
AND NOT EXISTS (SELECT 1 FROM sys_role_menu rm WHERE rm.role_id = 1 AND rm.menu_id = m.menu_id);
@@ -1,265 +0,0 @@
<template>
<div class="app-container">
<basic-table
ref="tableRef"
:columns="columns"
:search-columns="searchColumns"
:query="queryList"
row-key="docId"
>
<template #col-priceKind="{ row }">
<el-tag size="small" :type="kindTag(row)">{{ kindLabel(row) }}</el-tag>
</template>
<template #col-actionName="{ row }">
{{ actionLabel(row) }}
</template>
<template #col-operator="{ row }">
{{ operatorOf(row) }}
</template>
<template #col-productCode="{ row }">
{{ productCodeOf(row) }}
</template>
<template #col-status="{ row }">
<el-tag size="small" :type="statusTag(row.status)">{{ statusLabel(row.status) }}</el-tag>
</template>
<template #col-action="{ row }">
<el-button link type="primary" icon="View" @click="handleView(row)" v-hasPermi="['monitor:priceLog:list']">查看</el-button>
</template>
</basic-table>
<el-drawer v-model="open" size="760px" :title="drawerTitle" append-to-body destroy-on-close>
<div v-loading="loading">
<el-empty v-if="!detail" description="暂无详情" />
<div v-else>
<el-descriptions :column="2" border size="small" class="mb12">
<el-descriptions-item label="价格类型">
<el-tag size="small" :type="kindTag(detail)">{{ kindLabel(detail) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="操作">{{ actionLabel(detail) }}</el-descriptions-item>
<el-descriptions-item label="操作人">{{ operatorOf(detail) }}</el-descriptions-item>
<el-descriptions-item label="状态">
<el-tag size="small" :type="statusTag(detail.status)">{{ statusLabel(detail.status) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="业务ID">{{ detail.bizId || '-' }}</el-descriptions-item>
<el-descriptions-item label="写入时间">{{ detail.updateTime || '-' }}</el-descriptions-item>
<el-descriptions-item label="产品代码">{{ productCodeOf(detail) }}</el-descriptions-item>
<el-descriptions-item label="国家">{{ countryOf(detail) }}</el-descriptions-item>
<el-descriptions-item v-if="detail.errorMessage" label="错误信息" :span="2">
<span class="err-text">{{ detail.errorMessage }}</span>
</el-descriptions-item>
</el-descriptions>
<div class="change-panel">
<div class="change-panel__head">改前改后</div>
<el-table :data="changesOf(detail)" border size="small" empty-text="无字段变更">
<el-table-column prop="fieldLabel" label="字段" min-width="120" />
<el-table-column prop="oldValue" label="改前" min-width="140" show-overflow-tooltip />
<el-table-column prop="newValue" label="改后" min-width="140" show-overflow-tooltip />
</el-table>
</div>
<div class="json-panel">
<div class="json-panel__head">
<span>请求报文</span>
<el-button size="small" icon="CopyDocument" @click="copyJson(detail.requestJson)">复制</el-button>
</div>
<pre class="code-pre">{{ formatJson(detail.requestJson) }}</pre>
</div>
</div>
</div>
</el-drawer>
</div>
</template>
<script setup name="PriceLog">
import { listPriceLog, getPriceLog } from '@/api/monitor/priceLog'
const tableRef = ref()
const open = ref(false)
const loading = ref(false)
const detail = ref(null)
const drawerTitle = ref('价格日志详情')
const kindOptions = [
{ label: '销售价', value: 'SALES' },
{ label: '产品价', value: 'PRODUCT' },
{ label: '红线价', value: 'REDLINE' }
]
const actionOptions = [
{ label: '新增', value: 'INSERT' },
{ label: '修改', value: 'UPDATE' },
{ label: '删除', value: 'DELETE' },
{ label: '导入', value: 'IMPORT' }
]
const statusOptions = [
{ label: '成功', value: 'SUCCESS' },
{ label: '失败', value: 'FAIL' }
]
const searchColumns = [
{ label: '状态', prop: 'status', component: 'select', options: statusOptions, placeholder: '请选择状态', width: '140px', props: { clearable: true } },
{ label: '业务ID', prop: 'bizId', component: 'input', placeholder: 'SALES_/PRODUCT_/REDLINE_', width: '240px' }
]
const columns = [
{ label: '价格类型', prop: 'priceKind', align: 'center', width: 100, slot: 'priceKind' },
{ label: '操作', prop: 'actionName', align: 'center', width: 90, slot: 'actionName' },
{ label: '操作人', prop: 'operator', width: 110, slot: 'operator', showOverflowTooltip: true },
{ label: '产品代码', prop: 'productCode', minWidth: 120, slot: 'productCode', showOverflowTooltip: true },
{ label: '状态', prop: 'status', align: 'center', width: 90, slot: 'status' },
{ label: '业务ID', prop: 'bizId', minWidth: 160, showOverflowTooltip: true },
{ label: '写入时间', prop: 'updateTime', align: 'center', width: 180 },
{ label: '操作', prop: 'action', align: 'center', width: 90, fixed: 'right', slot: 'action', showInToolbar: false }
]
function queryList(params) {
return listPriceLog(params)
}
function parseReq(row) {
if (!row || !row.requestJson) return {}
try {
return typeof row.requestJson === 'object' ? row.requestJson : JSON.parse(row.requestJson)
} catch (e) {
return {}
}
}
function kindOf(row) {
const req = parseReq(row)
return req.priceKind || ''
}
function kindLabel(row) {
const v = kindOf(row)
const found = kindOptions.find(i => i.value === v)
return found ? found.label : (v || '-')
}
function kindTag(row) {
const v = kindOf(row)
if (v === 'SALES') return 'success'
if (v === 'PRODUCT') return 'warning'
if (v === 'REDLINE') return 'danger'
return 'info'
}
function actionLabel(row) {
const req = parseReq(row)
const found = actionOptions.find(i => i.value === req.action)
return found ? found.label : (req.action || '-')
}
function operatorOf(row) {
return parseReq(row).operator || '-'
}
function productCodeOf(row) {
const keys = parseReq(row).bizKeys || {}
return keys.productCode || '-'
}
function countryOf(row) {
const keys = parseReq(row).bizKeys || {}
if (keys.countryCode && keys.countryName) return keys.countryName + ' (' + keys.countryCode + ')'
return keys.countryCode || keys.countryName || '-'
}
function changesOf(row) {
const req = parseReq(row)
return Array.isArray(req.changes) ? req.changes : []
}
function statusLabel(status) {
const found = statusOptions.find(item => item.value === status)
if (found) return found.label
return status === 'FAIL' ? '失败' : '成功'
}
function statusTag(status) {
return status === 'FAIL' ? 'danger' : 'success'
}
function handleView(row) {
drawerTitle.value = '价格日志 #' + (row.bizId || row.docId)
open.value = true
loading.value = true
detail.value = null
getPriceLog(row.docId).then(res => {
detail.value = res.data || row
}).finally(() => {
loading.value = false
})
}
function formatJson(val) {
if (val === null || val === undefined || val === '') return '无数据'
if (typeof val === 'object') {
try { return JSON.stringify(val, null, 2) } catch (e) { return String(val) }
}
try { return JSON.stringify(JSON.parse(val), null, 2) } catch (e) { return String(val) }
}
function copyJson(val) {
const text = formatJson(val)
const done = () => ElMessage({ message: '已复制', type: 'success', duration: 1500 })
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(done)
return
}
const ta = document.createElement('textarea')
ta.value = text
document.body.appendChild(ta)
ta.select()
document.execCommand('copy')
document.body.removeChild(ta)
done()
}
</script>
<style scoped>
.mb12 { margin-bottom: 12px; }
.err-text { color: #f56c6c; word-break: break-all; }
.change-panel {
margin-bottom: 12px;
border: 1px solid #e8ecf0;
border-radius: 6px;
overflow: hidden;
}
.change-panel__head {
padding: 8px 12px;
font-size: 13px;
font-weight: 600;
color: #606266;
background: #fafbfc;
border-bottom: 1px solid #ebeef5;
}
.json-panel {
margin-bottom: 12px;
background: #f7f9fb;
border: 1px solid #e8ecf0;
border-radius: 6px;
overflow: hidden;
}
.json-panel__head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px;
font-size: 13px;
font-weight: 600;
color: #606266;
background: #fafbfc;
border-bottom: 1px solid #ebeef5;
}
.json-panel .code-pre {
margin: 0;
padding: 12px 14px;
max-height: 280px;
overflow: auto;
white-space: pre-wrap;
word-break: break-all;
}
</style>