Skip to content

Commit ab1685a

Browse files
author
puhui999
committed
商品管理: 完善选择商品分类
1 parent 5c52c17 commit ab1685a

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

src/api/mall/product/management/type/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface SpuType {
22
name?: string // 商品名称
3-
categoryId?: number // 商品分类
3+
categoryId?: number | undefined // 商品分类
44
keyword?: string // 关键字
55
unit?: string // 单位
66
picUrl?: string // 商品封面图

src/views/mall/product/management/addForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const DescriptionRef = ref<ComponentRef<typeof DescriptionForm>>() // 商品详
4949
const OtherSettingsRef = ref<ComponentRef<typeof OtherSettingsForm>>() // 其他设置Ref
5050
const formData = ref<SpuType>({
5151
name: '', // 商品名称
52-
categoryId: 0, // 商品分类
52+
categoryId: undefined, // 商品分类
5353
keyword: '', // 关键字
5454
unit: '', // 单位
5555
picUrl: '', // 商品封面图

src/views/mall/product/management/components/BasicInfoForm.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<el-form-item label="商品分类" prop="categoryId">
1111
<el-tree-select
1212
v-model="formData.categoryId"
13-
:data="[]"
13+
:data="categoryList"
1414
:props="defaultProps"
1515
check-strictly
1616
node-key="id"
@@ -101,10 +101,11 @@
101101
</template>
102102
<script lang="ts" name="ProductManagementBasicInfoForm" setup>
103103
import { PropType } from 'vue'
104-
import { defaultProps } from '@/utils/tree'
105104
import type { SpuType } from '@/api/mall/product/management/type'
106105
import { UploadImg, UploadImgs } from '@/components/UploadFile'
107106
import { copyValueToTarget } from '@/utils/object'
107+
import * as ProductCategoryApi from '@/api/mall/product/category'
108+
import { defaultProps, handleTree } from '@/utils/tree'
108109
109110
const message = useMessage() // 消息弹窗
110111
const props = defineProps({
@@ -117,7 +118,7 @@ const props = defineProps({
117118
const ProductManagementBasicInfoRef = ref() // 表单Ref
118119
const formData = ref<SpuType>({
119120
name: '', // 商品名称
120-
categoryId: 155415, // 商品分类
121+
categoryId: undefined, // 商品分类
121122
keyword: '', // 关键字
122123
unit: '', // 单位
123124
picUrl: '', // 商品封面图
@@ -186,4 +187,10 @@ const changeSubCommissionType = (subCommissionType) => {
186187
const confirm = () => {}
187188
// 添加规格
188189
const addRule = () => {}
190+
const categoryList = ref() // 分类树
191+
onMounted(async () => {
192+
// 获得分类树
193+
const data = await ProductCategoryApi.getCategoryList({})
194+
categoryList.value = handleTree(data, 'id', 'parentId')
195+
})
189196
</script>

src/views/mall/product/management/components/OtherSettingsForm.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ const onChangeGroup = () => {
9292
const OtherSettingsFormRef = ref() // 表单Ref
9393
// 表单数据
9494
const formData = ref<SpuType>({
95-
sort: 12, // 商品排序
96-
giveIntegral: 666, // 赠送积分
97-
virtualSalesCount: 565656, // 虚拟销量
95+
sort: 1, // 商品排序
96+
giveIntegral: 1, // 赠送积分
97+
virtualSalesCount: 1, // 虚拟销量
9898
recommendHot: false, // 是否热卖
9999
recommendBenefit: false, // 是否优惠
100100
recommendBest: false, // 是否精品

0 commit comments

Comments
 (0)