Skip to content

Commit 78062dd

Browse files
committed
promotion:调整拼团活动的界面
1 parent cf7ac2c commit 78062dd

File tree

5 files changed

+207
-106
lines changed

5 files changed

+207
-106
lines changed

src/api/mall/promotion/bargain/bargainActivity.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ export const updateBargainActivity = async (data: BargainActivityVO) => {
5757
return await request.put({ url: '/promotion/bargain-activity/update', data })
5858
}
5959

60+
// 关闭砍价活动
61+
export const closeBargainActivity = async (id: number) => {
62+
return await request.put({ url: '/promotion/bargain-activity/close?id=' + id })
63+
}
64+
6065
// 删除砍价活动
6166
export const deleteBargainActivity = async (id: number) => {
6267
return await request.delete({ url: '/promotion/bargain-activity/delete?id=' + id })

src/api/mall/promotion/combination/combinationActivity.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export const updateCombinationActivity = async (data: CombinationActivityVO) =>
5555
return await request.put({ url: '/promotion/combination-activity/update', data })
5656
}
5757

58+
// 关闭拼团活动
59+
export const closeCombinationActivity = async (id: number) => {
60+
return await request.put({ url: '/promotion/bargain-combination/close?id=' + id })
61+
}
62+
5863
// 删除拼团活动
5964
export const deleteCombinationActivity = async (id: number) => {
6065
return await request.delete({ url: '/promotion/combination-activity/delete?id=' + id })

src/views/mall/promotion/bargain/activity/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ import * as BargainActivityApi from '@/api/mall/promotion/bargain/bargainActivit
149149
import BargainActivityForm from './BargainActivityForm.vue'
150150
import { formatDate } from '@/utils/formatTime'
151151
import { fenToYuanFormat } from '@/utils/formatter'
152-
import { fenToYuan } from '@/utils'
153152
154153
defineOptions({ name: 'PromotionBargainActivity' })
155154
@@ -203,7 +202,7 @@ const openForm = (type: string, id?: number) => {
203202
const handleClose = async (id: number) => {
204203
try {
205204
// 关闭的二次确认
206-
await message.confirm('确认关闭该秒杀活动吗')
205+
await message.confirm('确认关闭该砍价活动吗')
207206
// 发起关闭
208207
await BargainActivityApi.closeSeckillActivity(id)
209208
message.success('关闭成功')
@@ -218,7 +217,7 @@ const handleDelete = async (id: number) => {
218217
// 删除的二次确认
219218
await message.delConfirm()
220219
// 发起删除
221-
await BargainActivityApi.deleteBargainActivity(id)
220+
await BargainActivityApi.closeBargainActivity(id)
222221
message.success(t('common.delSuccess'))
223222
// 刷新列表
224223
await getList()

src/views/mall/promotion/combination/activity/combinationActivity.data.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,6 @@ const crudSchemas = reactive<CrudSchema[]>([
114114
value: 0
115115
}
116116
},
117-
{
118-
label: '购买人数',
119-
field: 'userSize',
120-
isSearch: false,
121-
isForm: false
122-
},
123-
{
124-
label: '开团组数',
125-
field: 'totalCount',
126-
isSearch: false,
127-
isForm: false
128-
},
129-
{
130-
label: '成团组数',
131-
field: 'successCount',
132-
isSearch: false,
133-
isForm: false
134-
},
135-
{
136-
label: '活动状态',
137-
field: 'status',
138-
dictType: DICT_TYPE.COMMON_STATUS,
139-
dictClass: 'number',
140-
isSearch: true,
141-
isForm: false
142-
},
143117
{
144118
label: '拼团商品',
145119
field: 'spuId',
@@ -149,11 +123,6 @@ const crudSchemas = reactive<CrudSchema[]>([
149123
span: 24
150124
}
151125
}
152-
},
153-
{
154-
label: '操作',
155-
field: 'action',
156-
isForm: false
157126
}
158127
])
159128
export const { allSchemas } = useCrudSchemas(crudSchemas)
Lines changed: 195 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,194 @@
11
<template>
2-
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
3-
4-
<!-- 搜索工作栏 -->
52
<ContentWrap>
6-
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
7-
<!-- 新增等操作按钮 -->
8-
<template #actionMore>
3+
<!-- 搜索工作栏 -->
4+
<el-form
5+
class="-mb-15px"
6+
:model="queryParams"
7+
ref="queryFormRef"
8+
:inline="true"
9+
label-width="68px"
10+
>
11+
<el-form-item label="活动名称" prop="name">
12+
<el-input
13+
v-model="queryParams.name"
14+
placeholder="请输入活动名称"
15+
clearable
16+
@keyup.enter="handleQuery"
17+
class="!w-240px"
18+
/>
19+
</el-form-item>
20+
<el-form-item label="活动状态" prop="status">
21+
<el-select
22+
v-model="queryParams.status"
23+
placeholder="请选择活动状态"
24+
clearable
25+
class="!w-240px"
26+
>
27+
<el-option
28+
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
29+
:key="dict.value"
30+
:label="dict.label"
31+
:value="dict.value"
32+
/>
33+
</el-select>
34+
</el-form-item>
35+
<el-form-item>
36+
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
37+
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
938
<el-button
10-
v-hasPermi="['promotion:combination-activity:create']"
11-
plain
1239
type="primary"
40+
plain
1341
@click="openForm('create')"
42+
v-hasPermi="['promotion:combination-activity:create']"
1443
>
15-
<Icon class="mr-5px" icon="ep:plus" /> 新增
44+
<Icon icon="ep:plus" class="mr-5px" /> 新增
1645
</el-button>
17-
</template>
18-
</Search>
46+
</el-form-item>
47+
</el-form>
1948
</ContentWrap>
2049

2150
<!-- 列表 -->
2251
<ContentWrap>
23-
<Table
24-
v-model:currentPage="tableObject.currentPage"
25-
v-model:pageSize="tableObject.pageSize"
26-
:columns="allSchemas.tableColumns"
27-
:data="tableObject.tableList"
28-
:loading="tableObject.loading"
29-
:pagination="{
30-
total: tableObject.total
31-
}"
32-
>
33-
<template #spuId="{ row }">
34-
<el-image
35-
:src="row.picUrl"
36-
class="mr-5px h-30px w-30px align-middle"
37-
@click="imagePreview(row.picUrl)"
38-
/>
39-
<span class="align-middle">{{ row.spuName }}</span>
40-
</template>
41-
<template #action="{ row }">
42-
<el-button
43-
v-hasPermi="['promotion:combination-activity:update']"
44-
link
45-
type="primary"
46-
@click="openForm('update', row.id)"
47-
>
48-
编辑
49-
</el-button>
50-
<el-button
51-
v-hasPermi="['promotion:combination-activity:delete']"
52-
link
53-
type="danger"
54-
@click="handleDelete(row.id)"
55-
>
56-
删除
57-
</el-button>
58-
</template>
59-
</Table>
52+
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
53+
<el-table-column label="活动编号" prop="id" min-width="80" />
54+
<el-table-column label="活动名称" prop="name" min-width="140" />
55+
<el-table-column label="活动时间" min-width="210">
56+
<template #default="scope">
57+
{{ formatDate(scope.row.startTime, 'YYYY-MM-DD') }}
58+
~ {{ formatDate(scope.row.endTime, 'YYYY-MM-DD') }}
59+
</template>
60+
</el-table-column>
61+
<el-table-column label="商品图片" prop="spuName" min-width="80">
62+
<template #default="scope">
63+
<el-image
64+
:src="scope.row.picUrl"
65+
class="h-40px w-40px"
66+
:preview-src-list="[scope.row.picUrl]"
67+
preview-teleported
68+
/>
69+
</template>
70+
</el-table-column>
71+
<el-table-column label="商品标题" prop="spuName" min-width="300" />
72+
<el-table-column
73+
label="原价"
74+
prop="combinationFirstPrice"
75+
min-width="100"
76+
:formatter="fenToYuanFormat"
77+
/>
78+
<el-table-column
79+
label="拼团价"
80+
prop="combinationMinPrice"
81+
min-width="100"
82+
:formatter="fenToYuanFormat"
83+
/>
84+
<el-table-column label="拼团人数" prop="recordUserCount" min-width="100" />
85+
<el-table-column label="参与人数" prop="recordSuccessUserCount" min-width="110" />
86+
<el-table-column label="成团人数" prop="helpUserCount" min-width="100" />
87+
<el-table-column label="活动状态" align="center" prop="status" min-width="100">
88+
<template #default="scope">
89+
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
90+
</template>
91+
</el-table-column>
92+
<el-table-column label="库存" align="center" prop="stock" min-width="80" />
93+
<el-table-column label="总库存" align="center" prop="totalStock" min-width="80" />
94+
<el-table-column
95+
label="创建时间"
96+
align="center"
97+
prop="createTime"
98+
:formatter="dateFormatter"
99+
width="180px"
100+
/>
101+
<el-table-column label="操作" align="center" width="150px" fixed="right">
102+
<template #default="scope">
103+
<el-button
104+
link
105+
type="primary"
106+
@click="openForm('update', scope.row.id)"
107+
v-hasPermi="['promotion:combination-activity:update']"
108+
>
109+
编辑
110+
</el-button>
111+
<el-button
112+
link
113+
type="danger"
114+
@click="handleClose(scope.row.id)"
115+
v-if="scope.row.status === 0"
116+
v-hasPermi="['promotion:combination-activity:close']"
117+
>
118+
关闭
119+
</el-button>
120+
<el-button
121+
link
122+
type="danger"
123+
@click="handleDelete(scope.row.id)"
124+
v-else
125+
v-hasPermi="['promotion:combination-activity:delete']"
126+
>
127+
删除
128+
</el-button>
129+
</template>
130+
</el-table-column>
131+
</el-table>
132+
<!-- 分页 -->
133+
<Pagination
134+
:total="total"
135+
v-model:page="queryParams.pageNo"
136+
v-model:limit="queryParams.pageSize"
137+
@pagination="getList"
138+
/>
60139
</ContentWrap>
61140

62141
<!-- 表单弹窗:添加/修改 -->
63142
<CombinationActivityForm ref="formRef" @success="getList" />
64143
</template>
65-
<script lang="ts" setup>
66-
import { allSchemas } from './combinationActivity.data'
144+
145+
<script setup lang="ts">
146+
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
147+
import { dateFormatter } from '@/utils/formatTime'
67148
import * as CombinationActivityApi from '@/api/mall/promotion/combination/combinationActivity'
68149
import CombinationActivityForm from './CombinationActivityForm.vue'
69-
import { sortTableColumns } from '@/hooks/web/useCrudSchemas'
70-
import { createImageViewer } from '@/components/ImageViewer'
150+
import { formatDate } from '@/utils/formatTime'
151+
import { fenToYuanFormat } from '@/utils/formatter'
71152
72-
defineOptions({ name: 'PromotionCombinationActivity' })
153+
defineOptions({ name: 'PromotionBargainActivity' })
73154
74-
// tableObject:表格的属性对象,可获得分页大小、条数等属性
75-
// tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
76-
// 详细可见:https://doc.iocoder.cn/vue3/crud-schema/
77-
const { tableObject, tableMethods } = useTable({
78-
getListApi: CombinationActivityApi.getCombinationActivityPage, // 分页接口
79-
delListApi: CombinationActivityApi.deleteCombinationActivity // 删除接口
155+
const message = useMessage() // 消息弹窗
156+
const { t } = useI18n() // 国际化
157+
158+
const loading = ref(true) // 列表的加载中
159+
const total = ref(0) // 列表的总页数
160+
const list = ref([]) // 列表的数据
161+
const queryParams = reactive({
162+
pageNo: 1,
163+
pageSize: 10,
164+
name: null,
165+
status: null
80166
})
81-
// 获得表格的各种操作
82-
const { getList, setSearchParams } = tableMethods
167+
const queryFormRef = ref() // 搜索的表单
168+
const exportLoading = ref(false) // 导出的加载中
83169
84-
/** 商品图预览 */
85-
const imagePreview = (imgUrl: string) => {
86-
createImageViewer({
87-
urlList: [imgUrl]
88-
})
170+
/** 查询列表 */
171+
const getList = async () => {
172+
loading.value = true
173+
try {
174+
const data = await CombinationActivityApi.getCombinationActivityPage(queryParams)
175+
list.value = data.list
176+
total.value = data.total
177+
} finally {
178+
loading.value = false
179+
}
180+
}
181+
182+
/** 搜索按钮操作 */
183+
const handleQuery = () => {
184+
queryParams.pageNo = 1
185+
getList()
186+
}
187+
188+
/** 重置按钮操作 */
189+
const resetQuery = () => {
190+
queryFormRef.value.resetFields()
191+
handleQuery()
89192
}
90193
91194
/** 添加/修改操作 */
@@ -94,15 +197,35 @@ const openForm = (type: string, id?: number) => {
94197
formRef.value.open(type, id)
95198
}
96199
200+
// TODO 芋艿:这里要改下
201+
/** 关闭按钮操作 */
202+
const handleClose = async (id: number) => {
203+
try {
204+
// 关闭的二次确认
205+
await message.confirm('确认关闭该秒杀活动吗?')
206+
// 发起关闭
207+
await CombinationActivityApi.closeCombinationActivity(id)
208+
message.success('关闭成功')
209+
// 刷新列表
210+
await getList()
211+
} catch {}
212+
}
213+
97214
/** 删除按钮操作 */
98-
const handleDelete = (id: number) => {
99-
tableMethods.delList(id, false)
215+
const handleDelete = async (id: number) => {
216+
try {
217+
// 删除的二次确认
218+
await message.delConfirm()
219+
// 发起删除
220+
await CombinationActivityApi.deleteCombinationActivity(id)
221+
message.success(t('common.delSuccess'))
222+
// 刷新列表
223+
await getList()
224+
} catch {}
100225
}
101226
102227
/** 初始化 **/
103-
onMounted(() => {
104-
// 获得活动列表
105-
sortTableColumns(allSchemas.tableColumns, 'spuId')
106-
getList()
228+
onMounted(async () => {
229+
await getList()
107230
})
108231
</script>

0 commit comments

Comments
 (0)