|
@@ -1,105 +1,112 @@
|
|
|
<template>
|
|
|
- <el-scrollbar class="el-scrollbar-byself" style="width: 100%">
|
|
|
- <el-tree
|
|
|
- :data="tenantsTree"
|
|
|
- show-checkbox
|
|
|
- node-key="value"
|
|
|
- :props="treedefaultProps"
|
|
|
- :default-checked-keys="defaultcheckedkeys"
|
|
|
- ref="tenantstree"
|
|
|
- @check-change="checkChange"
|
|
|
- >
|
|
|
- <div style="width: 100%" slot-scope="{ node, data }" @click="thisCheck($event, node, data)">{{ data.name }}</div>
|
|
|
- </el-tree>
|
|
|
- </el-scrollbar>
|
|
|
+ <el-scrollbar
|
|
|
+ class="el-scrollbar-byself"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-tree
|
|
|
+ :data="tenantsTree"
|
|
|
+ show-checkbox
|
|
|
+ node-key="value"
|
|
|
+ :props="treedefaultProps"
|
|
|
+ :default-checked-keys="defaultcheckedkeys"
|
|
|
+ ref="tenantstree"
|
|
|
+ @check-change="checkChange"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ style="width: 100%"
|
|
|
+ slot-scope="{ node, data }"
|
|
|
+ @click="thisCheck($event, node, data)"
|
|
|
+ >{{ data.name }}</div>
|
|
|
+ </el-tree>
|
|
|
+ </el-scrollbar>
|
|
|
</template>
|
|
|
<script>
|
|
|
export default {
|
|
|
- props: ['params'],
|
|
|
- data() {
|
|
|
- return {
|
|
|
- tenantsTree: [],
|
|
|
- treedefaultProps: {
|
|
|
- children: 'children',
|
|
|
- label: 'name'
|
|
|
- },
|
|
|
- defaultcheckedkeys: []
|
|
|
- };
|
|
|
+ props: ['params'],
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ tenantsTree: [],
|
|
|
+ treedefaultProps: {
|
|
|
+ children: 'children',
|
|
|
+ label: 'name'
|
|
|
+ },
|
|
|
+ defaultcheckedkeys: []
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ mounted () {
|
|
|
+ console.log(this.$refs.tenantstree.$children);
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ submit () {
|
|
|
+ let arrs = this.$refs.tenantstree.getCheckedNodes();
|
|
|
+ let combination = [];
|
|
|
+ arrs.forEach((item, index) => {
|
|
|
+ let thisValue = this.$refs.tenantstree.getNode(item);
|
|
|
+ let newValueIds = thisValue.data.id.split('-');
|
|
|
+ let objArray = {};
|
|
|
+ if (
|
|
|
+ (item.children == null || item.children == undefined) &&
|
|
|
+ !this.defaultcheckedkeys.includes(parseInt(thisValue.data.value))
|
|
|
+ ) {
|
|
|
+ if (thisValue.data.type === 'room') {
|
|
|
+ objArray = {
|
|
|
+ houseId: thisValue.data.value,
|
|
|
+ buildingName: newValueIds.length === 4 ? thisValue.parent.parent.data.name : thisValue.parent.data.name,
|
|
|
+ unitName: newValueIds.length === 4 ? thisValue.parent.data.name : '',
|
|
|
+ roomNumber: thisValue.data.name
|
|
|
+ };
|
|
|
+ } else if (thisValue.data.type === 'parking') {
|
|
|
+ objArray = {
|
|
|
+ parkingId: thisValue.data.value,
|
|
|
+ parkingNumber: thisValue.data.name,
|
|
|
+ partitionName: newValueIds.length === 4 ? thisValue.parent.data.name : '',
|
|
|
+ garageName: newValueIds.length === 4 ? thisValue.parent.parent.data.name : thisValue.parent.data.name
|
|
|
+ };
|
|
|
+ }
|
|
|
+ combination.push(objArray);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ this.params.callback && this.params.callback(combination);
|
|
|
+ this.$emit('close');
|
|
|
},
|
|
|
- computed: {},
|
|
|
- mounted() {
|
|
|
- console.log(this.$refs.tenantstree.$children);
|
|
|
+ checkChange (data, checked) {
|
|
|
+ if (checked) {
|
|
|
+ }
|
|
|
},
|
|
|
- methods: {
|
|
|
- submit() {
|
|
|
- let arrs = this.$refs.tenantstree.getCheckedNodes();
|
|
|
- let combination = [];
|
|
|
- arrs.forEach((item, index) => {
|
|
|
- let thisValue = this.$refs.tenantstree.getNode(item);
|
|
|
- let newValueIds = thisValue.data.id.split('-');
|
|
|
- let objArray = {};
|
|
|
- if (
|
|
|
- (item.children == null || item.children == undefined) &&
|
|
|
- !this.defaultcheckedkeys.includes(parseInt(thisValue.data.value))
|
|
|
- ) {
|
|
|
- if (thisValue.data.type === 'room') {
|
|
|
- objArray = {
|
|
|
- houseId: thisValue.data.value,
|
|
|
- buildingName: newValueIds.length === 4 ? thisValue.parent.parent.data.name : thisValue.parent.data.name,
|
|
|
- unitName: newValueIds.length === 4 ? thisValue.parent.data.name : '',
|
|
|
- roomNumber: thisValue.data.name
|
|
|
- };
|
|
|
- } else if (thisValue.data.type === 'parking') {
|
|
|
- objArray = {
|
|
|
- parkingId: thisValue.data.value,
|
|
|
- parkingNumber: thisValue.data.name,
|
|
|
- partitionName: newValueIds.length === 4 ? thisValue.parent.data.name : '',
|
|
|
- garageName: newValueIds.length === 4 ? thisValue.parent.parent.data.name : thisValue.parent.data.name
|
|
|
- };
|
|
|
- }
|
|
|
- combination.push(objArray);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- this.params.callback && this.params.callback(combination);
|
|
|
- this.$emit('close');
|
|
|
- },
|
|
|
- checkChange(data, checked) {
|
|
|
- if (checked) {
|
|
|
- }
|
|
|
- },
|
|
|
- filterTreeData(trData) {
|
|
|
- trData.map((item, index) => {
|
|
|
- if (this.isNotEmpty(item.children)) {
|
|
|
- item.disabled = true;
|
|
|
- this.filterTreeData(item.children);
|
|
|
- } else {
|
|
|
- item.disabled = false;
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- isNotEmpty(arr) {
|
|
|
- return arr && Array.isArray(arr) && arr.length > 0;
|
|
|
- },
|
|
|
- thisCheck(ev, node, data) {
|
|
|
- if (!data.disabled) {
|
|
|
- node.checked = !node.checked;
|
|
|
- }
|
|
|
+ filterTreeData (trData) {
|
|
|
+ trData.map((item, index) => {
|
|
|
+ if (this.isNotEmpty(item.children)) {
|
|
|
+ item.disabled = true;
|
|
|
+ this.filterTreeData(item.children);
|
|
|
+ } else {
|
|
|
+ item.disabled = false;
|
|
|
}
|
|
|
+ });
|
|
|
+ },
|
|
|
+ isNotEmpty (arr) {
|
|
|
+ return arr && Array.isArray(arr) && arr.length > 0;
|
|
|
},
|
|
|
- created() {
|
|
|
- if (this.params.list.length !== 0) {
|
|
|
- this.params.list.forEach((item, index) => {
|
|
|
- if (this.params.num === 1) {
|
|
|
- this.defaultcheckedkeys.push(item.houseId);
|
|
|
- } else {
|
|
|
- this.defaultcheckedkeys.push(item.parkingId);
|
|
|
- }
|
|
|
- });
|
|
|
+ thisCheck (ev, node, data) {
|
|
|
+ if (!data.disabled) {
|
|
|
+ node.checked = !node.checked;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ if (this.params.list.length !== 0) {
|
|
|
+ this.params.list.forEach((item, index) => {
|
|
|
+ if (this.params.num === 1) {
|
|
|
+ this.defaultcheckedkeys.push(item.houseId);
|
|
|
+ } else {
|
|
|
+ this.defaultcheckedkeys.push(item.parkingId);
|
|
|
}
|
|
|
-
|
|
|
- this.filterTreeData(this.params.tenantsTree);
|
|
|
- this.tenantsTree = this.params.tenantsTree;
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
+ this.filterTreeData(this.params.tenantsTree);
|
|
|
+ this.tenantsTree = this.params.tenantsTree;
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|