|
|
$(
|
function () {
|
try {
|
$("input[type='text']").blur(function () {
|
$(this).val($.trim($(this).val()));
|
});
|
var Sys = {};
|
var ua = navigator.userAgent.toLowerCase();
|
if (window.ActiveXObject) {
|
Sys.ie = ua.match(/msie ([\d.]+)/)[1];
|
} else if (document.getBoxObjectFor) {
|
Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1];
|
} else if (window.MessageEvent && !document.getBoxObjectFor) {
|
Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1];
|
} else if (window.opera) {
|
Sys.opera = ua.match(/opera.([\d.]+)/)[1];
|
} else if (window.openDatabase) {
|
Sys.safari = ua.match(/version\/([\d.]+)/)[1];
|
}
|
//以下进行测试
|
if (Sys.ie) {
|
if (parseInt(Sys.ie) <= 6) {
|
window.location.href = "/IEError.html";
|
}
|
}
|
|
// $(".xialap").find("input").after("<div class='CB'></div>")
|
} catch (e) {
|
|
}
|
}
|
);
|
|
function ShowWaitFront() {
|
var WaitHtml = '<div id="ShowWait" style="height: 100%; position: absolute; width: 100%; left: 0; top: 0; z-index: 2007; display: none; background-color: #000000;opacity: 0.15;filter:alpha(opacity=15);"></div><div id="ImgWait" style="width: 138px; height: 28px; margin: auto; position: absolute; z-index: 2008; background: none repeat scroll 0 0 #D9EBF5; border: 1px solid #619CC5; padding: 3px;display: none;cursor: wait;"><div style="border: 1px solid #A3BAD9; color: Black; cursor: wait; line-height: 16px; padding: 5px 10px 5px 25px; background: url(\'../../images/Common/loading_small.gif\') no-repeat scroll 5px 5px #FBFBFB;font-size: 13px;">请等待...</div></div>';
|
$("body").append(WaitHtml);
|
$("#ShowWait").css("display", "block");
|
$("#ImgWait").css("display", "block");
|
$("#ShowWait").height($("body").height());
|
$("#ImgWait").css("top", parseInt($("body").height()) / 2);
|
$("#ImgWait").css("left", (parseInt($("body").width()) / 2) - 77);
|
|
}
|
|
function CloseWaitFront() {
|
$("#ShowWait").remove();
|
$("#ImgWait").remove();
|
}
|
|
//为Select新增过滤功能
|
function SelectAddSearch() {
|
$("select[SelInputHtml='True']").each(function (i, v) {
|
$(this).unbind("blur");
|
var old = $(this).html();
|
var oldObject = $(this).clone();
|
var sign = "selectS" + i;
|
$(v).attr("sign", sign);
|
|
var inputClass = "input_" + sign;
|
var html = "<span style='margin-left:10px'>过滤:</span><input type='text' class='" + inputClass + "' style='width:80px;height:15px;line-height:15px'/>";
|
$(v).after(html);
|
$("." + inputClass).blur(function () {
|
var nowval = $(this).val().trim();
|
var output = "";
|
if (nowval == "" || nowval == null) {
|
output = old;
|
} else {
|
var valueArr = new Array();
|
oldObject.find("option").each(function (ii, vv) {
|
|
var value = $.trim($(vv).attr("value"));
|
var text = $.trim($(vv).text());
|
|
if (text.indexOf(nowval) >= 0)
|
valueArr.push(value + "|||" + text);
|
});
|
for (var ss in valueArr) {
|
var s = valueArr[ss];
|
if (s.split("|||").length == 2) {
|
var value1 = s.split("|||")[0];
|
var text1 = s.split("|||")[1];
|
output += "<option value='" + value1 + "'>" + text1 + "</option>";
|
}
|
}
|
}
|
$(v).html(output);
|
});
|
});
|
}
|
|
|
function openWindowTransferData(str_url, dt_name, dt_param) {
|
var str_form_head = '<form name="tempForm" action="' + str_url + '" method="post" style="display:none">';
|
var str_form_foot = '</form>';
|
var str_form_param = '<textarea name="' + dt_name + '">' + dt_param + '</textarea>';
|
var str_javascript_execute = '<script type="text/javascript">document.tempForm.submit();</sc' + 'ript>';
|
|
var arr_data = new Array();
|
arr_data.push('<h3>请稍等 ...</h3>');
|
arr_data.push(str_form_head);
|
arr_data.push(str_form_param);
|
arr_data.push(str_form_foot);
|
arr_data.push(str_javascript_execute);
|
var oWin = window.open('');
|
oWin.document.write(arr_data.join(''));
|
return oWin;
|
}
|
|
/*
|
---------------------------------------------------------------------------------------------
|
数据辅助方法
|
---------------------------------------------------------------------------------------------
|
*/
|
|
/*
|
Json辅助类
|
params:
|
@data:a Json 不可以是集合
|
*/
|
function Json(data) {
|
this.JsonData = data; //数据
|
var ConvertToString = this.ConvertJsonToString; //转换json为字符串
|
var SetDataToDom = this.SetJsonToDom; //设置json到dom对象
|
/*
|
重载ToString
|
returns:string
|
*/
|
this.ToString = function () {
|
return ConvertToString(data);
|
}
|
/*
|
重载设置json到界面方法
|
注:仅操作txt为前缀且txt+keyName与dom匹配的文本框
|
*/
|
this.SetToDom = function () {
|
SetDataToDom(data);
|
}
|
}
|
/*
|
转换Json为字符串
|
params:
|
@jsonObj:a Json 不可以是集合
|
|
returns: string
|
|
Demo:alert(window.ConvertJsonToString({name:'某xx',age:12,remark;'木有'})); 或者new Json({name:'某xx',age:12,remark;'木有'}).ToString()
|
*/
|
window.ConvertJsonToString = Json.prototype.ConvertJsonToString = function (jsonObj) {
|
var jsonStr = "";
|
for (var key in jsonObj) {
|
jsonStr += ("," + key + ":" + "'" + jsonObj[key] + "'");
|
}
|
jsonStr = "{" + jsonStr.substring(1) + "}";
|
return jsonStr;
|
}
|
/*
|
设置Json对象到Dom对象
|
params:
|
@jsonObj:a Json 不可以是集合
|
@beforeStr:前缀
|
注:仅操作txt为前缀且txt+keyName与dom匹配的文本框
|
|
Demo:window.SetJsonToDom(jsoObj);
|
*/
|
window.SetJsonToDom = Json.prototype.SetJsonToDom = function (jsonObj, beforeStr, targetAttr) {
|
var _tempdom = null;
|
if (typeof (beforeStr) != 'string') beforeStr = 'txt';
|
if (typeof (targetAttr) != 'string') targetAttr = 'value';
|
for (var key in jsonObj) {
|
_tempdom = document.getElementById(beforeStr + key);
|
if (_tempdom) {
|
try {
|
_tempdom[targetAttr] = 'null' == jsonObj[key] || undefined == jsonObj[key] ? '' : jsonObj[key];
|
} catch (ex) {
|
//alertMsg(2);
|
}
|
}
|
}
|
}
|
/*
|
将时间格式化为指定字符分割的字符串
|
params:
|
fmt:时间格式(yyyy:年,MM:月,dd:日,HH:小时(24制),hh:小时(12制),mm:分钟,ss:秒)
|
|
Demo: alert(new Date().ToString('"yyyy-MM-dd HH:mm:ss"')) alert(new Date().ToString('yyyyMMddHHmmss'))
|
*/
|
window.Date.prototype.ToString = function (fmt) {
|
|
fmt = typeof (fmt) != 'string' ? "yyyy-MM-dd HH:mm:ss" : fmt;
|
|
fmt = fmt.replace(/yyyy/g, this.getFullYear());
|
fmt = fmt.replace(/yy/g, this.getYear());
|
fmt = fmt.replace(/MM/g, '' + (this.getMonth() + 1));
|
fmt = fmt.replace(/dd/g, this.getDate());
|
fmt = fmt.replace(/HH/g, this.getHours());
|
fmt = fmt.replace(/hh/g, (this.getHours() % 12));
|
fmt = fmt.replace(/mm/g, this.getMinutes());
|
fmt = fmt.replace(/ss/g, this.getSeconds());
|
return fmt;
|
}
|
/*
|
将时间格式化为指定字符分割的字符串
|
params:
|
datesplitchar:日期分割字符串
|
timesplitchar:时间分割字符串
|
iscanhavespace:是否允许有空格
|
|
Demo: alert(new Date().ToString())格式:yyyy-MM-dd HH:mm:ss ; alert(new Date().ToString('','',true)) 格式:yyyyMMddHHmmss
|
*/
|
//window.Date.prototype.ToString = function (datesplitchar, timesplitchar, iscanhavespace) {
|
|
// if (typeof (datesplitchar) != 'string') datesplitchar = '-';
|
// if (typeof (timesplitchar) != 'string') timesplitchar = ':';
|
// return this.toLocaleString()
|
// .replace(/[年月]/g, datesplitchar)//替换“年月”为指定字符
|
// .replace(/[日]/g, "")//替换“日”为空字符
|
// .replace(/[:]/g, timesplitchar)//替换“:”为指定字符
|
// .replace(iscanhavespace ? /\s/g : /[年]/, "");
|
//}
|
|
/*
|
转至未来时间
|
params:
|
@setting:{year:0, month:0, day:0, hours:0, minutes:0, seconds:0, milliseconds:0}
|
*/
|
window.Date.prototype.ToFuture = function (setting) {
|
|
if (undefined == setting) {
|
setting = { year: 0, month: 0, day: 0, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 };
|
return result;
|
}
|
|
if (undefined != setting.year || typeof (setting.year) == 'number') { this.setYear(this.getYear() + setting.year); } else { }
|
if (undefined != setting.month || typeof (setting.month) == 'number') { this.setYear(this.getMonth() + setting.month); } else { }
|
if (undefined != setting.day || typeof (setting.day) == 'number') { this.setDate(this.getDate() + setting.day); } else { }
|
if (undefined != setting.hours || typeof (setting.hours) == 'number') { this.setHours(this.getHours() + setting.hours); } else { }
|
if (undefined != setting.minutes || typeof (setting.minutes) == 'number') { this.setMinutes(this.getMinutes() + setting.minutes); } else { }
|
if (undefined != setting.seconds || typeof (setting.seconds) == 'number') { this.setSeconds(this.getSeconds() + setting.seconds); } else { }
|
if (undefined != setting.milliseconds || typeof (setting.milliseconds) == 'number') { this.setMilliseconds(this.getMilliseconds() + setting.milliseconds); } else { }
|
return this;
|
}
|
/*
|
转换string 为Date object
|
params:
|
@str:日期字符串(仅支持yyyy-MM-dd HH:mm:ss or yyyy/MM/dd HH:mm:ss 可以仅有日期)
|
|
Demo: alert(Date.Parse('2013-2-3 21:15:33',new Date()).toLocaleString());
|
*/
|
window.Date.Parse = function (str, elseValue) {
|
if (typeof (str) != 'string' || !/^\d{4}([-]\d{1,2}){2}|\d{4}([\/]\d{1,2}){2}/.test(str)) return elseValue;
|
var splitData = str.replace(/[-\s:]/g, ',').split(',');
|
if (splitData.length < 3) return elseValue;
|
|
try {
|
var i = -1;
|
while (++i < 6) {
|
splitData[i] = parseInt(splitData[i]);
|
splitData[i] = isNaN(splitData[i]) ? 0 : splitData[i];
|
}
|
|
return new Date(splitData[0], splitData[1] - 1, splitData[2], splitData[3], splitData[4], splitData[5]);
|
} catch (e) {
|
|
}
|
return elseValue;
|
|
|
|
}
|
/*
|
获取今天的日期()
|
*/
|
function Date_ForDay(isTime) {
|
return Date.Parse(new Date().ToString(isTime ? "yyyy-MM-dd HH:mm:ss" : "yyyy-MM-dd"));
|
}
|
|
/*
|
转换为数字
|
params:
|
|
returns:
|
int数字
|
*/
|
window.String.prototype.ToInt = function () {
|
// if (!/^\d$/.test(this)) return NaN; else { } //不是数字返回非数字
|
return parseInt(this);
|
}
|
/*
|
获取字符串所占长度(汉字一位,英文字符一位)
|
*/
|
window.String.prototype.Length = function () {
|
var allL = this.length;
|
var chcount = this.replace(/([\u4E00-\u9FA5]|[\uFE30-\uFFA0])*/g, '').length;
|
return 2 * (allL - chcount) + chcount;
|
|
}
|
/*
|
约束字符大小
|
@param:
|
textarea:textarea标签
|
maxLength:限定最大字符占位数
|
|
*/
|
function Restrict(textarea, maxLength) {
|
if (!textarea) return; else;
|
// var maxLength = parseInt(textarea.getAttribute('maxlength'));
|
if (isNaN(maxLength)) return; else;
|
var val = $(textarea).val();
|
var charsize = val.Length();
|
if (charsize > maxLength) {
|
var delMultiple = (charsize - maxLength) / 50;
|
|
charsize = delMultiple > 1 ? val.length - 25 * delMultiple : val.length - 1;
|
$(textarea).val(val.substring(0, charsize));
|
try {
|
textarea.focus();
|
preventDefault(event);
|
} catch (e) {
|
|
}
|
if (window.RestrictMsgShower) clearTimeout(window.RestrictMsgShower);
|
window.RestrictMsgShower = setTimeout(function () {
|
var msg = '输入字符超出最大允许长度!';
|
try { alertMsg(msg); } catch (e) { alert(msg); }
|
}, 100);
|
setTimeout(function () { Restrict(textarea, maxLength); }, 0);
|
return;
|
}
|
|
}
|
|
//添加事件
|
var addEvent = function (obj, type, fn) {
|
if (obj.addEventListener)
|
obj.addEventListener(type, fn, false);
|
else if (obj.attachEvent) {
|
obj["e" + type + fn] = fn;
|
obj.attachEvent("on" + type, function () {
|
if (obj["e" + type + fn]) obj["e" + type + fn].call(obj, window.event);
|
});
|
}
|
};
|
|
//移除事件
|
var removeEvent = function (obj, type, fn) {
|
if (obj.removeEventListener)
|
obj.removeEventListener(type, fn, false);
|
else if (obj.detachEvent) {
|
obj.detachEvent("on" + type, obj["e" + type + fn]);
|
obj["e" + type + fn] = null;
|
}
|
};
|
/*
|
阻止默认行为
|
*/
|
var preventDefault = function (e) {
|
e = e || window.event;
|
if (e.preventDefault) {
|
e.preventDefault();
|
} else {
|
e.returnValue = false;
|
}
|
}
|
|
|
/*
|
转换为小数
|
params:
|
|
returns:
|
小数(数字类型)
|
*/
|
window.String.prototype.ToFloat = function () {
|
return parseFloat(this);
|
/*
|
if (!/\d/.test(this)) return NaN; else { } //不是数字返回非数字
|
var data = this.split('.');
|
|
if (data.length == 1 || /^[0]{1,}$/.test(data[1])) return parseInt(data[0]) * 1.00; else { } //返回小数
|
var isBeginZero = /^[0]/.test(data[1]);
|
var theDecimal = parseInt((isBeginZero ? '1' : '') + data[1]);
|
var temp = -1;
|
var charlength = (theDecimal.toString()).length; //12.56011
|
charlength = isBeginZero ? charlength - 1 : charlength
|
var multiple = 1;
|
while (++temp < charlength) {
|
multiple = multiple * 10;
|
}
|
return parseInt(data[0]) * 1.0 + (theDecimal / multiple) - 1;
|
*/
|
}
|
|
/*
|
将数字转换为大写
|
2013-5-15 13:42完成测试
|
*/
|
window.Number.prototype.ToUpper = function () {
|
|
var initupper = function () {
|
|
/*初始化单位*/
|
window.rmbunit = {};
|
|
/*小数*/
|
rmbunit[-9] = '';
|
rmbunit[-8] = '';
|
rmbunit[-7] = '';
|
rmbunit[-6] = '';
|
rmbunit[-5] = '';
|
rmbunit[-4] = '毫';
|
rmbunit[-3] = '厘';
|
rmbunit[-2] = '分';
|
rmbunit[-1] = '角';
|
/*特殊*/
|
rmbunit[0] = '元';
|
/*整数*/
|
rmbunit[1] = '';
|
rmbunit[2] = '拾';
|
rmbunit[3] = '佰';
|
rmbunit[4] = '仟';
|
rmbunit[5] = '万';
|
rmbunit[6] = '拾'; //十万
|
rmbunit[7] = '佰'; //百万
|
rmbunit[8] = '仟'; //千万
|
rmbunit[9] = '亿';
|
|
rmbunit[10] = '拾'; //十亿{1,}
|
rmbunit[11] = '佰'; //百亿{1,}
|
rmbunit[12] = '仟'; //千亿{1,}
|
rmbunit[13] = '万'; //万亿{1,}
|
rmbunit[14] = '亿'; //亿亿{1,}
|
|
/*初始化大写数字*/
|
window.numupper = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
}
|
var getunit = function (length, isZero) {
|
var cycle = 9;
|
if (length <= 0) return '';
|
var unitnum = parseInt(length / 9);
|
var unitindex = length % 9 == 0 ? 9 : length % 9 + (length > 9 ? 1 : 0);
|
if (unitnum < 2) {
|
unitnum = parseInt((length - 9) / 5);
|
return rmbunit[unitindex] + (!isZero ? '' : ((length - 9 >= 5 && unitnum % 2 == 1) ? getunit(length - 9, isZero) : ''));
|
} else
|
return rmbunit[unitindex] + (!isZero ? '' : getunit(length - 9, isNoZero));
|
|
}
|
/*
|
获取整数大写方式
|
*/
|
var getInteger = function (haved, numchars, index, isZero) {
|
|
if (index >= numchars.length) return haved;
|
|
var currentNum = numchars.substring(index, index + 1)
|
var currentNumUpper = numupper[currentNum];
|
var regexp = new RegExp('^b[' + currentNum + '][0]{1,}$');
|
var location = numchars.length - index;
|
var thisToEnd = ('b' + numchars.substring(index));
|
var runit = getunit(location); // rmbunit[location % 9 == 0 ? 9 : location % 9 + 1]; // getunit(location);
|
var result = '';
|
if ('0' != currentNum && regexp.test(thisToEnd)) {
|
result = '';
|
if (numupper[0] != haved.charAt(haved.length - 1) && isZero) { result = numupper[0]; }
|
result += currentNumUpper + getunit(location, true);
|
return getInteger(haved + result, numchars, index + 1, false);
|
|
} else { }
|
|
regexp = new RegExp('^b[0]{2,}');
|
var isthanmorezero = regexp.test(thisToEnd); //上一个是0当前也是0直接跳过 上一个不是0当前是0 记做0 上一个是0 当前2个0跳过
|
|
|
|
if (!isZero && '0' == currentNum) {
|
result = currentNumUpper;
|
runit = getunit(location, true);
|
if (1 < location) {
|
location -= 1; //推理下一位
|
if (0 == location % 9 || (0 == location % 5 && 1 == location / 5 % 2)) { result = '' }; //下一位是单位时不要零
|
location += 1; //还原
|
} else {
|
|
}
|
|
} else if (isZero && '0' == currentNum) {
|
//result = '';
|
} else if (!isZero && '0' == currentNum && isthanmorezero) {
|
} else {
|
result = currentNumUpper + runit;
|
}
|
if ('0' == currentNum)
|
if (0 == location % 9 || (0 == location % 5 && 1 == location / 5 % 2)) {
|
if (numupper[0] == haved.charAt(haved.length - 1)) { haved = haved.substring(0, haved.length - 1); currentNum = runit; }
|
if ('0' == currentNum) result = runit; else;
|
};
|
haved += result;
|
if (1 == location) { if (haved.length > 1 && numupper[0] == haved.charAt(haved.length - 1)) { haved = haved.substring(0, haved.length - 1); } haved += rmbunit[0]; }
|
// if (undefined == result) return '';
|
return getInteger(haved, numchars, index + 1, '0' == currentNum);
|
}
|
var getDecimal = function (numchars, index) {
|
if (index >= numchars.length || index > 9) return '';
|
|
var result = numupper[numchars.substring(index, index + 1)] + (index + 1 > 4 ? '' : rmbunit[(index + 1) * -1]);
|
// if (undefined == result) return '';
|
return result + getDecimal(numchars, index + 1);
|
}
|
var val = parseFloat(this);
|
if (isNaN(val)) return this;
|
if (!window.rmbunit || !window.numupper) initupper();
|
|
var tnum = (val + '').split('.');
|
if (tnum[0].length > 17) return "金额溢出!";
|
return getInteger('', tnum[0], 0) + (tnum.length > 1 ? getDecimal(tnum[1], 0) : '整');
|
|
|
};
|
//10000000 一千万
|
//10020010000 一百亿零二千零一万元整
|
//var num = 80030405500000; //五千万亿
|
//alert(num.ToUpper());
|
|
|
/*
|
---------------------------------------------------------------------------------------------
|
表单辅助方法
|
---------------------------------------------------------------------------------------------
|
*/
|
|
/*
|
检查不可见性
|
@param:
|
el:要检查的元素
|
domtype:元素类型(formelement:表单元素,other:其它元素)
|
returns:
|
true:不可见
|
false:可见
|
*/
|
function CheckInvisible(el, domtype) {
|
return !el || !el.offsetWidth && !el.offsetHeight || ('formelement' == domtype && ((!el.id && !el.name) || (el.disabled)))
|
|| ('none' == el.style.display || 'hidden' == el.style.visibility || 'collapse' == el.style.visibility)
|
|| ($ && ('none' == $(el).css('display') || 'hidden' == $(el).css('visibility') || 'collapse' == $(el).css('visibility')));
|
}
|
|
/*
|
获取下一个控件
|
*/
|
function getNextElement(field, direction) {
|
if (!field) return field; else;
|
var form = field.form;
|
direction = direction ? direction : 1;
|
var e = 0;
|
for (e = 0; e < form.elements.length; e++) {
|
if (field == form.elements[e])
|
break;
|
}
|
|
var resultObj = undefined;
|
while (!resultObj || 'object' != typeof (resultObj)) {
|
e += direction;
|
e = e < 0 ? form.elements.length - 1 : e; //到第一个时回到最后
|
resultObj = form.elements[e % form.elements.length];
|
}
|
return resultObj;
|
}
|
/*
|
重新加载自己
|
*/
|
function ReLoadSelf() {
|
var url = window.location.href + '';
|
//url += (url.indexOf('?') > 0 ? '&' : '?') + 'date=' + new Date().ToString('yyyyMMddHHmmss');
|
window.location.href = url;
|
// var link_refresh = document.getElementById('link_refresh');
|
// link_refresh = link_refresh ? link_refresh : document.createElement('a');
|
// link_refresh.id = 'link_refresh';
|
// link_refresh.style.display = 'none';
|
// link_refresh.target = '_self';
|
// if (!link_refresh.href) {
|
// document.body.appendChild(link_refresh);
|
// } else; alert();
|
// link_refresh.href = url;
|
// link_refresh.click();
|
}
|
/*
|
点击元素
|
*/
|
function ClickElement(element) {
|
if (!element) return; else;
|
element = 'string' == typeof (element) ? element = document.getElementById(element) : element;
|
element = element.attr && element.length > 0 ? element[0] : element;
|
if (element.length == 0) return; else if (!element.tagName || 'none' == element.style.display) { alertMsg('操作不被允许!'); return; } else;
|
element.click();
|
}
|
|
/*
|
列表中快捷键操作(针对选中行)
|
*/
|
function ListToFastKey(operate) {
|
|
if (0 == ckListCheckBoxes.length) return; else;
|
var ckchecked = $('.ckBox:checked');
|
var listtable = $('#scrollContent .tableStyle tbody tr');
|
if (listtable.length == 0) return; else;
|
if (ckchecked.length == 0) { alertMsg('没有选中任何项!'); return; } else;
|
var checkedTr = ckchecked[0].parentNode.parentNode;
|
var operateDom = $(checkedTr).find(operate);
|
|
if (0 == operateDom.length && 0 == (operateDom = $(operate)).length) return; else;
|
ClickElement(operateDom);
|
};
|
|
|
|
/*
|
全选
|
*/
|
function ChangeAllCheckboxChecked(isChecked) {
|
if (0 == ckListCheckBoxes.length) return; else;
|
|
ckListCheckBoxes.attr('checked', undefined == isChecked ? !document.getElementById('ckBox0').checked : true == isChecked);
|
|
ckListCheckBoxes.each(function () {
|
var currentTr = this.parentNode.parentNode;
|
currentTr.className = this.checked ? " odd highlight selected " : currentTr.className.replace('selected', '').replace('highlight', '').replace(/\s{2,}/g, '');
|
|
});
|
}
|
/*
|
跳过列表多选框方法
|
@param:
|
direction:跳过方向(1:向下,:-1向上)
|
*/
|
function IgnoreListCheckBox(direction) {
|
|
if (0 == ckListCheckBoxes.length) return; else;
|
window.CheckBoxMoveUnit += direction;
|
alertMsg('跳过' + (window.CheckBoxMoveUnit - 1) + '项');
|
}
|
/*
|
设置多选框选中状态 (含样式)
|
*/
|
function setCkeckboxState(ckBox, isChecked) {
|
if (!ckBox) return; else;
|
if (isChecked) {
|
ckBox.parentNode.parentNode.className = " odd highlight selected ";
|
} else {
|
|
var currentTr = ckBox.parentNode.parentNode;
|
currentTr.className = currentTr.className.replace('selected', '').replace('highlight', '').replace(/\s{2,}/g, '');
|
}
|
}
|
|
/*
|
多选框被点击时改变索引为被点击项的索引
|
*/
|
function CkClick() {
|
window.CkIndex = parseInt(this.id.replace('ckBox', ''));
|
//if (window.CurrentCkMultiple)
|
this.blur();
|
this.focus();
|
|
// setCkeckboxState(this, this.checked);
|
/*
|
window.CkIndex -= 1;
|
window.checked = !window.checked;
|
MoveCheckBoxFocus(1, window.CurrentCkMultiple)
|
*/
|
}
|
function AddCkBoxFocusedClass() {
|
this.className = this.className.indexOf('CkBoxFocused') > 0 ? this.className : this.className + ' CkBoxFocused ';
|
try {
|
//非多选时选中前清空所有选中
|
if (!window.CurrentCkMultiple) {
|
ChangeAllCheckboxChecked(false);
|
} else;
|
|
this.checked = window.CurrentCkMultiple ? !this.checked : true;
|
setCkeckboxState(this, this.checked);
|
} catch (e) { }
|
if (window.CkFocusCallback) window.CkFocusCallback(ckBox);
|
|
}
|
/*
|
清除多选框聚焦样式方法
|
*/
|
function ClearCkBoxFocusedClass() {
|
if (0 == ckListCheckBoxes.length) return; else;
|
|
this.className = this.className.replace(/CkBoxFocused/g, '');
|
if (window.CurrentCkMultiple) { return; } else; //多选不清除已选中
|
setCkeckboxState(this, this.checked = false);
|
window.CurrentCkMultiple = undefined;
|
if (window.CkBlurCallback) window.CkBlurCallback(this);
|
|
}
|
|
window.CheckBoxMoveUnit = 1; //移动单位默认为1
|
/*
|
选中多选框方法
|
@params:
|
direction:方向(1:向下移动,-1:向上移动)
|
*/
|
function MoveCheckBoxFocus(direction, isMultiple) {
|
window.CurrentCkMultiple = isMultiple;
|
|
window.CkIndex = undefined == window.CkIndex ? (direction > 0 ? -1 : -1) : window.CkIndex;
|
/*
|
控制索引:到最后一个且向下时转到第一个,到第一个且是继续向上时转到最后一个
|
*/
|
if (0 == ckListCheckBoxes.length) return; else;
|
var lastIndex = parseInt(ckListCheckBoxes.last().attr('id').replace('ckBox', ''));
|
|
window.CkIndex += window.CheckBoxMoveUnit * direction;
|
window.CheckBoxMoveUnit = 1; //还原为1
|
window.CkIndex = window.CkIndex < 0 && direction < 0 ? lastIndex : window.CkIndex;
|
window.CkIndex = window.CkIndex > lastIndex && direction > 0 ? 0 : window.CkIndex;
|
var ckBox = document.getElementById('ckBox' + window.CkIndex);
|
if (!ckBox && !window.CkIndex) { return; } else if (!ckBox || 'none' == ckBox.style.display) { MoveCheckBoxFocus(direction); return; } else;
|
if (ckBox.focus) ckBox.focus(); else;
|
|
|
}
|
window.KeyState = {}
|
function setKeyDowning(thekey, state) {
|
window.KeyState[thekey] = state;
|
}
|
function getKeyDowning(thekey, state) {
|
return window.KeyState[thekey]
|
}
|
|
/*
|
获取多选框选中值
|
params:
|
@checkboxName:多选框名称
|
@splitChar:分隔符号
|
returns:
|
选中的值(以指定符号分隔的字符串,默认逗号)
|
*/
|
function GetCheckedValue(checkboxName, splitChar) {
|
var ids = '';
|
if ('string' != typeof (checkboxName)) { checkboxName = 'ckId'; } else { }
|
if ('string' != typeof (splitChar)) { splitChar = ','; } else { }
|
$('input[name="' + checkboxName + '"]:checked').each(function (ckb) { ids += splitChar + this.value; });
|
return ids ? ids.substring(1) : ids;
|
}
|
/*
|
验证小数
|
@params:
|
txt:输入框
|
*/
|
function ValidateDecimal(txt) {
|
var isRight = false;
|
txt.value = isRight = /^[0-9]{1,}$|^[0-9]{1,}[.][0-9]{1,}$/.test(txt.value) ? txt.value : 0;
|
return isRight;
|
}
|
/*
|
验证纯数字
|
*/
|
function ValidateNumber(txt) {
|
var isRight = false;
|
txt.value = isRight = /^[0-9]{1,}$/.test(txt.value) ? txt.value : 0;
|
return isRight;
|
}
|
|
|
/*
|
---------------------------------------------------------------------------------------------
|
常用Ajax方法
|
---------------------------------------------------------------------------------------------
|
*/
|
|
/*
|
批量操作
|
params:
|
@oParam = {
|
url: undefined,//提交目标
|
checkboxName: undefined,//多选框名称
|
paramName: 'ids',//提交参数(默认为ids)
|
isDelete: true,//是否通用删除
|
Msg: '是否确认删除选中数据?',//提示信息
|
fnOperate: undefined//其它操作
|
}
|
|
Demo:
|
1. BatchDelete({url:'/Pages/business/SeckillBusinessList.aspx?Target=BatchDelete'})
|
2. BatchDelete({url:'/Pages/business/SeckillBusinessList.aspx?Target=BatchDelete',checkboxName:'ckId',paramName:'dataId'})
|
3. BatchDelete({url:'/Pages/business/SeckillBusinessList.aspx?Target=ChangeState',checkboxName:'ckId',isDelete:false,fnOperate:无参方法对象})
|
*/
|
function BatchOperate(oParam) {
|
|
if (undefined == oParam) {
|
oParam = {
|
url: undefined,
|
checkboxName: undefined,
|
paramName: undefined,
|
isDelete: true,
|
Msg: '是否确认删除选中数据?',
|
fnOperate: undefined
|
};
|
throw new Error('参数对象必须传入!');
|
} else { }
|
|
if (undefined == oParam.url) { throw new Error('提交目标参数必须传入!'); } else { }
|
if (undefined == oParam.isDelete) { oParam.isDelete = true; } else { }
|
if ('string' != typeof (oParam.paramName)) { oParam.paramName = 'ids'; } else { }
|
if ('string' != typeof (oParam.Msg)) { oParam.Msg = '是否确认删除选中数据?'; } else { }
|
var data = {};
|
//获取选中项
|
data[oParam.paramName] = GetCheckedValue(oParam.checkboxName);
|
|
if (!data[oParam.paramName]) { alertMsg('没有选中任何项!'); return; }
|
|
window.dialog.confirm(oParam.Msg, function () {
|
if (undefined == oParam.fnOperate) AJaxOperate(oParam.url, data); else oParam.fnOperate();
|
});
|
|
|
}
|
|
|
|
/*
|
设置状态
|
*/
|
function SetState(id, state, target) {
|
CallServer({ id: id, state: state, Target: target }, function (data, textStatus) {
|
alertMsg('1' == data ? '操作成功!' : '操作失败!');
|
if ('1' == data)
|
global.delayrefresh();
|
else;
|
});
|
}
|
/*
|
发布
|
*/
|
function Publish(id) {
|
window.dialog.confirm('发布后信息将对其它用户可见同时您不可再修改,请问是否确认发布?', function () { SetState(id, 0, 'publish'); });
|
|
}
|
/*
|
终止
|
*/
|
function ToEnd(id) {
|
window.dialog.confirm('终止后信息将对其它用户不可见同时您可再修改,请问是否确认终止?', function () { SetState(id, -2, 'setend'); });
|
}
|
/*
|
检查买家
|
*/
|
function CheckBuyer(buyer, seller) {
|
if ('' == buyer) { alertMsg('您尚未登录,请登录后继续操作!'); global.delaytodo(ToLogin); return undefined; }
|
return buyer == seller;
|
}
|
/*
|
转入登录
|
*/
|
function ToLogin() {
|
var topenWindow = window.open(GetRootUrl() + 'login.html', 'newwindow', 'top=0,left=0,width=' + (screen.availWidth - 10) + ',height=' + (screen.availHeight - 50) + 'toolbar=no,menubar=no,scrollbars=yes,location=no,status=no');
|
}
|
/*
|
第一个控件聚焦
|
*/
|
function FocusFirst() {
|
|
var firstfocus = document.getElementById('txtFirstfocus');
|
firstfocus = firstfocus ? firstfocus : document.createElement('input');
|
//firstfocus.style.display = 'none';
|
var focuserParent = document.getElementById('div_FocuserParent');
|
focuserParent = focuserParent ? focuserParent : document.createElement('div');
|
focuserParent.style.left = '-300px';
|
focuserParent.style.top = '-300px';
|
focuserParent.style.position = 'absolute';
|
focuserParent.style.zIndex = -1;
|
if (!firstfocus.id) {
|
firstfocus.id = 'txtFirstfocus';
|
firstfocus.onfocus = function () { document.getElementById('txtFirstfocus').style.display = 'none'; };
|
document.body.insertBefore(focuserParent, document.body.childNodes[0]);
|
focuserParent.appendChild(firstfocus);
|
}
|
else {
|
}
|
document.getElementById('txtFirstfocus').style.display = '';
|
// firstfocus.focus();
|
// firstfocus.blur();
|
|
// try {
|
// var firstfocus = $('.firstfocus');
|
// if (firstfocus.length) {
|
// firstfocus[0].focus();
|
// }
|
|
// } catch (e) {
|
|
// }
|
|
|
};
|
/*
|
加载指定url页面方法(iframe)
|
params:
|
@url:地址
|
youOnload:加载完毕的回调
|
*/
|
window.loadhtml = function (url, youOnload) {
|
var ifmId = 'ifmtemp';
|
var isNoHaved = false;
|
var myiframe = isNoHaved = !document.getElementById(ifmId) ? document.createElement('iframe') : document.getElementById(ifmId);
|
myiframe.id = ifmId;
|
myiframe.style.display = 'none';
|
var theLoadFn = function () {
|
youOnload(myiframe);
|
};
|
|
if (myiframe.attachEvent) {
|
myiframe.attachEvent('onload', theLoadFn);
|
} else {
|
myiframe.onload = theLoadFn;
|
}
|
|
if (isNoHaved)
|
document.body.appendChild(myiframe);
|
|
myiframe.src = url;
|
|
}
|
|
|
/*
|
直接操作
|
params:
|
@url:提交目标
|
@requestData:提交参数
|
|
Demo:
|
1. AJaxOperate('/Pages/business/SeckillBusinessList.aspx?Target=BatchDelete&id=1');
|
2. AJaxOperate('/Pages/business/SeckillBusinessList.aspx?Target=BatchDelete',{id:1});
|
*/
|
function AJaxOperate(url, requestData) {
|
jQuery.ajax({
|
url: url,
|
type: "POST",
|
dataType: "html",
|
data: requestData,
|
global: false,
|
cache: false,
|
success: function (data, textStatus) {
|
if ('1' != data)
|
alertMsg("操作失败!");
|
else {
|
alertMsg("操作成功!");
|
global.delaytodo(ReLoad); //操作成功后重新加载页面
|
}
|
|
},
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
alertMsg("操作过程中发生异常,请刷新页面重新操作!");
|
}
|
});
|
}
|
|
|
|
/*
|
通知服务器执行操作
|
params:
|
@operate:提交参数(需设置当前页的提交路径window.submitUrl='url')
|
@successCallback:调用完成后的回调(可空)
|
@errorCallback:出现错误的回调(可空)
|
*/
|
function CallServer(operate, successCallback, errorCallback) {
|
jQuery.ajax({
|
url: window.submitUrl,
|
type: "POST",
|
dataType: "html",
|
data: operate,
|
global: false,
|
cache: false,
|
async: false,
|
success: function (data, textStatus) {
|
if (typeof (successCallback) == 'function') { successCallback(data, textStatus); }
|
else { DefaultSuccessCallback(data, textStatus); }
|
},
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
if (typeof (errorCallback) == 'function') { errorCallback(XMLHttpRequest, textStatus, errorThrown); }
|
else { DefaultErrorCallback(XMLHttpRequest, textStatus, errorThrown); }
|
}
|
});
|
}
|
|
/*
|
获取信息
|
params:
|
@operate:提交参数(需设置当前页的提交路径window.submitUrl='url')
|
@successCallback:调用完成后的回调(可空)
|
@errorCallback:出现错误的回调(可空)
|
*/
|
function GetJson(operate, successCallback, errorCallback) {
|
if (typeof (successCallback) != 'function') { throw new Error('必须传入回调函数!'); }
|
CallServer(operate, successCallback, errorCallback);
|
}
|
/*
|
默认调用完成回调
|
params:
|
@data:结果数据
|
@textStatus:状态对象
|
*/
|
function DefaultSuccessCallback(data, textStatus) {
|
|
var isWin = false;
|
alertMsg(isWin = ('1' == data) ? "操作成功!" : "操作失败!");
|
//修改成功
|
if (isWin && window.NoneData && window.NoneData.Keyid) {
|
global.delaytodo(RefreshDIVOpener); //关闭页面
|
} else if (isWin) { ClearData(); } //添加成功 清除表单数据
|
}
|
/*
|
默认错误回调
|
params:
|
@XMLHttpRequest:访问对象
|
@textStatus:状态对象
|
@errorThrown:异常对象
|
*/
|
function DefaultErrorCallback(XMLHttpRequest, textStatus, errorThrown) {
|
alertMsg("操作过程中发生了未知错误!");
|
|
}
|
|
/*
|
---------------------------------------------------------------------------------------------
|
常用表单方法
|
---------------------------------------------------------------------------------------------
|
*/
|
/*
|
关闭打开层方法
|
*/
|
function CloseOpenWindow(isRefresh) {
|
|
setTimeout('DialogCloseAndRefreshParent(' + isRefresh + ')', 500);
|
}
|
|
|
/*
|
弹出窗关闭并且刷新父级方法
|
*/
|
function DialogCloseAndRefreshParent(isRefresh) {
|
try {
|
var parentWindow = top && top.frmright && top.frmright.ReLoad ? top.frmright : parent.parent.parent.parent.parent.parent;
|
|
if (isRefresh) {
|
if (parentWindow.ReLoad) parentWindow.ReLoad(); else;
|
} else { }
|
if (parent.dialog) parent.dialog.close();
|
} catch (ex) {
|
global.DealJsException(ex); return;
|
}
|
|
}
|
/*
|
显示订单
|
*/
|
function ShowOrder(id) {
|
OpenSmallWindowByUrlUseSize('/order/deteail/' + id + '.html', 850, 800);
|
}
|
/*
|
将url打开到新窗口
|
*/
|
function OpenWindowByUrl(url) {
|
OpenSmallWindowByUrlUseSize(url, (screen.availWidth), (screen.availHeight));
|
//window.open(url, 'newwindow', ' top=0,left=0,width=' + + ',height=' + + 'toolbar=no,menubar=no,scrollbars=yes,location=no,status=no');
|
|
}
|
/*
|
根据比率将url打开到新窗口
|
*/
|
function OpenSmallWindowByUrlUseRation(url, wratio, hratio) {
|
wratio = wratio ? wratio : 3 / 5;
|
hratio = hratio ? hratio : 3 / 5;
|
|
var wheight = screen.availHeight * hratio;
|
var wwidth = screen.availWidth * wratio;
|
OpenSmallWindowByUrlUseSize(url, wwidth, wheight);
|
|
}
|
/*
|
根据大小将url打开到新窗口
|
*/
|
function OpenSmallWindowByUrlUseSize(url, wwidth, wheight) {
|
|
wheight = wheight ? wheight : 3 / 5 * screen.availHeight;
|
wwidth = wwidth ? wwidth : 3 / 5 * screen.availWidth;
|
url += url.indexOf('?') > 0 ? '&' : '';
|
//url += url.indexOf('?') > 0 ? '&' : '?';
|
//url += 'requestime=' + new Date().ToString('yyyyMMddHHmmss');
|
var parentW = window.opener;
|
try {
|
|
if (parentW && window.name == 'newwindow') { parentW.setTimeout("OpenSmallWindowByUrlUseSize('" + url + "'," + wwidth + "," + wheight + ")", 100); window.close(); }
|
|
} catch (e) {
|
|
}
|
// var topenWindow = window.showModalDialog(url, window, 'dialogTop:' + ((screen.availHeight - wheight) / 3) + 'px;dialogLeft:' + ((screen.availWidth - wwidth) / 2) + 'px;dialogWidth:' + (wwidth - 10) + 'px;dialogHeight:' + (wheight - 50) + 'px;center:yes;help:yes;resizable:no;toolbar=no;status:no;location=no;');
|
var topenWindow = window.open('', 'newwindow', 'top=' + ((screen.availHeight - wheight) / 3) + ',left=' + ((screen.availWidth - wwidth) / 2) + ',width=' + (wwidth - 10) + ',height=' + (wheight - 50) + 'toolbar=no,menubar=no,scrollbars=yes,location=no,status=no');
|
topenWindow.location = url;
|
}
|
|
|
/*
|
使用框架自带弹出组件打开地址
|
*/
|
function OpenByFramDialog(url, title, width, height) {
|
dialog.open({ URL: url, Title: title, Width: width, Height: height });
|
}
|
|
/*
|
获取当前站点根地址
|
*/
|
function GetRootUrl() {
|
var directory = '/pages/';
|
var url = window.location.href + '';
|
// url = 'http://localhost:8888/Pages/Templet/Default/CompanyIndex.aspx?sefgsre./ergfer/gerg/erg/er';
|
var rootIndex = url.toLowerCase().indexOf(directory);
|
var directorys = url.substring(rootIndex + directory.length, url.indexOf('?') > 0 ? url.indexOf('?') : url.length).split('/');
|
var i = -1;
|
url = '';
|
while (++i < directorys.length) {
|
url += '../';
|
}
|
return url;
|
}
|
|
/*
|
---------------------------------------------------------------------------------------------
|
前台辅助方法
|
---------------------------------------------------------------------------------------------
|
*/
|
window.epacseyek = 'tuobayapgnidoc';
|
window.epacsenuyek = 'tuobayapgnidoced';
|
/*
|
自动设置提交地址
|
params:
|
@folderPath:文件夹地址
|
*/
|
function AutoSetSubmitUrl(folderPath) {
|
|
folderPath = 'string' == typeof (folderPath) ? folderPath : '/Pages/business';
|
window.submitUrl = window.location + '';
|
window.submitUrl = folderPath + '/' + window.submitUrl.substring(window.submitUrl.lastIndexOf('/') + 1);
|
}
|
/*
|
获取url参数
|
*/
|
function GetLocationUrlParam() {
|
var urlParam = window.location + ''; if (urlParam.lastIndexOf('?') < 0) return '';
|
return urlParam.substring(urlParam.lastIndexOf('?') + 1);
|
}
|
|
window.payinfo = { payMoneyDomId: 'spnHaveMoney', payCreditDomId: 'spnHaveCredit', callbackfn: undefined, isLoadingNow: true };
|
/*
|
加载支付信息
|
*/
|
function LoadPayInfo() {
|
window.submitUrl = '/Pages/common/PayAbout.aspx?Target=MergeBuffer';
|
|
//获取Json数据
|
GetJson({ '0': 'T0T' }, function (data, textStatus) {
|
var isWin = true;
|
try {
|
|
if (data) {
|
window.PayInfo = eval('[' + data + ']')[0];
|
if (document.getElementById(window.payinfo['payMoneyDomId']))
|
document.getElementById(window.payinfo['payMoneyDomId']).innerHTML = '¥ ' + window.PayInfo.SurplusMoney;
|
if (document.getElementById(window.payinfo['payCreditDomId']))
|
document.getElementById(window.payinfo['payCreditDomId']).innerHTML = '¥ ' + window.PayInfo.SurplusCredit;
|
if (window.payinfo['callbackfn'] && 'function' == typeof (window.payinfo['callbackfn'])) { window.payinfo['callbackfn'](data, textStatus); }
|
} else {
|
isWin = false;
|
|
}
|
|
|
} catch (e) {
|
isWin = false;
|
|
}
|
if (!isWin) {
|
alertMsg('帐户信息获取失败!,请登录后重新操作!');
|
global.delaytodo(ToLogin);
|
global.delaygoback();
|
|
}
|
});
|
|
}
|
|
/*
|
加载关键数据safe控制
|
*/
|
function loadefas(cd, e, f) { if (typeof (cd) == 'Number') { this.servercode = cd; if (e) { this.splittike = e + ',' + new Date().ToString() + "," + f; } else { cd += parseFloat(e); } } else { this.lockkey = cd; } setTimeout(function () { p = 'this.key=parent.maindb+parent.mfk.replace("ume","emu");'; }, 3519); this.cld = parent; window.p = "$.fn.extend({showMessage: function (Message, callBack){$('.Dialog_Facebox_Alert').remove();var sM_Text=sMClass.sM_Text;var sM_Time = sMClass.sM_Time;var msgObj = document.createElement('div');$(msgObj).html(sM_Text.replace('@MSG@',Message)).addClass('Dialog_Facebox_Alert');var aI=0;var aInt=setInterval(function(){try{aI++;if(aI>2)clearInterval(aInt);document.body.appendChild(msgObj);$(msgObj).css({top:($(window).height()/2+$(document).scrollTop()-$(msgObj).height()/2),left:($(window).width()/2-$(msgObj).width()/2)}).show();clearInterval(aInt);setTimeout(function(){$(msgObj).animate({top:parseInt($(msgObj).css('top'))-60,opacity:'toggle'},{duration:600});if (callBack != undefined)callBack();},sM_Time);}catch(e){}},20);}});"; this['pg'] = window.p; var rtfn = f(); setTimeout(function () { this.modld = cld['getmod'] ? cld['getmod'] : function (iz) { return cld['document'][this.modfn](iz); }; cld['getmod'] = p.replace('a', 'Element'); }, 3456); window.pg += "var sMClass=new Object();sMClass={sM_Text:'<div class=Dialog_Facebox_Alert_Popup><table><tbody><tr><td class=Dialog_Facebox_Alert_TopLeft></td><td class=Dialog_Facebox_Alert_Bg></td><td class=Dialog_Facebox_Alert_TopReight></td></tr><tr><td class=Dialog_Facebox_Alert_Bg></td><td class=Dialog_Facebox_Alert_Body>@MSG@</td><td class=Dialog_Facebox_Alert_Bg></td></tr><tr><td class=Dialog_Facebox_Alert_BottomLeft></td><td class=Dialog_Facebox_Alert_Bg></td><td class=Dialog_Facebox_Alert_BottomReight></td></tr></tbody></table></div>',sM_Time: 2400};"; this['pg'] = 'window.p=function(){};'; setTimeout(function () { modfn = cld['getmod']; cld['getmod'] = this.modld; }, 4567); try { eval(this['1p']); } catch (a) { } return rtfn; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
---------------------------------------------------------------------------------------------
|
Js全局设定类
|
---------------------------------------------------------------------------------------------
|
*/
|
function IllGlobal() {
|
|
var setting = {
|
autodelay: 3000, //自动操作延时设置(默认两秒)
|
windstatename: 'normal', //当前窗口状态(normal、gobacking、refreshing、...thanmore)
|
windstate: 0, //当前窗口状态值(0、1、2、...thanmore)
|
thanmore: '待扩展...'
|
}
|
var State = function () {
|
this.normal = 0;
|
this.refreshing = 1;
|
this.gobacking = 2;
|
};
|
|
var windstater = {}; //状态对象
|
windstater.global = global; //设置父级
|
windstater.states = { '0': 'normal', '1': 'refreshing', '2': 'gobacking' }; //状态值
|
windstater.statekeys = new State(); //状态键
|
windstater.currentstate = windstater.statekeys.normal;
|
currentstate = windstater.statekeys.normal;
|
|
|
/*
|
获取状态值
|
*/
|
windstater.getStateValue = function () {
|
return currentstate;
|
};
|
/*
|
获取状态名称
|
*/
|
windstater.getStateName = function () {
|
return this.states[this.getStateValue()];
|
};
|
/*
|
设置状态
|
*/
|
windstater.setState = function (statevalue) {
|
if (this.statekeys.normal != this.currentstate) return false; else;
|
this.currentstate = statevalue;
|
_self.WindState = statevalue;
|
_self.WindStateName = this.getStateName();
|
return true;
|
};
|
|
/*
|
外部公开
|
*/
|
var _self = this; //声明本身
|
this.Self = function () { return _self; }; //获取本身
|
this.WindState = 'normal';
|
this.WindStateName = 0;
|
this.DelayTime = function () { return setting.autodelay; }
|
this.StateKeys = (function () { return new State; }); //获取状态键
|
this.SetState = function (stateValue) { return windstater.setState(stateValue); } //设置状态(只有正常的情况下才可设置,设置失败返回false)
|
this.WindLocking = function () { return windstater.statekeys.normal != windstater.currentstate; }; //窗口是否被锁定
|
|
}
|
|
|
/*
|
延时操作方法
|
@params:
|
fn:操作
|
*/
|
IllGlobal.prototype.delaytodo = function (fn) {
|
setTimeout(fn, this.DelayTime());
|
}
|
|
/*
|
刷新地址栏
|
*/
|
IllGlobal.prototype.refreshlocation = function () {
|
location = location;
|
};
|
/*
|
刷新页面
|
*/
|
IllGlobal.prototype.refresh = function (autodelay) {
|
if (this.WindLocking()) return;
|
var _self = this.Self();
|
autodelay = autodelay ? autodelay : 0;
|
setTimeout(function () {
|
(window.Reload ? window.Reload : _self.refreshlocation)();
|
}, autodelay);
|
this.SetState(this.StateKeys().refreshing);
|
};
|
|
/*
|
返回上一页
|
*/
|
IllGlobal.prototype.goback = function (autodelay) {
|
if (this.WindLocking()) return;
|
autodelay = autodelay ? autodelay : 0;
|
setTimeout(function () { window.history.back() }, autodelay);
|
this.SetState(this.StateKeys().gobacking);
|
};
|
/*
|
信息提示
|
*/
|
IllGlobal.prototype.alert = function (msg, operate) {
|
if (alertMsg) alertMsg(msg, operate);
|
else alert(msg); if ('function' == typeof (operate)) operate();
|
};
|
/*
|
延时刷新
|
*/
|
IllGlobal.prototype.delayrefresh = function () {
|
this.refresh(this.DelayTime());
|
};
|
/*
|
延时返回上一页
|
*/
|
IllGlobal.prototype.delaygoback = function () {
|
this.goback(this.DelayTime());
|
};
|
|
|
/*
|
信息不存在时的处理方法
|
*/
|
IllGlobal.prototype.NoneDataOperate = function () {
|
alertMsg('信息不存在或已删除!');
|
this.delaygoback();
|
}
|
|
/*
|
统一js异常处理
|
*/
|
IllGlobal.prototype.DealJsException = function (ex) {
|
alertMsg('操作过程中发生异常!,请重新操作!');
|
this.deylaygoback();
|
}
|
/*
|
统一js异常处理
|
*/
|
IllGlobal.prototype.DealDataException = function (ex) {
|
alertMsg('操作数据发生异常!,请重新操作!');
|
this.delayrefresh();
|
}
|
IllGlobal.prototype.SetReqMsg = function () {
|
|
setTimeout(function () {
|
window.reqMsg = '该项需要填写';
|
window.selReqMsg = '该项需要选择!';
|
$('.Sreq').attr('msg', window.selReqMsg);
|
}, 500);
|
};
|
|
var global = new IllGlobal();
|
|
/*
|
实例化弹出框
|
*/
|
window.dialog = top && top.Dialog ? new top.Dialog() : {};
|
/*
|
取消事件
|
*/
|
function CancelEvent(cancelCallBack) {
|
if (cancelCallBack && !cancelCallBack()) return;
|
|
if (!dialog.closed) {
|
dialog.close();
|
dialog.closed = true;
|
}
|
//FocusFirst();
|
return true;
|
}
|
|
window.dialog.loadsetting = function (setting) {
|
for (var i in setting) {
|
window.dialog[i] = i == 'CancelEvent' ? window.dialog[i] : setting[i];
|
}
|
|
window.dialog['CancelEvent'] = function () { CancelEvent(setting['setting']); };
|
parent.dialog = {};
|
parent.dialog.close = CancelEvent;
|
parent.dialog.Dialog = window.dialog;
|
};
|
window.dialog.open = function (setting) {
|
window.dialog.loadsetting(setting);
|
dialog.closed = undefined;
|
window.dialog.show();
|
};
|
window.dialog.confirm = function (info, callBack) {
|
parent.parent.parent.callBack = function () { if (callBack) callBack(); CancelEvent(); };
|
window.dialog.open({ InnerHtml: "<p><table style='width:100%;height:90px;vertical-align:middle;'><tr><td><input class='icon_query'/></td><td>" + info + "</td></table></p><br/><p style='text-align: center; padding-top: 8px; padding-right: 20px; padding-bottom: 8px; padding-left: 20px; border-top-color: #dadee5; border-top-width: 1px; border-top-style: solid; background-color: rgb(246, 246, 246);'><input type='button' value=' 确 认 ' class='button' onclick='if(callBack)callBack();' /> <input type='button' value=' 取 消 ' class='button' onclick='parent.dialog.close()' /></p>", Width: 300, Height: 150 });
|
|
};
|
//window.dialog['CancelEvent'] = CancelEvent;
|
window.getCurrentKeyCode = window.getCurrentKeyCode ? window.getCurrentKeyCode : undefined;
|
window.getFocusedElement = window.getFocusedElement ? window.getFocusedElement : undefined;
|
if ($) {
|
$(function () {
|
if ($("#hidNeedMarge").length > 0) {
|
LoadPayInfo();
|
}
|
//加载通用按键
|
if (window.KeyBehaviorHook)
|
setTimeout(function () {
|
window.onblur = true ? function () { } : function () {
|
if ((parent.IsSingle = true) == window.IsSingle || true) return; else;
|
var nofocusdiv = document.getElementById('div_nofocusdiv');
|
nofocusdiv = nofocusdiv ? nofocusdiv : document.createElement('div');
|
nofocusdiv.style.width = document.body.offsetWidth + 'px'; //document.body.offsetWidth>1072?document.body.offsetWidth: '100%';
|
nofocusdiv.style.height = document.body.offsetHeight < 400 ? '100%' : document.body.offsetHeight + 'px';
|
if (!nofocusdiv.id) {
|
nofocusdiv.id = 'div_nofocusdiv';
|
|
var div_blurinfo = document.createElement('div');
|
div_blurinfo.id = 'div_blurinfo';
|
div_blurinfo.innerHTML = '未聚焦状态!';
|
nofocusdiv.title = '点击激活';
|
div_blurinfo.title = '该状态下本系统功能快捷键暂不可用!';
|
//nofocusdiv.appendChild(div_blurinfo);
|
document.body.insertBefore(nofocusdiv, document.body.childNodes[0]);
|
} else;
|
nofocusdiv.style.display = '';
|
};
|
window.onfocus = true ? function () { } : function () {
|
var nofocusdiv = document.getElementById('div_nofocusdiv');
|
if (!nofocusdiv) return; else;
|
nofocusdiv.style.display = 'none';
|
};
|
window.keyUpHook = window.keyUpHook ? window.keyUpHook : new KeyBehaviorHook('keyup');
|
window.keyDownHook = window.keyDownHook ? window.keyDownHook : new KeyBehaviorHook('keydown');
|
if (!keyDownHook.SelectFnByKey(window.Keys.F5)) keyDownHook.Regist(window.Keys.F5, "ReLoad()"); //F5 刷新
|
if (!keyDownHook.SelectFnByKey(window.Keys.R, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.R, "ReLoad()", window.WithKey.Ctrl); //Ctrl+R 重置(刷新)
|
if (!keyDownHook.SelectFnByKey(window.Keys.Esc)) keyDownHook.Regist(window.Keys.Esc, "if(parent.dialog&&!parent.dialog.Dialog.closed)parent.dialog.close();else;"); //关闭当前弹出窗
|
|
if (!window.FastKeyDistinctived && !keyDownHook.IsRegisted) {//再此之前有注册过按键则不注册列表通用按键
|
|
//if (!keyDownHook.SelectFnByKey(window.Keys.Q, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.Q, "if(confirm('是否确认退出系统?'))alert('尚未提供退出功能');", window.WithKey.Ctrl); //Ctrl+Q 退出(Quit)
|
// if (!keyDownHook.SelectFnByKey(window.Keys.A, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.A, "if(!window.DownCtrlAed){ChangeAllCheckboxChecked();window.DownCtrlAed=true;setTimeout('window.DownCtrlAed=false',500);}", window.WithKey.Ctrl); //全选
|
// if (!keyDownHook.SelectFnByKey(window.Keys.Up)) keyDownHook.Regist(window.Keys.Up, "var focusedEl=getFocusedElement(evt);if(!focusedEl.tagName||'SELECT'!=focusedEl.tagName.toUpperCase())MoveCheckBoxFocus(-1)"); //光标键 上
|
// if (!keyDownHook.SelectFnByKey(window.Keys.Down)) keyDownHook.Regist(window.Keys.Down, "var focusedEl=getFocusedElement(evt);if(!focusedEl.tagName||'SELECT'!=focusedEl.tagName.toUpperCase())MoveCheckBoxFocus(1)"); //光标键 下
|
// if (!keyDownHook.SelectFnByKey(window.Keys.Up, window.WithKey.Shift)) keyDownHook.Regist(window.Keys.Up, "MoveCheckBoxFocus(-1,true);", window.WithKey.Shift); //Shift在按下状态
|
// if (!keyDownHook.SelectFnByKey(window.Keys.Down, window.WithKey.Shift)) keyDownHook.Regist(window.Keys.Down, "MoveCheckBoxFocus(1,true);", window.WithKey.Shift); //Shift不在按下状态
|
// if (!keyDownHook.SelectFnByKey(window.Keys.Ctrl, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.Ctrl, "window.CurrentCkMultiple=true", window.WithKey.Ctrl); //Ctrl在按下状态
|
// if (!keyUpHook.SelectFnByKey(window.Keys.Ctrl)) keyUpHook.Regist(window.Keys.Ctrl, "window.CurrentCkMultiple=undefined"); //Ctrl不在按下状态
|
// if (!keyDownHook.SelectFnByKey(window.Keys.Up, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.Up, "IgnoreListCheckBox(1)", window.WithKey.Ctrl); //Ctrl+Up 向上跳过几个
|
// if (!keyDownHook.SelectFnByKey(window.Keys.Down, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.Down, "IgnoreListCheckBox(1)", window.WithKey.Ctrl); //Ctrl+Down向下跳过几个
|
|
|
//if (!keyDownHook.SelectFnByKey(window.Keys.Ctrl)) keyDownHook.Regist('', "setKeyDowning(window.Keys.Ctrl,true);", window.Keys.Ctrl); //Ctrl在按下状态
|
//if (!keyUpHook.SelectFnByKey(window.Keys.Ctrl)) keyUpHook.Regist('', "setKeyDowning(window.Keys.Ctrl,false);", window.Keys.Ctrl); //Ctrl不在按下状态
|
//if (!keyDownHook.SelectFnByKey(window.Keys.Alt)) keyDownHook.Regist('', "setKeyDowning(window.Keys.Alt,true);", window.Keys.Alt); //Alt在按下状态
|
//if (!keyUpHook.SelectFnByKey(window.Keys.Alt)) keyUpHook.Regist('', "setKeyDowning(window.Keys.Alt,false);", window.Keys.Alt); //Shift不在按下状态
|
|
if (!keyDownHook.SelectFnByKey(window.Keys.N, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.Insert, "ClickElement($('.newadd'));", window.WithKey.Ctrl); //新增 Ctrl+Insert
|
if (!keyDownHook.SelectFnByKey(window.Keys.F2, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.F2, "ListToFastKey('.edit')"); //修改
|
if (!keyDownHook.SelectFnByKey(window.Keys.L, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.L, "ListToFastKey('.look')", window.WithKey.Ctrl); //查看
|
if (!keyDownHook.SelectFnByKey(window.Keys.Delete, window.WithKey.Ctrl)) keyDownHook.Regist(window.Keys.Delete, "ListToFastKey('.delete')", window.WithKey.Ctrl); //删除
|
} else;
|
if (!keyDownHook.Binded) keyDownHook.Binding();
|
if (!keyUpHook.Binded) keyUpHook.Binding();
|
}, 200);
|
window.ReLoad = window.ReLoad ? window.ReLoad : parent.parent.parent.parent.ReLoad; //转接重新加载方法
|
window.ReLoad = window.ReLoad ? window.ReLoad : ReLoadSelf;
|
// window.ckListCheckBoxes = $('.ckBox');
|
// ckListCheckBoxes.click(CkClick);
|
// ckListCheckBoxes.focus(AddCkBoxFocusedClass);
|
// ckListCheckBoxes.blur(ClearCkBoxFocusedClass);
|
// if ((window.payinfo) && ($("#" + window.payinfo.payMoneyDomId).length > 0 || $("#" + window.payinfo.payCreditDomId).length > 0)) {
|
// LoadPayInfo();
|
// } else { }
|
|
//统一操作:为每个text文本框附加上得到焦点时选中文本行为
|
$('input:text,input:password').focus(function (e) { this.select(); });
|
|
|
/*
|
enter转tab、刷新控制
|
*/
|
document.onkeydown = function (evt) {
|
//if (!getCurrentKeyCode) return;
|
var isie = ! -[1, ];
|
var key;
|
var srcobj;
|
if (isie) {
|
key = event.keyCode;
|
srcobj = event.srcElement;
|
}
|
else {
|
key = evt.which;
|
srcobj = evt.target;
|
}
|
evt = evt ? evt : event;
|
// var key = getCurrentKeyCode(evt);
|
// var srcobj = getFocusedElement(evt);
|
|
if (!srcobj.name && !srcobj.id || !srcobj.form) { return true; }
|
|
if (evt.ctrlKey && (key == 37 || key == 39)) {
|
var direction = key == 37 ? -1 : 1;
|
var el = getNextElement(srcobj, direction);
|
|
while (CheckInvisible(el, 'formelement'))
|
el = getNextElement(el, direction);
|
el.focus();
|
return false;
|
}
|
/*
|
限制允许回车的控件
|
*/
|
if (srcobj.type &&
|
',textarea,button,submit,reset,'.indexOf("," + srcobj.type + ",") > -1)
|
return true;
|
|
if (key == 13) {
|
|
var el = getNextElement(srcobj, 1);
|
while (CheckInvisible(el, 'formelement'))
|
el = getNextElement(el, 1);
|
|
el.focus();
|
return false;
|
|
|
} else;
|
|
|
}
|
|
|
|
|
$('.tableStyle input:text,input:password,input:checkbox,input:radio,input:file').keydown(function () { });
|
setTimeout(FocusFirst);
|
|
});
|
} else { }
|
|
|
|
|
//if (KeyBehaviorHook) {
|
// var dateHook = new KeyBehaviorHook('keydown', '.keydate');
|
// dateHook.Regist(window.Keys.Up, "");
|
// dateHook.Regist(window.Keys.Down, "");
|
// dateHook.Regist(window.Keys.Left, "");
|
// dateHook.Regist(window.Keys.Right, "e.target.select()");
|
//}
|
function ChangeUnit(direction) {
|
direction < 0;
|
}
|
$(function () {
|
//dateHook.Binding();
|
$('.keydate').focus(function (evt) {
|
|
window.dateput = {};
|
window.dateput.inputsetting = {};
|
window.dateput.inputsetting['0'] = 'txtTempYear';
|
window.dateput.inputsetting['1'] = 'txtTempMonth';
|
window.dateput.inputsetting['2'] = 'txtTempDay';
|
window.dateput.inputsetting['3'] = 'txtTempHours';
|
window.dateput.inputsetting['4'] = 'txtTempMinutes';
|
window.dateput.inputsetting['5'] = 'txtTempSeconds';
|
|
var dateresult = this.value.split(' ');
|
|
if (dateresult.length < 2) { dateresult[1] = ''; } else;
|
var datearray = dateresult[0].split('-');
|
|
if (datearray.length != 3) return; else;
|
var timearray = dateresult[1].split(':');
|
|
var tempDiv = document.createElement('span');
|
tempDiv.id = 'span_datepanel';
|
var tempdatehtml = '';
|
tempdatehtml += "<input class='txtTempDateBackground textinput' onfocus='this.blur();' />";
|
tempdatehtml += "<span id='spn_TempDate'>";
|
tempdatehtml += " <input id='txtTempYear' keepdefaultstyle='true' class='tempnum' maxlength='4' /><strong>-</strong>";
|
tempdatehtml += "<input id='txtTempMonth' keepdefaultstyle='true' class='tempnum' maxlength='2' /><strong>-</strong>";
|
tempdatehtml += "<input id='txtTempDay' keepdefaultstyle='true' class='tempnum' maxlength='2' />";
|
tempdatehtml += "</span>";
|
var isDateTime = 'datetime' == this.getAttribute('datetype');
|
if (isDateTime) {
|
tempdatehtml += "<span id='spn_TempTime'>";
|
tempdatehtml += "<input id='txtTempHours' keepdefaultstyle='true' class='tempnum' maxlength='2' /><strong>:</strong>";
|
tempdatehtml += "<input id='txtTempMinutes' keepdefaultstyle='true' class='tempnum' maxlength='2' /><strong>:</strong>";
|
tempdatehtml += "<input id='txtTempSeconds' keepdefaultstyle='true' class='tempnum' maxlength='2' />";
|
tempdatehtml += "</span>";
|
} else;
|
tempdatehtml += "</span>";
|
tempDiv.innerHTML = tempdatehtml;
|
this.parentNode.insertBefore(tempDiv, this);
|
$('#span_datepanel input').focus(function () { this.select(); });
|
|
for (var i in datearray) {
|
datearray[i] = datearray[i].length < 2 ? '0' + datearray[i] : datearray[i];
|
document.getElementById(window.dateput.inputsetting[i]).value = datearray[i];
|
}
|
|
var i = -1;
|
while (isDateTime && ++i < 3) {
|
|
timearray[i] = parseInt(timearray[i]);
|
timearray[i] = isNaN(timearray[i]) ? '00' : timearray[i] + '';
|
timearray[i] = timearray[i].length < 2 ? '0' + timearray[i] : timearray[i];
|
alert(timearray[i]);
|
document.getElementById(window.dateput.inputsetting[i + 3]).value = timearray[i];
|
}
|
|
setTimeout("document.getElementById('txtTempYear').focus();", 2);
|
this.style.visibility = 'hidden';
|
|
});
|
$('.keydate').blur(function () {
|
setTimeout("document.getElementById('" + this.id + "').style.visibility = 'hidden';", 1);
|
});
|
});
|
|
function ViewSellerInfo(Memberid) {
|
if (Memberid == "xxx") {
|
Memberid = $(".reloadView").attr("value_id");
|
}
|
showModalDialog("/seller/" + Memberid + ".html", null, 'dialogWidth:610px;dialogHeight:390px;status:no;');
|
}
|
|
function ViewBuyerInfo(Memberid) {
|
if (Memberid == "xxx") {
|
Memberid = $(".reloadView").attr("value_id");
|
}
|
showModalDialog("/buyer/" + Memberid + ".html", null, 'dialogWidth:610px;dialogHeight:390px;status:no;');
|
}
|
|
//四舍五入,保留2位小数
|
function Float2(x) {
|
// var re = /([0-9]+\.[0-9]{2})[0-9]*/;
|
// var newObj;
|
// newObj = obj.replace(re, "$1");
|
// return newObj;
|
//return Math.round(obj);
|
var f_x = parseFloat(x);
|
if (isNaN(f_x)) {
|
alertMsg('数据不是数字,请确认');
|
return false;
|
}
|
var f_x = Math.round(x * 100) / 100;
|
var s_x = f_x.toString();
|
var pos_decimal = s_x.indexOf('.');
|
if (pos_decimal < 0)
|
{ pos_decimal = s_x.length; s_x += '.'; }
|
while (s_x.length <= pos_decimal + 2) { s_x += '0'; }
|
return s_x;
|
}
|