Procházet zdrojové kódy

qhse资料库左侧菜单

yanghao před 1 týdnem
rodič
revize
e44f45078b

+ 1 - 1
.env.local

@@ -4,7 +4,7 @@ NODE_ENV=development
 VITE_DEV=true
 
 # 请求路径  http://192.168.188.200:48080  https://iot.deepoil.cc:5443  http://172.26.0.56:48080  http://192.168.188.198:48080
-VITE_BASE_URL='https://iot.deepoil.cc:5443'
+VITE_BASE_URL='http://172.26.0.56:48080'
 
 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
 VITE_UPLOAD_TYPE=server

+ 5 - 0
src/api/pms/qhse/index.ts

@@ -734,5 +734,10 @@ export const DataLibraryApi = {
   // 导出资料 Excel
   exportIotInfo: async (params) => {
     return await request.download({ url: `/rq/qhse-info/export-excel`, params })
+  },
+
+  // 左侧树
+  getFileTree: async () => {
+    return await request.get({ url: '/rq/qhse-file-tree/page' })
   }
 }

+ 19 - 1
src/views/pms/qhse/data/PmsTree.vue

@@ -3,6 +3,7 @@ import { ElTree } from 'element-plus'
 import { CaretLeft, CaretRight, Search } from '@element-plus/icons-vue'
 import type { IotTreeVO } from '@/api/system/tree'
 import { IotTreeApi } from '@/api/system/tree'
+// import { DataLibraryApi } from '@/api/pms/qhse/index'
 import { defaultProps, handleTree } from '@/utils/tree'
 
 defineOptions({ name: 'IotTree' })
@@ -43,6 +44,22 @@ const getNodeIconClass = (type: string) => {
   return type === 'device' ? 'node-icon node-icon--device' : 'node-icon node-icon--folder'
 }
 
+const filterDeviceNodes = (nodes: TreeNode[]): TreeNode[] => {
+  return nodes.reduce<TreeNode[]>((result, node) => {
+    if (node.type === 'device') {
+      return result
+    }
+
+    const nextNode: TreeNode = { ...node }
+    if (node.children?.length) {
+      nextNode.children = filterDeviceNodes(node.children)
+    }
+
+    result.push(nextNode)
+    return result
+  }, [])
+}
+
 const findNodePath = (
   nodes: TreeNode[],
   targetId: number | string,
@@ -82,8 +99,9 @@ const locateNode = (targetId: number | string) => {
 }
 
 const getTreeInfo = async () => {
+  // const res = await DataLibraryApi.getFileTree()
   const res = await IotTreeApi.getSimpleTreeList()
-  treeList.value = handleTree(res) as TreeNode[]
+  treeList.value = filterDeviceNodes(handleTree(res) as TreeNode[])
   expandedKeys.value = treeList.value.map((node) => node.id)
 
   if (props.currentId) {

+ 12 - 14
src/views/pms/qhse/data/index.vue

@@ -19,7 +19,7 @@
           <el-input
             v-model="queryParams.filename"
             :placeholder="t('file.nameHolder')"
-            size="default"
+            size="small"
             clearable
             @keyup.enter="handleQuery"
             class="!w-240px" />
@@ -40,19 +40,17 @@
         </el-form-item>
       </div>
       <el-form-item>
-        <el-button size="default" @click="handleQuery">
-          <Icon icon="ep:search" class="mr-5px" />{{ t('file.search') }}
-        </el-button>
-        <el-button size="default" @click="resetQuery">
-          <Icon icon="ep:refresh" class="mr-5px" />{{ t('file.reset') }}
-        </el-button>
-        <el-button
-          type="primary"
-          size="default"
-          :loading="uploadLoading"
-          @click="openForm('create')">
-          <Icon icon="ep:plus" class="mr-5px" />{{ t('file.upload') }}
-        </el-button>
+        <div class="flex">
+          <el-button @click="handleQuery">
+            <Icon icon="ep:search" class="mr-5px" />{{ t('file.search') }}
+          </el-button>
+          <el-button @click="resetQuery">
+            <Icon icon="ep:refresh" class="mr-5px" />{{ t('file.reset') }}
+          </el-button>
+          <el-button type="primary" :loading="uploadLoading" @click="openForm('create')">
+            <Icon icon="ep:plus" class="mr-5px" />{{ t('file.upload') }}
+          </el-button>
+        </div>
       </el-form-item>
     </el-form>