许成详 6 年前
父节点
当前提交
65d0672ea5

+ 70
- 20
src/pages/system/cardAndCouponManager/cardManager/edit.vue 查看文件

@@ -26,7 +26,7 @@
26 26
                 :action='$api.file.image.url'
27 27
                 :show-file-list="false"
28 28
                 :on-success="handleAvatarSuccess">
29
-                <img v-if="cardInfo.Images[0].CardImageUrl" :src="cardInfo.Images[0].CardImageUrl" class="avatar">
29
+                <img v-if="cardInfo.Images" :src="cardInfo.Images[0].CardImageUrl" class="avatar">
30 30
                 <i v-else class="el-icon-plus avatar-uploader-icon"></i>
31 31
               </el-upload>
32 32
             </div>
@@ -225,32 +225,29 @@ export default {
225 225
         Type: 'xxx'
226 226
       }], // 指定商品数据
227 227
       cardInfo: {
228
-        CardId: '',
229 228
         CardName: '',
230 229
         SendType: '',
231 230
         VideoUrl: '',
232
-        Price: '',
231
+        Price: ' ',
233 232
         StartDate: '',
234 233
         EndDate: '',
235 234
         TotalCount: '',
236
-        SentCount: '',
237
-        UsedCount: '',
238
-        Status: '',
239 235
         CaseId: '',
240 236
         OrgId: '',
241 237
         Share: {
242 238
           CardShareInfo: '',
243 239
           CardUseRule: '',
244
-          CardUseInstruction: '',
240
+          CardUseInstruction: ''
245 241
         },
246 242
         Images: [{
247
-          CardImageUrl: '',
243
+          CardImageUrl: ''
248 244
         }],
249 245
         Targets: [{
250 246
           TargetType: '',
251 247
           TargetId: '',
252 248
           TargetName: ''
253 249
         }],
250
+        ChannelId: ''
254 251
       },
255 252
       postData: {
256 253
         page: 1,
@@ -264,14 +261,33 @@ export default {
264 261
         caseid: this.defaultCaseId,
265 262
         page: 1,
266 263
         pagesize: 10000
267
-      })
268
-      this.GetCourseList({
269
-        caseid: this.defaultCaseId,
270
-        page: 1,
271
-        pagesize: 10000
272
-      }).then((res) => {
273
-        // console.log(JSON.stringify(res))
274
-        this.courseList = res.list
264
+      }).then(() => {
265
+        this.GetCourseList({
266
+          caseid: this.defaultCaseId,
267
+          page: 1,
268
+          pagesize: 10000
269
+        }).then((res) => {
270
+          this.courseList = res.list
271
+          if (this.$route.query.id) {
272
+            this.getCardById({
273
+              id: this.$route.query.id
274
+            }).then((res) => {
275
+              // console.log(JSON.stringify(res.Card))
276
+              this.cardInfo = res.Card
277
+              if (res.Card.VideoUrl) {
278
+                this.videoOff = true
279
+              }
280
+              if (res.Card.Images === null) {
281
+                this.cardInfo.Images = [{
282
+                  CardImageUrl: ''
283
+                }]
284
+              }
285
+              if (res.Card.StartDate) {
286
+                this.date = [res.Card.StartDate, res.Card.EndDate]
287
+              }
288
+            })
289
+          }
290
+        })
275 291
       })
276 292
     })
277 293
   },
@@ -349,13 +365,47 @@ export default {
349 365
     },
