parent
							
								
									ffc797ae31
								
							
						
					
					
						commit
						81d8e36ccc
					
				|  | @ -10,8 +10,8 @@ export interface CombinationActivityVO { | ||||||
|   startTime?: Date |   startTime?: Date | ||||||
|   endTime?: Date |   endTime?: Date | ||||||
|   userSize?: number |   userSize?: number | ||||||
|   totalNum?: number |   totalCount?: number | ||||||
|   successNum?: number |   successCount?: number | ||||||
|   orderUserCount?: number |   orderUserCount?: number | ||||||
|   virtualGroup?: number |   virtualGroup?: number | ||||||
|   status?: number |   status?: number | ||||||
|  | @ -23,7 +23,7 @@ export interface CombinationActivityVO { | ||||||
| export interface CombinationProductVO { | export interface CombinationProductVO { | ||||||
|   spuId: number |   spuId: number | ||||||
|   skuId: number |   skuId: number | ||||||
|   activePrice: number // 拼团价格
 |   combinationPrice: number // 拼团价格
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // 扩展 Sku 配置
 | // 扩展 Sku 配置
 | ||||||
|  |  | ||||||
|  | @ -19,7 +19,7 @@ | ||||||
|           <el-table-column align="center" label="拼团价格(元)" min-width="168"> |           <el-table-column align="center" label="拼团价格(元)" min-width="168"> | ||||||
|             <template #default="{ row: sku }"> |             <template #default="{ row: sku }"> | ||||||
|               <el-input-number |               <el-input-number | ||||||
|                 v-model="sku.productConfig.activePrice" |                 v-model="sku.productConfig.combinationPrice" | ||||||
|                 :min="0" |                 :min="0" | ||||||
|                 :precision="2" |                 :precision="2" | ||||||
|                 :step="0.1" |                 :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 { getPropertyList, RuleConfig } from '@/views/mall/product/spu/components' | ||||||
| import * as ProductSpuApi from '@/api/mall/product/spu' | import * as ProductSpuApi from '@/api/mall/product/spu' | ||||||
| import { convertToInteger, formatToFraction } from '@/utils' | import { convertToInteger, formatToFraction } from '@/utils' | ||||||
|  | import { cloneDeep } from 'lodash-es' | ||||||
| 
 | 
 | ||||||
| defineOptions({ name: 'PromotionCombinationActivityForm' }) | defineOptions({ name: 'PromotionCombinationActivityForm' }) | ||||||
| 
 | 
 | ||||||
|  | @ -65,8 +66,8 @@ const spuList = ref<CombinationActivityApi.SpuExtension[]>([]) // 选择的 spu | ||||||
| const spuPropertyList = ref<SpuProperty<CombinationActivityApi.SpuExtension>[]>([]) | const spuPropertyList = ref<SpuProperty<CombinationActivityApi.SpuExtension>[]>([]) | ||||||
| const ruleConfig: RuleConfig[] = [ | const ruleConfig: RuleConfig[] = [ | ||||||
|   { |   { | ||||||
|     name: 'productConfig.activePrice', |     name: 'productConfig.combinationPrice', | ||||||
|     rule: (arg) => arg > 0.01, |     rule: (arg) => arg >= 0.01, | ||||||
|     message: '商品拼团价格不能小于0.01 !!!' |     message: '商品拼团价格不能小于0.01 !!!' | ||||||
|   } |   } | ||||||
| ] | ] | ||||||
|  | @ -98,13 +99,12 @@ const getSpuDetails = async ( | ||||||
|     let config: CombinationProductVO = { |     let config: CombinationProductVO = { | ||||||
|       spuId: spu.id!, |       spuId: spu.id!, | ||||||
|       skuId: sku.id!, |       skuId: sku.id!, | ||||||
|       activePrice: 0 |       combinationPrice: 0 | ||||||
|     } |     } | ||||||
|     if (typeof products !== 'undefined') { |     if (typeof products !== 'undefined') { | ||||||
|       const product = products.find((item) => item.skuId === sku.id) |       const product = products.find((item) => item.skuId === sku.id) | ||||||
|       if (product) { |       if (product) { | ||||||
|         // 分转元 |         product.combinationPrice = formatToFraction(product.combinationPrice) | ||||||
|         product.activePrice = formatToFraction(product.activePrice) |  | ||||||
|       } |       } | ||||||
|       config = product || config |       config = product || config | ||||||
|     } |     } | ||||||
|  | @ -162,13 +162,14 @@ const submitForm = async () => { | ||||||
|   // 提交请求 |   // 提交请求 | ||||||
|   formLoading.value = true |   formLoading.value = true | ||||||
|   try { |   try { | ||||||
|     const data = formRef.value.formModel as CombinationActivityApi.CombinationActivityVO |     // 获得拼团商品配置 | ||||||
|     const products = spuAndSkuListRef.value.getSkuConfigs('productConfig') |     const products = cloneDeep(spuAndSkuListRef.value.getSkuConfigs('productConfig')) | ||||||
|     products.forEach((item: CombinationProductVO) => { |     products.forEach((item: CombinationActivityApi.CombinationProductVO) => { | ||||||
|       // 拼团价格元转分 |       item.combinationPrice = convertToInteger(item.combinationPrice) | ||||||
|       item.activePrice = convertToInteger(item.activePrice) |  | ||||||
|     }) |     }) | ||||||
|  |     const data = formRef.value.formModel as CombinationActivityApi.CombinationActivityVO | ||||||
|     data.products = products |     data.products = products | ||||||
|  |     // 真正提交 | ||||||
|     if (formType.value === 'create') { |     if (formType.value === 'create') { | ||||||
|       await CombinationActivityApi.createCombinationActivity(data) |       await CombinationActivityApi.createCombinationActivity(data) | ||||||
|       message.success(t('common.createSuccess')) |       message.success(t('common.createSuccess')) | ||||||
|  | @ -122,13 +122,13 @@ const crudSchemas = reactive<CrudSchema[]>([ | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|     label: '开团组数', |     label: '开团组数', | ||||||
|     field: 'totalNum', |     field: 'totalCount', | ||||||
|     isSearch: false, |     isSearch: false, | ||||||
|     isForm: false |     isForm: false | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|     label: '成团组数', |     label: '成团组数', | ||||||
|     field: 'successNum', |     field: 'successCount', | ||||||
|     isSearch: false, |     isSearch: false, | ||||||
|     isForm: false |     isForm: false | ||||||
|   }, |   }, | ||||||
|  | @ -1,4 +1,6 @@ | ||||||
| <template> | <template> | ||||||
|  |   <doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" /> | ||||||
|  | 
 | ||||||
|   <!-- 搜索工作栏 --> |   <!-- 搜索工作栏 --> | ||||||
|   <ContentWrap> |   <ContentWrap> | ||||||
|     <Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams"> |     <Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams"> | ||||||
|  | @ -10,8 +12,7 @@ | ||||||
|           type="primary" |           type="primary" | ||||||
|           @click="openForm('create')" |           @click="openForm('create')" | ||||||
|         > |         > | ||||||
|           <Icon class="mr-5px" icon="ep:plus" /> |           <Icon class="mr-5px" icon="ep:plus" /> 新增 | ||||||
|           新增 |  | ||||||
|         </el-button> |         </el-button> | ||||||
|       </template> |       </template> | ||||||
|     </Search> |     </Search> | ||||||
|  | @ -65,7 +66,7 @@ | ||||||
| import { allSchemas } from './combinationActivity.data' | import { allSchemas } from './combinationActivity.data' | ||||||
| import * as CombinationActivityApi from '@/api/mall/promotion/combination/combinationActivity' | import * as CombinationActivityApi from '@/api/mall/promotion/combination/combinationActivity' | ||||||
| import CombinationActivityForm from './CombinationActivityForm.vue' | import CombinationActivityForm from './CombinationActivityForm.vue' | ||||||
| import { cloneDeep } from 'lodash-es' | import { sortTableColumns } from '@/hooks/web/useCrudSchemas' | ||||||
| import { createImageViewer } from '@/components/ImageViewer' | import { createImageViewer } from '@/components/ImageViewer' | ||||||
| 
 | 
 | ||||||
| defineOptions({ name: 'PromotionCombinationActivity' }) | defineOptions({ name: 'PromotionCombinationActivity' }) | ||||||
|  | @ -100,17 +101,8 @@ const handleDelete = (id: number) => { | ||||||
| 
 | 
 | ||||||
| /** 初始化 **/ | /** 初始化 **/ | ||||||
| onMounted(() => { | onMounted(() => { | ||||||
|   /** |   // 获得活动列表 | ||||||
|    TODO |   sortTableColumns(allSchemas.tableColumns, 'spuId') | ||||||
|    后面准备封装成一个函数来操作 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) |  | ||||||
|   getList() |   getList() | ||||||
| }) | }) | ||||||
| </script> | </script> | ||||||
|  | @ -1,4 +1,6 @@ | ||||||
| <template> | <template> | ||||||
|  |   <doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" /> | ||||||
|  | 
 | ||||||
|   <!-- 搜索工作栏 --> |   <!-- 搜索工作栏 --> | ||||||
|   <ContentWrap> |   <ContentWrap> | ||||||
|     <Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams"> |     <Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams"> | ||||||
|  |  | ||||||
|  | @ -1,4 +1,6 @@ | ||||||
| <template> | <template> | ||||||
|  |   <doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" /> | ||||||
|  | 
 | ||||||
|   <!-- 搜索工作栏 --> |   <!-- 搜索工作栏 --> | ||||||
|   <ContentWrap> |   <ContentWrap> | ||||||
|     <Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams"> |     <Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams"> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 YunaiV
						YunaiV