许成详 6 years ago
parent
commit
6f61e648f6

+ 61
- 15
src/pages/system/cardAndCouponManager/couponManager/index.vue View File

75
           prop="Status"
75
           prop="Status"
76
           label="状态">
76
           label="状态">
77
           <template slot-scope="scope">
77
           <template slot-scope="scope">
78
-            {{scope.row.Status == 1 ? '正常' : '已过期'}}
78
+            <span>{{scope.row.Status === 1 ? '正常' : '已过期'}}</span>
79
           </template>
79
           </template>
80
         </el-table-column>
80
         </el-table-column>
81
         <el-table-column label="操作" fixed='right' width="350">
81
         <el-table-column label="操作" fixed='right' width="350">
127
           <li class="flex-item">
127
           <li class="flex-item">
128
             <el-input
128
             <el-input
129
               placeholder="请输入推荐人"
129
               placeholder="请输入推荐人"
130
-              v-model="dialogPostData.referrer"
130
+              v-model="dialogPostData.recommendname"
131
               clearable>
131
               clearable>
132
             </el-input>
132
             </el-input>
133
           </li>
133
           </li>
138
         <ul class="dialogSearchList flex-h">
138
         <ul class="dialogSearchList flex-h">
139
           <li class="flex-item">
139
           <li class="flex-item">
140
             <el-date-picker
140
             <el-date-picker
141
-              v-model="dialogPostData.startdate"
141
+              v-model="dialogPostData.begindate"
142
               type="date"
142
               type="date"
143
               placeholder="选择起始日期">
143
               placeholder="选择起始日期">
144
             </el-date-picker>
144
             </el-date-picker>
153
       <div>
153
       <div>
154
         <el-table
154
         <el-table
155
           ref="multipleTable"
155
           ref="multipleTable"
156
-          :data="customerList"
156
+          :data="customers.list"
157
           tooltip-effect="dark"
157
           tooltip-effect="dark"
158
           style="width: 100%"
158
           style="width: 100%"
159
           @selection-change="handleSelectionChange">
159
           @selection-change="handleSelectionChange">
165
             label="姓名">
165
             label="姓名">
166
           </el-table-column>
166
           </el-table-column>
167
           <el-table-column
167
           <el-table-column
168
-            prop="NickName"
168
+            prop="CustomerName"
169
             label="微信昵称">
169
             label="微信昵称">
170
           </el-table-column>
170
           </el-table-column>
171
           <el-table-column
171
           <el-table-column
173
             label="手机号">
173
             label="手机号">
174
           </el-table-column>
174
           </el-table-column>
175
           <el-table-column
175
           <el-table-column
176
-            prop="CreatDate"
176
+            prop="CreateDate"
177
             label="创建时间">
177
             label="创建时间">
178
+            <template slot-scope="scope">
179
+              <span>{{toolClass.dateFormat(scope.row.CreateDate, 'yyyy-MM-dd')}}</span>
180
+            </template>
178
           </el-table-column>
181
           </el-table-column>
179
           <el-table-column
182
           <el-table-column
180
-            prop="Referrer"
183
+            prop="RecommendName"
181
             label="推荐人">
184
             label="推荐人">
182
           </el-table-column>
185
           </el-table-column>
183
         </el-table>
186
         </el-table>
188
           :current-page.sync="dialogPostData.page"
191
           :current-page.sync="dialogPostData.page"
189
           :page-size="dialogPostData.pagesize"
192
           :page-size="dialogPostData.pagesize"
190
           layout="prev, pager, next, jumper"
193
           layout="prev, pager, next, jumper"
191
-          :total="dialogTotal">
194
+          :total="customers.pagenum">
192
         </el-pagination>
195
         </el-pagination>
193
       </div>
196
       </div>
194
       <span slot="footer" class="dialog-footer">
197
       <span slot="footer" class="dialog-footer">
195
         <el-button @click="centerDialogVisible = false">取 消</el-button>
198
         <el-button @click="centerDialogVisible = false">取 消</el-button>
196
-        <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
199
+        <el-button type="primary" @click="ForCustomer">确 定</el-button>
197
       </span>
200
       </span>
198
     </el-dialog>
201
     </el-dialog>
199
   </div>
202
   </div>
202
 <script>
