18
18
<el-select v-model =" queryParams.timeId" placeholder =" 请选择参与场次" clearable size =" small" >
19
19
<el-option v-for =" item in seckillTimeList" :key =" item.id" :label =" item.name" :value =" item.id" />
20
20
</el-select >
21
- <!-- <el-option v-for="seckill in seckillTimeList" :key="seckill.id" :lable="seckill.name" :value="seckill.id" /> -->
22
- <!-- <el-input v-model="queryParams.timeId" placeholder="请输入秒杀时段id" clearable @keyup.enter.native="handleQuery" /> -->
23
21
</el-form-item >
24
22
<el-form-item label =" 创建时间" prop =" createTime" >
25
23
<el-date-picker v-model =" queryParams.createTime" style =" width : 240px " value-format =" yyyy-MM-dd HH:mm:ss"
39
37
v-hasPermi =" ['promotion:seckill-activity:create']" >新增秒杀活动</el-button >
40
38
</el-col >
41
39
<el-col :span =" 1.5" >
42
- <el-button type =" warning " plain icon =" el-icon-download " size =" mini" @click =" handleExport "
43
- :loading = " exportLoading " v-hasPermi =" ['promotion:seckill-activity:export ']" >导出 </el-button >
40
+ <el-button type =" primary " plain icon =" el-icon-menu " size =" mini" @click =" openSeckillTime "
41
+ v-hasPermi =" ['promotion:seckill-activity:create ']" >管理参与场次 </el-button >
44
42
</el-col >
45
43
<right-toolbar :showSearch.sync =" showSearch" @queryTable =" getList" ></right-toolbar >
46
44
</el-row >
70
68
71
69
<el-table-column label =" 付款订单数" align =" center" prop =" orderCount" />
72
70
<el-table-column label =" 付款人数" align =" center" prop =" userCount" />
73
- <el-table-column label =" 订单实付金额" align =" center" >
74
- <template slot-scope="scope">
75
- ¥{{ (scope.row.totalPrice / 100.0).toFixed(2) }}
76
- </template >
77
- </el-table-column >
78
71
<el-table-column label =" 创建时间" align =" center" prop =" createTime" width =" 180" >
79
72
<template slot-scope="scope">
80
73
<span >{{ parseTime(scope.row.createTime) }}</span >
84
77
<template slot-scope="scope">
85
78
<el-button size =" mini" type =" text" icon =" el-icon-edit" @click =" handleUpdate(scope.row)"
86
79
v-hasPermi =" ['promotion:seckill-activity:update']" >修改</el-button >
80
+ <el-button size =" mini" type =" text" icon =" el-icon-close" @click =" handleClose(scope.row)"
81
+ v-hasPermi =" ['promotion:seckill-activity:delete']" >关闭</el-button >
87
82
<el-button size =" mini" type =" text" icon =" el-icon-delete" @click =" handleDelete(scope.row)"
88
83
v-hasPermi =" ['promotion:seckill-activity:delete']" >删除</el-button >
89
84
</template >
99
94
<el-form-item label =" 活动名称" prop =" name" >
100
95
<el-input v-model =" form.name" placeholder =" 请输入秒杀活动名称" />
101
96
</el-form-item >
102
- <!-- <el-form-item label="活动状态" prop="status">
103
- <el-radio-group v-model="form.status">
104
- <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.PROMOTION_ACTIVITY_STATUS)"
105
- :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
106
- </el-radio-group>
107
- </el-form-item> -->
108
-
109
97
<el-form-item label =" 活动时间" prop =" startAndEndTime" >
110
98
<el-date-picker clearable v-model =" form.startAndEndTime" type =" datetimerange"
111
99
value-format =" timestamp" range-separator =" 至" start-placeholder =" 开始日期" end-placeholder =" 结束日期"
112
100
style =" width : 1080px " />
113
101
</el-form-item >
114
- <!--
115
- <el-form-item label="活动结束时间" prop="endTime">
116
- <el-date-picker clearable v-model="form.endTime" type="date" value-format="timestamp" placeholder="选择活动结束时间" />
117
- </el-form-item> -->
118
-
119
102
<el-form-item label =" 排序" prop =" sort" >
120
103
<el-input-number v-model =" form.sort" controls-position =" right" :min =" 0" :max =" 10000" >
121
104
</el-input-number >
122
105
</el-form-item >
123
-
124
- <!-- <el-form-item label="秒杀时段id" prop="timeId">
125
- <el-input v-model="form.timeId" placeholder="请输入秒杀时段id" />
126
- </el-form-item>
127
- <el-form-item label="订单实付金额(分)" prop="totalPrice">
128
- <el-input v-model="form.totalPrice" placeholder="请输入订单实付金额(分)" />
129
- </el-form-item> -->
130
-
131
106
<el-form-item label =" 备注" prop =" remark" >
132
107
<el-input type =" textarea" v-model =" form.remark" placeholder =" 请输入备注" />
133
108
</el-form-item >
134
109
<el-form-item label =" 场次选择" >
135
- <el-select v-model =" form.timeIds " placeholder =" 请选择参与场次" clearable size =" small" multiple filterable
110
+ <el-select v-model =" form.timeId " placeholder =" 请选择参与场次" clearable size =" small" multiple filterable
136
111
style =" width : 880px " >
137
112
<el-option v-for =" item in seckillTimeList" :key =" item.id" :label =" item.name" :value =" item.id" >
138
113
<span style =" float : left " >{{ item.name + ': { ' }} {{ item.startTime }} -- {{ item.endTime +
142
117
</el-option >
143
118
</el-select >
144
119
</el-form-item >
145
-
146
120
<el-form-item label =" 商品选择" >
147
121
<el-select v-model =" form.skuIds" placeholder =" 请选择活动商品" clearable size =" small" multiple filterable
148
122
style =" width : 880px " @change =" changeFormSku" >
154
128
}}</span >
155
129
</el-option >
156
130
</el-select >
157
-
158
131
<el-row >
159
132
<el-button type =" primary" size =" mini" @click =" batchEditProduct('limitBuyCount')" >限购</el-button >
160
133
<el-button type =" primary" size =" mini" @click =" batchEditProduct('seckillPrice')" >秒杀价</el-button >
161
134
<el-button type =" primary" size =" mini" @click =" batchEditProduct('seckillStock')" >秒杀库存</el-button >
162
135
</el-row >
163
-
164
136
<el-table v-loading =" loading" ref =" productsTable" :data =" form.products" >
165
137
<el-table-column type =" selection" width =" 55" >
166
138
</el-table-column >
177
149
<el-table-column label =" 库存" align =" center" prop =" productStock" />
178
150
<el-table-column label =" 限购(0为不限购)" align =" center" width =" 150" >
179
151
<template slot-scope="scope">
180
- <el-input-number v-model =" scope.row.limitBuyCount" size =" mini" controls-position =" right"
181
- :min =" 0" :max =" 10000" >
152
+ <el-input-number v-model =" scope.row.limitBuyCount" size =" mini" :min =" 0" :max =" 10000" >
182
153
</el-input-number >
183
154
</template >
184
155
</el-table-column >
185
-
186
156
<el-table-column label =" 秒杀价(元)" align =" center" width =" 150" >
187
157
<template slot-scope="scope">
188
- <el-input-number v-model =" scope.row.seckillPrice" size =" mini" controls-position = " right "
189
- :precision = " 2 " :min = " 0 " : max =" 10000" >
158
+ <el-input-number v-model =" scope.row.seckillPrice" size =" mini" :precision = " 2 " :min = " 0 "
159
+ :max =" 10000" >
190
160
</el-input-number >
191
161
</template >
192
162
</el-table-column >
193
-
194
- <el-table-column label =" 秒杀库存" align =" center" width =" 150" >
163
+ <el-table-column label =" 秒杀库存" align =" center" width =" 150" prop =" seckillStock" >
195
164
<template slot-scope="scope">
196
- <el-input-number v-model =" scope.row.seckillStock" size =" mini" controls-position =" right"
197
- :min =" 0" :max =" 10000" >
165
+ <el-input-number v-model =" scope.row.seckillStock" size =" mini" :min =" 0" :max =" 10000" >
198
166
</el-input-number >
199
167
</template >
200
168
</el-table-column >
201
-
202
169
<el-table-column label =" 操作" align =" center" class-name =" small-padding fixed-width" >
203
170
<template slot-scope="scope">
204
171
<el-button size =" mini" type =" text" icon =" el-icon-delete"
208
175
</el-table-column >
209
176
</el-table >
210
177
</el-form-item >
211
-
212
-
213
178
</el-form >
214
179
<div slot =" footer" class =" dialog-footer" >
215
180
<el-button type =" primary" @click =" submitForm" >确 定</el-button >
221
186
222
187
<script >
223
188
import { getSkuOptionList } from " @/api/mall/product/sku" ;
224
- import { createSeckillActivity , updateSeckillActivity , deleteSeckillActivity , getSeckillActivity , getSeckillActivityPage , exportSeckillActivityExcel } from " @/api/promotion/seckillActivity" ;
225
- import { getSeckillTimeList } from " @/api/promotion/seckillTime" ;
226
- import router from ' @/router' ;
227
- import { PromotionDiscountTypeEnum } from " @/utils/constants" ;
189
+ import { createSeckillActivity , updateSeckillActivity , closeSeckillActivity ,deleteSeckillActivity , getSeckillActivity , getSeckillActivityPage , exportSeckillActivityExcel } from " @/api/mall/promotion/seckillActivity" ;
190
+ import { getSeckillTimeList } from " @/api/mall/promotion/seckillTime" ;
191
+ import { deepClone } from " @/utils" ;
228
192
229
193
export default {
230
194
name: " SeckillActivity" ,
@@ -234,8 +198,6 @@ export default {
234
198
return {
235
199
// 遮罩层
236
200
loading: true ,
237
- // 导出遮罩层
238
- exportLoading: false ,
239
201
// 显示搜索条件
240
202
showSearch: true ,
241
203
// 总条数
@@ -261,7 +223,7 @@ export default {
261
223
form: {
262
224
skuIds: [], // 选中的 SKU
263
225
products: [], // 商品信息
264
- timeIds : [], // 选中的秒杀场次id
226
+ timeId : [], // 选中的秒杀场次id
265
227
},
266
228
// 商品 SKU 列表
267
229
productSkus: [],
@@ -270,35 +232,42 @@ export default {
270
232
name: [{ required: true , message: " 秒杀活动名称不能为空" , trigger: " blur" }],
271
233
status: [{ required: true , message: " 活动状态不能为空" , trigger: " blur" }],
272
234
startAndEndTime: [{ required: true , message: " 活动时间不能为空" , trigger: " blur" }],
273
- endTime: [{ required: true , message: " 活动结束时间不能为空" , trigger: " blur" }],
274
235
sort: [{ required: true , message: " 排序不能为空" , trigger: " blur" }],
275
- timeIds : [{ required: true , message: " 秒杀场次不能为空" , trigger: " blur" }],
236
+ timeId : [{ required: true , message: " 秒杀场次不能为空" , trigger: " blur" }],
276
237
totalPrice: [{ required: true , message: " 订单实付金额,单位:分不能为空" , trigger: " blur" }],
277
238
}
278
239
};
279
240
},
280
241
created () {
281
242
this .getList ();
282
243
},
244
+ watch: {
245
+ $route: ' getList'
246
+ },
283
247
methods: {
284
248
/** 查询列表 */
285
249
getList () {
250
+ const timeId = this .$route .params && this .$route .params .timeId ;
251
+ if (timeId) {
252
+ this .queryParams .timeId = timeId
253
+ }
286
254
this .loading = true ;
287
255
// 执行查询
288
256
getSeckillActivityPage (this .queryParams ).then (response => {
289
257
this .list = response .data .list ;
290
- console .log (response, " 查询返回的秒杀活动列表" );
291
258
this .total = response .data .total ;
292
259
this .loading = false ;
293
260
});
261
+ if (timeId) {
262
+ this .$route .params .timeId = undefined
263
+ }
294
264
// 获得 SKU 商品列表
295
265
getSkuOptionList ().then (response => {
296
266
this .productSkus = response .data ;
297
267
});
298
268
// 获取参与场次列表
299
269
getSeckillTimeList ().then (response => {
300
270
this .seckillTimeList = response .data ;
301
- console .log (this .seckillTimeList , " 最终获取的参与场次列表" );
302
271
});
303
272
},
304
273
/** 取消按钮 */
@@ -316,7 +285,7 @@ export default {
316
285
startTime: undefined ,
317
286
endTime: undefined ,
318
287
sort: undefined ,
319
- timeId: undefined ,
288
+ timeId: [] ,
320
289
totalPrice: undefined ,
321
290
skuIds: [],
322
291
products: [],
@@ -333,6 +302,10 @@ export default {
333
302
this .resetForm (" queryForm" );
334
303
this .handleQuery ();
335
304
},
305
+ /** 打开秒杀场次管理页面 */
306
+ openSeckillTime () {
307
+ this .$tab .openPage (" 秒杀场次管理" , " /promotion/seckill-time" );
308
+ },
336
309
/** 新增按钮操作 */
337
310
handleAdd () {
338
311
this .reset ();
@@ -341,14 +314,34 @@ export default {
341
314
},
342
315
/** 修改按钮操作 */
343
316
handleUpdate (row ) {
344
- console .log (row, " 当前行数据" );
345
317
this .reset ();
346
318
const id = row .id ;
347
319
getSeckillActivity (id).then (response => {
320
+ var timeIdList = response .data .timeId .split (' ,' )
348
321
this .form = response .data ;
322
+ // 修改数据
323
+ this .form .startAndEndTime = [response .data .startTime , response .data .endTime ];
324
+ this .form .timeId = timeIdList .map (item => parseInt (item))
325
+ this .form .skuIds = response .data .products .map (item => item .skuId );
326
+ this .form .products .forEach (product => {
327
+ // 获得对应的 SKU 信息
328
+ const sku = this .productSkus .find (item => item .id === product .skuId );
329
+ if (! sku) {
330
+ return ;
331
+ }
332
+ // 设置商品信息
333
+ product .name = sku .name ;
334
+ product .spuName = sku .spuName ;
335
+ product .price = sku .price ;
336
+ product .productStock = sku .stock ;
337
+ this .$set (product,' seckillStock' ,product .stock );
338
+ product .seckillPrice = product .seckillPrice !== undefined ? product .seckillPrice / 100 : undefined ;
339
+
340
+ });
341
+ // 打开弹窗
349
342
this .open = true ;
350
- this .title = " 修改秒杀活动 " ;
351
- });
343
+ this .title = " 修改限时折扣活动 " ;
344
+ })
352
345
},
353
346
/** 提交按钮 */
354
347
submitForm () {
@@ -360,6 +353,11 @@ export default {
360
353
const data = deepClone (this .form );
361
354
data .startTime = this .form .startAndEndTime [0 ];
362
355
data .endTime = this .form .startAndEndTime [1 ];
356
+ data .timeId = data .timeId .toString ();
357
+ data .products .forEach (product => {
358
+ product .stock = product .seckillStock ;
359
+ product .seckillPrice = product .seckillPrice !== undefined ? product .seckillPrice * 100 : undefined ;
360
+ });
363
361
// 修改的提交
364
362
if (this .form .id != null ) {
365
363
updateSeckillActivity (data).then (response => {
@@ -377,6 +375,16 @@ export default {
377
375
});
378
376
});
379
377
},
378
+ /** 关闭按钮操作 */
379
+ handleClose (row ) {
380
+ const id = row .id ;
381
+ this .$modal .confirm (' 是否确认关闭秒杀活动编号为"' + id + ' "的数据项?' ).then (function () {
382
+ return closeSeckillActivity (id);
383
+ }).then (() => {
384
+ this .getList ();
385
+ this .$modal .msgSuccess (" 关闭成功" );
386
+ }).catch (() => { });
387
+ },
380
388
/** 删除按钮操作 */
381
389
handleDelete (row ) {
382
390
const id = row .id ;
@@ -387,20 +395,6 @@ export default {
387
395
this .$modal .msgSuccess (" 删除成功" );
388
396
}).catch (() => { });
389
397
},
390
- /** 导出按钮操作 */
391
- handleExport () {
392
- // 处理查询参数
393
- let params = { ... this .queryParams };
394
- params .pageNo = undefined ;
395
- params .pageSize = undefined ;
396
- this .$modal .confirm (' 是否确认导出所有秒杀活动数据项?' ).then (() => {
397
- this .exportLoading = true ;
398
- return exportSeckillActivityExcel (params);
399
- }).then (response => {
400
- this .$download .excel (response, ' 秒杀活动.xls' );
401
- this .exportLoading = false ;
402
- }).catch (() => { });
403
- },
404
398
/** 批量修改商品秒杀价,秒杀库存,每人限购数量 */
405
399
batchEditProduct (editType ) {
406
400
const selectProducts = this .$refs .productsTable .selection ;
@@ -459,7 +453,6 @@ export default {
459
453
return ;
460
454
}
461
455
// 判断已存在,直接跳过
462
- console .log (this .form , " 当前form" )
463
456
const product = this .form .products .find (item => item .skuId === skuId);
464
457
if (product) {
465
458
return ;
0 commit comments