Conflicts:
	src/utils/dict.ts
This commit is contained in:
YunaiV 2023-06-17 18:45:05 +08:00
commit 7908160e68
8 changed files with 22 additions and 24 deletions

View File

@ -355,7 +355,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
}, },
children: [ children: [
{ {
path: 'productSpuAdd', // TODO @puhui999最好拆成 add 和 edit 两个路由;添加商品;修改商品 fix path: 'spu/add',
component: () => import('@/views/mall/product/spu/addForm.vue'), component: () => import('@/views/mall/product/spu/addForm.vue'),
name: 'ProductSpuAdd', name: 'ProductSpuAdd',
meta: { meta: {
@ -368,9 +368,9 @@ const remainingRouter: AppRouteRecordRaw[] = [
} }
}, },
{ {
path: 'productSpuEdit/:spuId(\\d+)', path: 'spu/edit/:spuId(\\d+)',
component: () => import('@/views/mall/product/spu/addForm.vue'), component: () => import('@/views/mall/product/spu/addForm.vue'),
name: 'productSpuEdit', name: 'ProductSpuEdit',
meta: { meta: {
noCache: true, noCache: true,
hidden: true, hidden: true,
@ -381,9 +381,9 @@ const remainingRouter: AppRouteRecordRaw[] = [
} }
}, },
{ {
path: 'productSpuDetail/:spuId(\\d+)', path: 'spu/detail/:spuId(\\d+)',
component: () => import('@/views/mall/product/spu/addForm.vue'), component: () => import('@/views/mall/product/spu/addForm.vue'),
name: 'productSpuDetail', name: 'ProductSpuDetail',
meta: { meta: {
noCache: true, noCache: true,
hidden: true, hidden: true,

View File

@ -104,7 +104,7 @@ const getDetail = async () => {
formLoading.value = true formLoading.value = true
try { try {
const res = (await ProductSpuApi.getSpu(id)) as ProductSpuApi.Spu const res = (await ProductSpuApi.getSpu(id)) as ProductSpuApi.Spu
res.skus!.forEach((item) => { res.skus?.forEach((item) => {
// //
item.price = formatToFraction(item.price) item.price = formatToFraction(item.price)
item.marketPrice = formatToFraction(item.marketPrice) item.marketPrice = formatToFraction(item.marketPrice)

View File

@ -14,7 +14,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<!-- TODO @puhui999只能选根节点 fix: 已完善-->
<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"
@ -166,8 +165,7 @@
</Descriptions> </Descriptions>
<!-- 商品属性添加 Form 表单 --> <!-- 商品属性添加 Form 表单 -->
<!-- TODO @puhui999: ProductPropertyAddForm 是不是更合适呀 --> <ProductPropertyAddForm ref="attributesAddFormRef" :propertyList="propertyList" />
<ProductAttributesAddForm ref="attributesAddFormRef" :propertyList="propertyList" />
</template> </template>
<script lang="ts" name="ProductSpuBasicInfoForm" setup> <script lang="ts" name="ProductSpuBasicInfoForm" setup>
import { PropType } from 'vue' import { PropType } from 'vue'
@ -178,7 +176,7 @@ import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/uti
import { createImageViewer } from '@/components/ImageViewer' import { createImageViewer } from '@/components/ImageViewer'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { UploadImg, UploadImgs } from '@/components/UploadFile' import { UploadImg, UploadImgs } from '@/components/UploadFile'
import { ProductAttributes, ProductAttributesAddForm, SkuList } from './index' import { ProductAttributes, ProductPropertyAddForm, SkuList } from './index'
import { basicInfoSchema } from './spu.data' import { basicInfoSchema } from './spu.data'
import type { Spu } from '@/api/mall/product/spu' import type { Spu } from '@/api/mall/product/spu'
import * as ProductCategoryApi from '@/api/mall/product/category' import * as ProductCategoryApi from '@/api/mall/product/category'
@ -258,7 +256,7 @@ watch(
return return
} }
copyValueToTarget(formData, data) copyValueToTarget(formData, data)
formData.sliderPicUrls = data['sliderPicUrls'].map((item) => ({ formData.sliderPicUrls = data['sliderPicUrls']?.map((item) => ({
url: item url: item
})) }))
// //
@ -267,16 +265,16 @@ watch(
} }
// skus propertyList // skus propertyList
const properties = [] const properties = []
formData.skus.forEach((sku) => { formData.skus?.forEach((sku) => {
sku.properties.forEach(({ propertyId, propertyName, valueId, valueName }) => { sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
// //
if (!properties.some((item) => item.id === propertyId)) { if (!properties?.some((item) => item.id === propertyId)) {
properties.push({ id: propertyId, name: propertyName, values: [] }) properties.push({ id: propertyId, name: propertyName, values: [] })
} }
// //
const index = properties.findIndex((item) => item.id === propertyId) const index = properties?.findIndex((item) => item.id === propertyId)
if (!properties[index].values.some((value) => value.id === valueId)) { if (!properties[index].values?.some((value) => value.id === valueId)) {
properties[index].values.push({ id: valueId, name: valueName }) properties[index].values?.push({ id: valueId, name: valueName })
} }
}) })
}) })

View File

@ -17,7 +17,7 @@
</template> </template>
</Dialog> </Dialog>
</template> </template>
<script lang="ts" name="ProductPropertyForm" setup> <script lang="ts" name="ProductPropertyAddForm" setup>
import * as PropertyApi from '@/api/mall/product/property' import * as PropertyApi from '@/api/mall/product/property'
const { t } = useI18n() // const { t } = useI18n() //

View File

@ -23,7 +23,6 @@
min-width="120" min-width="120"
> >
<template #default="{ row }"> <template #default="{ row }">
<!-- TODO puhui999展示成蓝色有点区分度哈 fix-->
<span style="font-weight: bold; color: #40aaff"> <span style="font-weight: bold; color: #40aaff">
{{ row.properties[index]?.valueName }} {{ row.properties[index]?.valueName }}
</span> </span>

View File

@ -2,7 +2,7 @@ import BasicInfoForm from './BasicInfoForm.vue'
import DescriptionForm from './DescriptionForm.vue' import DescriptionForm from './DescriptionForm.vue'
import OtherSettingsForm from './OtherSettingsForm.vue' import OtherSettingsForm from './OtherSettingsForm.vue'
import ProductAttributes from './ProductAttributes.vue' import ProductAttributes from './ProductAttributes.vue'
import ProductAttributesAddForm from './ProductAttributesAddForm.vue' import ProductPropertyAddForm from './ProductPropertyAddForm.vue'
import SkuList from './SkuList.vue' import SkuList from './SkuList.vue'
export { export {
@ -10,6 +10,6 @@ export {
DescriptionForm, DescriptionForm,
OtherSettingsForm, OtherSettingsForm,
ProductAttributes, ProductAttributes,
ProductAttributesAddForm, ProductPropertyAddForm,
SkuList SkuList
} }

View File

@ -1,6 +1,7 @@
import { CrudSchema } from '@/hooks/web/useCrudSchemas' import { CrudSchema } from '@/hooks/web/useCrudSchemas'
// TODO @puhui999如果只要 detail可以不用 CrudSchema只要描述的 Schema // TODO @puhui999如果只要 detail可以不用 CrudSchema只要描述的 Schema
// fix: useCrudSchemas 中没有单独处理的情况且只要 detail 的情况只要 spu 这里有使用 如果改动得添加/修改代码
export const basicInfoSchema = reactive<CrudSchema[]>([ export const basicInfoSchema = reactive<CrudSchema[]>([
{ {
label: '商品名称', label: '商品名称',

View File

@ -396,18 +396,18 @@ const resetQuery = () => {
const openForm = (id?: number) => { const openForm = (id?: number) => {
// //
if (typeof id === 'number') { if (typeof id === 'number') {
push('/product/productSpuEdit/' + id) push('/product/spu/edit/' + id)
return return
} }
// //
push('/product/productSpuAdd') push({ name: 'ProductSpuAdd' })
} }
/** /**
* 查看商品详情 * 查看商品详情
*/ */
const openDetail = (id?: number) => { const openDetail = (id?: number) => {
push('/product/productSpuDetail/' + id) push('/product/spu/detail/' + id)
} }
/** 导出按钮操作 */ /** 导出按钮操作 */