This commit is contained in:
xing 2020-06-18 11:42:43 +08:00
parent dfed24cdfb
commit 3018a0d1e0

View File

@ -29,7 +29,7 @@
<el-table-column width="100" label="状态" >
<template slot-scope="scope">
<el-switch
v-model="scope.row.mg_state" @change="changeState">
v-model="scope.row.mg_state" @change="changeState(scope.row)">
</el-switch>
</template>
</el-table-column>
@ -82,8 +82,13 @@ export default {
this.queryInfo.pagenum = val
this.getUserList()
},
changeState (state) {
console.log(state)
async changeState (row) {
const { data: res } = await this.$http.put(`users/${row.id}/state/${row.mg_state}`)
if (res.meta.code !== 200) {
row.mg_state = !row.mg_state
return this.$message.error(res.meta.msg)
}
this.$message.success(res.meta.msg)
},
async getUserList () {
const { data: res } = await this.$http.get('users', {