许成详 6 years ago
parent
commit
438d9fa20b

+ 290
- 62
src/pages/system/cardAndCouponManager/couponManager/edit.vue View File

1
 <template>
1
 <template>
2
   <div class="subPage">
2
   <div class="subPage">
3
     <form class="mainForm">
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
       <ul>
5
       <ul>
6
         <li class="flex-h">
6
         <li class="flex-h">
7
           <span>选择案场:</span>
7
           <span>选择案场:</span>
8
           <div class="flex-item">
8
           <div class="flex-item">
9
             <div style="width:50%">
9
             <div style="width:50%">
10
-              <el-select v-model="postData.CaseId" placeholder="请选择">
10
+              <el-select v-model="couponInfo.CaseId" placeholder="请选择" @change="caseChange">
11
                 <el-option
11
                 <el-option
12
                   v-for="item in cases"
12
                   v-for="item in cases"
13
                   :key="item.CaseId"
13
                   :key="item.CaseId"
27
                 :action='$api.file.image.url'
27
                 :action='$api.file.image.url'
28
                 :show-file-list="false"
28
                 :show-file-list="false"
29
                 :on-success="handleAvatarSuccess">
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
                 <i v-else class="el-icon-plus avatar-uploader-icon"></i>
31
                 <i v-else class="el-icon-plus avatar-uploader-icon"></i>
32
               </el-upload>
32
               </el-upload>
33
             </div>
33
             </div>
39
             <div style="width:200px;">
39
             <div style="width:200px;">
40
               <el-input
40
               <el-input
41
                 placeholder="请输入"
41
                 placeholder="请输入"
42
-                v-model="postData.Name"
42
+                v-model="couponInfo.CouponName"
43
                 clearable>
43
                 clearable>
44
               </el-input>
44
               </el-input>
45
             </div>
45
             </div>
49
           <span>券类型:</span>
49
           <span>券类型:</span>
50
           <div class="flex-item">
50
           <div class="flex-item">
51
             <div style="width:50%">
51
             <div style="width:50%">
52
-              <el-select v-model="postData.Type" placeholder="请选择">
52
+              <el-select v-model="couponInfo.CouponTypeId" placeholder="请选择" @change="couponTypeChange">
53
                 <el-option
53
                 <el-option
54
                   v-for="item in TypeList"
54
                   v-for="item in TypeList"
55
                   :key="item.id"
55
                   :key="item.id"
56
-                  :label="item.name"
56
+                  :label="item.value"
57
                   :value="item.id">
57
                   :value="item.id">
58
                 </el-option>
58
                 </el-option>
59
               </el-select>
59
               </el-select>
66
             <div style="width:200px;">
66
             <div style="width:200px;">
67
               <el-input
67
               <el-input
68
                 placeholder="请输入"
68
                 placeholder="请输入"
69
-                v-model="postData.Price"
69
+                v-model="couponInfo.Price"
70
                 clearable>
70
                 clearable>
71
               </el-input>
71
               </el-input>
72
             </div>
72
             </div>
78
             <div style="width:200px;">
78
             <div style="width:200px;">
79
               <el-input
79
               <el-input
80
                 placeholder="请输入"
80
                 placeholder="请输入"
81
-                v-model="postData.TotalNum"
81
+                v-model="couponInfo.TotalCount"
82
                 clearable>
82
                 clearable>
83
               </el-input>
83
               </el-input>
84
             </div>
84
             </div>
88
           <span>发送类型:</span>
88
           <span>发送类型:</span>
89
           <div class="flex-item">
89
           <div class="flex-item">
90
             <div>
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
             </div>
94
             </div>
95
           </div>
95
           </div>
96
         </li>
96
         </li>
97
-        <li class="flex-h">
97
+        <li class="flex-h" v-if="couponInfo.SendType === 'channel'">
98
           <span>选择渠道:</span>
98
           <span>选择渠道:</span>
99
           <div class="flex-item">
99
           <div class="flex-item">
100
             <div style="width:50%">
100
             <div style="width:50%">
101
-              <el-select v-model="postData.ChannelId" placeholder="请选择">
101
+              <el-select v-model="couponInfo.ChannelId" placeholder="请选择">
102
                 <el-option
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
                 </el-option>
107
                 </el-option>
108
               </el-select>
108
               </el-select>
109
             </div>
109
             </div>
113
           <span>目标商品:</span>
113
           <span>目标商品:</span>
114
           <div class="flex-item">
114
           <div class="flex-item">
115
             <div>
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
             </div>
