许成详 преди 6 години
родител
ревизия
6f61e648f6
променени са 4 файла, в които са добавени 102 реда и са изтрити 15 реда
  1. 61
    15
      src/pages/system/cardAndCouponManager/couponManager/index.vue
  2. 13
    0
      src/store/coupon/coupon.js
  3. 20
    0
      src/store/customer/customer.js
  4. 8
    0
      src/util/api.js

+ 61
- 15
src/pages/system/cardAndCouponManager/couponManager/index.vue Целия файл

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

+ 13
- 0
src/store/coupon/coupon.js Целия файл

@@ -64,5 +64,18 @@ export default {
64 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 Целия файл

@@ -5,11 +5,15 @@ export default {
5 5
   namespaced: true,
6 6
   state: {
7 7
     customer: {},
8
+    customers: {},
8 9
   },
9 10
   mutations: {
10 11
     updateInfo (state, payload) {
11 12
       state.customer = payload || {}
12 13
     },
14
+    updateList (state, payload) {
15
+      state.customers = payload || {}
16
+    }
13 17
   },
14 18
   actions: {
15 19
     GetCustomerByTel ({ commit }, { tel }) {
@@ -25,6 +29,22 @@ export default {
25 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 48
     SetCustomerInfoNull ({ commit }) {
29 49
       commit('updateInfo', {})
30 50
     }

+ 8
- 0
src/util/api.js Целия файл

@@ -623,11 +623,19 @@ const $api = {
623 623
       method: 'get',
624 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 631
   customerManager: {
628 632
     getByTel: {
629 633
       method: 'get',
630 634
       url: `${baseUrl}${common}/customer/tel/:tel`
635
+    },
636
+    getCustomerList: { // 获取会员列表
637
+      method: 'get',
638
+      url: `${baseUrl}${common}/customer`
631 639
     }
632 640
   },
633 641
 }