Browse Source

add directory

ethan 6 years ago
parent
commit
a7bfe82467
4 changed files with 244 additions and 13 deletions
  1. 25 0
      src/api/directory.js
  2. 41 11
      src/router/index.js
  3. 2 2
      src/utils/point.js
  4. 176 0
      src/views/directory/index.vue

+ 25 - 0
src/api/directory.js

1
+import request from '@/utils/request'
2
+
3
+export function createDirectory(data) {
4
+  return request({
5
+    url: '/weChatDirectories',
6
+    method: 'post',
7
+    data: {
8
+      name: data.name,
9
+      wechatId: data.wechatId,
10
+      phone: data.phone
11
+    }
12
+  })
13
+}
14
+
15
+export function fetchDirectory(query) {
16
+  return request({
17
+    url: `/weChatDirectories`,
18
+    method: 'get',
19
+    params: {
20
+      name: query.name,
21
+      limit: query.limit,
22
+      offset: (query.page - 1) * query.limit
23
+    }
24
+  })
25
+}

+ 41 - 11
src/router/index.js

57
         // redirect: '/round/index/gambleMember/index',
57
         // redirect: '/round/index/gambleMember/index',
58
         meta: {
58
         meta: {
59
           title: '房間管理',
59
           title: '房間管理',
60
-          icon: 'form'
60
+          icon: 'form',
61
+          noCache: true
61
           // role: ['dd']
62
           // role: ['dd']
62
         },
63
         },
63
         children: [
64
         children: [
67
             component: _import('room/wechatMember/index'),
68
             component: _import('room/wechatMember/index'),
68
             hidden: true,
69
             hidden: true,
69
             meta: {
70
             meta: {
70
-              title: '微信會員'
71
+              title: '微信會員',
72
+              noCache: true
71
               // role: ['dd']
73
               // role: ['dd']
72
             },
74
             },
73
             children: [
75
             children: [
77
                 component: _import('room/gameHistory/index'),
79
                 component: _import('room/gameHistory/index'),
78
                 hidden: true,
80
                 hidden: true,
79
                 meta: {
81
                 meta: {
80
-                  title: '歷史紀錄'
82
+                  title: '歷史紀錄',
83
+                  noCache: true
81
                   // role: ['dd']
84
                   // role: ['dd']
82
                 },
85
                 },
83
                 children: [
86
                 children: [
87
                     component: _import('room/detail/index'),
90
                     component: _import('room/detail/index'),
88
                     hidden: true,
91
                     hidden: true,
89
                     meta: {
92
                     meta: {
90
-                      title: '詳細記錄'
93
+                      title: '詳細記錄',
94
+                      noCache: true
91
                       // role: ['dd']
95
                       // role: ['dd']
92
                     }
96
                     }
93
                   }
97
                   }
99
                 component: _import('room/chipsHistory/index'),
103
                 component: _import('room/chipsHistory/index'),
100
                 hidden: true,
104
                 hidden: true,
101
                 meta: {
105
                 meta: {
102
-                  title: '上下分紀錄'
106
+                  title: '上下分紀錄',
107
+                  noCache: true
103
                   // role: ['dd']
108
                   // role: ['dd']
104
                 }
109
                 }
105
               }
110
               }
110
             component: _import('room/wechatGameMaster/index'),
115
             component: _import('room/wechatGameMaster/index'),
111
             hidden: true,
116
             hidden: true,
112
             meta: {
117
             meta: {
113
-              title: '微信客服'
118
+              title: '微信客服',
119
+              noCache: true
114
               // role: ['dd']
120
               // role: ['dd']
115
             }
121
             }
116
           }
122
           }
129
         component: _import('gambleGameBucket/index'),
135
         component: _import('gambleGameBucket/index'),
130
         meta: {
136
         meta: {
131
           title: '每場紀錄',
137
           title: '每場紀錄',
132
-          icon: 'table'
138
+          icon: 'table',
139
+          noCache: true
133
           // role: ['dd']
140
           // role: ['dd']
134
         },
141
         },
135
         children: [
142
         children: [
139
             component: _import('gambleGameBucket/detail/index'),
146
             component: _import('gambleGameBucket/detail/index'),
140
             hidden: true,
147
             hidden: true,
141
             meta: {
148
             meta: {
142
-              title: '詳細紀錄'
149
+              title: '詳細紀錄',
150
+              noCache: true
143
               // role: ['dd']
151
               // role: ['dd']
144
             }
152
             }
145
           }
153
           }
158
         component: _import('agnetManagement/index'),
166
         component: _import('agnetManagement/index'),
