var layer;// 定义全局变量
|
var data = {
|
"firmware": "固件版本",
|
"software": "软件版本",
|
"hardware": "硬件版本",
|
"operation": "系统运行时长",
|
"time": new Date()
|
};
|
var form;
|
var laydate;
|
$(function () {
|
layui.use(['layer', 'form', 'laydate'], function () {
|
layer = layui.layer;
|
form = layui.form;
|
laydate = layui.laydate;
|
|
laydate.render({
|
elem: '#time'
|
, type: 'datetime'
|
, trigger: 'click'
|
, theme: 'custom'
|
,value: new Date()
|
});
|
|
if(TEST_TAG){
|
renderForm(data);
|
}else{
|
//默认查询
|
query();
|
|
//网关参数
|
querySet();
|
}
|
});
|
});
|
|
//执行查询
|
function query() {
|
$.get("./cgi-bin/device-ctrl/query-version", function (data, status) {
|
if ("success" == status) {
|
renderForm(data);
|
} else {
|
window.parent.parent.notify("数据查询出错,请重新操作!!");
|
}
|
}, "json");
|
}
|
|
//渲染表格
|
function renderForm(data) {
|
// console.log(list);
|
//赋值
|
$("#firmware").val(data.firmware);
|
$("#software").val(data.software);
|
$("#hardware").val(data.hardware);
|
//运行时长
|
// renderDay(data.operation);
|
$("#operation").val(data.operation);
|
$("#time").val(data.time);
|
}
|
|
//渲染使用天数
|
function renderDay(dayTime) {
|
if (dayTime) {
|
dayTime = dayTime.substring(0, 4) + "/" + dayTime.substring(4, 6) + "/" +
|
dayTime.substring(6, 8) + " 00:00:00";
|
//获取开始使用时的毫秒数
|
var timestamp = new Date(dayTime).getTime();
|
//当前时间的毫秒数
|
var timestampNow = new Date().getTime();
|
var num = timestampNow - timestamp;
|
var daytamp = 1000 * 60 * 60 * 24;
|
var day = Math.ceil(num / daytamp);
|
$("#operation").val(day);
|
}
|
}
|
|
//重启设备
|
function rebootDevice(){
|
if(confirm("是否进行重启设备?")){
|
$.get("./cgi-bin/device-ctrl/reboot-device", function (data, status) {
|
if ("success" == status) {
|
window.parent.parent.notify("操作成功!");
|
} else {
|
window.parent.parent.notify("重启设备失败!");
|
}
|
}, "json");
|
}
|
}
|
//重启服务器
|
function rebootService(){
|
if(confirm("是否进行重启服务?")){
|
$.get("./cgi-bin/device-ctrl/reboot-service", function (data, status) {
|
if ("success" == status) {
|
window.parent.parent.notify("操作成功!");
|
} else {
|
window.parent.parent.notify("重启服务失败!");
|
}
|
}, "json");
|
}
|
}
|
|
//下载协议库备份
|
function downLibname() {
|
// var $eleForm = $("<form method='get'></form>");
|
//
|
// $eleForm.attr("action","");
|
//
|
// $(document.body).append($eleForm);
|
// //提交表单实现下载
|
// $eleForm.submit();
|
}
|
|
|
//执行保存,网关设置
|
function saveSet() {
|
var set = form.val("form-set");
|
// console.log(JSON.stringify(set));
|
$.post("./cgi-bin/sys-set/save-set", JSON.stringify(set), function (data, status) {
|
if (data.code == "success") {
|
window.parent.parent.notify("数据保存成功!");
|
} else {
|
window.parent.parent.notify("数据保存出错,请重新操作!!msg=" + data.msg);
|
}
|
}, "json");
|
}
|
|
//时间格式处理,2021-02-26 -----20210226
|
function timeStr(time) {
|
return time.replace('-','').replace('-','');
|
}
|
|
//执行查询,网关参数
|
function querySet() {
|
$.get("./cgi-bin/sys-set/query-set", function (data, status) {
|
if ("success" == status) {
|
renderSet(data);
|
} else {
|
window.parent.parent.notify("数据查询出错,请重新操作!!msg=" + data.msg);
|
}
|
}, "json");
|
}
|
|
function renderSet(data){
|
form.val("form-set",data);
|
}
|