diff --git a/src/api/neUser/auth.ts b/src/api/neUser/auth.ts index a7c1cf29..77a25769 100644 --- a/src/api/neUser/auth.ts +++ b/src/api/neUser/auth.ts @@ -1,7 +1,34 @@ -import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { request } from '@/plugins/http-fetch'; -import { parseObjLineToHump } from '@/utils/parse-utils'; -import { toRaw } from 'vue'; + +/** + * 签约鉴权导出 + * @param query 查询参数 + * @returns bolb + */ +export function exportAuth(query: Record) { + return request({ + url: '/udmUserManage/v1/authExport', + method: 'post', + data: query, + responseType: 'blob', + }); +} + +/** + * 导入鉴权数据 + * @param neId 网元ID + * @param data 表单数据对象 + * @returns object + */ +export function importAuthData(neId: string, data: FormData) { + return request({ + url: `/udmUserManage/v1/authImport/${neId}`, + method: 'post', + data, + dataType: 'form-data', + }); +} + /** * 查询鉴权列表 * @param query 查询参数 @@ -16,34 +43,18 @@ export function listAuth(query: Record) { } /** - * 全部获取 + * 查询重新更新加载全部 * @param neId 网元ID * @returns object */ -export function getAllAuth(neId:string) { +export function loadAuth(neId: string) { return request({ url: `/udmUserManage/v1/authSave/${neId}`, method: 'post', - timeout:600*1000 + timeout: 60 * 1000, }); } -/** - * 导出鉴权数据 - * @param neId 网元ID - * @returns object - */ -export function exportAuth(data: Record) { - console.log(toRaw(data)) - return request({ - url: 'udmUserManage/v1/authExport', - method: 'post', - data: data, - responseType: 'blob', - }); -} - - /** * 查询鉴权详细 * @param neId 网元ID @@ -61,23 +72,22 @@ export function getAuth(neId: string, imsi: string) { * @param data 鉴权对象 * @returns object */ -export function updateAuth(data: Record,neID:string) { +export function updateAuth(data: Record) { return request({ - url: `/udmUserManage/v1/auth/${neID}`, + url: `/udmUserManage/v1/auth/${data.neId}`, method: 'put', data: data, }); } - /** * 新增鉴权 * @param data 鉴权对象 * @returns object */ -export function addAuth(neID:string,data: Record) { +export function addAuth(data: Record) { return request({ - url: `/udmUserManage/v1/auth/${neID}`, + url: `/udmUserManage/v1/auth/${data.neId}`, method: 'post', data: data, }); @@ -88,7 +98,7 @@ export function addAuth(neID:string,data: Record) { * @param data 鉴权对象 * @returns object */ -export function batchAuth(neID:string,data: Record) { +export function batchAuth(neID: string, data: Record) { return request({ url: `/udmUserManage/v1/auth/${neID}/${data.num}`, method: 'post', @@ -96,13 +106,12 @@ export function batchAuth(neID:string,data: Record) { }); } - /** * 删除鉴权 * @param data 鉴权对象 * @returns object */ -export function delAuth(neId:string,data: Record) { +export function delAuth(neId: string, data: Record) { return request({ url: `/udmUserManage/v1/auth/${neId}/${data.imsi}`, method: 'delete', diff --git a/src/api/neUser/sub.ts b/src/api/neUser/sub.ts new file mode 100644 index 00000000..716e2de8 --- /dev/null +++ b/src/api/neUser/sub.ts @@ -0,0 +1,106 @@ +import { request } from '@/plugins/http-fetch'; + +/** + * 签约列表导出 + * @param query 查询参数 + * @returns bolb + */ +export function exportSub(query: Record) { + return request({ + url: '/udmUserManage/v1/subExport', + method: 'post', + data: query, + responseType: 'blob', + }); +} + +/** + * 导入签约数据 + * @param neId 网元ID + * @param data 表单数据对象 + * @returns object + */ +export function importSubData(neId: string, data: FormData) { + return request({ + url: `/udmUserManage/v1/subImport/${neId}`, + method: 'post', + data, + dataType: 'form-data', + }); +} + +/** + * 查询重新更新加载全部 + * @param neId 网元ID + * @returns object + */ +export function loadSub(neId: string) { + return request({ + url: `/udmUserManage/v1/subSave/${neId}`, + method: 'post', + timeout: 60 * 1000, + }); +} + +/** + * 查询签约列表 + * @param query 查询参数 + * @returns object + */ +export function listSub(query: Record) { + return request({ + url: '/udmUserManage/v1/subs', + method: 'get', + params: query, + }); +} + +/** + * 查询签约详细 + * @param neId 网元ID + * @returns object + */ +export function getSub(neId: string, imsi: string) { + return request({ + url: `/udmUserManage/v1/subInfo/${neId}/${imsi}`, + method: 'get', + }); +} + +/** + * 修改签约 + * @param data 签约对象 + * @returns object + */ +export function updateSub(data: Record) { + return request({ + url: `/udmUserManage/v1/sub/${data.neId}`, + method: 'put', + data: data, + }); +} + +/** + * 新增签约 + * @param data 签约对象 + * @returns object + */ +export function addSub(neID: string, data: Record) { + return request({ + url: `/udmUserManage/v1/sub/${neID}`, + method: 'post', + data: data, + }); +} + +/** + * 删除签约 + * @param data 签约对象 + * @returns object + */ +export function delSub(neId: string, imsi: string) { + return request({ + url: `/udmUserManage/v1/sub/${neId}/${imsi}`, + method: 'delete', + }); +} diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 2ce3476a..cb3f8a3e 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -123,10 +123,16 @@ export default { }, neUser: { auth: { - getAll: 'Get ALL', + export: 'Export', + import: 'Import', + loadData: "LoadData", num:'Number allocation', batchAddText: 'Batch Add', + }, + sub:{ export: 'Export', + import: 'Import', + loadData: "LoadData" }, base5G: { neTypePlease: 'Query network element type', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index dd4b1b0b..8acb8d4a 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -123,10 +123,16 @@ export default { }, neUser: { auth: { - getAll: '全部获取', + export: '导出', + import: '导入', + loadData: "更新数据", num:'放号数', batchAddText: '批量新增', + }, + sub:{ export: '导出', + import: '导入', + loadData: "更新数据" }, base5G: { neTypePlease: '查询网元类型', diff --git a/src/views/neUser/auth/index.vue b/src/views/neUser/auth/index.vue index 937b03c4..c584fdc0 100644 --- a/src/views/neUser/auth/index.vue +++ b/src/views/neUser/auth/index.vue @@ -2,16 +2,26 @@ import { useRoute } from 'vue-router'; import { reactive, ref, onMounted, toRaw } from 'vue'; import { PageContainer } from '@ant-design-vue/pro-layout'; -import { message, Modal, Form } from 'ant-design-vue/lib'; +import { message, Modal, Form, notification } 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 { listAuth, getAuth, updateAuth, addAuth, delAuth, getAllAuth,exportAuth,batchAuth } from '@/api/neUser/auth'; -import { parseDateToStr } from '@/utils/date-utils'; +import UploadImport from '@/components/UploadImport/index.vue'; +import { + listAuth, + getAuth, + updateAuth, + addAuth, + delAuth, + loadAuth, + exportAuth, + importAuthData, + batchAuth, +} from '@/api/neUser/auth'; import useNeInfoStore from '@/store/modules/neinfo'; import useI18n from '@/hooks/useI18n'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; -import {saveAs} from "file-saver"; +import { saveAs } from 'file-saver'; const { t } = useI18n(); const route = useRoute(); @@ -21,17 +31,6 @@ let title = ref((route.meta.title as string) ?? '标题'); /**网元参数 */ let neOtions = ref[]>([]); - -/**全部获取开关*/ -let getAllSwitch = ref(false); -/**全部获取加载开关*/ -let getAllLoading = ref(false); - -/**导出开关*/ -let exportSwitch = ref(false); -/**全部获取加载开关*/ -let exportLoading = ref(false); - /**查询参数 */ let queryParams = reactive({ /**网元ID */ @@ -51,7 +50,6 @@ let queryParams = reactive({ /**查询参数重置 */ function fnQueryReset() { queryParams = Object.assign(queryParams, { - neId: undefined, imsi: '', sortField: 'imsi', sortOrder: 'asc', @@ -73,8 +71,6 @@ type TabeStateType = { seached: boolean; /**记录数据 */ data: object[]; - /**勾选记录 */ - selectedRowKeys: (string | number)[]; }; /**表格状态 */ @@ -83,7 +79,6 @@ let tableState: TabeStateType = reactive({ size: 'middle', seached: true, data: [], - selectedRowKeys: [], }); /**表格字段列 */ @@ -174,6 +169,8 @@ type ModalStateType = { BatchForm: Record; /**确定按钮 loading */ confirmLoading: boolean; + /**更新加载数据按钮 loading */ + loadDataLoading: boolean; }; /**对话框对象信息状态 */ @@ -198,6 +195,7 @@ let modalState: ModalStateType = reactive({ opc: '', }, confirmLoading: false, + loadDataLoading: false, }); /**对话框内表单属性和校验规则 */ @@ -216,8 +214,10 @@ const modalStateFrom = Form.useForm( const modalStateBatchFrom = Form.useForm( modalState.BatchForm, reactive({ - num: [{ required: true, message: '放号数不能为空' }, - { min: 1, max: 100, message: '放号数必须小于等于100' }], + 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不能为空' }], @@ -226,14 +226,13 @@ const modalStateBatchFrom = Form.useForm( }) ); - /** * 对话框弹出显示为 新增或者修改 * @param noticeId 网元id, 不传为新增 */ function fnModalVisibleByEdit(row?: Record) { if (!row) { - modalStateFrom.resetFields(); //重置表单 + modalStateFrom.resetFields(); //重置表单 modalState.title = '添加鉴权信息'; modalState.visibleByEdit = true; } else { @@ -261,29 +260,30 @@ function fnModalVisibleByEdit(row?: Record) { */ function fnModalVisibleByBatch(batchFlag?: number) { if (batchFlag) { - modalStateBatchFrom.resetFields(); //重置表单 + modalStateBatchFrom.resetFields(); //重置表单 modalState.title = '批量添加鉴权信息'; modalState.visibleByBatch = true; } else { - modalStateBatchFrom.resetFields(); //重置表单 + modalStateBatchFrom.resetFields(); //重置表单 modalState.title = '批量删除鉴权信息'; modalState.visibleByBatch = true; } } - /** * 对话框弹出确认执行函数 * 进行表达规则校验 */ function fnModalOk() { + const neID = queryParams.neId; + if (!neID) return; modalStateFrom .validate() .then(e => { modalState.confirmLoading = true; const from = toRaw(modalState.from); - const neID = queryParams.neId || '-'; - const result = from.id ? updateAuth(from,neID) : addAuth(neID, from); + from.neId = neID + const result = from.id ? updateAuth(from) : addAuth(from); const hide = message.loading({ content: t('common.loading') }); result .then(res => { @@ -312,7 +312,6 @@ function fnModalOk() { }); } - /** * 对话框弹出确认执行函数 * 进行表达规则校验 @@ -364,8 +363,6 @@ function fnBatchModalCancel() { modalStateBatchFrom.resetFields(); } - - /** * 对话框弹出关闭执行函数 * 进行表达规则校验 @@ -376,7 +373,6 @@ function fnModalCancel() { modalStateFrom.resetFields(); } - /** * UDM鉴权用户删除 * @param row 网元编号ID @@ -386,7 +382,6 @@ function fnRecordDelete(row: Record) { title: '提示', content: `确认删除IMSI编号为: ${row.imsi} 的用户嘛?`, onOk() { - const key = 'delNotice'; message.loading({ content: '请稍等...', key }); const neID = queryParams.neId || '-'; @@ -410,62 +405,24 @@ function fnRecordDelete(row: Record) { }); } -/**查询网元列表 */ -function fnGetList() { - 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; - } - tableState.loading = false; - }); -} - - - -/**全部获取 */ -function fnGetAll() { - if (tableState.loading) return; - tableState.loading = true; - 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(); - - } - }); -} - -/**导出鉴权用户 */ -function fnExport() { - const neID = queryParams.neId || '-'; - exportSwitch.value = true; - exportLoading.value = true; - const key = 'exportAuthUser'; - exportAuth({neId:neID,type:"csv"}).then(res => { +/**列表导出 */ +function fnExportList(type: string) { + const neID = queryParams.neId; + if (!neID) return; + const key = 'exportAuth'; + message.loading({ content: '请稍等...', key }); + exportAuth({ + neId: neID, + type: type, + }).then(res => { if (res.code === RESULT_CODE_SUCCESS) { message.success({ content: `已完成导出`, key, duration: 2, }); - saveAs(res.data, `udm_${Date.now()}.csv`); - exportSwitch.value = false; - exportLoading.value = false; + saveAs(res.data, `UDMAuth_${Date.now()}.${type}`); } else { - exportSwitch.value = false; - exportLoading.value = false; message.error({ content: `${res.msg}`, key, @@ -475,9 +432,83 @@ function fnExport() { }); } +/**重新加载数据 */ +function fnLoadData() { + const neID = queryParams.neId; + if (tableState.loading || !neID) return; + modalState.loadDataLoading = true; + loadAuth(neID).then(res => { + modalState.loadDataLoading = false; + if (res.code === RESULT_CODE_SUCCESS) { + notification.success({ + message: '更新数据', + description: `成功获取更新数据:${res.data}条,系统内部进行数据更新,请勿重复点击获取!!!`, + duration: 10, + }); + } else { + message.error({ + content: `获取数据失败`, + duration: 3, + }); + } + }); +} + +/**查询网元列表 */ +function fnGetList() { + if (tableState.loading) return; + tableState.loading = true; + listAuth(toRaw(queryParams)).then(res => { + if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) { + tablePagination.total = res.total; + tableState.data = res.rows; + } + tableState.loading = false; + }); +} + +/**对话框表格信息导入对象信息状态类型 */ +type ModalUploadImportStateType = { + /**是否显示 */ + visible: boolean; + /**标题 */ + title: string; + /**导入模板下载触发 */ + templateDownload: boolean; +}; + +/**对话框表格信息导入对象信息状态 */ +let modalUploadImportState: ModalUploadImportStateType = reactive({ + visible: false, + title: '数据导入', + templateDownload: false, +}); + +/** + * 对话框表格信息导入确认执行函数 + * @param isUpload 是否已上传文件 + */ +function fnModalUploadImportClose(isUpload: boolean) { + if (isUpload) { + fnGetList(); + } +} + +/**对话框表格信息导入弹出窗口 */ +function fnModalImportOpen() { + modalUploadImportState.visible = true; +} + +/**列表导入数据 */ +async function fnModalImportData(data: FormData) { + const neID = queryParams.neId; + if (!neID) { + return Promise.reject('未知网元'); + } + return importAuthData(neID, data); +} + onMounted(() => { - // 获取列表数据 - fnGetList(); // 获取网元网元列表 useNeInfoStore() .fnNelist() @@ -501,24 +532,41 @@ onMounted(() => { duration: 2, }); } + }) + .finally(() => { + // 获取列表数据 + fnGetList(); }); }); {{ t('common.addText') }} - - - {{ t('views.neUser.auth.getAll') }} - + {{ t('views.neUser.auth.batchAddText') }} - - - {{ t('views.neUser.auth.export') }} + + + + + {{ t('views.neUser.auth.loadData') }} + + + + + + {{ t('views.neUser.auth.import') }} + + + + + {{ t('views.neUser.auth.export') }} + + @@ -579,8 +653,12 @@ onMounted(() => { - + @@ -599,7 +677,10 @@ onMounted(() => { - +