全选按钮需求补充阶段提交
This commit is contained in:
parent
43df131610
commit
fd9969f375
@ -36,10 +36,22 @@
|
||||
<awsui-checkbox size="small" v-model="roleForm.isAllDataPerm">全部</awsui-checkbox>
|
||||
<div class="awsui-form-item__content">
|
||||
<awsui-input v-if="isOlderVersion" class="role_data_perm_textarea" type="textarea" v-model="roleForm.isAllDataPerm ? '全部' : roleForm.dataPermText" readonly placeholder="请选择" @click.native="openDataPermTreeDlg"></awsui-input>
|
||||
<div v-else style="height: 300px;overflow: auto;border: 1px solid #f2f2f2;">
|
||||
<div v-else style="height: 300px;border: 1px solid #f2f2f2;">
|
||||
<div v-if="roleForm.isAllDataPerm"> 全部</div>
|
||||
<div v-else class="tree">
|
||||
<div class="allGroup">
|
||||
<div class="processAll">
|
||||
<el-checkbox v-model="checkAllProcess" @change="checkAllProcessChange">全选</el-checkbox>
|
||||
</div>
|
||||
<div class="actionGroup">
|
||||
<el-checkbox v-model="checkAllUpdate" @change="checkAllUpdateChange"
|
||||
:disabled="checkAllDelete || checkAllVersion ">编辑</el-checkbox>
|
||||
<el-checkbox v-model="checkAllDelete" @change="checkAllDeleteChange">删除</el-checkbox>
|
||||
<el-checkbox v-model="checkAllVersion" @change="checkAllVersionChange">版本管理</el-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<el-tree
|
||||
style="height: 270px;overflow: auto;"
|
||||
v-loading="loading"
|
||||
ref="tree"
|
||||
:props="treeProps"
|
||||
@ -190,6 +202,11 @@
|
||||
pid: '',
|
||||
dataActionPerm: {},
|
||||
dataActionPermOpts:[],
|
||||
teamPermFileSize: 0,
|
||||
checkAllProcess: false,
|
||||
checkAllUpdate: false,
|
||||
checkAllDelete: false,
|
||||
checkAllVersion: false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -249,6 +266,16 @@
|
||||
node.expand();
|
||||
})
|
||||
|
||||
//计算全选按钮
|
||||
that.teamPermFileSize = data.teamPermFileSize
|
||||
that.checkAllProcess = data.teamPermFileSize == data.dataPerm.length;
|
||||
let wPermNum = that.getActionPermNum("w");
|
||||
that.checkAllUpdate = wPermNum == data.teamPermFileSize;
|
||||
let dPermNum = that.getActionPermNum("d");
|
||||
that.checkAllDelete = dPermNum == data.teamPermFileSize;
|
||||
let vPermNum = that.getActionPermNum("v");
|
||||
that.checkAllVersion = vPermNum == data.teamPermFileSize;
|
||||
|
||||
//用户权限设置roleId
|
||||
that.$emit('setUserRole', data.roleId);
|
||||
} else {
|
||||
@ -308,7 +335,7 @@
|
||||
that.$refs.tree.setCheckedNodes([]);
|
||||
that.$refs.tree.$children = [];
|
||||
that.treeChecked = [];
|
||||
that.dataActionPerm = [];
|
||||
that.dataActionPerm = {};
|
||||
that.dataActionPermOpts = [];
|
||||
}
|
||||
|
||||
@ -361,11 +388,13 @@
|
||||
if (!that.isOlderVersion){
|
||||
let dataPermArr = [];
|
||||
Object.keys(that.dataActionPerm).forEach((key) => {
|
||||
let obj = {
|
||||
id:key,
|
||||
actionPerm: that.dataActionPerm[key].join(",")
|
||||
if (key.length == 36){
|
||||
let obj = {
|
||||
id:key,
|
||||
actionPerm: that.dataActionPerm[key].join(",")
|
||||
}
|
||||
dataPermArr.push(obj);
|
||||
}
|
||||
dataPermArr.push(obj);
|
||||
})
|
||||
data.dataPerm = dataPermArr;
|
||||
}
|
||||
@ -439,10 +468,12 @@
|
||||
if (checked) {// 选中
|
||||
const checkedVerIds = that.roleForm.dataPerm;
|
||||
|
||||
//当前节点处理
|
||||
if (checkedVerIds.indexOf(currVerId) == -1) {
|
||||
checkedVerIds.push(currVerId);
|
||||
Object.assign(that.dataActionPerm,{[currVerId]:[]})
|
||||
}
|
||||
//当前下属节点处理
|
||||
for (let i = 0; i < childVerIds.length; i++) {
|
||||
if (checkedVerIds.indexOf(childVerIds[i]) == -1) {
|
||||
checkedVerIds.push(childVerIds[i]);
|
||||
@ -451,6 +482,38 @@
|
||||
}
|
||||
that.$refs.tree.setCheckedKeys(checkedVerIds);
|
||||
|
||||
//全选检测
|
||||
checkedVerIds.forEach(currVerId=>{
|
||||
let checkedNodes = that.$refs.tree.getCheckedNodes();
|
||||
//全选编辑检测
|
||||
if (that.checkAllUpdate){
|
||||
setTimeout(()=>{
|
||||
that.pushArr(that.dataActionPerm[currVerId],'w');
|
||||
checkedNodes.forEach(node=>{
|
||||
that.pushArr(node.dataActionPerm,'w')
|
||||
})
|
||||
},100)
|
||||
}
|
||||
//全选删除检测
|
||||
if (that.checkAllDelete){
|
||||
setTimeout(()=>{
|
||||
that.pushArr(that.dataActionPerm[currVerId],'d');
|
||||
checkedNodes.forEach(node=>{
|
||||
that.pushArr(node.dataActionPerm,'d')
|
||||
})
|
||||
},100)
|
||||
}
|
||||
//全选版本检测
|
||||
if (that.checkAllVersion){
|
||||
setTimeout(()=>{
|
||||
that.pushArr(that.dataActionPerm[currVerId],'v');
|
||||
checkedNodes.forEach(node=>{
|
||||
that.pushArr(node.dataActionPerm,'v')
|
||||
})
|
||||
},100)
|
||||
}
|
||||
})
|
||||
|
||||
} else {// 取消选中
|
||||
const checkedVerIds = that.roleForm.dataPerm;
|
||||
const checkedActions = that.dataActionPerm;
|
||||
@ -471,10 +534,19 @@
|
||||
that.dataActionPerm = tempActions;
|
||||
that.$refs.tree.setCheckedKeys([]);
|
||||
}
|
||||
|
||||
//计算流程全选按钮
|
||||
let num = 0;
|
||||
that.roleForm.dataPerm.forEach(item=>{
|
||||
if (item.length == 36){
|
||||
num++;
|
||||
}
|
||||
})
|
||||
that.checkAllProcess = num == that.teamPermFileSize;
|
||||
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
data.dataActionPerm = []
|
||||
},
|
||||
loadNode(node, resolve) {
|
||||
const that = this;
|
||||
@ -538,6 +610,14 @@
|
||||
if (that.dataActionPerm[node.data.versionId] != undefined){
|
||||
that.dataActionPerm[node.data.versionId] = node.data.dataActionPerm;
|
||||
}
|
||||
|
||||
//编辑全选
|
||||
let wPermNum = that.getActionPermNum("w");
|
||||
that.checkAllUpdate = wPermNum == that.teamPermFileSize;
|
||||
let dPermNum = that.getActionPermNum("d");
|
||||
that.checkAllDelete = dPermNum == that.teamPermFileSize;
|
||||
let vPermNum = that.getActionPermNum("v");
|
||||
that.checkAllVersion = vPermNum == that.teamPermFileSize;
|
||||
},100)
|
||||
|
||||
},
|
||||
@ -562,8 +642,102 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
checkAllProcessChange(value){
|
||||
const that = this;
|
||||
|
||||
if (value){//选中
|
||||
const params = {
|
||||
url:'jd',
|
||||
data:{
|
||||
cmd: 'com.actionsoft.apps.coe.pal.cooperation_repository_all_childern_data_query',
|
||||
wsId: that.wsId,
|
||||
teamId: that.teamId,
|
||||
pid: ''
|
||||
}
|
||||
};
|
||||
awsuiAxios.post(params).then(ro=>{
|
||||
const childVerIds = ro.data;
|
||||
|
||||
const checkedVerIds = that.roleForm.dataPerm;
|
||||
for (let i = 0; i < childVerIds.length; i++) {
|
||||
if (checkedVerIds.indexOf(childVerIds[i]) == -1) {
|
||||
checkedVerIds.push(childVerIds[i]);
|
||||
Object.assign(that.dataActionPerm,{[childVerIds[i]]:[]})
|
||||
}
|
||||
}
|
||||
that.$refs.tree.setCheckedKeys(checkedVerIds);
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}else {
|
||||
that.roleForm.dataPerm = [];
|
||||
that.dataActionPerm = {};
|
||||
that.$refs.tree.setCheckedKeys([]);
|
||||
}
|
||||
},
|
||||
checkAllUpdateChange(value){
|
||||
this.checkAllActionChange(value,'w')
|
||||
},
|
||||
checkAllDeleteChange(value){
|
||||
this.checkAllActionChange(value,'d')
|
||||
},
|
||||
checkAllVersionChange(value){
|
||||
this.checkAllActionChange(value,'v')
|
||||
},
|
||||
checkAllActionChange(flag,str){
|
||||
let actionPerm = this.dataActionPerm;
|
||||
let checkedNodes = this.$refs.tree.getCheckedNodes();
|
||||
|
||||
if (flag){
|
||||
Object.keys(actionPerm).forEach(key=>{
|
||||
this.pushArr(actionPerm[key],str);
|
||||
if (str == 'd' || str == 'v'){
|
||||
this.pushArr(actionPerm[key],'w');
|
||||
}
|
||||
})
|
||||
checkedNodes.forEach(node=>{
|
||||
this.pushArr(node.dataActionPerm,str);
|
||||
if (str == 'd' || str == 'v'){
|
||||
this.pushArr(node.dataActionPerm,'w');
|
||||
this.checkBoxDisabledHandle(node,{label:str})
|
||||
}
|
||||
})
|
||||
}else {
|
||||
Object.keys(actionPerm).forEach(key=>{
|
||||
this.removeArr(actionPerm[key],str);
|
||||
})
|
||||
checkedNodes.forEach(node=>{
|
||||
this.removeArr(node.dataActionPerm,str)
|
||||
if (str == 'd' || str == 'v'){
|
||||
this.checkBoxDisabledHandle(node,{label:str})
|
||||
}
|
||||
})
|
||||
}
|
||||
//重新计算全选编辑
|
||||
let wPermNum = this.getActionPermNum("w");
|
||||
this.checkAllUpdate = wPermNum == this.teamPermFileSize;
|
||||
},
|
||||
pushArr(arr,str){
|
||||
if (!arr.includes(str)){
|
||||
arr.push(str)
|
||||
}
|
||||
},
|
||||
removeArr(arr,str){
|
||||
if (arr.includes(str)){
|
||||
arr.splice(arr.indexOf(str),1)
|
||||
}
|
||||
},
|
||||
getActionPermNum(str){
|
||||
let num = 0;
|
||||
let actionPerm = this.dataActionPerm;
|
||||
Object.keys(actionPerm).forEach(key=>{
|
||||
if (actionPerm[key].includes(str)){
|
||||
num++;
|
||||
}
|
||||
})
|
||||
return num;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(val) {
|
||||
@ -579,5 +753,14 @@
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.allGroup{
|
||||
display: flex;
|
||||
}.allGroup .processAll{
|
||||
margin-left: 5px;
|
||||
}
|
||||
.allGroup .actionGroup{
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
padding-right: 1px;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user