allocateDialog.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <el-dialog
  3. :visible.sync="allocatedialogVisible"
  4. title="关联WBS"
  5. width="500"
  6. append-to-body
  7. >
  8. <div class="flex1 ov-hidden" style="height: 500px;">
  9. <el-scrollbar class="h-100p">
  10. <div v-loading="treeLoad">
  11. <el-tree
  12. class="filter-tree"
  13. lazy
  14. :load="loadNode"
  15. :props="defaultProps"
  16. :expand-on-click-node="false"
  17. highlight-current
  18. check-strictly
  19. :check-on-click-node="false"
  20. node-key="id"
  21. ref="tree"
  22. @check-change="handleCheckChange"
  23. >
  24. <span class="custom-tree-node" slot-scope="{node,data}" style="justify-content: flex-start;">
  25. <span> <el-checkbox v-model="data.checked" v-if="!data.hasChildren"></el-checkbox></span>
  26. {{ node.label }}
  27. </span>
  28. </el-tree>
  29. </div>
  30. </el-scrollbar>
  31. </div>
  32. <template #footer>
  33. <div class="dialog-footer">
  34. <el-button @click="allocatedialogVisible = false">取消</el-button>
  35. <el-button type="primary" @click="allocatedialogVisible = false">
  36. 确认
  37. </el-button>
  38. </div>
  39. </template>
  40. </el-dialog>
  41. </template>
  42. <script>
  43. import { getLazytree,} from "@/api/manager/wbsprivate";
  44. import { mapGetters } from "vuex";
  45. export default {
  46. props:{
  47. projectId:'',
  48. wbsId:'',
  49. wbsType:''
  50. },
  51. data () {
  52. return {
  53. allocatedialogVisible:false,
  54. treeLoad:false,
  55. defaultProps: {
  56. children: "children",
  57. label: "title",
  58. isLeaf: function (data) {
  59. //console.log(data, !data.hasChildren, data.isExistForm);
  60. let tag = false;
  61. if (!data.hasChildren) {
  62. tag = true;
  63. }
  64. if (data.isExistForm == 1) {
  65. tag = true;
  66. }
  67. if (data.nodeType >= 6 && data.nodeType <= 13) {
  68. tag = true;
  69. }
  70. //中间交工。开工报告、质量评定)
  71. if (
  72. data.majorDataType == 1 ||
  73. data.majorDataType == 2 ||
  74. data.majorDataType == 3
  75. ) {
  76. tag = true;
  77. }
  78. return tag;
  79. // return !data.hasChildren || (data.isExistForm == 1);
  80. },
  81. },
  82. }
  83. },
  84. computed: {
  85. ...mapGetters(["userInfo"]),
  86. },
  87. watch: {
  88. },
  89. created () {
  90. },
  91. mounted () {
  92. },
  93. methods: {
  94. show(){
  95. this.allocatedialogVisible=true
  96. },
  97. renderContent(h, { node, data, store }) {
  98. // 只有当节点没有子节点时才显示复选框
  99. if (!data.hasChildren ) {
  100. return (
  101. <span>
  102. <el-checkbox v-model={data.checked}></el-checkbox>
  103. <span>{node.label}</span>
  104. </span>
  105. );
  106. } else {
  107. return (
  108. <span>{node.label}</span>
  109. );
  110. }
  111. },
  112. loadNode(node, resolve) {
  113. let pid = 0;
  114. if (node.level != 0) {
  115. pid = node.data.id;
  116. }
  117. getLazytree(this.wbsId, pid, this.userInfo.tenant_id, this.projectId, {
  118. wbsType: this.wbsType,
  119. }).then((res) => {
  120. let arr = [];
  121. if (Array.isArray(res.data.data)) {
  122. arr = res.data.data;
  123. }
  124. return resolve(arr);
  125. });
  126. },
  127. handleCheckChange(checkedNodes) {
  128. // 在这里处理已选中的节点数据
  129. console.log(checkedNodes,'checkedNodes');
  130. }
  131. }
  132. };
  133. </script>
  134. <style scoped lang="scss">
  135. </style>