$.monitorScreenSet = function (param) {
var p = $.extend({
id: "mss", //id
name: "", //参数名字
range: [], //取值范围
width: 569, //宽度
height: 265, //高度
values: [], //参数值
refreshTime: [], //刷新时间【1,2,3,4】
closeFun: function (values) {
} //点击确定后执行的方法
//cancelFun:function(values){}
}, param);
//参数输入框
var paramStr = "";
//验证规则
var rules = {};
//参数index
var varIndex = 0;
if (p.name) {
paramStr = "<p><label for='" + p.id + "_name'>" + p.name + "</label>"
+ "<span style='margin: auto 5px;'><</span>"
+ "<input id='" + p.id + "_name' type='text' name='" + p.id + "_name' style='width:50px;' value='" + p.values[0] + "'>"
+ "<span>" + (p.values[2] || "") + "</span>"
+ "</p>";
rules[p.id + '_name'] = {
required: true,
number: true,
range: p.range,
decimalLength: 2
};
varIndex = 1;
} else {
varIndex = 0;
}
var firstTime = '<span class="text">' +Msg.gs.backInv.refresh5Min+ '</span>';
var secondTime = '<span class="text">' +Msg.gs.backInv.refresh15FMin+ '</span>';
var thirdTime = '<span class="text">' +Msg.gs.backInv.refresh45Min+ '</span>';
var forthTime = '<span class="text">' +Msg.gs.euh.onehour+ '</span>';
var first = '5';
var second = '15';
var third = '45';
var forth = '60';
if (p.refreshTime.length == 4) {
firstTime = p.refreshTime[0] + '<span class="text">' +Msg.second+ '</span>';
secondTime = p.refreshTime[1] +'<span class="text">' +Msg.second+ '</span>';
thirdTime = p.refreshTime[2] + '<span class="text">' +Msg.second+ '</span>';
forthTime = p.refreshTime[3] + '<span class="text">' +Msg.second+ '</span>';
first = p.refreshTime[0];
second = p.refreshTime[1];
third = p.refreshTime[2];
forth = p.refreshTime[3];
}
var contentStr = "<form>"
+ paramStr
+ "<p style='margin: 10px auto;'><span class='text'>" + Msg.gs.euh.dataRefreshCycle + "</span></p>"
+ "<input type='radio' name='refreshTime' id='" + p.id + "_1' style='margin-left:0;' value='" + first + "'><label for='" + p.id + "_1' style='margin-right:20px'>" + firstTime + "</label>"
+ "<input type='radio' name='refreshTime' id='" + p.id + "_2' value='" + second + "'><label for='" + p.id + "_2' style='margin-right:20px'>" + secondTime + "</label>"
+ "<input type='radio' name='refreshTime' id='" + p.id + "_3' value='" + third + "'><label for='" + p.id + "_3' style='margin-right:20px'>" + thirdTime + "</label>"
+ "<input type='radio' name='refreshTime' id='" + p.id + "_4' value='" + forth + "'><label for='" + p.id + "_4' style='margin-right:20px'>" + forthTime + "</label>"
+"</form>"
var form = $(contentStr);
if (p.values[varIndex]) {
form.find("input[value='" + p.values[varIndex] + "']").attr("checked", "true");
} else {
form.find("#" + p.id + "_1").attr("checked", "true");
}
if (p.name) {
form.validate({rules: rules});
}
var getValue = function () {
var result = [];
if (p.name) {
result.push(parseFloat(form.find("#" + p.id + "_name").val()));
}
result.push(form.find("input[name='refreshTime']:checked").val());
return result;
};
App.alert({
id: p.id,
title:Msg.widget.ExpandTable.head,
width: p.width,
height: p.height,
content: " ",
btns: [{
id: 'okId',
text: Msg.sure || 'OK',
click: function (d) {
if (p.name) {
if (form.valid()) {
p.closeFun(getValue());
$(this).dialog('close');
}
} else {
p.closeFun(getValue());
$(this).dialog('close');
}
}
}, {
id: 'cancelId',
text: Msg.cancel || 'Cancel',
click: function (d) {
$(this).dialog('close');
}
}]
}).append(form);
if (p.name) {
form[0].onkeydown = function (e) {
};
form.validate();
}
};
$.monitorScrSetCookie = function (name, val) {
var t = new Date();
t.setFullYear(t.getFullYear() + 1);
Cookies.set(name, val, t);
};
$.monitorScrGetCookie = function (name, isAjax, def) {
var val = Cookies.get(name);
if (isAjax) {
if (val == null) {
$.omcAjax("groupParameter/getParameterById", {
paramKey: name
}, function (data) {
if (data.success) {
val = data.data.paramValue;
}
}, null, false);
} else {
$.monitorScrSetCookie(name, val);
}
} else {
if (val == null) {
val = def || 5;
}
}
return val;
}
添加回答
举报
0/150
提交
取消