118
             </div>
119
           </div>
119
           </div>
120
         </li>
120
         </li>
121
-        <li class="flex-h" v-if="postData.Assign === '2'">
121
+        <li class="flex-h" v-if="couponInfo.IsAll === '0'">
122
           <div class="flex-item">
122
           <div class="flex-item">
123
             <div style="border: 1px solid #eee;">
123
             <div style="border: 1px solid #eee;">
124
               <el-table
124
               <el-table
125
-                :data="currentList"
125
+                :data="couponInfo.Targets"
126
                 stripe
126
                 stripe
127
                 style="width: 100%">
127
                 style="width: 100%">
128
                 <el-table-column
128
                 <el-table-column
129
-                  prop="Name"
129
+                  prop="TargetName"
130
                   label="商品">
130
                   label="商品">
131
                 </el-table-column>
131
                 </el-table-column>
132
                 <el-table-column
132
                 <el-table-column
133
-                  prop="Type"
133
+                  prop="TargetType"
134
                   label="分类">
134
                   label="分类">
135
                 </el-table-column>
135
                 </el-table-column>
136
                 <el-table-column label="操作">
136
                 <el-table-column label="操作">
148
             </div>
148
             </div>
149
           </div>
149
           </div>
150
         </li>
150
         </li>
151
-        <li class="flex-h" v-if="type === 'drink'">
151
+        <li class="flex-h" v-if="couponInfo.CouponTypeId === 'goods'">
152
           <span>券有效时间:</span>
152
           <span>券有效时间:</span>
153
           <div class="flex-item">
153
           <div class="flex-item">
154
             <div>
154
             <div>
155
               <div class="addLine flex-h" style="align-item:center;margin-bottom:20px;">
155
               <div class="addLine flex-h" style="align-item:center;margin-bottom:20px;">
156
                 <el-radio v-model="postData.TimeType" label="1">固定时间</el-radio>
156
                 <el-radio v-model="postData.TimeType" label="1">固定时间</el-radio>
157
                 <el-date-picker
157
                 <el-date-picker
158
-                  v-model="postData.StartDate"
158
+                  v-model="couponInfo.StartDate"
159
                   type="date"
159
                   type="date"
160
                   placeholder="选择起始日期">
160
                   placeholder="选择起始日期">
161
                 </el-date-picker>
161
                 </el-date-picker>
162
                 <span style="line-height:40px;">至</span>
162
                 <span style="line-height:40px;">至</span>
163
                 <el-date-picker
163
                 <el-date-picker
164
-                  v-model="postData.EndDate"
164
+                  v-model="couponInfo.EndDate"
165
                   type="date"
165
                   type="date"
166
                   placeholder="选择截止日期">
166
                   placeholder="选择截止日期">
167
                 </el-date-picker>
167
                 </el-date-picker>
171
                 <span style="width:100px;">
171
                 <span style="width:100px;">
172
                   <el-input
172
                   <el-input
173
                     placeholder="请输入"
173
                     placeholder="请输入"
174
-                    v-model="postData.Days"
174
+                    v-model="couponInfo.ValidDays"
175
                     clearable>
175
                     clearable>
176
                   </el-input>
176
                   </el-input>
177
                 </span>
177
                 </span>
185
           <div class="flex-item">
185
           <div class="flex-item">
186
             <div>
186
             <div>
187
               <el-date-picker
187
               <el-date-picker
188
-                v-model="postData.StartDate"
188
+                v-model="couponInfo.StartDate"
189
                 type="date"
189
                 type="date"
190
                 placeholder="选择起始日期">
190
                 placeholder="选择起始日期">
191
               </el-date-picker>
191
               </el-date-picker>
192
               <span style="line-height:40px;">至</span>
192
               <span style="line-height:40px;">至</span>
193
               <el-date-picker
193
               <el-date-picker
194
-                v-model="postData.EndDate"
194
+                v-model="couponInfo.EndDate"
195
                 type="date"
195
                 type="date"
196
                 placeholder="选择截止日期">
196
                 placeholder="选择截止日期">
197
               </el-date-picker>
197
               </el-date-picker>
201
         <li class="flex-h">
201
         <li class="flex-h">
202
           <span>视频:</span>
202
           <span>视频:</span>
203
           <div class="flex-item">
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
           </div>
215
           </div>
206
         </li>
216
         </li>
207
         <li class="flex-h">
217
         <li class="flex-h">
212
                 type="textarea"
222
                 type="textarea"
213
                 :rows="2"
223
                 :rows="2"
214
                 placeholder="请输入"
224
                 placeholder="请输入"
215
-                v-model="postData.ShareDesc">
225
+                v-model="couponInfo.Share.CouponShareInfo">
216
               </el-input>
226
               </el-input>
217
             </div>
227
             </div>
218
           </div>
228
           </div>
225
                 type="textarea"
235
                 type="textarea"
226
                 :rows="2"
236
                 :rows="2"
227
                 placeholder="请输入"
237
                 placeholder="请输入"
228
-                v-model="postData.RuleDesc">
238
+                v-model="couponInfo.Share.UseRule">
229
               </el-input>
239
               </el-input>
230
             </div>
240
             </div>
231
           </div>
241
           </div>
238
                 type="textarea"
248
                 type="textarea"
239
                 :rows="2"
249
                 :rows="2"
240
                 placeholder="请输入"
250
                 placeholder="请输入"
241
-                v-model="postData.UsedDesc">
251
+                v-model="couponInfo.Share.UseInstruction">
242
               </el-input>
252
               </el-input>
243
             </div>
253
             </div>
244
           </div>
254
           </div>
255
       width="650px"
265
       width="650px"
256
       center>
266
       center>
257
       <div>
267
       <div>
258
-        <div v-if="type === 'drink'">
268
+        <div v-if="couponInfo.CouponTypeId === 'goods'">
259
           <el-table
269
           <el-table
260
             ref="multipleTable"
270
             ref="multipleTable"
261
-            :data="drinkList"
271
+            :data="goodsList.list"
262
             tooltip-effect="dark"
272
             tooltip-effect="dark"
263
             style="width: 100%"
273
             style="width: 100%"
264
-            @selection-change="handleSelectionChange">
274
+            @selection-change="handleGoodsChange">
265
             <el-table-column
275
             <el-table-column
266
               type="selection">
276
               type="selection">
267
             </el-table-column>
277
             </el-table-column>
268
             <el-table-column
278
             <el-table-column
269
-              prop="Name"
279
+              prop="GoodsName"
270
               label="商品名称">
280
               label="商品名称">
271
             </el-table-column>
281
             </el-table-column>
272
             <el-table-column
282
             <el-table-column
273
-              prop="Type"
283
+              prop="TypeId"
274
               label="类别">
284
               label="类别">
275
             </el-table-column>
285
             </el-table-column>
276
             <el-table-column
286
             <el-table-column
286
             :total="total">
296
             :total="total">
287
           </el-pagination>
297
           </el-pagination>
288
         </div>
298
         </div>
289
-        <div v-if="type === 'course'">
299
+        <div v-if="couponInfo.CouponTypeId === 'course'">
290
           <el-table
300
           <el-table
291
             ref="multipleTable"
301
             ref="multipleTable"
292
-            :data="courseList"
302
+            :data="courseList.list"
293
             tooltip-effect="dark"
303
             tooltip-effect="dark"
294
             style="width: 100%"
304
             style="width: 100%"
295
-            @selection-change="handleSelectionChange">
305
+            @selection-change="handleCourseChange">
296
             <el-table-column
306
             <el-table-column
297
               type="selection">
307
               type="selection">
298
             </el-table-column>
308
             </el-table-column>
299
             <el-table-column
309
             <el-table-column
300
-              prop="Name"
310
+              prop="CourseName"
301
               label="商品名称">
311
               label="商品名称">
302
             </el-table-column>
312
             </el-table-column>
303
             <el-table-column
313
             <el-table-column
304
-              prop="StartDate"
314
+              prop="BeginDate"
305
               label="开始时间">
315
               label="开始时间">
306
             </el-table-column>
316
             </el-table-column>
307
             <el-table-column
317
             <el-table-column
309
               label="结束时间">
319
               label="结束时间">
310
             </el-table-column>
320
             </el-table-column>
311
             <el-table-column
321
             <el-table-column
312
-              prop="Type"
322
+              prop="CourseType"
313
               label="类别">
323
               label="类别">
314
             </el-table-column>
324
             </el-table-column>
315
             <el-table-column
325
             <el-table-column
328
       </div>
338
       </div>
329
       <span slot="footer" class="dialog-footer">
339
       <span slot="footer" class="dialog-footer">
330
         <el-button @click="centerDialogVisible = false">取 消</el-button>
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
       </span>
342
       </span>
333
     </el-dialog>
343
     </el-dialog>
334
   </div>
344
   </div>
335
 </template>
345
 </template>
336
 
346
 
337
 <script>
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
 export default {
354
 export default {
341
   name: '',
355
   name: '',
342
   data () {
356
   data () {
343
     return {
357
     return {
358
+      videoOff: false,
344
       total: 0,
359
       total: 0,
345
-      drinkList: [], // 饮品列表
346
-      courseList: [], // 课程列表
347
       centerDialogVisible: false,
360
       centerDialogVisible: false,
348
-      type: this.$route.query.type,
361
+      type: this.$route.query.type || '', // goods、course
349
       isEdit: this.$route.query.id === undefined ? 0 : 1,
362
       isEdit: this.$route.query.id === undefined ? 0 : 1,
350
       ChannelList: [], // 渠道列表
363
       ChannelList: [], // 渠道列表
351
-      TypeList: [], // 类型列表
364
+      TypeList: [{ // 类型列表
365
+        value: '商品券',
366
+        id: 'goods'
367
+      }, {
368
+        value: '课程券',
369
+        id: 'course'
370
+      }],
352
       currentList: [{
371
       currentList: [{
353
         Name: 'ccc',
372
         Name: 'ccc',
354
         Type: 'xxx'
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
       postData: {
398
       postData: {
357
         page: 1,
399
         page: 1,
358
-        pagesize: 10,
400
+        pagesize: 6,
359
       },
401
       },
402
+      currentSelectArr: [],
360
     }
403
     }
361
   },
404
   },
362
   mounted () {
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
   computed: {
427
   computed: {
366
     ...mapState({
428
     ...mapState({
367
       cases: x => x.app.cases.list,
429
       cases: x => x.app.cases.list,
368
       defaultCaseId: x => x.app.cases.default
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
     CaseId: {
441
     CaseId: {
371
       get () {
442
       get () {
372
-        return this.postData.caseid || this.defaultCaseId
443
+        return this.couponInfo.caseid || this.defaultCaseId
373
       },
444
       },
374
       set (val) {
445
       set (val) {
375
-        this.postData.caseid = val
446
+        this.couponInfo.caseid = val
376
       }
447
       }
377
     }
448
     }
378
   },
449
   },
379
   methods: {
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
     addGoods () { // 添加指定商品
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
     submit () { // 保存
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
     cancel () { // 取消
595
     cancel () { // 取消
390
       this.$router.push({ name: 'couponList' })
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
     handleAvatarSuccess (res, file) {
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
     handleCurrentChange (val) { // 跳转到分页
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
     margin-right: 10px;
634
     margin-right: 10px;
410
   }
635
   }
411
 }
636
 }
637
+.mainForm > ul > li > div > div > button {
638
+  margin-top: 0;
639
+}
412
 </style>
640
 </style>

+ 40
- 22
src/pages/system/cardAndCouponManager/couponManager/index.vue View File

3
     <div class="system-table-search">
3
     <div class="system-table-search">
4
       <div class="flex-h">
4
       <div class="flex-h">
5
         <div class="flex-item flex-h">
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
         </div>
9
         </div>
9
         <ul>
10
         <ul>
10
           <li>
11
           <li>
27
     </div>
28
     </div>
28
     <div class="system-table-box">
29
     <div class="system-table-box">
29
       <el-table
30
       <el-table
30
-        :data="currentList"
31
+        :data="couponList.list"
31
         stripe
32
         stripe
32
         style="width: 100%">
33
         style="width: 100%">
33
         <el-table-column
34
         <el-table-column
34
-          prop="xxx"
35
+          prop="CouponName"
35
           label="券名称">
36
           label="券名称">
36
         </el-table-column>
37
         </el-table-column>
37
         <el-table-column
38
         <el-table-column
38
-          prop="xxx"
39
+          prop="CouponTypeId"
39
           label="券类型">
40
           label="券类型">
41
+          <template slot-scope="scope">{{scope.row.CouponTypeId === 'goods' ? '商品券' : '课程券'}}</template>
40
         </el-table-column>
42
         </el-table-column>
41
         <el-table-column
43
         <el-table-column
42
-          prop="xxx"
44
+          prop="Price"
43
           label="券价格">
45
           label="券价格">
44
         </el-table-column>
46
         </el-table-column>
45
         <el-table-column
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
         </el-table-column>
56
         </el-table-column>
49
         <el-table-column
57
         <el-table-column
50
-          prop="xxx"
58
+          prop="SendType"
51
           label="发放类型">
59
           label="发放类型">
60
+          <template slot-scope="scope">{{scope.row.SendType === 'channel' ? '渠道' : scope.row.SendType === 'case' ? '案场' : '系统'}}</template>
52
         </el-table-column>
61
         </el-table-column>
53
         <el-table-column
62
         <el-table-column
54
-          prop="xxx"
63
+          prop="TotalCount"
55
           label="总数量">
64
           label="总数量">
56
         </el-table-column>
65
         </el-table-column>
57
         <el-table-column
66
         <el-table-column
58
-          prop="xxx"
67
+          prop="SentCount"
59
           label="已发">
68
           label="已发">
60
         </el-table-column>
69
         </el-table-column>
61
         <el-table-column
70
         <el-table-column
62
-          prop="xxx"
71
+          prop="UsedCount"
63
           label="实际使用">
72
           label="实际使用">
64
         </el-table-column>
73
         </el-table-column>
65
         <el-table-column
74
         <el-table-column
66
-          prop="xxx"
75
+          prop="Status"
67
           label="状态">
76
           label="状态">
68
         </el-table-column>
77
         </el-table-column>
69
         <el-table-column label="操作" fixed='right' width="350">
78
         <el-table-column label="操作" fixed='right' width="350">
188
 </template>
197
 </template>
189
 
198
 
190
 <script>
199
 <script>
191
-import { mapState } from 'vuex'
200
+import { mapState, createNamespacedHelpers } from 'vuex'
201
+const { mapState: mapCouponState, mapActions: mapCouponActions } = createNamespacedHelpers('coupon')
192
 
202
 
193
 export default {
203
 export default {
194
   name: '',
204
   name: '',
219
     })
229
     })
220
   },
230
   },
221
   computed: {
231
   computed: {
232
+    ...mapCouponState({
233
+      couponList: x => x.couponList,
234
+    }),
222
     ...mapState({
235
     ...mapState({
223
       cases: x => x.app.cases.list,
236
       cases: x => x.app.cases.list,
224
       defaultCaseId: x => x.app.cases.default
237
       defaultCaseId: x => x.app.cases.default
233
     }
246
     }
234
   },
247
   },
235
   methods: {
248
   methods: {
249
+    ...mapCouponActions([
250
+      'GetCouponList',
251
+    ]),
236
     dialogSearch () { // 赠送客户搜索
252
     dialogSearch () { // 赠送客户搜索
237
       // 1
253
       // 1
238
     },
254
     },
247
     },
263
     },
248
     search () { // 搜索
264
     search () { // 搜索
249
       this.postData.page = 1
265
       this.postData.page = 1
250
-      this.currentList = []
266
+      if (this.couponList.length) {
267
+        this.couponList = []
268
+      }
251
       this.getList()
269
       this.getList()
252
     },
270
     },
253
     getList () { // 获取列表
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
         this.total = res.pagenum
276
         this.total = res.pagenum
277
+        // console.log(JSON.stringify(res))
261
       })
278
       })
262
     },
279
     },
263
     handleCurrentChange (val) { // 跳转到分页
280
     handleCurrentChange (val) { // 跳转到分页
281
+      this.postData.page = val
264
       this.getList()
282
       this.getList()
265
     },
283
     },
266
     handleEdit (index, row) { // 编辑
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
     handleDelete (index, row) { // 删除
287
     handleDelete (index, row) { // 删除
270
       let name = '确认删除渠道“' + row.ChannelName + '”?'
288
       let name = '确认删除渠道“' + row.ChannelName + '”?'

+ 1
- 0
src/pages/system/cardAndCouponManager/couponManager/page.scss View File

23
 
23
 
24
 
24
 
25
 
25
 
26
+
26
 
27
 
27
 
28
 

+ 29
- 0
src/store/channel/channel.js View File

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 View File

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 View File

21
   },
21
   },
22
   actions: {
22
   actions: {
23
     GetCourseList ({ commit }, payload) {
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
     GetCourseByID ({ commit }, { id }) {
39
     GetCourseByID ({ commit }, { id }) {

+ 10
- 7
src/store/goods/goods.js View File

25
   },
25
   },
26
   actions: {
26
   actions: {
27
     GetGoodsList ({ commit }, payload) {
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
     GetGoodTypes ({ commit }, payload) {
40
     GetGoodTypes ({ commit }, payload) {

+ 2
- 0
src/store/index.js View File

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

+ 18
- 0
src/util/api.js View File

590
       url: `${baseUrl}${common}/vipcard/:code`
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
   customerManager: {
611
   customerManager: {
594
     getByTel: {
612
     getByTel: {
595
       method: 'get',
613
       method: 'get',