wbs-tree.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <hc-new-drawer v-model="isShow" is-close to-id="hc-project-list">
  3. <div class="hc-project-wbs-tree flex">
  4. <div class="header hc-flex">
  5. <div class="name flex-1">{{ typeLable }} - {{ projectInfo.projectName }}</div>
  6. <div class="hc-flex">
  7. <el-button hc-btn type="success">数据同步</el-button>
  8. <el-button hc-btn type="primary">表单设置</el-button>
  9. <el-button hc-btn type="danger">节点参数</el-button>
  10. <el-button hc-btn color="#626aef">独立表单库</el-button>
  11. <el-button hc-btn type="warning">归档文件时间</el-button>
  12. </div>
  13. </div>
  14. <div class="body">
  15. <hc-body split padding="8px">
  16. <template #left>
  17. <hc-new-card title="工程节点信息" scrollbar class="is-tree">
  18. <template #search>
  19. <hc-search-input v-model="searchTree.queryValue" @search="searchTreeClick">
  20. <template #prepend>
  21. <el-select v-model="searchTree.type" placeholder="类型" class="w-[75px]">
  22. <el-option label="节点" value="1" />
  23. <el-option label="表名" value="2" />
  24. </el-select>
  25. </template>
  26. </hc-search-input>
  27. </template>
  28. <hc-lazy-tree :h-props="treeProps" tree-key="id" @load="treeLoadNode" />
  29. </hc-new-card>
  30. </template>
  31. <div class="body-top">
  32. <hc-body padding="0px">
  33. <hc-new-card title="节点信息">
  34. 节点信息
  35. </hc-new-card>
  36. </hc-body>
  37. </div>
  38. <div class="body-content">
  39. <hc-body padding="0px">
  40. <hc-new-card title="当前项目信息表">
  41. 当前项目信息表
  42. </hc-new-card>
  43. </hc-body>
  44. </div>
  45. </hc-body>
  46. </div>
  47. </div>
  48. </hc-new-drawer>
  49. </template>
  50. <script setup>
  51. import { ref, watch } from 'vue'
  52. import { useAppStore } from '~src/store'
  53. import { delMessage } from 'hc-vue3-ui'
  54. import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
  55. import mainApi from '~api/project/project'
  56. import wbsPrivateApi from '~api/wbs/private'
  57. const props = defineProps({
  58. type: {
  59. type: [String, Number],
  60. default: '1',
  61. },
  62. info: {
  63. type: Object,
  64. default: () => ({}),
  65. },
  66. })
  67. //事件
  68. const emit = defineEmits(['change', 'close'])
  69. //双向绑定
  70. // eslint-disable-next-line no-undef
  71. const isShow = defineModel('modelValue', {
  72. default: false,
  73. })
  74. const store = useAppStore()
  75. //监听数据
  76. const isType = ref(props.type)
  77. const projectInfo = ref(props.info)
  78. watch(() => [
  79. props.type,
  80. props.info,
  81. ], ([type, info]) => {
  82. isType.value = type
  83. projectInfo.value = info
  84. }, { deep: true })
  85. //监听显示
  86. watch(isShow, (val) => {
  87. if (val) {
  88. getProjectData()
  89. } else {
  90. projectInfo.value = {}
  91. isType.value = ''
  92. emit('close')
  93. }
  94. })
  95. //获取项目信息
  96. const typeLable = ref('')
  97. const wbsId = ref('')
  98. const getProjectData = () => {
  99. const type = isType.value ?? 1
  100. const wbsArr = ['WBS树管理', '实验划分', '计量管理', '日志树管理', '征拆划分']
  101. typeLable.value = wbsArr[Number(type) - 1]
  102. const wbsIds = [
  103. 'referenceWbsTemplateId', 'referenceWbsTemplateIdTrial', 'referenceWbsTemplateIdMeter',
  104. 'referenceLogWbsTemplateId', 'referenceWbsTemplateIdLar',
  105. ]
  106. wbsId.value = projectInfo.value[wbsIds[Number(type) - 1]]
  107. console.log('type: ', type)
  108. console.log('wbsId: ', wbsId.value)
  109. console.log('info: ', projectInfo.value)
  110. }
  111. //树节点搜索
  112. const searchTree = ref({ queryValue: '', type: '1' })
  113. const searchTreeClick = () => {
  114. }
  115. //树属性
  116. const treeProps = {
  117. children: 'children',
  118. label: 'title',
  119. isLeaf: ({ hasChildren, isExistForm, majorDataType, nodeType }) => {
  120. let tag = false
  121. if (!hasChildren) {
  122. tag = true
  123. }
  124. if (isExistForm === 1) {
  125. tag = true
  126. }
  127. if (nodeType >= 6 && nodeType <= 13) {
  128. tag = true
  129. }
  130. //中间交工。开工报告、质量评定)
  131. if (majorDataType >= 1 && majorDataType <= 3) {
  132. tag = true
  133. }
  134. return tag
  135. },
  136. }
  137. //懒加载树
  138. const treeLoadNode = async ({ item, level }, resolve) => {
  139. let pid = level !== 0 ? item.id : 0
  140. const { data } = await wbsPrivateApi.getLazytree({
  141. wbsId: wbsId.value,
  142. parentId: pid,
  143. tenantId: store.tenantId,
  144. projectId: projectInfo.value.id,
  145. wbsType: isType.value,
  146. })
  147. resolve(getArrValue(data))
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. .hc-project-wbs-tree {
  152. position: relative;
  153. background: #ececec;
  154. border-radius: 4px;
  155. height: 100%;
  156. flex-direction: column;
  157. overflow: hidden;
  158. .header {
  159. color: white;
  160. background: #54565A;
  161. padding: 10px 14px;
  162. flex-shrink: 0;
  163. .name {
  164. white-space:nowrap;
  165. overflow:hidden;
  166. text-overflow:ellipsis;
  167. }
  168. }
  169. .body {
  170. flex: 1;
  171. flex-basis: auto;
  172. position: relative;
  173. }
  174. }
  175. </style>
  176. <style lang="scss">
  177. .hc-project-wbs-tree .body .hc-page-split-content {
  178. display: flex;
  179. flex-direction: column;
  180. .body-top {
  181. position: relative;
  182. flex: 1;
  183. }
  184. .body-content {
  185. position: relative;
  186. margin-top: 10px;
  187. flex: 4;
  188. }
  189. }
  190. </style>