feat:【mall】diy editor 的 hot-zone 代码优化(100%)完成商品分类的支持

This commit is contained in:
YunaiV
2025-10-28 23:21:07 +08:00
parent 05dc2c7eb2
commit fe7a69f570
4 changed files with 63 additions and 51 deletions

View File

@@ -3,32 +3,33 @@ import { computed, onMounted, ref } from 'vue';
import { handleTree } from '@vben/utils';
import { ElTreeSelect } from 'element-plus';
import { getCategoryList } from '#/api/mall/product/category';
/** 商品分类选择组件 */
defineOptions({ name: 'ProductCategorySelect' });
const props = defineProps({
// ID
modelValue: {
type: [Number, Array<Number>],
default: undefined,
},
//
}, // ID
multiple: {
type: Boolean,
default: false,
},
//
}, //
parentId: {
type: Number,
default: undefined,
},
}, //
});
/** 分类选择 */
const emit = defineEmits(['update:modelValue']);
const categoryList = ref<any[]>([]); //
/** 选中的分类 ID */
const selectCategoryId = computed({
get: () => {
@@ -40,7 +41,6 @@ const selectCategoryId = computed({
});
/** 初始化 */
const categoryList = ref<any[]>([]); //
onMounted(async () => {
const data = await getCategoryList({
parentId: props.parentId,
@@ -49,20 +49,19 @@ onMounted(async () => {
});
</script>
<template>
<el-tree-select
<ElTreeSelect
v-model="selectCategoryId"
:data="categoryList"
node-key="id"
:props="{
children: 'children',
label: 'name',
value: 'id',
isLeaf: 'leaf',
emitPath: false,
}"
:multiple="multiple"
:show-checkbox="multiple"
class="w-1/1"
node-key="id"
check-strictly
default-expand-all
class="w-full"
placeholder="请选择商品分类"
/>
</template>

View File

@@ -0,0 +1 @@
export { default as ProductCategorySelect } from './category-select.vue';