Commit 0045a0b1 authored by zhengke's avatar zhengke

修改

parent 242face2
......@@ -5,27 +5,20 @@
<div style="height:450px;overflow:scroll" v-if="item.PageTypeId!=6">
<template v-for="(subItem,subIndex) in item.SubMenuList">
<div :key="subIndex" style="margin-bottom:10px;">
<el-checkbox v-model="subItem.IsChecked" :key="subIndex" @change="checkMenuChange(subItem)">
<span v-if="subItem.SelfPageName">{{subItem.SelfPageName}}</span>
<span v-else>{{subItem.PageName}} </span>
</el-checkbox>
<el-checkbox v-model="subItem.IsChecked" :key="subIndex" @change="checkMenuChange(subItem)">
<span v-if="subItem.SelfPageName">{{subItem.SelfPageName}}</span>
<span v-else>{{subItem.PageName}} </span>
</el-checkbox>
</div>
</template>
</div>
<div style="height:450px;overflow:scroll" v-else>
<el-input
placeholder="输入关键字进行过滤"
v-model="filterText">
</el-input>
<el-tree
:data="treeData"
node-key="PageId"
ref="tree"
:props="defaultProps"
filter
:filter-node-method="filterNode"
show-checkbox>
</el-tree>
<el-input placeholder="输入关键字进行过滤" v-model="filterText">
</el-input>
<el-tree :data="item.SubMenuList" node-key="PageId" ref="tree" :props="defaultProps" filter
:filter-node-method="filterNode" @check="handleCheck"
:check-strictly="true" show-checkbox>
</el-tree>
</div>
</el-tab-pane>
</el-tabs>
......@@ -37,18 +30,18 @@
return {
dataList: [],
activeName: "1",
treeData: [],
filterText:'',
filterText: '',
defaultProps: {
children: 'children',
label: 'label'
}
children: 'SubMenuList',
label: 'PageName'
},
checkedObj:{}
};
},
created() {},
watch: {
filterText(val) {
this.$refs.tree.filter(val.trim());
this.$refs.tree[0].filter(val.trim());
}
},
methods: {
......@@ -73,19 +66,26 @@
ParameterValue: "",
PageName: ""
};
if (this.dataList && this.dataList.length > 0) {
this.dataList.forEach(item => {
if (item.SubMenuList && item.SubMenuList.length > 0) {
item.SubMenuList.forEach(subItem => {
if (subItem.IsChecked) {
obj.PageUrl = subItem.PageUrl;
obj.IsParameter = subItem.IsParameter;
obj.ParameterValue = subItem.ParameterValue;
obj.PageName = subItem.PageName;
}
})
}
});
if(this.activeName!=6){
if (this.dataList && this.dataList.length > 0) {
this.dataList.forEach(item => {
if (item.SubMenuList && item.SubMenuList.length > 0) {
item.SubMenuList.forEach(subItem => {
if (subItem.IsChecked) {
obj.PageUrl = subItem.PageUrl;
obj.IsParameter = subItem.IsParameter;
obj.ParameterValue = subItem.ParameterValue;
obj.PageName = subItem.PageName;
}
})
}
});
}
}else{
obj.PageUrl=this.checkedObj.PageUrl
obj.IsParameter=this.checkedObj.IsParameter
obj.ParameterValue=this.checkedObj.ParameterValue
obj.PageName=this.checkedObj.PageName;
}
return obj;
},
......@@ -102,40 +102,26 @@
subItem.IsChecked = false;
})
}
if (item.PageTypeId == 6) {
this.treeData = this.getTree(item.SubMenuList);
}
});
}
this.dataList = dataArray;
console.log(this.dataList, 'datalist');
console.log(this.treeData, 'treeData');
} else {
this.Info(res.data.message);
}
})
},
//递归改变label children
getTree(data) {
if (data) {
for (var i = 0; i < data.length; i++) {
data[i].label = data[i].PageName;
if (data[i].SubMenuList && data[i].SubMenuList.length > 0) {
data[i].children = data[i].SubMenuList;
}
data[i].IsChecked=false;
this.getTree(data[i].SubMenuList)
}
}
return data;
},
filterNode(value, data) {
console.log(value,'value');
console.log(data,'data');
if (!value) return true;
return data.label.indexOf(value) !== -1;
}
},
//check单选
handleCheck (a, b) {
//a为传递给 data 属性的数组中该节点所对应的对象;b为树目前的选中状态对象
if (b.checkedKeys.length > 0) {
this.$refs.tree[0].setCheckedKeys([a.PageId]);
this.checkedObj=a;
}
},
},
mounted() {
this.getList();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment