hc-tree.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <el-tree
  3. ref="ElTreeRef" v-loaing="treeLoaing"
  4. :class="ui"
  5. :data="ElTreeData"
  6. :indent="0"
  7. :props="ElTreeProps"
  8. accordion
  9. class="hc-tree-node tree-line"
  10. highlight-current
  11. node-key="id"
  12. show-checkbox
  13. >
  14. <template #default="{ node, data }">
  15. <div :id="`'entry-sampling-'${data.id}`" class="data-custom-tree-node">
  16. <div class="label">
  17. <span> {{ data.nodeName }}</span>
  18. <span v-if="data.nodeInfo" class="text-orange text-sm">(该目录已分属XX专家,如需调整,请联系该专家进行转让)</span>
  19. </div>
  20. </div>
  21. </template>
  22. </el-tree>
  23. </template>
  24. <script setup>
  25. import { onMounted, ref } from 'vue'
  26. //import dataFillQuery from '~api/data-fill/query';
  27. import { getArrValue, getObjValue } from 'js-fast-way'
  28. import initialgApi from '~api/initial/initial'
  29. //参数
  30. const props = defineProps({
  31. ui: {
  32. type: String,
  33. default: '',
  34. },
  35. projectId: {
  36. type: [String, Number],
  37. default: '',
  38. },
  39. contractId: {
  40. type: [String, Number],
  41. default: '',
  42. },
  43. types:{
  44. type: [String, Number],
  45. default: '',
  46. },
  47. })
  48. const projectId = ref(props.projectId)
  49. const types = ref(props.types)
  50. onMounted(()=>{
  51. getElTreeData()
  52. })
  53. //变量
  54. const ElTreeRef = ref(null)
  55. const ElTreeProps = ref({
  56. children: 'children',
  57. label: 'nodeName',
  58. })
  59. const treeLoaing = ref(false)
  60. const getElTreeData = async ()=>{
  61. treeLoaing.value = true
  62. const { error, code, data } = await initialgApi.getUnitAllNode({
  63. projectId: projectId.value,
  64. types:types.value,
  65. })
  66. treeLoaing.value = false
  67. if (!error && code === 200) {
  68. console.log(data, 'data')
  69. ElTreeData.value = getArrValue(data)
  70. } else {
  71. ElTreeData.value = []
  72. }
  73. }
  74. const ElTreeData = ref( [])
  75. </script>
  76. <style lang="scss" scoped>
  77. @import "../../../../styles/app/tree.scss";
  78. </style>