1
1
<template >
2
- <!-- 搜索工作栏 -->
3
2
<ContentWrap >
4
- <Search :schema =" allSchemas.searchSchema" @reset =" setSearchParams" @search =" setSearchParams" >
5
- <!-- 新增等操作按钮 -->
6
- <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 >
7
38
<el-button
8
- v-hasPermi =" ['promotion:bargain-activity:create']"
9
- plain
10
39
type =" primary"
40
+ plain
11
41
@click =" openForm('create')"
42
+ v-hasPermi =" ['promotion:bargain-activity:create']"
12
43
>
13
- <Icon class =" mr-5px" icon =" ep:plus" />
14
- 新增
44
+ <Icon icon =" ep:plus" class =" mr-5px" /> 新增
15
45
</el-button >
16
- </template >
17
- </Search >
46
+ </el-form-item >
47
+ </el-form >
18
48
</ContentWrap >
19
49
20
50
<!-- 列表 -->
21
51
<ContentWrap >
22
- <Table
23
- v-model:currentPage =" tableObject.currentPage"
24
- v-model:pageSize =" tableObject.pageSize"
25
- :columns =" allSchemas.tableColumns"
26
- :data =" tableObject.tableList"
27
- :loading =" tableObject.loading"
28
- :pagination =" {
29
- total: tableObject.total
30
- }"
31
- >
32
- <template #spuId =" { row } " >
33
- <el-image
34
- :src =" row.picUrl"
35
- class =" mr-5px h-30px w-30px align-middle"
36
- @click =" imagePreview(row.picUrl)"
37
- />
38
- <span class =" align-middle" >{{ row.spuName }}</span >
39
- </template >
40
- <template #action =" { row } " >
41
- <el-button
42
- v-hasPermi =" ['promotion:bargain-activity:update']"
43
- link
44
- type =" primary"
45
- @click =" openForm('update', row.id)"
46
- >
47
- 编辑
48
- </el-button >
49
- <el-button
50
- v-hasPermi =" ['promotion:bargain-activity:delete']"
51
- link
52
- type =" danger"
53
- @click =" handleDelete(row.id)"
54
- >
55
- 删除
56
- </el-button >
57
- </template >
58
- </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 =" bargainFirstPrice"
75
+ min-width =" 100"
76
+ :formatter =" fenToYuanFormat"
77
+ />
78
+ <el-table-column
79
+ label =" 砍价底价"
80
+ prop =" bargainMinPrice"
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:bargain-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:bargain-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:bargain-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
+ />
59
139
</ContentWrap >
60
140
61
141
<!-- 表单弹窗:添加/修改 -->
62
142
<BargainActivityForm ref =" formRef" @success =" getList" />
63
143
</template >
64
- <script lang="ts" setup>
65
- import { allSchemas } from ' ./bargainActivity.data'
144
+
145
+ <script setup lang="ts">
146
+ import { DICT_TYPE , getIntDictOptions } from ' @/utils/dict'
147
+ import { dateFormatter } from ' @/utils/formatTime'
66
148
import * as BargainActivityApi from ' @/api/mall/promotion/bargain/bargainActivity'
67
149
import BargainActivityForm from ' ./BargainActivityForm.vue'
68
- import { createImageViewer } from ' @/components/ImageViewer'
69
- import { sortTableColumns } from ' @/hooks/web/useCrudSchemas'
150
+ import { formatDate } from ' @/utils/formatTime'
151
+ import { fenToYuanFormat } from ' @/utils/formatter'
152
+ import { fenToYuan } from ' @/utils'
70
153
71
154
defineOptions ({ name: ' PromotionBargainActivity' })
72
155
73
- // tableObject:表格的属性对象,可获得分页大小、条数等属性
74
- // tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
75
- // 详细可见:https://doc.iocoder.cn/vue3/crud-schema/
76
- const { tableObject, tableMethods } = useTable ({
77
- getListApi: BargainActivityApi .getBargainActivityPage , // 分页接口
78
- delListApi: BargainActivityApi .deleteBargainActivity // 删除接口
156
+ const message = useMessage () // 消息弹窗
157
+ const { t } = useI18n () // 国际化
158
+
159
+ const loading = ref (true ) // 列表的加载中
160
+ const total = ref (0 ) // 列表的总页数
161
+ const list = ref ([]) // 列表的数据
162
+ const queryParams = reactive ({
163
+ pageNo: 1 ,
164
+ pageSize: 10 ,
165
+ name: null ,
166
+ status: null
79
167
})
80
- // 获得表格的各种操作
81
- const { getList, setSearchParams } = tableMethods
168
+ const queryFormRef = ref () // 搜索的表单
169
+ const exportLoading = ref ( false ) // 导出的加载中
82
170
83
- /** 商品图预览 */
84
- const imagePreview = (imgUrl : string ) => {
85
- createImageViewer ({
86
- urlList: [imgUrl ]
87
- })
171
+ /** 查询列表 */
172
+ const getList = async () => {
173
+ loading .value = true
174
+ try {
175
+ const data = await BargainActivityApi .getBargainActivityPage (queryParams )
176
+ list .value = data .list
177
+ total .value = data .total
178
+ } finally {
179
+ loading .value = false
180
+ }
181
+ }
182
+
183
+ /** 搜索按钮操作 */
184
+ const handleQuery = () => {
185
+ queryParams .pageNo = 1
186
+ getList ()
187
+ }
188
+
189
+ /** 重置按钮操作 */
190
+ const resetQuery = () => {
191
+ queryFormRef .value .resetFields ()
192
+ handleQuery ()
88
193
}
89
194
90
195
/** 添加/修改操作 */
@@ -93,15 +198,35 @@ const openForm = (type: string, id?: number) => {
93
198
formRef .value .open (type , id )
94
199
}
95
200
201
+ // TODO 芋艿:这里要改下
202
+ /** 关闭按钮操作 */
203
+ const handleClose = async (id : number ) => {
204
+ try {
205
+ // 关闭的二次确认
206
+ await message .confirm (' 确认关闭该秒杀活动吗?' )
207
+ // 发起关闭
208
+ await BargainActivityApi .closeSeckillActivity (id )
209
+ message .success (' 关闭成功' )
210
+ // 刷新列表
211
+ await getList ()
212
+ } catch {}
213
+ }
214
+
96
215
/** 删除按钮操作 */
97
- const handleDelete = (id : number ) => {
98
- tableMethods .delList (id , false )
216
+ const handleDelete = async (id : number ) => {
217
+ try {
218
+ // 删除的二次确认
219
+ await message .delConfirm ()
220
+ // 发起删除
221
+ await BargainActivityApi .deleteBargainActivity (id )
222
+ message .success (t (' common.delSuccess' ))
223
+ // 刷新列表
224
+ await getList ()
225
+ } catch {}
99
226
}
100
227
101
228
/** 初始化 **/
102
- onMounted (() => {
103
- // 获得活动列表
104
- sortTableColumns (allSchemas .tableColumns , ' spuId' )
105
- getList ()
229
+ onMounted (async () => {
230
+ await getList ()
106
231
})
107
232
</script >
0 commit comments