NGToolsCSharp/NGTools/MYJS/MyTools.js
2024-09-13 16:44:30 +08:00

922 lines
31 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//<reference path="../EASYUI/locale/easyui-lang-zh_CN.js" />
/*
关键词 主界面的easyui-accordion 菜单树加载 动态添加accordion和子菜单
@auhor 作者 廖德云 修改来自网络
@param 参数 Myaccordeasyui-accordion MyTabcenter中的tab 《div》
@example 示例
@link 链接
@namespace 命名空间
@requires 依赖模块
@return 返回值
@version 版本号
*/
function getLeftTree(Myaccord, MyTab, url) { //动态加载二级菜单
$.ajax({
type: 'post',
dataType: "json",
url: url,
success: function (data) {
//alert(JSON.stringify(data));
sessionStorage.setItem("AllMenu", JSON.stringify(data));
addTab("主页", "main.aspx", false);
$.each(data, function (i, n) {// 加载父类节点及一级菜单
var id = n.id;
Myaccord.accordion('add', {
title: n.text,
iconCls: n.iconCls,
selected: true,
content: '<div style="padding:10px"><ul id="tree-' + id + '" name="' + n.text + '"></ul></div>'
});
//// 解析整个页面
$.parser.parse();
// 第二层生成树节点
if (!n.children || n.children.length == 0) {
return true;
}
$("#tree-" + id).tree({
data: n.children,
//animate : true,
lines: true,// 显示虚线效果
onClick: function (node) {
if (node.attributes) {
var tabTitle = node.text;
var url = node.attributes;
var openMode = node.state;
var icon = node.iconCls;
var pid = node.id;
addTab(tabTitle, url, true);
} else {
$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
node.state = node.state === 'closed' ? 'open' : 'closed';
}
},
onSelect: function (node) {
$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
node.state = node.state === 'closed' ? 'open' : 'closed';
}
});
});
}
});
// 主窗体的tab控件添加两个工具栏按钮
MyTab.tabs({
tools: [{
iconCls: 'icon-reload',
border: false,
handler: function () {
// $('#home-datagrid').datagrid('reload');
// 刷新当前的tab
$('.panel:visible > .panel-body > iframe').get(0).contentDocument.location.reload(true);
}
},
{
iconCls: 'icon-cancel',
border: false,
handler: function () {
// $('#home-datagrid').datagrid('reload');
// 关闭所有的tab
var tiles = new Array();
var tabs = MyTab.tabs('tabs');
var len = tabs.length;
//关闭所有
if (len > 0) {
for (var j = 0; j < len; j++) {
var a = tabs[j].panel('options').title;
tiles.push(a);
}
for (var i = 0; i < tiles.length; i++) {
if (tiles[i] != "主页") {
MyTab.tabs('close', tiles[i]);
}
}
}
}
}
//,
//{
// iconCls: 'icon-cancel',
// border: false,
// handler: function () {
// // $('#home-datagrid').datagrid('reload');
// // 关闭所有的tab
// var tab = MyTab.tabs('getSelected');
// var title = tabs.panel('options').title;
// MyTab.tabs('close', title);
// }
//}
]
});
}
function getTree(MyTree, url) { //动态加载菜单
//$.messager.alert("提示",10);
MyTree.tree({
animate: true,
checkbox: false,
url: url,
onSelect: function (node) {
$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
node.state = node.state === 'closed' ? 'open' : 'closed';
},
onLoadSuccess: function (node, data) {
MyTree.show();
},
//onLoadError: function (arguments) {
// $.messager.alert("提示",JSON.stringify(arguments));
//}
});
}
function getDataGrid(MyGrid, url, parm, toolbar) { //动态加载网格控件表格
//动态加载标题和数据
$.ajax({
type: "post",
url: url,// "../../../ASHX/GetHistoryData.ashx?action=getjson" + "&t=" + Date.parse(new Date()),
dataType: "json",
//async: true,//异步请求默认为true。如果需要发送同步请求发送false
data: { par: parm },
success: function (data) {
MyGrid.datagrid({
loadMsg: '正在加载数据请稍后...',
pageSize: 20,
pageList: [20, 30, 40, 50, 100],
fitColumns: true,
pagination: true,
striped: true, //奇偶行是否区分
singleSelect: true,//单选模式
rownumbers: true,//行号
fitColumns: true,
//height: window.innerHeight - 45 - 58,
toolbar: toolbar,
fit: true,
columns: [data.title] //动态取标题
});
MyGrid.datagrid({ loadFilter: pagerFilter }).datagrid('loadData', data.rows); //动态取数据
}
});
}
//为网格添加分页
function pagerFilter(data) {
//$.messager.alert("提示",JSON.stringify(data));
if (typeof data.length == 'number' && typeof data.splice == 'function') { // 判断数据是否是数组
data = {
total: data.length,
rows: data
}
}
var dg = $(this);
var opts = dg.datagrid('options');
var pager = dg.datagrid('getPager');
pager.pagination({
onSelectPage: function (pageNum, pageSize) {
opts.pageNumber = pageNum;
opts.pageSize = pageSize;
pager.pagination('refresh', {
pageNumber: pageNum,
pageSize: pageSize
});
dg.datagrid('loadData', data);
}
});
if (!data.originalRows) {
data.originalRows = (data.rows);
}
var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
var end = start + parseInt(opts.pageSize);
data.rows = (data.originalRows.slice(start, end));
return data;
};
//例如我们希望输出的数字长度是固定的假设为10如果数字为123则输出0000000123不够位数就在之前补足0这里提供了三种不同的方式实现JS代码给数字补0 的操作
//原文http://www.jb51.net/article/62499.htm
//取后两位转成数字 +1 再转成固定的两位字符串
function PrefixInteger(str, length) {
var str1 = str.substr(0, str.length - length);
var str2 = str.substr(str.length - length, length);
var num = parseInt(str2) + 1;
var str3 = (Array(length).join('0') + num).slice(-length);
return (str1 + str3);
}
//扩展datagrid:动态加入删除editor
$.extend($.fn.datagrid.methods, {
addEditor: function (jq, param) {
if (param instanceof Array) {
$.each(param, function (index, item) {
var e = $(jq).datagrid('getColumnOption', item.field);
e.editor = item.editor;
});
} else {
var e = $(jq).datagrid('getColumnOption', param.field);
e.editor = param.editor;
}
},
removeEditor: function (jq, param) {
if (param instanceof Array) {
$.each(param, function (index, item) {
var e = $(jq).datagrid('getColumnOption', item);
e.editor = {};
});
} else {
var e = $(jq).datagrid('getColumnOption', param);
e.editor = {};
}
}
});
function sumZf() {
var summ = 0;
if ($('#NG_C1').numberbox('getValue') != "") { summ += parseFloat($('#NG_C1').numberbox('getValue')) };
if ($('#NG_N2').numberbox('getValue') != "") { summ += parseFloat($('#NG_N2').numberbox('getValue')) };
if ($('#NG_CO2').numberbox('getValue') != "") { summ += parseFloat($('#NG_CO2').numberbox('getValue')) };
if ($('#NG_C2').numberbox('getValue') != "") { summ += parseFloat($('#NG_C2').numberbox('getValue')) };
if ($('#NG_C3').numberbox('getValue') != "") { summ += parseFloat($('#NG_C3').numberbox('getValue')) };
if ($('#NG_H2O').numberbox('getValue') != "") { summ += parseFloat($('#NG_H2O').numberbox('getValue')) };
if ($('#NG_H2S').numberbox('getValue') != "") { summ += parseFloat($('#NG_H2S').numberbox('getValue')) };
if ($('#NG_H2').numberbox('getValue') != "") { summ += parseFloat($('#NG_H2').numberbox('getValue')) };
if ($('#NG_CO').numberbox('getValue') != "") { summ += parseFloat($('#NG_CO').numberbox('getValue')) };
if ($('#NG_O2').numberbox('getValue') != "") { summ += parseFloat($('#NG_O2').numberbox('getValue')) };
if ($('#NG_iC4').numberbox('getValue') != "") { summ += parseFloat($('#NG_iC4').numberbox('getValue')) };
if ($('#NG_nC4').numberbox('getValue') != "") { summ += parseFloat($('#NG_nC4').numberbox('getValue')) };
if ($('#NG_iC5').numberbox('getValue') != "") { summ += parseFloat($('#NG_iC5').numberbox('getValue')) };
if ($('#NG_nC5').numberbox('getValue') != "") { summ += parseFloat($('#NG_nC5').numberbox('getValue')) };
if ($('#NG_C6').numberbox('getValue') != "") { summ += parseFloat($('#NG_C6').numberbox('getValue')) };
if ($('#NG_C7').numberbox('getValue') != "") { summ += parseFloat($('#NG_C7').numberbox('getValue')) };
if ($('#NG_C8').numberbox('getValue') != "") { summ += parseFloat($('#NG_C8').numberbox('getValue')) };
if ($('#NG_C9').numberbox('getValue') != "") { summ += parseFloat($('#NG_C9').numberbox('getValue')) };
if ($('#NG_C10').numberbox('getValue') != "") { summ += parseFloat($('#NG_C10').numberbox('getValue')) };
if ($('#NG_He').numberbox('getValue') != "") { summ += parseFloat($('#NG_He').numberbox('getValue')) };
if ($('#NG_Ar').numberbox('getValue') != "") { summ += parseFloat($('#NG_Ar').numberbox('getValue')) };
$('#NG_SUM').numberbox('setValue', summ);
return summ;
};
function strZf() {
var summ = "";
summ += $('#NG_C1').numberbox('getValue') + "_";;
summ += $('#NG_N2').numberbox('getValue') + "_";;
summ += $('#NG_CO2').numberbox('getValue') + "_";;
summ += $('#NG_C2').numberbox('getValue') + "_";;
summ += $('#NG_C3').numberbox('getValue') + "_";;
summ += $('#NG_H2O').numberbox('getValue') + "_";;
summ += $('#NG_H2S').numberbox('getValue') + "_";;
summ += $('#NG_H2').numberbox('getValue') + "_";;
summ += $('#NG_CO').numberbox('getValue') + "_";;
summ += $('#NG_O2').numberbox('getValue') + "_";;
summ += $('#NG_iC4').numberbox('getValue') + "_";;
summ += $('#NG_nC4').numberbox('getValue') + "_";;
summ += $('#NG_iC5').numberbox('getValue') + "_";;
summ += $('#NG_nC5').numberbox('getValue') + "_";;
summ += $('#NG_C6').numberbox('getValue') + "_";;
summ += $('#NG_C7').numberbox('getValue') + "_";;
summ += $('#NG_C8').numberbox('getValue') + "_";;
summ += $('#NG_C9').numberbox('getValue') + "_";;
summ += $('#NG_C10').numberbox('getValue') + "_";;
summ += $('#NG_He').numberbox('getValue') + "_";;
summ += $('#NG_Ar').numberbox('getValue') + "_";;
return summ;
};
function Zore() {
$('#NG_C1').numberbox('setValue', 0);
$('#NG_N2').numberbox('setValue', 0);
$('#NG_CO2').numberbox('setValue', 0);
$('#NG_C2').numberbox('setValue', 0);
$('#NG_C3').numberbox('setValue', 0);
$('#NG_H2O').numberbox('setValue', 0);
$('#NG_H2S').numberbox('setValue', 0);
$('#NG_H2').numberbox('setValue', 0);
$('#NG_CO').numberbox('setValue', 0);
$('#NG_O2').numberbox('setValue', 0);
$('#NG_iC4').numberbox('setValue', 0);
$('#NG_nC4').numberbox('setValue', 0);
$('#NG_iC5').numberbox('setValue', 0);
$('#NG_nC5').numberbox('setValue', 0);
$('#NG_C6').numberbox('setValue', 0);
$('#NG_C7').numberbox('setValue', 0);
$('#NG_C8').numberbox('setValue', 0);
$('#NG_C9').numberbox('setValue', 0);
$('#NG_C10').numberbox('setValue', 0);
$('#NG_He').numberbox('setValue', 0);
$('#NG_Ar').numberbox('setValue', 0);
$('#NG_SUM').numberbox('setValue', 0);
};
function getFormJson(frm) {
var o = {};
var a = $(frm).serializeArray();
$.each(a, function () {
if (this.name == "password") {
//this.value = $.md5(this.value) //md5操作
this.value = this.value;
}
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
}
// 遍历清空表单值
function clearForm() {
try {
var div = document.getElementById("formPar");//建议不要用数字定义ID
var inputs = div.getElementsByTagName("input");
var inputID
//alert(inputs.length);
for (var i = 0; i < inputs.length; i++) {
inputID = (inputs[i].id);
var inputName = inputs[i].className.split(' ')[0];
if (inputName == "easyui-numberbox") {
$('#' + inputID).numberbox('setValue', "");
}
if (inputName == "easyui-combobox") {
$('#' + inputID).combobox('setValue', "");
}
if (inputName == "easyui-textbox") {
$('#' + inputID).numberbox('setValue', "");
}
}
var div = document.getElementById("Result");//建议不要用数字定义ID
var inputs = div.getElementsByTagName("input");
var inputID
//alert(inputs.length);
for (var i = 0; i < inputs.length; i++) {
inputID = (inputs[i].id);
var inputName = inputs[i].className.split(' ')[0];
if (inputName == "easyui-numberbox") {
$('#' + inputID).numberbox('setValue', "");
}
if (inputName == "easyui-combobox") {
$('#' + inputID).combobox('setValue', "");
}
if (inputName == "easyui-textbox") {
$('#' + inputID).numberbox('setValue', "");
}
}
var div = document.getElementById("ddPar");//建议不要用数字定义ID
var inputs = div.getElementsByTagName("input");
var inputID
//alert(inputs.length);
for (var i = 0; i < inputs.length; i++) {
inputID = (inputs[i].id);
var inputName = inputs[i].className.split(' ')[0];
if (inputName == "easyui-numberbox") {
$('#' + inputID).numberbox('setValue', "");
}
if (inputName == "easyui-combobox") {
$('#' + inputID).combobox('setValue', "");
}
if (inputName == "easyui-textbox") {
$('#' + inputID).numberbox('setValue', "");
}
}
} catch (e) {
}
}
function initialCom() {
try {
$("#GDLX").combobox({ data: GDLX, valueField: 'ID', textField: 'text' });
$('#GDLX').combobox('select', GDLX[0].ID);
} catch (e) {
}
try {
$('#GDCZ').combobox({ data: GDCZ, valueField: 'ID', textField: 'text' });
$('#GDCZ').combobox('select', GDCZ[2].ID);
} catch (e) {
}
try {
$('#CYSLLJLX').combobox({ data: CYSLLJLX, valueField: 'ID', textField: 'text' });
$('#CYSLLJLX').combobox('select', CYSLLJLX[0].ID);
} catch (e) {
}
try {
$('#JLJCZ').combobox({ data: JLJCZ, valueField: 'ID', textField: 'text' });
$('#JLJCZ').combobox('select', JLJCZ[9].ID);
} catch (e) {
}
try {
$('#QYFS').combobox({ data: QYFS, valueField: 'ID', textField: 'text' });
$('#QYFS').combobox('select', QYFS[0].ID);
} catch (e) {
}
try {
$('#CBTJ').combobox({ data: CBTJ, valueField: 'ID', textField: 'text' });
$('#CBTJ').combobox('select', CBTJ[0].ID);
} catch (e) {
}
try {
$('#CYCS').combobox({ data: CycsCom, valueField: 'ID', textField: 'text' });
$('#CYCS').combobox('select', CycsCom[0].ID);
} catch (e) {
}
}
//用于判断是否是对象类型,是否是数组,获取对象长度
function isObj(object) {
return object && typeof (object) == 'object' && Object.prototype.toString.call(object).toLowerCase() == "[object object]";
}
function isArray(object) {
return object && typeof (object) == 'object' && object.constructor == Array;
}
function getLength(object) {
var count = 0;
for (var i in object) count++;
return count;
}
//
function Compare(objA, objB) {
if (!isObj(objA) || !isObj(objB)) return false; //判断类型是否正确
if (getLength(objA) != getLength(objB)) return false; //判断长度是否一致
return CompareObj(objA, objB, true);//默认为true
}
function CompareObj(objA, objB, flag) {
for (var key in objA) {
if (!flag) //跳出整个循环
break;
if (!objB.hasOwnProperty(key)) { flag = false; break; }
if (!isArray(objA[key])) { //子级不是数组时,比较属性值
if (objB[key] != objA[key]) { flag = false; break; }
} else {
if (!isArray(objB[key])) { flag = false; break; }
var oA = objA[key], oB = objB[key];
if (oA.length != oB.length) { flag = false; break; }
for (var k in oA) {
if (!flag) //这里跳出循环是为了不让递归继续
break;
flag = CompareObj(oA[k], oB[k], flag);
}
}
}
return flag;
}
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);// alert(unescape(r[2]));
if (r != null) return unescape(r[2]); return null;
}
/**
* 指定年月日 日期字符串加月数
* @param dateStr
* @param monthCount 需要加的月数,负数为减
*/
function addMonth(dateStr, monthCount) {
var date = new Date(dateStr);
var newDate = date.addMonths(monthCount);
return dateToString(newDate, DateFormart.DATETIME_HORIZONTAL_24);
};
//设置转换方法
Date.prototype.pattern = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
var week = {
"0": "\u65e5",
"1": "\u4e00",
"2": "\u4e8c",
"3": "\u4e09",
"4": "\u56db",
"5": "\u4e94",
"6": "\u516d"
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
if (/(E+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]);
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
}
return fmt;
};
var DateFormart = {
YEAR: "yyyy",
YEAR_MONTH_HORIZONTAL: "yyyy-MM",
DATE_HORIZONTAL: "yyyy-MM-dd",
DATETIME_HORIZONTAL_12: "yyyy-MM-dd hh:mm:ss",
DATETIME_HORIZONTAL_24: "yyyy-MM-dd HH:mm:ss",
YEAR_MONTH_SLASH: "yyyy/MM",
DATE_SLASH: "yyyy/MM/dd",
DATETIME_SLASH_8: 'yyyyMMdd',
DATETIME_SLASHL_12: "yyyy/MM/dd hh:mm:ss",
DATETIME_SLASH_24: "yyyy/MM/dd HH:mm:ss"
};
/**
* js的Date类型转换成formart格式的字符串, 支持的格式见DateFormart
* 调用的方式例如:
* var date = new Date();
* var str = dateToString(date,DateFormart.DATETIME_HORIZONTAL_24);
* @param datetime js中的Date对象
* @param formart 转换成的字符串格式支持的格式有参考DateFormart
* */
function dateToString(date, formart) {
var f = "" + formart; //如果不加这个pattern方法识别不了。
var str = date.pattern(f);
return str;
}
Date.prototype.dateToString = function (date, formart) {
return dateToString(date, formart);
};
Date.isLeapYear = function (year) {
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
};
Date.getDaysInMonth = function (year, month) {
return [31, (Date.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
};
Date.prototype.isLeapYear = function () {
return Date.isLeapYear(this.getFullYear());
};
Date.prototype.getDaysInMonth = function () {
return Date.getDaysInMonth(this.getFullYear(), this.getMonth());
};
Date.prototype.addMonths = function (value) {
//debugger;
var n = this.getDate();
this.setDate(1);
this.setMonth(this.getMonth() + parseInt(value));
this.setDate(Math.min(n, this.getDaysInMonth()));
return this;
};
//计算日期差
function GetDateDiff(startTime, endTime, diffType) {
//将xxxx-xx-xx的时间格式转换为 xxxx/xx/xx的格式
startTime = startTime.replace(/\-/g, "/").split(' ')[0];
endTime = endTime.replace(/\-/g, "/").split(' ')[0];
//将计算间隔类性字符转换为小写
diffType = diffType.toLowerCase();
var sTime = new Date(startTime); //开始时间
var eTime = new Date(endTime); //结束时间
//作为除数的数字
var timeType = 1;
switch (diffType) {
case "second":
timeType = 1000;
break;
case "minute":
timeType = 1000 * 60;
break;
case "hour":
timeType = 1000 * 3600;
break;
case "day":
timeType = 1000 * 3600 * 24;
break;
default:
break;
}
return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(timeType));
}
//设置次数 返回是否到期或归零
function setremainTimes(userID,menuID) {
$.ajax({
type: "post",
url: "../../ASHX/getTreeCombox.ashx?action=setRemainTimes" + "&t=" + Date.parse(new Date()),
//dataType: "json",
data: { userID:userID , menuID: menuID },
traditional: true,
success: function (data) {
//alert(data);
if (data == "0") {
try {
$('#saveBtn').linkbutton('disable');
} catch (e) {
}
try {
$('#ExportXls').linkbutton('disable');
} catch (e) {
}
try {
$('#inP').numberbox('disable', true); //设置输入框为禁用
} catch (e) {
}
try {
$('#NG_C1').numberbox('disable', true); //设置输入框为禁用
} catch (e) {
}
}
}
})
}
//设置次数 返回是否到期或归零
function getEnable(userID, menuID) {
$.ajax({
type: "post",
url: "../../ASHX/getTreeCombox.ashx?action=getEnable" + "&t=" + Date.parse(new Date()),
//dataType: "json",
data: { userID: userID, menuID: menuID },
traditional: true,
success: function (data) {
//alert(data);
if (data == "0") {
try {
$('#saveBtn').linkbutton('disable');
} catch (e) {
}
try {
$('#ExportXls').linkbutton('disable');
} catch (e) {
}
try {
$('#inP').numberbox('disable', true); //设置输入框为禁用
} catch (e) {
}
try {
$('#NG_C1').numberbox('disable', true); //设置输入框为禁用
} catch (e) {
}
}
}
})
}
function getTime() {
var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var da = date.getDate();
var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
var week = date.getDay();
var time = year + "年" + month + "月" + da + "日 " + hour + ":" + minute + ":" + second + " " + weeks[week];
return time;
}
function copyZf() {
var strNGPar = "{";
strNGPar += '"NG_C1":"' + $('#NG_C1').numberbox('getValue') + '",';
strNGPar += '"NG_N2":"' + $('#NG_N2').numberbox('getValue') + '",';
strNGPar += '"NG_CO2":"' + $('#NG_CO2').numberbox('getValue') + '",';
strNGPar += '"NG_C2":"' + $('#NG_C2').numberbox('getValue') + '",';
strNGPar += '"NG_C3":"' + $('#NG_C3').numberbox('getValue') + '",';
strNGPar += '"NG_H2O":"' + $('#NG_H2O').numberbox('getValue') + '",';
strNGPar += '"NG_H2S":"' + $('#NG_H2S').numberbox('getValue') + '",';
strNGPar += '"NG_H2":"' + $('#NG_H2').numberbox('getValue') + '",';
strNGPar += '"NG_CO":"' + $('#NG_CO').numberbox('getValue') + '",';
strNGPar += '"NG_O2":"' + $('#NG_O2').numberbox('getValue') + '",';
strNGPar += '"NG_iC4":"' + $('#NG_iC4').numberbox('getValue') + '",';
strNGPar += '"NG_nC4":"' + $('#NG_nC4').numberbox('getValue') + '",';
strNGPar += '"NG_iC5":"' + $('#NG_iC5').numberbox('getValue') + '",';
strNGPar += '"NG_nC5":"' + $('#NG_nC5').numberbox('getValue') + '",';
strNGPar += '"NG_C6":"' + $('#NG_C6').numberbox('getValue') + '",';
strNGPar += '"NG_C7":"' + $('#NG_C7').numberbox('getValue') + '",';
strNGPar += '"NG_C8":"' + $('#NG_C8').numberbox('getValue') + '",';
strNGPar += '"NG_C9":"' + $('#NG_C9').numberbox('getValue') + '",';
strNGPar += '"NG_C10":"' + $('#NG_C10').numberbox('getValue') + '",';
strNGPar += '"NG_He":"' + $('#NG_He').numberbox('getValue') + '",';
strNGPar += '"NG_Ar":"' + $('#NG_Ar').numberbox('getValue') + '"}';
sessionStorage.setItem("NGPar", strNGPar);
}
function pasteZf() {
var strNGPar =JSON.parse( sessionStorage.getItem("NGPar"));
$('#NG_C1').numberbox('setValue', strNGPar.NG_C1);
$('#NG_N2').numberbox('setValue', strNGPar.NG_N2);
$('#NG_CO2').numberbox('setValue', strNGPar.NG_CO2);
$('#NG_C2').numberbox('setValue', strNGPar.NG_C2);
$('#NG_C3').numberbox('setValue', strNGPar.NG_C3);
$('#NG_H2O').numberbox('setValue', strNGPar.NG_H2O);
$('#NG_H2S').numberbox('setValue', strNGPar.NG_H2S);
$('#NG_H2').numberbox('setValue', strNGPar.NG_H2);
$('#NG_CO').numberbox('setValue', strNGPar.NG_CO);
$('#NG_O2').numberbox('setValue', strNGPar.NG_O2);
$('#NG_iC4').numberbox('setValue', strNGPar.NG_iC4);
$('#NG_nC4').numberbox('setValue', strNGPar.NG_nC4);
$('#NG_iC5').numberbox('setValue', strNGPar.NG_iC5);
$('#NG_nC5').numberbox('setValue', strNGPar.NG_nC5);
$('#NG_C6').numberbox('setValue', strNGPar.NG_C6);
$('#NG_C7').numberbox('setValue', strNGPar.NG_C7);
$('#NG_C8').numberbox('setValue', strNGPar.NG_C8);
$('#NG_C9').numberbox('setValue', strNGPar.NG_C9);
$('#NG_C10').numberbox('setValue', strNGPar.NG_C10);
$('#NG_He').numberbox('setValue', strNGPar.NG_He);
$('#NG_Ar').numberbox('setValue', strNGPar.NG_Ar);
}
/*
* jquery 初始化form插件传入一个json对象为form赋值
* version: 1.0.0-2013.06.24
* @requires jQuery v1.5 or later
* Copyright (c) 2013
* note: 1、此方法能赋值一般所有表单但考虑到checkbox的赋值难度以及表单中很少用checkbox这里不对checkbox赋值
* 2、此插件现在只接收json赋值不考虑到其他的来源数据
* 3、对于特殊的textarea比如CKEditor,kindeditor...,他们的赋值有提供不同的自带方法,这里不做统一,如果项目中有用到,不能正确赋值,请单独赋值
*/
function initForm (frm,options) {
alert(111);
//默认参数
var defaults = {
jsonValue: "",
exclude: [], //不需要进行初始化的name,将name字符串数组传入
isDebug: false //是否需要调试这个用于开发阶段发布阶段请将设置为false默认为false,true将会把name value打印出来
}
//设置参数
var setting = $.extend({}, defaults, options);
var form = frm;
jsonValue = setting.jsonValue;
//如果传入的json字符串将转为json对象
if ($.type(setting.jsonValue) === "string") {
jsonValue = $.parseJSON(jsonValue);
}
//如果传入的json对象为空则不做任何操作
if (!$.isEmptyObject(jsonValue)) {
var debugInfo = "";
$.each(jsonValue, function (key, value) {
//是否开启调试开启将会把name value打印出来
if (setting.isDebug) {
//alert("name:"+key+"; value:"+value);
debugInfo += "name:" + key + "; value:" + value + " || ";
}
if (setting.exclude.indexOf(key) == -1) {
var formField = form.find("[name='" + key + "']");
if ($.type(formField[0]) === "undefined") {
if (setting.isDebug) {
alert("can not find name:[" + key + "] in form!!!"); //没找到指定name的表单
}
} else {
var fieldTagName = formField[0].tagName.toLowerCase();
if (fieldTagName == "input") {
if (formField.attr("type") == "radio") {
$("input:radio[name='" + key + "'][value='" + value + "']").attr("checked", "checked");
} else {
formField.val(value);
}
} else if (fieldTagName == "select") {
//do something special
formField.val(value);
} else if (fieldTagName == "textarea") {
//do something special
formField.val(value);
} else {
formField.val(value);
}
}
}
})
if (setting.isDebug) {
alert(debugInfo);
}
}
return form; //返回对象,提供链式操作
}