diff --git a/src/api/personnel/group.js b/src/api/personnel/group.js index c9c0627..97820e6 100644 --- a/src/api/personnel/group.js +++ b/src/api/personnel/group.js @@ -107,3 +107,11 @@ export function syncOpenLdapDeptsApi(data) { data }) } +// 同步数据库的分组到ldap +export function syncSqlGroups(data) { + return request({ + url: '/api/group/syncSqlGroups', + method: 'post', + data + }) +} \ No newline at end of file diff --git a/src/api/personnel/user.js b/src/api/personnel/user.js index 0b3a46e..e6933dd 100644 --- a/src/api/personnel/user.js +++ b/src/api/personnel/user.js @@ -96,3 +96,12 @@ export function syncOpenLdapUsersApi(data) { data }) } + +// 同步Sql中的用户到ldap +export function syncSqlUsers(data) { + return request({ + url: '/api/user/syncSqlUsers', + method: 'post', + data + }) +} diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue index c87cd1b..ac414fd 100644 --- a/src/layout/components/AppMain.vue +++ b/src/layout/components/AppMain.vue @@ -55,7 +55,7 @@ export default { bottom: 0; left: 0; right: 0; - line-height: 45px; + line-height: 58px; text-align: center; border-top: 1px dashed #dcdfe6; } diff --git a/src/views/personnel/group/index.vue b/src/views/personnel/group/index.vue index e9e72f5..35cc4b9 100644 --- a/src/views/personnel/group/index.vue +++ b/src/views/personnel/group/index.vue @@ -3,10 +3,16 @@ - + - + + + + + + + 查询 @@ -20,18 +26,21 @@ 批量删除 + + 批量同步 +
- 同步原ldap部门 + 同步原ldap部门 - 同步钉钉部门 + 同步钉钉部门 - 同步飞书部门 + 同步飞书部门 - 同步企业微信部门 + 同步企业微信部门
@@ -56,6 +65,11 @@ + + + + + @@ -66,7 +80,10 @@ - + + + + import Treeselect from '@riophae/vue-treeselect' import '@riophae/vue-treeselect/dist/vue-treeselect.css' -import { getGroupTree, groupAdd, groupUpdate, groupDel, syncDingTalkDeptsApi, syncWeComDeptsApi, syncFeiShuDeptsApi, syncOpenLdapDeptsApi } from '@/api/personnel/group' +import { getGroupTree, groupAdd, groupUpdate, groupDel, syncDingTalkDeptsApi, syncWeComDeptsApi, syncFeiShuDeptsApi, syncOpenLdapDeptsApi, syncSqlGroups } from '@/api/personnel/group' import { Message } from 'element-ui' export default { @@ -133,6 +150,7 @@ export default { params: { groupName: undefined, remark: undefined, + syncState: undefined, pageNum: 1, pageSize: 1000// 平常百姓人家应该不会有这么多数据吧,后台限制最大单次获取1000条 }, @@ -154,7 +172,8 @@ export default { ID: '', groupName: '', parentId: 0, - groupType: undefined, + syncState:1, + groupType: '', remark: '' }, dialogFormRules: { @@ -211,11 +230,11 @@ export default { this.getTableData() }, methods: { - // 查询 + // // 查询 search() { // 初始化表格数据 this.infoTableData = JSON.parse(JSON.stringify(this.tableData)) - this.infoTableData = this.deal(this.infoTableData, node => node.groupName.includes(this.params.groupName) || node.remark.includes(this.params.remark)) + this.infoTableData = this.deal(this.infoTableData, node => node.groupName.includes(this.params.groupName) || node.remark.includes(this.params.remark) || node.syncState.toString().includes(this.params.syncState)) }, resetData() { this.infoTableData = JSON.parse(JSON.stringify(this.tableData)) @@ -363,6 +382,34 @@ export default { }) }) }, + // 批量同步 + batchSync() { + this.$confirm('此操作批量同步数据到Ldap, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(async res => { + this.loading = true + const groupIds = [] + this.multipleSelection.forEach(x => { + groupIds.push(x.ID) + }) + try { + await syncSqlGroups({ groupIds: groupIds }).then(res => { + this.judgeResult(res) + }) + } finally { + this.loading = false + } + this.getTableData() + }).catch(() => { + Message({ + showClose: true, + type: 'info', + message: '已取消同步' + }) + }) + }, // 表格多选 handleSelectionChange(val) { @@ -381,6 +428,18 @@ export default { } this.getTableData() }, + // 单个同步 + async singleSync(Id) { + this.loading = true + try { + await syncSqlGroups({ groupIds: [Id] }).then(res =>{ + this.judgeResult(res) + }) + } finally { + this.loading = false + } + this.getTableData() + }, // 分页 handleSizeChange(val) { diff --git a/src/views/personnel/user/index.vue b/src/views/personnel/user/index.vue index 27c5a85..2f04294 100644 --- a/src/views/personnel/user/index.vue +++ b/src/views/personnel/user/index.vue @@ -3,19 +3,25 @@ - + - + + + + - + - - + + + + + 查询 @@ -26,18 +32,21 @@ 批量删除 + + 批量同步 +
- 同步原ldap用户信息 + 同步原ldap用户信息 - 同步钉钉用户信息 + 同步钉钉用户信息 - 同步飞书用户信息 + 同步飞书用户信息 - 同步企业微信用户信息 + 同步企业微信用户信息
@@ -67,7 +76,7 @@ - + @@ -201,7 +215,7 @@ import JSEncrypt from 'jsencrypt' import Treeselect from '@riophae/vue-treeselect' import '@riophae/vue-treeselect/dist/vue-treeselect.css' -import { getUsers, createUser, updateUserById, batchDeleteUserByIds, changeUserStatus, syncDingTalkUsersApi, syncWeComUsersApi, syncFeiShuUsersApi, syncOpenLdapUsersApi } from '@/api/personnel/user' +import { getUsers, createUser, updateUserById, batchDeleteUserByIds, changeUserStatus, syncDingTalkUsersApi, syncWeComUsersApi, syncFeiShuUsersApi, syncOpenLdapUsersApi, syncSqlUsers } from '@/api/personnel/user' import { getRoles } from '@/api/system/role' import { getGroupTree } from '@/api/personnel/group' import { Message } from 'element-ui' @@ -236,6 +250,7 @@ export default { username: '', nickname: '', status: '', + syncState: '', mobile: '', pageNum: 1, pageSize: 10 @@ -604,6 +619,34 @@ export default { }) }) }, + // 批量同步 + batchSync() { + this.$confirm('此操作批量将数据库的用户同步到Ldap, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(async res => { + this.loading = true + const userIds = [] + this.multipleSelection.forEach(x => { + userIds.push(x.ID) + }) + try { + await syncSqlUsers({ userIds: userIds }).then(res =>{ + this.judgeResult(res) + }) + } finally { + this.loading = false + } + this.getTableData() + }).catch(() => { + Message({ + showClose: true, + type: 'info', + message: '已取消同步' + }) + }) + }, // 监听 switch 开关 状态改变 async userStateChanged(userInfo) { @@ -634,6 +677,18 @@ export default { } this.getTableData() }, + // 单个同步 + async singleSync(Id) { + this.loading = true + try { + await syncSqlUsers({ userIds: [Id] }).then(res =>{ + this.judgeResult(res) + }) + } finally { + this.loading = false + } + this.getTableData() + }, showPwd() { if (this.passwordType === 'password') {