350 366
     submit () { // 保存
351 367
       if (this.$route.query.id) {
352
-        // 1
368
+        if (this.date !== '') {
369
+          this.cardInfo.StartDate = this.date[0]
370
+          this.cardInfo.EndDate = this.date[1]
371
+        }
372
+        for (var x = 0; x < this.courseList.length; x++) {
373
+          if (this.courseList[x].CourseId === this.cardInfo.Targets[0].TargetId) {
374
+            this.cardInfo.Targets[0].TargetType = this.courseList[x].CourseType
375
+            this.cardInfo.Targets[0].TargetName = this.courseList[x].CourseName
376
+          }
377
+        }
378
+        this.cardInfo.TotalCount = this.cardInfo.TotalCount - 0
379
+        console.log(JSON.stringify(this.cardInfo))
380
+        this.editCard(this.cardInfo).then((res) => {
381
+          this.$alert('操作成功', '提示', {
382
+            confirmButtonText: '确定',
383
+            callback: action => {
384
+              this.$router.push({ name: 'cardList' })
385
+            }
386
+          })
387
+        })
353 388
       } else {
354 389
         this.cardInfo.OrgId = this.OrgId
390
+        if (this.date !== '') {
391
+          this.cardInfo.StartDate = this.date[0]
392
+          this.cardInfo.EndDate = this.date[1]
393
+        }
394
+        for (var n = 0; n < this.courseList.length; n++) {
395
+          if (this.courseList[n].CourseId === this.cardInfo.Targets[0].TargetId) {
396
+            this.cardInfo.Targets[0].TargetType = this.courseList[n].CourseType
397
+            this.cardInfo.Targets[0].TargetName = this.courseList[n].CourseName
398
+          }
399
+        }
400
+        this.cardInfo.TotalCount = this.cardInfo.TotalCount - 0
355 401
         console.log(JSON.stringify(this.cardInfo))
356
-        this.addCard({
357
-          info: this.cardInfo
358
-        }).then((res) => {
402
+        this.addCard(this.cardInfo).then((res) => {
403
+          this.$alert('操作成功', '提示', {
404
+            confirmButtonText: '确定',
405
+            callback: action => {
406
+              this.$router.push({ name: 'cardList' })
407
+            }
408
+          })
359 409
         })
360 410
       }
361 411
     },

+ 40
- 28
src/pages/system/cardAndCouponManager/cardManager/index.vue 查看文件

@@ -3,8 +3,7 @@
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="addCard('course')">新增课程体验卡</el-button>
7
-          <el-button size="mini" type="success" @click="addCard('bodybuilding')">新增健身卡</el-button>
6
+          <el-button size="mini" type="success" @click="addCard">新增课程体验卡</el-button>
8 7
         </div>
9 8
         <ul>
10 9
           <li>
@@ -27,44 +26,53 @@
27 26
     </div>
28 27
     <div class="system-table-box">
29 28
       <el-table
30
-        :data="currentList"
29
+        :data="cardList.list"
31 30
         stripe
32 31
         style="width: 100%">
33 32
         <el-table-column
34
-          prop="xxx"
33
+          prop="CardName"
35 34
           label="卡名称">
36 35
         </el-table-column>
37
-        <el-table-column
36
+        <!-- <el-table-column
38 37
           prop="xxx"
39 38
           label="卡类型">
40
-        </el-table-column>
39
+        </el-table-column> -->
41 40
         <el-table-column
42
-          prop="xxx"
41
+          prop="Price"
43 42
           label="卡价格">
44 43
         </el-table-column>
45 44
         <el-table-column
46
-          prop="xxx"
47
-          label="有效期">
45
+          prop="StartDate"
46
+          label="有效期"
47
+          width="150">
48
+          <template slot-scope="scope">
49
+            <span style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.StartDate)}}</span>
50
+            <span style="width:100%;display:block;text-align:center;white-space: nowrap;">至</span>
51
+            <span style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.EndDate)}}</span>
52
+          </template>
48 53
         </el-table-column>
49 54
         <el-table-column
50
-          prop="xxx"
55
+          prop="SendType"
51 56
           label="发放类型">
52 57
         </el-table-column>
53 58
         <el-table-column
54
-          prop="xxx"
59
+          prop="TotalCount"
55 60
           label="总数量">
56 61
         </el-table-column>
57 62
         <el-table-column
58
-          prop="xxx"
63
+          prop="SentCount"
59 64
           label="已发">
60 65
         </el-table-column>
61 66
         <el-table-column
62
-          prop="xxx"
67
+          prop="UsedCount"
63 68
           label="实际使用">
64 69
         </el-table-column>
65 70
         <el-table-column
66
-          prop="xxx"
71
+          prop="Status"
67 72
           label="状态">
73
+          <template slot-scope="scope">
74
+            {{scope.row.Status == 1 ? '正常' : '已过期'}}
75
+          </template>
68 76
         </el-table-column>
69 77
         <el-table-column label="操作" fixed='right' width="350">
