This commit is contained in:
lai
2024-07-18 11:26:15 +08:00
parent 15f6cf0b4c
commit 636c7a5939
3 changed files with 40 additions and 9 deletions

View File

@@ -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<any[]>([]);
let neCascaderOptions = ref<Record<string, any>[]>([]);
@@ -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"
></a-input>
</a-form-item>