人员业务配置-优化
This commit is contained in:
parent
0674d847ad
commit
d33bdca42f
|
|
@ -89,26 +89,10 @@
|
|||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleBind"
|
||||
>
|
||||
绑定
|
||||
</el-button>
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleBind">绑定</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-minus"
|
||||
size="mini"
|
||||
@click="handleNoBind"
|
||||
>
|
||||
解绑
|
||||
</el-button>
|
||||
<el-button type="warning" plain icon="el-icon-minus" size="mini" @click="handleNoBind">解绑</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button
|
||||
|
|
@ -310,21 +294,10 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
// this.getInfo()
|
||||
this.getTreeData()
|
||||
this.getTreeDataTwo()
|
||||
// this.getKeeperDataList();
|
||||
// setTimeout(()=>{
|
||||
// this.getList();
|
||||
// },200)
|
||||
},
|
||||
methods: {
|
||||
// getInfo() {
|
||||
// getInfo().then((res) => {
|
||||
// console.log(res, 'companyId----')
|
||||
// this.companyId = res.user.companyId
|
||||
// })
|
||||
// },
|
||||
selectFirstNode() {
|
||||
const firstNode = this.$refs.treeTwo.getNode(1)
|
||||
if (firstNode) {
|
||||
|
|
@ -341,9 +314,6 @@ export default {
|
|||
if (node.data.level == 99) {
|
||||
iconClass = 'el-icon-user-solid'
|
||||
}
|
||||
// else if (node.type === 'file') {
|
||||
// iconClass = 'el-icon-document';
|
||||
// }
|
||||
|
||||
return (
|
||||
<span>
|
||||
|
|
@ -430,7 +400,8 @@ export default {
|
|||
this.loading = true
|
||||
this.queryParams.displayBindRelationship = 'true'
|
||||
console.log('queryParams1', this.queryParams)
|
||||
await getPersonSettingListApi(this.queryParams).then(response => {
|
||||
await getPersonSettingListApi(this.queryParams)
|
||||
.then(response => {
|
||||
console.log('response', response)
|
||||
this.typeList = response.rows
|
||||
this.total = response.total
|
||||
|
|
@ -440,7 +411,8 @@ export default {
|
|||
item.rowKey = item.typeId + '_' + index
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('🚀 ~ 列表 ~ error:', error)
|
||||
this.loading = false
|
||||
})
|
||||
|
|
@ -545,138 +517,76 @@ export default {
|
|||
|
||||
//单选操作-跨页
|
||||
handlerSelect(val, row) {
|
||||
const index = this.userList.findIndex(item => item.typeId === row.typeId)
|
||||
if (this.ids.indexOf(row.typeId) === -1) {
|
||||
this.userList.push({ typeId: row.typeId, userId: this.userIdTemp })
|
||||
if (!row || !row.typeId) return
|
||||
|
||||
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) {
|
||||
this.userList.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)
|
||||
list.splice(index, 1)
|
||||
}
|
||||
},
|
||||
|
||||
//全选操作-跨页
|
||||
handlerSelectAll(val) {
|
||||
if (val.length) {
|
||||
// 进来此处说明:
|
||||
// 1 当前页的全选 2 其他页有数据然后当前页的取消全选
|
||||
// 比较全选或者取消全选与当前页的数据,得到差集
|
||||
// 如果tableData中的数据在val中不存在,则说明是取消全选,需要从currentSelection中移除
|
||||
// 如果tableData中所有的数据都在val中存在,则说明是全选,需要将差集添加到currentSelection中
|
||||
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
|
||||
}))
|
||||
)
|
||||
if (!Array.isArray(val) || !val.length) {
|
||||
// 当前页取消全选 & 其他页也无选中
|
||||
this.userList = []
|
||||
this.userNoList = []
|
||||
return
|
||||
}
|
||||
|
||||
// 全选中新增的差集
|
||||
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
|
||||
}))
|
||||
)
|
||||
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))
|
||||
}
|
||||
} else {
|
||||
// 进来此处说明:
|
||||
// 其他页并无勾选数据,且当前页取消勾选
|
||||
this.userList = []
|
||||
this.userNoList = []
|
||||
}
|
||||
},
|
||||
// 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() {
|
||||
console.log('ids----', this.ids)
|
||||
if (this.userIdTemp == -1) {
|
||||
this.$alert('未勾选绑定人,无法绑定', '提示', {
|
||||
type: 'warning',
|
||||
|
|
@ -684,26 +594,14 @@ export default {
|
|||
})
|
||||
return
|
||||
}
|
||||
if (this.ids.length == 0) {
|
||||
this.$alert('未进行勾选相关物资,无法绑定', '提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确定'
|
||||
})
|
||||
return
|
||||
} else {
|
||||
const ids = this.ids.join(',')
|
||||
|
||||
const params = [
|
||||
{
|
||||
typeId: this.queryParams.typeId,
|
||||
userId: this.userIdTemp
|
||||
}
|
||||
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 => {
|
||||
]
|
||||
bindPersonSettingApi(params).then(response => {
|
||||
this.$modal.msgSuccess('绑定成功')
|
||||
this.ids = 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() {
|
||||
const formatTime = date => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue