Ver Código Fonte

add agent management

Unknown 7 anos atrás
pai
commit
2faf94ff65

+ 27 - 0
src/api/agnetManagement.js

@@ -0,0 +1,27 @@
1
+import request from '@/utils/request'
2
+
3
+export function fetchList(query) {
4
+  return request({
5
+    url: '/agents',
6
+    method: 'get'
7
+    // params: {
8
+    //   limit: query.limit,
9
+    //   offset: (query.page - 1) * query.limit,
10
+    //   name: query.name,
11
+    //   chipsSort: query.chipsSort,
12
+    //   updatedSort: query.updatedSort
13
+    // }
14
+  })
15
+}
16
+
17
+export function createAgent(data) {
18
+  return request({
19
+    url: '/agents',
20
+    method: 'post',
21
+    data: {
22
+      name: data.name,
23
+      feeRatio: data.feeRatio
24
+    }
25
+  })
26
+}
27
+

+ 17 - 0
src/router/index.js

@@ -126,6 +126,23 @@ export const constantRouterMap = [
126 126
       }
127 127
     ]
128 128
   },
129
+  {
130
+    path: '/agent',
131
+    component: Layout,
132
+    redirect: '/agent/index',
133
+    children: [
134
+      {
135
+        path: 'index',
136
+        name: 'AgentManagement',
137
+        component: _import('agnetManagement/index'),
138
+        meta: {
139
+          title: '代理商管理',
140
+          icon: 'table'
141
+          // role: ['dd']
142
+        }
143
+      }
144
+    ]
145
+  },
129 146
   // {
130 147
   //   path: '/example',
131 148
   //   component: Layout,

+ 165 - 0
src/views/agnetManagement/index.vue

@@ -0,0 +1,165 @@
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.id}}
15
+        </template>
16
+      </el-table-column>
17
+      <el-table-column label="名稱" align="center">
18
+        <template slot-scope="scope">
19
+          {{scope.row.GambleMember.name}}
20
+        </template>
21
+      </el-table-column>
22
+      <el-table-column label="抽水%" align="center">
23
+        <template slot-scope="scope">
24
+          {{scope.row.feeRatio}}
25
+        </template>
26
+      </el-table-column>
27
+    </el-table>
28
+
29
+    <div v-show="!listLoading" class="pagination-container">
30
+      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
31
+        :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
32
+      </el-pagination>
33
+    </div>
34
+
35
+    <el-dialog title="創建代理商" :visible.sync="dialogCreateFormVisible" :before-close="handleDialogClose" center>
36
+        <el-form :rules="rules" ref="createForm" :model="createFormData" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
37
+          <el-form-item label="名稱" prop="name">
38
+            <el-input v-model="createFormData.name"></el-input>
39
+          </el-form-item>
40
+          <el-form-item label="抽水 %" prop="feeRatio">
41
+            <el-input v-model="createFormData.feeRatio"></el-input>
42
+          </el-form-item>
43
+        </el-form>          
44
+        <div slot="footer" class="dialog-footer">
45
+          <el-button @click="handleDialogClose">取 消</el-button>
46
+          <el-button type="primary" @click="createData">確 定</el-button>
47
+        </div>
48
+    </el-dialog>
49
+  </div>
50
+    <router-view :member="member"></router-view>
51
+  </div>
52
+</template>
53
+
54
+<script>
55
+
56
+import { mapGetters, mapActions } from 'vuex'
57
+import { fetchList, createAgent } from '@/api/agnetManagement'
58
+import waves from '@/directive/waves' // 水波纹指令
59
+
60
+export default {
61
+  directives: {
62
+    waves
63
+  },
64
+  data() {
65
+    return {
66
+      list: null,
67
+      total: null,
68
+      listLoading: true,
69
+      listQuery: {
70
+        page: 1,
71
+        limit: 20,
72
+      },
73
+      dialogCreateFormVisible: false,
74
+      dialogStatus: '',
75
+      member: {},
76
+      rules: {
77
+        // rewardChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],        
78
+        // depositChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],                
79
+        // chips: [{ pattern: /^(0|[1-9][0-9]*)$/, required: true, message: '請輸入整數', trigger: 'change' }],
80
+        // name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
81
+      },
82
+      createFormData: {
83
+        name: '',
84
+        feeRatio: '',
85
+      }
86
+    }
87
+  },
88
+  created() {
89
+    this.SetVisible(1)
90
+    this.getList()
91
+  },
92
+  computed: {
93
+    ...mapGetters([
94
+      'visible'
95
+    ])
96
+  },
97
+  methods: {
98
+    ...mapActions([
99
+      'SetVisible'
100
+    ]),
101
+    getList() {
102
+      this.listLoading = true
103
+      fetchList(this.listQuery).then(response => {
104
+        this.list = response.data.rows
105
+        console.log(this.list)
106
+        this.total = response.data.count
107
+        this.listLoading = false
108
+      })
109
+    },
110
+    resetCreateData() {
111
+      this.temp = {
112
+        id: undefined,
113
+        name: '',
114
+        chips: '',
115
+        depositChips: ''
116
+      }
117
+    },
118
+    handleCreate() {
119
+      this.resetCreateData()
120
+      this.dialogCreateFormVisible = true
121
+      this.$nextTick(() => {
122
+        this.$refs['createForm'].clearValidate()
123
+      })
124
+    },
125
+    createData() {
126
+      this.$refs['createForm'].validate((valid) => {
127
+        if (valid) {
128
+          createAgent(this.createFormData).then((response) => {
129
+            const agent = response.data.gambleAgentSetting;
130
+            agent.GambleMember = response.data.agent
131
+            this.list.unshift(agent)
132
+            this.dialogCreateFormVisible = false         
133
+            this.$notify({
134
+              title: '成功',
135
+              message: '創建成功',
136
+              type: 'success',
137
+              duration: 2000
138
+            })
139
+          })
140
+        }
141
+      })
142
+    },
143
+    handlePage(row) {
144
+      const temp = Object.assign({}, row) // copy obj
145
+      this.SetVisible(3)
146
+      this.member = temp
147
+    },
148
+    handleFilter() {
149
+      this.listQuery.page = 1
150
+      this.getList()
151
+    },
152
+    handleSizeChange(val) {
153
+      this.listQuery.limit = val
154
+      this.getList()
155
+    },
156
+    handleCurrentChange(val) {
157
+      this.listQuery.page = val
158
+      this.getList()
159
+    },
160
+    handleDialogClose() {
161
+      this.dialogCreateFormVisible = false;
162
+    },
163
+  },
164
+}
165
+</script>

