diff --git a/src/api/neUser/auth.ts b/src/api/neUser/auth.ts index 9f0565c9..15a08b9d 100644 --- a/src/api/neUser/auth.ts +++ b/src/api/neUser/auth.ts @@ -125,9 +125,9 @@ export function delAuth(neId: string, data: Record) { * @param data 鉴权对象 * @returns object */ -export function batchDelAuth(neId:string,data: Record) { +export function batchDelAuth(data: Record) { return request({ - url: `/udmUserManage/v1/auth/${neId}/${data.imsi}/${data.num}`, + url: `/udmUserManage/v1/auth/${data.neID}/${data.imsi}/${data.num}`, method: 'delete', }); } diff --git a/src/api/neUser/sub.ts b/src/api/neUser/sub.ts index 01cf7bc6..80c00afe 100644 --- a/src/api/neUser/sub.ts +++ b/src/api/neUser/sub.ts @@ -70,12 +70,13 @@ export function getSub(neId: string, imsi: string) { /** * 修改签约 - * @param data 签约对象 + * @param data 签约对象 + * @param neId 网元ID * @returns object */ -export function updateSub(data: Record) { +export function updateSub(neId:string,data: Record) { return request({ - url: `/udmUserManage/v1/sub/${data.neId}`, + url: `/udmUserManage/v1/sub/${neId}`, method: 'put', data: data, }); @@ -87,27 +88,6 @@ export function updateSub(data: Record) { * @returns object */ export function addSub(neID: string, data: Record) { - console.log(data); - let ardArr = [0, 0, 0, 0, 0, 0, 0, 0]; - let hplmnArr = [0, 0, 0, 0, 0, 0, 0, 0]; - let odbArr = [0, 0, 0, 0, 0, 0, 0, 0]; - - data.ard.forEach((item: any) => { - ardArr[item] = 1; - }); - - data.hplmnOdb.forEach((item: any) => { - hplmnArr[item] = 1; - }); - - data.epsOdb.forEach((item: any) => { - odbArr[item] = 1; - }); - - data.epsOdb = '' + parseInt(odbArr.join(''), 2); - data.hplmnOdb = '' + parseInt(hplmnArr.join(''), 2); - data.ard = '' + parseInt(ardArr.join(''), 2); - data.cn = '3'; return request({ url: `/udmUserManage/v1/sub/${neID}`, method: 'post', @@ -115,6 +95,19 @@ export function addSub(neID: string, data: Record) { }); } +/** + * 批量新增新增签约 + * @param data 签约对象 + * @returns object + */ +export function batchAddSub(data: Record) { + return request({ + url: `/udmUserManage/v1/sub/${data.neID}/${data.num}`, + method: 'post', + data: data, + }); +} + /** * 删除签约 * @param data 签约对象 @@ -126,3 +119,15 @@ export function delSub(neId: string, imsi: string) { method: 'delete', }); } + +/** + * 批量删除签约 + * @param data 签约对象 + * @returns object + */ +export function batchDelSub(data: Record) { + return request({ + url: `/udmUserManage/v1/sub/${data.neID}/${data.imsi}/${data.num}`, + method: 'delete', + }); +} diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 7a6cddca..b74b46c0 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -144,6 +144,8 @@ export default { loadDataConfirm: "Are you sure you want to reload the data?", loadData: "LoadData", loadDataTip: 'Successfully obtained updated data: {num} items. The system is updating the data internally. Please do not click repeatedly to obtain updates!!!', + num:'Number of deletions', + startIMSI:'start IMSI', }, base5G: { neTypePlease: 'Query network element type', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index dc6a645f..2e334f00 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -144,6 +144,8 @@ export default { loadDataConfirm: '确认要重新加载数据吗?', loadData: '更新数据', loadDataTip: '成功获取更新数据:{num}条,系统内部进行数据更新,请勿重复点击获取更新!!!', + num:'删除个数', + startIMSI:'起始IMSI', }, base5G: { neTypePlease: '查询网元类型', diff --git a/src/views/index.vue b/src/views/index.vue index 7ff4958f..7e76f4db 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -326,9 +326,6 @@ const closeDrawer = () => { function rowClick(record:any, index:any) { return { onClick: (event:any) => { - console.log(toRaw(record), "666"); -/* console.log( index, "666"); - console.log( event, "666");*/ if (toRaw(record).status=='异常'){ message.error(`网元状态异常`, 2); return false; diff --git a/src/views/neUser/auth/index.vue b/src/views/neUser/auth/index.vue index aad0a601..aeea8fa4 100644 --- a/src/views/neUser/auth/index.vue +++ b/src/views/neUser/auth/index.vue @@ -17,6 +17,7 @@ import { exportAuth, importAuthData, batchAuth, + batchDelAuth, } from '@/api/neUser/auth'; import useNeInfoStore from '@/store/modules/neinfo'; import useI18n from '@/hooks/useI18n'; @@ -241,10 +242,10 @@ const modalStateBatchDelFrom = Form.useForm( modalState.BatchDelForm, reactive({ num: [ - { required: true, message: '放号数不能为空' }, - { min: 1, max: 100, message: '放号数必须小于等于100' }, + { required: true, message: '删除个数不能为空' }, + { min: 1, max: 100, message: '删除个数必须小于等于100' }, ], - imsi: [{ required: true, message: 'IMSI不能为空' }], + imsi: [{ required: true, message: '起始IMSI不能为空' }], }) ); @@ -335,7 +336,7 @@ function fnModalOk() { } /** - * 对话框弹出 批量操作确认执行函数 + * 对话框弹出 批量新增操作确认执行函数 * 进行表达规则校验 */ function fnBatchModalOk() { @@ -376,6 +377,49 @@ function fnBatchModalOk() { }); } +/** + * 对话框弹出 批量删除确认执行函数 + * 进行表达规则校验 + */ + function fnBatchDelModalOk() { + modalStateBatchDelFrom + .validate() + .then(e => { + modalState.confirmLoading = true; + const from = toRaw(modalState.BatchDelForm); + + const neID = queryParams.neId || '-'; + // const result = from.id ? updateAuth(from) : addAuth(neID, from); + from.neID = neID; + const result = batchDelAuth(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.visibleByBatchDel = false; + modalStateBatchDelFrom.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); + }); +} + /** * 批量添加对话框弹出关闭执行函数 * 进行表达规则校验 @@ -386,6 +430,16 @@ function fnBatchModalCancel() { modalStateBatchFrom.resetFields(); } +/** + * 批量删除对话框弹出关闭执行函数 + * 进行表达规则校验 + */ + function fnBatchDelModalCancel() { + modalState.visibleByBatchDel = false; + modalState.visibleByView = false; + modalStateBatchDelFrom.resetFields(); +} + /** * 对话框弹出关闭执行函数 * 进行表达规则校验 @@ -1004,6 +1058,68 @@ onMounted(() => { + + + + + + + + + + + + + + + + + + + + + + + ; + /**表单数据 */ + BatchForm: Record; + /**表单数据 */ + BatchDelForm: Record; /**确定按钮 loading */ confirmLoading: boolean; /**更新加载数据按钮 loading */ @@ -195,6 +205,8 @@ type ModalStateType = { let modalState: ModalStateType = reactive({ visibleByView: false, visibleByEdit: false, + visibleByBatch: false, + visibleByBatchDel: false, title: 'UDM签约用户', from: { msisdn: '', @@ -218,6 +230,33 @@ let modalState: ModalStateType = reactive({ apnContext: '', staticIp: '', }, + BatchForm: { + num: '', + msisdn: '', + imsi: '', + ambr: 'def_ambr', + nssai: 'def_nssai', + rat: '', + arfb: 'def_arfb', + sar: 'def_sar', + cn: '', + smData: '', + smfSel: 'def_snssai', + epsDat: '', + neId: '', + epsFlag: '1', + epsOdb: [], + hplmnOdb: [], + ard: [], + epstpl: '', + contextId: '', + apnContext: '', + staticIp: '', + }, + BatchDelForm:{ + num:'', + imsi:'', + }, confirmLoading: false, loadDataLoading: false, }); @@ -281,6 +320,55 @@ 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不能为空' }], + msisdn: [{ required: true, message: 'MSISDN不能为空' }], + }) +); + +/**对话框内批量添加表单属性和校验规则 */ +const modalStateBatchDelFrom = Form.useForm( + modalState.BatchDelForm, + reactive({ + num: [ + { required: true, message: '放号数不能为空' }, + { min: 1, max: 100, message: '放号数必须小于等于100' }, + ], + imsi: [{ required: true, message: 'IMSI不能为空' }], + }) +); + +/** + * 针对修改框的截取每位数值 + * @param num 二进制值: 10001 n:长度有几位 + */ +function PrefixZero(num: any, n: any) { + return (Array(n).join('0') + num).slice(-n); +} + +/** + * 对话框弹出显示为 批量新增,批量删除 + * @param noticeId 网元id, 不传为新增 + */ +function fnModalVisibleByBatch(batchFlag?: number) { + if (batchFlag) { + modalStateBatchFrom.resetFields(); //重置表单 + modalState.title = '批量添加鉴权信息'; + modalState.visibleByBatch = true; + } else { + modalStateBatchFrom.resetFields(); //重置表单 + modalState.title = '批量删除鉴权信息'; + modalState.visibleByBatchDel = true; + } +} + /** * 对话框弹出显示为 新增或者修改 * @param noticeId 网元id, 不传为新增 @@ -299,6 +387,32 @@ function fnModalVisibleByEdit(imsi?: string) { modalState.confirmLoading = false; hide(); if (res.code === RESULT_CODE_SUCCESS) { + let ardAll = parseInt(res.data.ard).toString(2).padStart(8, '0'); + let hplAll = parseInt(res.data.hplmnOdb).toString(2).padStart(8, '0'); + let odbAll = parseInt(res.data.epsOdb).toString(2).padStart(9, '0'); + const ardArray: any[] = []; + const hplmnArray: any[] = []; + const epsOdbArray: any[] = []; + for (let i = 0; i < ardAll.length; i++) { + if (PrefixZero(ardAll, ardAll.length).charAt(i) === '1') { + ardArray.push(i); + } + } + + for (let i = 0; i < hplAll.length; i++) { + if (PrefixZero(hplAll, hplAll.length).charAt(i) === '1') { + hplmnArray.push(i); + } + } + for (let i = 0; i < odbAll.length; i++) { + if (PrefixZero(odbAll, odbAll.length).charAt(i) === '1') { + epsOdbArray.push(i); + } + } + res.data.ard = ardArray; + res.data.hplmnOdb = hplmnArray; + res.data.epsOdb = epsOdbArray; + modalState.from = Object.assign(modalState.from, res.data); modalState.title = '修改签约信息'; modalState.visibleByEdit = true; @@ -319,8 +433,28 @@ function fnModalOk() { .then(e => { modalState.confirmLoading = true; const from = toRaw(modalState.from); + let ardArr = [0, 0, 0, 0, 0, 0, 0, 0]; + let hplmnArr = [0, 0, 0, 0, 0, 0, 0, 0]; + let odbArr = [0, 0, 0, 0, 0, 0, 0, 0]; + + from.ard.forEach((item: any) => { + ardArr[item] = 1; + }); + + from.hplmnOdb.forEach((item: any) => { + hplmnArr[item] = 1; + }); + + from.epsOdb.forEach((item: any) => { + odbArr[item] = 1; + }); + + from.epsOdb = '' + parseInt(odbArr.join(''), 2); + from.hplmnOdb = '' + parseInt(hplmnArr.join(''), 2); + from.ard = '' + parseInt(ardArr.join(''), 2); + from.cn = '3'; const neID = queryParams.neId || '-'; - const result = from.id ? updateSub(from) : addSub(neID, from); + const result = from.id ? updateSub(neID, from) : addSub(neID, from); const hide = message.loading({ content: t('common.loading') }); result .then(res => { @@ -349,6 +483,111 @@ function fnModalOk() { }); } +/** + * 对话框弹出 批量新增操作确认执行函数 + * 进行表达规则校验 + */ +function fnBatchModalOk() { + modalStateBatchFrom + .validate() + .then(e => { + modalState.confirmLoading = true; + const from = toRaw(modalState.BatchForm); + let ardArr = [0, 0, 0, 0, 0, 0, 0, 0]; + let hplmnArr = [0, 0, 0, 0, 0, 0, 0, 0]; + let odbArr = [0, 0, 0, 0, 0, 0, 0, 0]; + + from.ard.forEach((item: any) => { + ardArr[item] = 1; + }); + + from.hplmnOdb.forEach((item: any) => { + hplmnArr[item] = 1; + }); + + from.epsOdb.forEach((item: any) => { + odbArr[item] = 1; + }); + + from.epsOdb = '' + parseInt(odbArr.join(''), 2); + from.hplmnOdb = '' + parseInt(hplmnArr.join(''), 2); + from.ard = '' + parseInt(ardArr.join(''), 2); + from.cn = '3'; + const neID = queryParams.neId || '-'; + // const result = from.id ? updateAuth(from) : addAuth(neID, from); + from.neID = neID; + const result = batchAddSub(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 fnBatchDelModalOk() { + modalStateBatchDelFrom + .validate() + .then(e => { + modalState.confirmLoading = true; + const from = toRaw(modalState.BatchDelForm); + + const neID = queryParams.neId || '-'; + // const result = from.id ? updateAuth(from) : addAuth(neID, from); + from.neID = neID; + const result = batchDelSub(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.visibleByBatchDel = false; + modalStateBatchDelFrom.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); + }); +} + /** * 对话框弹出关闭执行函数 * 进行表达规则校验 @@ -359,6 +598,26 @@ function fnModalCancel() { modalStateFrom.resetFields(); } +/** + * 批量添加对话框弹出关闭执行函数 + * 进行表达规则校验 + */ +function fnBatchModalCancel() { + modalState.visibleByBatch = false; + modalState.visibleByView = false; + modalStateBatchFrom.resetFields(); +} + +/** + * 批量删除对话框弹出关闭执行函数 + * 进行表达规则校验 + */ + function fnBatchDelModalCancel() { + modalState.visibleByBatchDel = false; + modalState.visibleByView = false; + modalStateBatchDelFrom.resetFields(); +} + /** * UDM签约用户删除 * @param imsi 网元编号ID @@ -616,6 +875,23 @@ onMounted(() => { {{ t('common.addText') }} + + + {{ t('views.neUser.auth.batchAddText') }} + + + + {{ t('views.neUser.auth.batchDelText') }} + { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Enable + Disable + + + + + + + + + + + + + + + + + + + + + + + + + + + + Enable + Disable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +