商城:

1. 修复拼团活动,修改商品的拼团价格,会存在 *100 的问题

(cherry picked from commit 127e6b202e)
This commit is contained in:
YunaiV 2023-08-13 00:07:04 +08:00 committed by shizhong
parent ffc797ae31
commit 81d8e36ccc
7 changed files with 27 additions and 30 deletions

View File

@ -10,8 +10,8 @@ export interface CombinationActivityVO {
startTime?: Date
endTime?: Date
userSize?: number
totalNum?: number
successNum?: number
totalCount?: number
successCount?: number
orderUserCount?: number
virtualGroup?: number
status?: number
@ -23,7 +23,7 @@ export interface CombinationActivityVO {
export interface CombinationProductVO {
spuId: number
skuId: number
activePrice: number // 拼团价格
combinationPrice: number // 拼团价格
}
// 扩展 Sku 配置

View File

@ -19,7 +19,7 @@
<el-table-column align="center" label="拼团价格(元)" min-width="168">
<template #default="{ row: sku }">
<el-input-number
v-model="sku.productConfig.activePrice"
v-model="sku.productConfig.combinationPrice"
:min="0"
:precision="2"
:step="0.1"
@ -45,6 +45,7 @@ import { SpuAndSkuList, SpuProperty, SpuSelect } from '@/views/mall/promotion/co
import { getPropertyList, RuleConfig } from '@/views/mall/product/spu/components'
import * as ProductSpuApi from '@/api/mall/product/spu'
import { convertToInteger, formatToFraction } from '@/utils'
import { cloneDeep } from 'lodash-es'
defineOptions({ name: 'PromotionCombinationActivityForm' })
@ -65,8 +66,8 @@ const spuList = ref<CombinationActivityApi.SpuExtension[]>([]) // 选择的 spu
const spuPropertyList = ref<SpuProperty<CombinationActivityApi.SpuExtension>[]>([])
const ruleConfig: RuleConfig[] = [
{
name: 'productConfig.activePrice',
rule: (arg) => arg > 0.01,
name: 'productConfig.combinationPrice',
rule: (arg) => arg >= 0.01,
message: '商品拼团价格不能小于0.01 '
}
]
@ -98,13 +99,12 @@ const getSpuDetails = async (
let config: CombinationProductVO = {
spuId: spu.id!,
skuId: sku.id!,
activePrice: 0
combinationPrice: 0
}
if (typeof products !== 'undefined') {
const product = products.find((item) => item.skuId === sku.id)
if (product) {
//
product.activePrice = formatToFraction(product.activePrice)
product.combinationPrice = formatToFraction(product.combinationPrice)
}
config = product || config
}
@ -162,13 +162,14 @@ const submitForm = async () => {
//
formLoading.value = true
try {
const data = formRef.value.formModel as CombinationActivityApi.CombinationActivityVO
const products = spuAndSkuListRef.value.getSkuConfigs('productConfig')
products.forEach((item: CombinationProductVO) => {
//
item.activePrice = convertToInteger(item.activePrice)
//
const products = cloneDeep(spuAndSkuListRef.value.getSkuConfigs('productConfig'))
products.forEach((item: CombinationActivityApi.CombinationProductVO) => {
item.combinationPrice = convertToInteger(item.combinationPrice)
})
const data = formRef.value.formModel as CombinationActivityApi.CombinationActivityVO
data.products = products
//
if (formType.value === 'create') {
await CombinationActivityApi.createCombinationActivity(data)
message.success(t('common.createSuccess'))

View File

@ -122,13 +122,13 @@ const crudSchemas = reactive<CrudSchema[]>([
},
{
label: '开团组数',
field: 'totalNum',
field: 'totalCount',
isSearch: false,
isForm: false
},
{
label: '成团组数',
field: 'successNum',
field: 'successCount',
isSearch: false,
isForm: false
},

View File

@ -1,4 +1,6 @@
<template>
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
<!-- 搜索工作栏 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
@ -10,8 +12,7 @@
type="primary"
@click="openForm('create')"
>
<Icon class="mr-5px" icon="ep:plus" />
新增
<Icon class="mr-5px" icon="ep:plus" /> 新增
</el-button>
</template>
</Search>
@ -65,7 +66,7 @@
import { allSchemas } from './combinationActivity.data'
import * as CombinationActivityApi from '@/api/mall/promotion/combination/combinationActivity'
import CombinationActivityForm from './CombinationActivityForm.vue'
import { cloneDeep } from 'lodash-es'
import { sortTableColumns } from '@/hooks/web/useCrudSchemas'
import { createImageViewer } from '@/components/ImageViewer'
defineOptions({ name: 'PromotionCombinationActivity' })
@ -100,17 +101,8 @@ const handleDelete = (id: number) => {
/** 初始化 **/
onMounted(() => {
/**
TODO
后面准备封装成一个函数来操作 tableColumns 重新排列比如说需求是表单上商品选择是在后面的而列表展示的时候需要调到位置
封装效果支持批量操作给出 field 和需要插入的位置[{field:'spuId',index: 1}] 效果为把 field spuId column 移动到第一个位置
*/
//
const index = allSchemas.tableColumns.findIndex((item) => item.field === 'spuId')
const column = cloneDeep(allSchemas.tableColumns[index])
allSchemas.tableColumns.splice(index, 1)
//
allSchemas.tableColumns.unshift(column)
//
sortTableColumns(allSchemas.tableColumns, 'spuId')
getList()
})
</script>

View File

@ -1,4 +1,6 @@
<template>
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
<!-- 搜索工作栏 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">

View File

@ -1,4 +1,6 @@
<template>
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
<!-- 搜索工作栏 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">