feat: 网元主机操作Hooks包
This commit is contained in:
@@ -364,6 +364,7 @@ export default {
|
||||
totalSure:'Confirm the network element with {operator} network element name {msg}',
|
||||
stop: 'Stop',
|
||||
start: 'Start',
|
||||
log: 'Logs',
|
||||
export: 'Export',
|
||||
import: 'Import',
|
||||
fileForm:'File Source',
|
||||
@@ -1219,7 +1220,6 @@ export default {
|
||||
serialNum: 'Serial Number',
|
||||
expiryDate: 'Expiry Date',
|
||||
switchLayout: "Switch Layout",
|
||||
viewLogFile: "Viewing Log Files",
|
||||
noData: "Can't find the corresponding plot data",
|
||||
},
|
||||
topologyBuild: {
|
||||
|
||||
@@ -364,6 +364,7 @@ export default {
|
||||
totalSure:'确认{oper}网元名称为 {msg} 的网元',
|
||||
stop: '停止',
|
||||
start: '启动',
|
||||
log: '日志',
|
||||
export: '导出',
|
||||
import: '导入',
|
||||
fileForm:'文件来源',
|
||||
@@ -1219,7 +1220,6 @@ export default {
|
||||
serialNum: '序列号',
|
||||
expiryDate: '许可证到期日期',
|
||||
switchLayout: "切换布局",
|
||||
viewLogFile: "查看日志文件",
|
||||
noData: "找不到对应的图组数据",
|
||||
},
|
||||
topologyBuild: {
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
nodeImageAnimateState,
|
||||
nodeRectAnimateState,
|
||||
} from '../topologyBuild/hooks/registerNode';
|
||||
import useNeOptions from './useNeOptions';
|
||||
import useNeOptions from '@/views/ne/neInfo/hooks/useNeOptions';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { OptionsType, WS } from '@/plugins/ws-websocket';
|
||||
const { t } = useI18n();
|
||||
@@ -97,7 +97,7 @@ const graphNodeMenu = new Menu({
|
||||
> ${t('views.configManage.neManage.stop')}
|
||||
</div>
|
||||
<div id="log" style="cursor: pointer; margin-bottom: 4px;">
|
||||
> ${t('views.monitor.topology.viewLogFile')}
|
||||
> ${t('views.configManage.neManage.log')}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
import { restartNf, stopNf } from '@/api/configManage/neManage';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { Modal, message } from 'ant-design-vue/lib';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
export default function useNeOptions() {
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 网元重启
|
||||
* @param row {neName,neType,neId}
|
||||
*/
|
||||
function fnNeRestart(row: Record<string, any>) {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.configManage.neManage.totalSure', {
|
||||
msg: row.neName,
|
||||
oper: t('views.configManage.neManage.restart'),
|
||||
}),
|
||||
onOk() {
|
||||
const key = 'restartNf';
|
||||
message.loading({ content: t('common.loading'), key });
|
||||
restartNf(row).then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: t('common.msgSuccess', {
|
||||
msg: t('views.configManage.neManage.restart'),
|
||||
}),
|
||||
key,
|
||||
duration: 3,
|
||||
});
|
||||
} else {
|
||||
message.error({
|
||||
content: `${res.msg}`,
|
||||
key: key,
|
||||
duration: 3,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 网元停止
|
||||
* @param row {neName,neType,neId}
|
||||
*/
|
||||
function fnNeStop(row: Record<string, any>) {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.configManage.neManage.totalSure', {
|
||||
msg: row.neName,
|
||||
oper: t('views.configManage.neManage.stop'),
|
||||
}),
|
||||
onOk() {
|
||||
const key = 'restartNf';
|
||||
message.loading({ content: t('common.loading'), key });
|
||||
stopNf(row).then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: t('common.msgSuccess', {
|
||||
msg: t('views.configManage.neManage.stop'),
|
||||
}),
|
||||
key: key,
|
||||
duration: 3,
|
||||
});
|
||||
} else {
|
||||
message.error({
|
||||
content: `${res.msg}`,
|
||||
key: key,
|
||||
duration: 3,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转网元日志文件页面
|
||||
* @param row {neType,neId}
|
||||
*/
|
||||
function fnNeLogFile(row: Record<string, any>) {
|
||||
router.push(`/logManage/neFile?neType=${row.neType}&neId=${row.neId}`);
|
||||
}
|
||||
|
||||
return { fnNeRestart, fnNeStop, fnNeLogFile };
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export default function useNeOptions() {
|
||||
* 网元启动
|
||||
* @param row {neName,neType,neId}
|
||||
*/
|
||||
function fnRecordStart(row: Record<string, any>) {
|
||||
function fnNeStart(row: Record<string, any>) {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.configManage.neManage.totalSure', {
|
||||
@@ -154,8 +154,14 @@ export default function useNeOptions() {
|
||||
* @param row {neType,neId}
|
||||
*/
|
||||
function fnNeLogFile(row: Record<string, any>) {
|
||||
router.push(`/logManage/neFile?neType=${row.neType}&neId=${row.neId}`);
|
||||
router.push({
|
||||
name: 'NeFile_2123',
|
||||
query: {
|
||||
neType: row.neType,
|
||||
neId: row.neId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return { fnNeRestart, fnNeStop, fnNeLogFile };
|
||||
return { fnNeStart, fnNeRestart, fnNeStop, fnNeReload, fnNeLogFile };
|
||||
}
|
||||
@@ -12,8 +12,11 @@ import useNeInfoStore from '@/store/modules/neinfo';
|
||||
import { listNeInfo, delNeInfo } from '@/api/ne/neInfo';
|
||||
import { NE_TYPE_LIST } from '@/constants/ne-constants';
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
import useNeOptions from './hooks/useNeOptions';
|
||||
const { getDict } = useDictStore();
|
||||
const { t } = useI18n();
|
||||
const { fnNeStart, fnNeRestart, fnNeStop, fnNeReload, fnNeLogFile } =
|
||||
useNeOptions();
|
||||
|
||||
/**字典数据 */
|
||||
let dict: {
|
||||
@@ -271,29 +274,28 @@ function fnRecordDelete(id: string) {
|
||||
* 记录多项选择
|
||||
*/
|
||||
function fnRecordMore(type: string | number, row: Record<string, any>) {
|
||||
if (type === 'delete') {
|
||||
// fnRecordDelete(row);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === 'export') {
|
||||
// fnRecordExport(row);
|
||||
}
|
||||
|
||||
if (type === 'start') {
|
||||
// fnRecordStart(row);
|
||||
}
|
||||
|
||||
if (type === 'restart') {
|
||||
// fnRecordRestart(row);
|
||||
}
|
||||
|
||||
if (type === 'stop') {
|
||||
// fnRecordStop(row);
|
||||
}
|
||||
|
||||
if (type === 'reload') {
|
||||
// fnNeReload(row);
|
||||
switch (type) {
|
||||
case 'delete':
|
||||
fnRecordDelete(row.id);
|
||||
break;
|
||||
case 'start':
|
||||
fnNeStart(row);
|
||||
break;
|
||||
case 'restart':
|
||||
fnNeRestart(row);
|
||||
break;
|
||||
case 'stop':
|
||||
fnNeStop(row);
|
||||
break;
|
||||
case 'reload':
|
||||
fnNeReload(row);
|
||||
break;
|
||||
case 'log':
|
||||
fnNeLogFile(row);
|
||||
break;
|
||||
default:
|
||||
console.warn(type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,17 +540,6 @@ onMounted(() => {
|
||||
<template #icon><FormOutlined /></template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-tooltip>
|
||||
<template #title>{{ t('common.deleteText') }}</template>
|
||||
<a-button
|
||||
type="link"
|
||||
@click.prevent="fnRecordDelete(record.id)"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-tooltip>
|
||||
<template #title>
|
||||
{{ t('views.configManage.neManage.restart') }}
|
||||
@@ -560,6 +551,17 @@ onMounted(() => {
|
||||
<template #icon><UndoOutlined /></template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-tooltip>
|
||||
<template #title>
|
||||
{{ t('views.configManage.neManage.stop') }}
|
||||
</template>
|
||||
<a-button
|
||||
type="link"
|
||||
@click.prevent="fnRecordMore('stop', record)"
|
||||
>
|
||||
<template #icon><StopOutlined /> </template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="left">
|
||||
<template #title>{{ t('common.moreText') }}</template>
|
||||
<a-dropdown
|
||||
@@ -571,22 +573,14 @@ onMounted(() => {
|
||||
</a-button>
|
||||
<template #overlay>
|
||||
<a-menu @click="({ key }:any) => fnRecordMore(key, record)">
|
||||
<a-menu-item key="export">
|
||||
<ExportOutlined />
|
||||
{{ t('views.configManage.neManage.export') }}
|
||||
</a-menu-item>
|
||||
<a-menu-item key="import">
|
||||
<ImportOutlined />
|
||||
{{ t('views.configManage.neManage.import') }}
|
||||
<a-menu-item key="log">
|
||||
<FileTextOutlined />
|
||||
{{ t('views.configManage.neManage.log') }}
|
||||
</a-menu-item>
|
||||
<a-menu-item key="start">
|
||||
<thunderbolt-outlined />
|
||||
<ThunderboltOutlined />
|
||||
{{ t('views.configManage.neManage.start') }}
|
||||
</a-menu-item>
|
||||
<a-menu-item key="stop">
|
||||
<pause-outlined />
|
||||
{{ t('views.configManage.neManage.stop') }}
|
||||
</a-menu-item>
|
||||
<a-menu-item
|
||||
key="reload"
|
||||
v-if="
|
||||
@@ -721,3 +715,4 @@ onMounted(() => {
|
||||
padding: 0 24px;
|
||||
}
|
||||
</style>
|
||||
./components/useNeOptions
|
||||
|
||||
Reference in New Issue
Block a user