优化分类属性管理,移除description字段,统一使用name字段存储属性名称和字典类型

This commit is contained in:
WUSIJIAN
2025-12-23 16:55:31 +08:00
parent 95da8576bc
commit b910584019
3 changed files with 14 additions and 19 deletions

View File

@@ -37,7 +37,7 @@
placeholder="请输入属性名称"
clearable
/>
<span v-else class="dict-name">{{ attr.description || '请选择字典' }}</span>
<span v-else class="dict-name">{{ attr.name || '请选择字典' }}</span>
</div>
<div class="col col-type">
<el-select v-model="attr.type" placeholder="属性类型" class="w100" @change="onAttrTypeChange(attr)">
@@ -51,7 +51,7 @@
</div>
<div class="col col-dict">
<el-select
v-model="attr.description"
v-model="attr.name"
placeholder="选择字典"
class="w100"
:disabled="!isDictType(attr.type)"
@@ -69,7 +69,7 @@
</div>
<div class="col col-dict-value">
<el-select
v-if="isDictType(attr.type) && attr.description"
v-if="isDictType(attr.type) && attr.name"
v-model="attr.options"
multiple
placeholder="选择字典值"
@@ -79,7 +79,7 @@
:max-collapse-tags="2"
>
<el-option
v-for="(item, idx) in getDictValuesByType(attr.description)"
v-for="(item, idx) in getDictValuesByType(attr.name)"
:key="idx"
:label="item.value"
:value="item.key"
@@ -126,8 +126,7 @@ interface CategoryRow {
id: string;
name: string;
level: number;
type: string;
status: string;
options?: string[];
sort?: number;
children?: CategoryRow[] | null;
}
@@ -138,7 +137,6 @@ interface CustomAttr {
required?: boolean;
multiple?: boolean;
options?: string[];
description?: string;
sort?: number;
dictKey?: string;
dictValues?: string[];
@@ -254,7 +252,6 @@ const addAttr = () => {
ruleForm.attrs.push({
name: '',
type: 'text',
description: '',
options: [],
});
};
@@ -271,10 +268,10 @@ const onAttrTypeChange = (attr: CustomAttr) => {
if (dictTypeOptions.value.length === 0) {
fetchDictTypeOptions();
}
attr.description = '';
attr.name = '';
attr.options = [];
} else {
attr.description = '';
attr.name = '';
attr.options = [];
}
};
@@ -364,7 +361,7 @@ const formatDictOptions = (attr: CustomAttr) => {
value: opt.value ?? opt.key ?? '',
}));
}
const dictValues = getDictValuesByType(attr.description || '');
const dictValues = getDictValuesByType(attr.name || '');
return options.map((optValue: string) => {
const dictItem = dictValues.find((d: any) => d.key === optValue);
return {
@@ -383,7 +380,6 @@ const onSubmit = () => {
const processedAttrs = ruleForm.attrs.map((attr) => {
const base = {
type: attr.type,
description: attr.description || '',
required: attr.required ?? false,
multiple: attr.type === 'multi_select',
sort: attr.sort ?? 0,
@@ -392,7 +388,7 @@ const onSubmit = () => {
if (isDictType(attr.type)) {
return {
...base,
name: '',
name: attr.name || '',
options: formatDictOptions(attr),
};
}