index.vue 818 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <div>
  3. <el-input v-model="userNames" size="mini" disabled></el-input>
  4. <el-tree
  5. ref="dut"
  6. :data="userList"
  7. @check="change"
  8. show-checkbox
  9. :props="{label:'name'}"
  10. node-key="id">
  11. </el-tree>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: "index",
  17. props: {
  18. userList: {
  19. type: Array,
  20. default: []
  21. }
  22. },
  23. data() {
  24. return {
  25. userNames: undefined
  26. }
  27. },
  28. methods: {
  29. change() {
  30. let checkedNodes = this.$refs.dut.getCheckedNodes(true, false);
  31. let val = checkedNodes.map(node => node.id);
  32. let labels = checkedNodes.map(node => node.name);
  33. this.userNames = labels.join()
  34. this.$emit('selected', val)
  35. this.$emit('selectNode', checkedNodes)
  36. }
  37. }
  38. }
  39. </script>
  40. <style scoped>
  41. </style>