商城:
1. 修复拼团活动,修改商品的拼团价格,会存在 *100 的问题
This commit is contained in:
parent
ff8bde207d
commit
127e6b202e
@ -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 配置
|
||||
|
@ -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'))
|
@ -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
|
||||
},
|
@ -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>
|
@ -1,4 +1,6 @@
|
||||
<template>
|
||||
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
|
||||
|
@ -1,4 +1,6 @@
|
||||
<template>
|
||||
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
|
||||
|
Loading…
Reference in New Issue
Block a user