人员业务配置-优化

This commit is contained in:
bb_pan 2025-07-23 10:58:24 +08:00
parent 0674d847ad
commit d33bdca42f
1 changed files with 83 additions and 225 deletions

View File

@ -89,26 +89,10 @@
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleBind">绑定</el-button>
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleBind"
>
绑定
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="warning" plain icon="el-icon-minus" size="mini" @click="handleNoBind">解绑</el-button>
type="warning"
plain
icon="el-icon-minus"
size="mini"
@click="handleNoBind"
>
解绑
</el-button>
</el-col> </el-col>
<!-- <el-col :span="1.5"> <!-- <el-col :span="1.5">
<el-button <el-button
@ -310,21 +294,10 @@ export default {
} }
}, },
created() { created() {
// this.getInfo()
this.getTreeData() this.getTreeData()
this.getTreeDataTwo() this.getTreeDataTwo()
// this.getKeeperDataList();
// setTimeout(()=>{
// this.getList();
// },200)
}, },
methods: { methods: {
// getInfo() {
// getInfo().then((res) => {
// console.log(res, 'companyId----')
// this.companyId = res.user.companyId
// })
// },
selectFirstNode() { selectFirstNode() {
const firstNode = this.$refs.treeTwo.getNode(1) const firstNode = this.$refs.treeTwo.getNode(1)
if (firstNode) { if (firstNode) {
@ -341,9 +314,6 @@ export default {
if (node.data.level == 99) { if (node.data.level == 99) {
iconClass = 'el-icon-user-solid' iconClass = 'el-icon-user-solid'
} }
// else if (node.type === 'file') {
// iconClass = 'el-icon-document';
// }
return ( return (
<span> <span>
@ -430,20 +400,22 @@ export default {
this.loading = true this.loading = true
this.queryParams.displayBindRelationship = 'true' this.queryParams.displayBindRelationship = 'true'
console.log('queryParams1', this.queryParams) console.log('queryParams1', this.queryParams)
await getPersonSettingListApi(this.queryParams).then(response => { await getPersonSettingListApi(this.queryParams)
console.log('response', response) .then(response => {
this.typeList = response.rows console.log('response', response)
this.total = response.total this.typeList = response.rows
this.loading = false this.total = response.total
if (this.typeList.length > 0) { this.loading = false
this.typeList.forEach((item, index) => { if (this.typeList.length > 0) {
item.rowKey = item.typeId + '_' + index this.typeList.forEach((item, index) => {
}) item.rowKey = item.typeId + '_' + index
} })
}).catch(error => { }
console.log('🚀 ~ 列表 ~ error:', error) })
this.loading = false .catch(error => {
}) console.log('🚀 ~ 列表 ~ error:', error)
this.loading = false
})
}, },
// - // -
filterNode(value, data) { filterNode(value, data) {
@ -545,138 +517,76 @@ export default {
//- //-
handlerSelect(val, row) { handlerSelect(val, row) {
const index = this.userList.findIndex(item => item.typeId === row.typeId) if (!row || !row.typeId) return
if (this.ids.indexOf(row.typeId) === -1) {
this.userList.push({ typeId: row.typeId, userId: this.userIdTemp }) this.userList = this.userList || []
this.userNoList = this.userNoList || []
this.ids = this.ids || []
const isSelected = this.ids.indexOf(row.typeId) === -1
this.updateList(this.userList, row.typeId, this.userIdTemp, isSelected)
this.updateList(this.userNoList, row.typeId, row.keeperUserId, isSelected)
},
updateList(list, typeId, userId, isSelected) {
const index = list.findIndex(item => item.typeId === typeId)
if (isSelected) {
list.push({ typeId, userId })
} else if (index !== -1) { } else if (index !== -1) {
this.userList.splice(index, 1) list.splice(index, 1)
}
const indexNo = this.userNoList.findIndex(item => item.typeId === row.typeId)
if (this.ids.indexOf(row.typeId) === -1) {
this.userNoList.push({ typeId: row.typeId, userId: row.keeperUserId })
} else if (indexNo !== -1) {
this.userNoList.splice(indexNo, 1)
} }
}, },
//- //-
handlerSelectAll(val) { handlerSelectAll(val) {
if (val.length) { if (!Array.isArray(val) || !val.length) {
// : // &
// 1 2
//
// tableDatavalcurrentSelection
// tableDatavalcurrentSelection
const isAllSelect = this.tableData.every(item => val.some(valItem => valItem.typeId === item.typeId))
if (isAllSelect) {
//
const diff = val.filter(item => !this.userList.some(user => user.typeId === item.typeId))
if (this.userList.length + diff.length > this.maxLength) {
const spaceLeft = this.maxLength - this.userList.length
const toAdd = diff.slice(0, spaceLeft)
this.userList = this.userList.concat(
toAdd.map(item => ({
typeId: item.typeId,
userId: this.userIdTemp
}))
)
diff.slice(spaceLeft).forEach(item => this.$refs.multipleTable.toggleRowSelection(item, false))
} else {
this.userList = this.userList.concat(
diff.map(item => ({
typeId: item.typeId,
userId: this.userIdTemp
}))
)
}
//
const diffNo = val.filter(item => !this.userNoList.some(user => user.typeId === item.typeId))
if (this.userNoList.length + diff.length > this.maxLength) {
const spaceLeft = this.maxLength - this.userNoList.length
const toAdd = diff.slice(0, spaceLeft)
this.userNoList = this.userNoList.concat(
toAdd.map(item => ({
typeId: item.typeId,
userId: item.userId
}))
)
diff.slice(spaceLeft).forEach(item => this.$refs.multipleTable.toggleRowSelection(item, false))
} else {
this.userNoList = this.userNoList.concat(
diff.map(item => ({
typeId: item.typeId,
userId: item.userId
}))
)
}
} else {
this.userList = this.userList.filter(user => !this.tableData.some(item => item.typeId === user.typeId))
this.userNoList = this.userNoList.filter(user => !this.tableData.some(item => item.typeId === user.typeId))
}
} else {
// :
//
this.userList = [] this.userList = []
this.userNoList = [] this.userNoList = []
return
}
this.tableData = this.tableData || []
this.userList = this.userList || []
this.userNoList = this.userNoList || []
this.maxLength = this.maxLength || 9999 //
const isAllSelect = this.tableData.every(item => val.some(valItem => valItem.typeId === item.typeId))
const getDiff = (source, compareList) =>
source.filter(item => !compareList.some(target => target.typeId === item.typeId))
if (isAllSelect) {
//
const diff = getDiff(val, this.userList)
const diffNo = getDiff(val, this.userNoList)
const addWithLimit = (targetList, diffList, mapFn) => {
const spaceLeft = this.maxLength - targetList.length
const toAdd = diffList.slice(0, spaceLeft).map(mapFn)
const toDeselect = diffList.slice(spaceLeft)
toDeselect.forEach(item => this.$refs.multipleTable?.toggleRowSelection(item, false))
return targetList.concat(toAdd)
}
this.userList = addWithLimit(this.userList, diff, item => ({
typeId: item.typeId,
userId: this.userIdTemp
}))
this.userNoList = addWithLimit(this.userNoList, diffNo, item => ({
typeId: item.typeId,
userId: item.userId
}))
} else {
//
this.userList = this.userList.filter(user => !this.tableData.some(item => item.typeId === user.typeId))
this.userNoList = this.userNoList.filter(user => !this.tableData.some(item => item.typeId === user.typeId))
} }
}, },
// handleSelect(selection, row) {
// this.toggleSelection(selection, row);
// },
// handleSelectAll(selection) {
// this.isAllSelect = !this.isAllSelect;
// let data = this.typeList;
// this.toggleSelect(data,this.isAllSelect,'all');
// },
// //
// selectTr(selection,row){
// this.$set(row,'isChecked',!row.isChecked);
// this.$nextTick(()=>{
// this.isAllSelect = row.isChecked;
// this.toggleSelect(row,row.isChecked,'tr');
// });
// },
// //
// toggleSelect(data,flag,type){
// if(type === 'all'){
// if(data.length > 0){
// data.forEach(item=>{
// this.toggleSelection(item, flag);
// if(item.children && item.children.length > 0){
// this.toggleSelect(item.children,flag,type)
// }
// })
// }
// }else {
// if(data.children && data.children.length > 0){
// data.children.forEach(item =>{
// item.isChecked = !item.isChecked;
// this.$refs.multipleTable.toggleRowSelection(item, flag);
// this.toggleSelect(item,flag,type);
// })
// }
// }
// },
// //
// toggleSelection(row, flag) {
// this.$set(row,'isChecked',flag);
// this.$nextTick(()=>{
// if (flag) {
// this.$refs.multipleTable.toggleRowSelection(row, flag);
// } else {
// this.$refs.multipleTable.clearSelection();
// }
// });
// },
/** 绑定按钮操作 */ /** 绑定按钮操作 */
handleBind() { handleBind() {
console.log('ids----', this.ids)
if (this.userIdTemp == -1) { if (this.userIdTemp == -1) {
this.$alert('未勾选绑定人,无法绑定', '提示', { this.$alert('未勾选绑定人,无法绑定', '提示', {
type: 'warning', type: 'warning',
@ -684,26 +594,14 @@ export default {
}) })
return return
} }
if (this.ids.length == 0) {
this.$alert('未进行勾选相关物资,无法绑定', '提示', { const params = [
type: 'warning', {
confirmButtonText: '确定' typeId: this.queryParams.typeId,
}) userId: this.userIdTemp
return }
} else { ]
const ids = this.ids.join(',') bindPersonSettingApi(params).then(response => {
}
console.log('userList', this.userList)
// bindKeeper(this.userList).then(response => {
// this.$modal.msgSuccess('')
// this.ids = null
// this.userList = null
// this.userIdTemp = -1
// this.getTreeData()
// this.getList()
// this.$refs.multipleTable.clearSelection()
// })
bindPersonSettingApi(this.userList).then(response => {
this.$modal.msgSuccess('绑定成功') this.$modal.msgSuccess('绑定成功')
this.ids = null this.ids = null
this.userList = null this.userList = null
@ -761,46 +659,6 @@ export default {
}) })
}, },
/** 提交按钮 */
// submitForm: function () {
// console.log(this.form, "---");
// this.$refs["form"].validate((valid) => {
// if (valid) {
// if (this.form.typeId != undefined) {
// updateMaType(this.form).then((response) => {
// this.$modal.msgSuccess("");
// this.open = false;
// this.getList();
// this.getTreeData();
// });
// } else {
// // this.form.companyId = this.companyId
// addMaType(this.form).then((response) => {
// this.$modal.msgSuccess("");
// this.open = false;
// this.getList();
// this.getTreeData();
// });
// }
// }
// });
// },
// /** */
// handleDelete(row) {
// const typeIds = row.typeId;
// this.$modal
// .confirm("")
// .then(function () {
// return delMaType(typeIds);
// })
// .then(() => {
// this.$modal.msgSuccess("");
// this.getList();
// this.getTreeData();
// })
// .catch(() => {});
// },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const formatTime = date => { const formatTime = date => {