1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <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-tree>
- </el-scrollbar>
- </template>
- <script>
- export default {
- props: ['params'],
- data() {
- return {
- tenantsTree: [],
- treedefaultProps: {
- children: 'children',
- label: 'name'
- },
- defaultcheckedkeys: []
- };
- },
- 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');
- }
- },
- 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>
|