#
vincent
2020-06-03 45e4c1543eaacc87ccf67a7ae91d2a8bb5b82ddc
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("口令错误");
                    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)
        }
    }
    // 请求服务器控制wcs系统运行状态
    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);
                }
            }
        });
    }
    // 输送设备实时数据获取