Commit 12d1e461 by crushh

Merge branch 'feature/2月迭代' into dev

parents 4491c11c a86a0dd9
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
</div> </div>
</div> </div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="scopeVisible = false">取消</el-button> <el-button @click="treeDialogCancel">取消</el-button>
<el-button type="primary" @click="addSuitDepartment">确认</el-button> <el-button type="primary" @click="addSuitDepartment">确认</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -310,6 +310,10 @@ export default { ...@@ -310,6 +310,10 @@ export default {
}); });
}); });
}, },
treeDialogCancel() {
this.scopeVisible = false;
this.filterText = '';
},
addSuitDepartment() { addSuitDepartment() {
this.form.suitDepartmentAddList = Object.assign([], this.selectedTreeData); this.form.suitDepartmentAddList = Object.assign([], this.selectedTreeData);
this.scopeVisible = false; this.scopeVisible = false;
...@@ -355,7 +359,8 @@ export default { ...@@ -355,7 +359,8 @@ export default {
// 前端搜索部门树 // 前端搜索部门树
this.treeData = this.treeDataCopy.filter(ele => ele.departmentName.indexOf(this.filterText) != -1); this.treeData = this.treeDataCopy.filter(ele => ele.departmentName.indexOf(this.filterText) != -1);
if (this.selectedTreeData.length) { if (this.selectedTreeData.length) {
this.$refs.tree.setCheckedKeys(this.selectedTreeData.map(item => item.departmentId)); const arr = this.selectedTreeData.map(item => item.departmentId);
this.$refs.tree.setCheckedKeys(arr);
} else { } else {
this.$refs.tree.setCheckedKeys([]); this.$refs.tree.setCheckedKeys([]);
} }
...@@ -363,10 +368,21 @@ export default { ...@@ -363,10 +368,21 @@ export default {
handleCheck(data, arr) { handleCheck(data, arr) {
// 部门树选中时 // 部门树选中时
const { checkedNodes } = arr; const { checkedNodes } = arr;
this.selectedTreeData = JSON.parse(JSON.stringify(checkedNodes)); if (this.filterText) {
// 搜索时的树
const arr = this.selectedTreeData.map(item => item.departmentId);
checkedNodes.forEach(item => {
if (!arr.includes(item.departmentId)) {
this.selectedTreeData.push(item);
}
});
} else {
this.selectedTreeData = JSON.parse(JSON.stringify(checkedNodes));
}
}, },
handleCheckChange(data, checked) { handleCheckChange(data, checked) {
// 部门树选中变化时 // 部门树选中变化时
console.log('部门树选中变化时', this.selectedTreeData.length);
const obj = JSON.parse(JSON.stringify(data)); const obj = JSON.parse(JSON.stringify(data));
if (!checked) { if (!checked) {
this.$nextTick(() => { this.$nextTick(() => {
......
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