diff --git a/src/views/neUser/sub/index.vue b/src/views/neUser/sub/index.vue index beed9851..2c7b9f1f 100644 --- a/src/views/neUser/sub/index.vue +++ b/src/views/neUser/sub/index.vue @@ -24,6 +24,7 @@ import { resetUDMSub, updateUDMSub, } from '@/api/neData/udm_sub'; +import { getNeConfigData, addNeConfigData } from '@/api/ne/neConfig'; import { uploadFile } from '@/api/tool/file'; import { getNeViewFile } from '@/api/tool/neFile'; const { t } = useI18n(); @@ -111,39 +112,42 @@ let tableColumns = ref([ { title: 'Subscribed AMBR', dataIndex: 'ambr', - align: 'center', - width: 100, + align: 'left', + resizable: true, + width: 150, + minWidth: 150, + maxWidth: 300, }, { title: 'Subscribed SNSSAIs', dataIndex: 'nssai', - align: 'center', + align: 'left', width: 100, }, { title: 'Forbidden Areas', dataIndex: 'arfb', - align: 'center', + align: 'left', width: 100, }, { title: 'Service Area Restrict', dataIndex: 'sar', - align: 'center', + align: 'left', width: 100, }, { title: '5G', dataIndex: 'cn', key: 'cnFlag', - align: 'center', + align: 'left', width: 100, }, { title: '4G', dataIndex: 'epsFlag', key: 'epsFlag', - align: 'center', + align: 'left', width: 100, }, { @@ -237,6 +241,10 @@ type ModalStateType = { confirmLoading: boolean; /**更新加载数据按钮 loading */ loadDataLoading: boolean; + /**5G Subscribed UE AMBR 模板对象 */ + ambr: Record; + /**已有AMBE数据 */ + ambrData: Record[]; }; /**对话框对象信息状态 */ @@ -288,6 +296,36 @@ let modalState: ModalStateType = reactive({ }, confirmLoading: false, loadDataLoading: false, + // 5G Subscribed UE AMBR + ambr: { + uplink: 1, + uplinkUnit: 'Gbps', + downlink: 2, + downlinkUnit: 'Gbps', + options: [ + { + label: 'bps', + value: 'bps', + }, + { + label: 'Kbps', + value: 'Kbps', + }, + { + label: 'Mbps', + value: 'Mbps', + }, + { + label: 'Gbps', + value: 'Gbps', + }, + { + label: 'Tbps', + value: 'Tbps', + }, + ], + }, + ambrData: [], }); /**表单中多选的OPTION */ @@ -386,7 +424,23 @@ function fnModalVisibleByBatch() { * 对话框弹出显示为 新增或者修改 * @param noticeId 网元id, 不传为新增 */ -function fnModalVisibleByEdit(imsi?: string) { +async function fnModalVisibleByEdit(imsi?: string) { + const neId = queryParams.neId || '-'; + + // 获取AMBR数据 + const ambrRes = await getNeConfigData({ + neType: 'UDM', + neId: neId, + paramName: 'subsUEAmbr', + }); + if (ambrRes.code === RESULT_CODE_SUCCESS) { + modalState.ambr.uplink = 1; + modalState.ambr.uplinkUnit = 'Gbps'; + modalState.ambr.downlink = 2; + modalState.ambr.downlinkUnit = 'Gbps'; + modalState.ambrData = ambrRes.data; + } + if (!imsi) { modalStateFrom.resetFields(); modalState.title = t('common.addText') + t('views.neUser.sub.subInfo'); @@ -395,60 +449,68 @@ function fnModalVisibleByEdit(imsi?: string) { if (modalState.confirmLoading) return; const hide = message.loading(t('common.loading'), 0); modalState.confirmLoading = true; - const neId = queryParams.neId || '-'; - getUDMSub(neId, imsi) - .then(res => { - if (res.code === RESULT_CODE_SUCCESS) { - transformFormData(res.data.smData); - 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; - - // 4G APN Context List - const apnContextStr = res.data.apnContext; - const apnContextArr = []; - for (let i = 0; i < apnContextStr.length; i += 2) { - const num = Number(`${apnContextStr[i]}${apnContextStr[i + 1]}`); - apnContextArr.push(num); - } - - modalState.from = Object.assign(modalState.from, res.data, { - apnContext: apnContextArr, - }); - - modalState.title = - t('common.editText') + t('views.neUser.sub.subInfo'); - modalState.openByEdit = true; - } else { - message.error(t('common.getInfoFail'), 2); + // 获取IMSI数据 + const res = await getUDMSub(neId, imsi); + if (res.code === RESULT_CODE_SUCCESS) { + transformFormData(res.data.smData); + 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); } - }) - .finally(() => { - hide(); - modalState.confirmLoading = false; + } + + 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; + + // 4G APN Context List + const apnContextStr = res.data.apnContext; + const apnContextArr = []; + for (let i = 0; i < apnContextStr.length; i += 2) { + const num = Number(`${apnContextStr[i]}${apnContextStr[i + 1]}`); + apnContextArr.push(num); + } + + modalState.from = Object.assign(modalState.from, res.data, { + apnContext: apnContextArr, }); + + // AMBR数据 + const ambrItem = modalState.ambrData.find( + item => item.name === modalState.from.ambr + ); + if (ambrItem) { + const uplinkItme = ambrItem.uplink.split(' '); + modalState.ambr.uplink = uplinkItme[0] || 1; + modalState.ambr.uplinkUnit = uplinkItme[1] || 'Gbps'; + const downlinkItme = ambrItem.downlink.split(' '); + modalState.ambr.downlink = downlinkItme[0] || 2; + modalState.ambr.downlinkUnit = downlinkItme[1] || 'Gbps'; + } + + modalState.title = t('common.editText') + t('views.neUser.sub.subInfo'); + modalState.openByEdit = true; + } else { + message.error(t('common.getInfoFail'), 2); + } + hide(); + modalState.confirmLoading = false; } } @@ -614,7 +676,7 @@ function fnModalOk() { modalStateFrom .validate() - .then(e => { + .then(async e => { modalState.confirmLoading = true; let ardArr = [0, 0, 0, 0, 0, 0, 0, 0]; let hplmnArr = [0, 0, 0, 0, 0, 0, 0, 0]; @@ -646,58 +708,107 @@ function fnModalOk() { from.regTimer = `${from.regTimer}`; from.ueUsageType = `${from.ueUsageType}`; from.neId = queryParams.neId || '-'; - const result = from.id - ? updateUDMSub(from) - : from.num === 1 - ? addUDMSub(from) - : batchAddUDMSub(from, from.num); + + // 组合检查ambr + from.ambr = await fnAMBRName(); + + let res = null; + if (from.id) { + res = await updateUDMSub(from); + } else { + if (from.num === 1) { + res = await addUDMSub(from); + } else { + res = await batchAddUDMSub(from, from.num); + } + } + if (!res) return; + const hide = message.loading(t('common.loading'), 0); - result - .then(res => { - if (res.code === RESULT_CODE_SUCCESS) { - if (from.num === 1) { - message.success({ - content: t('common.msgSuccess', { msg: modalState.title }), - duration: 3, - }); - fnGetList(1); - } else { - const timerS = Math.ceil(+from.num / 800) + 1; - notification.success({ - message: modalState.title, - description: t('common.operateOk'), - duration: timerS, - }); - setTimeout(() => { - fnGetList(1); - }, timerS * 1000); - } - } else { - if (from.num === 1) { - message.error({ - content: `${res.msg}`, - duration: 3, - }); - } else { - notification.error({ - message: modalState.title, - description: res.msg, - duration: 3, - }); - } - } - }) - .finally(() => { - hide(); - fnModalCancel(); - modalState.confirmLoading = false; - }); + if (res.code === RESULT_CODE_SUCCESS) { + if (from.num === 1) { + message.success({ + content: t('common.msgSuccess', { msg: modalState.title }), + duration: 3, + }); + fnGetList(1); + } else { + const timerS = Math.ceil(+from.num / 800) + 1; + notification.success({ + message: modalState.title, + description: t('common.operateOk'), + duration: timerS, + }); + setTimeout(() => { + fnGetList(1); + }, timerS * 1000); + } + } else { + if (from.num === 1) { + message.error({ + content: `${res.msg}`, + duration: 3, + }); + } else { + notification.error({ + message: modalState.title, + description: res.msg, + duration: 3, + }); + } + } + + hide(); + fnModalCancel(); + modalState.confirmLoading = false; }) .catch(e => { message.error(t('common.errorFields', { num: e.errorFields.length }), 3); }); } +/** + * 检查ambr是否存在,不存在则新增 + */ +async function fnAMBRName() { + const ambrItem = modalState.ambrData.find( + item => + item.downlink === + `${modalState.ambr.downlink} ${modalState.ambr.downlinkUnit}` && + item.uplink === `${modalState.ambr.uplink} ${modalState.ambr.uplinkUnit}` + ); + if (ambrItem) { + return ambrItem.name; + } else { + // 新增 + const ambrData = modalState.ambrData.sort((a: any, b: any) => { + return b.index - a.index; + }); + if (ambrData.length > 0) { + const neId = queryParams.neId || '-'; + const loc = ambrData[0].index + 1; + const name = `ambr_${modalState.ambr.uplink}${modalState.ambr.uplinkUnit}_${modalState.ambr.downlink}${modalState.ambr.downlinkUnit}`; + const ambrRes = await addNeConfigData({ + neType: 'UDM', + neId: neId, + paramName: 'subsUEAmbr', + paramData: { + index: loc, + name: name, + uplink: `${modalState.ambr.uplink} ${modalState.ambr.uplinkUnit}`, + downlink: `${modalState.ambr.downlink} ${modalState.ambr.downlinkUnit}`, + }, + loc: `${loc}`, + }); + if (ambrRes.code === RESULT_CODE_SUCCESS) { + return name; + } + } else { + return 'def_ambr'; + } + } +} + /**对话框内批量添加表单属性和校验规则 */ const modalStateBatchDelFrom = Form.useForm( modalState.BatchDelForm, @@ -1700,7 +1811,7 @@ onMounted(() => { - + + + + + + + + + + + + + + + + + + + +