feat: MML管理功能
This commit is contained in:
@@ -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 { Form, message } from 'ant-design-vue/lib';
|
||||
import { message } from 'ant-design-vue/lib';
|
||||
import CodemirrorEdite from '@/components/CodemirrorEdite/index.vue';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { getOperationSet, updateOperationSet } from '@/api/mmlManage/mmlSet';
|
||||
import useNeInfoStore from '@/store/modules/neinfo';
|
||||
import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { getSubscriberByUDM, sendMMlByUDM } from '@/api/mmlManage/udmOperate';
|
||||
import { number } from 'echarts/core';
|
||||
import { getMMLByUDM, sendMMlByUDM } from '@/api/mmlManage/udmOperate';
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
@@ -78,12 +76,20 @@ function fnSendMML() {
|
||||
const param = toRaw(state.mmlSelect.param) || [];
|
||||
const from = toRaw(state.from);
|
||||
for (const item of param) {
|
||||
// 检查是否存在值
|
||||
const hasV = Reflect.has(from, item.name) && !!from[item.name];
|
||||
if (!hasV) {
|
||||
const value = from[item.name];
|
||||
|
||||
// 是否必填项且有效值
|
||||
const notV = value === null || value === undefined || value === '';
|
||||
if (item.optional === 'false' && notV) {
|
||||
message.warning(`必填参数:${item.display}`, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否存在值
|
||||
if (!Reflect.has(from, item.name) || notV) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查规则
|
||||
const [ok, msg] = ruleVerification(item, from[item.name]);
|
||||
if (!ok) {
|
||||
@@ -93,6 +99,7 @@ function fnSendMML() {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
argsArr.push(`${item.name}=${from[item.name]}`);
|
||||
}
|
||||
|
||||
@@ -105,6 +112,7 @@ function fnSendMML() {
|
||||
} else {
|
||||
cmdStr = `${operation} ${argsStr}`;
|
||||
}
|
||||
cmdStr = cmdStr.trim();
|
||||
|
||||
// 发送
|
||||
state.mmlCmdLog += `$> ${cmdStr}\n`;
|
||||
@@ -137,7 +145,6 @@ function ruleVerification(
|
||||
const filterArr = filter.split('~');
|
||||
const minInt = parseInt(filterArr[0]);
|
||||
const maxInt = parseInt(filterArr[1]);
|
||||
debugger;
|
||||
const valueInt = parseInt(value);
|
||||
if (valueInt < minInt || valueInt > maxInt) {
|
||||
return [false, `${display} 参数值不在合理范围 ${filter}`];
|
||||
@@ -220,7 +227,7 @@ function ruleVerification(
|
||||
|
||||
/**查询可选命令列表 */
|
||||
function fnGetList() {
|
||||
getSubscriberByUDM().then(res => {
|
||||
getMMLByUDM().then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||
// 构建树结构
|
||||
const treeArr: Record<string, any>[] = [];
|
||||
@@ -395,14 +402,14 @@ onMounted(() => {
|
||||
['string', 'ipv6', 'ipv4', 'regex'].includes(item.type)
|
||||
"
|
||||
v-model:value="state.from[item.name]"
|
||||
:placeholder="state.from[item.filter]"
|
||||
:placeholder="item.filter"
|
||||
></a-input>
|
||||
<a-input-number
|
||||
v-else-if="item.type === 'int'"
|
||||
v-model:value="state.from[item.name]"
|
||||
:min="0"
|
||||
:max="65535"
|
||||
:placeholder="state.from[item.filter]"
|
||||
:placeholder="item.filter"
|
||||
style="width: 100%"
|
||||
></a-input-number>
|
||||
<a-switch
|
||||
@@ -414,12 +421,13 @@ onMounted(() => {
|
||||
<a-select
|
||||
v-else-if="item.type === 'enum'"
|
||||
v-model:value="state.from[item.name]"
|
||||
:placeholder="state.from[item.filter]"
|
||||
:placeholder="item.filter"
|
||||
:allow-clear="true"
|
||||
>
|
||||
<a-select-option
|
||||
:value="+v"
|
||||
:key="+v"
|
||||
v-for="(k, v) in JSON.parse(state.from[item.filter])"
|
||||
:value="v"
|
||||
:key="v"
|
||||
v-for="(k, v) in JSON.parse(item.filter)"
|
||||
>
|
||||
{{ k }}
|
||||
</a-select-option>
|
||||
@@ -459,6 +467,7 @@ onMounted(() => {
|
||||
<CodemirrorEdite
|
||||
v-model:value="state.mmlCmdLog"
|
||||
:disabled="true"
|
||||
:editor-style="{ height: '500px !important' }"
|
||||
placeholder="等待发送命令"
|
||||
></CodemirrorEdite>
|
||||
</a-card>
|
||||
|
||||
Reference in New Issue
Block a user