feat: 网元授权文件支持勾选指定网元类型替换
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, onMounted, watch } from 'vue';
|
||||
import { reactive, onMounted, watch, PropType, computed } from 'vue';
|
||||
import { message, Upload } from 'ant-design-vue/lib';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
@@ -14,6 +14,11 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
/**指定网元类型 */
|
||||
licenseList: {
|
||||
type: Array as PropType<Record<string, any>[]>,
|
||||
default: [],
|
||||
},
|
||||
});
|
||||
|
||||
/**对话框对象信息状态类型 */
|
||||
@@ -23,7 +28,9 @@ type ModalStateType = {
|
||||
/**标题 */
|
||||
title: string;
|
||||
/**模式 */
|
||||
mode: '5GC' | 'AUSF-UDM-IMS';
|
||||
mode: 'Universal' | 'AUSF-UDM-IMS';
|
||||
/**指定网元 */
|
||||
selectNe: any[];
|
||||
/**授权文件路径 */
|
||||
licensePath: string;
|
||||
/**上传文件 */
|
||||
@@ -35,7 +42,8 @@ type ModalStateType = {
|
||||
/**对话框对象信息状态 */
|
||||
let modalState: ModalStateType = reactive({
|
||||
visibleByUploadFile: false,
|
||||
mode: '5GC',
|
||||
mode: 'Universal',
|
||||
selectNe: [],
|
||||
licensePath: '',
|
||||
uploadFiles: [],
|
||||
title: '授权文件',
|
||||
@@ -46,40 +54,28 @@ let modalState: ModalStateType = reactive({
|
||||
* 对话框弹出确认执行函数
|
||||
* 进行表达规则校验
|
||||
*/
|
||||
function fnModalOk() {
|
||||
if (modalState.confirmLoading || !modalState.licensePath) return;
|
||||
async function fnModalOk() {
|
||||
if (!modalState.licensePath) {
|
||||
message.warning('请上传授权文件', 3);
|
||||
return;
|
||||
}
|
||||
if (modalState.confirmLoading) return;
|
||||
modalState.confirmLoading = true;
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
listNeLicense({
|
||||
neType: undefined,
|
||||
neId: '',
|
||||
version: '',
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
})
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
|
||||
if (modalState.mode === '5GC') {
|
||||
return res.rows.filter(
|
||||
s => !['OMC', 'AUSF', 'UDM', 'IMS'].includes(s.neType)
|
||||
);
|
||||
}
|
||||
if (modalState.mode === 'AUSF-UDM-IMS') {
|
||||
return res.rows.filter(s =>
|
||||
['AUSF', 'UDM', 'IMS'].includes(s.neType)
|
||||
);
|
||||
}
|
||||
}
|
||||
return [];
|
||||
})
|
||||
.then(arr => {
|
||||
return Promise.all(
|
||||
arr.map(s => {
|
||||
s.licensePath = modalState.licensePath;
|
||||
return changeNeLicense(s);
|
||||
})
|
||||
);
|
||||
})
|
||||
|
||||
let reqArr: any = calcSelectNe.value.map(s => {
|
||||
s.reload = true; // 重启网元
|
||||
s.licensePath = modalState.licensePath;
|
||||
return changeNeLicense(s);
|
||||
});
|
||||
if (reqArr.length === 0) {
|
||||
message.warning('没有对应的网元对象', 3);
|
||||
hide();
|
||||
modalState.confirmLoading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Promise.all(reqArr)
|
||||
.then(resArr => {
|
||||
message.success(t('common.operateOk'), 3);
|
||||
emit('ok', resArr);
|
||||
@@ -98,7 +94,8 @@ function fnModalOk() {
|
||||
function fnModalCancel() {
|
||||
modalState.visibleByUploadFile = false;
|
||||
modalState.confirmLoading = false;
|
||||
modalState.mode = '5GC';
|
||||
modalState.mode = 'Universal';
|
||||
modalState.selectNe = [];
|
||||
modalState.licensePath = '';
|
||||
modalState.uploadFiles = [];
|
||||
emit('cancel');
|
||||
@@ -155,12 +152,43 @@ watch(
|
||||
() => props.visible,
|
||||
val => {
|
||||
if (val) {
|
||||
// 传入授权列表
|
||||
if (props.licenseList.length === 0) {
|
||||
listNeLicense({
|
||||
neType: undefined,
|
||||
neId: '',
|
||||
version: '',
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
}).then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
|
||||
modalState.selectNe = res.rows;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
modalState.selectNe = props.licenseList;
|
||||
}
|
||||
|
||||
modalState.title = 'Upload License File';
|
||||
modalState.visibleByUploadFile = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**授权模式选择 */
|
||||
const calcSelectNe = computed(() => {
|
||||
if (!Array.isArray(modalState.selectNe)) return [];
|
||||
if (modalState.mode === 'AUSF-UDM-IMS') {
|
||||
return modalState.selectNe.filter(s =>
|
||||
['AUSF', 'UDM', 'IMS'].includes(s.neType)
|
||||
);
|
||||
}
|
||||
|
||||
return modalState.selectNe.filter(
|
||||
s => !['OMC', 'AUSF', 'UDM', 'IMS'].includes(s.neType)
|
||||
);
|
||||
});
|
||||
|
||||
onMounted(() => {});
|
||||
</script>
|
||||
|
||||
@@ -178,11 +206,50 @@ onMounted(() => {});
|
||||
<a-form
|
||||
name="modalStateFrom"
|
||||
layout="horizontal"
|
||||
:validate-on-rule-change="false"
|
||||
:validateTrigger="[]"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
:label-col="{ span: 6 }"
|
||||
:labelWrap="true"
|
||||
>
|
||||
<a-form-item label="License File" name="file">
|
||||
<a-form-item label="NE Type" v-if="calcSelectNe.length > 0">
|
||||
<a-tag color="default" v-for="s in calcSelectNe">
|
||||
{{ s.neType }}
|
||||
</a-tag>
|
||||
</a-form-item>
|
||||
<a-form-item label="License Mode" name="mode">
|
||||
<a-select v-model:value="modalState.mode">
|
||||
<a-select-option value="Universal">Universal</a-select-option>
|
||||
<a-select-option value="AUSF-UDM-IMS">AUSF-UDM-IMS</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="License File" name="file" :required="true">
|
||||
<a-upload
|
||||
name="file"
|
||||
v-model:file-list="modalState.uploadFiles"
|
||||
accept=".ini"
|
||||
list-type="text"
|
||||
:multiple="true"
|
||||
:max-count="1"
|
||||
:show-upload-list="{
|
||||
showPreviewIcon: false,
|
||||
showRemoveIcon: false,
|
||||
showDownloadIcon: false,
|
||||
}"
|
||||
:before-upload="fnBeforeUploadFile"
|
||||
:custom-request="fnUploadFile"
|
||||
:disabled="modalState.confirmLoading"
|
||||
>
|
||||
<a-button type="primary">
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
Upload
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="License File" name="file" v-if="false">
|
||||
<a-input-group compact>
|
||||
<a-upload
|
||||
name="file"
|
||||
@@ -191,7 +258,11 @@ onMounted(() => {});
|
||||
list-type="text"
|
||||
:multiple="true"
|
||||
:max-count="1"
|
||||
:show-upload-list="false"
|
||||
:show-upload-list="{
|
||||
showPreviewIcon: false,
|
||||
showRemoveIcon: false,
|
||||
showDownloadIcon: false,
|
||||
}"
|
||||
:before-upload="fnBeforeUploadFile"
|
||||
:custom-request="fnUploadFile"
|
||||
:disabled="modalState.confirmLoading"
|
||||
@@ -204,7 +275,7 @@ onMounted(() => {});
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<a-select v-model:value="modalState.mode" style="width: 142px">
|
||||
<a-select-option value="5GC">5GC</a-select-option>
|
||||
<a-select-option value="Other">Other</a-select-option>
|
||||
<a-select-option value="AUSF-UDM-IMS">AUSF-UDM-IMS</a-select-option>
|
||||
</a-select>
|
||||
</a-input-group>
|
||||
|
||||
@@ -60,6 +60,8 @@ type StateType = {
|
||||
selectedRowKeys: (string | number)[];
|
||||
/**授权文件上传 */
|
||||
visibleByLicenseFile: boolean;
|
||||
/**授权文件上传勾选指定到网元授权列表 */
|
||||
neLicenseList: any[];
|
||||
/**确定按钮 loading */
|
||||
confirmLoading: boolean;
|
||||
};
|
||||
@@ -70,6 +72,7 @@ let state: StateType = reactive({
|
||||
data: [],
|
||||
selectedRowKeys: [],
|
||||
visibleByLicenseFile: false,
|
||||
neLicenseList: [],
|
||||
confirmLoading: false,
|
||||
});
|
||||
|
||||
@@ -88,6 +91,21 @@ function fnModalCancel() {
|
||||
state.visibleByLicenseFile = false;
|
||||
}
|
||||
|
||||
/**对话框弹出打开执行函数 */
|
||||
function fnModalOpen() {
|
||||
if (state.selectedRowKeys.length > 0) {
|
||||
// 勾选的网元数据的网元类型
|
||||
let neTypeArr = state.data.filter(item =>
|
||||
state.selectedRowKeys.includes(item.id)
|
||||
);
|
||||
state.neLicenseList = neTypeArr;
|
||||
}else{
|
||||
state.neLicenseList = []
|
||||
}
|
||||
|
||||
state.visibleByLicenseFile = !state.visibleByLicenseFile;
|
||||
}
|
||||
|
||||
/**勾选刷新网元状态 */
|
||||
function fnRecordState() {
|
||||
Modal.confirm({
|
||||
@@ -236,6 +254,7 @@ onMounted(() => {
|
||||
<!-- 授权文件上传框 -->
|
||||
<UploadLicenseFile
|
||||
v-model:visible="state.visibleByLicenseFile"
|
||||
:licenseList="state.neLicenseList"
|
||||
@ok="fnModalOk"
|
||||
@cancel="fnModalCancel"
|
||||
></UploadLicenseFile>
|
||||
@@ -244,12 +263,7 @@ onMounted(() => {
|
||||
<a-space direction="horizontal" :size="18">
|
||||
<a-button @click="fnStepPrev()"> 上一步 </a-button>
|
||||
|
||||
<a-button
|
||||
type="primary"
|
||||
@click.prevent="
|
||||
() => (state.visibleByLicenseFile = !state.visibleByLicenseFile)
|
||||
"
|
||||
>
|
||||
<a-button type="primary" @click.prevent="fnModalOpen">
|
||||
<template #icon><UploadOutlined /></template>
|
||||
Upload License
|
||||
</a-button>
|
||||
|
||||
Reference in New Issue
Block a user