feat: UDM用户导入导出

This commit is contained in:
TsMask
2023-09-22 17:52:36 +08:00
parent 56e409bec3
commit b59c906423
7 changed files with 1305 additions and 176 deletions

View File

@@ -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<string, any>) {
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<string, any>) {
}
/**
* 全部获取
* 查询重新更新加载全部
* @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<string, any>) {
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<string, any>,neID:string) {
export function updateAuth(data: Record<string, any>) {
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<string, any>) {
export function addAuth(data: Record<string, any>) {
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<string, any>) {
* @param data 鉴权对象
* @returns object
*/
export function batchAuth(neID:string,data: Record<string, any>) {
export function batchAuth(neID: string, data: Record<string, any>) {
return request({
url: `/udmUserManage/v1/auth/${neID}/${data.num}`,
method: 'post',
@@ -96,13 +106,12 @@ export function batchAuth(neID:string,data: Record<string, any>) {
});
}
/**
* 删除鉴权
* @param data 鉴权对象
* @returns object
*/
export function delAuth(neId:string,data: Record<string, any>) {
export function delAuth(neId: string, data: Record<string, any>) {
return request({
url: `/udmUserManage/v1/auth/${neId}/${data.imsi}`,
method: 'delete',

106
src/api/neUser/sub.ts Normal file
View File

@@ -0,0 +1,106 @@
import { request } from '@/plugins/http-fetch';
/**
* 签约列表导出
* @param query 查询参数
* @returns bolb
*/
export function exportSub(query: Record<string, any>) {
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<string, any>) {
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<string, any>) {
return request({
url: `/udmUserManage/v1/sub/${data.neId}`,
method: 'put',
data: data,
});
}
/**
* 新增签约
* @param data 签约对象
* @returns object
*/
export function addSub(neID: string, data: Record<string, any>) {
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',
});
}

View File

@@ -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',

View File

@@ -123,10 +123,16 @@ export default {
},
neUser: {
auth: {
getAll: '全部获取',
export: '导出',
import: '导入',
loadData: "更新数据",
num:'放号数',
batchAddText: '批量新增',
},
sub:{
export: '导出',
import: '导入',
loadData: "更新数据"
},
base5G: {
neTypePlease: '查询网元类型',

View File

@@ -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<string>((route.meta.title as string) ?? '标题');
/**网元参数 */
let neOtions = ref<Record<string, any>[]>([]);
/**全部获取开关*/
let getAllSwitch = ref<boolean>(false);
/**全部获取加载开关*/
let getAllLoading = ref<boolean>(false);
/**导出开关*/
let exportSwitch = ref<boolean>(false);
/**全部获取加载开关*/
let exportLoading = ref<boolean>(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<string, any>;
/**确定按钮 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<string, any>) {
if (!row) {
modalStateFrom.resetFields(); //重置表单
modalStateFrom.resetFields(); //重置表单
modalState.title = '添加鉴权信息';
modalState.visibleByEdit = true;
} else {
@@ -261,29 +260,30 @@ function fnModalVisibleByEdit(row?: Record<string, any>) {
*/
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<string, any>) {
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<string, any>) {
});
}
/**查询网元列表 */
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();
});
});
</script>
<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-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">
@@ -553,24 +601,50 @@ onMounted(() => {
</template>
{{ t('common.addText') }}
</a-button>
<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="fnModalVisibleByBatch(1)">
<template #icon>
<PlusOutlined />
</template>
{{ t('views.neUser.auth.batchAddText') }}
</a-button>
<a-button type="primary" @click.prevent="fnExport" :disabled="exportSwitch" :loading="exportLoading">
<template #icon>
<DownloadOutlined />
</template>
{{ t('views.neUser.auth.export') }}
<a-popconfirm
title="确认要重新加载数据吗?"
ok-text="确认"
cancel-text="取消"
:disabled="modalState.loadDataLoading"
@confirm="fnLoadData"
>
<a-button
type="dashed"
danger
:disabled="modalState.loadDataLoading"
:loading="modalState.loadDataLoading"
>
<template #icon><SyncOutlined /></template>
{{ t('views.neUser.auth.loadData') }}
</a-button>
</a-popconfirm>
<a-button type="dashed" @click.prevent="fnModalImportOpen">
<template #icon><ImportOutlined /></template>
{{ t('views.neUser.auth.import') }}
</a-button>
<a-popconfirm
title="确认导出全部鉴权用户数据吗?"
ok-text="txt文件"
ok-type="default"
@confirm="fnExportList('txt')"
cancel-text="csv文件"
@cancel="fnExportList('csv')"
>
<a-button type="dashed">
<template #icon><ExportOutlined /></template>
{{ t('views.neUser.auth.export') }}
</a-button>
</a-popconfirm>
</a-space>
</template>
@@ -579,8 +653,12 @@ 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>
@@ -599,7 +677,10 @@ onMounted(() => {
</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>
@@ -617,14 +698,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)">
<a-button
type="link"
@click.prevent="fnModalVisibleByEdit(record)"
>
<template #icon>
<FormOutlined />
</template>
@@ -645,13 +737,33 @@ 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>
@@ -662,22 +774,46 @@ 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>
@@ -685,8 +821,16 @@ 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>
@@ -694,19 +838,46 @@ onMounted(() => {
</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-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
: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">
<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>
@@ -717,22 +888,46 @@ onMounted(() => {
</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
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-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-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>
@@ -740,13 +935,31 @@ onMounted(() => {
<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
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>
</a-form>
</a-modal>
<!-- 上传导入表格数据文件框 -->
<UploadImport
:title="modalUploadImportState.title"
v-model:visible="modalUploadImportState.visible"
:file-size="5"
:file-ext="['.csv', '.txt']"
:upload-file-method="fnModalImportData"
@close="fnModalUploadImportClose"
/>
</PageContainer>
</template>

View File

@@ -0,0 +1,800 @@
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { reactive, ref, onMounted, toRaw } from 'vue';
import { PageContainer } from '@ant-design-vue/pro-layout';
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 UploadImport from '@/components/UploadImport/index.vue';
import {
loadSub,
listSub,
getSub,
updateSub,
addSub,
delSub,
importSubData,
exportSub,
} from '@/api/neUser/sub';
import useNeInfoStore from '@/store/modules/neinfo';
import useI18n from '@/hooks/useI18n';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import saveAs from 'file-saver';
const { t } = useI18n();
const route = useRoute();
/**路由标题 */
let title = ref<string>((route.meta.title as string) ?? '标题');
/**网元参数 */
let neOtions = ref<Record<string, any>[]>([]);
/**查询参数 */
let queryParams = reactive({
/**网元ID */
neId: undefined,
/**移动编号 */
imsi: '',
/**移动号 */
msisdn: '',
/**排序字段 */
sortField: 'imsi',
/**排序方式 */
sortOrder: 'asc',
/**当前页数 */
pageNum: 1,
/**每页条数 */
pageSize: 20,
});
/**查询参数重置 */
function fnQueryReset() {
queryParams = Object.assign(queryParams, {
imsi: '',
msisdn: '',
sortField: 'imsi',
sortOrder: 'asc',
pageNum: 1,
pageSize: 20,
});
tablePagination.current = 1;
tablePagination.pageSize = 20;
fnGetList();
}
/**表格状态类型 */
type TabeStateType = {
/**加载等待 */
loading: boolean;
/**紧凑型 */
size: SizeType;
/**搜索栏 */
seached: boolean;
/**记录数据 */
data: object[];
};
/**表格状态 */
let tableState: TabeStateType = reactive({
loading: false,
size: 'middle',
seached: true,
data: [],
});
/**表格字段列 */
let tableColumns: ColumnsType = [
{
title: 'IMSI',
dataIndex: 'imsi',
align: 'center',
},
{
title: 'MSISDN',
dataIndex: 'msisdn',
align: 'center',
},
{
title: 'Subscribed AMBR Temp',
dataIndex: 'ambr',
align: 'center',
},
{
title: 'Subscribed SNSSAIs Temp',
dataIndex: 'sar',
align: 'center',
},
{
title: 'RAT Restriction',
dataIndex: 'rat',
align: 'center',
},
{
title: 'Forbidden Areas Temp',
dataIndex: 'arfb',
align: 'center',
},
{
title: 'Service Area Restrict Temp',
dataIndex: 'nssai',
align: 'center',
},
{
title: 'CN Type Restriction',
dataIndex: 'cn',
align: 'center',
},
{
title: 'Subscribed Data',
dataIndex: 'smData',
align: 'center',
},
{
title: 'EPS Flag',
dataIndex: 'epsFlag',
align: 'center',
},
{
title: t('common.operate'),
key: 'imsi',
align: 'center',
},
];
/**表格分页器参数 */
let tablePagination = reactive({
/**当前页数 */
current: 1,
/**每页条数 */
pageSize: 20,
/**默认的每页条数 */
defaultPageSize: 20,
/**指定每页可以显示多少条 */
pageSizeOptions: ['10', '20', '50', '100'],
/**只有一页时是否隐藏分页器 */
hideOnSinglePage: false,
/**是否可以快速跳转至某页 */
showQuickJumper: true,
/**是否可以改变 pageSize */
showSizeChanger: true,
/**数据总数 */
total: 0,
showTotal: (total: number) => t('common.tablePaginationTotal', { total }),
onChange: (page: number, pageSize: number) => {
tablePagination.current = page;
tablePagination.pageSize = pageSize;
queryParams.pageNum = page;
queryParams.pageSize = pageSize;
fnGetList();
},
});
/**表格紧凑型变更操作 */
function fnTableSize({ key }: MenuInfo) {
tableState.size = key as SizeType;
}
/**对话框对象信息状态类型 */
type ModalStateType = {
/**详情框是否显示 */
visibleByView: boolean;
/**新增框或修改框是否显示 */
visibleByEdit: boolean;
/**标题 */
title: string;
/**表单数据 */
from: Record<string, any>;
/**确定按钮 loading */
confirmLoading: boolean;
/**更新加载数据按钮 loading */
loadDataLoading: boolean;
};
/**对话框对象信息状态 */
let modalState: ModalStateType = reactive({
visibleByView: false,
visibleByEdit: false,
title: 'UDM签约用户',
from: {
msisdn: '',
imsi: '',
ambr: '',
nssai: '',
rat: '',
arfb: '',
sar: '',
cn: '',
smData: '',
smfSel: '',
epsDat: '',
neId: '',
epsFlag: '',
epsOdb: '',
hplmnOdb: '',
ard: '',
epstpl: '',
contextId: '',
apnContext: '',
staticIp: '',
},
confirmLoading: false,
loadDataLoading: false,
});
/**对话框内表单属性和校验规则 */
const modalStateFrom = Form.useForm(
modalState.from,
reactive({
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(imsi?: string) {
if (!imsi) {
modalStateFrom.resetFields();
modalState.title = '添加签约信息';
modalState.visibleByEdit = true;
} else {
if (modalState.confirmLoading) return;
const hide = message.loading('正在打开...', 0);
modalState.confirmLoading = true;
const neID = queryParams.neId || '-';
getSub(neID, imsi).then(res => {
modalState.confirmLoading = false;
hide();
if (res.code === RESULT_CODE_SUCCESS) {
modalState.from = Object.assign(modalState.from, res.data);
modalState.title = '修改签约信息';
modalState.visibleByEdit = true;
} else {
message.error(`获取签约信息失败`, 2);
}
});
}
}
/**
* 对话框弹出确认执行函数
* 进行表达规则校验
*/
function fnModalOk() {
modalStateFrom
.validate()
.then(e => {
modalState.confirmLoading = true;
const from = toRaw(modalState.from);
const neID = queryParams.neId || '-';
const result = from.id ? updateSub(from) : addSub(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.visibleByEdit = false;
modalStateFrom.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 fnModalCancel() {
modalState.visibleByEdit = false;
modalState.visibleByView = false;
modalStateFrom.resetFields();
}
/**
* UDM签约用户删除
* @param imsi 网元编号ID
*/
function fnRecordDelete(imsi: string) {
const neID = queryParams.neId;
if (!neID) return;
Modal.confirm({
title: '提示',
content: `确认删除IMSI编号为: ${imsi} 的签约用户嘛?`,
onOk() {
const key = 'delSub';
message.loading({ content: '请稍等...', key });
delSub(neID, imsi).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `删除成功`,
key,
duration: 2,
});
fnGetList();
} else {
message.error({
content: `${res.msg}`,
key: key,
duration: 2,
});
}
});
},
});
}
/**列表导出 */
function fnExportList(type: string) {
const neID = queryParams.neId;
if (!neID) return;
const key = 'exportSub';
message.loading({ content: '请稍等...', key });
exportSub({
neId: neID,
type: type,
}).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已完成导出`,
key,
duration: 2,
});
saveAs(res.data, `UDMSub_${Date.now()}.${type}`);
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
}
/**重新加载数据 */
function fnLoadData() {
const neID = queryParams.neId;
if (tableState.loading || !neID) return;
modalState.loadDataLoading = true;
loadSub(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;
listSub(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 importSubData(neID, data);
}
onMounted(() => {
// 获取网元网元列表
useNeInfoStore()
.fnNelist()
.then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
if (res.data.length > 0) {
let arr: Record<string, any>[] = [];
res.data.forEach(i => {
if (i.neType === 'UDM') {
arr.push({ value: i.neId, label: i.neName });
}
});
neOtions.value = arr;
if (arr.length > 0) {
queryParams.neId = arr[0].value;
}
}
} else {
message.warning({
content: `暂无网元列表数据`,
duration: 2,
});
}
})
.finally(() => {
// 获取列表数据
fnGetList();
});
});
</script>
<template>
<PageContainer :title="title">
<a-card
v-show="tableState.seached"
:bordered="false"
:body-style="{ marginBottom: '24px', paddingBottom: 0 }"
>
<!-- 表格搜索栏 -->
<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-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-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="MSISDN" name="msisdn">
<a-input
v-model:value="queryParams.msisdn"
allow-clear
placeholder="查询MSISDN"
></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>
{{ t('common.search') }}
</a-button>
<a-button type="default" @click.prevent="fnQueryReset">
<template #icon><ClearOutlined /></template>
{{ t('common.reset') }}
</a-button>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
<a-card :bordered="false" :body-style="{ padding: '0px' }">
<!-- 插槽-卡片左侧侧 -->
<template #title>
<a-space :size="8" align="center">
<a-button type="primary" @click.prevent="fnModalVisibleByEdit()">
<template #icon><PlusOutlined /></template>
{{ t('common.addText') }}
</a-button>
<a-popconfirm
title="确认要重新加载数据吗?"
ok-text="确认"
cancel-text="取消"
:disabled="modalState.loadDataLoading"
@confirm="fnLoadData"
>
<a-button
type="dashed"
danger
:disabled="modalState.loadDataLoading"
:loading="modalState.loadDataLoading"
>
<template #icon><SyncOutlined /></template>
{{ t('views.neUser.sub.loadData') }}
</a-button>
</a-popconfirm>
<a-button type="dashed" @click.prevent="fnModalImportOpen">
<template #icon><ImportOutlined /></template>
{{ t('views.neUser.sub.import') }}
</a-button>
<a-popconfirm
title="确认导出全部签约用户数据吗?"
ok-text="txt文件"
ok-type="default"
@confirm="fnExportList('txt')"
cancel-text="csv文件"
@cancel="fnExportList('csv')"
>
<a-button type="dashed">
<template #icon><ExportOutlined /></template>
{{ t('views.neUser.sub.export') }}
</a-button>
</a-popconfirm>
</a-space>
</template>
<!-- 插槽-卡片右侧 -->
<template #extra>
<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-tooltip>
<a-tooltip>
<template #title>{{ t('common.reloadText') }}</template>
<a-button type="text" @click.prevent="fnGetList">
<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>
</a-button>
<template #overlay>
<a-menu
:selected-keys="[tableState.size as string]"
@click="fnTableSize"
>
<a-menu-item key="default">{{
t('common.size.default')
}}</a-menu-item>
<a-menu-item key="middle">{{
t('common.size.middle')
}}</a-menu-item>
<a-menu-item key="small">{{
t('common.size.small')
}}</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-tooltip>
</a-space>
</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 }"
>
<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.imsi)"
>
<template #icon><FormOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>{{ t('common.deleteText') }}</template>
<a-button
type="link"
@click.prevent="fnRecordDelete(record.imsi)"
>
<template #icon><DeleteOutlined /></template>
</a-button>
</a-tooltip>
</a-space>
</template>
</template>
</a-table>
</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-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"
>
<template #prefix>
<a-tooltip placement="topLeft">
<template #title>
SUPI=MCC+MNC+MSIN MCC=移动国家号码, 由三位数字组成
MNC=移动网络号由两位数字组成
MSIN=移动客户识别码采用等长10位数字构成
</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="cn"
name="cn"
v-bind="modalStateFrom.validateInfos.cn"
>
<a-input
v-model:value="modalState.from.cn"
allow-clear
placeholder="请输入cn"
></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="4G EPS User Template Name"
name="epstpl"
v-bind="modalStateFrom.validateInfos.epstpl"
>
<a-input
v-model:value="modalState.from.epstpl"
allow-clear
placeholder="请输入KI"
>
</a-input>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
label="4G Context ID"
name="contextId"
v-bind="modalStateFrom.validateInfos.contextId"
>
<a-input
v-model:value="modalState.from.contextId"
allow-clear
placeholder="请输入4G Context ID"
>
</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="4G Static IP"
name="staticIp"
v-bind="modalStateFrom.validateInfos.staticIp"
>
<a-input
v-model:value="modalState.from.staticIp"
allow-clear
placeholder="静态IP地址"
>
<template #prefix>
<a-tooltip placement="topLeft">
<template #title>
指定手机用户上网时使用的静态IP地址为空时表示使用动态IP地址
</template>
<InfoCircleOutlined style="color: rgba(0, 0, 0, 0.45)" />
</a-tooltip>
</template>
</a-input>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-modal>
<!-- 上传导入表格数据文件框 -->
<UploadImport
:title="modalUploadImportState.title"
v-model:visible="modalUploadImportState.visible"
:file-size="5"
:file-ext="['.csv', '.txt']"
:upload-file-method="fnModalImportData"
@close="fnModalUploadImportClose"
/>
</PageContainer>
</template>
<style lang="less" scoped>
.table :deep(.ant-pagination) {
padding: 0 24px;
}
</style>

View File

@@ -1,11 +0,0 @@
<script lang="ts" setup>
import { ref } from 'vue';
const msg = ref<string>('愿这世间美好与你环环相扣');
</script>
<template>
<h1>{{ msg }}</h1>
</template>
<style lang="less" scoped></style>