70 78
           <template slot-scope="scope">
@@ -188,7 +196,8 @@
188 196
 </template>
189 197
 
190 198
 <script>
191
-import { mapState } from 'vuex'
199
+import { mapState, createNamespacedHelpers } from 'vuex'
200
+const { mapState: mapCardState, mapActions: mapCardActions } = createNamespacedHelpers('card')
192 201
 
193 202
 export default {
194 203
   name: '',
@@ -208,9 +217,6 @@ export default {
208 217
         page: 1, // 当前页码
209 218
         pagesize: 10, // 请求数据量
210 219
       },
211
-      currentList: [{
212
-        xxx: 'xxx'
213
-      }]
214 220
     }
215 221
   },
216 222
   mounted () {
@@ -219,6 +225,9 @@ export default {
219 225
     })
220 226
   },
221 227
   computed: {
228
+    ...mapCardState({
229
+      cardList: x => x.cardList,
230
+    }),
222 231
     ...mapState({
223 232
       cases: x => x.app.cases.list,
224 233
       defaultCaseId: x => x.app.cases.default
@@ -233,6 +242,9 @@ export default {
233 242
     }
234 243
   },
235 244
   methods: {
245
+    ...mapCardActions([
246
+      'GetCardList',
247
+    ]),
236 248
     toSendHistory () { // 查看赠送记录
237 249
       this.$router.push({name: 'givingRecords'})
238 250
     },
@@ -243,7 +255,8 @@ export default {
243 255
       // 1
244 256
     },
245 257
     handleSelectionChange (val) {
246
-      // 1
258
+      this.postData.page = val
259
+      this.getList()
247 260
     },
248 261
     sendCard (index, row) { // 赠送卡
249 262
       this.centerDialogVisible = true
@@ -254,20 +267,19 @@ export default {
254 267
       this.getList()
255 268
     },
256 269
     getList () { // 获取列表
257
-      this.$ajax(this.$api.channelManager.getChannelList.url, {
258
-        method: this.$api.channelManager.getChannelList.method,
259
-        queryData: { ...this.postData, caseid: this.CaseId }
260
-      }).then(res => {
261
-        this.currentList = res.list
262
-        this.postData.page = res.page
270
+      this.GetCardList({
271
+        ...this.postData,
272
+        caseid: this.CaseId || this.defaultCaseId
273
+      }).then((res) => {
263 274
         this.total = res.pagenum
275
+        // console.log(JSON.stringify(res))
264 276
       })
265 277
     },
266 278
     handleCurrentChange (val) { // 跳转到分页
267 279
       this.getList()
268 280
     },
269 281
     handleEdit (index, row) { // 编辑
270
-      this.$router.push({ name: 'editChannel', query: { id: row.ChannelId } })
282
+      this.$router.push({ name: 'editCard', query: { id: row.CardId } })
271 283
     },
272 284
     handleDelete (index, row) { // 删除
273 285
       let name = '确认删除渠道“' + row.ChannelName + '”?'
@@ -293,8 +305,8 @@ export default {
293 305
         })
294 306
       })
295 307
     },
296
-    addCard (val) {
297
-      this.$router.push({ name: 'editCard', query: { type: val } })
308
+    addCard () {
309
+      this.$router.push({ name: 'editCard', query: {} })
298 310
     }
299 311
   }
300 312
 }

+ 4
- 1
src/pages/system/cardAndCouponManager/couponManager/index.vue 查看文件

@@ -52,7 +52,7 @@
52 52
             <span style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.StartDate)}}</span>
53 53
             <span style="width:100%;display:block;text-align:center;white-space: nowrap;">至</span>
54 54
             <span style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.EndDate)}}</span>
55
-            </template>
55
+          </template>
56 56
         </el-table-column>
57 57
         <el-table-column
58 58
           prop="SendType"
@@ -74,6 +74,9 @@
74 74
         <el-table-column
75 75
           prop="Status"
76 76
           label="状态">
77
+          <template slot-scope="scope">
78
+            {{scope.row.Status == 1 ? '正常' : '已过期'}}
79
+          </template>
77 80
         </el-table-column>
78 81
         <el-table-column label="操作" fixed='right' width="350">
79 82
           <template slot-scope="scope">