瀏覽代碼

项目管理

ZaiZai 1 年之前
父節點
當前提交
0ad96f6d67
共有 2 個文件被更改,包括 55 次插入2 次删除
  1. 5 0
      src/styles/app/element.scss
  2. 50 2
      src/views/project/modules/list/wbs-tree.vue

+ 5 - 0
src/styles/app/element.scss

@@ -217,3 +217,8 @@
         flex: 1;
     }
 }
+
+//树卡片
+.hc-div-new-card-box.is-tree .el-card.hc-new-card-box .hc-card-main .hc-card-main-body {
+    left: -12px;
+}

+ 50 - 2
src/views/project/modules/list/wbs-tree.vue

@@ -14,7 +14,7 @@
             <div class="body">
                 <hc-body split padding="8px">
                     <template #left>
-                        <hc-new-card title="工程节点信息" scrollbar>
+                        <hc-new-card title="工程节点信息" scrollbar class="is-tree">
                             <template #search>
                                 <hc-search-input v-model="searchTree.queryValue" @search="searchTreeClick">
                                     <template #prepend>
@@ -25,7 +25,7 @@
                                     </template>
                                 </hc-search-input>
                             </template>
-                            工程节点信息
+                            <hc-lazy-tree :h-props="treeProps" tree-key="id" @load="treeLoadNode" />
                         </hc-new-card>
                     </template>
                     <div class="body-top">
@@ -50,9 +50,12 @@
 
 <script setup>
 import { ref, watch } from 'vue'
+import { useAppStore } from '~src/store'
 import { delMessage } from 'hc-vue3-ui'
 import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
 import mainApi from '~api/project/project'
+import wbsPrivateApi from '~api/wbs/private'
+
 
 const props = defineProps({
     type: {
@@ -74,6 +77,8 @@ const isShow = defineModel('modelValue', {
     default: false,
 })
 
+const store = useAppStore()
+
 //监听数据
 const isType = ref(props.type)
 const projectInfo = ref(props.info)
@@ -98,11 +103,18 @@ watch(isShow, (val) => {
 
 //获取项目信息
 const typeLable = ref('')
+const wbsId = ref('')
 const getProjectData = () => {
     const type = isType.value ?? 1
     const wbsArr = ['WBS树管理', '实验划分', '计量管理', '日志树管理', '征拆划分']
     typeLable.value = wbsArr[Number(type) - 1]
+    const wbsIds = [
+        'referenceWbsTemplateId', 'referenceWbsTemplateIdTrial', 'referenceWbsTemplateIdMeter',
+        'referenceLogWbsTemplateId', 'referenceWbsTemplateIdLar',
+    ]
+    wbsId.value = projectInfo.value[wbsIds[Number(type) - 1]]
     console.log('type: ', type)
+    console.log('wbsId: ', wbsId.value)
     console.log('info: ', projectInfo.value)
 }
 
@@ -111,6 +123,42 @@ const searchTree = ref({ queryValue: '', type: '1' })
 const searchTreeClick = () => {
 
 }
+
+//树属性
+const treeProps = {
+    children: 'children',
+    label: 'title',
+    isLeaf: ({ hasChildren, isExistForm, majorDataType, nodeType }) => {
+        let tag = false
+        if (!hasChildren) {
+            tag = true
+        }
+        if (isExistForm === 1) {
+            tag = true
+        }
+        if (nodeType >= 6 && nodeType <= 13) {
+            tag = true
+        }
+        //中间交工。开工报告、质量评定)
+        if (majorDataType >= 1 && majorDataType <= 3) {
+            tag = true
+        }
+        return tag
+    },
+}
+
+//懒加载树
+const treeLoadNode = async ({ item, level }, resolve) => {
+    let pid = level !== 0 ? item.id : 0
+    const { data } = await wbsPrivateApi.getLazytree({
+        wbsId: wbsId.value,
+        parentId: pid,
+        tenantId: store.tenantId,
+        projectId: projectInfo.value.id,
+        wbsType: isType.value,
+    })
+    resolve(getArrValue(data))
+}
 </script>
 
 <style scoped lang="scss">