feat: 软件版本勾选多升级

This commit is contained in:
TsMask
2024-04-16 11:42:45 +08:00
parent 69c32b2593
commit f291bb0907

View File

@@ -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<Record<string, any>[]>([]);
@@ -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<string, any>) {
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(() => {
<a-card :bordered="false" :body-style="{ padding: '0px' }">
<!-- 插槽-卡片左侧侧 -->
<template #title>
<a-button type="primary" @click.prevent="fnModalVisibleByEdit()">
<template #icon><PlusOutlined /></template>
Upload Software
</a-button>
<a-space :size="8" align="center">
<a-button
type="primary"
@click.prevent="
() => (modalState.visibleByEdit = !modalState.visibleByEdit)
"
>
<template #icon><PlusOutlined /></template>
Upload Software
</a-button>
<a-button
type="primary"
@click.prevent="
() =>
(modalState.visibleByMoreFile = !modalState.visibleByMoreFile)
"
>
<template #icon><PlusOutlined /></template>
Upload More Software
</a-button>
<a-button
type="default"
danger
:disabled="tableState.selectedRowKeys.length <= 0"
:loading="modalState.confirmLoading"
@click.prevent="fnRecordUpgrade()"
>
<template #icon><ThunderboltOutlined /></template>
Check Upgrade
</a-button>
</a-space>
</template>
<!-- 插槽-卡片右侧 -->
@@ -444,15 +538,6 @@ onMounted(() => {
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>{{ t('common.zebra') }}</template>
<a-switch
v-model:checked="tableState.striped"
:checked-children="t('common.switch.show')"
:un-checked-children="t('common.switch.hide')"
size="small"
/>
</a-tooltip>
<a-tooltip>
<template #title>{{ t('common.reloadText') }}</template>
<a-button type="text" @click.prevent="fnGetList()">
@@ -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(() => {
</a-table>
</a-card>
<!-- 新增框或修改框 -->
<!-- 新增单文件上传 -->
<EditModal
v-model:visible="modalState.visibleByEdit"
@ok="fnModalEditOk"
@cancel="fnModalEditCancel"
></EditModal>
<!-- 新增多文件上传框 -->
<UploadMoreFile
v-model:visible="modalState.visibleByMoreFile"
@ok="fnModalEditOk"
@cancel="fnModalEditCancel"
></UploadMoreFile>
<!-- 新增多文件上传框 -->
<a-modal
width="800px"
:keyboard="false"
:mask-closable="false"
:visible="modalState.visibleByUpgrade"
title="Upgrade Version"
:confirm-loading="modalState.confirmLoading"
@ok="fnModalEditOk"
@cancel="fnModalEditCancel"
>
<p v-for="o in modalState.operateDataUpgrade">
{{ o.neType }} - {{ o.neId }} - {{ o.status }}
<TerminalText id="installLog" :rows="12" :value="o.log"></TerminalText>
</p>
</a-modal>
</PageContainer>
</template>
@@ -545,8 +653,4 @@ onMounted(() => {
.table :deep(.ant-pagination) {
padding: 0 24px;
}
.table :deep(.table-striped) td {
background-color: #fafafa;
}
</style>