设置父用户
This commit is contained in:
@@ -30,3 +30,11 @@ export function deleteLbDepartmentUser(id) {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function bindLbDepartmentUserParent(params) {
|
||||
return request({
|
||||
url: '/lbDepartmentUser/bindParentUser',
|
||||
method: 'post',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<span class="selected-tip">已选 {{ parentSelectedRows.length }} 人</span>
|
||||
<el-button @click="parentDialogVisible = false">关闭</el-button>
|
||||
<el-button type="primary" @click="confirmParentSelection">确定</el-button>
|
||||
<el-button type="primary" :loading="parentBindLoading" @click="confirmParentSelection">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@@ -195,6 +195,7 @@
|
||||
<script>
|
||||
import {
|
||||
addLbDepartmentUser,
|
||||
bindLbDepartmentUserParent,
|
||||
deleteLbDepartmentUser,
|
||||
getLbDepartmentUserList,
|
||||
updateLbDepartmentUser
|
||||
@@ -206,6 +207,7 @@ export default {
|
||||
return {
|
||||
loading: false,
|
||||
submitLoading: false,
|
||||
parentBindLoading: false,
|
||||
list: [],
|
||||
total: 0,
|
||||
dialogVisible: false,
|
||||
@@ -217,6 +219,7 @@ export default {
|
||||
parentList: [],
|
||||
parentTotal: 0,
|
||||
parentSelectedRows: [],
|
||||
lastSelectedParentRow: null,
|
||||
queryParams: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
@@ -419,7 +422,18 @@ export default {
|
||||
return params
|
||||
},
|
||||
handleParentSelectionChange(selection) {
|
||||
this.parentSelectedRows = selection
|
||||
if (!selection.length) {
|
||||
this.parentSelectedRows = []
|
||||
this.lastSelectedParentRow = null
|
||||
return
|
||||
}
|
||||
const latestSelected = selection[selection.length - 1]
|
||||
if (selection.length > 1 && this.$refs.parentTable) {
|
||||
this.$refs.parentTable.clearSelection()
|
||||
this.$refs.parentTable.toggleRowSelection(latestSelected, true)
|
||||
}
|
||||
this.parentSelectedRows = [latestSelected]
|
||||
this.lastSelectedParentRow = latestSelected
|
||||
},
|
||||
handleParentQuery() {
|
||||
this.parentQueryParams.current = 1
|
||||
@@ -451,13 +465,45 @@ export default {
|
||||
this.$message.warning('请先勾选上级人员')
|
||||
return
|
||||
}
|
||||
this.$message.success(`已勾选 ${this.parentSelectedRows.length} 位人员`)
|
||||
if (this.parentSelectedRows.length > 1) {
|
||||
this.$message.warning('一次只能选择 1 位上级人员')
|
||||
return
|
||||
}
|
||||
if (!this.currentParentTarget || !this.currentParentTarget.userId) {
|
||||
this.$message.error('未获取到当前子用户信息,请重新打开弹框后重试')
|
||||
return
|
||||
}
|
||||
const selectedParent = this.parentSelectedRows[0]
|
||||
if (!selectedParent || !selectedParent.userId) {
|
||||
this.$message.error('未获取到上级用户ID,请重新选择')
|
||||
return
|
||||
}
|
||||
const tenantId = this.currentParentTarget.tenantId || selectedParent.tenantId || ''
|
||||
if (!tenantId) {
|
||||
this.$message.error('未获取到租户ID,无法绑定')
|
||||
return
|
||||
}
|
||||
this.parentBindLoading = true
|
||||
bindLbDepartmentUserParent({
|
||||
parentUserId: selectedParent.userId,
|
||||
parentUserName: selectedParent.name || undefined,
|
||||
childUserId: this.currentParentTarget.userId,
|
||||
childUserName: this.currentParentTarget.name || undefined,
|
||||
tenantId
|
||||
}).then((res) => {
|
||||
this.$message.success((res && res.message) || '绑定上级成功')
|
||||
this.parentDialogVisible = false
|
||||
this.fetchList()
|
||||
}).finally(() => {
|
||||
this.parentBindLoading = false
|
||||
})
|
||||
},
|
||||
resetParentDialog() {
|
||||
this.parentList = []
|
||||
this.parentTotal = 0
|
||||
this.parentSelectedRows = []
|
||||
this.lastSelectedParentRow = null
|
||||
this.parentBindLoading = false
|
||||
this.currentParentTarget = null
|
||||
this.parentQueryParams = {
|
||||
current: 1,
|
||||
|
||||
Reference in New Issue
Block a user