|
@@ -1,13 +1,6 @@
|
|
|
<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"
|
|
|
- >
|
|
|
+ <el-scrollbar class="el-scrollbar-byself thisColor" style="width: 100%">
|
|
|
+ <el-tree class="" :data="tenantsTree" @node-click="treeClick" node-key="value" :props="treedefaultProps" ref="tenantstree">
|
|
|
</el-tree>
|
|
|
</el-scrollbar>
|
|
|
</template>
|
|
@@ -21,54 +14,48 @@ export default {
|
|
|
children: 'children',
|
|
|
label: 'name'
|
|
|
},
|
|
|
- defaultcheckedkeys: []
|
|
|
+ unitPa: {
|
|
|
+ buildingId: '',
|
|
|
+ buildingName: '',
|
|
|
+ unitId: '',
|
|
|
+ unitName: '',
|
|
|
+ houseId: '',
|
|
|
+ houseName: '',
|
|
|
+ type: ''
|
|
|
+ }
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
mounted() {},
|
|
|
methods: {
|
|
|
submit() {
|
|
|
- let arrs = this.$refs.tenantstree.getCheckedNodes();
|
|
|
- let combination = [];
|
|
|
- arrs.forEach((item, index) => {
|
|
|
- let thisValue = this.$refs.tenantstree.getNode(item);
|
|
|
- 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: thisValue.parent.parent.data.name,
|
|
|
- unitName: thisValue.parent.data.name,
|
|
|
- roomNumber: thisValue.data.name
|
|
|
- };
|
|
|
- } else if (thisValue.data.type === 'parking') {
|
|
|
- objArray = {
|
|
|
- parkingId: thisValue.data.value,
|
|
|
- parkingNumber: thisValue.data.name
|
|
|
- };
|
|
|
- }
|
|
|
- combination.push(objArray);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- this.params.callback && this.params.callback(combination);
|
|
|
- this.$emit('close');
|
|
|
+ if (this.unitPa.type === 'room') {
|
|
|
+ this.params.callback && this.params.callback(this.unitPa);
|
|
|
+ this.$emit('close');
|
|
|
+ } else {
|
|
|
+ this.$message.error('请先选择到房间');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ treeClick(e) {
|
|
|
+ this.unitPa.type = e.type;
|
|
|
+ if (e.type == 'room') {
|
|
|
+ this.unitPa.buildingId = this.$refs.tenantstree.getNode(e).parent.parent.data.value;
|
|
|
+ this.unitPa.buildingName = this.$refs.tenantstree.getNode(e).parent.parent.data.name;
|
|
|
+ this.unitPa.unitId = this.$refs.tenantstree.getNode(e).parent.data.value;
|
|
|
+ this.unitPa.unitName = this.$refs.tenantstree.getNode(e).parent.data.name;
|
|
|
+ this.unitPa.houseId = e.value;
|
|
|
+ this.unitPa.houseName = e.name;
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
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.tenantsTree = this.params.tenantsTree;
|
|
|
}
|
|
|
};
|
|
|
-</script>
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.thisColor /deep/ .el-tree .is-current {
|
|
|
+ color: #56c6ff;
|
|
|
+}
|
|
|
+</style>
|