许成详 6 年之前
父節點
當前提交
438d9fa20b

+ 290
- 62
src/pages/system/cardAndCouponManager/couponManager/edit.vue 查看文件

@@ -1,13 +1,13 @@
1 1
 <template>
2 2
   <div class="subPage">
3 3
     <form class="mainForm">
4
-      <h1 style="font-size:22px;">{{isEdit === 0 ? '新建' : '编辑'}}{{type === 'drink' ? '饮品优惠券' : '课程优惠券'}}</h1>
4
+      <!-- <h1 style="font-size:22px;">{{isEdit === 0 ? '新建' : '编辑'}}{{couponInfo.CouponTypeId === 'goods' ? '饮品优惠券' : '课程优惠券'}}</h1> -->
5 5
       <ul>
6 6
         <li class="flex-h">
7 7
           <span>选择案场:</span>
8 8
           <div class="flex-item">
9 9
             <div style="width:50%">
10
-              <el-select v-model="postData.CaseId" placeholder="请选择">
10
+              <el-select v-model="couponInfo.CaseId" placeholder="请选择" @change="caseChange">
11 11
                 <el-option
12 12
                   v-for="item in cases"
13 13
                   :key="item.CaseId"
@@ -27,7 +27,7 @@
27 27
                 :action='$api.file.image.url'
28 28
                 :show-file-list="false"
29 29
                 :on-success="handleAvatarSuccess">
30
-                <img v-if="postData.Img" :src="postData.Img" class="avatar">
30
+                <img v-if="couponInfo.Images[0].CouponImageUrl" :src="couponInfo.Images[0].CouponImageUrl" class="avatar">
31 31
                 <i v-else class="el-icon-plus avatar-uploader-icon"></i>
32 32
               </el-upload>
33 33
             </div>
@@ -39,7 +39,7 @@
39 39
             <div style="width:200px;">
40 40
               <el-input
41 41
                 placeholder="请输入"
42
-                v-model="postData.Name"
42
+                v-model="couponInfo.CouponName"
43 43
                 clearable>
44 44
               </el-input>
45 45
             </div>
@@ -49,11 +49,11 @@
49 49
           <span>券类型:</span>
50 50
           <div class="flex-item">
51 51
             <div style="width:50%">
52
-              <el-select v-model="postData.Type" placeholder="请选择">
52
+              <el-select v-model="couponInfo.CouponTypeId" placeholder="请选择" @change="couponTypeChange">
53 53
                 <el-option
54 54
                   v-for="item in TypeList"
55 55
                   :key="item.id"
56
-                  :label="item.name"
56
+                  :label="item.value"
57 57
                   :value="item.id">
58 58
                 </el-option>
59 59
               </el-select>
@@ -66,7 +66,7 @@
66 66
             <div style="width:200px;">
67 67
               <el-input
68 68
                 placeholder="请输入"
69
-                v-model="postData.Price"
69
+                v-model="couponInfo.Price"
70 70
                 clearable>
71 71
               </el-input>
72 72
             </div>
@@ -78,7 +78,7 @@
78 78
             <div style="width:200px;">
79 79
               <el-input
80 80
                 placeholder="请输入"
81
-                v-model="postData.TotalNum"
81
+                v-model="couponInfo.TotalCount"
82 82
                 clearable>
83 83
               </el-input>
84 84
             </div>
@@ -88,22 +88,22 @@
88 88
           <span>发送类型:</span>
89 89
           <div class="flex-item">
90 90
             <div>
91
-              <el-radio v-model="postData.SendType" label="1">渠道</el-radio>
92
-              <el-radio v-if="type === 'course'" v-model="postData.SendType" label="3">案场</el-radio>
93
-              <el-radio v-model="postData.SendType" label="2">系统</el-radio>
91
+              <el-radio v-model="couponInfo.SendType" label="channel">渠道</el-radio>
92
+              <el-radio v-if="couponInfo.CouponTypeId === 'case'" v-model="couponInfo.SendType" label="case">案场</el-radio>
93
+              <el-radio v-model="couponInfo.SendType" label="system">系统</el-radio>
94 94
             </div>
95 95
           </div>
96 96
         </li>
97
-        <li class="flex-h">
97
+        <li class="flex-h" v-if="couponInfo.SendType === 'channel'">
98 98
           <span>选择渠道:</span>
99 99
           <div class="flex-item">
100 100
             <div style="width:50%">
101
-              <el-select v-model="postData.ChannelId" placeholder="请选择">
101
+              <el-select v-model="couponInfo.ChannelId" placeholder="请选择">
102 102
                 <el-option
