diff --git a/src/views/ne/neConfPara5G/index.vue b/src/views/ne/neConfPara5G/index.vue index 3bdfd4db..8c8769dd 100644 --- a/src/views/ne/neConfPara5G/index.vue +++ b/src/views/ne/neConfPara5G/index.vue @@ -8,24 +8,29 @@ import { getPara5GFilee, savePara5GFile } from '@/api/ne/neInfo'; import useNeInfoStore from '@/store/modules/neinfo'; const { t } = useI18n(); -/**对话框对象信息状态类型 */ -type ModalStateType = { +/**对象信息信息状态类型 */ +type StateType = { + /**保存选择同步到网元窗 */ + visible: boolean; /**网元选择 */ neSelectOtions: any[]; /**同步到网元 */ sync: boolean; syncNe: string[]; + syncMsg: string; /**表单数据 */ from: Record; /**确定按钮 loading */ confirmLoading: boolean; }; -/**对话框对象信息状态 */ -let modalState: ModalStateType = reactive({ +/**对象信息状态 */ +let state: StateType = reactive({ + visible: false, neSelectOtions: [], sync: false, syncNe: [], + syncMsg: '', from: { basic: { dnn_data: 'internet', @@ -54,47 +59,51 @@ let modalState: ModalStateType = reactive({ confirmLoading: false, }); -/**获取文件数据*/ -function fnGetData() { - if (modalState.confirmLoading) return; - modalState.confirmLoading = true; - getPara5GFilee('yaml') +/**对话框弹出确认执行函数*/ +function fnModalOk() { + if (state.confirmLoading) return; + state.confirmLoading = true; + savePara5GFile({ + fileType: 'yaml', + content: toRaw(state.from), + syncNe: state.sync ? state.syncNe : [], + }) .then(res => { - if (res.code === RESULT_CODE_SUCCESS) { - Object.assign(modalState.from, res.data); + if (state.sync) { + state.syncMsg = res.msg; } else { - message.error({ - content: res.msg, - duration: 3, - }); + message.success('Save Success'); } }) .finally(() => { - modalState.confirmLoading = false; + state.confirmLoading = false; }); } +/**对话框弹出关闭执行函数*/ +function fnModalCancel() { + state.visible = false; + state.sync = false; + state.syncNe = []; +} + /**保存文件数据*/ function fnSaveData() { - if (modalState.confirmLoading) return; - modalState.confirmLoading = true; - savePara5GFile({ - fileType: 'yaml', - content: toRaw(modalState.from), - syncNe: modalState.sync ? modalState.syncNe : [], - }) + state.visible = true; +} + +/**获取文件数据*/ +function fnGetData() { + if (state.confirmLoading) return; + state.confirmLoading = true; + getPara5GFilee('yaml') .then(res => { - if (res.code === RESULT_CODE_SUCCESS) { - message.success('Save complete!'); - } else { - message.error({ - content: t('common.operateErr'), - duration: 3, - }); + if (typeof res.data === 'object') { + Object.assign(state.from, res.data); } }) .finally(() => { - modalState.confirmLoading = false; + state.confirmLoading = false; }); } @@ -104,8 +113,8 @@ onMounted(() => { .then(res => { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { for (const row of res.data) { - modalState.neSelectOtions.push({ - label: `${row.neType} : ${row.ip}`, + state.neSelectOtions.push({ + label: `[${row.neType} ${row.neId}] ${row.neName}`, value: `${row.neType}@${row.neId}`, }); } @@ -127,39 +136,14 @@ onMounted(() => { - +