Skip to content

Commit 9680a20

Browse files
committed
调整商品分类的实现
1 parent c14b5c5 commit 9680a20

File tree

4 files changed

+45
-39
lines changed

4 files changed

+45
-39
lines changed

build/vite/optimize.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const include = [
6464
'element-plus/es/components/dropdown-menu/style/index',
6565
'element-plus/es/components/dropdown-item/style/index',
6666
'element-plus/es/components/skeleton/style/index',
67+
6768
'element-plus/es/components/skeleton/style/css',
6869
'element-plus/es/components/backtop/style/css',
6970
'element-plus/es/components/menu/style/css',
@@ -76,7 +77,21 @@ const include = [
7677
'element-plus/es/components/badge/style/css',
7778
'element-plus/es/components/breadcrumb/style/css',
7879
'element-plus/es/components/breadcrumb-item/style/css',
79-
'element-plus/es/components/image/style/css'
80+
'element-plus/es/components/image/style/css',
81+
'element-plus/es/components/tag/style/css',
82+
'element-plus/es/components/dialog/style/css',
83+
'element-plus/es/components/form/style/css',
84+
'element-plus/es/components/form-item/style/css',
85+
'element-plus/es/components/card/style/css',
86+
'element-plus/es/components/tooltip/style/css',
87+
'element-plus/es/components/radio-group/style/css',
88+
'element-plus/es/components/radio/style/css',
89+
'element-plus/es/components/input-number/style/css',
90+
'element-plus/es/components/tree-select/style/css',
91+
'element-plus/es/components/drawer/style/css',
92+
'element-plus/es/components/image-viewer/style/css',
93+
'element-plus/es/components/upload/style/css',
94+
'element-plus/es/components/switch/style/css'
8095
]
8196

8297
const exclude = ['@iconify/json']

src/api/mall/product/category.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ export interface CategoryVO {
1717
*/
1818
name: string
1919
/**
20-
* 分类图片
20+
* 移动端分类图
2121
*/
2222
picUrl: string
2323
/**
24-
* 分类排序
24+
* PC 端分类图
2525
*/
26-
sort?: number
26+
bigPicUrl?: string
2727
/**
28-
* 分类描述
28+
* 分类排序
2929
*/
30-
description?: string
30+
sort: number
3131
/**
3232
* 开启状态
3333
*/

src/views/mall/product/category/CategoryForm.vue

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,30 @@
44
ref="formRef"
55
:model="formData"
66
:rules="formRules"
7-
label-width="80px"
7+
label-width="120px"
88
v-loading="formLoading"
99
>
1010
<el-form-item label="上级分类" prop="parentId">
11-
<el-tree-select
12-
v-model="formData.parentId"
13-
:data="categoryTree"
14-
:props="{ label: 'name', value: 'id' }"
15-
:render-after-expand="false"
16-
placeholder="请选择上级分类"
17-
check-strictly
18-
default-expand-all
19-
/>
11+
<el-select v-model="formData.parentId" placeholder="请选择上级分类">
12+
<el-option :key="0" label="顶级分类" :value="0" />
13+
<el-option
14+
v-for="item in categoryList"
15+
:key="item.id"
16+
:label="item.name"
17+
:value="item.id"
18+
/>
19+
</el-select>
2020
</el-form-item>
2121
<el-form-item label="分类名称" prop="name">
2222
<el-input v-model="formData.name" placeholder="请输入分类名称" />
2323
</el-form-item>
24-
<el-form-item label="分类图片" prop="picUrl">
24+
<el-form-item label="移动端分类图" prop="picUrl">
2525
<UploadImg v-model="formData.picUrl" :limit="1" :is-show-tip="false" />
26-
<div v-if="formData.parentId === 0" style="font-size: 10px">推荐 200x100 图片分辨率</div>
27-
<div v-else style="font-size: 10px">推荐 100x100 图片分辨率</div>
26+
<div style="font-size: 10px" class="pl-10px">推荐 180x180 图片分辨率</div>
27+
</el-form-item>
28+
<el-form-item label="PC 端分类图" prop="bigPicUrl">
29+
<UploadImg v-model="formData.bigPicUrl" :limit="1" :is-show-tip="false" />
30+
<div style="font-size: 10px" class="pl-10px">推荐 468x340 图片分辨率</div>
2831
</el-form-item>
2932
<el-form-item label="分类排序" prop="sort">
3033
<el-input-number v-model="formData.sort" controls-position="right" :min="0" />
@@ -40,9 +43,6 @@
4043
</el-radio>
4144
</el-radio-group>
4245
</el-form-item>
43-
<el-form-item label="分类描述">
44-
<el-input v-model="formData.description" type="textarea" placeholder="请输入分类描述" />
45-
</el-form-item>
4646
</el-form>
4747
<template #footer>
4848
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
@@ -53,7 +53,6 @@
5353
<script setup lang="ts" name="ProductCategory">
5454
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
5555
import { CommonStatusEnum } from '@/utils/constants'
56-
import { handleTree } from '@/utils/tree'
5756
import * as ProductCategoryApi from '@/api/mall/product/category'
5857
const { t } = useI18n() // 国际化
5958
const message = useMessage() // 消息弹窗
@@ -66,8 +65,8 @@ const formData = ref({
6665
id: undefined,
6766
name: '',
6867
picUrl: '',
69-
status: CommonStatusEnum.ENABLE,
70-
description: ''
68+
bigPicUrl: '',
69+
status: CommonStatusEnum.ENABLE
7170
})
7271
const formRules = reactive({
7372
parentId: [{ required: true, message: '请选择上级分类', trigger: 'blur' }],
@@ -77,7 +76,7 @@ const formRules = reactive({
7776
status: [{ required: true, message: '开启状态不能为空', trigger: 'blur' }]
7877
})
7978
const formRef = ref() // 表单 Ref
80-
const categoryTree = ref<any[]>([]) // 分类树
79+
const categoryList = ref<any[]>([]) // 分类树
8180
8281
/** 打开弹窗 */
8382
const open = async (type: string, id?: number) => {
@@ -95,7 +94,7 @@ const open = async (type: string, id?: number) => {
9594
}
9695
}
9796
// 获得分类树
98-
await getTree()
97+
categoryList.value = await ProductCategoryApi.getCategoryList({ parentId: 0 })
9998
}
10099
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
101100
@@ -131,17 +130,9 @@ const resetForm = () => {
131130
id: undefined,
132131
name: '',
133132
picUrl: '',
134-
status: CommonStatusEnum.ENABLE,
135-
description: ''
133+
bigPicUrl: '',
134+
status: CommonStatusEnum.ENABLE
136135
}
137136
formRef.value?.resetFields()
138137
}
139-
140-
/** 获得分类树 */
141-
const getTree = async () => {
142-
const data = await ProductCategoryApi.getCategoryList({})
143-
const tree = handleTree(data, 'id', 'parentId')
144-
const menu = { id: 0, name: '顶级分类', children: tree }
145-
categoryTree.value = [menu]
146-
}
147138
</script>

src/views/mall/product/category/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
<ContentWrap>
3737
<el-table v-loading="loading" :data="list" row-key="id" default-expand-all>
3838
<el-table-column label="分类名称" prop="name" sortable />
39-
<el-table-column label="分类图片" align="center" prop="picUrl">
39+
<el-table-column label="移动端分类图" align="center" prop="picUrl">
4040
<template #default="scope">
41-
<img v-if="scope.row.picUrl" :src="scope.row.picUrl" alt="分类图片" class="h-100px" />
41+
<img v-if="scope.row.picUrl" :src="scope.row.picUrl" alt="移动端分类图" class="h-100px" />
4242
</template>
4343
</el-table-column>
4444
<el-table-column label="分类排序" align="center" prop="sort" />

0 commit comments

Comments
 (0)