Skip to content

Commit 4fcc33e

Browse files
author
puhui999
committed
【代码优化】商城: 满减活动增加关闭操作
1 parent cb34733 commit 4fcc33e

File tree

3 files changed

+75
-44
lines changed

3 files changed

+75
-44
lines changed

src/api/mall/promotion/reward/rewardActivity.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export const getReward = async (id: number) => {
4747
return await request.get({ url: '/promotion/reward-activity/get?id=' + id })
4848
}
4949

50+
// 关闭拼团活动
51+
export const closeRewardActivity = async (id: number) => {
52+
return await request.put({ url: '/promotion/reward-activity/close?id=' + id })
53+
}
54+
5055
// 删除限时折扣活动
5156
export const deleteRewardActivity = async (id: number) => {
5257
return await request.delete({ url: '/promotion/reward-activity/delete?id=' + id })

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

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
<ContentWrap>
55
<!-- 搜索工作栏 -->
66
<el-form
7-
class="-mb-15px"
8-
:model="queryParams"
97
ref="queryFormRef"
108
:inline="true"
9+
:model="queryParams"
10+
class="-mb-15px"
1111
label-width="68px"
1212
>
1313
<el-form-item label="活动名称" prop="name">
1414
<el-input
1515
v-model="queryParams.name"
16-
placeholder="请输入活动名称"
16+
class="!w-240px"
1717
clearable
18+
placeholder="请输入活动名称"
1819
@keyup.enter="handleQuery"
19-
class="!w-240px"
2020
/>
2121
</el-form-item>
2222
<el-form-item label="活动状态" prop="status">
2323
<el-select
2424
v-model="queryParams.status"
25-
placeholder="请选择活动状态"
26-
clearable
2725
class="!w-240px"
26+
clearable
27+
placeholder="请选择活动状态"
2828
>
2929
<el-option
3030
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
@@ -35,93 +35,100 @@
3535
</el-select>
3636
</el-form-item>
3737
<el-form-item>
38-
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
39-
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
38+
<el-button @click="handleQuery">
39+
<Icon class="mr-5px" icon="ep:search" />
40+
搜索
41+
</el-button>
42+
<el-button @click="resetQuery">
43+
<Icon class="mr-5px" icon="ep:refresh" />
44+
重置
45+
</el-button>
4046
<el-button
41-
type="primary"
47+
v-hasPermi="['promotion:combination-activity:create']"
4248
plain
49+
type="primary"
4350
@click="openForm('create')"
44-
v-hasPermi="['promotion:combination-activity:create']"
4551
>
46-
<Icon icon="ep:plus" class="mr-5px" /> 新增
52+
<Icon class="mr-5px" icon="ep:plus" />
53+
新增
4754
</el-button>
4855
</el-form-item>
4956
</el-form>
5057
</ContentWrap>
5158

5259
<!-- 列表 -->
5360
<ContentWrap>
54-
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
55-
<el-table-column label="活动编号" prop="id" min-width="80" />
56-
<el-table-column label="活动名称" prop="name" min-width="140" />
61+
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
62+
<el-table-column label="活动编号" min-width="80" prop="id" />
63+
<el-table-column label="活动名称" min-width="140" prop="name" />
5764
<el-table-column label="活动时间" min-width="210">
5865
<template #default="scope">
5966
{{ formatDate(scope.row.startTime, 'YYYY-MM-DD') }}
6067
~ {{ formatDate(scope.row.endTime, 'YYYY-MM-DD') }}
6168
</template>
6269
</el-table-column>
63-
<el-table-column label="商品图片" prop="spuName" min-width="80">
70+
<el-table-column label="商品图片" min-width="80" prop="spuName">
6471
<template #default="scope">
6572
<el-image
73+
:preview-src-list="[scope.row.picUrl]"
6674
:src="scope.row.picUrl"
6775
class="h-40px w-40px"
68-
:preview-src-list="[scope.row.picUrl]"
6976
preview-teleported
7077
/>
7178
</template>
7279
</el-table-column>
73-
<el-table-column label="商品标题" prop="spuName" min-width="300" />
80+
<el-table-column label="商品标题" min-width="300" prop="spuName" />
7481
<el-table-column
82+
:formatter="fenToYuanFormat"
7583
label="原价"
76-
prop="marketPrice"
7784
min-width="100"
78-
:formatter="fenToYuanFormat"
85+
prop="marketPrice"
7986
/>
80-
<el-table-column label="拼团价" prop="seckillPrice" min-width="100">
87+
<el-table-column label="拼团价" min-width="100" prop="seckillPrice">
8188
<template #default="scope">
8289
{{ formatCombinationPrice(scope.row.products) }}
8390
</template>
8491
</el-table-column>
85-
<el-table-column label="开团组数" prop="groupCount" min-width="100" />
86-
<el-table-column label="成团组数" prop="groupSuccessCount" min-width="100" />
87-
<el-table-column label="购买次数" prop="recordCount" min-width="100" />
88-
<el-table-column label="活动状态" align="center" prop="status" min-width="100">
92+
<el-table-column label="开团组数" min-width="100" prop="groupCount" />
93+
<el-table-column label="成团组数" min-width="100" prop="groupSuccessCount" />
94+
<el-table-column label="购买次数" min-width="100" prop="recordCount" />
95+
<el-table-column align="center" label="活动状态" min-width="100" prop="status">
8996
<template #default="scope">
9097
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
9198
</template>
9299
</el-table-column>
93100
<el-table-column
94-
label="创建时间"
101+
:formatter="dateFormatter"
95102
align="center"
103+
label="创建时间"
96104
prop="createTime"
97-
:formatter="dateFormatter"
98105
width="180px"
99106
/>
100-
<el-table-column label="操作" align="center" width="150px" fixed="right">
107+
<el-table-column align="center" fixed="right" label="操作" width="150px">
101108
<template #default="scope">
102109
<el-button
110+
v-hasPermi="['promotion:combination-activity:update']"
103111
link
104112
type="primary"
105113
@click="openForm('update', scope.row.id)"
106-
v-hasPermi="['promotion:combination-activity:update']"
107114
>
108115
编辑
109116
</el-button>
110117
<el-button
118+
v-if="scope.row.status === 0"
119+
v-hasPermi="['promotion:combination-activity:close']"
111120
link
112121
type="danger"
113122
@click="handleClose(scope.row.id)"
114-
v-if="scope.row.status === 0"
115-
v-hasPermi="['promotion:combination-activity:close']"
116123
>
117124
关闭
118125
</el-button>
119126
<el-button
127+
v-else
128+
v-hasPermi="['promotion:combination-activity:delete']"
120129
link
121130
type="danger"
122131
@click="handleDelete(scope.row.id)"
123-
v-else
124-
v-hasPermi="['promotion:combination-activity:delete']"
125132
>
126133
删除
127134
</el-button>
@@ -130,9 +137,9 @@
130137
</el-table>
131138
<!-- 分页 -->
132139
<Pagination
133-
:total="total"
134-
v-model:page="queryParams.pageNo"
135140
v-model:limit="queryParams.pageSize"
141+
v-model:page="queryParams.pageNo"
142+
:total="total"
136143
@pagination="getList"
137144
/>
138145
</ContentWrap>
@@ -141,12 +148,11 @@
141148
<CombinationActivityForm ref="formRef" @success="getList" />
142149
</template>
143150

144-
<script setup lang="ts">
151+
<script lang="ts" setup>
145152
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
146-
import { dateFormatter } from '@/utils/formatTime'
153+
import { dateFormatter, formatDate } from '@/utils/formatTime'
147154
import * as CombinationActivityApi from '@/api/mall/promotion/combination/combinationActivity'
148155
import CombinationActivityForm from './CombinationActivityForm.vue'
149-
import { formatDate } from '@/utils/formatTime'
150156
import { fenToYuanFormat } from '@/utils/formatter'
151157
import { fenToYuan } from '@/utils'
152158
@@ -165,7 +171,6 @@ const queryParams = reactive({
165171
status: null
166172
})
167173
const queryFormRef = ref() // 搜索的表单
168-
const exportLoading = ref(false) // 导出的加载中
169174
170175
/** 查询列表 */
171176
const getList = async () => {
@@ -197,12 +202,11 @@ const openForm = (type: string, id?: number) => {
197202
formRef.value.open(type, id)
198203
}
199204
200-
// TODO 芋艿:这里要改下
201205
/** 关闭按钮操作 */
202206
const handleClose = async (id: number) => {
203207
try {
204208
// 关闭的二次确认
205-
await message.confirm('确认关闭该秒杀活动吗')
209+
await message.confirm('确认关闭该拼团活动吗')
206210
// 发起关闭
207211
await CombinationActivityApi.closeCombinationActivity(id)
208212
message.success('关闭成功')

src/views/mall/promotion/rewardActivity/index.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
重置
5656
</el-button>
5757
<el-button
58-
v-hasPermi="['product:brand:create']"
58+
v-hasPermi="['promotion:reward-activity:create']"
5959
plain
6060
type="primary"
6161
@click="openForm('create')"
@@ -85,7 +85,7 @@
8585
/>
8686
<el-table-column align="center" label="状态" prop="status">
8787
<template #default="scope">
88-
<dict-tag :type="DICT_TYPE.PROMOTION_ACTIVITY_STATUS" :value="scope.row.status" />
88+
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
8989
</template>
9090
</el-table-column>
9191
<el-table-column
@@ -98,15 +98,24 @@
9898
<el-table-column align="center" label="操作">
9999
<template #default="scope">
100100
<el-button
101-
v-hasPermi="['product:brand:update']"
101+
v-hasPermi="['promotion:reward-activity:update']"
102102
link
103103
type="primary"
104104
@click="openForm('update', scope.row.id)"
105105
>
106106
编辑
107107
</el-button>
108108
<el-button
109-
v-hasPermi="['product:brand:delete']"
109+
v-if="scope.row.status === 0"
110+
v-hasPermi="['promotion:reward-activity:close']"
111+
link
112+
type="danger"
113+
@click="handleClose(scope.row.id)"
114+
>
115+
关闭
116+
</el-button>
117+
<el-button
118+
v-hasPermi="['promotion:reward-activity:delete']"
110119
link
111120
type="danger"
112121
@click="handleDelete(scope.row.id)"
@@ -180,6 +189,19 @@ const openForm = (type: string, id?: number) => {
180189
formRef.value?.open(type, id)
181190
}
182191
192+
/** 关闭按钮操作 */
193+
const handleClose = async (id: number) => {
194+
try {
195+
// 关闭的二次确认
196+
await message.confirm('确认关闭该满减活动吗?')
197+
// 发起关闭
198+
await RewardActivityApi.closeRewardActivity(id)
199+
message.success('关闭成功')
200+
// 刷新列表
201+
await getList()
202+
} catch {}
203+
}
204+
183205
/** 删除按钮操作 */
184206
const handleDelete = async (id: number) => {
185207
try {

0 commit comments

Comments
 (0)