159
         meta: {
167
         meta: {
160
           title: '代理商管理',
168
           title: '代理商管理',
161
-          icon: 'table'
169
+          icon: 'table',
170
+          noCache: true
162
           // role: ['dd']
171
           // role: ['dd']
163
         },
172
         },
164
         children: [
173
         children: [
168
             component: _import('agnetManagement/gambleMemberManagement/index'),
177
             component: _import('agnetManagement/gambleMemberManagement/index'),
169
             hidden: true,
178
             hidden: true,
170
             meta: {
179
             meta: {
171
-              title: '會員管理'
180
+              title: '會員管理',
181
+              noCache: true
172
               // role: ['dd']
182
               // role: ['dd']
173
             },
183
             },
174
             children: [
184
             children: [
178
                 component: _import('room/gameHistory/index'),
188
                 component: _import('room/gameHistory/index'),
179
                 hidden: true,
189
                 hidden: true,
180
                 meta: {
190
                 meta: {
181
-                  title: '歷史紀錄'
191
+                  title: '歷史紀錄',
192
+                  noCache: true
182
                   // role: ['dd']
193
                   // role: ['dd']
183
                 }
194
                 }
184
               }
195
               }
207
       }
218
       }
208
     ]
219
     ]
209
   },
220
   },
221
+  {
222
+    path: '/directory',
223
+    component: Layout,
224
+    redirect: 'directory',
225
+    name: 'Directory',
226
+    children: [
227
+      {
228
+        path: 'directory',
229
+        name: 'directory',
230
+        component: _import('directory/index'),
231
+        meta: {
232
+          title: '通訊錄',
233
+          icon: 'table',
234
+          noCache: true
235
+          // role: ['dd']
236
+        }
237
+      }
238
+    ]
239
+  },
210
   // {
240
   // {
211
   //   path: '/example',
241
   //   path: '/example',
212
   //   component: Layout,
242
   //   component: Layout,

+ 2 - 2
src/utils/point.js

7
   totalPoints = Number(totalPoints)
7
   totalPoints = Number(totalPoints)
8
   if (point1 === 0 && point2 === 0) {
8
   if (point1 === 0 && point2 === 0) {
9
     return `白板對`
9
     return `白板對`
10
+  } else if (point1 === -1 || point2 === -1) {
11
+    return `莊家通賠`
10
   } else if (point1 === point2) {
12
   } else if (point1 === point2) {
11
     return `對子`
13
     return `對子`
12
   } else if (point1 + point2 === 10) {
14
   } else if (point1 + point2 === 10) {
13
     return `尻`
15
     return `尻`
14
   } else if (point1 === 0 || point2 === 0) {
16
   } else if (point1 === 0 || point2 === 0) {
15
     return `${point1 === 0 ? nzhhk.encodeS(`${point2}`) : nzhhk.encodeS(`${point1}`)}點半`
17
     return `${point1 === 0 ? nzhhk.encodeS(`${point2}`) : nzhhk.encodeS(`${point1}`)}點半`
16
-  } else if (point1 === -1 || point2 === -1) {
17
-    return `莊家通賠`
18
   } else {
18
   } else {
19
     return `${nzhhk.encodeS(`${totalPoints}`)}點`
19
     return `${nzhhk.encodeS(`${totalPoints}`)}點`
20
   }
20
   }

+ 176 - 0
src/views/directory/index.vue

