Browse Source

Added SectorName Query Functionality

Fruit of Eden 6 năm trước cách đây
mục cha
commit
3d27377e3b
2 tập tin đã thay đổi với 27 bổ sung1 xóa
  1. 26 0
      js/basic.js
  2. 1 1
      js/lazhang-data.js

+ 26 - 0
js/basic.js

@@ -284,6 +284,32 @@ function on_secname_retn(obj, sta) {
     }
 }
 
+function getSectorId(spotId){
+    var secName = null;
+    Sectors.list.forEach(function(val, aid, arr){
+        if(val.sector.spotId === spotId){
+            secName = val.sector.sectorName;
+        }
+    });
+    if(secName == null) {
+        get_data("fcSectorSpot/list?spotId=" + spotId, on_secid_retn);
+        return "[工位:"+sectorId+"]";
+    }else{
+        return secName;
+    }
+}
+
+function on_secid_retn(obj, sta) {
+    var secid = this.url.substring(this.url.indexOf("sectorId=") + 9);
+    let rsecid = parseInt(secid);
+    var out = first_parse(this, obj);
+    if(out.list.length > 0){
+        Sectors.list.push({
+            secid : rsecid, sector: out.list[0]
+        });
+    }
+}
+
 /**
  *  Calc b/a+b * 100(precision = 2), when b is zero, return zero
  * @param a (pass)

+ 1 - 1
js/lazhang-data.js

@@ -180,7 +180,7 @@ function realtime_success(obj, sta) {
         stackeverynum[0] = 0;
         z = 0;
         for (i = 1; i < output.list.length; i++) {
-            var thisUid = output.list[i].sectorId;
+            var thisUid = getSectorId(output.list[i].spotId);
             x = 0;
             for (j = 0; j < sectorID.length; j++) {
                 if (sectorID[j] === thisUid) {