205
 <script>
203
 import { mapState, createNamespacedHelpers } from 'vuex'
206
 import { mapState, createNamespacedHelpers } from 'vuex'
204
 const { mapState: mapCouponState, mapActions: mapCouponActions } = createNamespacedHelpers('coupon')
207
 const { mapState: mapCouponState, mapActions: mapCouponActions } = createNamespacedHelpers('coupon')
208
+const { mapState: mapCustomerState, mapActions: mapCustomerActions } = createNamespacedHelpers('customer')
205
 
209
 
206
 export default {
210
 export default {
207
   name: '',
211
   name: '',
209
     return {
213
     return {
210
       dialogTotal: 0,
214
       dialogTotal: 0,
211
       dialogPostData: {
215
       dialogPostData: {
212
-        caseid: '', // 案场id
216
+        username: '',
217
+        phone: '',
218
+        recommendname: '',
219
+        begindate: '',
220
+        enddate: '',
213
         page: 1, // 当前页码
221
         page: 1, // 当前页码
214
         pagesize: 10, // 请求数据量
222
         pagesize: 10, // 请求数据量
215
       },
223
       },
216
-      customerList: [],
217
       centerDialogVisible: false,
224
       centerDialogVisible: false,
218
       total: 0,
225
       total: 0,
219
       postData: { // 表格搜索条件
226
       postData: { // 表格搜索条件
221
         page: 1, // 当前页码
228
         page: 1, // 当前页码
222
         pagesize: 10, // 请求数据量
229
         pagesize: 10, // 请求数据量
223
       },
230
       },
224
-      currentList: [{
225
-        xxx: 'xxx'
226
-      }]
231
+      currentInfo: {},
232
+      selUsers: '',
227
     }
233
     }
228
   },
234
   },
229
   mounted () {
235
   mounted () {
235
     ...mapCouponState({
241
     ...mapCouponState({
236
       couponList: x => x.couponList,
242
       couponList: x => x.couponList,
237
     }),
243
     }),
244
+    ...mapCustomerState({
245
+      customers: x => x.customers,
246
+    }),
238
     ...mapState({
247
     ...mapState({
239
       cases: x => x.app.cases.list,
248
       cases: x => x.app.cases.list,
240
       defaultCaseId: x => x.app.cases.default
249
       defaultCaseId: x => x.app.cases.default
251
   methods: {
260
   methods: {
252
     ...mapCouponActions([
261
     ...mapCouponActions([
253
       'GetCouponList',
262
       'GetCouponList',
263
+      'GiveCoupon',
264
+    ]),
265
+    ...mapCustomerActions([
266
+      'GetCustomerList',
267
+      'SetCustomerListNull',
254
     ]),
268
     ]),
255
     dialogSearch () { // 赠送客户搜索
269
     dialogSearch () { // 赠送客户搜索
270
+      this.GetCustomerList(this.dialogPostData)
256
       // 1
271
       // 1
257
     },
272
     },
258
     handleCurrentChangeDialog (val) {
273
     handleCurrentChangeDialog (val) {
259
       // 1
274
       // 1
260
     },
275
     },
261
     handleSelectionChange (val) {
276
     handleSelectionChange (val) {
277
+      this.selUsers = val.map(x => x.CustomerId).join(',')
262
       // 1
278
       // 1
263
     },
279
     },
264
     sendCoupon (index, row) { // 赠送优惠券
280
     sendCoupon (index, row) { // 赠送优惠券
281
+      this.currentInfo = row
282
+      this.selUsers = ''
283
+      this.SetCustomerListNull()
265
       this.centerDialogVisible = true
284
       this.centerDialogVisible = true
266
     },
285
     },
267
     search () { // 搜索
286
     search () { // 搜索
313
     },
332
     },
314
     addCoupon (val) {
333
     addCoupon (val) {
315
       this.$router.push({ name: 'editCoupon', query: { type: val } })
334
       this.$router.push({ name: 'editCoupon', query: { type: val } })
335
+    },
336
+    ForCustomer () {
337
+      if (this.selUsers === '') {
338
+        this.$message({
339
+          type: 'error',
340
+          message: '请先选择客户!'
341
+        })
342
+        return false
343
+      }
344
+      if (!this.currentInfo || this.currentInfo.CouponId === '') {
345
+        this.$message({
346
+          type: 'error',
347
+          message: '请先选择需要赠送的优惠券!'
348
+        })
349
+        return false
350
+      }
351
+      this.GiveCoupon({
352
+        id: this.currentInfo.CouponId,
353
+        users: this.selUsers,
354
+      }).then(res => {
355
+        this.$message({
356
+          type: 'success',
357
+          message: '赠送成功!'
358
+        })
359
+        this.centerDialogVisible = false
360
+        this.getList()
361
+      })
316
     }
362
     }
317
   }
363
   }
318
 }
364
 }
319
 </script>
365
 </script>
320
 
366
 
321
-<!-- Add "scoped" attribute to limit CSS to this component only -->
367
+<!-- Add "scoped" attrib0 0ute to limit CSS to this component only -->
322
 <style lang="scss" scoped>
368
 <style lang="scss" scoped>
323
 @import "page.scss";
369
 @import "page.scss";
324
 .dialogSearchList {
370
 .dialogSearchList {

+ 13
- 0
src/store/coupon/coupon.js View File

64
         }).catch(reject)
64
         }).catch(reject)
65
       })
