var xhr = new XMLHttpRequest(); var url = "tower/org"; obj = ""; xhr.open("GET", url); xhr.onload = function () { obj = JSON.parse(xhr.responseText); //insertHTML(); start(); onChangeColumn1(); onChangeColumn2(); onChangeColumn3(); click_button_history(); }; xhr.send(); function start() { companySelect = document.getElementById("company-list"); factorySelect = document.getElementById("factory-list"); departmentSelect = document.getElementById("department-list"); towerGroupSelect = document.getElementById("towerGroup-list"); var inner = ''; var company_arr = new Array(); for (var i = 0; i < obj.length; i++) { if (company_arr.indexOf(obj[i].company) == -1 && obj[i].able == 1) { inner = inner + ''; company_arr.push(obj[i].company); } } //innerHTML 賦值inner給這element屬性 companySelect.innerHTML = inner; } //製造一個字串,以html的語法填入院的陣列 function onChangeColumn1() { companySelect = document.getElementById("company-list"); factorySelect = document.getElementById("factory-list"); departmentSelect = document.getElementById("department-list"); towerGroupSelect = document.getElementById("towerGroup-list"); factorySelect.innerHTML = ''; let factory_arr = new Array(); let factory_inner = ''; for (var i = 0; i < obj.length; i++) { if (companySelect.value == obj[i].company) { if (factory_arr.indexOf(obj[i].factory) == -1 && obj[i].able == 1) { factory_inner = factory_inner + ''; factory_arr.push(obj[i].factory); } } //alert(companySelect.value); } factorySelect.innerHTML = factory_inner; onChangeColumn2(); } function onChangeColumn2() { companySelect = document.getElementById("company-list"); factorySelect = document.getElementById("factory-list"); departmentSelect = document.getElementById("department-list"); towerGroupSelect = document.getElementById("towerGroup-list"); departmentSelect.innerHTML = ''; let department_arr = new Array(); let department_inner = ''; for (var i = 0; i < obj.length; i++) { if (companySelect.value == obj[i].company && factorySelect.value == obj[i].factory) { if (department_arr.indexOf(obj[i].department) == -1 && obj[i].able == 1) { department_inner = department_inner + ''; department_arr.push(obj[i].department); } } } document.getElementById("department-list").innerHTML = department_inner; onChangeColumn3(); } function onChangeColumn3() { companySelect = document.getElementById("company-list"); factorySelect = document.getElementById("factory-list"); departmentSelect = document.getElementById("department-list"); towerGroupSelect = document.getElementById("towerGroup-list"); towerGroupSelect.innerHTML = ''; let towerGroup_inner = ''; for (var i = 0; i < obj.length; i++) { if (companySelect.value == obj[i].company && factorySelect.value == obj[i].factory && departmentSelect.value == obj[i].department) { if (obj[i].able == 1) { for (var ii = 0; ii < obj[i].group.length; ii++) { towerGroup_inner = towerGroup_inner + ''; } } } } document.getElementById("towerGroup-list").innerHTML = towerGroup_inner; } function click_button_history() { //alert("click"); companySelect = document.getElementById("company-list"); factorySelect = document.getElementById("factory-list"); departmentSelect = document.getElementById("department-list"); towerGroupSelect = document.getElementById("towerGroup-list"); if (companySelect.value != 0 && factorySelect.value != 0 && departmentSelect.value != 0 && towerGroupSelect.value != 0) { var url2 = "history/?company=" + companySelect.value + "&factory=" + factorySelect.value + "&department=" + departmentSelect.value + "&towerGroup=" + towerGroupSelect.value; var xhr2 = new XMLHttpRequest(); xhr2.open("GET", url2); xhr2.onload = function () { obj2 = JSON.parse(xhr2.responseText); inner_table(obj2); }; xhr2.send(); } } function inner_table(obj){ console.log(obj); inner ='
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ '; for (var i = 0; i < obj.length; i++) { inner+='\ \ \ \ \ \ \ \ \ \ \ \ \ \ '; } document.getElementById("vibration_info").innerHTML = inner; }
Creat IDCreat timedevice Codechannel Coderecord Feildrecord Markremark Valueremark Labelremark Textremark Linkdevice NameChannel NameEditor
' + obj[i].id + '' + obj[i].updateTime + '' + obj[i].device_id + '' + obj[i].channelName + 'CV_index' + obj[i].CVIndex + 'WARING可輸入文字tmpFFT