商品管理: 完善选择商品分类

This commit is contained in:
puhui999 2023-04-26 17:53:17 +08:00
parent 5c52c17227
commit ab1685a741
4 changed files with 15 additions and 8 deletions

View File

@ -1,6 +1,6 @@
export interface SpuType { export interface SpuType {
name?: string // 商品名称 name?: string // 商品名称
categoryId?: number // 商品分类 categoryId?: number | undefined // 商品分类
keyword?: string // 关键字 keyword?: string // 关键字
unit?: string // 单位 unit?: string // 单位
picUrl?: string // 商品封面图 picUrl?: string // 商品封面图

View File

@ -49,7 +49,7 @@ const DescriptionRef = ref<ComponentRef<typeof DescriptionForm>>() // 商品详
const OtherSettingsRef = ref<ComponentRef<typeof OtherSettingsForm>>() // Ref const OtherSettingsRef = ref<ComponentRef<typeof OtherSettingsForm>>() // Ref
const formData = ref<SpuType>({ const formData = ref<SpuType>({
name: '', // name: '', //
categoryId: 0, // categoryId: undefined, //
keyword: '', // keyword: '', //
unit: '', // unit: '', //
picUrl: '', // picUrl: '', //

View File

@ -10,7 +10,7 @@
<el-form-item label="商品分类" prop="categoryId"> <el-form-item label="商品分类" prop="categoryId">
<el-tree-select <el-tree-select
v-model="formData.categoryId" v-model="formData.categoryId"
:data="[]" :data="categoryList"
:props="defaultProps" :props="defaultProps"
check-strictly check-strictly
node-key="id" node-key="id"
@ -101,10 +101,11 @@
</template> </template>
<script lang="ts" name="ProductManagementBasicInfoForm" setup> <script lang="ts" name="ProductManagementBasicInfoForm" setup>
import { PropType } from 'vue' import { PropType } from 'vue'
import { defaultProps } from '@/utils/tree'
import type { SpuType } from '@/api/mall/product/management/type' import type { SpuType } from '@/api/mall/product/management/type'
import { UploadImg, UploadImgs } from '@/components/UploadFile' import { UploadImg, UploadImgs } from '@/components/UploadFile'
import { copyValueToTarget } from '@/utils/object' import { copyValueToTarget } from '@/utils/object'
import * as ProductCategoryApi from '@/api/mall/product/category'
import { defaultProps, handleTree } from '@/utils/tree'
const message = useMessage() // const message = useMessage() //
const props = defineProps({ const props = defineProps({
@ -117,7 +118,7 @@ const props = defineProps({
const ProductManagementBasicInfoRef = ref() // Ref const ProductManagementBasicInfoRef = ref() // Ref
const formData = ref<SpuType>({ const formData = ref<SpuType>({
name: '', // name: '', //
categoryId: 155415, // categoryId: undefined, //
keyword: '', // keyword: '', //
unit: '', // unit: '', //
picUrl: '', // picUrl: '', //
@ -186,4 +187,10 @@ const changeSubCommissionType = (subCommissionType) => {
const confirm = () => {} const confirm = () => {}
// //
const addRule = () => {} const addRule = () => {}
const categoryList = ref() //
onMounted(async () => {
//
const data = await ProductCategoryApi.getCategoryList({})
categoryList.value = handleTree(data, 'id', 'parentId')
})
</script> </script>

View File

@ -92,9 +92,9 @@ const onChangeGroup = () => {
const OtherSettingsFormRef = ref() // Ref const OtherSettingsFormRef = ref() // Ref
// //
const formData = ref<SpuType>({ const formData = ref<SpuType>({
sort: 12, // sort: 1, //
giveIntegral: 666, // giveIntegral: 1, //
virtualSalesCount: 565656, // virtualSalesCount: 1, //
recommendHot: false, // recommendHot: false, //
recommendBenefit: false, // recommendBenefit: false, //
recommendBest: false, // recommendBest: false, //