65
       })
66
     },
66
     },
67
+    GiveCoupon ({ commit }, { id, users }) {
68
+      return new Promise((resolve, reject) => {
69
+        ajax(api.couponManager.giveCoupon.url, {
70
+          method: api.couponManager.giveCoupon.method,
71
+          urlData: {
72
+            id,
73
+            users
74
+          },
75
+        }).then(res => {
76
+          resolve(res)
77
+        }).catch(reject)
78
+      })
79
+    }
67
   }
80
   }
68
 }
81
 }

+ 20
- 0
src/store/customer/customer.js View File

5
   namespaced: true,
5
   namespaced: true,
6
   state: {
6
   state: {
7
     customer: {},
7
     customer: {},
8
+    customers: {},
8
   },
9
   },
9
   mutations: {
10
   mutations: {
10
     updateInfo (state, payload) {
11
     updateInfo (state, payload) {
11
       state.customer = payload || {}
12
       state.customer = payload || {}
12
     },
13
     },
14
+    updateList (state, payload) {
15
+      state.customers = payload || {}
16
+    }
13
   },
17
   },
14
   actions: {
18
   actions: {
15
     GetCustomerByTel ({ commit }, { tel }) {
19
     GetCustomerByTel ({ commit }, { tel }) {
25
         }).catch(reject)
29
         }).catch(reject)
26
       })
30
       })
27
     },
31
     },
32
+    GetCustomerList ({ commit }, payload) {
33
+      return new Promise((resolve, reject) => {
34
+        ajax(api.customerManager.getCustomerList.url, {
35
+          method: api.customerManager.getCustomerList.method,
36
+          queryData: {
37
+            ...payload
38
+          }
39
+        }).then(res => {
40
+          commit('updateList', res)
41
+          resolve(res)
42
+        }).catch(reject)
43
+      })
44
+    },
45
+    SetCustomerListNull ({ commit }) {
46
+      commit('updateList', {})
47
+    },
28
     SetCustomerInfoNull ({ commit }) {
48
     SetCustomerInfoNull ({ commit }) {
29
       commit('updateInfo', {})
49
       commit('updateInfo', {})
30
     }
50
     }

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

623
       method: 'get',
623
       method: 'get',
624
       url: `${baseUrl}${common}/coupon/:id`
624
       url: `${baseUrl}${common}/coupon/:id`
625
     },
625
     },
626
+    giveCoupon: {
627
+      method: 'post',
628
+      url: `${baseUrl}${common}/coupon/:id/to/:users`
629
+    },
626
   },
630
   },
627
   customerManager: {
631
   customerManager: {
628
     getByTel: {
632
     getByTel: {
629
       method: 'get',
633
       method: 'get',
630
       url: `${baseUrl}${common}/customer/tel/:tel`
634
       url: `${baseUrl}${common}/customer/tel/:tel`
635
+    },
636
+    getCustomerList: { // 获取会员列表
637
+      method: 'get',
638
+      url: `${baseUrl}${common}/customer`
631
     }
639
     }
632
   },
640
   },
633
 }
641
 }