From 45e4c1543eaacc87ccf67a7ae91d2a8bb5b82ddc Mon Sep 17 00:00:00 2001 From: vincent <1341870251@qq.com> Date: 星期三, 03 六月 2020 13:27:15 +0800 Subject: [PATCH] # --- src/main/webapp/views/console.html | 101 +++++++++++++++++++++++++++++++++----------------- 1 files changed, 66 insertions(+), 35 deletions(-) diff --git a/src/main/webapp/views/console.html b/src/main/webapp/views/console.html index 56663d2..5666f17 100644 --- a/src/main/webapp/views/console.html +++ b/src/main/webapp/views/console.html @@ -625,9 +625,11 @@ // 鍒濆鍖� getSitesInfo(); getCrnInfo(); + getSystemRunningStatus(); // 瀹炴椂璁块棶 setInterval(function () { getCrnInfo(); + getSystemRunningStatus(); }, 500); setInterval(function () { getSitesInfo(); @@ -638,46 +640,75 @@ if (systemRunning){ layer.prompt({title: '璇疯緭鍏ュ彛浠わ紝骞跺仠姝� WCS 绯荤粺', formType: 1, shadeClose: true}, function(pass, idx){ layer.close(idx); - if ("123"!==pass){ - alert("鍙d护閿欒"); - return; - } - var index = null; - index = layer.load(1, { - shade: [0.1,'#fff'] - }); - setTimeout(function () { - if (systemRunning){ - $('#system-icon').attr("class", "system-icon-close"); - $('#system-run-desc').html("绯荤粺宸插仠姝�!"); - systemRunning = false; - } else { + doSwitch(0, pass); + }); + } else { + doSwitch(1) + } + + } + + // 璇锋眰鏈嶅姟鍣ㄦ帶鍒秝cs绯荤粺杩愯鐘舵�� + function doSwitch(operatorType, password) { + // 鍔犺浇tips + var index = layer.load(1, { + shade: [0.1,'#fff'] + }); + $.ajax({ + url: baseUrl+ "/console/system/switch", + headers: {'token': localStorage.getItem('token')}, + // async: false, + data: { + operatorType: operatorType, + password: password + }, + method: 'POST', + success: function (res) { + if (res.code === 200){ + layer.close(index); + if (res.data.status) { $('#system-icon').attr("class", "system-icon-open"); $('#system-run-desc').html("绯荤粺杩愯涓�..."); systemRunning = true; + } else { + $('#system-icon').attr("class", "system-icon-close"); + $('#system-run-desc').html("绯荤粺宸插仠姝�!"); + systemRunning = false; } - layer.close(index); - }, 2000); - }); - - } else { - var index = null; - index = layer.load(1, { - shade: [0.1,'#fff'] - }); - setTimeout(function () { - if (systemRunning){ - $('#system-icon').attr("class", "system-icon-close"); - $('#system-run-desc').html("绯荤粺宸插仠姝�!"); - systemRunning = false; - } else { - $('#system-icon').attr("class", "system-icon-open"); - $('#system-run-desc').html("绯荤粺杩愯涓�..."); - systemRunning = true; + } else if (res.code === 403){ + top.location.href = baseUrl+"/login"; + } else { + alert(res.msg); } - layer.close(index); - }, 2000); - } + } + }); + + } + + // 鑾峰彇wcs绯荤粺杩愯鐘舵�� + function getSystemRunningStatus() { + $.ajax({ + url: baseUrl+ "/console/system/running/status", + headers: {'token': localStorage.getItem('token')}, + method: 'POST', + success: function (res) { + if (res.code === 200){ + if (res.data.status) { + $('#system-icon').attr("class", "system-icon-open"); + $('#system-run-desc').html("绯荤粺杩愯涓�..."); + systemRunning = true; + } else { + $('#system-icon').attr("class", "system-icon-close"); + $('#system-run-desc').html("绯荤粺宸插仠姝�!"); + systemRunning = false; + } + } else if (res.code === 403){ + top.location.href = baseUrl+"/login"; + } else { + alert(res.msg); + } + } + }); } // 杈撻�佽澶囧疄鏃舵暟鎹幏鍙� -- Gitblit v1.9.1