|
@@ -0,0 +1,627 @@
|
|
|
+//该文件将可能用于多种浏览器,或是多种前段开发框架的BS系统。编写代码时,请注意以下事项:
|
|
|
+//定义函数参数时,不要给默认值,需在函数体能判断参数是否存在,不存在需赋初始值。
|
|
|
+var MLRKON_CLIENT = window.MLRKON_CLIENT || (function(){
|
|
|
+ var mlrkon_embed = {
|
|
|
+ // 如果从MINDS动态加载本文件,则"无需"修改此变量(MINDS_HOST)值!
|
|
|
+ // 如果是静态加载,则将此变量修改为MINDS服务主机和端口。如:http://192.168.1.100:8080
|
|
|
+ // proxy : 'MINDS_HOST',
|
|
|
+ proxy : 'http://130.150.161.153:8080',
|
|
|
+ html : '',
|
|
|
+ api : false,
|
|
|
+ dMap : {},
|
|
|
+ command:'',
|
|
|
+ input: '',
|
|
|
+ options: '',
|
|
|
+ callback: null,
|
|
|
+ floatNum : null
|
|
|
+ };
|
|
|
+ var zIndex = 30000
|
|
|
+ var locked = false
|
|
|
+
|
|
|
+ /*function loadScript(url, callback) {
|
|
|
+ var script = document.createElement("script");
|
|
|
+ script.type = "text/javascript";
|
|
|
+
|
|
|
+ script.src = url;
|
|
|
+ if (typeof(callback) != "undefined") {
|
|
|
+ script.onload = script.onreadystatechange = function() {
|
|
|
+ if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
|
|
|
+ callback();
|
|
|
+ script.onload = script.onreadystatechange = null;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ };
|
|
|
+ document.body.appendChild(script);
|
|
|
+ }*/
|
|
|
+ function loadScript(url, callback) {
|
|
|
+ var script = document.createElement("script");
|
|
|
+ script.type = "text/javascript";
|
|
|
+ if (typeof(callback) != "undefined") {
|
|
|
+ if (script.readyState) {
|
|
|
+ script.onreadystatechange = function() {
|
|
|
+ if (script.readyState == "loaded" || script.readyState == "complete") {
|
|
|
+ script.onreadystatechange = null;
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ script.onload = function() {
|
|
|
+ callback();
|
|
|
+ };
|
|
|
+ }
|
|
|
+ };
|
|
|
+ script.src = url;
|
|
|
+ document.body.appendChild(script);
|
|
|
+ }
|
|
|
+
|
|
|
+ function createDialogDiv(ctrl){
|
|
|
+ var hostIp = window.location.host;
|
|
|
+ var protocol = window.location.protocol;
|
|
|
+ var src = mlrkon_embed.proxy + '/api/web_embed.html?X-MA-Timeout=-1&X-MA-KeepSession=true&userIp=' + hostIp
|
|
|
+
|
|
|
+ var div = document.createElement('div');
|
|
|
+ div.id ='_MLRKON_DIV_' + ctrl.num;
|
|
|
+ //div.style.display = 'none';
|
|
|
+ div.style.overflow = 'hidden';
|
|
|
+ div.style.padding = '0px';
|
|
|
+
|
|
|
+ var iframe = document.createElement('iframe');
|
|
|
+ iframe.id = "_MLRKON_IFRAME_" + ctrl.num;
|
|
|
+ //iframe.style = "width:100%; height:100%; margin:0px; padding:0px; border:none; ";
|
|
|
+
|
|
|
+ iframe.style.width = '100%';
|
|
|
+ iframe.style.height = '100%';
|
|
|
+ iframe.style.margin = '0px';
|
|
|
+ iframe.style.padding = '0px';
|
|
|
+ iframe.style.border = 'none';
|
|
|
+
|
|
|
+ iframe.scrolling = 'no';
|
|
|
+
|
|
|
+ if (ctrl.url){
|
|
|
+ iframe.src = ctrl.url;
|
|
|
+ } else {
|
|
|
+ iframe.src = src;
|
|
|
+ iframe.src += '&protocol=' + protocol + '&num=' + ctrl.num ;
|
|
|
+ if (ctrl.pnum) iframe.src += '&pnum=' + ctrl.pnum
|
|
|
+ }
|
|
|
+
|
|
|
+ document.body.appendChild(div);
|
|
|
+ document.getElementById('_MLRKON_DIV_' + ctrl.num).appendChild(iframe);
|
|
|
+ mlrkon_embed.dMap[ctrl.num].div = div;
|
|
|
+ mlrkon_embed.dMap[ctrl.num].iframe = iframe;
|
|
|
+ }
|
|
|
+
|
|
|
+ function createPostMessageFrame(){
|
|
|
+ var hostIp = window.location.host;
|
|
|
+ var protocol = window.location.protocol;
|
|
|
+
|
|
|
+ if (document.getElementById('_MLRKON_IFRAME') == undefined){
|
|
|
+
|
|
|
+ var iframe = document.createElement('iframe');
|
|
|
+ iframe.id = "_MLRKON_IFRAME";
|
|
|
+ iframe.style.display = 'none';
|
|
|
+ iframe.src = mlrkon_embed.proxy + '/api/web_embed.html?X-MA-Timeout=-1&X-MA-KeepSession=true&userIp='+hostIp+'&protocol='+protocol;
|
|
|
+ document.body.appendChild(iframe);
|
|
|
+
|
|
|
+ mlrkon_embed.sIframe = iframe;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function createInitDiv(ctrl){
|
|
|
+
|
|
|
+ if (document.getElementById('_MLRKON_LOGO_DIV') == undefined){
|
|
|
+ ctrl.image = (ctrl.image != 'NaN' && ctrl.image != '') ? ctrl.image : '/images/nest/sda.png';
|
|
|
+
|
|
|
+ var css = "position:absolute; width: 64px; height: 64px; right: 10px; top: 10px;z-index: 1000;";
|
|
|
+ css += " background : transparent; background-image: url(" + mlrkon_embed.proxy;
|
|
|
+ css += ctrl.image + '); background-repeat: no-repeat;';
|
|
|
+ css += ' background-size: cover; padding: 0px; ';
|
|
|
+ css += " filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + mlrkon_embed.proxy;
|
|
|
+ css += ctrl.image + ",sizingMethod='scale'); ";
|
|
|
+
|
|
|
+ var gdiv = document.createElement('div');
|
|
|
+ gdiv.id ='_MLRKON_LOGO_DIV';
|
|
|
+ gdiv.style = css;
|
|
|
+ /*
|
|
|
+ gdiv.style.position = 'absolute';
|
|
|
+ gdiv.style.right = '10px';
|
|
|
+ gdiv.style.top = '10px';
|
|
|
+ gdiv.style.width = '60px';//ctrl.width < 1 ? ctrl.width * $(window).width() : (ctrl.width ? ctrl.width : 64);
|
|
|
+ gdiv.style.height = '60px';//ctrl.height < 1 ? ctrl.height * $(window).height() : (ctrl.height ? ctrl.height : 64);
|
|
|
+
|
|
|
+ try{
|
|
|
+ gdiv.style.background = 'transparent url(' + mlrkon_embed.proxy + ctrl.image + ') no-repeat cover ';
|
|
|
+ }catch (e) {
|
|
|
+ console.log("IE8兼容问题请忽略",e)
|
|
|
+ }
|
|
|
+ gdiv.style.padding = '0px';
|
|
|
+ try{
|
|
|
+ gdiv.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + mlrkon_embed.proxy + ctrl.image + ",sizingMethod='scale')";
|
|
|
+
|
|
|
+ }catch (e) {
|
|
|
+ console.log("IE8以上兼容问题请忽略",e)
|
|
|
+ }
|
|
|
+ */
|
|
|
+ document.body.appendChild(gdiv);
|
|
|
+
|
|
|
+ mlrkon_embed.ctrl = ctrl;
|
|
|
+ mlrkon_embed.gDiv = gdiv;
|
|
|
+
|
|
|
+ jMLRK("#_MLRKON_LOGO_DIV").draggable().on('click',function(){
|
|
|
+ var dialog = mlrkon_embed.dMap[mlrkon_embed.floatNum];
|
|
|
+
|
|
|
+ if (dialog.dialog != undefined){
|
|
|
+ dialog.dialog.dialog("open");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ showFlatDialog(ctrl);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ function dealResult(data){
|
|
|
+ // york start
|
|
|
+ if (mlrkon_embed.timer == 2) { return }
|
|
|
+ // york end
|
|
|
+ var ctrl = JSON.parse(data);
|
|
|
+ if (ctrl._tag != 'MLRKON') return;
|
|
|
+ //york start
|
|
|
+ mlrkon_embed.timer = 1
|
|
|
+ //york end
|
|
|
+ var dialog = mlrkon_embed.dMap[ctrl.num];
|
|
|
+ if (ctrl.status != 'ok'){
|
|
|
+ if (dialog != undefined)
|
|
|
+ _callBack(dialog.callback, {bSave: true, orderIds: []});
|
|
|
+ else
|
|
|
+ // york start
|
|
|
+ _callBack(mlrkon_embed.callback,{bSave: true, orderIds: []} )
|
|
|
+ //york end
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch(ctrl.cmd){
|
|
|
+ case 'load_over':
|
|
|
+ mlrkon_embed._init_ = true
|
|
|
+ if (dialog && dialog.html != '' && dialog.html != undefined){
|
|
|
+ var arg = {
|
|
|
+ cmd : 'show_html',
|
|
|
+ input : dialog.html,
|
|
|
+ opts : null,
|
|
|
+ callback: dialog.callback,
|
|
|
+ num : ctrl.num
|
|
|
+ }
|
|
|
+ postMessage(arg, dialog.iframe);
|
|
|
+ //dialog.html = '';
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'close_dialog':
|
|
|
+ if (dialog === undefined || dialog == null || !dialog) return;
|
|
|
+ if (ctrl.orderIds) dialog.orderIds = ctrl.orderIds;
|
|
|
+ if (ctrl.bSave || ctrl.bSave === false){
|
|
|
+ dialog.bSave = ctrl.bSave;
|
|
|
+ }else{
|
|
|
+ dialog.bSave = true
|
|
|
+ } //by GP
|
|
|
+ if (ctrl.insurOrders) dialog.insurOrders=ctrl.insurOrders; //传参2
|
|
|
+
|
|
|
+ if(dialog.dialog == undefined || dialog.dialog == null){
|
|
|
+ if (ctrl.insurOrders){
|
|
|
+ _callBack(dialog.callback, {bSave: dialog.bSave, orderIds: dialog.orderIds,insurOrders:ctrl.insurOrders});
|
|
|
+ }else{
|
|
|
+ _callBack(dialog.callback, {bSave: dialog.bSave, orderIds: dialog.orderIds});
|
|
|
+ }
|
|
|
+ jMLRK("#"+dialog.div.id).parent().remove()
|
|
|
+ }else{
|
|
|
+ dialog.dialog.dialog("close");
|
|
|
+ }
|
|
|
+ if (ctrl.pnum){
|
|
|
+ dialog = mlrkon_embed.dMap[ctrl.pnum];
|
|
|
+ postMessage(ctrl, dialog.iframe);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'close_dialog_srv_screen':
|
|
|
+ if (dialog === undefined || dialog == null || !dialog) return;
|
|
|
+
|
|
|
+ if(dialog.dialog == undefined || dialog.dialog == null){
|
|
|
+ if (ctrl.insurOrders){
|
|
|
+ _callBack(dialog.callback, {bSave: dialog.bSave, orderIds: dialog.orderIds,insurOrders:ctrl.insurOrders});
|
|
|
+ }else{
|
|
|
+ _callBack(dialog.callback, {bSave: dialog.bSave, orderIds: dialog.orderIds});
|
|
|
+ }
|
|
|
+ jMLRK("#"+dialog.div.id).parent().remove()
|
|
|
+ } else {
|
|
|
+ dialog.dialog.dialog("close");
|
|
|
+
|
|
|
+ var url = mlrkon_embed.proxy + '/api/srv_screen.html?X-MA-KeepSession=true&format=json';
|
|
|
+ url += '&caseId=' + ctrl.caseId;
|
|
|
+ url += '&doFinal=' + ctrl.doFinal;
|
|
|
+ url += '&aimValue=' + ctrl.aimValue;
|
|
|
+ _doCall('srv_screen', mlrkon_embed.input, mlrkon_embed.options, mlrkon_embed.callback, url);
|
|
|
+ }
|
|
|
+ break
|
|
|
+ case 'sys_init' :
|
|
|
+ var a = dialog
|
|
|
+ if (mlrkon_embed.api) {
|
|
|
+ _callBack(dialog.callback, ctrl);
|
|
|
+ } else {
|
|
|
+ mlrkon_embed.caseId = ctrl.caseId;
|
|
|
+ createInitDiv(ctrl);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'show_message_dialog':
|
|
|
+ ctrl.callback = function(p){
|
|
|
+ var dialog = mlrkon_embed.dMap[mlrkon_embed.floatNum];
|
|
|
+ var params = {
|
|
|
+ cmd: 'close_message_dialog',
|
|
|
+ mids: p.mids,
|
|
|
+ urls: p.urls
|
|
|
+ }
|
|
|
+ postMessage(params, dialog.iframe);
|
|
|
+ };
|
|
|
+ mlrkon_embed.showDialog(ctrl);
|
|
|
+ break;
|
|
|
+ case 'show_dialog':
|
|
|
+ if (mlrkon_embed.api)
|
|
|
+ _callBack(dialog.callback, ctrl);
|
|
|
+ else
|
|
|
+ mlrkon_embed.showDialog(ctrl);
|
|
|
+ break;
|
|
|
+ case 'open_link':
|
|
|
+ var url = mlrkon_embed.proxy + ctrl.url;
|
|
|
+ if (ctrl.isExter == '1'){
|
|
|
+ window.open(ctrl.url,'_blank');
|
|
|
+ } else {
|
|
|
+ ctrl.url = url;
|
|
|
+ mlrkon_embed.showDialog(ctrl);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ function _callBack(fun, args) {
|
|
|
+ if (fun === undefined || fun == null || fun == '') return;
|
|
|
+ if (jMLRK.isFunction(fun)) {
|
|
|
+ fun(args);
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ eval(fun + "('" + stat + "')");
|
|
|
+ } catch (ex) {
|
|
|
+ alert('回调函数"' + fun + '"没有定义。')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ function showFlatDialog(ctrl){
|
|
|
+
|
|
|
+ createDialogDiv(ctrl);
|
|
|
+
|
|
|
+ mlrkon_embed.floatNum = ctrl.num;
|
|
|
+
|
|
|
+ var dialog = mlrkon_embed.dMap[ctrl.num];
|
|
|
+ dialog.html = ctrl.html;
|
|
|
+
|
|
|
+ var pos = ctrl.flat_position ? ctrl.flat_position.toLowerCase() + " top" : "right top";
|
|
|
+ var w = ctrl.flat_width < 1 ? ctrl.flat_width * jMLRK(window).width() : (ctrl.flat_width ? ctrl.flat_width : 300);
|
|
|
+ var h = ctrl.flat_height < 1 ? ctrl.flat_height * jMLRK(window).height() : (ctrl.flat_height ? ctrl.flat_height : 210);
|
|
|
+
|
|
|
+ dialog.dialog = jMLRK(dialog.div).dialog({
|
|
|
+ title: ctrl.flat_title ? ctrl.flat_title : '我的平台',
|
|
|
+ autoOpen: false,
|
|
|
+ height: h < 210 ? 210 : h,
|
|
|
+ width: w < 400 ? 400 : w,
|
|
|
+ position: {my: pos, at: pos, of: document},
|
|
|
+ modal: false
|
|
|
+ });
|
|
|
+ //jMLRK("#"+dialog.div.id).parent().css('z-index',zIndex--);//在初始化先打开工作台 后监控弹框的时候 遮罩层层级会高于监控弹框无法关闭
|
|
|
+ //20240426
|
|
|
+ jMLRK("#"+dialog.div.id).parent().css('z-index',2999);//初始化调用层级需要小于遮罩层层级 遮罩层默认2999 会始终小于监控3000++的层级
|
|
|
+ };
|
|
|
+
|
|
|
+ mlrkon_embed.showDialog = function(ctrl){
|
|
|
+ if (ctrl.html == '' && !ctrl.url) return;
|
|
|
+
|
|
|
+ if (!ctrl.num) {
|
|
|
+ ctrl.num = Math.ceil(Math.random()*100);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!mlrkon_embed.dMap[ctrl.num])
|
|
|
+ mlrkon_embed.dMap[ctrl.num] = {num : ctrl.num};
|
|
|
+
|
|
|
+ mlrkon_embed.dMap[ctrl.num].bcmd = ctrl.bcmd;
|
|
|
+
|
|
|
+ createDialogDiv(ctrl);
|
|
|
+
|
|
|
+ var dialog = mlrkon_embed.dMap[ctrl.num];
|
|
|
+ if (dialog.dialog != undefined)
|
|
|
+ dialog.dialog.dialog("close");
|
|
|
+
|
|
|
+ if (ctrl.hasTimer){
|
|
|
+ clearInterval(dialog.timer_ctrl);
|
|
|
+
|
|
|
+ dialog.timerCount = ctrl.timerCount;
|
|
|
+ dialog.timeCount = ctrl.timerCount;
|
|
|
+ dialog.hasTimer = ctrl.hasTimer;
|
|
|
+ }
|
|
|
+
|
|
|
+ var pos = ctrl.position ? ctrl.position.toLowerCase() + " top" : "center top";
|
|
|
+ var w = ctrl.width < 1 ? ctrl.width * jMLRK(window).width() : (ctrl.width ? ctrl.width : 900);
|
|
|
+ var h = ctrl.height < 1 ? ctrl.height * jMLRK(window).height() : (ctrl.height ? ctrl.height : 500);
|
|
|
+
|
|
|
+ dialog.html = ctrl.html;
|
|
|
+ dialog.title = ctrl.title ;
|
|
|
+
|
|
|
+ var config = {
|
|
|
+ title: dialog.title,
|
|
|
+ autoOpen: true,
|
|
|
+ height: h < 300 ? 300 : h,
|
|
|
+ width: w < 600 ? 600 : w,
|
|
|
+ position: {my: pos, at: pos, of: document},
|
|
|
+ modal: ctrl.modal ? ctrl.modal : false,
|
|
|
+ closeOnEscape: false,
|
|
|
+ open: function(event, ui) {
|
|
|
+ if (ctrl.modal){
|
|
|
+ jMLRK('[aria-describedby="_MLRKON_DIV_'+ctrl.num+'"] .ui-dialog-titlebar-close').hide();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close: function () {
|
|
|
+ if (dialog.hasTimer){
|
|
|
+ dialog.dialog.unbind();
|
|
|
+ clearInterval(dialog.timer_ctrl);
|
|
|
+ dialog.hasTimer = false;
|
|
|
+ }
|
|
|
+ jMLRK(this).dialog("destroy");
|
|
|
+
|
|
|
+ if (dialog.callback)
|
|
|
+ _callBack(dialog.callback, {bSave: dialog.bSave, orderIds: dialog.orderIds,insurOrders:dialog.insurOrders});//传参3
|
|
|
+
|
|
|
+ if (ctrl.callback)
|
|
|
+ _callBack(ctrl.callback, {mids: ctrl.mids, urls: ctrl.urls});
|
|
|
+
|
|
|
+ document.body.removeChild(dialog.div);
|
|
|
+ delete mlrkon_embed.dMap[dialog.num];
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ try{
|
|
|
+ dialog.dialog = jMLRK(dialog.div).dialog(config);
|
|
|
+ }catch(e){
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ //york start
|
|
|
+ jMLRK("#"+dialog.div.id).parent().css('z-index',zIndex++)
|
|
|
+ console.log("窗体编号num",ctrl.num)
|
|
|
+ //$(dialog.dialog).parent().css('z-index',zIndex++)
|
|
|
+ //york end
|
|
|
+ if (dialog.hasTimer) {
|
|
|
+ dialog.timer_ctrl = setInterval(function(){_changeOnlineTitle(dialog);}, 1000);
|
|
|
+ mlrkon_embed.dMap[ctrl.num] = dialog;
|
|
|
+
|
|
|
+ dialog.dialog.bind('mouseover', function() {
|
|
|
+ clearInterval(dialog.timer_ctrl);
|
|
|
+ var titleBar = dialog.dialog.dialog("instance").uiDialogTitlebar;
|
|
|
+ titleBar.find("span.ui-dialog-title").text(dialog.title);
|
|
|
+ dialog.timeCount = dialog.timerCount;
|
|
|
+ }).bind('mouseleave', function () {
|
|
|
+ dialog.timeCount = dialog.timerCount;
|
|
|
+ dialog.timer_ctrl = setInterval(function(){_changeOnlineTitle(dialog);}, 1000);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ function _changeOnlineTitle(dialog) {
|
|
|
+ if (dialog) {
|
|
|
+ var d = dialog.dialog.dialog("instance");
|
|
|
+ if (d != undefined){
|
|
|
+ var titleBar = d.uiDialogTitlebar;
|
|
|
+ var span = titleBar.find("span.ui-dialog-title");
|
|
|
+ var title = dialog.dialog.dialog( "option", "title" );
|
|
|
+ span.text(title + '(离窗口关闭还有 ' + dialog.timeCount + ' 秒)');
|
|
|
+ if (dialog.timeCount == 0) {
|
|
|
+ clearInterval(dialog.timer_ctrl);
|
|
|
+ dialog.dialog.dialog("close");
|
|
|
+ }
|
|
|
+ if (dialog.timeCount > 0) dialog.timeCount--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ function postMessage(args, frame){
|
|
|
+ if (frame == null || frame == undefined)
|
|
|
+ frame = mlrkon_embed.sIframe;
|
|
|
+ args._tag = 'MLRKON';
|
|
|
+ var params = JSON.stringify(args);
|
|
|
+ if(mlrkon_embed._init_ == true){
|
|
|
+ frame.contentWindow.postMessage(params, mlrkon_embed.proxy);
|
|
|
+ }else{
|
|
|
+ try{
|
|
|
+ recursiveTimeout(10, function() {
|
|
|
+ frame.contentWindow.postMessage(params, mlrkon_embed.proxy);
|
|
|
+ });
|
|
|
+ }catch(ex){
|
|
|
+ _callBack(mlrkon_embed.callback,{bSave: true, orderIds: []} )
|
|
|
+ console.log(ex)
|
|
|
+ console.log("recursiveTimeout")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ function recursiveTimeout(n, callbackFrame) {
|
|
|
+ if(n>0){
|
|
|
+ setTimeout(function() {
|
|
|
+ if(mlrkon_embed._init_ == true){
|
|
|
+ callbackFrame()
|
|
|
+ }else{
|
|
|
+ recursiveTimeout(n - 1, callbackFrame);
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ }else{
|
|
|
+ _callBack(mlrkon_embed.callback,{bSave: true, orderIds: []} )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function noRegeistry() {
|
|
|
+ if (mlrkon_embed.startMills == undefined || mlrkon_embed.startMills == null || mlrkon_embed.startMills == ''){
|
|
|
+ return
|
|
|
+ }else{
|
|
|
+ var endMills = Date.now()
|
|
|
+ if (endMills - mlrkon_embed.startMills > mlrkon_embed.options.timeout){ // 超时
|
|
|
+ _callBack(mlrkon_embed.callback,{bSave: true, orderIds: []} )
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mlrkon_embed.doCall = function(command, input, options, callback){
|
|
|
+ if(locked){
|
|
|
+ setTimeout(function(){
|
|
|
+ locked = false
|
|
|
+ innerCall(command, input, options, callback)
|
|
|
+ }, 100);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ locked = true
|
|
|
+ innerCall(command, input, options, callback)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ function innerCall(command, input, options, callback){
|
|
|
+
|
|
|
+ var url = mlrkon_embed.proxy + '/api/test_service.js'
|
|
|
+ var script = document.createElement("script");
|
|
|
+ script.src = url;
|
|
|
+ script.onerror = function () {
|
|
|
+ document.head.removeChild(script);
|
|
|
+ _callBack(callback, {bSave: true, orderIds: []});
|
|
|
+ return
|
|
|
+ }
|
|
|
+ script.onload = function () {
|
|
|
+ document.head.removeChild(script);
|
|
|
+ _doCall(command, input, options, callback);
|
|
|
+
|
|
|
+ mlrkon_embed.command = (command == 'srv_screen') ? command : ''
|
|
|
+ mlrkon_embed.input = (command == 'srv_screen') ? input : ''
|
|
|
+ mlrkon_embed.optins = (command == 'srv_screen') ? options : ''
|
|
|
+ mlrkon_embed.callback = (command == 'srv_screen') ? callback : null
|
|
|
+ }
|
|
|
+
|
|
|
+ document.head.appendChild(script);
|
|
|
+ // document.head.removeChild(script);
|
|
|
+ }
|
|
|
+
|
|
|
+ function _doCall(command, input, options, callback, url) {
|
|
|
+ locked = false
|
|
|
+ if (url==undefined || url==null) url='';
|
|
|
+
|
|
|
+ var input = (typeof input === 'string') ? JSON.parse(input) : input;
|
|
|
+ try{
|
|
|
+ if (command == 'srv_screen' || command == 'srv_online') {
|
|
|
+ var orders = input.orders
|
|
|
+ if(orders.length>0){
|
|
|
+ for(var i = 0;i < orders.length;i++){
|
|
|
+ if(orders[i].code == null || orders[i].code == undefined || orders[i].code == ''){
|
|
|
+ _callBack(callback, {bSave: true, orderIds: []});
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _callBack(callback, {bSave: true, orderIds: []});//传入医嘱为空也返回bSave为true by zhangyi
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch(e){
|
|
|
+ _callBack(callback, {bSave: true, orderIds: []});
|
|
|
+ console.log(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (options == undefined || options == null || options == ''){
|
|
|
+ options = {api:false,timeout: 5500}
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (command.replace(/(^\s*)|(\s*$)/g, "") == '') {
|
|
|
+ alert("请输入命令名称!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var opts = (typeof options === 'string') ? JSON.parse(options) : options;
|
|
|
+ var num = Math.ceil(Math.random()*100);
|
|
|
+
|
|
|
+ if (callback == null || callback == undefined || callback == ''){
|
|
|
+ callback = function(){}
|
|
|
+ }
|
|
|
+ mlrkon_embed.dMap[num] = {callback : callback, num: num};
|
|
|
+
|
|
|
+ mlrkon_embed.api = opts ? (opts.api ? opts.api : false) : false;
|
|
|
+
|
|
|
+ postMessage({cmd : command, input : input, opts : options, num: num, url:url});
|
|
|
+ // york start
|
|
|
+ mlrkon_embed.callback = callback
|
|
|
+ //york end
|
|
|
+ } catch (e){
|
|
|
+ _callBack(callback, {bSave: true, orderIds: []});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var jMLRK
|
|
|
+ if (!jMLRK){
|
|
|
+ loadScript(mlrkon_embed.proxy + '/js/jquery-1.11.1.js', function(){
|
|
|
+ jMLRK = window.jMLRK = $.noConflict(true);
|
|
|
+ loadJqueryUIJs('jquery-ui-mlrk.js')
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ /**客户的jQuery版本在1.6以下,用jquery-ui-1.8.16.custom.min.js**/
|
|
|
+ //loadJqueryUIJs('jquery-ui-1.8.16.custom.min.js');
|
|
|
+ loadJqueryUIJs('jquery-ui-mlrk.js')
|
|
|
+ }
|
|
|
+
|
|
|
+ function loadJqueryUIJs(fileName){
|
|
|
+ jMLRK.noConflict()
|
|
|
+ if ((typeof (jMLRK.ui) == 'undefined' || typeof (jMLRK.ui.dialog) == 'undefined' ) /*&&
|
|
|
+ typeof(LOAD_JQUERY_UI) != 'undefined' && LOAD_JQUERY_UI==true*/){
|
|
|
+ jMLRK.getScript(mlrkon_embed.proxy + '/js/' + fileName );
|
|
|
+
|
|
|
+ var d = jMLRK.Deferred();
|
|
|
+ var link = jMLRK('<link/>').attr({
|
|
|
+ rel: 'stylesheet',
|
|
|
+ type: 'text/css',
|
|
|
+ href: mlrkon_embed.proxy + '/css/jquery-ui.css'
|
|
|
+ }).appendTo('head');
|
|
|
+
|
|
|
+ d.resolve(link);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (typeof(JSON) == 'undefined'){
|
|
|
+ jMLRK.getScript(mlrkon_embed.proxy + '/js/jquery.json-2.4.js' );
|
|
|
+ jMLRK.getScript(mlrkon_embed.proxy + '/js/json2/json2.js' );
|
|
|
+ jMLRK.getScript(mlrkon_embed.proxy + '/js/json2/cycle.js');
|
|
|
+ }
|
|
|
+ createPostMessageFrame();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (window.addEventListener) { //所有主流浏览器,除了 IE 8 及更早 IE版本
|
|
|
+ window.addEventListener("message", function( event ) {
|
|
|
+ // console.log('----event.data='+event.data);
|
|
|
+ dealResult(event.data);
|
|
|
+
|
|
|
+ }, false );
|
|
|
+ } else if (window.attachEvent) { // IE 8 及更早 IE 版本
|
|
|
+ window.attachEvent("message", function( event ) {
|
|
|
+ // console.log('----event.data='+event.data);
|
|
|
+ dealResult(event.data);
|
|
|
+ }, false );
|
|
|
+ }
|
|
|
+
|
|
|
+ return mlrkon_embed;
|
|
|
+ }(document));
|
|
|
+
|
|
|
+window.MLRKON_CLIENT = MLRKON_CLIENT;
|
|
|
+
|
|
|
+function trim(str) {
|
|
|
+ if (!String.prototype.trim) {
|
|
|
+ return str.toString().replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, "").replace(/\s+/g, " ");
|
|
|
+ } else {
|
|
|
+ return str.toString().trim();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+
|