diff --git a/src/views/system/tenant/index.vue b/src/views/system/tenant/index.vue index 513aad9a..47d99e55 100644 --- a/src/views/system/tenant/index.vue +++ b/src/views/system/tenant/index.vue @@ -17,7 +17,7 @@ import useDictStore from '@/store/modules/dict'; import { parseDateToStr } from '@/utils/date-utils'; import { Form, Modal, message } from 'ant-design-vue'; import { listNeInfo } from '@/api/ne/neInfo'; -import { AnyARecord } from 'dns'; +import { listBase5G } from '@/api/neUser/base5G'; const neInfoStore = useNeInfoStore(); const { getDict } = useDictStore(); @@ -71,10 +71,13 @@ let dict: { sysTenancyType: DictType[]; /**实时的UPF RMUID 不是字典 */ allRmUid: any[]; + /**实时的RADIO ID不是字典 */ + allRadio: any[]; } = reactive({ sysNormalDisable: [], sysTenancyType: [], allRmUid: [], + allRadio: [], }); /**查询参数 */ @@ -184,6 +187,8 @@ let modalState: ModalStateType = reactive({ tenancyKey: '', tenancyType: '', status: '0', + radioType: '5G', + radioId: '', }, confirmLoading: false, }); @@ -203,7 +208,7 @@ const modalStateFrom = Form.useForm( }) ); -/**对话框内表单属性和校验规则 */ +/**租赁类型对话框内表单属性和校验规则 */ const modalStateTypeFrom = Form.useForm( modalState.typeFrom, reactive({ @@ -223,6 +228,22 @@ const modalStateTypeFrom = Form.useForm( message: t('views.system.tenant.key') + t('common.unableNull'), }, ], + radioType: [ + { + required: true, + min: 1, + max: 50, + message: t('views.system.tenant.key') + t('common.unableNull'), + }, + ], + radioId: [ + { + required: true, + min: 1, + max: 50, + message: t('views.system.tenant.key') + t('common.unableNull'), + }, + ], }) ); @@ -447,9 +468,19 @@ function fnModalVisibleByType( .then(res => { if (res.code === RESULT_CODE_SUCCESS && res.data) { modalState.typeFrom = Object.assign(modalState.typeFrom, res.data); - if (modalState.typeFrom.tenancyType === 'UPF') { - fnTypeChange('UPF'); + //动态表单 + fnTypeChange(modalState.typeFrom.tenancyType); + + if ( + modalState.typeFrom.tenancyType == 'RADIO' && + modalState.typeFrom.tenancyKey + ) { + modalState.typeFrom.radioType = + modalState.typeFrom.tenancyKey.split('_')[0]; + modalState.typeFrom.radioId = + modalState.typeFrom.tenancyKey.split('_')[1]; } + modalState.typeTitle = t('common.editText') + t('views.system.tenant.type'); modalState.visibleByType = true; @@ -473,11 +504,20 @@ function fnModalVisibleByType( * 进行表达规则校验 */ function fnModalTypeOk() { + const from = toRaw(modalState.typeFrom); + + let validateName = ['tenancyType']; + + if (from.tenancyType === 'RADIO') { + validateName.push('radioType', 'radioId'); + from.tenancyKey = from.radioType + '_' + from.radioId; + } else { + validateName.push('tenancyKey'); + } modalStateTypeFrom - .validate() + .validate(validateName) .then(() => { modalState.confirmLoading = true; - const from = toRaw(modalState.typeFrom); from.parentId = state.selectedNode; const tenant = from.tenantId ? updateTenant(from) : addTenant(from); const hide = message.loading(t('common.loading'), 0); @@ -554,6 +594,10 @@ function fnTypeChange(value: any) { }); } + if (value === 'RADIO') { + fnRadioIdChange(modalState.typeFrom.radioType); + } + const tipMapping: any = { UPF: t('views.system.tenant.upfTip'), IMSI: t('views.system.tenant.imsiTip'), @@ -563,6 +607,58 @@ function fnTypeChange(value: any) { keyTip.value = tipMapping[value]; } +//为后续批量请求使用 +let promises = ref([]); +let neCascaderOptions = ref[]>([]); + +/**查询基站ID */ +function fnRadioIdChange(value: any) { + const typeMapping: any = { + '4G': ['MME'], + '5G': ['AMF'], + }; + + const typeArr: any = []; + typeArr.value = typeMapping[value] || ['AMF']; + + neCascaderOptions.value = neInfoStore.getNeCascaderOptions.filter( + (item: any) => { + return typeArr.value.includes(item.value); + } + ); + promises.value = []; + //获取4G或者5G基站ID + neCascaderOptions.value.map((item: any) => { + item.children.forEach((child: any) => { + promises.value.push( + listBase5G({ + neId: child.neId, + neType: child.neType, + pageNum: queryParams.pageNum, + pageSize: 10000, + }) + ); + }); + }); + + Promise.allSettled(promises.value).then(results => { + results.forEach(result => { + if (result.status === 'fulfilled') { + const allBaseData = result.value; + if ( + allBaseData.code === RESULT_CODE_SUCCESS && + Array.isArray(allBaseData.rows) + ) { + // 处理成功结果 + dict.allRadio = allBaseData.rows + .filter((item: any) => item.id !== '') // 排除 item.id 为空字符串的情况 + .map((item: any) => ({ option: item.id, value: item.id })); + } + } + }); + }); +} + //自动完成框不区分大小写 function filterOption(input: string, option: any) { return option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0; @@ -589,8 +685,22 @@ onMounted(() => { } }); - // 初始渲染左侧树状数据 - fnGetList(undefined, 'tree'); + neInfoStore + .fnNelist() + .then(res => { + if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { + if (res.data.length == 0) { + message.warning({ + content: t('common.noData'), + duration: 2, + }); + } + } + }) + .finally(() => { + // 初始渲染左侧树状数据 + fnGetList(undefined, 'tree'); + }); });