From 92b2a4fb374a46d29c9027651d5e2e2d01ba0216 Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Thu, 29 Feb 2024 10:21:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8C=87=E6=A0=87?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/perfManage/customTarget.ts | 146 ++++ src/i18n/locales/en-US.ts | 14 + src/i18n/locales/zh-CN.ts | 16 +- src/views/perfManage/customTarget/index.vue | 741 ++++++++++++-------- 4 files changed, 642 insertions(+), 275 deletions(-) create mode 100644 src/api/perfManage/customTarget.ts diff --git a/src/api/perfManage/customTarget.ts b/src/api/perfManage/customTarget.ts new file mode 100644 index 00000000..4134a0fd --- /dev/null +++ b/src/api/perfManage/customTarget.ts @@ -0,0 +1,146 @@ +import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; +import { request } from '@/plugins/http-fetch'; +import { parseObjLineToHump } from '@/utils/parse-utils'; +import { parseDateToStr } from '@/utils/date-utils'; + +/** + * 查询自定义指标 + * @param query 查询参数 + * @returns object + */ +export async function listCustom(query: Record) { + let totalSQL = 'select count(*) as total from pm_custom_title where 1=1 '; + let rowsSQL = 'select * from pm_custom_title where 1=1 '; + + // 查询 + let querySQL = ''; + if (query.neType) { + querySQL += ` and ne_type like '%${query.neType}%' `; + } + + // 排序 + let sortSql = ' order by update_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: `/api/rest/databaseManagement/v1/select/omc_db/pm_custom_title`, + 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['pm_custom_title']; + if (Array.isArray(itemData)) { + if (itemData.length === 1 && itemData[0]['total'] >= 0) { + data.total = itemData[0]['total']; + } else { + data.rows = itemData.map(v => parseObjLineToHump(v)); + } + } + }); + return data; + } + return result; +} + +/** + * 查询自定义指标详细 + * @param id 网元ID + * @returns object + */ +export async function getCustom(id: string | number) { + // 发起请求 + const result = await request({ + url: `/api/rest/databaseManagement/v1/select/omc_db/pm_custom_title`, + method: 'get', + params: { + SQL: `select * from pm_custom_title where id = ${id}`, + }, + }); + // 解析数据 + if (result.code === RESULT_CODE_SUCCESS && Array.isArray(result.data.data)) { + let data = result.data.data[0]; + return Object.assign(result, { + data: parseObjLineToHump(data['pm_custom_title'][0]), + }); + } + return result; +} + +/** + * 新增自定义指标 + * @param data 网元对象 + * @returns object + */ +export function addCustom(data: Record) { + let obj: any = { + title: data.title, + ne_type: data.neType, + kpi_id: data.kpiId, + object_type: data.objectType, + expression: data.expression, + period: data.period, + description: data.description, + kpi_set: data.kpiSet, + }; + + return request({ + url: `/api/rest/databaseManagement/v1/omc_db/pm_custom_title`, + method: 'post', + data: { 'data': [obj] }, + }); +} + +/** + * 修改自定义指标 + * @param data 网元对象 + * @returns object + */ +export function updateCustom(data: Record) { + let obj: any = { + title: data.title, + ne_type: data.neType, + kpi_id: data.kpiId, + object_type: data.objectType, + expression: data.expression, + period: data.period, + description: data.description, + kpi_set: data.kpiSet, + }; + return request({ + url: `/api/rest/databaseManagement/v1/omc_db/pm_custom_title?WHERE=id=${data.id}`, + method: 'put', + data: { data: obj }, + }); +} + +/** + * 删除自定义指标 + * @returns object + */ +export async function delCustom(data: Record) { + return request({ + url: `/api/rest/databaseManagement/v1/omc_db/pm_custom_title?WHERE=id=${data.id}`, + method: 'delete', + }); +} + diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 107bd584..caaa78ad 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -765,6 +765,20 @@ export default { exportEmpty: "Export data is empty", showChartSelected: "Show All", realTimeData: "Real Time 5s Data", + }, + customTarget:{ + kpiId:' Custom Indicator', + period:' Granularity', + title:' Custom Indicator Title', + objectType:' Object type', + expression:'Expression', + description:' Description', + kpiSet:' Statistical Settings', + delCustomTip:'Confirm deletion of data item with record number {num}?', + delCustom:' Successfully delete record number {num} custom indicator', + addCustom:' Add custom indicator', + editCustom:' Edit Custom indicator', + errorCustomInfo: 'Failed to get information', } }, traceManage: { diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 64c78b3a..8fc27625 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -765,7 +765,21 @@ export default { exportEmpty: "导出数据为空", showChartSelected: "显示全部", realTimeData: "实时5s数据", - } + }, + customTarget:{ + kpiId:'自定义指标项', + period:'颗粒度', + title:'自定义指标项标题', + objectType:'对象类型', + expression:'计算公式', + description:'描述', + kpiSet:'统计设置', + delCustomTip:'确认删除记录编号为 {num} 的数据项?', + delCustom:'成功删除记录编号为 {num} 自定义指标', + addCustom:'添加自定义指标', + editCustom:'编辑自定义指标', + errorCustomInfo: '获取信息失败', + } }, traceManage: { analysis: { diff --git a/src/views/perfManage/customTarget/index.vue b/src/views/perfManage/customTarget/index.vue index aca5cddb..0eacb7da 100644 --- a/src/views/perfManage/customTarget/index.vue +++ b/src/views/perfManage/customTarget/index.vue @@ -1,23 +1,36 @@ @@ -354,26 +478,15 @@ onMounted(() => { - - - - - - + @@ -396,12 +509,17 @@ onMounted(() => { - +