+ 1 - 27
src/views/room/gambleMember/index.vue

@@ -13,7 +13,6 @@
13 13
         </el-option>
14 14
       </el-select>
15 15
       <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜尋</el-button>
16
-      <!-- <el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">創建</el-button> -->
17 16
     </div>
18 17
     <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
19 18
       style="width: 100%">
@@ -143,7 +142,7 @@ export default {
143 142
         // chips: [{ pattern: /^(0|[1-9][0-9]*)$/, required: true, message: '請輸入整數', trigger: 'change' }],
144 143
         // name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
145 144
       },
146
-      activeName: 'deposit'
145
+      activeName: 'deposit',
147 146
     }
148 147
   },
149 148
   created() {
@@ -211,31 +210,6 @@ export default {
211 210
         depositChips: ''
212 211
       }
213 212
     },
214
-    // handleCreate() {
215
-    //   this.resetTemp()
216
-    //   this.dialogStatus = 'create'
217
-    //   this.dialogFormVisible = true
218
-    //   this.$nextTick(() => {
219
-    //     this.$refs['dataForm'].clearValidate()
220
-    //   })
221
-    // },
222
-    // createData() {
223
-    //   this.$refs['dataForm'].validate((valid) => {
224
-    //     if (valid) {
225
-    //       createGambleMember(this.temp).then((response) => {
226
-    //         this.list.unshift(response.data)
227
-    //         this.dialogFormVisible = false
228
-    //         this.activeName = 'depoist';            
229
-    //         this.$notify({
230
-    //           title: '成功',
231
-    //           message: '創建成功',
232
-    //           type: 'success',
233
-    //           duration: 2000
234
-    //         })
235
-    //       })
236
-    //     }
237
-    //   })
238
-    // },
239 213
     handlePage(row) {
240 214
       const temp = Object.assign({}, row) // copy obj
241 215
       this.SetVisible(3)