Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/api/personnel/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export function batchDeleteUserByIds(data) {
data
})
}

// 更改用户状态(已完成)
export function changeUserStatus(data) {
return request({
url: '/api/user/changeUserStatus',
method: 'post',
data
})
}

// 同步钉钉用户信息
export function syncDingTalkUsersApi(data) {
return request({
Expand Down
32 changes: 28 additions & 4 deletions src/views/personnel/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@
<el-table-column show-overflow-tooltip sortable prop="username" label="用户名" />
<el-table-column show-overflow-tooltip sortable prop="nickname" label="中文名" />
<el-table-column show-overflow-tooltip sortable prop="givenName" label="花名" />
<el-table-column show-overflow-tooltip sortable prop="status" label="状态" align="center">
<!-- 使用按钮方式展示,以后改成布尔参数比较合适 -->
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-tag size="small" :type="scope.row.status === 1 ? 'success':'danger'" disable-transitions>{{ scope.row.status === 1 ? '正常':'禁用' }}</el-tag>
<el-switch v-model="scope.row.status" :active-value='1' :inactive-value='2' @change="userStateChanged(scope.row)"></el-switch>
</template>
</el-table-column>
<!-- <el-table-column show-overflow-tooltip sortable prop="status" label="状态" align="center">
<template slot-scope="scope">
<el-tag size="small" :type="scope.row.status === 1 ? 'success':'danger'" disable-transitions>{{ scope.row.status === 1 ? '正常':'禁用' }}</el-tag>
</template>
</el-table-column> -->
<el-table-column show-overflow-tooltip sortable prop="mail" label="邮箱" />
<el-table-column show-overflow-tooltip sortable prop="mobile" label="手机号" />
<el-table-column show-overflow-tooltip sortable prop="jobNumber" label="工号" />
Expand Down Expand Up @@ -195,7 +201,7 @@
import JSEncrypt from 'jsencrypt'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { getUsers, createUser, updateUserById, batchDeleteUserByIds, syncDingTalkUsersApi, syncWeComUsersApi, syncFeiShuUsersApi, syncOpenLdapUsersApi } from '@/api/personnel/user'
import { getUsers, createUser, updateUserById, batchDeleteUserByIds, changeUserStatus, syncDingTalkUsersApi, syncWeComUsersApi, syncFeiShuUsersApi, syncOpenLdapUsersApi } from '@/api/personnel/user'
import { getRoles } from '@/api/system/role'
import { getGroupTree } from '@/api/personnel/group'

Expand Down Expand Up @@ -323,7 +329,11 @@ wLXapv+ZfsjG7NgdawIDAQAB
// 删除按钮弹出框
popoverVisible: false,
// 表格多选
multipleSelection: []
multipleSelection: [],
changeUserStatusFormData: {
id: '',
status: '',
},
}
},
created() {
Expand Down Expand Up @@ -600,6 +610,20 @@ wLXapv+ZfsjG7NgdawIDAQAB
})
},

// 监听 switch 开关 状态改变
async userStateChanged(userInfo) {
this.changeUserStatusFormData.id = userInfo.ID
this.changeUserStatusFormData.status = userInfo.status

const { code } = await changeUserStatus(this.changeUserStatusFormData)

if (code !== 0) {
userInfo.status = !userInfo.status
return this.$message.error('更新用户状态失败')
}
this.$message.success('更新用户状态成功')
},

// 表格多选
handleSelectionChange(val) {
this.multipleSelection = val
Expand Down