103
-                  v-for="item in ChannelList"
104
-                  :key="item.id"
105
-                  :label="item.name"
106
-                  :value="item.id">
103
+                  v-for="item in channelList"
104
+                  :key="item.ChannelId"
105
+                  :label="item.ChannelName"
106
+                  :value="item.ChannelId">
107 107
                 </el-option>
108 108
               </el-select>
109 109
             </div>
@@ -113,24 +113,24 @@
113 113
           <span>目标商品:</span>
114 114
           <div class="flex-item">
115 115
             <div>
116
-              <el-radio v-model="postData.Assign" label="1">全部商品</el-radio>
117
-              <el-radio v-model="postData.Assign" label="2">指定商品</el-radio>
116
+              <el-radio v-model="couponInfo.IsAll" label="1">全部商品</el-radio>
117
+              <el-radio v-model="couponInfo.IsAll" label="0">指定商品</el-radio>
118 118
             </div>
119 119
           </div>
120 120
         </li>
121
-        <li class="flex-h" v-if="postData.Assign === '2'">
121
+        <li class="flex-h" v-if="couponInfo.IsAll === '0'">
122 122
           <div class="flex-item">
123 123
             <div style="border: 1px solid #eee;">
124 124
               <el-table
125
-                :data="currentList"
125
+                :data="couponInfo.Targets"
126 126
                 stripe
127 127
                 style="width: 100%">
128 128
                 <el-table-column
129
-                  prop="Name"
129
+                  prop="TargetName"
130 130
                   label="商品">
131 131
                 </el-table-column>
132 132
                 <el-table-column
133
-                  prop="Type"
133
+                  prop="TargetType"
134 134
                   label="分类">
135 135
                 </el-table-column>
136 136
                 <el-table-column label="操作">
@@ -148,20 +148,20 @@
148 148
             </div>
149 149
           </div>
150 150
         </li>
151
-        <li class="flex-h" v-if="type === 'drink'">
151
+        <li class="flex-h" v-if="couponInfo.CouponTypeId === 'goods'">
152 152
           <span>券有效时间:</span>
153 153
           <div class="flex-item">
154 154
             <div>
155 155
               <div class="addLine flex-h" style="align-item:center;margin-bottom:20px;">
156 156
                 <el-radio v-model="postData.TimeType" label="1">固定时间</el-radio>
157 157
                 <el-date-picker
158
-                  v-model="postData.StartDate"
158
+                  v-model="couponInfo.StartDate"
159 159
                   type="date"
160 160
                   placeholder="选择起始日期">
161 161
                 </el-date-picker>
162 162
                 <span style="line-height:40px;">至</span>
163 163
                 <el-date-picker
164
-                  v-model="postData.EndDate"
164
+                  v-model="couponInfo.EndDate"
165 165
                   type="date"
166 166
                   placeholder="选择截止日期">
167 167
                 </el-date-picker>
@@ -171,7 +171,7 @@
171 171
                 <span style="width:100px;">
172 172
                   <el-input
173 173
                     placeholder="请输入"
174
-                    v-model="postData.Days"
174
+                    v-model="couponInfo.ValidDays"
175 175
                     clearable>
176 176
                   </el-input>
177 177
                 </span>
@@ -185,13 +185,13 @@
185 185
           <div class="flex-item">
186 186
             <div>
187 187
               <el-date-picker
188
-                v-model="postData.StartDate"
188
+                v-model="couponInfo.StartDate"
189 189
                 type="date"
190 190
                 placeholder="选择起始日期">
191 191
               </el-date-picker>
192 192
               <span style="line-height:40px;">至</span>
193 193
               <el-date-picker
194
-                v-model="postData.EndDate"
194
+                v-model="couponInfo.EndDate"
195 195
                 type="date"
196 196
                 placeholder="选择截止日期">
197 197
               </el-date-picker>
@@ -201,7 +201,17 @@
201 201
         <li class="flex-h">
202 202
           <span>视频:</span>
203 203
           <div class="flex-item">
204
-            <div></div>
204
+            <div style="vertical-align: middle;">
205
+              <a style="line-height: 40px;" v-if="videoOff" :href="couponInfo.VideoUrl" target="blank">{{couponInfo.VideoUrl}}</a>
206
+              <el-upload
207
+                class="avatar-uploader"
208
+                :action='$api.file.image.url'
209
+                :show-file-list="false"
210
+                :on-success="videoSuccess">
211
+                <a style="line-height: 40px;padding: 0 10px;">{{videoOff ? '更换' : '添加'}}视频</a>
212
+              </el-upload>
213
+              <el-button v-if="videoOff" type="danger" @click="deleteVideo">删除视频</el-button>
214
+            </div>
205 215
           </div>
