Ver código fonte

设备导入导出优化

jingyuanchao 1 ano atrás
pai
commit
cfed21a76b
2 arquivos alterados com 33 adições e 13 exclusões
  1. 8 0
      src/api/system/device.js
  2. 25 13
      src/views/system/device/index.vue

+ 8 - 0
src/api/system/device.js

@@ -68,6 +68,14 @@ export function delDevice(id) {
 // 查询资产字典
 export function getDictTree() {
   return request({
+    url: '/system/dictionary/tree',
+    method: 'get'
+  })
+}
+
+// 查询资产字典
+export function getDictList() {
+  return request({
     url: '/system/dictionary/list',
     method: 'get'
   })

+ 25 - 13
src/views/system/device/index.vue

@@ -334,7 +334,7 @@ import {getDeviceType} from "@/api/system/dict/data";
 import {
   addDevice,
   delDevice,
-  getDevice,
+  getDevice, getDictList,
   getDictTree, getDictTreeByParentId,
   getHostByOrgId,
   listDevice,
@@ -390,6 +390,7 @@ export default {
       //主机集合
       hostList: [],
       dictionaryTreeList: [],
+      dictionaryList: [],
       assetChildrenDictList: [],
       brandChildrenDictList: [],
       deviceType: 0,
@@ -468,6 +469,7 @@ export default {
   },
   mounted() {
     this.initDictionaryTreeList();
+    this.initDictionaryList();
   },
 
 
@@ -705,21 +707,17 @@ export default {
       this.changeSelect(this.dept);
       this.devices = null;
     },
-    changeSelectDevice(val) {
-      if (val) {
-        getDeviceType(val).then((response) => {
-          this.devices = response.data;
-          this.form.deviceType = null;
-          this.queryParams.deviceType = null;
-        });
-      }
-    },
     //获取字典数据
     initDictionaryTreeList() {
       getDictTree().then((response) => {
         this.dictionaryTreeList = response.data;
       });
     },
+    initDictionaryList() {
+      getDictList().then((response) => {
+        this.dictionaryList = response.data;
+      });
+    },
     //从基础数据中获取资产分类
     getAssetDict(type, parentId) {
       let arr = []
@@ -728,12 +726,21 @@ export default {
       });
       return arr;
     },
+    //从基础数据中获取资产分类
+    getAssetDictDetailInfo(id) {
+      let arr = []
+      this.dictionaryList.filter(item => item.id == id).map(item => {
+        arr.push(item);
+      });
+      return arr;
+    },
     assetSelectChange(val) {
       //改成数据库查询, children里面
       if (!val) return;
       this.form.deviceType = null;
       getDictTreeByParentId(val).then((response) => {
         this.assetChildrenDictList = response.data;
+        console.log('获取设备分类数据', this.assetChildrenDictList);
       });
     },
     brandSelectChange(val) {
@@ -742,6 +749,7 @@ export default {
       this.form.deviceModel = null;
       getDictTreeByParentId(val).then((response) => {
         this.brandChildrenDictList = response.data;
+        console.log('获取设备型号数据', this.assetChildrenDictList);
       });
     },
     clearAsset() {
@@ -753,11 +761,15 @@ export default {
       const id = row.id || this.ids;
       getDevice(id).then((response) => {
         this.form = response.data;
-        // this.form.inBook=response.data.inBook.toString();
-        this.devices = response.devices;
-        this.hostList = response.hostList;
         this.open = true;
         this.title = "编辑设备信息";
+        console.log(this.form.assetType,this.form.deviceBrand)
+        getDictTreeByParentId(this.form.assetType).then((response) => {
+          this.assetChildrenDictList = response.data;
+        });
+        getDictTreeByParentId(this.form.deviceBrand).then((response) => {
+          this.brandChildrenDictList = response.data;
+        });
       });
     },
     /** 提交按钮 */