diff --git a/src/views/system/quick-start/components/NeInfoSoftwareInstall.vue b/src/views/system/quick-start/components/NeInfoSoftwareInstall.vue index fd7c6eba..aeff0a2f 100644 --- a/src/views/system/quick-start/components/NeInfoSoftwareInstall.vue +++ b/src/views/system/quick-start/components/NeInfoSoftwareInstall.vue @@ -70,6 +70,8 @@ type StateType = { data: any[]; /**勾选记录 */ selectedRowKeys: (string | number)[]; + /**勾选单行记录 */ + selectedRowOne: any; /**多文件上传 */ visibleByMoreFile: boolean; /**勾选安装弹窗 */ @@ -85,6 +87,7 @@ let state: StateType = reactive({ loading: false, data: [], selectedRowKeys: [], + selectedRowOne: { neType: '' }, visibleByMoreFile: false, visibleByInstall: false, operateDataUpgrade: [], @@ -92,8 +95,17 @@ let state: StateType = reactive({ }); /**表格多选 */ -function fnTableSelectedRowKeys(keys: (string | number)[]) { +function fnTableSelectedRowKeys( + keys: (string | number)[], + selectedRows: any[] +) { state.selectedRowKeys = keys; + // 勾选单个上传 + if (selectedRows.length === 1) { + state.selectedRowOne = selectedRows[0]; + } else { + state.selectedRowOne = { neType: '' }; + } } /**对话框弹出确认执行函数*/ @@ -111,81 +123,73 @@ function fnModalCancel() { state.operateDataUpgrade = []; } -/**版本安装 */ -function fnRecordInstall() { +/**版本安装弹出确认是否安装 */ +function fnRecordInstallConfirm() { Modal.confirm({ title: t('common.tipTitle'), content: t('views.system.quickStart.stepInstallTip'), onOk() { - if (state.confirmLoading) return; - state.confirmLoading = true; - const notificationKey = 'NE_Select_Install'; - notification.info({ - key: notificationKey, - duration: 0, - message: t('common.loading'), - }); - // 操作升级的网元数据 - const selectRows = state.data.filter(item => - state.selectedRowKeys.includes(item.id) - ); - for (const row of selectRows) { - if ( - row.neType.toUpperCase() === 'OMC' || - row.newVersion === '-' || - row.newVersion === '' - ) { - state.operateDataUpgrade.push({ - neType: row.neType, - neId: row.neId, - status: 'fail', - }); - continue; - } - let preinput = {}; - if (row.neType.toUpperCase() === 'IMS') { - preinput = { pisCSCF: 'y' }; - } - state.operateDataUpgrade.push({ - neType: row.neType, - neId: row.neId, - action: 'install', - preinput: preinput, - }); - } - - // 发请求信息 - state.visibleByInstall = true; - Promise.allSettled( - state.operateDataUpgrade - .filter(s => s.status !== 'fail') - .map(s => operateNeVersion(s)) - ) - .then(resArr => { - console.log(resArr); - resArr.forEach((s, i) => { - if (s.status === 'rejected') { - message.error(s.reason, 3); - } else { - const res = s.value; - if (res.code === RESULT_CODE_SUCCESS) { - state.operateDataUpgrade[i].status = 'done'; - state.operateDataUpgrade[i].log = res.data; - } else { - state.operateDataUpgrade[i].status = 'fail'; - state.operateDataUpgrade[i].log = res.msg; - } - } - }); - }) - .finally(() => { - notification.close(notificationKey); - state.confirmLoading = false; - }); + fnRecordInstall(); }, }); } +/**版本安装进行 */ +async function fnRecordInstall() { + if (state.confirmLoading) return; + state.confirmLoading = true; + state.visibleByInstall = true; + // 操作升级的网元数据 + const selectRows = state.data.filter(item => + state.selectedRowKeys.includes(item.id) + ); + for (const row of selectRows) { + if (row.newVersion === '-' || row.newVersion === '') { + state.operateDataUpgrade.push({ + neType: row.neType, + neId: row.neId, + status: 'fail', + log: t('views.system.quickStart.stepInstallNotNewVer'), + }); + continue; + } + // 开始安装 + let preinput = {}; + if (row.neType.toUpperCase() === 'IMS') { + preinput = { pisCSCF: 'y' }; + } + const installData = { + neType: row.neType, + neId: row.neId, + action: 'install', + preinput: preinput, + }; + + try { + const res = await operateNeVersion(installData); + const operateData = { + neType: row.neType, + neId: row.neId, + status: 'fail', + log: t('common.operateErr'), + }; + if (res.code === RESULT_CODE_SUCCESS) { + operateData.status = 'done'; + operateData.log = t('views.system.quickStart.stepInstallDone') + } else { + operateData.status = 'fail'; + operateData.log = t('views.system.quickStart.stepInstallFail') + } + state.operateDataUpgrade.unshift(operateData); + } catch (error) { + console.error(error); + } + } + + // 结束 + state.confirmLoading = false; +} + /**获取列表 */ function fnGetList() { state.loading = true; @@ -200,6 +204,7 @@ function fnGetList() { // 取消勾选 if (state.selectedRowKeys.length > 0) { state.selectedRowKeys = []; + state.selectedRowOne = { neType: '' }; } state.data = res.rows.filter(s => s.neType !== 'OMC'); } @@ -270,32 +275,6 @@ onMounted(() => { - - - - - -

- {{ o.neType }} - {{ o.neId }} - {{ o.status }} - -

-
-
@@ -304,12 +283,14 @@ onMounted(() => { {{ t('views.ne.neSoftware.uploadBatch') }} + {{ state.selectedRowOne.neType }} { ghost :disabled="state.selectedRowKeys.length <= 0" :loading="state.confirmLoading" - @click.prevent="fnRecordInstall()" + @click.prevent="fnRecordInstallConfirm()" > {{ t('views.system.quickStart.stepInstallText') }} @@ -330,6 +311,65 @@ onMounted(() => {
+ + + + + + + + +

+ + + +

+ +

+ + + +

+