--批量新增鉴权用户

This commit is contained in:
lai
2023-09-22 15:26:45 +08:00
parent 0118e5d1b8
commit fb9f465e12
4 changed files with 268 additions and 139 deletions

View File

@@ -15,6 +15,19 @@ export function listAuth(query: Record<string, any>) {
});
}
/**
* 全部获取
* @param neId 网元ID
* @returns object
*/
export function getAllAuth(neId:string) {
return request({
url: `/udmUserManage/v1/authSave/${neId}`,
method: 'post',
timeout:600*1000
});
}
/**
* 查询鉴权详细
* @param neId 网元ID
@@ -54,6 +67,19 @@ export function addAuth(neID:string,data: Record<string, any>) {
});
}
/**
* 批量新增鉴权
* @param data 鉴权对象
* @returns object
*/
export function batchAuth(neID:string,data: Record<string, any>) {
return request({
url: `/udmUserManage/v1/auth/${neID}/${data.num}`,
method: 'post',
data: data,
});
}
/**
* 删除鉴权

View File

@@ -124,6 +124,8 @@ export default {
neUser: {
auth: {
getAll: 'Get ALL',
num:'Number allocation',
batchAddText: '批量新增',
},
base5G: {
neTypePlease: 'Query network element type',

View File

@@ -124,6 +124,8 @@ export default {
neUser: {
auth: {
getAll: '全部获取',
num:'放号数',
batchAddText: '批量新增',
},
base5G: {
neTypePlease: '查询网元类型',

View File

@@ -6,15 +6,7 @@ import { message, Modal, Form } from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
import { ColumnsType } from 'ant-design-vue/lib/table';
import {
listNeInfo,
getNeInfo,
addNeInfo,
updateNeInfo,
delNeInfo,
} from '@/api/configManage/neManage';
import { listAuth, getAuth, updateAuth,addAuth,delAuth} from '@/api/neUser/auth';
import { listAuth, getAuth, updateAuth, addAuth, delAuth, getAllAuth, batchAuth } from '@/api/neUser/auth';
import { parseDateToStr } from '@/utils/date-utils';
import useNeInfoStore from '@/store/modules/neinfo';
import useI18n from '@/hooks/useI18n';
@@ -28,6 +20,15 @@ let title = ref<string>((route.meta.title as string) ?? '标题');
/**网元参数 */
let neOtions = ref<Record<string, any>[]>([]);
/**全部获取开关*/
let getAllSwitch = ref<boolean>(false);
/**全部获取加载开关*/
let getAllLoading = ref<boolean>(false);
/**查询参数 */
let queryParams = reactive({
/**网元ID */
@@ -160,10 +161,14 @@ type ModalStateType = {
visibleByView: boolean;
/**新增框或修改框是否显示 */
visibleByEdit: boolean;
/**批量新增新增框是否显示 */
visibleByBatch: boolean;
/**标题 */
title: string;
/**表单数据 */
from: Record<string, any>;
/**表单数据 */
BatchForm: Record<string, any>;
/**确定按钮 loading */
confirmLoading: boolean;
};
@@ -172,6 +177,7 @@ type ModalStateType = {
let modalState: ModalStateType = reactive({
visibleByView: false,
visibleByEdit: false,
visibleByBatch: false,
title: 'UDM鉴权用户',
from: {
imsi: '',
@@ -180,6 +186,14 @@ let modalState: ModalStateType = reactive({
algoIndex: '',
opc: '',
},
BatchForm: {
num: '',
imsi: '',
amf: '',
ki: '',
algoIndex: '',
opc: '',
},
confirmLoading: false,
});
@@ -195,13 +209,28 @@ const modalStateFrom = Form.useForm(
})
);
/**对话框内表单属性和校验规则 */
const modalStateBatchFrom = Form.useForm(
modalState.BatchForm,
reactive({
num: [{ required: true, message: '放号数不能为空' },
{ min: 1, max: 100, message: '放号数必须小于等于100' }],
imsi: [{ required: true, message: 'IMSI不能为空' }],
amf: [{ required: true, message: 'AMF不能为空' }],
ki: [{ required: true, message: 'KI不能为空' }],
algo: [{ required: true, message: 'algoIndex不能为空' }],
opc: [{ required: true, message: 'OPC能为空' }],
})
);
/**
* 对话框弹出显示为 新增或者修改
* 对话框弹出显示为 新增或者修改,批量新增
* @param noticeId 网元id, 不传为新增
*/
function fnModalVisibleByEdit(row?: Record<string, any>) {
if (!row) {
modalStateFrom.resetFields();
function fnModalVisibleByEdit(batchFlag?: number, row?: Record<string, any>) {
if (!row && !batchFlag) {
modalStateFrom.resetFields(); //重置表单
modalState.title = '添加鉴权信息';
modalState.visibleByEdit = true;
} else {
@@ -209,7 +238,7 @@ function fnModalVisibleByEdit(row?: Record<string, any>) {
const hide = message.loading('正在打开...', 0);
modalState.confirmLoading = true;
const neID = queryParams.neId || '-';
getAuth(neID, row.imsi).then(res => {
getAuth(neID, row?.imsi).then(res => {
modalState.confirmLoading = false;
hide();
if (res.code === RESULT_CODE_SUCCESS) {
@@ -223,7 +252,21 @@ function fnModalVisibleByEdit(row?: Record<string, any>) {
}
}
/**
* 对话框弹出显示为 新增或者修改,批量新增
* @param noticeId 网元id, 不传为新增
*/
function fnModalVisibleByBatch(batchFlag?: number) {
if (batchFlag) {
modalStateBatchFrom.resetFields(); //重置表单
modalState.title = '批量添加鉴权信息';
modalState.visibleByBatch = true;
} else {
modalStateBatchFrom.resetFields(); //重置表单
modalState.title = '批量删除鉴权信息';
modalState.visibleByBatch = true;
}
}
/**
@@ -237,7 +280,7 @@ function fnModalOk() {
modalState.confirmLoading = true;
const from = toRaw(modalState.from);
const neID = queryParams.neId || '-';
const result = from.id ? updateAuth(from) : addAuth(neID,from);
const result = from.id ? updateAuth(from) : addAuth(neID, from);
const hide = message.loading({ content: t('common.loading') });
result
.then(res => {
@@ -266,6 +309,60 @@ function fnModalOk() {
});
}
/**
* 对话框弹出确认执行函数
* 进行表达规则校验
*/
function fnBatchModalOk() {
modalStateBatchFrom
.validate()
.then(e => {
modalState.confirmLoading = true;
const from = toRaw(modalState.BatchForm);
const neID = queryParams.neId || '-';
// const result = from.id ? updateAuth(from) : addAuth(neID, from);
const result = batchAuth(neID, from);
const hide = message.loading({ content: t('common.loading') });
result
.then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('common.msgSuccess', { msg: modalState.title }),
duration: 3,
});
modalState.visibleByBatch = false;
modalStateBatchFrom.resetFields();
fnGetList();
} else {
message.error({
content: `${res.msg}`,
duration: 3,
});
}
})
.finally(() => {
hide();
modalState.confirmLoading = false;
});
})
.catch(e => {
message.error(t('common.errorFields', { num: e.errorFields.length }), 3);
});
}
/**
* 批量添加对话框弹出关闭执行函数
* 进行表达规则校验
*/
function fnBatchModalCancel() {
modalState.visibleByBatch = false;
modalState.visibleByView = false;
modalStateBatchFrom.resetFields();
}
/**
* 对话框弹出关闭执行函数
* 进行表达规则校验
@@ -276,6 +373,7 @@ function fnModalCancel() {
modalStateFrom.resetFields();
}
/**
* UDM鉴权用户删除
* @param row 网元编号ID
@@ -285,11 +383,11 @@ function fnRecordDelete(row: Record<string, any>) {
title: '提示',
content: `确认删除IMSI编号为: ${row.imsi} 的用户嘛?`,
onOk() {
const key = 'delNotice';
message.loading({ content: '请稍等...', key });
const neID = queryParams.neId || '-';
delAuth(neID,row).then(res => {
delAuth(neID, row).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `删除成功`,
@@ -326,20 +424,23 @@ function fnGetList() {
});
}
/**全部获取 */
function fnGetAll() {
if (tableState.loading) return;
tableState.loading = true;
listAuth(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
}
tablePagination.total = res.total;
tableState.data = res.rows;
const neID = queryParams.neId || '-';
getAllSwitch.value = true;
getAllLoading.value = true;
getAllAuth(neID).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
tableState.loading = false;
getAllSwitch.value = false;
getAllLoading.value = false;
fnGetList();
}
tableState.loading = false;
});
}
@@ -376,42 +477,33 @@ onMounted(() => {
<template>
<PageContainer :title="title">
<a-card
v-show="tableState.seached"
:bordered="false"
:body-style="{ marginBottom: '24px', paddingBottom: 0 }"
>
<a-card v-show="tableState.seached" :bordered="false" :body-style="{ marginBottom: '24px', paddingBottom: 0 }">
<!-- 表格搜索栏 -->
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="UDM网元类型" name="neId ">
<a-select
v-model:value="queryParams.neId"
:options="neOtions"
allow-clear
placeholder="请选择网元"
/>
<a-select v-model:value="queryParams.neId" :options="neOtions" allow-clear placeholder="请选择网元" />
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="IMSI" name="imsi">
<a-input
v-model:value="queryParams.imsi"
allow-clear
placeholder="查询IMSI"
></a-input>
<a-input v-model:value="queryParams.imsi" allow-clear placeholder="查询IMSI"></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item>
<a-space :size="8">
<a-button type="primary" @click.prevent="fnGetList">
<template #icon><SearchOutlined /></template>
<template #icon>
<SearchOutlined />
</template>
{{ t('common.search') }}
</a-button>
<a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template>
<template #icon>
<ClearOutlined />
</template>
{{ t('common.reset') }}
</a-button>
</a-space>
@@ -425,14 +517,24 @@ onMounted(() => {
<!-- 插槽-卡片左侧侧 -->
<template #title>
<a-space :size="8" align="center">
<a-button type="primary" @click.prevent="fnModalVisibleByEdit()">
<template #icon><PlusOutlined /></template>
<a-button type="primary" @click.prevent="fnModalVisibleByEdit(0)">
<template #icon>
<PlusOutlined />
</template>
{{ t('common.addText') }}
</a-button>
<a-button type="primary" @click.prevent="fnGetAll">
<template #icon><PlusOutlined /></template>
<a-button type="primary" @click.prevent="fnGetAll" :disabled="getAllSwitch" :loading="getAllLoading">
<template #icon>
<ReloadOutlined />
</template>
{{ t('views.neUser.auth.getAll') }}
</a-button>
<a-button type="primary" @click.prevent="fnModalVisibleByEdit(1)">
<template #icon>
<PlusOutlined />
</template>
{{ t('views.neUser.auth.batchAddText') }}
</a-button>
</a-space>
</template>
@@ -441,30 +543,27 @@ onMounted(() => {
<a-space :size="8" align="center">
<a-tooltip>
<template #title>{{ t('common.searchBarText') }}</template>
<a-switch
v-model:checked="tableState.seached"
:checked-children="t('common.switch.show')"
:un-checked-children="t('common.switch.hide')"
size="small"
/>
<a-switch v-model:checked="tableState.seached" :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">
<template #icon><ReloadOutlined /></template>
<template #icon>
<ReloadOutlined />
</template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>{{ t('common.sizeText') }}</template>
<a-dropdown trigger="click">
<a-button type="text">
<template #icon><ColumnHeightOutlined /></template>
<template #icon>
<ColumnHeightOutlined />
</template>
</a-button>
<template #overlay>
<a-menu
:selected-keys="[tableState.size as string]"
@click="fnTableSize"
>
<a-menu :selected-keys="[tableState.size as string]" @click="fnTableSize">
<a-menu-item key="default">{{
t('common.size.default')
}}</a-menu-item>
@@ -482,32 +581,25 @@ onMounted(() => {
</template>
<!-- 表格列表 -->
<a-table
class="table"
row-key="imsi"
:columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data"
:size="tableState.size"
:pagination="tablePagination"
:scroll="{ x: true }"
>
<a-table class="table" row-key="imsi" :columns="tableColumns" :loading="tableState.loading"
:data-source="tableState.data" :size="tableState.size" :pagination="tablePagination" :scroll="{ x: true }">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'imsi'">
<a-space :size="8" align="center">
<a-tooltip>
<template #title>{{ t('common.editText') }}</template>
<a-button
type="link"
@click.prevent="fnModalVisibleByEdit(record)"
>
<template #icon><FormOutlined /></template>
<a-button type="link" @click.prevent="fnModalVisibleByEdit(0, record)">
<template #icon>
<FormOutlined />
</template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>{{ t('common.deleteText') }}</template>
<a-button type="link" @click.prevent="fnRecordDelete(record)">
<template #icon><DeleteOutlined /></template>
<template #icon>
<DeleteOutlined />
</template>
</a-button>
</a-tooltip>
</a-space>
@@ -517,29 +609,13 @@ onMounted(() => {
</a-card>
<!-- 新增框或修改框 -->
<a-modal
width="800px"
:keyboard="false"
:mask-closable="false"
:visible="modalState.visibleByEdit"
:title="modalState.title"
:confirm-loading="modalState.confirmLoading"
@ok="fnModalOk"
@cancel="fnModalCancel"
>
<a-form name="modalStateFrom" layout="horizontal" :label-col= "{ span: 7 }">
<a-modal width="800px" :keyboard="false" :mask-closable="false" :visible="modalState.visibleByEdit"
:title="modalState.title" :confirm-loading="modalState.confirmLoading" @ok="fnModalOk" @cancel="fnModalCancel">
<a-form name="modalStateFrom" layout="horizontal" :label-col="{ span: 7 }">
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
label="IMSI"
name="imsi"
v-bind="modalStateFrom.validateInfos.imsi"
>
<a-input
v-model:value="modalState.from.imsi"
allow-clear
placeholder="请输入IMSI"
>
<a-form-item label="IMSI" name="imsi" v-bind="modalStateFrom.validateInfos.imsi">
<a-input v-model:value="modalState.from.imsi" allow-clear placeholder="请输入IMSI">
<!-- <template #prefix>
<a-tooltip placement="topLeft">
<template #title> 填写创建的网元类型,:SMF </template>
@@ -550,46 +626,22 @@ onMounted(() => {
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
label="AMF"
name="amf"
v-bind="modalStateFrom.validateInfos.amf"
>
<a-input
v-model:value="modalState.from.amf"
allow-clear
placeholder="请输入AMF"
></a-input>
<a-form-item label="AMF" name="amf" v-bind="modalStateFrom.validateInfos.amf">
<a-input v-model:value="modalState.from.amf" allow-clear placeholder="请输入AMF"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
label="KI"
name="ki"
v-bind="modalStateFrom.validateInfos.ki"
>
<a-input
v-model:value="modalState.from.ki"
allow-clear
placeholder="请输入KI"
>
<a-form-item label="KI" name="ki" v-bind="modalStateFrom.validateInfos.ki">
<a-input v-model:value="modalState.from.ki" allow-clear placeholder="请输入KI">
</a-input>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
label="Algo Index"
name="algo"
v-bind="modalStateFrom.validateInfos.algo"
>
<a-input
v-model:value="modalState.from.algoIndex"
allow-clear
placeholder="请输入Algo Index"
>
<a-form-item label="Algo Index" name="algo" v-bind="modalStateFrom.validateInfos.algo">
<a-input v-model:value="modalState.from.algoIndex" allow-clear placeholder="请输入Algo Index">
</a-input>
</a-form-item>
</a-col>
@@ -597,16 +649,63 @@ onMounted(() => {
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
label="OPC"
name="opc"
v-bind="modalStateFrom.validateInfos.opc"
>
<a-input
v-model:value="modalState.from.opc"
allow-clear
placeholder="请输入OPC"
></a-input>
<a-form-item label="OPC" name="opc" v-bind="modalStateFrom.validateInfos.opc">
<a-input v-model:value="modalState.from.opc" allow-clear placeholder="请输入OPC"></a-input>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-modal>
<!-- 批量新增框 -->
<a-modal width="800px" :keyboard="false" :mask-closable="false" :visible="modalState.visibleByBatch"
:title="modalState.title" :confirm-loading="modalState.confirmLoading" @ok="fnBatchModalOk"
@cancel="fnBatchModalCancel">
<a-form name="modalStateBatchFrom" layout="horizontal" :label-col="{ span: 7 }">
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item :label="t('views.neUser.auth.num')" name="num" v-bind="modalStateBatchFrom.validateInfos.num">
<a-input v-model:value="modalState.BatchForm.num" allow-clear placeholder="请输入放号数"></a-input>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="IMSI" name="imsi" v-bind="modalStateBatchFrom.validateInfos.imsi">
<a-input v-model:value="modalState.BatchForm.imsi" allow-clear placeholder="请输入IMSI">
<!-- <template #prefix>
<a-tooltip placement="topLeft">
<template #title> 填写创建的网元类型,:SMF </template>
<InfoCircleOutlined style="color: rgba(0, 0, 0, 0.45)" />
</a-tooltip>
</template> -->
</a-input>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="AMF" name="amf" v-bind="modalStateBatchFrom.validateInfos.amf">
<a-input v-model:value="modalState.BatchForm.amf" allow-clear placeholder="请输入AMF"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="KI" name="ki" v-bind="modalStateBatchFrom.validateInfos.ki">
<a-input v-model:value="modalState.BatchForm.ki" allow-clear placeholder="请输入KI">
</a-input>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="Algo Index" name="algo" v-bind="modalStateBatchFrom.validateInfos.algo">
<a-input v-model:value="modalState.BatchForm.algoIndex" allow-clear placeholder="请输入Algo Index">
</a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="OPC" name="opc" v-bind="modalStateBatchFrom.validateInfos.opc">
<a-input v-model:value="modalState.BatchForm.opc" allow-clear placeholder="请输入OPC"></a-input>
</a-form-item>
</a-col>
</a-row>