Browse Source

modify parts add family

haojianlong 5 years ago
parent
commit
35f2eb8dc0

+ 7 - 0
src/api/scan/request.js

@@ -912,6 +912,13 @@ export function updateParts(param, success) {
     http.postJson(url, data, success)
 }
 
+//创建资产所需(Family族id3位编码)-根据设备类型(4位编码)或部件类型(6位编码)查询
+export function getEquipBelongs(param, success) {
+    let url = `${baseUrl}/datacenter/data-dictionary/family-query`;
+    let data = param.data;
+    http.postJson(url, data, success)
+}
+
 //创建资产
 export function createPropertyData(param, success) {
     let url = `${baseUrl}/datacenter/property/create?projectId=${param.projectId}`;

+ 16 - 35
src/views/ledger/facility/partsmanage/addparts/index.vue

@@ -54,8 +54,8 @@ import handsonTable from "@/components/common/handsontable";
 import {
   getDataDictionary,
   createPart,
-  getEquipmentFamily,
-  createPropertyData
+  createPropertyData,
+  getEquipBelongs
 } from "@/api/scan/request";
 import { mapGetters, mapActions } from "vuex";
 
@@ -121,7 +121,6 @@ export default {
       picsArr: [], //临时设备图片keys数组
       systemId: null,
       graphyId: null,
-      mess: {},
       id: 0,
       readArr: [
         "A1",
@@ -139,7 +138,7 @@ export default {
         "M"
       ],
       EquipmentList: [],
-      firmId: "" //品牌型号所需字段
+      firmId: "" //品牌型号所需字段--族id三位编码(传设备类id或部件类id)
     };
   },
   computed: {
@@ -148,18 +147,22 @@ export default {
   created() {
     this.category = this.$route.params;
     this.category.ParentId = this.category.Code.substr(0, 4);
-    this.mess = {
-      deviceId: this.category.ParentId
-    };
-    this.getEquipmentFamilyList();
+    this.getBelongs();
     this.getTableHeader();
   },
   methods: {
-    getEquipmentFamilyList() {
-      getEquipmentFamily(res => {
-        this.EquipmentList = res.Content;
-        this.changeCader();
-      });
+    //查询部件类对应的 族
+    getBelongs() {
+      let params = {
+        data: {
+          Filters: `EquipCode='${this.category.Code}'`,
+          PageNumber: 1,
+          PageSize: 50        
+        }
+      }
+      getEquipBelongs(params, res => {
+        this.firmId = res.Content[0].Family;
+      })
     },
     // 获取表头数据(初始化表格)
     async getTableHeader() {
@@ -358,7 +361,6 @@ export default {
     },
     //选择型号修改
     firmChange(data) {
-      console.log(this.row)
       tools.setDataForKey(this.tableData[this.row], "DPSpecificationID", data.specificationId)
       tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brand)
       tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
@@ -443,15 +445,6 @@ export default {
     changePics(keys) {
       this.setDataToMain(keys, this.messKey, this.row);
     },
-    setGraphyId(graphyId, assetGroupList) {
-      this.graphyId = graphyId;
-      this.assetGroupList = assetGroupList;
-    },
-    //触发父组件change
-    getClose(val) {
-      this.$emit("close", val);
-    },
-    reset() { },
     //表格点击事件
     handleTdClick(el, rowArr) {
       //点击的是表头
@@ -607,18 +600,6 @@ export default {
       this.row = row.row;
       this.messKey = val;
     },
-    //修改设备类型
-    changeCader() {
-      this.EquipmentList.map(item => {
-        if (!!item.content && item.content.length) {
-          item.content.map(child => {
-            if (child.code == this.mess.deviceId) {
-              this.firmId = item.code;
-            }
-          });
-        }
-      });
-    },
     utilToKey(key, name, data, messName) {
       if (key == name) {
         this.setDataToMain(data[key], messName, this.row);

+ 14 - 28
src/views/ledger/facility/partsmanage/index.vue

@@ -58,7 +58,7 @@ import {
   getEquipPartsCon,
   updateParts,
   deleteParts,
-  getEquipmentFamily
+  getEquipBelongs
 } from "@/api/scan/request";
 import { mapGetters, mapActions } from "vuex";
 
@@ -150,7 +150,7 @@ export default {
         "M"
       ],
       EquipmentList: [],
-      firmId: "" //品牌型号所需字段
+      firmId: "" //品牌型号所需字段--族id三位编码(传设备类id或部件类id)
     };
   },
   computed: {
@@ -161,14 +161,19 @@ export default {
     this.typeId = this.$route.query.typeId; //设备类id
     this.mess.deviceId = this.typeId;
     this.getTypes();
-    this.getEquipmentFamilyList();
   },
   methods: {
-    getEquipmentFamilyList() {
-      getEquipmentFamily(res => {
-        this.EquipmentList = res.Content;
-        this.changeCader();
-      });
+    getBelongs() {
+      let params = {
+        data: {
+          Filters: `EquipCode='${this.tabVal}'`,
+          PageNumber: 1,
+          PageSize: 50
+        }
+      }
+      getEquipBelongs(params, res => {
+        this.firmId = res.Content[0].Family;
+      })
     },
     //tab页点击事件
     tabsClick(tab) {
@@ -186,6 +191,7 @@ export default {
         this.tabVal = this.partsTypeList[0].Code;
         this.activeTab = this.partsTypeList[0];
         this.getTableHeader();
+        this.getBelongs();
       });
     },
     // 获取表头数据(初始化表格)
@@ -608,14 +614,6 @@ export default {
     changePics(keys) {
       this.setDataToMain(keys, this.messKey, this.row);
     },
-    setGraphyId(graphyId, assetGroupList) {
-      this.graphyId = graphyId;
-      this.assetGroupList = assetGroupList;
-    },
-    //触发父组件change
-    getClose(val) {
-      this.$emit("close", val);
-    },
     //表格点击事件
     handleTdClick(el, rowArr) {
       //点击的是表头
@@ -756,18 +754,6 @@ export default {
       this.row = row.row;
       this.messKey = val;
     },
-    //修改设备类型
-    changeCader() {
-      this.EquipmentList.map(item => {
-        if (!!item.content && item.content.length) {
-          item.content.map(child => {
-            if (child.code == this.mess.deviceId) {
-              this.firmId = item.code;
-            }
-          });
-        }
-      });
-    },
     utilToKey(key, name, data, messName) {
       if (key == name) {
         this.setDataToMain(data[key], messName, this.row);