Browse Source

edit room name

ethan 6 years ago
parent
commit
ef965910b1
2 changed files with 66 additions and 7 deletions
  1. 10 0
      src/api/room.js
  2. 56 7
      src/views/room/index.vue

+ 10 - 0
src/api/room.js

65
     }
65
     }
66
   })
66
   })
67
 }
67
 }
68
+
69
+export function resetRoomName(data, query) {
70
+  return request({
71
+    url: `/weChatRooms/${data.room}/wechatUser`,
72
+    method: 'put',
73
+    data: {
74
+      name: query.name
75
+    }
76
+  })
77
+}

+ 56 - 7
src/views/room/index.vue

27
       </el-table-column>
27
       </el-table-column>
28
       <el-table-column align="center" label="操作" width="350">
28
       <el-table-column align="center" label="操作" width="350">
29
         <template slot-scope="scope">
29
         <template slot-scope="scope">
30
-            <router-link to="/room/index/wechatMember/index">
31
-              <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">會員管理</el-button>
32
-            </router-link>       
33
-            <router-link to="/room/index/wechatGameMaster/index">
34
-              <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">客服管理</el-button>
35
-            </router-link>       
30
+          <router-link to="/room/index/wechatMember/index">
31
+            <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">會員管理</el-button>
32
+          </router-link>       
33
+          <router-link to="/room/index/wechatGameMaster/index">
34
+            <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">客服管理</el-button>
35
+          </router-link>
36
+          <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handleEdit(scope.row)">修改</el-button> 
36
         </template>
37
         </template>
37
       </el-table-column>
38
       </el-table-column>
38
     </el-table>
39
     </el-table>
55
       </div>
56
       </div>
56
     </el-dialog>
57
     </el-dialog>
57
 
58
 
59
+    <el-dialog title="名稱修改" :visible.sync="dialogEditFormVisible" :before-close="handleDialogClose" center>
60
+      <el-form :rules="rules" :model="temp" ref="editForm" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
61
+        <el-form-item label="名稱" prop="id">
62
+          <el-input v-model="temp.name"></el-input>
63
+        </el-form-item>
64
+      </el-form>          
65
+      <div slot="footer" class="dialog-footer">
66
+        <el-button @click="handleDialogClose">取 消</el-button>
67
+        <el-button type="primary" @click="editData()">確 定</el-button>
68
+      </div>
69
+    </el-dialog>
58
   </div>
70
   </div>
59
     <router-view></router-view>
71
     <router-view></router-view>
60
   </div>
72
   </div>
63
 <script>
75
 <script>
64
 
76
 
65
 import { mapGetters, mapActions } from 'vuex'
77
 import { mapGetters, mapActions } from 'vuex'
66
-import { fetchWechatRooms, createWeChatRoom } from '@/api/room'
78
+import { fetchWechatRooms, createWeChatRoom, resetRoomName } from '@/api/room'
67
 import waves from '@/directive/waves' // 水波纹指令
79
 import waves from '@/directive/waves' // 水波纹指令
68
 import moment from 'moment-timezone'
80
 import moment from 'moment-timezone'
69
 
81
 
84
         page: 1, 
96
         page: 1, 
85
         limit: 20, 
97
         limit: 20, 
86
       }, 
98
       }, 
99
+      game: {},
87
       rules: {
100
       rules: {
88
         name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
101
         name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
89
       },
102
       },
90
       dialogCreateFormVisible: false,
103
       dialogCreateFormVisible: false,
104
+      dialogEditFormVisible: false,
91
     }
105
     }
92
   },
106
   },
93
   created() {
107
   created() {
110
     getList() {
124
     getList() {
111
       this.listLoading = true
125
       this.listLoading = true
112
       fetchWechatRooms(this.listQuery).then(response => {
126
       fetchWechatRooms(this.listQuery).then(response => {
127
+        console.log(response.data)
113
         this.list = response.data
128
         this.list = response.data
114
         this.total = response.data.length
129
         this.total = response.data.length
115
         this.listLoading = false
130
         this.listLoading = false
120
       this.SetVisible(2)
135
       this.SetVisible(2)
121
       this.SetData({layer:2, data: temp})
136
       this.SetData({layer:2, data: temp})
122
     },
137
     },
138
+    handleEdit(row) {
139
+      this.dialogEditFormVisible = true
140
+      console.log('eeee', row)
141
+      this.game = row
142
+      this.$nextTick(() => {
143
+        this.$refs['editForm'].clearValidate()
144
+      })
145
+    },
146
+    editData() {
147
+      this.$refs['editForm'].validate((valid) => {
148
+        if (valid) {
149
+          const temp = Object.assign({}, this.temp)
150
+          const game = Object.assign({}, this.game)
151
+          resetRoomName(game, temp).then(() => {
152
+            for (const v of this.list) {
153
+              if (v.id === this.temp.id) {
154
+                const index = this.list.indexOf(v)
155
+                this.list.splice(index, 1, this.temp)
156
+                break
157
+              }
158
+            }
159
+            this.dialogEditFormVisible = false
160
+            this.$notify({
161
+              title: '成功',
162
+              message: '操作成功',
163
+              type: 'success',
164
+              duration: 2000
165
+            })
166
+            this.getList()
167
+          })
168
+        }
169
+      })
170
+    },
123
     handleCreate() {
171
     handleCreate() {
124
       //TODO 了解wechat 的 room 關聯
172
       //TODO 了解wechat 的 room 關聯
125
       this.dialogCreateFormVisible = true
173
       this.dialogCreateFormVisible = true
165
     },
213
     },
166
     handleDialogClose() {
214
     handleDialogClose() {
167
       this.dialogCreateFormVisible = false;
215
       this.dialogCreateFormVisible = false;
216
+      this.dialogEditFormVisible = false;
168
       this.temp = {name: ''};
217
       this.temp = {name: ''};
169
     },
218
     },
170
     moment(time) {
219
     moment(time) {