206 216
         </li>
207 217
         <li class="flex-h">
@@ -212,7 +222,7 @@
212 222
                 type="textarea"
213 223
                 :rows="2"
214 224
                 placeholder="请输入"
215
-                v-model="postData.ShareDesc">
225
+                v-model="couponInfo.Share.CouponShareInfo">
216 226
               </el-input>
217 227
             </div>
218 228
           </div>
@@ -225,7 +235,7 @@
225 235
                 type="textarea"
226 236
                 :rows="2"
227 237
                 placeholder="请输入"
228
-                v-model="postData.RuleDesc">
238
+                v-model="couponInfo.Share.UseRule">
229 239
               </el-input>
230 240
             </div>
231 241
           </div>
@@ -238,7 +248,7 @@
238 248
                 type="textarea"
239 249
                 :rows="2"
240 250
                 placeholder="请输入"
241
-                v-model="postData.UsedDesc">
251
+                v-model="couponInfo.Share.UseInstruction">
242 252
               </el-input>
243 253
             </div>
244 254
           </div>
@@ -255,22 +265,22 @@
255 265
       width="650px"
256 266
       center>
257 267
       <div>
258
-        <div v-if="type === 'drink'">
268
+        <div v-if="couponInfo.CouponTypeId === 'goods'">
259 269
           <el-table
260 270
             ref="multipleTable"
261
-            :data="drinkList"
271
+            :data="goodsList.list"
262 272
             tooltip-effect="dark"
263 273
             style="width: 100%"
264
-            @selection-change="handleSelectionChange">
274
+            @selection-change="handleGoodsChange">
265 275
             <el-table-column
266 276
               type="selection">
267 277
             </el-table-column>
268 278
             <el-table-column
269
-              prop="Name"
279
+              prop="GoodsName"
270 280
               label="商品名称">
271 281
             </el-table-column>
272 282
             <el-table-column
273
-              prop="Type"
283
+              prop="TypeId"
274 284
               label="类别">
275 285
             </el-table-column>
276 286
             <el-table-column
@@ -286,22 +296,22 @@
286 296
             :total="total">
287 297
           </el-pagination>
288 298
         </div>
289
-        <div v-if="type === 'course'">
299
+        <div v-if="couponInfo.CouponTypeId === 'course'">
290 300
           <el-table
291 301
             ref="multipleTable"
292
-            :data="courseList"
302
+            :data="courseList.list"
293 303
             tooltip-effect="dark"
294 304
             style="width: 100%"
295
-            @selection-change="handleSelectionChange">
305
+            @selection-change="handleCourseChange">
296 306
             <el-table-column
297 307
               type="selection">
298 308
             </el-table-column>
299 309
             <el-table-column
300
-              prop="Name"
310
+              prop="CourseName"
301 311
               label="商品名称">
302 312
             </el-table-column>
303 313
             <el-table-column
304
-              prop="StartDate"
314
+              prop="BeginDate"
305 315
               label="开始时间">
306 316
             </el-table-column>
307 317
             <el-table-column
@@ -309,7 +319,7 @@
309 319
               label="结束时间">
310 320
             </el-table-column>
311 321
             <el-table-column
312
-              prop="Type"
322
+              prop="CourseType"
313 323
               label="类别">
314 324
             </el-table-column>
315 325
             <el-table-column
@@ -328,75 +338,290 @@
328 338
       </div>
329 339
       <span slot="footer" class="dialog-footer">
330 340
         <el-button @click="centerDialogVisible = false">取 消</el-button>
331
-        <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
341
+        <el-button type="primary" @click="sureAddItem">确 定</el-button>
332 342
       </span>
333 343
     </el-dialog>
334 344
   </div>
335 345
 </template>
336 346
 
337 347
 <script>
338
-import { mapState } from 'vuex'
348
+import { mapState, createNamespacedHelpers } from 'vuex'
349
+const { mapActions: mapCouponActions } = createNamespacedHelpers('coupon')
350
+const { mapState: mapChannelState, mapActions: mapChannelActions } = createNamespacedHelpers('channel')
351
+const { mapState: mapGoodsState, mapActions: mapGoodsActions } = createNamespacedHelpers('goods')
352
+const { mapState: mapCourseState, mapActions: mapCourseActions } = createNamespacedHelpers('course')
339 353
 
