From 823114a6d028178d3630dce261617b6722f5f59a Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Wed, 20 Dec 2023 11:22:55 +0800 Subject: [PATCH] =?UTF-8?q?--=E8=B0=83=E6=95=B4=E5=9B=9E=E9=80=80=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/locales/en-US.ts | 5 +- src/i18n/locales/zh-CN.ts | 1 + .../configManage/softwareManage/index.vue | 173 ++++++++++++++++-- 3 files changed, 159 insertions(+), 20 deletions(-) diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index be4adee1..dcfe21bf 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -173,8 +173,8 @@ export default { reload: "Refresh Current Tab", more: "More Options", closeCurrent: "Close Current Tab", - closeOther: "Close Other Tab", - closeAll: "Close All Tab", + closeOther: "Close Other Tabs", + closeAll: "Close All Tabs", } }, @@ -402,6 +402,7 @@ export default { createTime:'Creation time', onlyAble:'Only upload file format {fileText} is supported', nullData:'No network element list data yet', + nullVersion:'There is no rollback version for the current network element.', }, license: { neTypePlease: 'Select network element type', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 1789e8aa..78afe6a8 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -402,6 +402,7 @@ export default { createTime:'创建时间', onlyAble:'只支持上传文件格式 {fileText}', nullData:'暂无网元列表数据', + nullVersion:'当前网元无可回退版本', }, license: { neTypePlease: '选择网元类型', diff --git a/src/views/configManage/softwareManage/index.vue b/src/views/configManage/softwareManage/index.vue index db2735b7..6aec4abf 100644 --- a/src/views/configManage/softwareManage/index.vue +++ b/src/views/configManage/softwareManage/index.vue @@ -8,7 +8,7 @@ import { ColumnsType } from 'ant-design-vue/lib/table'; import { parseDateToStr } from '@/utils/date-utils'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import SoftwareHistory from './components/software-history.vue'; - +import { listNeVersion } from '@/api/configManage/softwareManage'; import { listNeSoftware, delNeSoftware, @@ -154,14 +154,20 @@ type FileStateType = { visible: boolean; /**框类型 */ visibleType: string; + /**回退框是否显示 */ + visibleByBack: boolean; /**标题 */ title: string; /**提示内容 */ content: string; + /**OK按钮是否禁用 */ + okDisable: boolean; /**网元参数 */ neOtions: Record[]; /**表单数据 */ from: Record; + /**回退表单数据 */ + backFrom: Record; /**确定按钮 loading */ confirmLoading: boolean; }; @@ -170,12 +176,19 @@ type FileStateType = { let fileModalState: FileStateType = reactive({ visible: false, visibleType: 'send', + visibleByBack: false, title: '下发激活回退', content: '', + okDisable: false, neOtions: [], from: { neId: undefined, }, + backFrom: { + neType: undefined, + neId: undefined, + version: '', + }, confirmLoading: false, }); @@ -192,6 +205,19 @@ const fileModalStateFrom = Form.useForm( }) ); +/**对话框内表单属性和校验规则 */ +const fileModalStateBackFrom = Form.useForm( + fileModalState.backFrom, + reactive({ + neType: [ + { + required: true, + message: t('views.configManage.softwareManage.neIdPlease'), + }, + ], + }) +); + /** * 文件对话框弹出显示为 下发或激活 */ @@ -217,13 +243,7 @@ function fnFileModalVisible(type: string | number, row: Record) { fileName: row.fileName, }); } - if (type === 'back') { - fileModalState.title = t('views.configManage.softwareManage.backTitle'); - fileModalState.content = t( - 'views.configManage.softwareManage.backContent', - { fileName: row.fileName } - ); - } + if (!fileModalState.content) { return; } @@ -263,9 +283,6 @@ function fnFileModalOk() { if (type === 'run') { fnType = runNeSoftware(from); } - if (type === 'back') { - fnType = backNeSoftware(from); - } if (fnType === null) { return; } @@ -396,6 +413,7 @@ type ModalStateType = { visibleByEdit: boolean; /**网元版本历史框是否显示 */ visibleByHistory: boolean; + /**标题 */ title: string; /**表单数据 */ @@ -408,6 +426,7 @@ type ModalStateType = { let modalState: ModalStateType = reactive({ visibleByEdit: false, visibleByHistory: false, + visibleByBack: false, title: '上传更新', from: { neType: undefined, @@ -512,8 +531,10 @@ function fnModalOk() { */ function fnModalCancel() { modalState.visibleByEdit = false; + fileModalState.visibleByBack = false; modalState.visibleByHistory = false; modalStateFrom.resetFields(); + fileModalStateBackFrom.resetFields(); } /** @@ -523,6 +544,88 @@ function fnModalVisibleByHistory() { modalState.visibleByHistory = true; } +/** + * 对话框弹出显示为 回退框 + */ +function fnModalVisibleByBack() { + fileModalState.visibleByBack = true; + fileModalState.title = t('views.configManage.softwareManage.backTitle'); + fileModalState.content = t('views.configManage.softwareManage.neIdPlease'); + + if (!fileModalState.content) { + return; + } +} + +/**回退网元类型选择对应修改 */ +function fnNeChange(_: any, item: any) { + fileModalState.backFrom.neType = item[1].neType; + fileModalState.backFrom.neId = item[1].neId; + let queryData: any = fileModalState.backFrom; + queryData.status = 'Active'; + queryData.pageNum = 1; + queryData.pageSize = 20; + listNeVersion(toRaw(queryData)).then(res => { + if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) { + if ( + !res.total || + !res.rows[0].preVersion || + res.rows[0].preVersion === '-' + ) { + fileModalState.okDisable = true; + fileModalState.content = t( + 'views.configManage.softwareManage.nullVersion' + ); + tableState.loading = false; + return; + } + fileModalState.content = t( + 'views.configManage.softwareManage.backContent', + { fileName: res.rows[0].preVersion } + ); + fileModalState.backFrom.version = res.rows[0].preVersion; + fileModalState.okDisable = false; + } + tableState.loading = false; + }); +} + +/** + * 回退对话框弹出确认执行函数 + */ +function fnBackModalOk() { + fileModalStateBackFrom + .validate() + .then(e => { + const from = toRaw(fileModalState.backFrom); + // 发送请求 + fileModalState.confirmLoading = true; + const hide = message.loading({ content: t('common.loading') }); + backNeSoftware(from) + .then(res => { + if (res.code === RESULT_CODE_SUCCESS) { + message.success({ + content: t('common.msgSuccess', { msg: fileModalState.title }), + duration: 3, + }); + fnFileModalCancel(); + } else { + message.error({ + content: `${fileModalState.title} ${res.msg}`, + duration: 3, + }); + } + }) + .finally(() => { + hide(); + fileModalState.confirmLoading = false; + }); + }) + .catch(e => { + message.error(t('common.errorFields', { num: e.errorFields.length }), 3); + }); +} + /**上传前检查或转换压缩 */ function fnBeforeUploadFile(file: FileType) { if (modalState.confirmLoading) return false; @@ -538,9 +641,9 @@ function fnBeforeUploadFile(file: FileType) { return false; } // 根据给定的软件名取版本号 ims-r2.2312.8_u18.deb - const nameArr = fileName.split('.') - if(nameArr.length > 3) { - modalState.from.version = nameArr[1] + const nameArr = fileName.split('.'); + if (nameArr.length > 3) { + modalState.from.version = nameArr[1]; } return true; } @@ -657,6 +760,10 @@ onMounted(() => { {{ t('views.configManage.softwareManage.historyBtn') }} + + + {{ t('views.configManage.softwareManage.backBtn') }} + @@ -762,10 +869,6 @@ onMounted(() => { {{ t('common.deleteText') }} - - - {{ t('views.configManage.softwareManage.backBtn') }} - @@ -910,6 +1013,40 @@ onMounted(() => { + + + + + + + + {{ fileModalState.content }} + + + + + + +