1
+<template>
2
+  <div class="app-container calendar-list-container">
3
+    <div  v-show="visible.firstLayer">
4
+      <div class="app-container">
5
+        <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="名稱" v-model="listQuery.name">
6
+        </el-input>
7
+        <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜尋</el-button>
8
+        <el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">創建聯絡人</el-button>
9
+      </div>
10
+      <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
11
+        style="width: 100%">
12
+        <!-- <el-table-column align="center" label='ID' >
13
+          <template slot-scope="scope">
14
+            {{scope.row.GambleMember.id}}
15
+          </template>
16
+        </el-table-column> -->
17
+        <el-table-column label="名稱" align="center">
18
+          <template slot-scope="scope">
19
+            {{scope.row.name}}
20
+          </template>
21
+        </el-table-column>
22
+        <el-table-column label="微信ID" align="center">
23
+          <template slot-scope="scope">
24
+            {{scope.row.wechatId}}
25
+          </template>
26
+        </el-table-column>
27
+          <el-table-column label="電話" align="center">
28
+            <template slot-scope="scope">
29
+              <span>{{scope.row.phone}}</span>
30
+            </template>
31
+        </el-table-column>
32
+        <el-table-column align="center" label="操作" width="450">
33
+        </el-table-column>
34
+      </el-table>
35
+
36
+      <div v-show="!listLoading" class="pagination-container">
37
+        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
38
+          :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
39
+        </el-pagination>
40
+      </div>
41
+
42
+      <el-dialog title="創建聯絡人" :visible.sync="dialogCreateFormVisible" :before-close="handleDialogClose" center>
43
+        <el-form :rules="rules" ref="createForm" :model="createFormData" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
44
+          <el-form-item label="名稱" prop="name">
45
+            <el-input v-model="createFormData.name"></el-input>
46
+          </el-form-item>
47
+          <el-form-item label="微信 ID">
48
+            <el-input v-model="createFormData.wechatId"></el-input>
49
+          </el-form-item>
50
+            <el-form-item label="電話">
51
+            <el-input v-model="createFormData.phone"></el-input>
52
+          </el-form-item>
53
+        </el-form>          
54
+        <div slot="footer" class="dialog-footer">
55
+          <el-button @click="handleDialogClose">取 消</el-button>
56
+          <el-button type="primary" @click="createData">確 定</el-button>
57
+        </div>
58
+      </el-dialog>
59
+    </div>
60
+    <router-view></router-view>
61
+  </div>
62
+</template>
63
+
64
+<script>
65
+
66
+import { mapGetters, mapActions } from 'vuex'
67
+import { createDirectory, fetchDirectory } from '@/api/directory'
68
+import waves from '@/directive/waves' // 水波纹指令
69
+import moment from 'moment-timezone'
70
+import _ from 'lodash'
71
+import { Decimal } from 'decimal.js';
72
+
73
+export default {
74
+  directives: {
75
+    waves
76
+  },
77
+  data() {
78
+    return {
79
+      list: [],
80
+      total: null,
81
+      listLoading: true,
82
+      listQuery: {
83
+        page: 1,
84
+        limit: 20,
85
+        name: '',
86
+      },
87
+      dialogCreateFormVisible: false,
88
+      dialogStatus: '',
89
+      // agent: {},
90
+      rules: {
91
+        // rewardChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],        
92
+        // depositChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],                
93
+        // chips: [{ pattern: /^(0|[1-9][0-9]*)$/, required: true, message: '請輸入整數', trigger: 'change' }],
94
+        // name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
95
+      },
96
+      createFormData: {
97
+        name: '',
98
+        wechatId: '',
99
+        phone: ''
100
+      }
101
+    }
102
+  },
103
+  created() {
104
+    this.SetVisible(1)
105
+    this.getList()
106
+  },
107
+  computed: {
108
+    ...mapGetters([
109
+      'visible',
110
+      'data',
111
+    ])
112
+  },
113
+  methods: {
114
+    ...mapActions([
115
+      'SetVisible',
116
+      'SetData',
117
+    ]),
118
+    getList() {
119
+      this.listLoading = true
120
+      fetchDirectory(this.listQuery).then(response => {
121
+        this.list = response.data.rows
122
+        this.total = response.data.count
123
+        console.log('res', response)
124
+      })
125
+      this.listLoading = false
126
+    },
127
+    resetCreateData() {
128
+      this.createFormData = {
129
+        id: undefined,
130
+        name: '',
131
+        wechatId: '',
132
+        phone: ''
133
+      }
134
+    },
135
+    handleCreate() {
136
+      this.resetCreateData()
137
+      this.dialogCreateFormVisible = true
138
+      this.$nextTick(() => {
139
+        this.$refs['createForm'].clearValidate()
140
+      })
141
+    },
142
+    createData() {
143
+      this.$refs['createForm'].validate((valid) => {
144
+        if (valid) {
145
+          createDirectory(this.createFormData).then((response) => {
146
+            let user = response.data
147
+            this.list.unshift(user)
148
+            this.dialogCreateFormVisible = false         
149
+            this.$notify({
150
+              title: '成功',
151
+              message: '創建成功',
152
+              type: 'success',
153
+              duration: 2000
154
+            })
155
+          })
156
+        }
157
+      })
158
+    },
159
+    handleFilter() {
160
+      this.listQuery.page = 1
161
+      this.getList()
162
+    },
163
+    handleSizeChange(val) {
164
+      this.listQuery.limit = val
165
+      this.getList()
166
+    },
167
+    handleCurrentChange(val) {
168
+      this.listQuery.page = val
169
+      this.getList()
170
+    },
171
+    handleDialogClose() {
172
+      this.dialogCreateFormVisible = false;
173
+    },
174
+  },
175
+}
176
+</script>