309 lines
8.9 KiB
JavaScript
309 lines
8.9 KiB
JavaScript
|
|
//屏蔽浏览器右键
|
|||
|
|
//$(function () {
|
|||
|
|
// $(document).bind('contextmenu', function (e) {
|
|||
|
|
// return false;
|
|||
|
|
// });
|
|||
|
|
//});
|
|||
|
|
$.cetc54 = {
|
|||
|
|
officeKey: "CETC54"
|
|||
|
|
};
|
|||
|
|
$.fn.uiOfficeControl.defaults = $.extend($.fn.uiOfficeControl.defaults, {
|
|||
|
|
classid: '6AA93C0B-D450-4a80-876E-3909055B0640',
|
|||
|
|
makerCaption: '中国电子科技集团公司第五十四研究所',
|
|||
|
|
makerKey: 'B441164A78B3CA7F2D4C7F2706617EDAE267C0CC',
|
|||
|
|
productCaption: 'JAVA快速开发平台',
|
|||
|
|
productKey: '2592FF2524683EFF9F624D8A21E949E3F6C49C7A',
|
|||
|
|
cabVersion: '5,0,2,8'
|
|||
|
|
});
|
|||
|
|
//$.fn.uiValidate.defaults = $.extend($.fn.uiValidate.defaults, {
|
|||
|
|
// tipPosition: 'bottom',
|
|||
|
|
// tipOffset: [0, 0]
|
|||
|
|
//});
|
|||
|
|
//$.fn.uiCombo.defaults = $.extend($.fn.uiCombo.defaults, {
|
|||
|
|
// delay: 500
|
|||
|
|
//});
|
|||
|
|
$.fn.uiGrid.defaults = $.extend($.fn.uiGrid.defaults, {
|
|||
|
|
autoFit: true,
|
|||
|
|
border: false,
|
|||
|
|
colFit: true,
|
|||
|
|
colFitAllTime: false,
|
|||
|
|
gridTitleFix: true,
|
|||
|
|
showCellTip: false,
|
|||
|
|
showHeader: false,
|
|||
|
|
icon: 'list'
|
|||
|
|
});
|
|||
|
|
$.fn.uiPanel.defaults = $.extend({},$.fn.uiPanel.defaults, {
|
|||
|
|
/**
|
|||
|
|
* @type Boolean
|
|||
|
|
* @default false
|
|||
|
|
* @summary true时,页面需要引用animate.css
|
|||
|
|
*/
|
|||
|
|
animate:true,
|
|||
|
|
/**
|
|||
|
|
* @type String
|
|||
|
|
* @default ""
|
|||
|
|
* @summary 打开时的动画样式名称
|
|||
|
|
*/
|
|||
|
|
animateOpen:'fadeIn',
|
|||
|
|
/**
|
|||
|
|
* @type String
|
|||
|
|
* @default ""
|
|||
|
|
* @summary 关闭时的动画样式名称
|
|||
|
|
*/
|
|||
|
|
animateClose:'fadeOut'
|
|||
|
|
});
|
|||
|
|
$.fn.uiDialog.defaults = $.extend($.fn.uiDialog.defaults, {
|
|||
|
|
icon: 'list',
|
|||
|
|
width: '80%',
|
|||
|
|
height: '80%',
|
|||
|
|
mask: true,
|
|||
|
|
maskContainer: $(document.body),
|
|||
|
|
showBtnBar: true,
|
|||
|
|
lazyLoad: true
|
|||
|
|
});
|
|||
|
|
/**
|
|||
|
|
* 扩展验证方法
|
|||
|
|
* @type {*|Object|void|vjs.CoreObject}
|
|||
|
|
*/
|
|||
|
|
$.fn.uiValidate.defaults.rules = $.extend({}, $.fn.uiValidate.defaults.rules, {
|
|||
|
|
idCard: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
//身份证正则表达式(15位)
|
|||
|
|
isIDCard1 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
|
|||
|
|
//身份证正则表达式(18位)
|
|||
|
|
isIDCard2 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}[0-9xX]$/;
|
|||
|
|
return (isIDCard1.test(val) || isIDCard2.test(val));
|
|||
|
|
}, message: '请输入15位或18位身份证号!'
|
|||
|
|
},
|
|||
|
|
postcode: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
//邮政编码正则表达式
|
|||
|
|
isPostcode = /^\d{6}$/;
|
|||
|
|
return isPostcode.test(val);
|
|||
|
|
}, message: '请输入正确的邮政编码格式!'
|
|||
|
|
},
|
|||
|
|
number: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
//数字判断包含小数
|
|||
|
|
return !isNaN(val);
|
|||
|
|
}, message: '请输入数字!'
|
|||
|
|
},
|
|||
|
|
integer_p: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
var reg = /^[+]?\d*$/;
|
|||
|
|
return reg.test(val);
|
|||
|
|
}, message: '请输入正整数!'
|
|||
|
|
},
|
|||
|
|
english: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
//数字判断包含小数
|
|||
|
|
return $.regexs.english.test(val);
|
|||
|
|
}, message: '请输入字母A~Z'
|
|||
|
|
},
|
|||
|
|
AboveAndEqualZero: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
isAboveAndEqualZero = /^([1-9]\d*|0)\.\d*$|^0\.\d*[1-9]\d*$|^([1-9]\d*|0)$/;
|
|||
|
|
return isAboveAndEqualZero.test(val);
|
|||
|
|
}, message: '请输入大于等于0的数'
|
|||
|
|
},
|
|||
|
|
positiveNumber: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
isPositiveNumber = /^[1-9]\d*\.\d*$|^0\.\d*[1-9]\d*$|^[1-9]\d*$/;
|
|||
|
|
return isPositiveNumber.test(val);
|
|||
|
|
}, message: '请输入正数'
|
|||
|
|
},
|
|||
|
|
positiveInteger: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
isPositiveInteger = /^[1-9]\d*$/;
|
|||
|
|
return isPositiveInteger.test(val);
|
|||
|
|
}, message: '请输入正整数'
|
|||
|
|
},
|
|||
|
|
monthNum: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
isMonthNum = /^([1-9]|1[0-2])$/;
|
|||
|
|
return isMonthNum.test(val);
|
|||
|
|
}, message: '请输入每年正确的工作时间(1-12)'
|
|||
|
|
},
|
|||
|
|
moreThanFive: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
moreThanFive = /^[5-9]\d(\.\d+)?$/;
|
|||
|
|
return moreThanFive.test(val);
|
|||
|
|
}, message: '请输入大于5的正数'
|
|||
|
|
},
|
|||
|
|
pointNum: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
// isPointNum = /^[0-9]+(.[0-9]{0,6})?$/;
|
|||
|
|
isPointNum = /^\d+(\.\d{0,2})?$/
|
|||
|
|
return isPointNum.test(val);
|
|||
|
|
}, message: '请输入不多于两位小数的正数或正整数'
|
|||
|
|
},
|
|||
|
|
Email: {
|
|||
|
|
validator: function (val) {
|
|||
|
|
isEmail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
|
|||
|
|
return isEmail.test(val);
|
|||
|
|
}, message: '请输入正确的电子邮件编码格式'
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 数据字典路径
|
|||
|
|
* @type {string}
|
|||
|
|
*/
|
|||
|
|
var dictBaseUrl = $('#hdWebroot').val() + '/dict/dict/getDictList?dictKey=';
|
|||
|
|
/**
|
|||
|
|
* 数据字典缓存hd前缀
|
|||
|
|
* @type {string}
|
|||
|
|
*/
|
|||
|
|
var dict_prefix = 'hdDict_';
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 日期转换
|
|||
|
|
*/
|
|||
|
|
template.helper('dateTimeFilter', function (value) {
|
|||
|
|
var d = new Date(value);
|
|||
|
|
return d == "Invalid Date" ? "" : d.format("yyyy-MM-dd hh:mm:ss");
|
|||
|
|
});
|
|||
|
|
/**
|
|||
|
|
* 日期转换
|
|||
|
|
*/
|
|||
|
|
template.helper('dateFilter', function (value) {
|
|||
|
|
var d = new Date(value);
|
|||
|
|
return d == "Invalid Date" ? "" : d.format("yyyy-MM-dd");
|
|||
|
|
});
|
|||
|
|
template.helper('customDateFilter', function (value) {
|
|||
|
|
return getCustomTime(value);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
template.helper('istrueFilter', function (value) {
|
|||
|
|
return gridColFilter('istrue', value);
|
|||
|
|
});
|
|||
|
|
template.helper('isenableFilter', function (value) {
|
|||
|
|
return gridColFilter('isenable', value);
|
|||
|
|
});
|
|||
|
|
template.helper('sexFilter', function (value) {
|
|||
|
|
return gridColFilter('sex', value);
|
|||
|
|
});
|
|||
|
|
/**
|
|||
|
|
* 数据表格列带数据字典的转换
|
|||
|
|
* @param dictKey 字典Key
|
|||
|
|
* @param value 列值
|
|||
|
|
* @returns {*}
|
|||
|
|
*/
|
|||
|
|
function gridColFilter(dictKey, value) {
|
|||
|
|
var hdName = dict_prefix + dictKey;
|
|||
|
|
var res;
|
|||
|
|
if (window[hdName]) {
|
|||
|
|
res = window[hdName];
|
|||
|
|
} else {
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
async: false,
|
|||
|
|
url: dictBaseUrl + dictKey,
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (result) {
|
|||
|
|
if (result.success) {
|
|||
|
|
window[hdName] = result.data;
|
|||
|
|
res = result.data;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
return findValue(res, value);
|
|||
|
|
|
|||
|
|
function findValue(data, value) {
|
|||
|
|
var res = value;
|
|||
|
|
if (data != null) {
|
|||
|
|
for (var i = 0; i < data.length; i++) {
|
|||
|
|
var item = data[i];
|
|||
|
|
if (item.value == value) {
|
|||
|
|
res = item.name;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return res;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 获取当前日期
|
|||
|
|
* @returns {string}
|
|||
|
|
*/
|
|||
|
|
function getDateNow(dateSp) {
|
|||
|
|
dateSp = dateSp || '-';
|
|||
|
|
var date = new Date();
|
|||
|
|
return dat.format("yyyy" + dateSp + "MM" + dateSp + "dd");
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 获取当前时间(日期和时间)
|
|||
|
|
* @param dateSp 日期分隔符
|
|||
|
|
* @param timeSp 时间分隔符
|
|||
|
|
* @param sp 日期和时间之间的分隔符
|
|||
|
|
* @param withMs 是否带毫秒 true带毫秒
|
|||
|
|
*/
|
|||
|
|
function getDateAndTime(dateSp, timeSp, sp, withMs) {
|
|||
|
|
if (dateSp == undefined) {
|
|||
|
|
dateSp = '-';
|
|||
|
|
}
|
|||
|
|
if (timeSp == undefined) {
|
|||
|
|
timeSp = ':';
|
|||
|
|
}
|
|||
|
|
if (sp == undefined) {
|
|||
|
|
sp = ' ';
|
|||
|
|
}
|
|||
|
|
var format = "yyyy" + dateSp + "MM" + dateSp + "dd" + sp + "hh" + timeSp + "mm" + timeSp + "ss";
|
|||
|
|
|
|||
|
|
if (withMs) {
|
|||
|
|
format += timeSp + "S";
|
|||
|
|
}
|
|||
|
|
var date = new Date();
|
|||
|
|
return date.format(format);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getCustomTime(date) {
|
|||
|
|
var tempTime;
|
|||
|
|
var dateTime1 = new Date();;
|
|||
|
|
var dateTime2 =new Date(date);
|
|||
|
|
if (dateTime1.getFullYear() == dateTime2.getFullYear()) {
|
|||
|
|
if (dateTime1.getMonth() == dateTime2.getMonth()) {
|
|||
|
|
if (dateTime1.getDay() == dateTime2.getDay()) {
|
|||
|
|
tempTime = dateTime2.format("hh:mm");
|
|||
|
|
} else {
|
|||
|
|
if (dateTime1.getDay() - dateTime2.getDay() == 1) {
|
|||
|
|
tempTime = dateTime2.format("昨天 hh:mm");
|
|||
|
|
} else {
|
|||
|
|
tempTime = dateTime2.format("M-dd hh:mm");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else
|
|||
|
|
tempTime = dateTime2.format("M-dd hh:mm");
|
|||
|
|
} else {
|
|||
|
|
tempTime = dateTime2.format("yyyy-M-dd");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return tempTime;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function showErrorContent(container, content, width, height) {
|
|||
|
|
var html = $('<div id="div_error"></div>');
|
|||
|
|
container.html(html);
|
|||
|
|
html.uiPanel({
|
|||
|
|
panelStyle: 'ui_panel_danger',
|
|||
|
|
title: '提示',
|
|||
|
|
content: '<div style="padding: 5px;">' + content + '</div>',
|
|||
|
|
width: width,
|
|||
|
|
height: height
|
|||
|
|
});
|
|||
|
|
html.uiPosition({
|
|||
|
|
vertical: 'center',
|
|||
|
|
horizontal: 'center'
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
$(document).unbind(".shortcut").bind("mousedown.shortcut", function (e) {
|
|||
|
|
var target= $(e.target).closest(".shortcut");
|
|||
|
|
try {
|
|||
|
|
var shortcut = top.$('#shortcut');
|
|||
|
|
if (target.length == 0 && shortcut && shortcut.hasClass("fadeInDown")) {
|
|||
|
|
shortcut.removeClass('fadeInDown').addClass('slideOutUp fast');
|
|||
|
|
}
|
|||
|
|
}catch(e){}
|
|||
|
|
});
|