340 354
 export default {
341 355
   name: '',
342 356
   data () {
343 357
     return {
358
+      videoOff: false,
344 359
       total: 0,
345
-      drinkList: [], // 饮品列表
346
-      courseList: [], // 课程列表
347 360
       centerDialogVisible: false,
348
-      type: this.$route.query.type,
361
+      type: this.$route.query.type || '', // goods、course
349 362
       isEdit: this.$route.query.id === undefined ? 0 : 1,
350 363
       ChannelList: [], // 渠道列表
351
-      TypeList: [], // 类型列表
364
+      TypeList: [{ // 类型列表
365
+        value: '商品券',
366
+        id: 'goods'
367
+      }, {
368
+        value: '课程券',
369
+        id: 'course'
370
+      }],
352 371
       currentList: [{
353 372
         Name: 'ccc',
354 373
         Type: 'xxx'
355 374
       }], // 指定商品数据
375
+      couponInfo: {
376
+        CaseId: '',
377
+        CouponName: '',
378
+        CouponTypeId: '',
379
+        Price: '',
380
+        TotalCount: '',
381
+        SendType: '',
382
+        IsAll: '',
383
+        StartDate: '',
384
+        EndDate: '',
385
+        ValidDays: '',
386
+        VideoUrl: '',
387
+        ChannelId: '',
388
+        Images: [{
389
+          CouponImageUrl: ''
390
+        }],
391
+        Share: {
392
+          CouponShareInfo: '',
393
+          UseRule: '',
394
+          UseInstruction: ''
395
+        },
396
+        Targets: []
397
+      },
356 398
       postData: {
357 399
         page: 1,
358
-        pagesize: 10,
400
+        pagesize: 6,
359 401
       },
402
+      currentSelectArr: [],
360 403
     }
361 404
   },
362 405
   mounted () {
363
-    this.$nextTick(function () { })
406
+    this.$nextTick(function () {
407
+      this.GetChannelListList({
408
+        caseid: this.defaultCaseId,
409
+        page: 1,
410
+        pagesize: 10000
411
+      }).then(() => {
412
+        if (this.$route.query.id) {
413
+          this.getCouponById({
414
+            id: this.$route.query.id
415
+          }).then((res) => {
416
+            // console.log(JSON.stringify(res))
417
+            res.coupon.IsAll = String(res.coupon.IsAll)
418
+            if (res.coupon.VideoUrl !== '') {
419
+              this.videoOff = true
420
+            }
421
+            this.couponInfo = res.coupon
422
+          })
423
+        }
424
+      })
425
+    })
364 426
   },
365 427
   computed: {
366 428
     ...mapState({
367 429
       cases: x => x.app.cases.list,
368 430
       defaultCaseId: x => x.app.cases.default
369 431
     }),
432
+    ...mapChannelState({
433
+      channelList: x => x.channelList,
434
+    }),
435
+    ...mapGoodsState({
436
+      goodsList: x => x.goodsList,
437
+    }),
438
+    ...mapCourseState({
439
+      courseList: x => x.courseList,
440
+    }),
370 441
     CaseId: {
371 442
       get () {
372
-        return this.postData.caseid || this.defaultCaseId
443
+        return this.couponInfo.caseid || this.defaultCaseId
373 444
       },
374 445
       set (val) {
375
-        this.postData.caseid = val
446
+        this.couponInfo.caseid = val
376 447
       }
377 448
     }
378 449
   },
379 450
   methods: {
380
-    handleSelectionChange (val) {
381
-      // this.multipleSelection = val;
451
+    ...mapGoodsActions([
452
+      'GetGoodsList',
453
+    ]),
454
+    ...mapCouponActions([
455
+      'addCoupon',
456
+      'getCouponById',
457
+      'editCoupon',
458
+    ]),
459
+    ...mapChannelActions([
460
+      'GetChannelListList',
461
+    ]),
462
+    ...mapCourseActions([
463
+      'GetCourseList',
464
+    ]),
465
+    deleteVideo () { // 删除视频
466
+      this.couponInfo.VideoUrl = ''
467
+      this.videoOff = false
468
+    },
469
+    caseChange () { // 选择案场
470
+      this.couponInfo.ChannelId = ''
471
+      this.GetChannelListList({
472
+        caseid: this.couponInfo.CaseId,
473
+        page: 1,
474
+        pagesize: 10000
475
+      })
476
+    },
477
+    sureAddItem () { // 确定添加指定商品
478
+      var bool = true
479
+      if (this.couponInfo.CouponTypeId === 'goods') {
480
+        for (var n = 0; n < this.currentSelectArr.length; n++) {
481
+          if (this.couponInfo.Targets.length) {
482
+            bool = true
483
+            for (var a = 0; a < this.couponInfo.Targets.length; a++) {
484
+              if (this.currentSelectArr[n].GoodsId === this.couponInfo.Targets[a].TargetId) {
485
+                bool = false
486
+              }
487
+            }
488
+            if (bool) {
489
+              this.couponInfo.Targets.push({
490
+                TargetName: this.currentSelectArr[n].GoodsName,
491
+                TargetId: this.currentSelectArr[n].GoodsId,
492
+                TargetType: this.currentSelectArr[n].TypeId
493
+              })
494
+            }
495
+          } else {
496
+            this.couponInfo.Targets.push({
497
+              TargetName: this.currentSelectArr[n].GoodsName,
498
+              TargetId: this.currentSelectArr[n].GoodsId,
499
+              TargetType: this.currentSelectArr[n].TypeId
500
+            })
501
+          }
502
+        }
503
+      } else if (this.couponInfo.CouponTypeId === 'course') {
504
+        for (var x = 0; x < this.currentSelectArr.length; x++) {
505
+          if (this.couponInfo.Targets.length) {
506
+            bool = true
507
+            for (var y = 0; y < this.couponInfo.Targets.length; y++) {
508
+              if (this.currentSelectArr[x].CourseId === this.couponInfo.Targets[y].TargetId) {
509
+                bool = false
510
+              }
511
+            }
512
+            if (bool) {
513
+              this.couponInfo.Targets.push({
514
+                TargetName: this.currentSelectArr[x].CourseName,
515
+                TargetId: this.currentSelectArr[x].CourseId,
516
+                TargetType: this.currentSelectArr[x].CourseType
517
+              })
518
+            }
519
+          } else {
520
+            this.couponInfo.Targets.push({
521
+              TargetName: this.currentSelectArr[x].CourseName,
522
+              TargetId: this.currentSelectArr[x].CourseId,
523
+              TargetType: this.currentSelectArr[x].CourseType
524
+            })
525
+          }
526
+        }
527
+      }
528
+      this.centerDialogVisible = false
529
+    },
530
+    handleGoodsChange (val) {
531
+      this.currentSelectArr = val
532
+    },
533
+    handleCourseChange (val) {
534
+      this.currentSelectArr = val
535
+    },
536
+    couponTypeChange () {
537
+      if (this.goodsList.length) {
538
+        this.goodsList = []
539
+      }
540
+      if (this.courseList.length) {
541
+        this.courseList = []
542
+      }
543
+      this.couponInfo.Targets = []
382 544
     },
383 545
     addGoods () { // 添加指定商品
384
-      this.centerDialogVisible = true
546
+      if (this.couponInfo.CouponTypeId === 'goods') {
547
+        this.GetGoodsList({
548
+          ...this.postData,
549
+          caseid: this.couponInfo.CaseId
550
+        }).then((res) => {
551
+          this.total = res.pagenum
552
+          this.centerDialogVisible = true
553
+        })
554
+      } else if (this.couponInfo.CouponTypeId === 'course') {
555
+        this.GetCourseList({
556
+          ...this.postData,
557
+          caseid: this.couponInfo.CaseId
558
+        }).then((res) => {
559
+          this.total = res.pagenum
560
+          this.centerDialogVisible = true
561
+        })
562
+      }
385 563
     },
386 564
     submit () { // 保存
387
-      // 1
565
+      if (this.$route.query.id) {
566
+        this.editCoupon({
567
+          ...this.couponInfo,
568
+          IsAll: this.couponInfo.IsAll - 0,
569
+          TotalCount: this.couponInfo.TotalCount - 0,
570
+          ValidDays: this.couponInfo.ValidDays || 0
571
+        }).then((res) => {
572
+          this.$alert('操作成功', '提示', {
573
+            confirmButtonText: '确定',
574
+            callback: action => {
575
+              this.$router.push({ name: 'couponList' })
576
+            }
577
+          })
578
+        })
579
+      } else {
580
+        this.addCoupon({
581
+          ...this.couponInfo,
582
+          IsAll: this.couponInfo.IsAll - 0,
583
+          TotalCount: this.couponInfo.TotalCount - 0,
584
+          ValidDays: this.couponInfo.ValidDays || 0
585
+        }).then((res) => {
586
+          this.$alert('操作成功', '提示', {
587
+            confirmButtonText: '确定',
588
+            callback: action => {
589
+              this.$router.push({ name: 'couponList' })
590
+            }
591
+          })
592
+        })
593
+      }
388 594
     },
389 595
     cancel () { // 取消
390 596
       this.$router.push({ name: 'couponList' })
391 597
     },
392
-    deleteGoodsItem () { // 删除指定商品item
393
-      // 1
598
+    deleteGoodsItem (index, row) { // 删除指定商品item
599
+      this.couponInfo.Targets.splice(index, 1)
394 600
     },
395 601
     handleAvatarSuccess (res, file) {
396
-      this.postData.Img = res.result.url
602
+      this.couponInfo.Images[0].CouponImageUrl = res.result.url
603
+    },
604
+    videoSuccess (res, file) {
605
+      this.videoOff = true
606
+      this.couponInfo.VideoUrl = res.result.url
397 607
     },
398 608
     handleCurrentChange (val) { // 跳转到分页
399
-      // this.getList()
609
+      this.postData.page = val
610
+      if (this.couponInfo.CouponTypeId === 'goods') {
611
+        this.GetGoodsList({
612
+          ...this.postData,
613
+          caseid: this.couponInfo.CaseId
614
+        }).then((res) => {
615
+          this.total = res.pagenum
616
+        })
617
+      } else if (this.couponInfo.CouponTypeId === 'course') {
618
+        this.GetCourseList({
619
+          ...this.postData,
620
+          caseid: this.couponInfo.CaseId
621
+        }).then((res) => {
622
+          this.total = res.pagenum
623
+        })
624
+      }
400 625
     },
401 626
   }
402 627
 }
@@ -409,4 +634,7 @@ export default {
409 634
     margin-right: 10px;
410 635
   }
411 636
 }
637
+.mainForm > ul > li > div > div > button {
638
+  margin-top: 0;
639
+}
412 640
 </style>

+ 40
- 22
src/pages/system/cardAndCouponManager/couponManager/index.vue 查看文件

@@ -3,8 +3,9 @@
3 3
     <div class="system-table-search">
4 4
       <div class="flex-h">
5 5
         <div class="flex-item flex-h">
6
-          <el-button size="mini" type="success" @click="addCoupon('drink')">新增饮品优惠券</el-button>
7
-          <el-button size="mini" type="success" @click="addCoupon('course')">新增课程优惠券</el-button>
6
+          <el-button size="mini" type="success" @click="addCoupon('')">新增优惠券</el-button>
7
+          <!-- <el-button size="mini" type="success" @click="addCoupon('drink')">新增饮品优惠券</el-button>
8
+          <el-button size="mini" type="success" @click="addCoupon('course')">新增课程优惠券</el-button> -->
8 9
         </div>
9 10
         <ul>
10 11
           <li>
@@ -27,43 +28,51 @@
27 28
     </div>
28 29
     <div class="system-table-box">
29 30
       <el-table
30
-        :data="currentList"
31
+        :data="couponList.list"
31 32
         stripe
32 33
         style="width: 100%">
33 34
         <el-table-column
34
-          prop="xxx"
35
+          prop="CouponName"
35 36
           label="券名称">
36 37
         </el-table-column>
37 38
         <el-table-column
38
-          prop="xxx"
39
+          prop="CouponTypeId"
39 40
           label="券类型">
41
+          <template slot-scope="scope">{{scope.row.CouponTypeId === 'goods' ? '商品券' : '课程券'}}</template>
40 42
         </el-table-column>
41 43
         <el-table-column
42
-          prop="xxx"
44
+          prop="Price"
43 45
           label="券价格">
44 46
         </el-table-column>
45 47
         <el-table-column
46
-          prop="xxx"
47
-          label="有效期">
48
+          prop="StartDate"
49
+          label="有效期"
50
+          width="150">
51
+          <template slot-scope="scope">
52
+            <span style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.StartDate)}}</span>
53
+            <span style="width:100%;display:block;text-align:center;white-space: nowrap;">至</span>
54
+            <span style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.EndDate)}}</span>
55
+            </template>
48 56
         </el-table-column>
