From 800547d1ef1cc38344b8b2ecbe14277109700fe6 Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Fri, 8 Nov 2024 12:00:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8C=87=E6=A0=87?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/locales/en-US.ts | 3 + src/i18n/locales/zh-CN.ts | 3 + src/views/perfManage/customTarget/index.vue | 233 +++++++++++--------- 3 files changed, 133 insertions(+), 106 deletions(-) diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 47d8c18e..6e4af64b 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -1079,6 +1079,9 @@ export default { element:'Element', granularity:'Granularity', unit:'Unit', + expressionModal:'Expression Modal', + expressionErrorTip:'Please check the expression, the wrong indicator is {kpiId}', + expressionNoIdTip:'Please check the expression, no valid indicator is found', }, kpiKeyTarget:{ "fullWidthLayout":"Full Width", diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index df937e84..494c1dff 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -1079,6 +1079,9 @@ export default { element:'元素', granularity:'颗粒度', unit:'单位', + expressionModal:'表达式模块', + expressionErrorTip:'请检查表达式,错误的指标为{kpiId}', + expressionNoIdTip:'请检查表达式,没有找到任何有效的指标', }, kpiKeyTarget:{ "fullWidthLayout":"全宽布局", diff --git a/src/views/perfManage/customTarget/index.vue b/src/views/perfManage/customTarget/index.vue index e9daa452..892e3abf 100644 --- a/src/views/perfManage/customTarget/index.vue +++ b/src/views/perfManage/customTarget/index.vue @@ -218,6 +218,8 @@ type ModalStateType = { neTypPerformance: Record[]; /**已选择性能测量项 */ selectedPre: string[]; + /** 元素选择*/ + elemSelect: any; /**表单数据 */ from: Record; /**确定按钮 loading */ @@ -232,10 +234,10 @@ let modalState: ModalStateType = reactive({ neType: [], neTypPerformance: [], selectedPre: [], + elemSelect: '', from: { id: undefined, neType: 'UDM', - kpiId: '', title: '', expression: '', status: 'Active', @@ -275,13 +277,6 @@ const modalStateFrom = Form.useForm( t('common.unableNull'), }, ], - kpiId: [ - { - required: true, - message: - t('views.perfManage.customTarget.kpiId') + t('common.unableNull'), - }, - ], title: [ { required: true, @@ -302,6 +297,7 @@ const modalStateFrom = Form.useForm( /**性能测量数据集选择初始 value:neType*/ function fnSelectPerformanceInit(value: any) { modalState.from.expression = ''; + modalState.elemSelect = ''; modalState.neTypPerformance = [ { value: 'granularity', @@ -356,7 +352,33 @@ function fnModalVisibleByEdit(row?: any, id?: any) { function fnModalOk() { modalStateFrom .validate() - .then(e => { + .then((e: any) => { + const matches = modalState.from.expression.match(/'([^']+)'/g); // 提取单引号内容 + // 替换为对应的 value + let result = modalState.from.expression; + + if (matches) { + matches.forEach((match: any) => { + const valueToReplace = match.slice(1, -1); // 去掉单引号 + const found = modalState.neTypPerformance.find( + (item: any) => item.label === valueToReplace + ); + if (found) { + result = result.replace(match, `'${found.value}'`); // 替换为对应的 value + } else { + message.error( + t('views.perfManage.customTarget.expressionErrorTip', { + kpiId: valueToReplace, + }), + 3 + ); + return false; + } + }); + } else { + message.error(t('views.perfManage.customTarget.expressionNoIdTip'), 3); + } + const from = toRaw(modalState.from); //return false; modalState.confirmLoading = true; @@ -405,12 +427,20 @@ function fnModalCancel() { * 选择性能指标,填充进当前计算公式的值 */ function fnSelectPer(s: any, option: any) { - modalState.from.expression += `'${s}'`; + console.log(option); + modalState.from.expression += `'${option.label}'`; } function fnSelectSymbol(s: any) { modalState.from.expression += s; } + +function fnChangeUnit(value: any) { + if (value === '%' && modalState.from.expression) { + modalState.from.expression = `(${modalState.from.expression})*100`; + } +} + /**网元参数 */ let neCascaderOptions = ref[]>([]); onMounted(() => { @@ -634,102 +664,6 @@ onMounted(() => { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { + + + + + + + + + {{ + t('views.perfManage.customTarget.expressionModal') + }} + + + + + + + + + + + + + + + + + + + + + + + + + +