From f291bb090729dff02699bd3ac525ac84c836edcc Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 16 Apr 2024 11:42:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BD=AF=E4=BB=B6=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E5=A4=9A=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ne/neVersion/index.vue | 200 +++++++++++++++++++++++-------- 1 file changed, 152 insertions(+), 48 deletions(-) diff --git a/src/views/ne/neVersion/index.vue b/src/views/ne/neVersion/index.vue index 5cca023d..305fcc6f 100644 --- a/src/views/ne/neVersion/index.vue +++ b/src/views/ne/neVersion/index.vue @@ -18,6 +18,9 @@ const { t } = useI18n(); const EditModal = defineAsyncComponent( () => import('../neSoftware/components/EditModal.vue') ); +const UploadMoreFile = defineAsyncComponent( + () => import('../neSoftware/components/UploadMoreFile.vue') +); /**网元参数 */ let neOtions = ref[]>([]); @@ -56,12 +59,10 @@ type TabeStateType = { loading: boolean; /**紧凑型 */ size: SizeType; - /**斑马纹 */ - striped: boolean; /**搜索栏 */ seached: boolean; /**记录数据 */ - data: object[]; + data: any[]; /**勾选记录 */ selectedRowKeys: (string | number)[]; }; @@ -70,7 +71,6 @@ type TabeStateType = { let tableState: TabeStateType = reactive({ loading: false, size: 'middle', - striped: false, seached: false, data: [], selectedRowKeys: [], @@ -179,13 +179,8 @@ function fnTableSize({ key }: MenuInfo) { tableState.size = key as SizeType; } -/**表格斑马纹 */ -function fnTableStriped(_record: unknown, index: number): any { - return tableState.striped && index % 2 === 1 ? 'table-striped' : undefined; -} - /**表格多选 */ -function fnTableSelectedRowKeys(keys: (string | number)[]) { +function fnTableSelectedRowKeys(keys: (string | number)[], rows: any[]) { tableState.selectedRowKeys = keys; } @@ -222,8 +217,14 @@ function fnGetList(pageNum?: number) { /**对话框对象信息状态类型 */ type ModalStateType = { - /**新增框或修改框是否显示 */ + /**单文件上传 */ visibleByEdit: boolean; + /**多文件上传 */ + visibleByMoreFile: boolean; + /**勾选升级情况 */ + visibleByUpgrade: boolean; + /**操作数据进行版本升级 */ + operateDataUpgrade: any[]; /**确定按钮 loading */ confirmLoading: boolean; }; @@ -231,23 +232,21 @@ type ModalStateType = { /**对话框对象信息状态 */ let modalState: ModalStateType = reactive({ visibleByEdit: false, + visibleByMoreFile: false, + visibleByUpgrade: false, + operateDataUpgrade: [], confirmLoading: false, }); -/** - * 对话框弹出显示为 新增或者修改 - * @param noticeId 网元id, 不传为新增 - */ -function fnModalVisibleByEdit() { - modalState.visibleByEdit = true; -} - /** * 对话框弹出确认执行函数 * 进行表达规则校验 */ function fnModalEditOk() { fnGetList(1); + if (modalState.visibleByUpgrade) { + fnModalEditCancel(); + } } /** @@ -256,6 +255,9 @@ function fnModalEditOk() { */ function fnModalEditCancel() { modalState.visibleByEdit = false; + modalState.visibleByMoreFile = false; + modalState.visibleByUpgrade = false; + modalState.operateDataUpgrade = []; } /**版本控制升级回退 */ @@ -321,6 +323,7 @@ function fnRecordVersion( } return; } + fnGetList(1); console.log(res); } else { message.error(res.msg, 3); @@ -334,16 +337,80 @@ function fnRecordVersion( }); } -/** - * 记录更多操作 - */ -function fnRecordMore(type: string | number, row: Record) { - if (type === 'download') { - return; - } - if (type === 'delete') { - return; - } +/**版本升级 */ +function fnRecordUpgrade() { + Modal.confirm({ + title: t('common.tipTitle'), + content: `check upgrade version?`, + onOk() { + if (modalState.confirmLoading) return; + modalState.confirmLoading = true; + const hide = message.loading(t('common.loading'), 0); + // 操作升级的网元数据 + const selectRows = tableState.data.filter(item => + tableState.selectedRowKeys.includes(item.id) + ); + for (const row of selectRows) { + if (row.neType.toUpperCase() === 'OMC') { + continue; + } + let preinput = {}; + if (row.neType.toUpperCase() === 'IMS') { + preinput = { pisCSCF: 'n' }; + } + modalState.operateDataUpgrade.push({ + neType: row.neType, + neId: row.neId, + action: 'upgrade', + preinput: preinput, + }); + } + // operateNeVersion({ + // neType: 'row.neType', + // neId: 'row.neId', + // action: 'upgrade', + // preinput: 'preinput', + // }) + // .then(res => { + // if (res.code === RESULT_CODE_SUCCESS) { + // console.log(res); + // } else { + // message.error(res.msg, 3); + // } + // }) + // .finally(() => { + // hide(); + // modalState.confirmLoading = false; + // }); + + // 发请求信息 + modalState.visibleByUpgrade = true; + Promise.allSettled( + modalState.operateDataUpgrade.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) { + modalState.operateDataUpgrade[i].status = 'done'; + modalState.operateDataUpgrade[i].log = res.data; + } else { + modalState.operateDataUpgrade[i].status = 'fail'; + modalState.operateDataUpgrade[i].log = res.msg; + } + } + }); + }) + .finally(() => { + hide(); + modalState.confirmLoading = false; + }); + }, + }); } onMounted(() => { @@ -426,10 +493,37 @@ onMounted(() => { @@ -444,15 +538,6 @@ onMounted(() => { size="small" /> - - - - @@ -494,7 +579,6 @@ onMounted(() => { :loading="tableState.loading" :data-source="tableState.data" :size="tableState.size" - :row-class-name="fnTableStriped" :pagination="tablePagination" :scroll="{ y: 'calc(100vh - 480px)' }" @resizeColumn="(w:number, col:any) => (col.width = w)" @@ -532,12 +616,36 @@ onMounted(() => { - + + + + + + + +

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

+
@@ -545,8 +653,4 @@ onMounted(() => { .table :deep(.ant-pagination) { padding: 0 24px; } - -.table :deep(.table-striped) td { - background-color: #fafafa; -}