fix: 修复 spu 详情查看错误,同步 mall seckill 组件 name 配置方式

pull/176/head
puhui999 2023-06-25 09:35:20 +08:00
parent 5d613e69b3
commit 76ccc54a35
6 changed files with 20 additions and 30 deletions

View File

@ -55,9 +55,9 @@ const { delView } = useTagsViewStore() // 视图操作
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const activeName = ref('basicInfo') // Tag const activeName = ref('basicInfo') // Tag
const isDetail = ref(false) // const isDetail = ref(false) //
const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>() // Ref const basicInfoRef = ref() // Ref
const descriptionRef = ref<ComponentRef<typeof DescriptionForm>>() // Ref const descriptionRef = ref() // Ref
const otherSettingsRef = ref<ComponentRef<typeof OtherSettingsForm>>() // Ref const otherSettingsRef = ref() // Ref
// spu // spu
const formData = ref<ProductSpuApi.Spu>({ const formData = ref<ProductSpuApi.Spu>({
name: '', // name: '', //
@ -98,7 +98,7 @@ const formData = ref<ProductSpuApi.Spu>({
/** 获得详情 */ /** 获得详情 */
const getDetail = async () => { const getDetail = async () => {
if ('productSpuDetail' === name) { if ('ProductSpuDetail' === name) {
isDetail.value = true isDetail.value = true
} }
const id = params.spuId as number const id = params.spuId as number

View File

@ -176,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, ProductPropertyAddForm, SkuList } from './index' import { getPropertyList, 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'
@ -242,7 +242,7 @@ const rules = reactive({
introduction: [required], introduction: [required],
picUrl: [required], picUrl: [required],
sliderPicUrls: [required], sliderPicUrls: [required],
// deliveryTemplateId: [required], deliveryTemplateId: [required],
brandId: [required], brandId: [required],
specType: [required], specType: [required],
subCommissionType: [required] subCommissionType: [required]
@ -261,26 +261,7 @@ watch(
formData.sliderPicUrls = data['sliderPicUrls']?.map((item) => ({ formData.sliderPicUrls = data['sliderPicUrls']?.map((item) => ({
url: item url: item
})) }))
// propertyList.value = getPropertyList(data)
if (!formData.specType) {
return
}
// skus propertyList
const properties = []
formData.skus?.forEach((sku) => {
sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
//
if (!properties?.some((item) => item.id === propertyId)) {
properties.push({ id: propertyId, name: propertyName, values: [] })
}
//
const index = properties?.findIndex((item) => item.id === propertyId)
if (!properties[index].values?.some((value) => value.id === valueId)) {
properties[index].values?.push({ id: valueId, name: valueName })
}
})
})
propertyList.value = properties
}, },
{ {
immediate: true immediate: true

View File

@ -22,13 +22,15 @@
<!-- TODO @puhui999这个组件是不是 SpuSelect不需要带 sku 或者 Form --> <!-- TODO @puhui999这个组件是不是 SpuSelect不需要带 sku 或者 Form -->
<SpuAndSkuSelectForm ref="spuAndSkuSelectForm" @confirm="selectSpu" /> <SpuAndSkuSelectForm ref="spuAndSkuSelectForm" @confirm="selectSpu" />
</template> </template>
<script lang="ts" name="PromotionSeckillActivityForm" setup> <script lang="ts" setup>
import { SpuAndSkuList, SpuAndSkuSelectForm } from './components' import { SpuAndSkuList, SpuAndSkuSelectForm } from './components'
import { allSchemas, rules } from './seckillActivity.data' import { allSchemas, rules } from './seckillActivity.data'
import { Spu } from '@/api/mall/product/spu' import { Spu } from '@/api/mall/product/spu'
import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity' import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
defineOptions({ name: 'PromotionSeckillActivityForm' })
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //

View File

@ -46,7 +46,7 @@
<el-table-column align="center" label="库存" min-width="90" prop="stock" /> <el-table-column align="center" label="库存" min-width="90" prop="stock" />
</el-table> </el-table>
</template> </template>
<script lang="ts" name="SpuAndSkuList" setup> <script lang="ts" setup>
// TODO SPU // TODO SPU
import { formatToFraction } from '@/utils' import { formatToFraction } from '@/utils'
import { createImageViewer } from '@/components/ImageViewer' import { createImageViewer } from '@/components/ImageViewer'
@ -59,6 +59,9 @@ import {
SkuList SkuList
} from '@/views/mall/product/spu/components' } from '@/views/mall/product/spu/components'
import { SeckillProductVO, SpuExtension } from '@/api/mall/promotion/seckill/seckillActivity' import { SeckillProductVO, SpuExtension } from '@/api/mall/promotion/seckill/seckillActivity'
defineOptions({ name: 'PromotionSpuAndSkuList' })
const message = useMessage() // const message = useMessage() //
// TODO @puhui999 spu // TODO @puhui999 spu

View File

@ -110,7 +110,7 @@
</Dialog> </Dialog>
</template> </template>
<script lang="ts" name="SeckillActivitySpuAndSkuSelect" setup> <script lang="ts" setup>
import { getPropertyList, Properties, SkuList } from '@/views/mall/product/spu/components' import { getPropertyList, Properties, SkuList } from '@/views/mall/product/spu/components'
import { ElTable } from 'element-plus' import { ElTable } from 'element-plus'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
@ -122,6 +122,8 @@ import * as ProductCategoryApi from '@/api/mall/product/category'
import * as ProductSpuApi from '@/api/mall/product/spu' import * as ProductSpuApi from '@/api/mall/product/spu'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
defineOptions({ name: 'PromotionSpuAndSkuSelect' })
const props = defineProps({ const props = defineProps({
// spu spu sku // spu spu sku
// :isSelectSku='true' // :isSelectSku='true'

View File

@ -53,11 +53,13 @@
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<SeckillActivityForm ref="formRef" @success="getList" /> <SeckillActivityForm ref="formRef" @success="getList" />
</template> </template>
<script lang="ts" name="PromotionSeckillActivity" setup> <script lang="ts" setup>
import { allSchemas } from './seckillActivity.data' import { allSchemas } from './seckillActivity.data'
import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity' import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
import SeckillActivityForm from './SeckillActivityForm.vue' import SeckillActivityForm from './SeckillActivityForm.vue'
defineOptions({ name: 'PromotionSeckillActivity' })
// tableObject // tableObject
// tableMethods // tableMethods
// https://doc.iocoder.cn/vue3/crud-schema/ // https://doc.iocoder.cn/vue3/crud-schema/