Skip to content

Commit eea285b

Browse files
author
puhui999
committed
Merge remote-tracking branch 'yudao/dev' into dev-to-dev
2 parents ed739ae + 8d026f0 commit eea285b

File tree

9 files changed

+46
-61
lines changed

9 files changed

+46
-61
lines changed

src/router/modules/remaining.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
340340
children: [
341341
{
342342
path: 'spu/add',
343-
component: () => import('@/views/mall/product/spu/addForm.vue'),
343+
component: () => import('@/views/mall/product/spu/form/index.vue'),
344344
name: 'ProductSpuAdd',
345345
meta: {
346346
noCache: true,
@@ -353,7 +353,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
353353
},
354354
{
355355
path: 'spu/edit/:spuId(\\d+)',
356-
component: () => import('@/views/mall/product/spu/addForm.vue'),
356+
component: () => import('@/views/mall/product/spu/form/index.vue'),
357357
name: 'ProductSpuEdit',
358358
meta: {
359359
noCache: true,
@@ -366,7 +366,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
366366
},
367367
{
368368
path: 'spu/detail/:spuId(\\d+)',
369-
component: () => import('@/views/mall/product/spu/addForm.vue'),
369+
component: () => import('@/views/mall/product/spu/form/index.vue'),
370370
name: 'ProductSpuDetail',
371371
meta: {
372372
noCache: true,
Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
import BasicInfoForm from './BasicInfoForm.vue'
2-
import DescriptionForm from './DescriptionForm.vue'
3-
import OtherSettingsForm from './OtherSettingsForm.vue'
4-
import ProductAttributes from './ProductAttributes.vue'
5-
import ProductPropertyAddForm from './ProductPropertyAddForm.vue'
61
import SkuList from './SkuList.vue'
72

8-
import { Spu } from '@/api/mall/product/spu'
9-
103
interface PropertyAndValues {
114
id: number
125
name: string
@@ -29,42 +22,4 @@ interface RuleConfig {
2922
message: string
3023
}
3124

32-
/**
33-
* 获得商品的规格列表
34-
*
35-
* @param spu
36-
* @return PropertyAndValues 规格列表
37-
*/
38-
const getPropertyList = (spu: Spu): PropertyAndValues[] => {
39-
// 直接拿返回的 skus 属性逆向生成出 propertyList
40-
const properties: PropertyAndValues[] = []
41-
// 只有是多规格才处理
42-
if (spu.specType) {
43-
spu.skus?.forEach((sku) => {
44-
sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
45-
// 添加属性
46-
if (!properties?.some((item) => item.id === propertyId)) {
47-
properties.push({ id: propertyId!, name: propertyName!, values: [] })
48-
}
49-
// 添加属性值
50-
const index = properties?.findIndex((item) => item.id === propertyId)
51-
if (!properties[index].values?.some((value) => value.id === valueId)) {
52-
properties[index].values?.push({ id: valueId!, name: valueName! })
53-
}
54-
})
55-
})
56-
}
57-
return properties
58-
}
59-
60-
export {
61-
BasicInfoForm,
62-
DescriptionForm,
63-
OtherSettingsForm,
64-
ProductAttributes,
65-
ProductPropertyAddForm,
66-
SkuList,
67-
getPropertyList,
68-
PropertyAndValues,
69-
RuleConfig
70-
}
25+
export { SkuList, PropertyAndValues, RuleConfig }

src/views/mall/product/spu/components/BasicInfoForm.vue renamed to src/views/mall/product/spu/form/BasicInfoForm.vue

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,17 @@ import { propTypes } from '@/utils/propTypes'
175175
import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/utils/tree'
176176
import { createImageViewer } from '@/components/ImageViewer'
177177
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
178-
import { UploadImg, UploadImgs } from '@/components/UploadFile'
179-
import { getPropertyList, ProductAttributes, ProductPropertyAddForm, SkuList } from './index'
178+
import { PropertyAndValues, SkuList } from '@/views/mall/product/spu/components/index.ts'
179+
import ProductAttributes from './ProductAttributes.vue'
180+
import ProductPropertyAddForm from './ProductPropertyAddForm.vue'
180181
import { basicInfoSchema } from './spu.data'
181182
import type { Spu } from '@/api/mall/product/spu'
182183
import * as ProductCategoryApi from '@/api/mall/product/category'
183-
import { getSimpleBrandList } from '@/api/mall/product/brand'
184-
import { getSimpleTemplateList } from '@/api/mall/trade/delivery/expressTemplate/index'
184+
import * as ProductBrandApi from '@/api/mall/product/brand'
185+
import * as ExpressTemplateApi from '@/api/mall/trade/delivery/expressTemplate'
186+
187+
defineOptions({ name: 'ProductSpuBasicInfoForm' })
188+
185189
// ====== 商品详情相关操作 ======
186190
const { allSchemas } = useCrudSchemas(basicInfoSchema)
187191
/** 商品图预览 */
@@ -198,9 +202,36 @@ const imagePreview = (args) => {
198202
urlList
199203
})
200204
}
201-
// ====== end ======
202205
203-
defineOptions({ name: 'ProductSpuBasicInfoForm' })
206+
/**
207+
* 获得商品的规格列表
208+
*
209+
* @param spu
210+
* @return PropertyAndValues 规格列表
211+
*/
212+
const getPropertyList = (spu: Spu): PropertyAndValues[] => {
213+
// 直接拿返回的 skus 属性逆向生成出 propertyList
214+
const properties: PropertyAndValues[] = []
215+
// 只有是多规格才处理
216+
if (spu.specType) {
217+
spu.skus?.forEach((sku) => {
218+
sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
219+
// 添加属性
220+
if (!properties?.some((item) => item.id === propertyId)) {
221+
properties.push({ id: propertyId!, name: propertyName!, values: [] })
222+
}
223+
// 添加属性值
224+
const index = properties?.findIndex((item) => item.id === propertyId)
225+
if (!properties[index].values?.some((value) => value.id === valueId)) {
226+
properties[index].values?.push({ id: valueId!, name: valueName! })
227+
}
228+
})
229+
})
230+
}
231+
return properties
232+
}
233+
234+
// ====== end ======
204235
205236
const message = useMessage() // 消息弹窗
206237
@@ -346,8 +377,8 @@ onMounted(async () => {
346377
const data = await ProductCategoryApi.getCategoryList({})
347378
categoryList.value = handleTree(data, 'id', 'parentId')
348379
// 获取商品品牌列表
349-
brandList.value = await getSimpleBrandList()
380+
brandList.value = await ProductBrandApi.getSimpleBrandList()
350381
// 获取运费模版
351-
deliveryTemplateList.value = await getSimpleTemplateList()
382+
deliveryTemplateList.value = await ExpressTemplateApi.getSimpleTemplateList()
352383
})
353384
</script>

src/views/mall/product/spu/addForm.vue renamed to src/views/mall/product/spu/form/index.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@
3939
<script lang="ts" setup>
4040
import { cloneDeep } from 'lodash-es'
4141
import { useTagsViewStore } from '@/store/modules/tagsView'
42-
import { BasicInfoForm, DescriptionForm, OtherSettingsForm } from './components'
43-
// 业务api
4442
import * as ProductSpuApi from '@/api/mall/product/spu'
43+
import BasicInfoForm from './BasicInfoForm.vue'
44+
import DescriptionForm from './DescriptionForm.vue'
45+
import OtherSettingsForm from './OtherSettingsForm.vue'
4546
import { convertToInteger, floatToFixed2, formatToFraction } from '@/utils'
4647
47-
// TODO @芋艿:后续稍微调整下;
48-
4948
defineOptions({ name: 'ProductSpuForm' })
5049
5150
const { t } = useI18n() // 国际化

0 commit comments

Comments
 (0)