diff --git a/src/api/logManage/operation.ts b/src/api/logManage/operation.ts new file mode 100644 index 00000000..ab59d48e --- /dev/null +++ b/src/api/logManage/operation.ts @@ -0,0 +1,69 @@ +import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; +import { request } from '@/plugins/http-fetch'; +import { parseObjLineToHump } from '@/utils/parse-utils'; + +/** + * 查询日志列表 + * @param query 查询参数 + * @returns object + */ +export async function listOperationLog(query: Record) { + let totalSQL = 'select count(*) as total from operation_log where 1=1 '; + let rowsSQL = 'select * from operation_log where 1=1 '; + + // 查询 + let querySQL = ''; + if (query.accountName) { + querySQL += ` and account_name like '%${query.accountName}%' `; + } + if (query.beginTime) { + querySQL += ` and begin_time >= '${query.beginTime}' `; + } + if (query.endTime) { + querySQL += ` and end_time <= '${query.endTime}' `; + } + + // 排序 + let sortSql = ' order by begin_time '; + if (query.sortOrder === 'asc') { + sortSql += ' asc '; + } else { + sortSql += ' desc '; + } + + // 分页 + const pageNum = (query.pageNum - 1) * query.pageSize; + const limtSql = ` limit ${pageNum},${query.pageSize} `; + + // 发起请求 + const result = await request({ + url: `/databaseManagement/v1/select/omc_db/operation_log`, + method: 'get', + params: { + totalSQL: totalSQL + querySQL, + rowsSQL: rowsSQL + querySQL + sortSql + limtSql, + }, + }); + + // 解析数据 + if (result.code === RESULT_CODE_SUCCESS) { + const data: DataList = { + total: 0, + rows: [], + code: result.code, + msg: result.msg, + }; + result.data.data.forEach((item: any) => { + const itemData = item['operation_log']; + if (Array.isArray(itemData)) { + if (itemData.length === 1 && itemData[0]['total']) { + data.total = itemData[0]['total']; + } else { + data.rows = itemData.map(v => parseObjLineToHump(v)); + } + } + }); + return data; + } + return result; +} diff --git a/src/views/logManage/operation/index.vue b/src/views/logManage/operation/index.vue index 38f1f3b1..145a8bfa 100644 --- a/src/views/logManage/operation/index.vue +++ b/src/views/logManage/operation/index.vue @@ -2,15 +2,13 @@ import { useRoute } from 'vue-router'; import { reactive, ref, onMounted, toRaw } from 'vue'; import { PageContainer } from '@ant-design-vue/pro-layout'; -import { message, Modal } from 'ant-design-vue/lib'; import { SizeType } from 'ant-design-vue/lib/config-provider'; import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface'; import { ColumnsType } from 'ant-design-vue/lib/table'; import { parseDateToStr } from '@/utils/date-utils'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; -import { saveAs } from 'file-saver'; +import { listOperationLog } from '@/api/logManage/operation'; import useI18n from '@/hooks/useI18n'; -import { getTraceRawInfo, listTraceData } from '@/api/traceManage/analysis'; const { t } = useI18n(); const route = useRoute(); @@ -19,10 +17,11 @@ let title = ref((route.meta.title as string) ?? '标题'); /**查询参数 */ let queryParams = reactive({ - /**移动号 */ - imsi: '', - /**移动号 */ - msisdn: '', + /**登录账号 */ + accountName: '', + /**记录时间 */ + beginTime: '', + endTime: '', /**当前页数 */ pageNum: 1, /**每页条数 */ @@ -32,7 +31,9 @@ let queryParams = reactive({ /**查询参数重置 */ function fnQueryReset() { queryParams = Object.assign(queryParams, { - imsi: '', + accountName: '', + beginTime: '', + endTime: undefined, pageNum: 1, pageSize: 20, }); @@ -64,48 +65,48 @@ let tableState: TabeStateType = reactive({ /**表格字段列 */ let tableColumns: ColumnsType = [ { - title: t('views.traceManage.analysis.trackTaskId'), - dataIndex: 'taskId', + title: t('common.rowId'), + dataIndex: 'opId', align: 'center', }, { - title: t('views.traceManage.analysis.imsi'), - dataIndex: 'imsi', + title: '登录账号', + dataIndex: 'accountName', align: 'center', }, { - title: t('views.traceManage.analysis.msisdn'), - dataIndex: 'msisdn', + title: '用户类型', + dataIndex: 'accountType', align: 'center', }, { - title: t('views.traceManage.analysis.srcIp'), - dataIndex: 'srcAddr', + title: '源IP地址', + dataIndex: 'opIp', align: 'center', }, { - title: t('views.traceManage.analysis.dstIp'), - dataIndex: 'dstAddr', + title: '操作对象', + dataIndex: 'subsysTag', align: 'center', }, { - title: t('views.traceManage.analysis.signalType'), - dataIndex: 'ifType', + title: '操作类型', + dataIndex: 'opType', align: 'center', }, { - title: t('views.traceManage.analysis.msgType'), - dataIndex: 'msgType', + title: '操作内容', + dataIndex: 'opContent', align: 'center', }, { - title: t('views.traceManage.analysis.msgDirect'), - dataIndex: 'msgDirect', + title: '操作结果', + dataIndex: 'opResult', align: 'center', }, { - title: t('views.traceManage.analysis.rowTime'), - dataIndex: 'timestamp', + title: '开始时间', + dataIndex: 'beginTime', align: 'center', customRender(opt) { if (!opt.value) return ''; @@ -113,9 +114,23 @@ let tableColumns: ColumnsType = [ }, }, { - title: t('common.operate'), - key: 'id', + title: '结束时间', + dataIndex: 'endTime', align: 'center', + customRender(opt) { + if (!opt.value) return ''; + return parseDateToStr(opt.value); + }, + }, + { + title: '网元虚拟化标识', + dataIndex: 'vnfFlag', + align: 'center', + customRender(opt) { + if (opt.value === 0) return 'PNF'; + if (opt.value === 1) return 'VNF'; + return ''; + }, }, ]; @@ -156,7 +171,7 @@ function fnTableSize({ key }: MenuInfo) { function fnGetList() { if (tableState.loading) return; tableState.loading = true; - listTraceData(toRaw(queryParams)).then(res => { + listOperationLog(toRaw(queryParams)).then(res => { console.log(res); if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) { tablePagination.total = res.total; @@ -166,143 +181,6 @@ function fnGetList() { }); } -/**抽屉对象信息状态类型 */ -type ModalStateType = { - /**抽屉框是否显示 */ - visible: boolean; - /**标题 */ - title: string; - /**表单数据 */ - from: Record; -}; - -/**抽屉对象信息状态 */ -let modalState: ModalStateType = reactive({ - visible: false, - title: '', - from: { - rawData: '', - rawDataHTML: '', - downBtn: false, - }, -}); - -/** - * 对话框弹出显示 - * @param row 记录信息 - */ -function fnModalVisible(row: Record) { - // 进制转数据 - const hexString = parseBase64Data(row.rawMsg); - const rawData = convertToReadableFormat(hexString); - modalState.from.rawData = rawData; - // RAW解析HTML - getTraceRawInfo(row.id).then(res => { - if (res.code === RESULT_CODE_SUCCESS) { - const htmlString = res.msg; - // 删除所有 标签 - const withoutATags = htmlString.replace(/]*>(.*?)<\/a>/gi, ''); - // 删除所有