Browse Source

券赠送客户

wangfei 6 years ago
parent
commit
59df1a8369

+ 63
- 14
src/pages/system/cardAndCouponManager/couponManager/index.vue View File

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