Parcourir la source

pms 设备顶级分类

zhangcl il y a 3 mois
Parent
commit
5401afbbb9

+ 3 - 3
src/views/pms/bom/BomForm.vue

@@ -203,9 +203,9 @@ const resetForm = () => {
 const getDeviceCategoryTree = async () => {
   deviceCategoryTree.value = []
   const res = await DeviceCategoryApi.IotProductClassifyApi.getSimpleProductClassifyList()
-  let bom: Tree = { id: 0, name: '顶级Bom', children: [] }
-  bom.children = handleTree(res)
-  deviceCategoryTree.value.push(bom)
+  let device: Tree = { id: 0, name: '顶级设备分类', children: [] }
+  device.children = handleTree(res)
+  deviceCategoryTree.value.push(device)
 }
 
 /** 获得 Bom 树 */

+ 6 - 1
src/views/pms/bom/DeviceCategoryTree.vue

@@ -14,6 +14,7 @@
       :filter-node-method="filterNode"
       :props="defaultProps"
       :default-expand-all="false"
+      :default-expanded-keys="firstLevelKeys"
       highlight-current
       node-key="id"
       @node-click="handleNodeClick"
@@ -84,7 +85,11 @@ const handleMenuClick = (action) => {
 const getTree = async () => {
   const res = await DeviceCategoryApi.IotProductClassifyApi.getSimpleProductClassifyList()
   deviceCategoryList.value = []
-  deviceCategoryList.value.push(...handleTree(res))
+  let device: Tree = { id: 0, name: '顶级设备分类', children: [] }
+  device.children = handleTree(res)
+  // deviceCategoryList.value.push(...handleTree(res))
+  deviceCategoryList.value.push(device)
+  firstLevelKeys.value = deviceCategoryList.value.map(node => node.id);
 }
 
 /** 基于名字过滤 */

+ 2 - 1
src/views/pms/bom/index.vue

@@ -58,7 +58,8 @@
             <el-button type="danger" plain @click="toggleExpandAll">
               <Icon icon="ep:sort" class="mr-5px" /> 展开/折叠
             </el-button>
-            <el-button @click="handleAllQuery"><Icon icon="ep:search" class="mr-5px" /> 查询所有</el-button>
+            <!--
+            <el-button @click="handleAllQuery"><Icon icon="ep:search" class="mr-5px" /> 查询所有</el-button> -->
           </el-form-item>
         </el-form>
       </ContentWrap>

+ 8 - 1
src/views/pms/devicetemplate/DeviceCategoryTree.vue

@@ -14,6 +14,7 @@
       :filter-node-method="filterNode"
       :props="defaultProps"
       :default-expand-all="false"
+      :default-expanded-keys="firstLevelKeys"
       highlight-current
       node-key="id"
       @node-click="handleNodeClick"
@@ -50,6 +51,8 @@ const menuVisible = ref(false);
 const menuX = ref(0);
 const menuY = ref(0);
 let selectedNode = null;
+const firstLevelKeys = ref([])
+
 const handleRightClick = (event, { node, data }) => {
   event.preventDefault();
   menuX.value = event.clientX;
@@ -76,7 +79,11 @@ const handleMenuClick = (action) => {
 const getTree = async () => {
   const res = await DeviceCategoryApi.IotProductClassifyApi.getSimpleProductClassifyList()
   deviceCategoryList.value = []
-  deviceCategoryList.value.push(...handleTree(res))
+  let device: Tree = { id: 0, name: '顶级设备分类', children: [] }
+  device.children = handleTree(res)
+  // deviceCategoryList.value.push(...handleTree(res))
+  deviceCategoryList.value.push(device)
+  firstLevelKeys.value = deviceCategoryList.value.map(node => node.id);
 }
 
 /** 基于名字过滤 */

+ 2 - 1
src/views/pms/devicetemplate/index.vue

@@ -74,7 +74,8 @@
             >
               <Icon icon="ep:plus" /> 新增
             </el-button>
-            <el-button @click="handleAllQuery"><Icon icon="ep:search" />查询所有</el-button>
+            <!--
+            <el-button @click="handleAllQuery"><Icon icon="ep:search" />查询所有</el-button> -->
           </el-form-item>
         </el-form>
       </ContentWrap>