49 57
         <el-table-column
50
-          prop="xxx"
58
+          prop="SendType"
51 59
           label="发放类型">
60
+          <template slot-scope="scope">{{scope.row.SendType === 'channel' ? '渠道' : scope.row.SendType === 'case' ? '案场' : '系统'}}</template>
52 61
         </el-table-column>
53 62
         <el-table-column
54
-          prop="xxx"
63
+          prop="TotalCount"
55 64
           label="总数量">
56 65
         </el-table-column>
57 66
         <el-table-column
58
-          prop="xxx"
67
+          prop="SentCount"
59 68
           label="已发">
60 69
         </el-table-column>
61 70
         <el-table-column
62
-          prop="xxx"
71
+          prop="UsedCount"
63 72
           label="实际使用">
64 73
         </el-table-column>
65 74
         <el-table-column
66
-          prop="xxx"
75
+          prop="Status"
67 76
           label="状态">
68 77
         </el-table-column>
69 78
         <el-table-column label="操作" fixed='right' width="350">
@@ -188,7 +197,8 @@
188 197
 </template>
189 198
 
190 199
 <script>
191
-import { mapState } from 'vuex'
200
+import { mapState, createNamespacedHelpers } from 'vuex'
201
+const { mapState: mapCouponState, mapActions: mapCouponActions } = createNamespacedHelpers('coupon')
192 202
 
