diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 6073fb90..b63352f6 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -903,6 +903,8 @@ export default { imsiMode:'IMSI Matching Mode', fuzzyMatch:'Fuzzy Match', prefixMatch:'Prefix Match', + fullMatch:'Full Match', + suffixMatch:'Suffix Match', }, pcf: { neType: 'PCF Object', @@ -1829,6 +1831,7 @@ export default { imsiTip:'Please fill in the SIM card number or number range, \'%\' represents the number wildcard, for example: 111000%', radioTip:'Please select from the drop-down list of radio type and radio ID', defaultTip:'Please select from the drop-down list of Tenancy Asset, and then fill the Asset Key', + patternTip:'The Asset Key cannot contain special characters', }, post:{ positionInfo:'Position Information', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index fda502e9..5bf23218 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -903,6 +903,8 @@ export default { imsiMode:'IMSI匹配模式', fuzzyMatch:'模糊匹配', prefixMatch:'前缀匹配', + fullMatch:'全匹配', + suffixMatch:'后缀匹配', }, pcf: { neType: 'PCF网元对象', @@ -1829,6 +1831,7 @@ export default { imsiTip:'请填入SIM卡号码或者号段, \'%\'表示号码通配符, 例如: 460001%', radioTip:'请从下拉列表选择基站类型和基站ID', defaultTip:'请选择租赁资产类别, 然后填写资产标识', + patternTip:'租赁标识不能包含特殊字符', }, post:{ positionInfo:'岗位信息', diff --git a/src/views/system/tenant/index.vue b/src/views/system/tenant/index.vue index 149b95c1..2908808a 100644 --- a/src/views/system/tenant/index.vue +++ b/src/views/system/tenant/index.vue @@ -228,6 +228,7 @@ const modalStateTypeFrom = Form.useForm( max: 50, message: t('views.system.tenant.key') + t('common.unableNull'), }, + { pattern: /^[a-zA-Z0-9]+$/, message: t('views.system.tenant.patternTip') }, ], radioType: [ { @@ -492,12 +493,20 @@ function fnModalVisibleByType( modalState.typeFrom.tenancyType == 'IMSI' && modalState.typeFrom.tenancyKey ) { + let tenancyKey: any = modalState.typeFrom.tenancyKey.trim(); // 去除首尾空格 const prefixRule: RegExp = /%$/; // 前缀匹配正则 const fuzzyRule: RegExp = /^%.+%$/; // 模糊匹配正则 - if (fuzzyRule.test(modalState.typeFrom.tenancyKey)) { + const suffixRule: RegExp = /^%[^%]+$/; // 后缀匹配正则 + const fullRule: RegExp = /^[^%]*$/; // 全部匹配正则 + + if (fuzzyRule.test(tenancyKey)) { modalState.typeFrom.imsiMatch = 'fuzzy'; - } else if (prefixRule.test(modalState.typeFrom.tenancyKey)) { + } else if (prefixRule.test(tenancyKey)) { modalState.typeFrom.imsiMatch = 'prefix'; + } else if (suffixRule.test(tenancyKey)) { + modalState.typeFrom.imsiMatch = 'suffix'; + } else if (fullRule.test(tenancyKey)) { + modalState.typeFrom.imsiMatch = 'full'; } // 去除百分号 @@ -539,19 +548,21 @@ function fnModalTypeOk() { validateName.push('tenancyKey'); } - if (from.tenancyType === 'IMSI') { - const imsiMatchRule: any = { - prefix: from.tenancyKey ? `${from.tenancyKey}%` : '', - fuzzy: from.tenancyKey ? `%${from.tenancyKey}%` : '', - }; - from.tenancyKey = imsiMatchRule[modalState.typeFrom.imsiMatch]; - } + const imsiMatchRule: any = { + prefix: from.tenancyKey ? `${from.tenancyKey}%` : '', + fuzzy: from.tenancyKey ? `%${from.tenancyKey}%` : '', + full: from.tenancyKey ? from.tenancyKey : '', + suffix: from.tenancyKey ? `%${from.tenancyKey}` : '', + }; modalStateTypeFrom .validate(validateName) .then(() => { modalState.confirmLoading = true; from.parentId = state.selectedNode; + if (from.tenancyType === 'IMSI') { + from.tenancyKey = imsiMatchRule[modalState.typeFrom.imsiMatch]; + } const tenant = from.tenantId ? updateTenant(from) : addTenant(from); const hide = message.loading(t('common.loading'), 0); tenant @@ -640,6 +651,17 @@ function fnTypeChange(value: any) { keyTip.value = tipMapping[value]; } +function handleInputChange(value: any) { + console.log('value', value); + // 去掉百分号 + const filteredValue = value.data.replace('%', ''); + console.log('filteredValue', filteredValue); + + if (filteredValue) modalState.typeFrom.tenancyKey += filteredValue; + // 更新数据模型 + //modalState.typeFrom.tenancyKey = filteredValue; +} + //为后续批量请求使用 let promises = ref([]); let neCascaderOptions = ref[]>([]); @@ -1014,6 +1036,8 @@ onMounted(() => { :options="[ { label: t('views.neUser.sub.fuzzyMatch'), value: 'fuzzy' }, { label: t('views.neUser.sub.prefixMatch'), value: 'prefix' }, + { label: t('views.neUser.sub.fullMatch'), value: 'full' }, + { label: t('views.neUser.sub.suffixMatch'), value: 'suffix' }, ]" style="width: 20%" > @@ -1023,6 +1047,7 @@ onMounted(() => { v-model:value="modalState.typeFrom.tenancyKey" allow-clear style="width: 80%" + @change="handleInputChange" >