poptreeSelect.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <el-scrollbar class="el-scrollbar-byself thisColor" style="width: 100%">
  3. <el-tree class="" :data="tenantsTree" @node-click="treeClick" node-key="value" :props="treedefaultProps" ref="tenantstree">
  4. </el-tree>
  5. </el-scrollbar>
  6. </template>
  7. <script>
  8. export default {
  9. props: ['params'],
  10. data() {
  11. return {
  12. tenantsTree: [],
  13. treedefaultProps: {
  14. children: 'children',
  15. label: 'name'
  16. },
  17. unitPa: {
  18. buildingId: '',
  19. buildingName: '',
  20. unitId: '',
  21. unitName: '',
  22. houseId: '',
  23. houseName: '',
  24. type: ''
  25. }
  26. };
  27. },
  28. computed: {},
  29. mounted() {},
  30. methods: {
  31. submit() {
  32. if (this.unitPa.type === 'room') {
  33. this.params.callback && this.params.callback(this.unitPa);
  34. this.$emit('close');
  35. } else {
  36. this.$message.error('请先选择到房间');
  37. return;
  38. }
  39. },
  40. treeClick(e) {
  41. this.unitPa.type = e.type;
  42. if (e.type == 'room') {
  43. this.unitPa.buildingId = this.$refs.tenantstree.getNode(e).parent.parent.data.value;
  44. this.unitPa.buildingName = this.$refs.tenantstree.getNode(e).parent.parent.data.name;
  45. this.unitPa.unitId = this.$refs.tenantstree.getNode(e).parent.data.value;
  46. this.unitPa.unitName = this.$refs.tenantstree.getNode(e).parent.data.name;
  47. this.unitPa.houseId = e.value;
  48. this.unitPa.houseName = e.name;
  49. }
  50. }
  51. },
  52. created() {
  53. this.tenantsTree = this.params.tenantsTree;
  54. }
  55. };
  56. </script>
  57. <style lang="scss" scoped>
  58. .thisColor /deep/ .el-tree .is-current {
  59. color: #56c6ff;
  60. }
  61. </style>