--新增网元管理 导出导入重启启动停止
This commit is contained in:
@@ -157,6 +157,70 @@ export function exportSet(data: Record<string, any>) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入网元配置文件
|
||||||
|
* @param data 网元对象
|
||||||
|
* @returns object
|
||||||
|
*/
|
||||||
|
export function importFile(data: Record<string, any>) {
|
||||||
|
let dataType: 'json' | 'form-data' = 'json';
|
||||||
|
let url = `/systemManagement/v1/elementType/${data.neType}/objectType/cm?ne_id=${data.neId}`;
|
||||||
|
let obj: any = { fileName: data.fileName };
|
||||||
|
if (data.importType === 'local') {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append('nfType', data.neType);
|
||||||
|
formData.append('nfId', data.neId);
|
||||||
|
formData.append('file', data.file);
|
||||||
|
obj = formData;
|
||||||
|
dataType = 'form-data';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理FormData类型的data
|
||||||
|
return request({
|
||||||
|
url,
|
||||||
|
method: 'post',
|
||||||
|
data: obj,
|
||||||
|
dataType,
|
||||||
|
});
|
||||||
|
if (data instanceof FormData) {
|
||||||
|
// 处理FormData类型的data
|
||||||
|
return request({
|
||||||
|
url: `/systemManagement/v1/elementType/${data.get(
|
||||||
|
'nfType'
|
||||||
|
)}/objectType/cm?ne_id=${data.get('nfId')}`,
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
dataType: 'form-data',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 处理普通对象类型的data
|
||||||
|
return request({
|
||||||
|
url: `/systemManagement/v1/elementType/${data.nfType}/objectType/cm?ne_id=${data.nfId}`,
|
||||||
|
method: 'post',
|
||||||
|
data: { fileName: data.fileName },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询远程服务器上网元配置文件
|
||||||
|
* @param data 网元对象
|
||||||
|
* @returns object
|
||||||
|
*/
|
||||||
|
export async function listServerFile(data: Record<string, any>) {
|
||||||
|
const result = await request({
|
||||||
|
url: `databaseManagement/v1/omc_db/ne_backup?SQL= select * from ne_backup where ne_type ='${data.neType}'`,
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
// 解析数据
|
||||||
|
if (result.code === RESULT_CODE_SUCCESS && Array.isArray(result.data.data)) {
|
||||||
|
let data = result.data.data[0];
|
||||||
|
return Object.assign(result, {
|
||||||
|
data: parseObjLineToHump(data['ne_backup']),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动网元
|
* 启动网元
|
||||||
|
|||||||
@@ -16,9 +16,13 @@ import {
|
|||||||
startNf,
|
startNf,
|
||||||
restartNf,
|
restartNf,
|
||||||
stopNf,
|
stopNf,
|
||||||
|
importFile,
|
||||||
|
listServerFile,
|
||||||
} from '@/api/configManage/neManage';
|
} from '@/api/configManage/neManage';
|
||||||
import { parseDateToStr } from '@/utils/date-utils';
|
import { parseDateToStr } from '@/utils/date-utils';
|
||||||
import useI18n from '@/hooks/useI18n';
|
import useI18n from '@/hooks/useI18n';
|
||||||
|
import { FileType } from 'ant-design-vue/lib/upload/interface';
|
||||||
|
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -26,6 +30,15 @@ const route = useRoute();
|
|||||||
/**路由标题 */
|
/**路由标题 */
|
||||||
let title = ref<string>((route.meta.title as string) ?? '标题');
|
let title = ref<string>((route.meta.title as string) ?? '标题');
|
||||||
|
|
||||||
|
/**表格所需option */
|
||||||
|
const neManageOption = reactive({
|
||||||
|
importType: [
|
||||||
|
{ label: t('views.configManage.neManage.server'), value: 'server' },
|
||||||
|
{ label: t('views.configManage.neManage.local'), value: 'local' },
|
||||||
|
],
|
||||||
|
serverFileName: <any[]>[],
|
||||||
|
});
|
||||||
|
|
||||||
/**查询参数 */
|
/**查询参数 */
|
||||||
let queryParams = reactive({
|
let queryParams = reactive({
|
||||||
/**网元类型 */
|
/**网元类型 */
|
||||||
@@ -183,10 +196,14 @@ type ModalStateType = {
|
|||||||
visibleByView: boolean;
|
visibleByView: boolean;
|
||||||
/**新增框或修改框是否显示 */
|
/**新增框或修改框是否显示 */
|
||||||
visibleByEdit: boolean;
|
visibleByEdit: boolean;
|
||||||
|
/**导入是否显示 */
|
||||||
|
visibleByImport: boolean;
|
||||||
/**标题 */
|
/**标题 */
|
||||||
title: string;
|
title: string;
|
||||||
/**表单数据 */
|
/**表单数据 */
|
||||||
from: Record<string, any>;
|
from: Record<string, any>;
|
||||||
|
/**导入表单数据 */
|
||||||
|
importFrom: Record<string, any>;
|
||||||
/**确定按钮 loading */
|
/**确定按钮 loading */
|
||||||
confirmLoading: boolean;
|
confirmLoading: boolean;
|
||||||
};
|
};
|
||||||
@@ -195,6 +212,7 @@ type ModalStateType = {
|
|||||||
let modalState: ModalStateType = reactive({
|
let modalState: ModalStateType = reactive({
|
||||||
visibleByView: false,
|
visibleByView: false,
|
||||||
visibleByEdit: false,
|
visibleByEdit: false,
|
||||||
|
visibleByImport: false,
|
||||||
title: '网元',
|
title: '网元',
|
||||||
from: {
|
from: {
|
||||||
dn: '',
|
dn: '',
|
||||||
@@ -209,6 +227,14 @@ let modalState: ModalStateType = reactive({
|
|||||||
rmUid: '',
|
rmUid: '',
|
||||||
vendorName: '',
|
vendorName: '',
|
||||||
},
|
},
|
||||||
|
importFrom: {
|
||||||
|
neId: '',
|
||||||
|
neType: '',
|
||||||
|
importType: '',
|
||||||
|
file: undefined,
|
||||||
|
fileList: [],
|
||||||
|
fileName: '',
|
||||||
|
},
|
||||||
confirmLoading: false,
|
confirmLoading: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -226,6 +252,31 @@ const modalStateFrom = Form.useForm(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**导入对话框内表单属性和校验规则 */
|
||||||
|
const importStateFrom = Form.useForm(
|
||||||
|
modalState.importFrom,
|
||||||
|
reactive({
|
||||||
|
file: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: t('views.configManage.softwareManage.updateFilePlease'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
importType: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: t('views.configManage.neManage.selectPlease'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fileName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: t('views.configManage.neManage.fileSelect'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对话框弹出显示为 新增或者修改
|
* 对话框弹出显示为 新增或者修改
|
||||||
* @param noticeId 网元id, 不传为新增
|
* @param noticeId 网元id, 不传为新增
|
||||||
@@ -292,6 +343,72 @@ function fnModalOk() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入对话框弹出确认执行函数
|
||||||
|
* 进行表达规则校验
|
||||||
|
*/
|
||||||
|
function fnImportModalOk() {
|
||||||
|
const from = toRaw(modalState.importFrom);
|
||||||
|
let validateName = ['importType'];
|
||||||
|
if (from.file) {
|
||||||
|
validateName.push('file');
|
||||||
|
} else {
|
||||||
|
validateName.push('fileName');
|
||||||
|
}
|
||||||
|
|
||||||
|
importStateFrom
|
||||||
|
.validate(validateName)
|
||||||
|
.then(e => {
|
||||||
|
modalState.confirmLoading = true;
|
||||||
|
const hide = message.loading({ content: t('common.loading') });
|
||||||
|
// let result = importFile(from);
|
||||||
|
// if (from.importType === 'local') {
|
||||||
|
// let formData = new FormData();
|
||||||
|
// formData.append('nfType', from.neType);
|
||||||
|
// formData.append('nfId', from.neId);
|
||||||
|
// formData.append('file', from.file);
|
||||||
|
// result = importFile(formData);
|
||||||
|
// }
|
||||||
|
|
||||||
|
importFile(from)
|
||||||
|
.then(res => {
|
||||||
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
|
message.success({
|
||||||
|
content: t('common.msgSuccess', { msg: modalState.title }),
|
||||||
|
duration: 3,
|
||||||
|
});
|
||||||
|
modalState.visibleByEdit = false;
|
||||||
|
modalStateFrom.resetFields();
|
||||||
|
} else {
|
||||||
|
message.error({
|
||||||
|
content: `${res.msg}`,
|
||||||
|
duration: 3,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hide();
|
||||||
|
modalState.confirmLoading = false;
|
||||||
|
// 获取列表数据
|
||||||
|
fnGetList();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.error(e)
|
||||||
|
message.error(t('common.errorFields', { num: e.errorFields.length }), 3);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入对话框弹出关闭执行函数
|
||||||
|
* 进行表达规则校验
|
||||||
|
*/
|
||||||
|
function fnImportModalCancel() {
|
||||||
|
modalState.visibleByView = false;
|
||||||
|
modalState.visibleByImport = false;
|
||||||
|
importStateFrom.resetFields();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对话框弹出关闭执行函数
|
* 对话框弹出关闭执行函数
|
||||||
* 进行表达规则校验
|
* 进行表达规则校验
|
||||||
@@ -431,6 +548,12 @@ function fnFileModalVisible(type: string | number, row: Record<string, any>) {
|
|||||||
tableState.loading = false;
|
tableState.loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === 'import') {
|
||||||
|
modalState.importFrom = Object.assign(modalState.importFrom, row);
|
||||||
|
modalState.title = '导入';
|
||||||
|
modalState.visibleByImport = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**查询网元列表 */
|
/**查询网元列表 */
|
||||||
@@ -450,6 +573,53 @@ function fnGetList() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**查询网元远程服务器备份文件 */
|
||||||
|
function typeChange(value: any) {
|
||||||
|
if (value === 'server') {
|
||||||
|
listServerFile(modalState.importFrom).then(res => {
|
||||||
|
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||||
|
neManageOption.serverFileName = [];
|
||||||
|
res.data.forEach((item: any) => {
|
||||||
|
neManageOption.serverFileName.push({
|
||||||
|
label: item.fileName,
|
||||||
|
value: item.fileName,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// else if (res.code === RESULT_CODE_SUCCESS && !res.data) {
|
||||||
|
// message.error({
|
||||||
|
// content: `当前网元没有远程服务器备份文件`,
|
||||||
|
// key: 'importServer',
|
||||||
|
// duration: 2,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**上传前检查或转换压缩 */
|
||||||
|
function fnBeforeUploadFile(file: FileType) {
|
||||||
|
if (modalState.confirmLoading) return false;
|
||||||
|
const fileName = file.name;
|
||||||
|
const suff = fileName.substring(fileName.lastIndexOf('.'));
|
||||||
|
const isLt60M = file.size / 1024 / 1024 > 60;
|
||||||
|
if (isLt60M) {
|
||||||
|
message.error('有效软件文件大小应不小于 60MB', 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**上传文件 */
|
||||||
|
function fnUploadFile(up: UploadRequestOption) {
|
||||||
|
// 改为完成状态
|
||||||
|
const file = modalState.importFrom.fileList[0];
|
||||||
|
file.percent = 100;
|
||||||
|
file.status = 'done';
|
||||||
|
// 预置到表单
|
||||||
|
modalState.importFrom.file = up.file;
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 获取列表数据
|
// 获取列表数据
|
||||||
fnGetList();
|
fnGetList();
|
||||||
@@ -604,7 +774,7 @@ onMounted(() => {
|
|||||||
{{ t('views.configManage.neManage.start') }}
|
{{ t('views.configManage.neManage.start') }}
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item key="restart">
|
<a-menu-item key="restart">
|
||||||
<loading-outlined />
|
<redo-outlined />
|
||||||
{{ t('views.configManage.neManage.restart') }}
|
{{ t('views.configManage.neManage.restart') }}
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item key="stop">
|
<a-menu-item key="stop">
|
||||||
@@ -807,6 +977,97 @@ onMounted(() => {
|
|||||||
</a-row>
|
</a-row>
|
||||||
</a-form>
|
</a-form>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
|
|
||||||
|
<!-- 导入框 -->
|
||||||
|
<a-modal
|
||||||
|
width="800px"
|
||||||
|
:keyboard="false"
|
||||||
|
:mask-closable="false"
|
||||||
|
:visible="modalState.visibleByImport"
|
||||||
|
:title="modalState.title"
|
||||||
|
:confirm-loading="modalState.confirmLoading"
|
||||||
|
@ok="fnImportModalOk"
|
||||||
|
@cancel="fnImportModalCancel"
|
||||||
|
>
|
||||||
|
<a-form name="importStateFrom" layout="horizontal">
|
||||||
|
<a-row :gutter="16">
|
||||||
|
<a-col :lg="12" :md="12" :xs="24">
|
||||||
|
<a-form-item
|
||||||
|
label="网元类型"
|
||||||
|
name="neType"
|
||||||
|
v-bind="importStateFrom.validateInfos.neType"
|
||||||
|
>
|
||||||
|
<a-input
|
||||||
|
v-model:value="modalState.importFrom.neType"
|
||||||
|
disabled
|
||||||
|
allow-clear
|
||||||
|
>
|
||||||
|
</a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :lg="12" :md="12" :xs="24">
|
||||||
|
<a-form-item
|
||||||
|
label="网元内部标识"
|
||||||
|
name="neId"
|
||||||
|
v-bind="importStateFrom.validateInfos.neId"
|
||||||
|
>
|
||||||
|
<a-input
|
||||||
|
v-model:value="modalState.importFrom.neId"
|
||||||
|
disabled
|
||||||
|
></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
|
||||||
|
<a-form-item
|
||||||
|
label="文件来源"
|
||||||
|
name="importType"
|
||||||
|
v-bind="importStateFrom.validateInfos.importType"
|
||||||
|
>
|
||||||
|
<a-select
|
||||||
|
v-model:value="modalState.importFrom.importType"
|
||||||
|
default-value="server"
|
||||||
|
:options="neManageOption.importType"
|
||||||
|
@change="typeChange"
|
||||||
|
>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item
|
||||||
|
label="导入远程文件"
|
||||||
|
name="fileName"
|
||||||
|
v-bind="importStateFrom.validateInfos.fileName"
|
||||||
|
v-show="modalState.importFrom.importType === 'server'"
|
||||||
|
>
|
||||||
|
<a-select
|
||||||
|
v-model:value="modalState.importFrom.fileName"
|
||||||
|
:options="neManageOption.serverFileName"
|
||||||
|
>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item
|
||||||
|
label="导入本地文件"
|
||||||
|
name="file"
|
||||||
|
v-bind="importStateFrom.validateInfos.file"
|
||||||
|
v-show="modalState.importFrom.importType === 'local'"
|
||||||
|
>
|
||||||
|
<a-upload
|
||||||
|
name="file"
|
||||||
|
v-model:file-list="modalState.importFrom.fileList"
|
||||||
|
list-type="text"
|
||||||
|
:max-count="1"
|
||||||
|
:show-upload-list="true"
|
||||||
|
:before-upload="fnBeforeUploadFile"
|
||||||
|
:custom-request="fnUploadFile"
|
||||||
|
>
|
||||||
|
<a-button type="default" :loading="modalState.confirmLoading">
|
||||||
|
{{ t('views.configManage.neManage.fileSelect') }}
|
||||||
|
</a-button>
|
||||||
|
</a-upload>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user