Browse Source

项目管理

ZaiZai 1 year ago
parent
commit
309ddd17e6
6 changed files with 379 additions and 61 deletions
  1. 1 2
      package.json
  2. 264 0
      src/api/modules/wbs/tree.js
  3. 11 0
      src/utils/tools.js
  4. 99 17
      src/views/project/modules/list/wbs-tree.vue
  5. 0 3
      uno.config.js
  6. 4 39
      yarn.lock

+ 1 - 2
package.json

@@ -21,7 +21,7 @@
         "dayjs": "^1.11.10",
         "echarts": "^5.5.0",
         "element-plus": "2.6.1",
-        "hc-vue3-ui": "^3.2.5",
+        "hc-vue3-ui": "^3.3.0",
         "js-base64": "^3.7.7",
         "js-fast-way": "^0.4.6",
         "js-md5": "^0.8.3",
@@ -44,7 +44,6 @@
         "sass": "^1.71.1",
         "unocss": "^0.58.5",
         "unocss-preset-extra": "^0.5.3",
-        "unocss-preset-scrollbar": "^0.3.1",
         "vite": "^5.1.5"
     }
 }

+ 264 - 0
src/api/modules/wbs/tree.js

@@ -0,0 +1,264 @@
+import { HcApi } from '../../request/index'
+
+export default {
+    async getList(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/lazy-tree?parentId=0',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async getLazytree(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/lazy-tree',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async getAlltree(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/tree',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async getDetail(id) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/detail',
+            method: 'get',
+            params: { id },
+        }, false)
+    },
+    async remove(id) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/remove',
+            method: 'post',
+            params: { id },
+        }, false)
+    },
+    async submit(data) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/submit',
+            method: 'post',
+            data: data,
+        }, false)
+    },
+    async selectByNodeTable(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/get-node-table',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async getParamElements(form) {
+        return HcApi({
+            url: '/api/blade-manager/param/get-param-elements',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async delParamElements(form) {
+        return HcApi({
+            url: '/api/blade-manager/param/del-param-elements',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async specifiedParamElements(form) {
+        return HcApi({
+            url: '/api/blade-manager/param/specified-param-elements',
+            method: 'post',
+            params: form,
+        }, false)
+    },
+    async saveFormAndElement(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/save-table-element',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async selectFormElements(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/get-table-elements',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async selectPrivateFormElements(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/get-private-table-elements',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async getTableElments(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/get-table-formula-elements',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async removeTableById(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/remove-table',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async importWbsTree(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/import-wbsTree',
+            method: 'post',
+            headers: { 'Content-Type': 'multipart/form-data' },
+            data: form,
+        }, false)
+    },
+    async exportTemplate() {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/export-template',
+            method: 'get',
+            responseType: 'arraybuffer',
+        }, false)
+    },
+    async findWbsTreeSameLevel(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/get-same-level',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async wbsTreeSort(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/submit-sort',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async findWbsTreeTableSameLevel(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsFormElement/get-table-same-level',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async wbsTreeTableSort(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsFormElement/submit-table-sort',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async findWbsTreePrivateSameLevel(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsPrivate/get-node-same-level',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async wbsTreePrivateSort(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsPrivate/submit-sort',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async parameters(form) {
+        return HcApi({
+            url: '/api/blade-manager/param/list',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async saveOrUpdateBatch(form) {
+        return HcApi({
+            url: '/api/blade-manager/param/saveOrUpdateBatch',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async keymap(form) {
+        return HcApi({
+            url: '/api/blade-manager/param/keymap',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async importwbsTreeFormBatch(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/import-wbsTreeFormBatch',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async exportBatchTemplate(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/export-batchTemplate',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async updateBatchNodeTableInfo(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/update-batch-node-tableInfo',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async updateBatchNodeTableInfo2(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsPrivate/update-batch-node-tableInfo',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async updateBatchNodeTableInfoElement(form) {
+        return HcApi({
+            url: '/api/blade-manager/tableinfo/update-batch-tableInfo',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async updateStatus(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsPrivate/update-status',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async getNodeTabAndParam(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/get-node-table-param',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async submitFullName(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/submit-full-name',
+            method: 'post',
+            params: form,
+        }, false)
+    },
+    async refrehPram(form) {
+        return HcApi({
+            url: '/api/blade-manager/param/refresh',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async syncCurrentFormInProject(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsPrivate/syncCurrentFormInProject',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    async getQueryValueByType(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTree/getQueryValueByType',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+}

+ 11 - 0
src/utils/tools.js

@@ -1,6 +1,17 @@
+import { nextTick } from 'vue'
 import { getArrValue } from 'js-fast-way'
 import { getBizDictionary, getDictionary } from '~api/other'
 
+//设置分割滑块
+export const setSplit = (ids, data) => {
+    //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
+    nextTick(() => {
+        setTimeout(() => {
+            window.$split(ids, data)
+        }, 300)
+    }).then()
+}
+
 //刷新页面
 export const reloadPage = () => {
     setTimeout(() => {

+ 99 - 17
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 class="is-tree">
+                        <hc-new-card v-loading="isTreeLoading" title="工程节点信息" scrollbar class="is-tree">
                             <template #search>
                                 <hc-search-input v-model="searchTree.queryValue" @search="searchTreeClick">
                                     <template #prepend>
@@ -25,20 +25,26 @@
                                     </template>
                                 </hc-search-input>
                             </template>
+                            <hc-data-tree
+                                v-if="isSearchTree" :h-props="treeProps" :datas="treeLoadData" tree-key="id" :auto-expand-keys="treeExpandKeys"
+                                :menus="treeMenus" @menu-tap="treeMenuClick" @node-tap="treeNodeClick"
+                            />
                             <hc-lazy-tree
-                                :h-props="treeProps" tree-key="id" :menus="treeMenus" :auto-expand-keys="treeExpandKeys"
-                                @load="treeLoadNode" @menu-tap="treeMenuClick" @node-tap="treeNodeClick"
+                                v-else :h-props="treeProps" tree-key="id" :auto-expand-keys="treeExpandKeys"
+                                :menus="treeMenus" @load="treeLoadNode" @menu-tap="treeMenuClick" @node-tap="treeNodeClick"
                             />
                         </hc-new-card>
                     </template>
-                    <div class="body-top">
+                    <div :id="`hc_body_top_${uuid}`" class="body-top">
                         <hc-body padding="0px">
                             <hc-new-card title="节点信息">
-                                节点信息
+                                <hc-table is-new :column="nodeTableColumn" :datas="nodeTableData">
+                                    <template #nodeType="{ row }">{{ getDictionaryName(nodeTypelist, row.nodeType, true) }}</template>
+                                </hc-table>
                             </hc-new-card>
                         </hc-body>
                     </div>
-                    <div class="body-content">
+                    <div :id="`hc_body_content_${uuid}`" class="body-content">
                         <hc-body padding="0px">
                             <hc-new-card title="当前项目信息表">
                                 当前项目信息表
@@ -54,9 +60,11 @@
 <script setup>
 import { ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
-import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
-import { delMessage, getStore } from 'hc-vue3-ui'
+import { delMessage, getStore, setStore } from 'hc-vue3-ui'
+import { getArrValue, getObjValue, getRandom, isNullES } from 'js-fast-way'
+import { getDictionaryData, setSplit } from '~uti/tools'
 import mainApi from '~api/project/project'
+import wbsTreeApi from '~api/wbs/tree'
 import wbsPrivateApi from '~api/wbs/private'
 
 const props = defineProps({
@@ -96,6 +104,7 @@ watch(() => [
 watch(isShow, (val) => {
     if (val) {
         getProjectData()
+        setSplitRef()
     } else {
         projectInfo.value = {}
         isType.value = ''
@@ -103,6 +112,16 @@ watch(isShow, (val) => {
     }
 })
 
+//初始化设置拖动分割线
+const uuid = getRandom(4)
+const setSplitRef = () => {
+    setSplit(['#hc_body_top_' + uuid, '#hc_body_content_' + uuid], {
+        direction: 'vertical',
+        sizes: [25, 75],
+        snapOffset: 0,
+    })
+}
+
 //获取项目信息
 const typeLable = ref('')
 const wbsId = ref('')
@@ -111,19 +130,50 @@ const getProjectData = () => {
     const wbsArr = ['WBS树管理', '实验划分', '计量管理', '日志树管理', '征拆划分']
     typeLable.value = wbsArr[Number(type) - 1]
     const wbsIds = [
-        'referenceWbsTemplateId', 'referenceWbsTemplateIdTrial', 'referenceWbsTemplateIdMeter',
-        'referenceLogWbsTemplateId', 'referenceWbsTemplateIdLar',
+        '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)
+    getNodeTypelist(Number(type) - 1)
+}
+
+//获取节点类型
+const nodeTypelist = ref([])
+const getNodeTypelist = async (type) => {
+    const types = ['wbs_node_type', 'trial_node_type', 'meter_node_type', 'wbs_node_type', 'lar_node_type']
+    const data = await getDictionaryData(types[type])
+    nodeTypelist.value = getArrValue(data)
+}
+
+//获取字典里的数据
+const getDictionaryName = (arr, id, name) => {
+    const item = arr.find((item) => item.value === id)
+    return name ? item?.label : getObjValue(item)
 }
 
 //树节点搜索
+const isSearchTree = ref(false)
+const isTreeLoading = ref(false)
 const searchTree = ref({ queryValue: '', type: '1' })
 const searchTreeClick = () => {
+    const { queryValue } = searchTree.value
+    isSearchTree.value = !isNullES(queryValue)
+    getTreeLoadData()
+}
 
+//获取搜索树的数据
+const treeLoadData = ref([])
+const getTreeLoadData = async () => {
+    isTreeLoading.value = true
+    const { data } = await wbsTreeApi.getQueryValueByType({
+        ...searchTree.value,
+        wbsId: wbsId.value,
+        projectId: projectInfo.value.id,
+    })
+    treeLoadData.value = getArrValue(data)
+    isTreeLoading.value = false
 }
 
 //树属性
@@ -177,9 +227,43 @@ const treeLoadNode = async ({ item, level }, resolve) => {
     resolve(getArrValue(data))
 }
 
+//节点信息
+const nodeTableColumn = ref([
+    { key: 'nodeName', name: '当前节点' },
+    { key: 'nodeType', name: '节点类型' },
+    { key: 'parentName', name: '上级节点' },
+])
+const nodeTableData = ref([])
+
 //节点被点击
+const treeItem = ref({})
 const treeNodeClick = ({ node, data, keys }) => {
+    //获取父节点名称
+    let parentName = ''
+    if (node?.parent?.data) {
+        parentName = node.parent.data.title ?? ''
+    }
+    data.parentName = parentName
+    //设置相关数据
+    treeItem.value = getObjValue(data)
+    setStore('project-wbs-tree-expand-keys', keys)
+    treeExpandKeys.value = getArrValue(keys)
+    //获取节点详情
+    getTreeDetail(data.id, parentName)
+}
 
+//获取节点详情
+const treeInfo = ref({})
+const getTreeDetail = async (id, parentName) => {
+    const { data } = await wbsPrivateApi.detail({
+        id,
+        wbsId: wbsId.value,
+        projectId: projectInfo.value.id,
+    })
+    const res = getObjValue(data)
+    res.parentName = parentName
+    treeInfo.value = res
+    nodeTableData.value = [res]
 }
 </script>
 
@@ -212,16 +296,14 @@ const treeNodeClick = ({ node, data, keys }) => {
 
 <style lang="scss">
 .hc-project-wbs-tree .body .hc-page-split-content {
-    display: flex;
-    flex-direction: column;
+    position: relative;
     .body-top {
         position: relative;
-        flex: 1;
+        height: 166px;
     }
     .body-content {
         position: relative;
-        margin-top: 10px;
-        flex: 4;
+        height: calc(100% - 166px);
     }
 }
 </style>

+ 0 - 3
uno.config.js

@@ -1,5 +1,4 @@
 import { defineConfig, presetAttributify, presetIcons, presetUno } from 'unocss'
-import { presetScrollbar } from 'unocss-preset-scrollbar'
 import { presetExtra } from 'unocss-preset-extra'
 
 export default defineConfig({
@@ -16,8 +15,6 @@ export default defineConfig({
             prefix: 'hc-', //属性冲突的自定义前缀
             prefixedOnly: true, //强制使用前缀
         }),
-        //滚动条
-        presetScrollbar(),
         //其它扩展,主要用动画,集成了 animate.css
         presetExtra(),
     ],

+ 4 - 39
yarn.lock

@@ -816,11 +816,6 @@
     "@unocss/core" "0.58.5"
     unconfig "^0.3.11"
 
-"@unocss/core@0.56.5", "@unocss/core@^0.56.5":
-  version "0.56.5"
-  resolved "http://39.108.216.210:9000/@unocss/core/-/core-0.56.5.tgz#5c3caf24dd0d13e359aa71112d0487b685cb165a"
-  integrity sha512-fx5VhOjSHn0HdV2D34pEwFMAHJcJQRTCp1xEE4GzxY1irXzaa+m2aYf5PZjmDxehiOC16IH7TO9FOWANXk1E0w==
-
 "@unocss/core@0.58.5", "@unocss/core@^0.58.5":
   version "0.58.5"
   resolved "http://39.108.216.210:9000/@unocss/core/-/core-0.58.5.tgz#7bd38512710df7ff1fea4137d92aea6199ddc260"
@@ -844,13 +839,6 @@
     magic-string "^0.30.6"
     synckit "^0.9.0"
 
-"@unocss/extractor-arbitrary-variants@0.56.5":
-  version "0.56.5"
-  resolved "http://39.108.216.210:9000/@unocss/extractor-arbitrary-variants/-/extractor-arbitrary-variants-0.56.5.tgz#fa88a30bc10e68f2899f375aa01e03f11ea18d01"
-  integrity sha512-p2pyzz/ONvc5CGcaB9OZvWE8qkRSgyuhaQqFQLdBFeUhveHC0CGP0iSnXwBgAFHWM7DJo4/JpWeZ+mBt0ogVLA==
-  dependencies:
-    "@unocss/core" "0.56.5"
-
 "@unocss/extractor-arbitrary-variants@0.58.5":
   version "0.58.5"
   resolved "http://39.108.216.210:9000/@unocss/extractor-arbitrary-variants/-/extractor-arbitrary-variants-0.58.5.tgz#eadc23f553c7b6aad4c74c0581c7d1704735f30a"
@@ -906,15 +894,6 @@
     "@unocss/extractor-arbitrary-variants" "0.58.5"
     "@unocss/rule-utils" "0.58.5"
 
-"@unocss/preset-mini@^0.56.0":
-  version "0.56.5"
-  resolved "http://39.108.216.210:9000/@unocss/preset-mini/-/preset-mini-0.56.5.tgz#109fe9183b12313b7f9923577791391cf55989f3"
-  integrity sha512-/KhlThhs1ilauM7MwRSpahLbIPZ5VGeGvaUsU8+ZlNT3sis4yoVYkPtR14tL2IT6jhOU05N/uu3aBj+1bP8GjQ==
-  dependencies:
-    "@unocss/core" "0.56.5"
-    "@unocss/extractor-arbitrary-variants" "0.56.5"
-    "@unocss/rule-utils" "0.56.5"
-
 "@unocss/preset-tagify@0.58.5":
   version "0.58.5"
   resolved "http://39.108.216.210:9000/@unocss/preset-tagify/-/preset-tagify-0.58.5.tgz#d7b6c86cf9a71b4e9d6bb5051af7ed9d5fe14e44"
@@ -962,13 +941,6 @@
   resolved "http://39.108.216.210:9000/@unocss/reset/-/reset-0.58.5.tgz#2284efdd7adbd01e07905337727557b77a2e9114"
   integrity sha512-2wMrkCj3SSb5hrx9TKs5jZa34QIRkHv9FotbJutAPo7o8hx+XXn56ogzdoUrcFPJZJUx2R2nyOVbSlGMIjtFtw==
 
-"@unocss/rule-utils@0.56.5":
-  version "0.56.5"
-  resolved "http://39.108.216.210:9000/@unocss/rule-utils/-/rule-utils-0.56.5.tgz#ca924845081aa231d007533b65510c9e9fc0c034"
-  integrity sha512-CXIGHCIC9B8WUl9KbbFMSZHcsIgfmI/+X0bjBv6xrgBVC1EQ2Acq4PYnJIbaRGBRAhl9wYjNL7Zq2UWOdowHAw==
-  dependencies:
-    "@unocss/core" "^0.56.5"
-
 "@unocss/rule-utils@0.58.5":
   version "0.58.5"
   resolved "http://39.108.216.210:9000/@unocss/rule-utils/-/rule-utils-0.58.5.tgz#d21cf790b53b812c3185c4352fe72698162ff3f5"
@@ -2015,10 +1987,10 @@ has-flag@^4.0.0:
   resolved "http://39.108.216.210:9000/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
   integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
 
-hc-vue3-ui@^3.2.5:
-  version "3.2.5"
-  resolved "http://39.108.216.210:9000/hc-vue3-ui/-/hc-vue3-ui-3.2.5.tgz#f33352322860471d0aa2628d2f4e941cd7d00677"
-  integrity sha512-jRCa7WPuMTVZQDWH0KM+OC72d+g1E71p46AtaSgZE1uPqWmPKLxMN8XlMT1RrIDQ6Vy6w0oHanbydnPwffBMSQ==
+hc-vue3-ui@^3.3.0:
+  version "3.3.0"
+  resolved "http://39.108.216.210:9000/hc-vue3-ui/-/hc-vue3-ui-3.3.0.tgz#bf179cab0ed6b67df0d410be40a1649e13fb0653"
+  integrity sha512-lmSZUY9/5lZUBwC3XRxXBQw3z2hnYBArP/gr06Z+7es0cjiUVK0xrg45MU9nwpOjLq1Fyq6IidPOQYou3BUJkA==
 
 human-signals@^2.1.0:
   version "2.1.0"
@@ -2925,13 +2897,6 @@ unocss-preset-extra@^0.5.3:
   resolved "http://39.108.216.210:9000/unocss-preset-extra/-/unocss-preset-extra-0.5.3.tgz#eaa703e84f5652f544599f4de424a3a128147174"
   integrity sha512-rRosBmJ3S8/97o/l4J1lc3AJnSGMSD1FgDs4bvUWmrz2OQvPheuZluL8xULEd5MGwHjw4vAwYkue114pnVelzA==
 
-unocss-preset-scrollbar@^0.3.1:
-  version "0.3.1"
-  resolved "http://39.108.216.210:9000/unocss-preset-scrollbar/-/unocss-preset-scrollbar-0.3.1.tgz#a7faff0522e046c037300dcf92bec3000519fcb8"
-  integrity sha512-LhvcQA1cfwq06sqAZY++1crrLsOf/IfOPdyCkMHVyywI9WCvMhxCJlCcrySlQI8/Y2VUjOpLBDWB0w3DXS5qRA==
-  dependencies:
-    "@unocss/preset-mini" "^0.56.0"
-
 unocss@^0.58.5:
   version "0.58.5"
   resolved "http://39.108.216.210:9000/unocss/-/unocss-0.58.5.tgz#feeedb3fab6c913634c4a8eabd86d4a893a640a9"