去掉监控的价格日志
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user