Ver código fonte

上傳檔案到 'static'

miacheng913 3 anos atrás
pai
commit
eb1e0fc7a5
1 arquivos alterados com 16 adições e 9 exclusões
  1. 16 9
      static/home.js

+ 16 - 9
static/home.js

@@ -39,6 +39,16 @@ function get_user_role(){
     user_role = data[0].user_role
 }
 
+function clear(){
+    document.getElementById('company').innerHTML='';
+    document.getElementById('towergroup').innerHTML='';
+    document.getElementById('company_name').innerHTML='';
+    document.getElementById('factory_select').innerHTML='';
+    document.getElementById("map").style.display="none";
+    document.getElementById('department_show').innerHTML="";
+    document.getElementById("department_list").style.display="none";
+}
+
 function company_show(){
     //顯示company按鈕
     var inner='';
@@ -52,13 +62,9 @@ function company_show(){
             console.log(obj[1][i].company);
         }
     }
+    clear();
     document.getElementById('company').innerHTML=inner;
-    document.getElementById('company_name').innerHTML='';
-    document.getElementById('factory_select').innerHTML='';
     company_health(company_arr);
-    document.getElementById("map").style.display="none";
-    document.getElementById('department_show').innerHTML="";
-    document.getElementById("department_list").style.display="none";
 }
 
 function company_health(company_arr){
@@ -140,11 +146,11 @@ function department_show(company,factory){
 
 function department_change(){
     console.log("change");
-    var inner='<table><tr><td>機組</td><td>健康狀態</td></tr>';
+    var inner='<table><tr><td>機組</td><td>健康狀態</td><td>查看</td></tr>';
     var tower_group_arr = new Array();
     for(var i=0;i<obj[1].length;i++){
         if(tower_group_arr.indexOf(obj[1][i].group)==-1 && obj[1][i].company==document.getElementById('company_text').innerHTML&& obj[1][i].factory==document.getElementById('factory_text').innerHTML&& obj[1][i].department==document.getElementById("department_list").value){
-            inner+='<tr><td>' + obj[1][i].group + '</td><td>健康</td></tr>' ;
+            inner+='<tr><td>' + obj[1][i].group + '</td><td>健康</td><td><button onclick=\"towerGroup_show();\">更多</button></td></tr>' ;
             tower_group_arr.push(obj[1][i].group);
         }
     }
@@ -160,10 +166,11 @@ function towerGroup_show(){
     for(var i=0;i<obj[1].length;i++){
         if(tower_group_arr.indexOf(obj[1][i].group)==-1 && obj[1][i].company==document.getElementById('company_text').innerHTML&& obj[1][i].factory==document.getElementById('factory_text').innerHTML&& obj[1][i].department==document.getElementById("department_text").innerHTML){
             inner += tower(obj[1][i].group);
+            tower_group_arr.push(obj[1][i].group);
         }
     }
     
-    document.getElementById('department-show').innerHTML=inner;
+    document.getElementById('towergroup').innerHTML=inner;
 }
 
 function tower(tower_group){
@@ -175,7 +182,7 @@ function tower(tower_group){
         }
     }
 
-    inner += '/<table>'
+    inner += '</table>'
     return inner;
 }