feat: 网元软件包支持携带依赖进行记录
This commit is contained in:
@@ -17,3 +17,10 @@ export const NE_TYPE_LIST = [
|
|||||||
'MOCNGW',
|
'MOCNGW',
|
||||||
'SMSC',
|
'SMSC',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网元拓展包列表,默认顺序
|
||||||
|
* IMS-adb/rtproxy/mf
|
||||||
|
* UDM-adb
|
||||||
|
*/
|
||||||
|
export const NE_EXPAND_LIST = ['ADB', 'RTPROXY', 'MF'];
|
||||||
|
|||||||
@@ -704,7 +704,11 @@ export default {
|
|||||||
fileCheckType: 'The corresponding network element type is not resolved',
|
fileCheckType: 'The corresponding network element type is not resolved',
|
||||||
fileCheckVer: 'The corresponding version number is not resolved',
|
fileCheckVer: 'The corresponding version number is not resolved',
|
||||||
fileTypeNotEq: 'Not a specified network element type {txt}',
|
fileTypeNotEq: 'Not a specified network element type {txt}',
|
||||||
fileTypeExists: 'Same network element type file already exists',
|
fileTypeExists: 'Same type of file already exists',
|
||||||
|
fileNameExists: 'File with same name already exists',
|
||||||
|
fileCheckTypeDep: 'The specified dependency package type is not resolved',
|
||||||
|
dependFile: 'Software Dependencies',
|
||||||
|
dependFileTip: 'File name resolution is the same as above, and installation is based on the order of uploading.',
|
||||||
},
|
},
|
||||||
neVersion: {
|
neVersion: {
|
||||||
upgrade: "Upgrade To New Version",
|
upgrade: "Upgrade To New Version",
|
||||||
|
|||||||
@@ -704,7 +704,11 @@ export default {
|
|||||||
fileCheckType: '未解析出对应的网元类型',
|
fileCheckType: '未解析出对应的网元类型',
|
||||||
fileCheckVer: '未解析出对应的版本号',
|
fileCheckVer: '未解析出对应的版本号',
|
||||||
fileTypeNotEq: '不是指定网元类型 {txt}',
|
fileTypeNotEq: '不是指定网元类型 {txt}',
|
||||||
fileTypeExists: '已存在相同网元类型文件',
|
fileTypeExists: '已存在相同类型文件',
|
||||||
|
fileNameExists: '已存在相同名称文件',
|
||||||
|
fileCheckTypeDep: '未解析出对应指定的依赖包类型',
|
||||||
|
dependFile: '软件包依赖',
|
||||||
|
dependFileTip: '文件名解析同上,依据上传顺序安装',
|
||||||
},
|
},
|
||||||
neVersion: {
|
neVersion: {
|
||||||
upgrade: "升级到新版本",
|
upgrade: "升级到新版本",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, onMounted, toRaw, watch } from 'vue';
|
import { reactive, onMounted, toRaw, watch } from 'vue';
|
||||||
import { message, Form, Upload } from 'ant-design-vue/lib';
|
import { message, Form, Upload, notification } from 'ant-design-vue/lib';
|
||||||
import useI18n from '@/hooks/useI18n';
|
import useI18n from '@/hooks/useI18n';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import { NE_TYPE_LIST } from '@/constants/ne-constants';
|
import { NE_EXPAND_LIST, NE_TYPE_LIST } from '@/constants/ne-constants';
|
||||||
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||||
import {
|
import {
|
||||||
addNeSoftware,
|
addNeSoftware,
|
||||||
@@ -44,6 +44,8 @@ type ModalStateType = {
|
|||||||
confirmLoading: boolean;
|
confirmLoading: boolean;
|
||||||
/**上传文件 */
|
/**上传文件 */
|
||||||
uploadFiles: any[];
|
uploadFiles: any[];
|
||||||
|
/**上传文件-依赖包 */
|
||||||
|
uploadFilesDep: any[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**对话框对象信息状态 */
|
/**对话框对象信息状态 */
|
||||||
@@ -60,13 +62,14 @@ let modalState: ModalStateType = reactive({
|
|||||||
},
|
},
|
||||||
confirmLoading: false,
|
confirmLoading: false,
|
||||||
uploadFiles: [],
|
uploadFiles: [],
|
||||||
|
uploadFilesDep: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
/**对话框内表单属性和校验规则 */
|
/**对话框内表单属性和校验规则 */
|
||||||
const modalStateFrom = Form.useForm(
|
const modalStateFrom = Form.useForm(
|
||||||
modalState.from,
|
modalState.from,
|
||||||
reactive({
|
reactive({
|
||||||
type: [
|
neType: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
min: 1,
|
min: 1,
|
||||||
@@ -103,6 +106,19 @@ function fnModalOk() {
|
|||||||
modalState.confirmLoading = true;
|
modalState.confirmLoading = true;
|
||||||
const hide = message.loading(t('common.loading'), 0);
|
const hide = message.loading(t('common.loading'), 0);
|
||||||
const from = toRaw(modalState.from);
|
const from = toRaw(modalState.from);
|
||||||
|
|
||||||
|
// 安装带依赖包
|
||||||
|
if (modalState.uploadFilesDep.length > 0) {
|
||||||
|
const depFiles = [];
|
||||||
|
for (const depFile of modalState.uploadFilesDep) {
|
||||||
|
if (depFile.status === 'done' && depFile.path) {
|
||||||
|
depFiles.push(depFile.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
depFiles.push(from.path);
|
||||||
|
from.path = depFiles.join(',');
|
||||||
|
}
|
||||||
|
|
||||||
const software = from.id ? updateNeSoftware(from) : addNeSoftware(from);
|
const software = from.id ? updateNeSoftware(from) : addNeSoftware(from);
|
||||||
software.then(res => {
|
software.then(res => {
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
@@ -137,6 +153,7 @@ function fnModalCancel() {
|
|||||||
modalState.confirmLoading = false;
|
modalState.confirmLoading = false;
|
||||||
modalStateFrom.resetFields();
|
modalStateFrom.resetFields();
|
||||||
modalState.uploadFiles = [];
|
modalState.uploadFiles = [];
|
||||||
|
modalState.uploadFilesDep = [];
|
||||||
emit('cancel');
|
emit('cancel');
|
||||||
emit('update:visible', false);
|
emit('update:visible', false);
|
||||||
}
|
}
|
||||||
@@ -155,29 +172,46 @@ function fnBeforeUploadFile(file: FileType) {
|
|||||||
);
|
);
|
||||||
return Upload.LIST_IGNORE;
|
return Upload.LIST_IGNORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 取网元类型判断是否支持
|
||||||
|
let neType = '';
|
||||||
|
const neTypeIndex = fileName.indexOf('-');
|
||||||
|
if (neTypeIndex !== -1) {
|
||||||
|
neType = fileName.substring(0, neTypeIndex).toUpperCase();
|
||||||
|
}
|
||||||
|
// 主包类型
|
||||||
|
if (!NE_TYPE_LIST.includes(neType)) {
|
||||||
|
notification.warning({
|
||||||
|
message: fileName,
|
||||||
|
description: t('views.ne.neSoftware.fileCheckType'),
|
||||||
|
});
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
modalState.from.neType = neType;
|
||||||
|
|
||||||
// 根据给定的软件名取版本号 ims-r2.2312.x-ub22.deb
|
// 根据给定的软件名取版本号 ims-r2.2312.x-ub22.deb
|
||||||
const matches = fileName.match(/([0-9.]+[0-9x]+)/);
|
const matches = fileName.match(/([0-9.]+[0-9x]+)/);
|
||||||
if (matches) {
|
if (matches) {
|
||||||
modalState.from.version = matches[0];
|
modalState.from.version = matches[0];
|
||||||
}
|
}
|
||||||
const neTypeIndex = fileName.indexOf('-');
|
|
||||||
if (neTypeIndex !== -1) {
|
|
||||||
modalState.from.neType = fileName.substring(0, neTypeIndex).toUpperCase();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**表单上传文件 */
|
/**表单上传文件 */
|
||||||
function fnUploadFile(up: UploadRequestOption) {
|
function fnUploadFile(up: UploadRequestOption) {
|
||||||
|
const uploadFile = modalState.uploadFiles.find(
|
||||||
|
item => item.uid === (up.file as any).uid
|
||||||
|
);
|
||||||
|
if (!uploadFile) return;
|
||||||
|
|
||||||
// 发送请求
|
// 发送请求
|
||||||
modalState.confirmLoading = true;
|
|
||||||
uploadFileChunk(up.file as File, 5, 'software')
|
uploadFileChunk(up.file as File, 5, 'software')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
// 改为完成状态
|
// 改为完成状态
|
||||||
const file = modalState.uploadFiles[0];
|
uploadFile.percent = 100;
|
||||||
file.percent = 100;
|
uploadFile.status = 'done';
|
||||||
file.status = 'done';
|
uploadFile.path = res.data.fileName;
|
||||||
// 预置到表单
|
// 预置到表单
|
||||||
const { fileName, originalFileName } = res.data;
|
const { fileName, originalFileName } = res.data;
|
||||||
modalState.from.name = originalFileName;
|
modalState.from.name = originalFileName;
|
||||||
@@ -186,6 +220,85 @@ function fnUploadFile(up: UploadRequestOption) {
|
|||||||
message.error(res.msg, 3);
|
message.error(res.msg, 3);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch(error => {
|
||||||
|
uploadFile.percent = 0;
|
||||||
|
uploadFile.status = 'error';
|
||||||
|
uploadFile.response = error.message;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
modalState.confirmLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**表单上传前检查或转换压缩-依赖包 */
|
||||||
|
function fnBeforeUploadFileDep(file: FileType) {
|
||||||
|
if (modalState.confirmLoading) return false;
|
||||||
|
const fileName = file.name;
|
||||||
|
const suff = fileName.substring(fileName.lastIndexOf('.'));
|
||||||
|
if (!['.deb', '.rpm'].includes(suff)) {
|
||||||
|
message.error(
|
||||||
|
t('views.configManage.softwareManage.onlyAble', {
|
||||||
|
fileText: '(.deb、.rpm)',
|
||||||
|
}),
|
||||||
|
3
|
||||||
|
);
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已存在同名文件
|
||||||
|
const hasItem = modalState.uploadFilesDep.find(
|
||||||
|
item => item.name === fileName
|
||||||
|
);
|
||||||
|
if (hasItem) {
|
||||||
|
notification.warning({
|
||||||
|
message: fileName,
|
||||||
|
description: t('views.ne.neSoftware.fileNameExists'),
|
||||||
|
});
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取网元类型判断是否支持
|
||||||
|
let neType = '';
|
||||||
|
const neTypeIndex = fileName.indexOf('-');
|
||||||
|
if (neTypeIndex !== -1) {
|
||||||
|
neType = fileName.substring(0, neTypeIndex).toUpperCase();
|
||||||
|
}
|
||||||
|
// 依赖包类型
|
||||||
|
if (!NE_EXPAND_LIST.includes(neType)) {
|
||||||
|
notification.warning({
|
||||||
|
message: fileName,
|
||||||
|
description: t('views.ne.neSoftware.fileCheckTypeDep'),
|
||||||
|
});
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**表单上传文件-依赖包 */
|
||||||
|
function fnUploadFileDep(up: UploadRequestOption) {
|
||||||
|
const uploadFile = modalState.uploadFilesDep.find(
|
||||||
|
item => item.uid === (up.file as any).uid
|
||||||
|
);
|
||||||
|
if (!uploadFile) return;
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
uploadFileChunk(up.file as File, 5, 'software')
|
||||||
|
.then(res => {
|
||||||
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
|
// 改为完成状态
|
||||||
|
uploadFile.percent = 100;
|
||||||
|
uploadFile.status = 'done';
|
||||||
|
uploadFile.path = res.data.fileName;
|
||||||
|
} else {
|
||||||
|
message.error(res.msg, 3);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
uploadFile.percent = 0;
|
||||||
|
uploadFile.status = 'error';
|
||||||
|
uploadFile.response = error.message;
|
||||||
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
modalState.confirmLoading = false;
|
modalState.confirmLoading = false;
|
||||||
});
|
});
|
||||||
@@ -232,7 +345,7 @@ onMounted(() => {});
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<a-modal
|
<a-modal
|
||||||
width="500px"
|
width="550px"
|
||||||
:keyboard="false"
|
:keyboard="false"
|
||||||
:mask-closable="false"
|
:mask-closable="false"
|
||||||
:visible="modalState.visibleByEdit"
|
:visible="modalState.visibleByEdit"
|
||||||
@@ -248,12 +361,12 @@ onMounted(() => {});
|
|||||||
:label-col="{ span: 8 }"
|
:label-col="{ span: 8 }"
|
||||||
:labelWrap="true"
|
:labelWrap="true"
|
||||||
>
|
>
|
||||||
|
<template v-if="modalState.from.id === ''">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
:label="t('views.ne.neSoftware.path')"
|
:label="t('views.ne.neSoftware.path')"
|
||||||
:help="t('views.ne.neSoftware.uploadFileName')"
|
:help="t('views.ne.neSoftware.uploadFileName')"
|
||||||
name="file"
|
name="file"
|
||||||
v-bind="modalStateFrom.validateInfos.path"
|
v-bind="modalStateFrom.validateInfos.path"
|
||||||
v-if="modalState.from.id === ''"
|
|
||||||
>
|
>
|
||||||
<a-upload
|
<a-upload
|
||||||
name="file"
|
name="file"
|
||||||
@@ -279,6 +392,37 @@ onMounted(() => {});
|
|||||||
</a-upload>
|
</a-upload>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item
|
||||||
|
name="dep"
|
||||||
|
:label="t('views.ne.neSoftware.dependFile')"
|
||||||
|
:help="t('views.ne.neSoftware.dependFileTip')"
|
||||||
|
>
|
||||||
|
<a-upload
|
||||||
|
name="file"
|
||||||
|
v-model:file-list="modalState.uploadFilesDep"
|
||||||
|
accept=".rpm,.deb"
|
||||||
|
list-type="text"
|
||||||
|
:multiple="true"
|
||||||
|
:max-count="5"
|
||||||
|
:show-upload-list="{
|
||||||
|
showPreviewIcon: false,
|
||||||
|
showRemoveIcon: true,
|
||||||
|
showDownloadIcon: false,
|
||||||
|
}"
|
||||||
|
:before-upload="fnBeforeUploadFileDep"
|
||||||
|
:custom-request="fnUploadFileDep"
|
||||||
|
:disabled="modalState.confirmLoading"
|
||||||
|
>
|
||||||
|
<a-button type="dashed">
|
||||||
|
<template #icon>
|
||||||
|
<UploadOutlined />
|
||||||
|
</template>
|
||||||
|
{{ t('views.ne.neSoftware.upload') }}
|
||||||
|
</a-button>
|
||||||
|
</a-upload>
|
||||||
|
</a-form-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
<a-form-item
|
<a-form-item
|
||||||
:label="t('views.ne.common.neType')"
|
:label="t('views.ne.common.neType')"
|
||||||
name="neType"
|
name="neType"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, onMounted, toRaw, watch } from 'vue';
|
import { reactive, onMounted, toRaw, watch } from 'vue';
|
||||||
import { message, Form, Upload, notification } from 'ant-design-vue/lib';
|
import { message, Upload, notification } from 'ant-design-vue/lib';
|
||||||
import useI18n from '@/hooks/useI18n';
|
import useI18n from '@/hooks/useI18n';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import { NE_TYPE_LIST } from '@/constants/ne-constants';
|
import { NE_TYPE_LIST, NE_EXPAND_LIST } from '@/constants/ne-constants';
|
||||||
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||||
import { addNeSoftware } from '@/api/ne/neSoftware';
|
import { addNeSoftware } from '@/api/ne/neSoftware';
|
||||||
import { FileType } from 'ant-design-vue/lib/upload/interface';
|
import { FileType } from 'ant-design-vue/lib/upload/interface';
|
||||||
@@ -21,6 +21,9 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**网元支持 */
|
||||||
|
const NE_TYPE_EXP = NE_EXPAND_LIST.concat(NE_TYPE_LIST);
|
||||||
|
|
||||||
/**对话框对象信息状态类型 */
|
/**对话框对象信息状态类型 */
|
||||||
type ModalStateType = {
|
type ModalStateType = {
|
||||||
/**新增框或修改框是否显示 */
|
/**新增框或修改框是否显示 */
|
||||||
@@ -32,8 +35,6 @@ type ModalStateType = {
|
|||||||
neType: string;
|
neType: string;
|
||||||
name: string;
|
name: string;
|
||||||
path: string;
|
path: string;
|
||||||
status: 'done' | 'uploading' | 'error';
|
|
||||||
uid: string;
|
|
||||||
version: string;
|
version: string;
|
||||||
description: string;
|
description: string;
|
||||||
}[];
|
}[];
|
||||||
@@ -41,6 +42,8 @@ type ModalStateType = {
|
|||||||
confirmLoading: boolean;
|
confirmLoading: boolean;
|
||||||
/**上传文件 */
|
/**上传文件 */
|
||||||
uploadFiles: any[];
|
uploadFiles: any[];
|
||||||
|
/**上传文件-依赖包 */
|
||||||
|
uploadFilesDep: any[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**对话框对象信息状态 */
|
/**对话框对象信息状态 */
|
||||||
@@ -50,13 +53,14 @@ let modalState: ModalStateType = reactive({
|
|||||||
from: [],
|
from: [],
|
||||||
confirmLoading: false,
|
confirmLoading: false,
|
||||||
uploadFiles: [],
|
uploadFiles: [],
|
||||||
|
uploadFilesDep: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对话框弹出确认执行函数
|
* 对话框弹出确认执行函数
|
||||||
* 进行表达规则校验
|
* 进行表达规则校验
|
||||||
*/
|
*/
|
||||||
function fnModalOk() {
|
async function fnModalOk() {
|
||||||
if (modalState.confirmLoading) return;
|
if (modalState.confirmLoading) return;
|
||||||
if (modalState.uploadFiles.length < 1) {
|
if (modalState.uploadFiles.length < 1) {
|
||||||
message.warning({
|
message.warning({
|
||||||
@@ -68,39 +72,76 @@ function fnModalOk() {
|
|||||||
// 处理上传文件过滤
|
// 处理上传文件过滤
|
||||||
const uploadFiles = toRaw(modalState.uploadFiles);
|
const uploadFiles = toRaw(modalState.uploadFiles);
|
||||||
const from = toRaw(modalState.from);
|
const from = toRaw(modalState.from);
|
||||||
const softwareData: any[] = [];
|
const expandFile: Record<string, string> = {};
|
||||||
for (const hasFile of uploadFiles) {
|
for (const item of uploadFiles) {
|
||||||
for (const itemFile of from) {
|
if (item.status !== 'done' || !item.path) continue;
|
||||||
if (itemFile.uid === hasFile.uid) {
|
const neSoftware = from.find(s => s.name === item.name);
|
||||||
softwareData.push(itemFile);
|
if (neSoftware && NE_TYPE_LIST.includes(neSoftware.neType)) {
|
||||||
|
neSoftware.path = item.path;
|
||||||
|
}
|
||||||
|
if (neSoftware && NE_EXPAND_LIST.includes(neSoftware.neType)) {
|
||||||
|
expandFile[neSoftware.neType] = item.path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IMS拼接拓展包
|
||||||
|
const ims = from.find(s => s.neType === 'IMS');
|
||||||
|
if (ims) {
|
||||||
|
const pkgArr = [];
|
||||||
|
if (expandFile['ADB']) {
|
||||||
|
pkgArr.push(expandFile['ADB']);
|
||||||
}
|
}
|
||||||
// 新增软件文件
|
if (expandFile['RTPROXY']) {
|
||||||
modalState.confirmLoading = true;
|
pkgArr.push(expandFile['RTPROXY']);
|
||||||
const hide = message.loading(t('common.loading'), 0);
|
}
|
||||||
Promise.all(softwareData.map(s => addNeSoftware(s)))
|
if (expandFile['MF']) {
|
||||||
.then(resArr => {
|
pkgArr.push(expandFile['MF']);
|
||||||
|
}
|
||||||
|
pkgArr.push(ims.path);
|
||||||
|
ims.path = pkgArr.join(',');
|
||||||
|
}
|
||||||
|
// UDM拼接拓展包
|
||||||
|
const udm = from.find(s => s.neType === 'UDM');
|
||||||
|
if (udm && expandFile['ADB']) {
|
||||||
|
udm.path = [expandFile['ADB'], udm.path].join(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 安装带依赖包-指定网元时
|
||||||
|
if (props.neType && modalState.uploadFilesDep.length > 0) {
|
||||||
|
const neInfo = from.find(s => s.neType === props.neType);
|
||||||
|
if (neInfo) {
|
||||||
|
const depFiles = [];
|
||||||
|
for (const depFile of modalState.uploadFilesDep) {
|
||||||
|
if (depFile.status === 'done' && depFile.path) {
|
||||||
|
depFiles.push(depFile.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
depFiles.push(neInfo.path);
|
||||||
|
neInfo.path = depFiles.join(',');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始添加到软件包数据
|
||||||
const rows: any[] = [];
|
const rows: any[] = [];
|
||||||
resArr.forEach((res, i) => {
|
modalState.confirmLoading = true;
|
||||||
const info = softwareData[i];
|
for (const item of from.filter(s => NE_TYPE_LIST.includes(s.neType))) {
|
||||||
|
try {
|
||||||
|
const res = await addNeSoftware(item);
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
rows.push(info);
|
rows.push(item);
|
||||||
} else {
|
} else {
|
||||||
message.error({
|
message.error({
|
||||||
content: `${info.neType} ${res.msg}`,
|
content: `${item.neType} ${res.msg}`,
|
||||||
duration: 3,
|
duration: 3,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
} catch (error) {
|
||||||
Object.assign(modalState.from, rows);
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
emit('ok', rows);
|
emit('ok', rows);
|
||||||
fnModalCancel();
|
fnModalCancel();
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
hide();
|
|
||||||
modalState.confirmLoading = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,6 +153,7 @@ function fnModalCancel() {
|
|||||||
modalState.confirmLoading = false;
|
modalState.confirmLoading = false;
|
||||||
modalState.from = [];
|
modalState.from = [];
|
||||||
modalState.uploadFiles = [];
|
modalState.uploadFiles = [];
|
||||||
|
modalState.uploadFilesDep = [];
|
||||||
emit('cancel');
|
emit('cancel');
|
||||||
emit('update:visible', false);
|
emit('update:visible', false);
|
||||||
}
|
}
|
||||||
@@ -137,7 +179,7 @@ function fnBeforeUploadFile(file: FileType) {
|
|||||||
if (neTypeIndex !== -1) {
|
if (neTypeIndex !== -1) {
|
||||||
neType = fileName.substring(0, neTypeIndex).toUpperCase();
|
neType = fileName.substring(0, neTypeIndex).toUpperCase();
|
||||||
}
|
}
|
||||||
if (!NE_TYPE_LIST.includes(neType)) {
|
if (!NE_TYPE_EXP.includes(neType)) {
|
||||||
notification.warning({
|
notification.warning({
|
||||||
message: fileName,
|
message: fileName,
|
||||||
description: t('views.ne.neSoftware.fileCheckType'),
|
description: t('views.ne.neSoftware.fileCheckType'),
|
||||||
@@ -182,9 +224,7 @@ function fnBeforeUploadFile(file: FileType) {
|
|||||||
name: fileName,
|
name: fileName,
|
||||||
neType: neType,
|
neType: neType,
|
||||||
version: version,
|
version: version,
|
||||||
uid: file.uid,
|
path: '', // 上传完成后提交注入
|
||||||
status: 'uploading',
|
|
||||||
path: '',
|
|
||||||
description: '',
|
description: '',
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@@ -192,28 +232,104 @@ function fnBeforeUploadFile(file: FileType) {
|
|||||||
|
|
||||||
/**表单上传文件 */
|
/**表单上传文件 */
|
||||||
function fnUploadFile(up: UploadRequestOption) {
|
function fnUploadFile(up: UploadRequestOption) {
|
||||||
const file = up.file as File;
|
const uploadFile = modalState.uploadFiles.find(
|
||||||
const fromItem = modalState.from.find(item => item.uid === (file as any).uid);
|
item => item.uid === (up.file as any).uid
|
||||||
if (!fromItem) {
|
);
|
||||||
return;
|
if (!uploadFile) return;
|
||||||
}
|
|
||||||
// 发送请求
|
// 发送请求
|
||||||
fromItem.status = 'uploading';
|
uploadFileChunk(up.file as File, 5, 'software')
|
||||||
uploadFileChunk(file, 5, 'software').then(res => {
|
.then(res => {
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
// 改为完成状态
|
// 改为完成状态
|
||||||
const uploadFile = modalState.uploadFiles.find(
|
|
||||||
item => item.uid === (file as any).uid
|
|
||||||
);
|
|
||||||
uploadFile.percent = 100;
|
uploadFile.percent = 100;
|
||||||
uploadFile.status = 'done';
|
uploadFile.status = 'done';
|
||||||
// 预置到表单
|
uploadFile.path = res.data.fileName;
|
||||||
fromItem.status = 'done';
|
|
||||||
fromItem.path = res.data.fileName;
|
|
||||||
} else {
|
} else {
|
||||||
fromItem.status = 'error';
|
|
||||||
message.error(res.msg, 3);
|
message.error(res.msg, 3);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
uploadFile.percent = 0;
|
||||||
|
uploadFile.status = 'error';
|
||||||
|
uploadFile.response = error.message;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
modalState.confirmLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**表单上传前检查或转换压缩-依赖包 */
|
||||||
|
function fnBeforeUploadFileDep(file: FileType) {
|
||||||
|
if (modalState.confirmLoading) return false;
|
||||||
|
const fileName = file.name;
|
||||||
|
const suff = fileName.substring(fileName.lastIndexOf('.'));
|
||||||
|
if (!['.deb', '.rpm'].includes(suff)) {
|
||||||
|
message.error(
|
||||||
|
t('views.configManage.softwareManage.onlyAble', {
|
||||||
|
fileText: '(.deb、.rpm)',
|
||||||
|
}),
|
||||||
|
3
|
||||||
|
);
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已存在同名文件
|
||||||
|
const hasItem = modalState.uploadFilesDep.find(
|
||||||
|
item => item.name === fileName
|
||||||
|
);
|
||||||
|
if (hasItem) {
|
||||||
|
notification.warning({
|
||||||
|
message: fileName,
|
||||||
|
description: t('views.ne.neSoftware.fileNameExists'),
|
||||||
|
});
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取网元类型判断是否支持
|
||||||
|
let neType = '';
|
||||||
|
const neTypeIndex = fileName.indexOf('-');
|
||||||
|
if (neTypeIndex !== -1) {
|
||||||
|
neType = fileName.substring(0, neTypeIndex).toUpperCase();
|
||||||
|
}
|
||||||
|
// 依赖包类型
|
||||||
|
if (!NE_EXPAND_LIST.includes(neType)) {
|
||||||
|
notification.warning({
|
||||||
|
message: fileName,
|
||||||
|
description: t('views.ne.neSoftware.fileCheckTypeDep'),
|
||||||
|
});
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**表单上传文件-依赖包 */
|
||||||
|
function fnUploadFileDep(up: UploadRequestOption) {
|
||||||
|
const uploadFile = modalState.uploadFilesDep.find(
|
||||||
|
item => item.uid === (up.file as any).uid
|
||||||
|
);
|
||||||
|
if (!uploadFile) return;
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
uploadFileChunk(up.file as File, 5, 'software')
|
||||||
|
.then(res => {
|
||||||
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
|
// 改为完成状态
|
||||||
|
uploadFile.percent = 100;
|
||||||
|
uploadFile.status = 'done';
|
||||||
|
uploadFile.path = res.data.fileName;
|
||||||
|
} else {
|
||||||
|
message.error(res.msg, 3);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
uploadFile.percent = 0;
|
||||||
|
uploadFile.status = 'error';
|
||||||
|
uploadFile.response = error.message;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
modalState.confirmLoading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,8 +374,11 @@ onMounted(() => {});
|
|||||||
|
|
||||||
<a-form-item
|
<a-form-item
|
||||||
:label="t('views.ne.neSoftware.path')"
|
:label="t('views.ne.neSoftware.path')"
|
||||||
name="file"
|
|
||||||
:help="t('views.ne.neSoftware.uploadFileName')"
|
:help="t('views.ne.neSoftware.uploadFileName')"
|
||||||
|
:required="true"
|
||||||
|
:validate-on-rule-change="false"
|
||||||
|
:validateTrigger="[]"
|
||||||
|
name="file"
|
||||||
>
|
>
|
||||||
<a-upload
|
<a-upload
|
||||||
name="file"
|
name="file"
|
||||||
@@ -284,27 +403,67 @@ onMounted(() => {});
|
|||||||
</a-button>
|
</a-button>
|
||||||
</a-upload>
|
</a-upload>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item
|
||||||
|
name="dep"
|
||||||
|
:label="t('views.ne.neSoftware.dependFile')"
|
||||||
|
:help="t('views.ne.neSoftware.dependFileTip')"
|
||||||
|
>
|
||||||
|
<a-upload
|
||||||
|
name="file"
|
||||||
|
v-model:file-list="modalState.uploadFilesDep"
|
||||||
|
accept=".rpm,.deb"
|
||||||
|
list-type="text"
|
||||||
|
:multiple="true"
|
||||||
|
:max-count="5"
|
||||||
|
:show-upload-list="{
|
||||||
|
showPreviewIcon: false,
|
||||||
|
showRemoveIcon: true,
|
||||||
|
showDownloadIcon: false,
|
||||||
|
}"
|
||||||
|
:before-upload="fnBeforeUploadFileDep"
|
||||||
|
:custom-request="fnUploadFileDep"
|
||||||
|
:disabled="modalState.confirmLoading"
|
||||||
|
>
|
||||||
|
<a-button type="dashed">
|
||||||
|
<template #icon>
|
||||||
|
<UploadOutlined />
|
||||||
|
</template>
|
||||||
|
{{ t('views.ne.neSoftware.upload') }}
|
||||||
|
</a-button>
|
||||||
|
</a-upload>
|
||||||
|
</a-form-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<a-form-item :label="t('common.description')">
|
<a-form-item :label="t('common.description')">
|
||||||
{{
|
{{
|
||||||
t('views.ne.neSoftware.uploadBatchMax', {
|
t('views.ne.neSoftware.uploadBatchMax', {
|
||||||
txt: NE_TYPE_LIST.length,
|
txt: NE_TYPE_EXP.length,
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
<br />
|
<br />
|
||||||
{{ t('views.ne.neSoftware.uploadFileName') }}
|
{{ t('views.ne.neSoftware.uploadFileName') }}
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="t('views.ne.neSoftware.path')" name="file">
|
<a-form-item
|
||||||
|
:label="t('views.ne.neSoftware.path')"
|
||||||
|
:required="true"
|
||||||
|
:validate-on-rule-change="false"
|
||||||
|
:validateTrigger="[]"
|
||||||
|
name="file"
|
||||||
|
>
|
||||||
<a-upload
|
<a-upload
|
||||||
name="file"
|
name="file"
|
||||||
v-model:file-list="modalState.uploadFiles"
|
v-model:file-list="modalState.uploadFiles"
|
||||||
accept=".rpm,.deb"
|
accept=".rpm,.deb"
|
||||||
list-type="text"
|
list-type="text"
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:max-count="NE_TYPE_LIST.length"
|
:max-count="NE_TYPE_EXP.length"
|
||||||
:show-upload-list="false"
|
:show-upload-list="{
|
||||||
|
showPreviewIcon: false,
|
||||||
|
showRemoveIcon: true,
|
||||||
|
showDownloadIcon: false,
|
||||||
|
}"
|
||||||
:before-upload="fnBeforeUploadFile"
|
:before-upload="fnBeforeUploadFile"
|
||||||
:custom-request="fnUploadFile"
|
:custom-request="fnUploadFile"
|
||||||
:disabled="modalState.confirmLoading"
|
:disabled="modalState.confirmLoading"
|
||||||
@@ -317,40 +476,9 @@ onMounted(() => {});
|
|||||||
</a-button>
|
</a-button>
|
||||||
</a-upload>
|
</a-upload>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<div class="moreFile">
|
|
||||||
<p :key="item.uid" v-for="item in modalState.from">
|
|
||||||
<template v-if="item.status === 'done'">
|
|
||||||
<a-alert
|
|
||||||
:message="`${item.neType}-${item.version}`"
|
|
||||||
type="success"
|
|
||||||
show-icon
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-if="item.status === 'uploading'">
|
|
||||||
<a-alert
|
|
||||||
:message="`${item.neType}-${item.version}`"
|
|
||||||
type="info"
|
|
||||||
show-icon
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-if="item.status === 'error'">
|
|
||||||
<a-alert
|
|
||||||
:message="`${item.neType}-${item.version}`"
|
|
||||||
type="error"
|
|
||||||
show-icon
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</a-form>
|
</a-form>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped></style>
|
||||||
.moreFile {
|
|
||||||
max-height: 300px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user