feat: MML操作支持多条发送/文件上传到网元
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted, toRaw } from 'vue';
|
||||
import { PageContainer } from '@ant-design-vue/pro-layout';
|
||||
import { message } from 'ant-design-vue/lib';
|
||||
import { Modal, message } from 'ant-design-vue/lib';
|
||||
import CodemirrorEdite from '@/components/CodemirrorEdite/index.vue';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import useNeInfoStore from '@/store/modules/neinfo';
|
||||
import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { getMMLByNE, sendMMlByNE } from '@/api/mmlManage/neOperate';
|
||||
import { transferToNeFile } from '@/api/mmlManage/neOperate';
|
||||
import { uploadFileChunk } from '@/api/tool/file';
|
||||
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||
const { t } = useI18n();
|
||||
|
||||
/**网元参数 */
|
||||
@@ -48,6 +51,7 @@ let state: StateType = reactive({
|
||||
param: [],
|
||||
},
|
||||
from: {
|
||||
uploadLoading: false,
|
||||
sendLoading: false,
|
||||
},
|
||||
autoCompleteValue: '',
|
||||
@@ -88,7 +92,7 @@ function fnSendMML() {
|
||||
return;
|
||||
}
|
||||
|
||||
let cmdStr = '';
|
||||
let cmdArr: string[] = [];
|
||||
const operation = state.mmlSelect.operation;
|
||||
const object = state.mmlSelect.object;
|
||||
// 根据参数取值
|
||||
@@ -126,6 +130,7 @@ function fnSendMML() {
|
||||
|
||||
// 拼装命令
|
||||
const argsStr = argsArr.join(',');
|
||||
let cmdStr = '';
|
||||
if (object && argsStr) {
|
||||
cmdStr = `${operation} ${object} ${argsStr}`;
|
||||
} else if (object) {
|
||||
@@ -133,35 +138,76 @@ function fnSendMML() {
|
||||
} else {
|
||||
cmdStr = `${operation} ${argsStr}`;
|
||||
}
|
||||
cmdStr = cmdStr.trim();
|
||||
cmdArr = [cmdStr.trim()];
|
||||
}
|
||||
|
||||
if (cmdStr) {
|
||||
state.autoCompleteValue = cmdStr;
|
||||
if (cmdArr.length > 0) {
|
||||
state.autoCompleteValue = cmdArr[0];
|
||||
} else {
|
||||
let value = state.autoCompleteValue;
|
||||
if (value.indexOf('\n') !== -1) {
|
||||
value = value.replace(/(\r\n|\n)/g, ';');
|
||||
}
|
||||
cmdStr = value;
|
||||
cmdArr = value.split(';');
|
||||
}
|
||||
|
||||
// 发送
|
||||
state.mmlCmdLog += `${cmdStr}\n`;
|
||||
state.mmlCmdLog += `${cmdArr.join('\n')}\n`;
|
||||
state.from.sendLoading = true;
|
||||
const [neType, neId] = state.neType;
|
||||
sendMMlByNE(neType, neId, cmdStr).then(res => {
|
||||
sendMMlByNE(neType, neId, cmdArr).then(res => {
|
||||
state.from.sendLoading = false;
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
let resultStr = res.data;
|
||||
resultStr = resultStr.replace(/(\r\n|\n)/g, '\n');
|
||||
state.mmlCmdLog += `${resultStr}\n`;
|
||||
let resultArr = res.data;
|
||||
for (const str of resultArr) {
|
||||
const logStr = str.replace(/(\r\n|\n)/g, '\n');
|
||||
state.mmlCmdLog += `${logStr}\n`;
|
||||
}
|
||||
} else {
|
||||
state.mmlCmdLog += `${res.msg}\n`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**上传变更 */
|
||||
function fnUpload(up: UploadRequestOption, name: string) {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.mmlManage.uploadFileTip'),
|
||||
onOk() {
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
state.from.uploadLoading = true;
|
||||
uploadFileChunk(up.file as File, 5, 'import')
|
||||
.then(res => {
|
||||
// 文件上传
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
const [neType, neId] = state.neType;
|
||||
return transferToNeFile({
|
||||
uploadPath: res.data.fileName,
|
||||
neType: neType,
|
||||
neId: neId,
|
||||
});
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
// 文件转存
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success(t('views.mmlManage.uploadFileOk'), 3);
|
||||
state.from[name] = res.data;
|
||||
} else {
|
||||
message.error(res.msg, 3);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
state.from.uploadLoading = false;
|
||||
hide();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**规则校验 */
|
||||
function ruleVerification(
|
||||
row: Record<string, any>,
|
||||
@@ -588,6 +634,29 @@ onMounted(() => {
|
||||
{{ k }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
<a-input-group compact v-else-if="item.type === 'file'">
|
||||
<a-input
|
||||
v-model:value="state.from[item.name]"
|
||||
style="width: calc(100% - 32px)"
|
||||
/>
|
||||
<a-upload
|
||||
name="file"
|
||||
list-type="text"
|
||||
:accept="item.filter"
|
||||
:max-count="1"
|
||||
:show-upload-list="false"
|
||||
:custom-request="v => fnUpload(v, item.name)"
|
||||
>
|
||||
<a-button
|
||||
type="primary"
|
||||
:loading="state.from.uploadLoading"
|
||||
>
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-input-group>
|
||||
<a-input
|
||||
v-else
|
||||
v-model:value="state.from[item.name]"
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted, toRaw } from 'vue';
|
||||
import { PageContainer } from '@ant-design-vue/pro-layout';
|
||||
import { message } from 'ant-design-vue/lib';
|
||||
import { Modal, message } from 'ant-design-vue/lib';
|
||||
import CodemirrorEdite from '@/components/CodemirrorEdite/index.vue';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import useNeInfoStore from '@/store/modules/neinfo';
|
||||
import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { getMMLByOMC, sendMMlByOMC } from '@/api/mmlManage/omcOperate';
|
||||
import { transferToNeFile } from '@/api/mmlManage/neOperate';
|
||||
import { uploadFileChunk } from '@/api/tool/file';
|
||||
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||
const { t } = useI18n();
|
||||
|
||||
/**网元参数 */
|
||||
@@ -45,6 +48,7 @@ let state: StateType = reactive({
|
||||
param: [],
|
||||
},
|
||||
from: {
|
||||
uploadLoading: false,
|
||||
sendLoading: false,
|
||||
},
|
||||
autoCompleteValue: '',
|
||||
@@ -85,7 +89,7 @@ function fnSendMML() {
|
||||
return;
|
||||
}
|
||||
|
||||
let cmdStr = '';
|
||||
let cmdArr: string[] = [];
|
||||
const operation = state.mmlSelect.operation;
|
||||
const object = state.mmlSelect.object;
|
||||
// 根据参数取值
|
||||
@@ -123,6 +127,7 @@ function fnSendMML() {
|
||||
|
||||
// 拼装命令
|
||||
const argsStr = argsArr.join(',');
|
||||
let cmdStr = '';
|
||||
if (object && argsStr) {
|
||||
cmdStr = `${operation} ${object}:${argsStr}`;
|
||||
} else if (object) {
|
||||
@@ -130,34 +135,74 @@ function fnSendMML() {
|
||||
} else {
|
||||
cmdStr = `${operation} ${argsStr}`;
|
||||
}
|
||||
cmdStr = cmdStr.trim();
|
||||
cmdArr = [cmdStr.trim()];
|
||||
}
|
||||
|
||||
if (cmdStr) {
|
||||
state.autoCompleteValue = cmdStr;
|
||||
if (cmdArr.length > 0) {
|
||||
state.autoCompleteValue = cmdArr[0];
|
||||
} else {
|
||||
let value = state.autoCompleteValue;
|
||||
if (value.indexOf('\n') !== -1) {
|
||||
value = value.replace(/(\r\n|\n)/g, ';');
|
||||
}
|
||||
cmdStr = value;
|
||||
cmdArr = value.split(';');
|
||||
}
|
||||
|
||||
// 发送
|
||||
state.mmlCmdLog += `${cmdStr}\n`;
|
||||
state.mmlCmdLog += `${cmdArr.join('\n')}\n`;
|
||||
state.from.sendLoading = true;
|
||||
sendMMlByOMC(state.neId, cmdStr).then(res => {
|
||||
sendMMlByOMC(state.neId, cmdArr).then(res => {
|
||||
state.from.sendLoading = false;
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
let resultStr = res.data;
|
||||
resultStr = resultStr.replace(/(\r\n|\n)/g, '\n');
|
||||
state.mmlCmdLog += `${resultStr}\n`;
|
||||
let resultArr = res.data;
|
||||
for (const str of resultArr) {
|
||||
const logStr = str.replace(/(\r\n|\n)/g, '\n');
|
||||
state.mmlCmdLog += `${logStr}\n`;
|
||||
}
|
||||
} else {
|
||||
state.mmlCmdLog += `${res.msg}\n`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**上传变更 */
|
||||
function fnUpload(up: UploadRequestOption, name: string) {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.mmlManage.uploadFileTip'),
|
||||
onOk() {
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
state.from.uploadLoading = true;
|
||||
uploadFileChunk(up.file as File, 5, 'import')
|
||||
.then(res => {
|
||||
// 文件上传
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
return transferToNeFile({
|
||||
uploadPath: res.data.fileName,
|
||||
neType: 'OMC',
|
||||
neId: state.neId,
|
||||
});
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
// 文件转存
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success(t('views.mmlManage.uploadFileOk'), 3);
|
||||
state.from[name] = res.data;
|
||||
} else {
|
||||
message.error(res.msg, 3);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
state.from.uploadLoading = false;
|
||||
hide();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**规则校验 */
|
||||
function ruleVerification(
|
||||
row: Record<string, any>,
|
||||
@@ -563,6 +608,29 @@ onMounted(() => {
|
||||
{{ k }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
<a-input-group compact v-else-if="item.type === 'file'">
|
||||
<a-input
|
||||
v-model:value="state.from[item.name]"
|
||||
style="width: calc(100% - 32px)"
|
||||
/>
|
||||
<a-upload
|
||||
name="file"
|
||||
list-type="text"
|
||||
:accept="item.filter"
|
||||
:max-count="1"
|
||||
:show-upload-list="false"
|
||||
:custom-request="v => fnUpload(v, item.name)"
|
||||
>
|
||||
<a-button
|
||||
type="primary"
|
||||
:loading="state.from.uploadLoading"
|
||||
>
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-input-group>
|
||||
<a-input
|
||||
v-else
|
||||
v-model:value="state.from[item.name]"
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted, toRaw } from 'vue';
|
||||
import { PageContainer } from '@ant-design-vue/pro-layout';
|
||||
import { message } from 'ant-design-vue/lib';
|
||||
import { Modal, message } from 'ant-design-vue/lib';
|
||||
import CodemirrorEdite from '@/components/CodemirrorEdite/index.vue';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import useNeInfoStore from '@/store/modules/neinfo';
|
||||
import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { getMMLByUDM, sendMMlByUDM } from '@/api/mmlManage/udmOperate';
|
||||
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||
import { uploadFileChunk } from '@/api/tool/file';
|
||||
import { transferToNeFile } from '@/api/mmlManage/neOperate';
|
||||
const { t } = useI18n();
|
||||
|
||||
/**网元参数 */
|
||||
@@ -45,6 +48,7 @@ let state: StateType = reactive({
|
||||
param: [],
|
||||
},
|
||||
from: {
|
||||
uploadLoading: false,
|
||||
sendLoading: false,
|
||||
},
|
||||
autoCompleteValue: '',
|
||||
@@ -85,7 +89,7 @@ function fnSendMML() {
|
||||
return;
|
||||
}
|
||||
|
||||
let cmdStr = '';
|
||||
let cmdArr: string[] = [];
|
||||
const operation = state.mmlSelect.operation;
|
||||
const object = state.mmlSelect.object;
|
||||
// 根据参数取值
|
||||
@@ -123,6 +127,7 @@ function fnSendMML() {
|
||||
|
||||
// 拼装命令
|
||||
const argsStr = argsArr.join(',');
|
||||
let cmdStr = '';
|
||||
if (object && argsStr) {
|
||||
cmdStr = `${operation} ${object}:${argsStr}`;
|
||||
} else if (object) {
|
||||
@@ -130,34 +135,74 @@ function fnSendMML() {
|
||||
} else {
|
||||
cmdStr = `${operation} ${argsStr}`;
|
||||
}
|
||||
cmdStr = cmdStr.trim();
|
||||
cmdArr = [cmdStr.trim()];
|
||||
}
|
||||
|
||||
if (cmdStr) {
|
||||
state.autoCompleteValue = cmdStr;
|
||||
if (cmdArr.length > 0) {
|
||||
state.autoCompleteValue = cmdArr[0];
|
||||
} else {
|
||||
let value = state.autoCompleteValue;
|
||||
if (value.indexOf('\n') !== -1) {
|
||||
value = value.replace(/(\r\n|\n)/g, ';');
|
||||
}
|
||||
cmdStr = value;
|
||||
cmdArr = value.split(';');
|
||||
}
|
||||
|
||||
// 发送
|
||||
state.mmlCmdLog += `${cmdStr}\n`;
|
||||
state.mmlCmdLog += `${cmdArr.join('\n')}\n`;
|
||||
state.from.sendLoading = true;
|
||||
sendMMlByUDM(state.neId, cmdStr).then(res => {
|
||||
sendMMlByUDM(state.neId, cmdArr).then(res => {
|
||||
state.from.sendLoading = false;
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
let resultStr = res.data;
|
||||
resultStr = resultStr.replace(/(\r\n|\n)/g, '\n');
|
||||
state.mmlCmdLog += `${resultStr}\n`;
|
||||
let resultArr = res.data;
|
||||
for (const str of resultArr) {
|
||||
const logStr = str.replace(/(\r\n|\n)/g, '\n');
|
||||
state.mmlCmdLog += `${logStr}\n`;
|
||||
}
|
||||
} else {
|
||||
state.mmlCmdLog += `${res.msg}\n`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**上传变更 */
|
||||
function fnUpload(up: UploadRequestOption, name: string) {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.mmlManage.uploadFileTip'),
|
||||
onOk() {
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
state.from.uploadLoading = true;
|
||||
uploadFileChunk(up.file as File, 5, 'import')
|
||||
.then(res => {
|
||||
// 文件上传
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
return transferToNeFile({
|
||||
uploadPath: res.data.fileName,
|
||||
neType: 'UDM',
|
||||
neId: state.neId,
|
||||
});
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
// 文件转存
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success(t('views.mmlManage.uploadFileOk'), 3);
|
||||
state.from[name] = res.data;
|
||||
} else {
|
||||
message.error(res.msg, 3);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
state.from.uploadLoading = false;
|
||||
hide();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**规则校验 */
|
||||
function ruleVerification(
|
||||
row: Record<string, any>,
|
||||
@@ -563,6 +608,29 @@ onMounted(() => {
|
||||
{{ k }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
<a-input-group compact v-else-if="item.type === 'file'">
|
||||
<a-input
|
||||
v-model:value="state.from[item.name]"
|
||||
style="width: calc(100% - 32px)"
|
||||
/>
|
||||
<a-upload
|
||||
name="file"
|
||||
list-type="text"
|
||||
:accept="item.filter"
|
||||
:max-count="1"
|
||||
:show-upload-list="false"
|
||||
:custom-request="v => fnUpload(v, item.name)"
|
||||
>
|
||||
<a-button
|
||||
type="primary"
|
||||
:loading="state.from.uploadLoading"
|
||||
>
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-input-group>
|
||||
<a-input
|
||||
v-else
|
||||
v-model:value="state.from[item.name]"
|
||||
|
||||
Reference in New Issue
Block a user