diff --git a/src/views/neUser/imsUDM/index.vue b/src/views/neUser/imsUDM/index.vue index e59c01e3..3c408fd4 100644 --- a/src/views/neUser/imsUDM/index.vue +++ b/src/views/neUser/imsUDM/index.vue @@ -27,7 +27,6 @@ import { listTenant } from '@/api/system/tenant'; import { uploadFile } from '@/api/tool/file'; import { getNeViewFile } from '@/api/tool/neFile'; const { t } = useI18n(); - /**网元参数 */ let neOtions = ref[]>([]); @@ -37,14 +36,12 @@ let queryParams = reactive({ neId: undefined, /**移动编号 */ imsi: '', - /**imsi匹配方式 */ imsiMatch: 'fuzzy', /**租户名 */ tenantName: '', /**移动号 */ msisdn: '', - /**TAG */ - tag: undefined, + tag:undefined, /**排序字段 */ sortField: 'imsi', /**排序方式 */ @@ -59,7 +56,6 @@ let queryParams = reactive({ function fnQueryReset() { queryParams = Object.assign(queryParams, { imsi: '', - imsiMatch: 'fuzzy', msisdn: '', tenantName: '', tag: undefined, @@ -148,7 +144,10 @@ let tableColumns = ref([ dataIndex: 'tag', align: 'center', width: 150, - key: 'tag' + key: 'tag', + customRender: ({ text }: { text: number }) => { + return text === 0 ? 'VoIP' : 'VoLTE'; + } }, { title: t('common.operate'), @@ -194,62 +193,6 @@ let tablePagination = reactive({ function fnTableSize({ key }: MenuInfo) { tableState.size = key as SizeType; } - -/**表格分页、排序、筛选变化时触发操作, 排序方式,取值为 ascend descend */ -function fnTableChange(pagination: any, filters: any, sorter: any, extra: any) { - const { field, order } = sorter; - if (order) { - queryParams.sortField = field; - queryParams.sortOrder = order.replace('end', ''); - } else { - queryParams.sortOrder = 'asc'; - } - fnGetList(1); -} - -/**表格多选 */ -function fnTableSelectedRowKeys(keys: (string | number)[]) { - tableState.selectedRowKeys = keys; -} - -/**对话框对象信息状态类型 */ -type ModalStateType = { - /**新增框是否显示 */ - openByAdd: boolean; - /**批量删除框是否显示 */ - openByBatchDel: boolean; - /**标题 */ - title: string; - /**表单数据 */ - from: Record; - /**批量删除表单数据 */ - BatchDelForm: Record; - /**确定按钮 loading */ - confirmLoading: boolean; - /**更新加载数据按钮 loading */ - loadDataLoading: boolean; -}; - -/**对话框对象信息状态 */ -let modalState: ModalStateType = reactive({ - openByAdd: false, - openByBatchDel: false, - title: 'UDM签约用户', - from: { - imsi: '', - msisdn: '', - tag: '0', - vni: '', - num: 1, - }, - BatchDelForm: { - num: 1, - imsi: '', - }, - confirmLoading: false, - loadDataLoading: false, -}); - /**表单中多选的OPTION */ const modalStateFromOption = reactive({ ardJson: [ @@ -302,24 +245,188 @@ const modalStateFromOption = reactive({ }, ], }); +/**表格分页、排序、筛选变化时触发操作, 排序方式,取值为 ascend descend */ +function fnTableChange(pagination: any, filters: any, sorter: any, extra: any) { + const { field, order } = sorter; + if (order) { + queryParams.sortField = field; + queryParams.sortOrder = order.replace('end', ''); + } else { + queryParams.sortOrder = 'asc'; + } + fnGetList(1); +} + +/**表格多选 */ +function fnTableSelectedRowKeys(keys: (string | number)[]) { + tableState.selectedRowKeys = keys; +} + +/**对话框对象信息状态类型 */ +type ModalStateType = { + /**新增框或修改框是否显示 */ + openByEdit: boolean; + /**批量新增新增框是否显示 */ + openByBatch: boolean; + /**批量新增删除框是否显示 */ + openByBatchDel: boolean; + /**标题 */ + title: string; + /**表单数据 */ + from: Record; + /**表单数据 */ + BatchDelForm: Record; + /**确定按钮 loading */ + confirmLoading: boolean; + /**更新加载数据按钮 loading */ + loadDataLoading: boolean; +}; + +/**对话框对象信息状态 */ +let modalState: ModalStateType = reactive({ + openByEdit: false, + openByBatch: false, + openByBatchDel: false, + title: 'UDM鉴权用户', + from: { + imsi: '', + msisdn: '', + tag: undefined, + vni: '', + num: 1, + }, + BatchDelForm: { + num: 1, + imsi: '', + }, + confirmLoading: false, + loadDataLoading: false, +}); + +/**对话框内表单属性和校验规则 */ +const modalStateFrom = Form.useForm( + modalState.from, + reactive({ + num: [ + { + required: true, + message: t('views.neUser.auth.numAdd') + t('common.unableNull'), + }, + ], + imsi: [ + { required: computed(() => modalState.from.tag === 1), message: 'IMSI' + t('common.unableNull') }, + { min: 15, max: 15, message: t('views.neUser.auth.imsiConfirm') }, + ], + msisdn: [{ required: true, message: 'MSISDN' + t('common.unableNull') }], + tag: [ + { required: true, message: 'TAG' + t('common.unableNull') } + ], + vni: [ + { required: true, message: 'vni' + t('common.unableNull') }, + ], + // algoIndex: [ + // { required: true, message: 'algoIndex' + t('common.unableNull') }, + // ], + }) +); + +function fnTenantNameFocus() { + Promise.allSettled([listTenant({ parentId: 0 })]).then(resArr => { + if (resArr[0].status === 'fulfilled') { + var tenantNameData = resArr[0].value; + if ( + tenantNameData.code === RESULT_CODE_SUCCESS && + Array.isArray(tenantNameData.data) + ) { + modalStateFromOption.tenantName = []; //上面置为空数组时会报错 故在此 + tenantNameData.data.forEach((item: any) => { + if (item.parentId === '0') { + modalStateFromOption.tenantName.push({ + value: item.tenantName, + label: item.tenantName, + }); + } + }); + } + } + }); +} +/**对话框内批量删除表单属性和校验规则 */ +const modalStateBatchDelFrom = Form.useForm( + modalState.BatchDelForm, + reactive({ + num: [ + { + required: true, + message: t('views.neUser.auth.numDel') + t('common.unableNull'), + }, + ], + imsi: [{ required: true, message: 'IMSI' + t('common.unableNull') }], + }) +); + +/** + * 对话框弹出显示为 新增或者修改 + * @param noticeId 网元id, 不传为新增 + */ +function fnModalVisibleByEdit(row?: Record) { + if (!row) { + modalStateFrom.resetFields(); //重置表单 + modalState.title = t('common.addText') + t('views.neUser.auth.authInfo'); + modalState.openByEdit = true; + } else { + if (modalState.confirmLoading) return; + const hide = message.loading(t('common.loading'), 0); + modalState.confirmLoading = true; + const neId = queryParams.neId || '-'; + getIMSSub(neId, row.imsi) + .then(res => { + if (res.code === RESULT_CODE_SUCCESS) { + modalState.from = Object.assign(modalState.from, res.data); + modalState.title = + t('common.editText') + t('views.neUser.auth.authInfo'); + modalState.openByEdit = true; + } else { + message.error(t('common.getInfoFail'), 2); + } + }) + .finally(() => { + hide(); + modalState.confirmLoading = false; + }); + } +} + +/** + * 对话框弹出显示为 批量删除 + * @param noticeId 网元id, 不传为新增 + */ +function fnModalVisibleByBatch() { + modalStateBatchDelFrom.resetFields(); //重置表单 + modalState.title = + t('views.neUser.auth.batchDelText') + t('views.neUser.auth.authInfo'); + modalState.openByBatchDel = true; +} /** * 对话框弹出确认执行函数 * 进行表达规则校验 */ function fnModalOk() { - const from = Object.assign({}, toRaw(modalState.from)); - + console.log(modalState.from) modalStateFrom .validate() .then(e => { + const from = Object.assign({}, toRaw(modalState.from)); modalState.confirmLoading = true; from.neId = queryParams.neId || '-'; + console.log(from) const result = from.num === 1 - ? addIMSSub(from)//单条新增 - : batchAddIMSSub(from, from.num);//批量新增 + ? addIMSSub(from) + : batchAddIMSSub(from, from.num); const hide = message.loading(t('common.loading'), 0); - result + + return result .then((res: any) => { if (res.code === RESULT_CODE_SUCCESS) { if (from.num === 1) { @@ -364,59 +471,80 @@ function fnModalOk() { }); }) .catch(e => { + console.error(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 || '-'; + batchDelIMSSub(neId, from.imsi, from.num).then(res => { + if (res.code === RESULT_CODE_SUCCESS) { + const timerS = Math.ceil(+from.num / 1500) + 1; + notification.success({ + message: modalState.title, + description: t('common.operateOk'), + duration: timerS, + }); + setTimeout(() => { + modalState.openByBatchDel = false; + modalState.confirmLoading = false; + modalStateBatchDelFrom.resetFields(); + fnGetList(1); + }, timerS * 1000); + } else { + modalState.confirmLoading = false; + notification.error({ + message: modalState.title, + description: res.msg, + duration: 3, + }); + } + }); + }) + .catch(e => { + message.error(t('common.errorFields', { num: e.errorFields.length }), 3); + }); +} + +/** + * 批量删除对话框弹出关闭执行函数 + * 进行表达规则校验 + */ +function fnBatchDelModalCancel() { + modalState.openByBatchDel = false; + modalStateBatchDelFrom.resetFields(); +} + /** * 对话框弹出关闭执行函数 * 进行表达规则校验 */ function fnModalCancel() { - modalState.openByAdd = false; + modalState.openByEdit = false; modalStateFrom.resetFields(); } -/**对话框内表单属性和校验规则 */ -const modalStateFrom = Form.useForm( - modalState.from, - reactive({ - num: [ - { - required: true, - message: t('views.neUser.sub.numAdd') + t('common.unableNull'), - }, - ], - imsi: [ - { - required: computed(() => modalState.from.tag === '1'), - message: 'IMSI' + t('common.unableNull') - }, - { min: 15, max: 15, message: t('views.neUser.auth.imsiConfirm') }, - ], - msisdn: [ - { required: true, message: 'MSISDN' + t('common.unableNull') }, - ], - tag: [ - { required: true, message: 'TAG' + t('common.unableNull') }, - ], - vni: [ - { required: true, message: 'VNI' + t('common.unableNull') }, - ], - }) -); - /** - * UDM签约用户删除 + * UDM鉴权用户删除 * @param imsi 编号imsi */ function fnRecordDelete(imsi: string) { const neId = queryParams.neId; if (!neId) return; - let imsiMsg = imsi;//单条/批量删除逻辑 + let imsiMsg = imsi; if (imsi === '0') { imsiMsg = `${tableState.selectedRowKeys[0]}... ${t( - 'views.neUser.sub.numDel' + 'views.neUser.auth.numDel' )} ${tableState.selectedRowKeys.length}`; imsi = tableState.selectedRowKeys.join(','); } @@ -424,37 +552,37 @@ function fnRecordDelete(imsi: string) { Modal.confirm({ title: t('common.tipTitle'), content: t('views.neUser.auth.delSure', { imsi: imsiMsg }), - onOk() {//删除操作 - modalState.loadDataLoading = true;//设置加载状态 - const hide = message.loading(t('common.loading'), 0);//显示加载提示 - delIMSSub(neId, imsi)//调用删除接口方法 + onOk() { + modalState.loadDataLoading = true; + const hide = message.loading(t('common.loading'), 0); + delIMSSub(neId, imsi) .then(res => { - if (res.code === RESULT_CODE_SUCCESS) {//返回删除成功 + if (res.code === RESULT_CODE_SUCCESS) { const msgContent = t('common.msgSuccess', { msg: t('common.deleteText'), }); - message.success({//显示成功提示 + message.success({ content: `${msgContent} : ${imsiMsg}`, duration: 3, }); - } else {//删除失败 - message.error({//显示错误信息 + } else { + message.error({ content: `${res.msg}`, duration: 3, }); } }) - .finally(() => {//无论结果固定执行 - hide();//隐藏加载提示 - fnGetList();//刷新列表数据 - modalState.loadDataLoading = false;//重置加载状态 + .finally(() => { + hide(); + fnGetList(); + modalState.loadDataLoading = false; }); }, }); } /** - * UDM签约用户导出 + * UDM鉴权用户勾选导出 */ function fnRecordExport(type: string = 'txt') { const selectLen = tableState.selectedRowKeys.length; @@ -465,16 +593,10 @@ function fnRecordExport(type: string = 'txt') { exportIMSSub({ type: type, neId: neId, imsis: tableState.selectedRowKeys }) .then(res => { if (res.code === RESULT_CODE_SUCCESS) { - message.success({ - content: t('common.msgSuccess', { msg: t('common.export') }), - duration: 2, - }); - saveAs(res.data, `UDMSub_select_${Date.now()}.${type}`); + message.success(t('common.msgSuccess', { msg: t('common.export') }), 3); + saveAs(res.data, `UDMAuth_select_${Date.now()}.${type}`); } else { - message.error({ - content: `${res.msg}`, - duration: 2, - }); + message.error(`${res.msg}`, 3); } }) .finally(() => { @@ -482,38 +604,23 @@ function fnRecordExport(type: string = 'txt') { }); } -/**列表导出 */ +/**列表导出全部数据 */ function fnExportList(type: string) { const neId = queryParams.neId; - const imsiMatchRule: any = { - prefix: queryParams.imsi ? `${queryParams.imsi}%` : '', - fuzzy: queryParams.imsi ? `%${queryParams.imsi}%` : '', - }; - const realImsi = imsiMatchRule[queryParams.imsiMatch] || ''; if (!neId) return; - const key = 'exportSub'; - message.loading({ content: t('common.loading'), key }); - - exportIMSSub({ - ...queryParams, - imsi: realImsi, - type: type, - }).then(res => { - if (res.code === RESULT_CODE_SUCCESS) { - message.success({ - content: t('common.msgSuccess', { msg: t('common.export') }), - key, - duration: 2, - }); - saveAs(res.data, `UDMSub_${Date.now()}.${type}`); - } else { - message.error({ - content: `${res.msg}`, - key, - duration: 2, - }); - } - }); + const hide = message.loading(t('common.loading'), 0); + exportIMSSub(Object.assign({ type: type }, queryParams)) + .then(res => { + if (res.code === RESULT_CODE_SUCCESS) { + message.success(t('common.msgSuccess', { msg: t('common.export') }), 3); + saveAs(res.data, `UDMAuth_${Date.now()}.${type}`); + } else { + message.error(`${res.msg}`, 3); + } + }) + .finally(() => { + hide(); + }); } /**重新加载数据 */ @@ -527,13 +634,13 @@ function fnLoadData() { resetIMSSub(neId).then(res => { if (res.code === RESULT_CODE_SUCCESS) { const num = res.data; - const timerS = Math.ceil(+num / 2000) + 3; + const timerS = Math.ceil(+num / 3000) + 3; notification.success({ - message: t('views.neUser.sub.loadData'), - description: t('views.neUser.sub.loadDataTip', { num, timer: timerS }), + message: t('views.neUser.auth.loadData'), + description: t('views.neUser.auth.loadDataTip', { num, timer: timerS }), duration: timerS, }); - // 延迟20s后关闭loading刷新列表 + // 延迟10s后关闭loading刷新列表 setTimeout(() => { modalState.loadDataLoading = false; tableState.loading = false; // 表格loading @@ -574,7 +681,6 @@ function fnGetList(pageNum?: number) { pageNum: queryParams.pageNum, pageSize: queryParams.pageSize, }; - listIMSSub({ ...queryParams, imsi: imsiMatchRule[queryParams.imsiMatch], @@ -632,7 +738,7 @@ function fnModalUploadImportFailReason() { neType: 'UDM', neId: neId, path: '/tmp', - fileName: 'import_udmuser_err_records.txt', + fileName: 'import_authdata_err_records.txt', }) .then(res => { if (res.code === RESULT_CODE_SUCCESS) { @@ -640,7 +746,7 @@ function fnModalUploadImportFailReason() { const blob = new Blob([res.data], { type: 'text/plain', }); - saveAs(blob, `import_udmuser_err_records_${Date.now()}.txt`); + saveAs(blob, `import_authdata_err_records_${Date.now()}.txt`); } else { message.error(`${res.msg}`, 3); } @@ -661,7 +767,7 @@ function fnModalUploadImportOpen() { /**对话框表格信息导入关闭窗口 */ function fnModalUploadImportClose() { uploadImportState.open = false; - fnGetList(); + fnGetList(1); } /**对话框表格信息导入上传 */ @@ -712,126 +818,6 @@ function fnModalUploadImportUpload(file: File) { }); } -function fnTenantNameFocus() { - Promise.allSettled([listTenant({ parentId: 0 })]).then(resArr => { - if (resArr[0].status === 'fulfilled') { - var tenantNameData = resArr[0].value; - if ( - tenantNameData.code === RESULT_CODE_SUCCESS && - Array.isArray(tenantNameData.data) - ) { - modalStateFromOption.tenantName = []; //上面置为空数组时会报错 故在此 - tenantNameData.data.forEach((item: any) => { - if (item.parentId === '0') { - modalStateFromOption.tenantName.push({ - value: item.tenantName, - label: item.tenantName, - }); - } - }); - } - } - }); -} - -/** - * 对话框弹出显示为 新增 - */ -function fnModalVisibleByAdd() { - modalState.openByAdd = true; - modalState.title = t('common.addText') + t('views.neUser.sub.subInfo'); - modalState.from = { - imsi: '', - msisdn: '', - tag: '0', - vni: '', - num: 1, - }; -} - -/** - * 对话框弹出显示为 批量删除 - */ -function fnModalVisibleByBatch() { - modalState.openByBatchDel = true; - modalState.title = t('views.neUser.auth.batchDelText'); - modalState.BatchDelForm = { - num: 1, - imsi: '', - }; -} - -/** - * 批量删除对话框确认 - */ -function fnBatchDelModalOk() { - modalStateBatchDelFrom - .validate() - .then(() => { - modalState.confirmLoading = true; - const hide = message.loading(t('common.loading'), 0); - const neId = queryParams.neId; - if (!neId) return; - - batchDelIMSSub(neId, modalState.BatchDelForm.imsi, modalState.BatchDelForm.num) - .then(res => { - if (res.code === RESULT_CODE_SUCCESS) { - const timerS = Math.max( - Math.ceil(modalState.BatchDelForm.num / 500), - `${modalState.BatchDelForm.num}`.length * 5 - ); - notification.success({ - message: modalState.title, - description: t('common.operateOk'), - duration: timerS, - }); - setTimeout(() => { - fnGetList(1); - }, timerS * 1000); - } else { - notification.error({ - message: modalState.title, - description: res.msg, - duration: 3, - }); - } - }) - .finally(() => { - hide(); - fnBatchDelModalCancel(); - modalState.confirmLoading = false; - }); - }) - .catch(e => { - message.error(t('common.errorFields', { num: e.errorFields.length }), 3); - }); -} - -/** - * 批量删除对话框取消 - */ -function fnBatchDelModalCancel() { - modalState.openByBatchDel = false; - modalStateBatchDelFrom.resetFields(); -} - -/**批量删除对话框内表单属性和校验规则 */ -const modalStateBatchDelFrom = Form.useForm( - modalState.BatchDelForm, - reactive({ - imsi: [ - { required: true, message: 'IMSI' + t('common.unableNull') }, - { min: 15, max: 15, message: t('views.neUser.auth.imsiConfirm') }, - ], - num: [ - { - required: true, - message: t('views.neUser.sub.numDel') + t('common.unableNull'), - }, - ], - }) -); - onMounted(() => { // 获取网元网元列表 useNeInfoStore() @@ -875,7 +861,7 @@ onMounted(() => { - + { /> - - + - - + + + + + + { > - - - - - @@ -964,7 +938,7 @@ onMounted(() => {