193 203
 export default {
194 204
   name: '',
@@ -219,6 +229,9 @@ export default {
219 229
     })
220 230
   },
221 231
   computed: {
232
+    ...mapCouponState({
233
+      couponList: x => x.couponList,
234
+    }),
222 235
     ...mapState({
223 236
       cases: x => x.app.cases.list,
224 237
       defaultCaseId: x => x.app.cases.default
@@ -233,6 +246,9 @@ export default {
233 246
     }
234 247
   },
235 248
   methods: {
249
+    ...mapCouponActions([
250
+      'GetCouponList',
251
+    ]),
236 252
     dialogSearch () { // 赠送客户搜索
237 253
       // 1
238 254
     },
@@ -247,24 +263,26 @@ export default {
247 263
     },
248 264
     search () { // 搜索
249 265
       this.postData.page = 1
250
-      this.currentList = []
266
+      if (this.couponList.length) {
267
+        this.couponList = []
268
+      }
251 269
       this.getList()
252 270
     },
253 271
     getList () { // 获取列表
254
-      this.$ajax(this.$api.channelManager.getChannelList.url, {
255
-        method: this.$api.channelManager.getChannelList.method,
256
-        queryData: { ...this.postData, caseid: this.CaseId }
257
-      }).then(res => {
258
-        this.currentList = res.list
259
-        this.postData.page = res.page
272
+      this.GetCouponList({
273
+        ...this.postData,
274
+        caseid: this.CaseId || this.defaultCaseId
275
+      }).then((res) => {
260 276
         this.total = res.pagenum
277
+        // console.log(JSON.stringify(res))
261 278
       })
262 279
     },
263 280
     handleCurrentChange (val) { // 跳转到分页
281
+      this.postData.page = val
264 282
       this.getList()
265 283
     },
266 284
     handleEdit (index, row) { // 编辑
267
-      this.$router.push({ name: 'editChannel', query: { id: row.ChannelId } })
285
+      this.$router.push({ name: 'editCoupon', query: { type: row.CouponTypeId, id: row.CouponId } })
268 286
     },
269 287
     handleDelete (index, row) { // 删除
270 288
       let name = '确认删除渠道“' + row.ChannelName + '”?'

+ 1
- 0
src/pages/system/cardAndCouponManager/couponManager/page.scss 查看文件

@@ -23,5 +23,6 @@
23 23
 
24 24
 
25 25
 
26
+
26 27
 
27 28
 

+ 29
- 0
src/store/channel/channel.js 查看文件

@@ -0,0 +1,29 @@
1
+import ajax from '../../util/ajax'
2
+import api from '../../util/api'
3
+
4
+export default {
5
+  namespaced: true,
6
+  state: {
7
+    channelList: [],
8
+  },
9
+  mutations: {
10
+    updateList (state, payload) {
11
+      state.channelList = payload || []
12
+    },
13
+  },
14
+  actions: {
15
+    GetChannelListList ({ commit }, payload) {
16
+      return new Promise((resolve, reject) => {
17
+        ajax(api.channelManager.getChannelList.url, {
18
+          method: api.channelManager.getChannelList.method,
19
+          queryData: {
20
+            ...payload,
21
+          }
22
+        }).then(res => {
23
+          commit('updateList', res.list)
24
+          resolve(res)
25
+        }).catch(reject)
26
+      })
27
+    },
28
+  }
29
+}

+ 68
- 0
src/store/coupon/coupon.js 查看文件

@@ -0,0 +1,68 @@
1
+import ajax from '../../util/ajax'
2
+import api from '../../util/api'
3
+
4
+export default {
5
+  namespaced: true,
6
+  state: {
7
+    couponList: [],
8
+  },
9
+  mutations: {
10
+    updateList (state, payload) {
11
+      state.couponList = payload || []
12
+    },
13
+  },
14
+  actions: {
15
+    GetCouponList ({ commit }, payload) {
16
+      return new Promise((resolve, reject) => {
17
+        ajax(api.couponManager.couponList.url, {
18
+          method: api.couponManager.couponList.method,
19
+          queryData: {
20
+            ...payload,
21
+          }
22
+        }).then(res => {
23
+          commit('updateList', res)
24
+          resolve(res)
25
+        }).catch(reject)
26
+      })
27
+    },
28
+    addCoupon ({ commit }, payload) {
29
+      return new Promise((resolve, reject) => {
30
+        ajax(api.couponManager.addCoupon.url, {
31
+          method: api.couponManager.addCoupon.method,
32
+          data: {
33
+            info: JSON.stringify(payload)
34
+          }
35
+        }).then(res => {
36
+          resolve(res)
37
+        }).catch(reject)
38
+      })
39
+    },
40
+    getCouponById ({ commit }, { id }) {
41
+      return new Promise((resolve, reject) => {
42
+        ajax(api.couponManager.getCouponById.url, {
43
+          method: api.couponManager.getCouponById.method,
44
+          urlData: {
45
+            id,
46
+          }
47
+        }).then(res => {
48
+          resolve(res)
49
+        }).catch(reject)
50
+      })
51
+    },
52
+    editCoupon ({ commit }, payload) {
53
+      return new Promise((resolve, reject) => {
54
+        ajax(api.couponManager.editCoupon.url, {
55
+          method: api.couponManager.editCoupon.method,
56
+          data: {
57
+            info: JSON.stringify(payload)
58
+          },
59
+          urlData: {
60
+            id: payload.CouponId
61
+          },
62
+        }).then(res => {
63
+          resolve(res)
64
+        }).catch(reject)
65
+      })
66
+    },
67
+  }
68
+}

+ 13
- 10
src/store/course/course.js 查看文件

@@ -21,16 +21,19 @@ export default {
21 21
   },
22 22
   actions: {
23 23
     GetCourseList ({ commit }, payload) {
24
-      ajax(api.course.list.url, {
25
-        method: api.course.list.method,
26
-        queryData: {
27
-          ...payload,
28
-        }
29
-      }).then(res => {
30
-        commit('updateList', res)
31
-        if (payload.callback) {
32
-          payload.callback()
33
-        }
24
+      return new Promise((resolve, reject) => {
25
+        ajax(api.course.list.url, {
26
+          method: api.course.list.method,
27
+          queryData: {
28
+            ...payload,
29
+          }
30
+        }).then(res => {
31
+          commit('updateList', res)
32
+          resolve(res)
33
+          if (payload.callback) {
34
+            payload.callback()
35
+          }
36
+        }).catch(reject)
34 37
       })
35 38
     },
36 39
     GetCourseByID ({ commit }, { id }) {

+ 10
- 7
src/store/goods/goods.js 查看文件

@@ -25,13 +25,16 @@ export default {
25 25
   },
26 26
   actions: {
27 27
     GetGoodsList ({ commit }, payload) {
28
-      ajax(api.goodsManager.getGoodsList.url, {
29
-        method: api.goodsManager.getGoodsList.method,
30
-        queryData: {
31
-          ...payload,
32
-        }
33
-      }).then(res => {
34
-        commit('updateList', res)
28
+      return new Promise((resolve, reject) => {
29
+        ajax(api.goodsManager.getGoodsList.url, {
30
+          method: api.goodsManager.getGoodsList.method,
31
+          queryData: {
32
+            ...payload,
33
+          }
34
+        }).then(res => {
35
+          commit('updateList', res)
36
+          resolve(res)
37
+        }).catch(reject)
35 38
       })
36 39
     },
37 40
     GetGoodTypes ({ commit }, payload) {

+ 2
- 0
src/store/index.js 查看文件

@@ -26,6 +26,8 @@ export const modules = {
26 26
   cmscase: () => require('./cms/case').default,
27 27
   caserecord: () => require('./case/record').default,
28 28
   vip: () => require('./card/vip').default,
29
+  coupon: () => require('./coupon/coupon').default,
30
+  channel: () => require('./channel/channel').default,
29 31
   customer: () => require('./customer/customer').default,
30 32
   user: () => require('./system/user').default,
31 33
 }

+ 18
- 0
src/util/api.js 查看文件

@@ -590,6 +590,24 @@ const $api = {
590 590
       url: `${baseUrl}${common}/vipcard/:code`
591 591
     }
592 592
   },
593
+  couponManager: {
594
+    couponList: {
595
+      method: 'get',
596
+      url: `${baseUrl}${common}/coupon`
597
+    },
598
+    addCoupon: {
599
+      method: 'post',
600
+      url: `${baseUrl}${common}/coupon`
601
+    },
602
+    editCoupon: {
603
+      method: 'put',
604
+      url: `${baseUrl}${common}/coupon/:id`
605
+    },
606
+    getCouponById: {
607
+      method: 'get',
608
+      url: `${baseUrl}${common}/coupon/:id`
609
+    },
610
+  },
593 611
   customerManager: {
594 612
     getByTel: {
595 613
       method: 'get',