diff --git a/src/api/perfManage/customTarget.ts b/src/api/perfManage/customTarget.ts index 4134a0fd..ac3b9ab6 100644 --- a/src/api/perfManage/customTarget.ts +++ b/src/api/perfManage/customTarget.ts @@ -8,57 +8,72 @@ 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 '; +// 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 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} `; +// // 排序 +// 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 query 查询参数 + * @returns object + */ +export async function listCustom(query?: Record) { // 发起请求 const result = await request({ - url: `/api/rest/databaseManagement/v1/select/omc_db/pm_custom_title`, + url: `/pm/kpiC/title/totalList`, method: 'get', - params: { - totalSQL: totalSQL + querySQL, - rowsSQL: rowsSQL + querySQL + sortSql + limtSql, - }, + params: query, }); - - // 解析数据 - 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; } @@ -68,22 +83,10 @@ export async function listCustom(query: Record) { * @returns object */ export async function getCustom(id: string | number) { - // 发起请求 - const result = await request({ - url: `/api/rest/databaseManagement/v1/select/omc_db/pm_custom_title`, + return request({ + url: `/pm/kpiC/title/${id}`, 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; } /** @@ -92,21 +95,10 @@ export async function getCustom(id: string | number) { * @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`, + url: `/pm/kpiC/title`, method: 'post', - data: { 'data': [obj] }, + data: data, }); } @@ -116,20 +108,10 @@ export function addCustom(data: Record) { * @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}`, + url: `/pm/kpiC/title/${data.id}`, method: 'put', - data: { data: obj }, + data: data, }); } @@ -139,8 +121,7 @@ export function updateCustom(data: Record) { */ export async function delCustom(data: Record) { return request({ - url: `/api/rest/databaseManagement/v1/omc_db/pm_custom_title?WHERE=id=${data.id}`, + url: `/pm/kpiC/title/${data.id}`, method: 'delete', }); } - diff --git a/src/views/perfManage/customTarget/index.vue b/src/views/perfManage/customTarget/index.vue index 2c5b78f3..21ec15dd 100644 --- a/src/views/perfManage/customTarget/index.vue +++ b/src/views/perfManage/customTarget/index.vue @@ -7,8 +7,8 @@ import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface'; import { ColumnsType } from 'ant-design-vue/lib/table'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import useI18n from '@/hooks/useI18n'; -import useDictStore from '@/store/modules/dict'; import useNeInfoStore from '@/store/modules/neinfo'; +import { parseObjLineToHump } from '@/utils/parse-utils'; import { addCustom, delCustom, @@ -16,15 +16,17 @@ import { listCustom, updateCustom, } from '@/api/perfManage/customTarget'; -const { getDict } = useDictStore(); +import { getKPITitle } from '@/api/perfManage/goldTarget'; +import useDictStore from '@/store/modules/dict'; const { t, currentLocale } = useI18n(); +const { getDict } = useDictStore(); /**字典数据 */ let dict: { - /**原始严重程度 */ - activeAlarmSeverity: DictType[]; + /**状态 */ + sysNormalDisable: DictType[]; } = reactive({ - activeAlarmSeverity: [], + sysNormalDisable: [], }); /**查询参数 */ @@ -85,15 +87,22 @@ let tableColumns: ColumnsType = [ align: 'center', }, { - title: t('views.perfManage.customTarget.kpiSet'), - dataIndex: 'kpiSet', + title: t('views.perfManage.customTarget.title'), + dataIndex: 'title', align: 'center', }, { - title: t('views.perfManage.customTarget.period'), - dataIndex: 'threshold', + title: t('views.perfManage.customTarget.description'), + dataIndex: 'description', align: 'center', }, + { + title: t('views.perfManage.customTarget.status'), + dataIndex: 'status', + key: 'status', + align: 'left', + width: 100, + }, { title: t('common.operate'), key: 'id', @@ -175,13 +184,14 @@ function fnGetList(pageNum?: number) { queryParams.pageNum = pageNum; } listCustom(toRaw(queryParams)).then(res => { - if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) { + if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { // 取消勾选 if (tableState.selectedRowKeys.length > 0) { tableState.selectedRowKeys = []; } tablePagination.total = res.total; - tableState.data = res.rows; + tableState.data = res.data; + if ( tablePagination.total <= (queryParams.pageNum - 1) * tablePagination.pageSize && @@ -207,8 +217,6 @@ type ModalStateType = { neType: string[]; /**网元类型性能测量集 */ neTypPerformance: Record[]; - /**网元类型对象类型集 */ - objectTypeArr: Record[]; /**已选择性能测量项 */ selectedPre: string[]; /**表单数据 */ @@ -224,21 +232,32 @@ let modalState: ModalStateType = reactive({ title: '', neType: [], neTypPerformance: [], - objectTypeArr: [], selectedPre: [], from: { - id: '', - neType: '', - objectType: '', - expression: '', - kpiSet: '', - title: '', + id: undefined, + neType: 'UDM', kpiId: '', - period: 900, + title: '', + expression: '', + status: 'Active', + unit: '', + description: '', }, confirmLoading: false, }); +/**表单中多选的OPTION */ +const modalStateFromOption = reactive({ + symbolJson: [ + { label: '(', value: '(' }, + { label: ')', value: ')' }, + { label: '+', value: '+' }, + { label: '-', value: '-' }, + { label: '*', value: '*' }, + { label: '/', value: '/' }, + ], +}); + /**对话框内表单属性和校验规则 */ const modalStateFrom = Form.useForm( modalState.from, @@ -249,14 +268,6 @@ const modalStateFrom = Form.useForm( message: t('views.traceManage.task.neTypePlease'), }, ], - objectType: [ - { - required: true, - message: - t('views.perfManage.customTarget.objectType') + - t('common.unableNull'), - }, - ], expression: [ { required: true, @@ -279,60 +290,33 @@ const modalStateFrom = Form.useForm( t('views.perfManage.customTarget.title') + t('common.unableNull'), }, ], - period: [ - { - required: true, - message: - t('views.perfManage.customTarget.period') + t('common.unableNull'), - }, - ], }) ); -/**性能测量数据集选择初始 */ +/**性能测量数据集选择初始 value:neType*/ function fnSelectPerformanceInit(value: any) { - const performance = useNeInfoStore().perMeasurementList.filter( - i => i.neType === value - ); - if (modalState.from.objectType) modalState.from.objectType = ''; - if (modalState.selectedPre.length > 0) modalState.selectedPre = []; - modalState.from.expression = ''; - const arrSet = new Set(); - performance.forEach((data: any) => { - arrSet.add(data.objectType); - }); - // 组装对象类型options - modalState.objectTypeArr = Array.from(arrSet).map((value: any) => ({ - label: value, - value: value, - })); - - //进行分组选择 - const groupedData = performance.reduce((groups: any, item: any) => { - const { kpiCode, ...rest } = item; - if (!groups[kpiCode]) { - groups[kpiCode] = []; + modalState.neTypPerformance = [{value:'granularity',label:t('views.perfManage.customTarget.granularity')}]; + // 当前语言 + var language = currentLocale.value.split('_')[0]; + if (language === 'zh') language = 'cn'; + // 获取表头文字 + getKPITitle(value).then(res => { + if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { + for (const item of res.data) { + const kpiDisplay = item[`${language}Title`]; + const kpiValue = item[`kpiId`]; + modalState.neTypPerformance.push({ + value: kpiValue, + label: kpiDisplay, + }); + } + } else { + message.warning({ + content: t('common.getInfoFail'), + duration: 2, + }); } - groups[kpiCode].push(rest); - return groups; - }, {}); - - //渲染出性能测量集的选择项 - modalState.neTypPerformance = Object.keys(groupedData).map(kpiCode => { - return { - label: kpiCode, - options: groupedData[kpiCode].map((item: any) => { - return { - value: item.kpiId, - label: - currentLocale.value === 'zh_CN' - ? JSON.parse(item.titleJson).cn - : JSON.parse(item.titleJson).en, - kpiCode: kpiCode, - }; - }), - }; }); } @@ -340,30 +324,17 @@ function fnSelectPerformanceInit(value: any) { * 对话框弹出显示为 新增或者修改 * @param noticeId 网元id, 不传为新增 */ -function fnModalVisibleByEdit(id?: string) { +function fnModalVisibleByEdit(row?: any, id?: any) { if (!id) { modalStateFrom.resetFields(); modalState.title = t('views.perfManage.customTarget.addCustom'); modalState.visibleByEdit = true; + fnSelectPerformanceInit(modalState.from.neType); } else { - if (modalState.confirmLoading) return; - const hide = message.loading(t('common.loading'), 0); - modalState.confirmLoading = true; - getCustom(id).then(res => { - modalState.confirmLoading = false; - hide(); - if (res.code === RESULT_CODE_SUCCESS && res.data) { - fnSelectPerformanceInit(res.data.neType); - modalState.selectedPre = res.data.kpiSet - ? res.data.kpiSet.split(',') - : []; - modalState.from = Object.assign(modalState.from, res.data); - modalState.title = t('views.perfManage.customTarget.editCustom'); - modalState.visibleByEdit = true; - } else { - message.error(t('views.perfManage.customTarget.errorCustomInfo'), 3); - } - }); + fnSelectPerformanceInit(row.neType); + modalState.from = Object.assign(modalState.from, row); + modalState.title = t('views.perfManage.customTarget.editCustom'); + modalState.visibleByEdit = true; } } @@ -375,13 +346,6 @@ function fnModalOk() { modalStateFrom .validate() .then(e => { - // if (modalState.selectedPre.length === 0) { - // message.error({ - // content: `${res.msg}`, - // duration: 3, - // }); - // } - modalState.from.kpiSet = modalState.selectedPre.join(','); const from = toRaw(modalState.from); //return false; modalState.confirmLoading = true; @@ -424,46 +388,57 @@ function fnModalCancel() { modalStateFrom.resetFields(); modalState.neType = []; modalState.neTypPerformance = []; - modalState.selectedPre = []; } /** * 选择性能指标,填充进当前计算公式的值 */ function fnSelectPer(s: any, option: any) { + modalState.from.expression += `'${s}'`; +} + +function fnSelectSymbol(s: any) { modalState.from.expression += s; } - -/** - * 多选框取消性能指标 表达式的变化 - */ -function fnDelPer(s: any, option: any) { - modalState.from.expression = modalState.from.expression.replace(s, ''); -} - -// function checkText(e:any){ -// console.log(e); -// const reg = /^[*+-/]*$/; - -// } - +/**网元参数 */ +let neCascaderOptions = ref[]>([]); onMounted(() => { - // 初始字典数据 - Promise.allSettled([getDict('active_alarm_severity')]).then(resArr => { - if (resArr[0].status === 'fulfilled') { - dict.activeAlarmSeverity = resArr[0].value; - } - }); - Promise.allSettled([ // 获取网元网元列表 + getDict('sys_normal_disable'), useNeInfoStore().fnNelist(), - // 获取性能测量集列表 - useNeInfoStore().fnNeTaskPerformance(), - ]).finally(() => { - // 获取列表数据 - fnGetList(); - }); + ]) + .then(resArr => { + if (resArr[0].status === 'fulfilled') { + dict.sysNormalDisable = resArr[0].value; + } + + if ( + resArr[1].status === 'fulfilled' && + Array.isArray(resArr[1].value.data) + ) { + if (resArr[1].value.data.length > 0) { + // 过滤不可用的网元 + neCascaderOptions.value = + useNeInfoStore().getNeCascaderOptions.filter((item: any) => { + return !['OMC', 'NSSF', 'NEF', 'NRF', 'LMF', 'N3IWF'].includes( + item.value + ); + }); + if (neCascaderOptions.value.length === 0) { + message.warning({ + content: t('common.noData'), + duration: 2, + }); + return; + } + } + } + }) + .finally(() => { + // 获取列表数据 + fnGetList(); + }); }); @@ -484,7 +459,7 @@ onMounted(() => { > @@ -580,7 +555,7 @@ onMounted(() => { @@ -593,6 +568,24 @@ onMounted(() => { + + @@ -610,7 +603,12 @@ onMounted(() => { @ok="fnModalOk" @cancel="fnModalCancel" > - + { > { - + @@ -646,6 +649,16 @@ onMounted(() => { + + + + + + { - - - - - - - - - - + + + - - + + + + + + + @@ -714,6 +729,7 @@ onMounted(() => {