基础信息修改针对于类别删除4层限制
This commit is contained in:
@ -361,6 +361,7 @@
|
||||
<el-form-item label="类别" prop="category" v-if="hasFieldPermission('category')">
|
||||
<div style="display: flex; width: 100%; align-items: center;">
|
||||
<el-cascader
|
||||
ref="categoryCascaderRef"
|
||||
v-model="tempCategoryPrefix"
|
||||
:options="categoryTreeOptions"
|
||||
:props="{ expandTrigger: 'hover', checkStrictly: true, emitPath: true }"
|
||||
@ -368,6 +369,7 @@
|
||||
filterable
|
||||
clearable
|
||||
style="width: 50%;"
|
||||
@change="onCategoryChange"
|
||||
/>
|
||||
<div style="padding: 0 8px; font-weight: bold; color: #909399;">/</div>
|
||||
<el-input
|
||||
@ -377,9 +379,7 @@
|
||||
style="width: 50%;"
|
||||
/>
|
||||
</div>
|
||||
<div style="font-size: 12px; color: #E6A23C; margin-top: 4px; line-height: 1.2;">
|
||||
* 必须构成4层结构
|
||||
</div>
|
||||
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -842,6 +842,16 @@ const categoryOptions = ref<string[]>([]);
|
||||
const typeOptions = ref<string[]>([]);
|
||||
const categoryTreeOptions = ref<CascaderOption[]>([]);
|
||||
|
||||
// 类别级联选择器的 ref
|
||||
const categoryCascaderRef = ref<any>(null);
|
||||
|
||||
// 选中类别后自动收起下拉面板
|
||||
const onCategoryChange = () => {
|
||||
if (categoryCascaderRef.value) {
|
||||
categoryCascaderRef.value.togglePopperVisible(false);
|
||||
}
|
||||
};
|
||||
|
||||
const tempCategoryPrefix = ref<string[]>([]);
|
||||
const tempCategorySuffix = ref<string>('');
|
||||
|
||||
@ -891,19 +901,8 @@ const validateCategoryLevel = (rule: any, value: any, callback: any) => {
|
||||
|
||||
if (!prefixStr && !suffixStr) {
|
||||
callback(new Error('请填写或选择类别'));
|
||||
return;
|
||||
}
|
||||
|
||||
let fullPath = '';
|
||||
if (prefixStr && suffixStr) fullPath = prefixStr + '/' + suffixStr;
|
||||
else if (prefixStr) fullPath = prefixStr;
|
||||
else fullPath = suffixStr;
|
||||
|
||||
const levels = fullPath.split('/').filter(p => p.trim() !== '').length;
|
||||
|
||||
if (levels !== 4) {
|
||||
callback(new Error(`必须严格满足4层结构,当前为 ${levels} 层`));
|
||||
} else {
|
||||
// 只要有前缀或后缀,就直接放行,不再限制必须是4层
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user