1
1
<template >
2
- <doc-alert title =" 功能开启" url =" https://doc.iocoder.cn/mall/build/" />
3
-
4
- <!-- 搜索工作栏 -->
5
2
<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 >
9
38
<el-button
10
- v-hasPermi =" ['promotion:combination-activity:create']"
11
- plain
12
39
type =" primary"
40
+ plain
13
41
@click =" openForm('create')"
42
+ v-hasPermi =" ['promotion:combination-activity:create']"
14
43
>
15
- <Icon class = " mr-5px " icon =" ep:plus" /> 新增
44
+ <Icon icon =" ep:plus" class = " mr-5px " /> 新增
16
45
</el-button >
17
- </template >
18
- </Search >
46
+ </el-form-item >
47
+ </el-form >
19
48
</ContentWrap >
20
49
21
50
<!-- 列表 -->
22
51
<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
+ />
60
139
</ContentWrap >
61
140
62
141
<!-- 表单弹窗:添加/修改 -->
63
142
<CombinationActivityForm ref =" formRef" @success =" getList" />
64
143
</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'
67
148
import * as CombinationActivityApi from ' @/api/mall/promotion/combination/combinationActivity'
68
149
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 '
71
152
72
- defineOptions ({ name: ' PromotionCombinationActivity ' })
153
+ defineOptions ({ name: ' PromotionBargainActivity ' })
73
154
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
80
166
})
81
- // 获得表格的各种操作
82
- const { getList, setSearchParams } = tableMethods
167
+ const queryFormRef = ref () // 搜索的表单
168
+ const exportLoading = ref ( false ) // 导出的加载中
83
169
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 ()
89
192
}
90
193
91
194
/** 添加/修改操作 */
@@ -94,15 +197,35 @@ const openForm = (type: string, id?: number) => {
94
197
formRef .value .open (type , id )
95
198
}
96
199
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
+
97
214
/** 删除按钮操作 */
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 {}
100
225
}
101
226
102
227
/** 初始化 **/
103
- onMounted (() => {
104
- // 获得活动列表
105
- sortTableColumns (allSchemas .tableColumns , ' spuId' )
106
- getList ()
228
+ onMounted (async () => {
229
+ await getList ()
107
230
})
108
231
</script >
0 commit comments