From fb9f465e121dbb44c41a0e132d56636356469e8b Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Fri, 22 Sep 2023 15:26:45 +0800 Subject: [PATCH] =?UTF-8?q?--=E6=89=B9=E9=87=8F=E6=96=B0=E5=A2=9E=E9=89=B4?= =?UTF-8?q?=E6=9D=83=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/neUser/auth.ts | 26 +++ src/i18n/locales/en-US.ts | 2 + src/i18n/locales/zh-CN.ts | 2 + src/views/neUser/auth/index.vue | 377 ++++++++++++++++++++------------ 4 files changed, 268 insertions(+), 139 deletions(-) diff --git a/src/api/neUser/auth.ts b/src/api/neUser/auth.ts index fb42be81..fe6b6758 100644 --- a/src/api/neUser/auth.ts +++ b/src/api/neUser/auth.ts @@ -15,6 +15,19 @@ export function listAuth(query: Record) { }); } +/** + * 全部获取 + * @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) { }); } +/** + * 批量新增鉴权 + * @param data 鉴权对象 + * @returns object + */ +export function batchAuth(neID:string,data: Record) { + return request({ + url: `/udmUserManage/v1/auth/${neID}/${data.num}`, + method: 'post', + data: data, + }); +} + /** * 删除鉴权 diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 39de3c37..f4e79c5e 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -124,6 +124,8 @@ export default { neUser: { auth: { getAll: 'Get ALL', + num:'Number allocation', + batchAddText: '批量新增', }, base5G: { neTypePlease: 'Query network element type', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index bb015259..d35eafd1 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -124,6 +124,8 @@ export default { neUser: { auth: { getAll: '全部获取', + num:'放号数', + batchAddText: '批量新增', }, base5G: { neTypePlease: '查询网元类型', diff --git a/src/views/neUser/auth/index.vue b/src/views/neUser/auth/index.vue index e069a658..3c9806da 100644 --- a/src/views/neUser/auth/index.vue +++ b/src/views/neUser/auth/index.vue @@ -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((route.meta.title as string) ?? '标题'); /**网元参数 */ let neOtions = ref[]>([]); + +/**全部获取开关*/ +let getAllSwitch = ref(false); + + +/**全部获取加载开关*/ +let getAllLoading = ref(false); + + /**查询参数 */ let queryParams = reactive({ /**网元ID */ @@ -160,10 +161,14 @@ type ModalStateType = { visibleByView: boolean; /**新增框或修改框是否显示 */ visibleByEdit: boolean; + /**批量新增新增框是否显示 */ + visibleByBatch: boolean; /**标题 */ title: string; /**表单数据 */ from: Record; + /**表单数据 */ + BatchForm: Record; /**确定按钮 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) { - if (!row) { - modalStateFrom.resetFields(); +function fnModalVisibleByEdit(batchFlag?: number, row?: Record) { + if (!row && !batchFlag) { + modalStateFrom.resetFields(); //重置表单 modalState.title = '添加鉴权信息'; modalState.visibleByEdit = true; } else { @@ -209,7 +238,7 @@ function fnModalVisibleByEdit(row?: Record) { 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) { } } - +/** + * 对话框弹出显示为 新增或者修改,批量新增 + * @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) { 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(() => {