fix: 上传切片文件并发送文件到网元端
This commit is contained in:
@@ -51,15 +51,3 @@ export async function sendMMlByNE(
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送文件到网元端
|
||||
* @returns object
|
||||
*/
|
||||
export function transferToNeFile(data: Record<string, any>) {
|
||||
return request({
|
||||
url: `/ne/action/pushFile`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { RESULT_CODE_ERROR, RESULT_CODE_SUCCESS, RESULT_MSG_ERROR } from '@/constants/result-constants';
|
||||
import {
|
||||
RESULT_CODE_ERROR,
|
||||
RESULT_CODE_SUCCESS,
|
||||
RESULT_MSG_ERROR,
|
||||
} from '@/constants/result-constants';
|
||||
import { request, language } from '@/plugins/http-fetch';
|
||||
import { encode } from 'js-base64';
|
||||
|
||||
@@ -194,3 +198,33 @@ export function chunkUpload(data: FormData) {
|
||||
dataType: 'form-data',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传切片文件并发送文件到网元端
|
||||
* @param neType 网元类型, UPF
|
||||
* @param neId 网元标识, 001
|
||||
* @param fileData 文件对象
|
||||
* @param chunkSize 数据块大小MB,默认1MB
|
||||
* @returns
|
||||
*/
|
||||
export async function uploadFileToNE(
|
||||
neType: string,
|
||||
neId: string,
|
||||
fileData: File,
|
||||
chunkSize: number = 1
|
||||
) {
|
||||
const uploadChunkRes = await uploadFileChunk(fileData, chunkSize, 'import');
|
||||
if (uploadChunkRes.code === RESULT_CODE_SUCCESS) {
|
||||
const transferToNeFileRes = await request({
|
||||
url: `/ne/action/pushFile`,
|
||||
method: 'post',
|
||||
data: {
|
||||
uploadPath: uploadChunkRes.data.fileName,
|
||||
neType,
|
||||
neId,
|
||||
},
|
||||
});
|
||||
return transferToNeFileRes;
|
||||
}
|
||||
return uploadChunkRes;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ 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 { uploadFileToNE } from '@/api/tool/file';
|
||||
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -177,20 +176,8 @@ function fnUpload(up: UploadRequestOption, name: string) {
|
||||
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;
|
||||
}
|
||||
})
|
||||
const [neType, neId] = state.neType;
|
||||
uploadFileToNE(neType, neId, up.file as File, 5)
|
||||
.then(res => {
|
||||
// 文件转存
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
|
||||
@@ -8,8 +8,7 @@ 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 { uploadFileToNE } from '@/api/tool/file';
|
||||
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -173,19 +172,7 @@ function fnUpload(up: UploadRequestOption, name: string) {
|
||||
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;
|
||||
}
|
||||
})
|
||||
uploadFileToNE('OMC', state.neId, up.file as File, 5)
|
||||
.then(res => {
|
||||
// 文件转存
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
|
||||
@@ -9,8 +9,7 @@ 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';
|
||||
import { uploadFileToNE } from '@/api/tool/file';
|
||||
const { t } = useI18n();
|
||||
|
||||
/**网元参数 */
|
||||
@@ -173,19 +172,7 @@ function fnUpload(up: UploadRequestOption, name: string) {
|
||||
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;
|
||||
}
|
||||
})
|
||||
uploadFileToNE('UDM', state.neId, up.file as File, 5)
|
||||
.then(res => {
|
||||
// 文件转存
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
|
||||
Reference in New Issue
Block a user