|
|
|
|
(function(global){
|
|
|
|
|
|
|
|
|
|
var ER = {};
|
|
|
|
|
|
|
|
|
|
ER.Cache = {};
|
|
|
|
|
|
|
|
|
|
global.ER = ER;
|
|
|
|
|
|
|
|
|
|
ER.useVK = true;
|
|
|
|
|
|
|
|
|
|
ER.version = '1.0.0';
|
|
|
|
|
|
|
|
|
|
ER.host = 'http://127.0.0.1:8091';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建对象
|
|
|
|
|
var beget = function (o) {
|
|
|
|
|
var F = function () {
|
|
|
|
|
};
|
|
|
|
|
if (typeof o === 'object') {
|
|
|
|
|
F.prototype = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new F();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
global.PVLOADER = 0;
|
|
|
|
|
|
|
|
|
|
ER.loading = function (title, msg) {
|
|
|
|
|
// if (FDP.silent) return;
|
|
|
|
|
// if (PVLOADER > 0) return;
|
|
|
|
|
disableScroll();
|
|
|
|
|
global.PVLOADER++;
|
|
|
|
|
if (!$('.main-waiting').is(':visible')) {
|
|
|
|
|
$('.main-waiting').css('display', '-webkit-flex');
|
|
|
|
|
$('.main-waiting img').css({
|
|
|
|
|
'position': 'absolute',
|
|
|
|
|
'top': ((window.innerHeight / 2) + window.scrollY) + 'px',
|
|
|
|
|
'left': ((window.innerWidth / 2) - 64) + 'px'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ER.loaded = function () {
|
|
|
|
|
global.PVLOADER--;
|
|
|
|
|
enableScroll();
|
|
|
|
|
if (global.PVLOADER <= 0) {
|
|
|
|
|
$('.main-waiting').css('display', 'none');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var findSuper = function (obj, n, method) {
|
|
|
|
|
var index = obj.super.fn.length - n;
|
|
|
|
|
if (index < 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return obj.super.fn[index][method];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
global.inherits = function (subType, superType) {
|
|
|
|
|
if (subType) {
|
|
|
|
|
var prototype = beget(superType.prototype);
|
|
|
|
|
prototype.constructor = subType;
|
|
|
|
|
subType.prototype = prototype;
|
|
|
|
|
if (subType.prototype.super) {
|
|
|
|
|
if (!subType.prototype.super.fn) {
|
|
|
|
|
console.log(new Error('super error invalid super'));
|
|
|
|
|
}
|
|
|
|
|
subType.prototype.super.fn.push(superType.prototype);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
var superCall = {};
|
|
|
|
|
subType.prototype.super = function (method) {
|
|
|
|
|
if (superCall.hasOwnProperty(method)) {
|
|
|
|
|
superCall[method]++;
|
|
|
|
|
} else {
|
|
|
|
|
superCall[method] = 1;
|
|
|
|
|
}
|
|
|
|
|
var n = superCall[method];
|
|
|
|
|
var f = findSuper(this, n, method);
|
|
|
|
|
if (!f) throw new Error('super error no method');
|
|
|
|
|
|
|
|
|
|
var slice = Array.prototype.slice;
|
|
|
|
|
var args = slice.call(arguments, 1)
|
|
|
|
|
try {
|
|
|
|
|
return f.apply(this, args);
|
|
|
|
|
} finally {
|
|
|
|
|
superCall[method] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
subType.prototype.super.fn = [superType.prototype]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var createGuid = global.createGuid = function() {
|
|
|
|
|
// 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
|
|
|
// var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
|
|
|
|
// return v.toString(16);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
function S4() {
|
|
|
|
|
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
|
|
|
|
|
}
|
|
|
|
|
return (S4() + S4() + "-" + S4() + "-4" + S4().substr(0,3) + "-" + S4() + "-" + S4() + S4() + S4()).toLowerCase();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global.getParameterByName = function(name, url) {
|
|
|
|
|
if (!url) {
|
|
|
|
|
url = window.location.href;
|
|
|
|
|
}
|
|
|
|
|
name = name.replace(/[\[\]]/g, "\\$&");
|
|
|
|
|
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
|
|
|
|
results = regex.exec(url);
|
|
|
|
|
if (!results) return null;
|
|
|
|
|
if (!results[2]) return '';
|
|
|
|
|
return decodeURIComponent(results[2]);
|
|
|
|
|
// return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
global.REPORT = {};
|
|
|
|
|
|
|
|
|
|
ER.bindVKEvents = function(el) {
|
|
|
|
|
// el.removeEventListener('focus')
|
|
|
|
|
el.addEventListener('focus', function() {
|
|
|
|
|
openVK(el);
|
|
|
|
|
});
|
|
|
|
|
el.addEventListener('blur', function(e) {
|
|
|
|
|
closeVK(e);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ER.print = function(funcCode, serialNo, mod, printData, variables) {
|
|
|
|
|
var params = {
|
|
|
|
|
funcCode: funcCode || '*',
|
|
|
|
|
serialNo: serialNo,
|
|
|
|
|
mode: mod, //0-打印,1-预览,2-设计
|
|
|
|
|
printData: printData,
|
|
|
|
|
variables: variables,
|
|
|
|
|
token: FDP.logOn.token,
|
|
|
|
|
host: FDP.host
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (window.FdpExt && window.FdpExt.DoPlugin) {
|
|
|
|
|
window.FdpExt.DoPlugin('PrintPlugin', 'FastPrint', JSON.stringify(params));
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (window.qt) {
|
|
|
|
|
new QWebChannel(qt.webChannelTransport, function(channel) {
|
|
|
|
|
// make dialog object accessible globally
|
|
|
|
|
var report = channel.objects.report;
|
|
|
|
|
report.doPrint(JSON.stringify(params));
|
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
console.log(params);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//关闭键盘
|
|
|
|
|
global.closeVK = function(e) {
|
|
|
|
|
if (!ER.useVK) return;
|
|
|
|
|
if(ER.Cache.showVitalKeybord === '0') return;
|
|
|
|
|
|
|
|
|
|
ER.VK.closeVK(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
global.openVK = function(data, args) {
|
|
|
|
|
if (!ER.useVK) return;
|
|
|
|
|
if(ER.Cache.showVitalKeybord === '0') return;
|
|
|
|
|
|
|
|
|
|
ER.VK.openVK(data, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Number.prototype.add = function(value) {
|
|
|
|
|
var arg1 = this,
|
|
|
|
|
arg2 = value;
|
|
|
|
|
|
|
|
|
|
var r1, r2, m;
|
|
|
|
|
try {
|
|
|
|
|
r1 = arg1.toString().split(".")[1].length;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
r1 = 0;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
r2 = arg2.toString().split(".")[1].length;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
r2 = 0;
|
|
|
|
|
}
|
|
|
|
|
m = Math.pow(10, Math.max(r1, r2));
|
|
|
|
|
arg1 = Math.round(arg1 * m);
|
|
|
|
|
arg2 = Math.round(arg2 * m);
|
|
|
|
|
return (arg1 + arg2) / m;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function preventDefault(e) {
|
|
|
|
|
e = e || window.event;
|
|
|
|
|
if (e.preventDefault)
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.returnValue = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function preventDefaultForScrollKeys(e) {
|
|
|
|
|
var keys = {37: 1, 38: 1, 39: 1, 40: 1};
|
|
|
|
|
if (keys[e.keyCode]) {
|
|
|
|
|
preventDefault(e);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function disableScroll() {
|
|
|
|
|
if (window.addEventListener) // older FF
|
|
|
|
|
window.addEventListener('DOMMouseScroll', preventDefault, false);
|
|
|
|
|
window.onwheel = preventDefault; // modern standard
|
|
|
|
|
window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
|
|
|
|
|
window.ontouchmove = preventDefault; // mobile
|
|
|
|
|
document.onkeydown = preventDefaultForScrollKeys;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function enableScroll() {
|
|
|
|
|
if (window.removeEventListener)
|
|
|
|
|
window.removeEventListener('DOMMouseScroll', preventDefault, false);
|
|
|
|
|
window.onmousewheel = document.onmousewheel = null;
|
|
|
|
|
window.onwheel = null;
|
|
|
|
|
window.ontouchmove = null;
|
|
|
|
|
document.onkeydown = null;
|
|
|
|
|
}
|
|
|
|
|
})(window)
|