ethan vor 6 Jahren
Ursprung
Commit
ef965910b1
2 geänderte Dateien mit 66 neuen und 7 gelöschten Zeilen
  1. 10 0
      src/api/room.js
  2. 56 7
      src/views/room/index.vue

+ 10 - 0
src/api/room.js

@@ -65,3 +65,13 @@ export function createWechatMember(data, query) {
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,12 +27,13 @@
27 27
       </el-table-column>
28 28
       <el-table-column align="center" label="操作" width="350">
29 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 37
         </template>
37 38
       </el-table-column>
38 39
     </el-table>
@@ -55,6 +56,17 @@
55 56
       </div>
56 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 70
   </div>
59 71
     <router-view></router-view>
60 72
   </div>
@@ -63,7 +75,7 @@
63 75
 <script>
64 76
 
65 77
 import { mapGetters, mapActions } from 'vuex'
66
-import { fetchWechatRooms, createWeChatRoom } from '@/api/room'
78
+import { fetchWechatRooms, createWeChatRoom, resetRoomName } from '@/api/room'
67 79
 import waves from '@/directive/waves' // 水波纹指令
68 80
 import moment from 'moment-timezone'
69 81
 
@@ -84,10 +96,12 @@ export default {
84 96
         page: 1, 
85 97
         limit: 20, 
86 98
       }, 
99
+      game: {},
87 100
       rules: {
88 101
         name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
89 102
       },
90 103
       dialogCreateFormVisible: false,
104
+      dialogEditFormVisible: false,
91 105
     }
92 106
   },
93 107
   created() {
@@ -110,6 +124,7 @@ export default {
110 124
     getList() {
111 125
       this.listLoading = true
112 126
       fetchWechatRooms(this.listQuery).then(response => {
127
+        console.log(response.data)
113 128
         this.list = response.data
114 129
         this.total = response.data.length
115 130
         this.listLoading = false
@@ -120,6 +135,39 @@ export default {
120 135
       this.SetVisible(2)
121 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 171
     handleCreate() {
124 172
       //TODO 了解wechat 的 room 關聯
125 173
       this.dialogCreateFormVisible = true
@@ -165,6 +213,7 @@ export default {
165 213
     },
166 214
     handleDialogClose() {
167 215
       this.dialogCreateFormVisible = false;
216
+      this.dialogEditFormVisible = false;
168 217
       this.temp = {name: ''};
169 218
     },
170 219
     moment(time) {