diff --git a/src/views/assets/asset/component/editAsset.vue b/src/views/assets/asset/component/editAsset.vue index 6aafb49..db2c16d 100644 --- a/src/views/assets/asset/component/editAsset.vue +++ b/src/views/assets/asset/component/editAsset.vue @@ -355,7 +355,6 @@ interface CategoryAttr { name: string; type: string; options?: { label: string; value: string }[]; - description?: string; } interface RuleForm { @@ -411,12 +410,12 @@ const isTimeSlotLimitReached = computed(() => ruleForm.serviceAssetConfig.schedu // 获取属性的key const getAttrKey = (attr: CategoryAttr): string => { - return attr.name || attr.description || `attr_${categoryAttrs.value.indexOf(attr)}`; + return attr.name || `attr_${categoryAttrs.value.indexOf(attr)}`; }; // 获取属性的显示名称 const getAttrLabel = (attr: CategoryAttr): string => { - return attr.description || attr.name || '属性'; + return attr.name || '属性'; }; // 图片相关 @@ -692,7 +691,7 @@ const onCategoryChange = (categoryId: string) => { if (data?.attrs && Array.isArray(data.attrs)) { categoryAttrs.value = data.attrs; // 初始化属性值,确保 boolean 类型默认为 false - data.attrs.forEach((attr: CategoryAttr) => { + categoryAttrs.value.forEach((attr: CategoryAttr) => { const key = getAttrKey(attr); if (attr.type === 'boolean') { ruleForm.metadata[key] = false; @@ -789,7 +788,7 @@ const openDialog = (row?: any, edit?: boolean) => { if (catData?.attrs && Array.isArray(catData.attrs)) { categoryAttrs.value = catData.attrs; // 初始化属性值,确保 boolean 类型默认为 false - catData.attrs.forEach((attr: CategoryAttr) => { + categoryAttrs.value.forEach((attr: CategoryAttr) => { const key = getAttrKey(attr); if (attr.type === 'boolean' && ruleForm.metadata[key] === undefined) { ruleForm.metadata[key] = false; diff --git a/src/views/assets/asset/index.vue b/src/views/assets/asset/index.vue index bb0b360..22e2aaa 100644 --- a/src/views/assets/asset/index.vue +++ b/src/views/assets/asset/index.vue @@ -64,7 +64,7 @@ diff --git a/src/views/assets/category/component/editCategory.vue b/src/views/assets/category/component/editCategory.vue index 0f9ae7a..cd89112 100644 --- a/src/views/assets/category/component/editCategory.vue +++ b/src/views/assets/category/component/editCategory.vue @@ -37,7 +37,7 @@ placeholder="请输入属性名称" clearable /> - {{ attr.description || '请选择字典' }} + {{ attr.name || '请选择字典' }}
@@ -51,7 +51,7 @@
{ 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), }; }