var WF_PARAMS = { RENDER_TYPE_DOM:'dom'//返回jquery dom元素 ,RENDER_TYPE_APPEND:'append'//直接在指定容器ID(containerid)的dom上生成 }; var _nodedata = []; $.extend({ //渲染图形化流程监控图 wfchat:function(jparam){ var _id=jparam.id?jparam.id:$.getID(); var _returntype = jparam.returntype?jparam.returntype:''; var _width = jparam.width?jparam.width:50;//默认圆圈的直径是50像素 var _blink = jparam.blink?jparam.blink:false;//默认不闪烁 if(_width<30){ _width = 30; } var _width2 = 2 * _width;//圆圈外框的宽度 var _shift = _width/2; var _containerid = jparam.containerid; var _containHeight = jparam.containerheight?jparam.containerheight:''; if(!_containHeight){ _containHeight = $('#'+_containerid).height(); } if(!_containHeight){ _containHeight = _width2+30; } var _data = jparam.data; var _top = (_containHeight - _width - 28)/2; var _current = jparam.current?jparam.current:''; var valid = false;//是否有效 var isused = false; if(_data){ for(var i=0;i<_data.length;i++){ var wfnodedata = _data[i]; if(wfnodedata.nodename == _current){ valid = true; break; } } var htmlStr = []; htmlStr.push('
'); var nodesize = _data.length-1; var _containerWidth = 100/nodesize; htmlStr.push('
'); for(var i=1;i<_data.length;i++){ var wfnodedata = _data[i-1]; htmlStr.push('
'); htmlStr.push('
'); var colorCss = ' blue-bg'; if(valid){ if(wfnodedata.nodename == _current){ colorCss = ' yellow-bg'; if(_blink == true){ colorCss = ' yellow-bg-blink'; } isused = true; }else{ if(isused==true){ colorCss = ''; } } }else{ colorCss = ''; } htmlStr.push('
'+i+'
'); htmlStr.push('
'+wfnodedata.nodetitle+'
'); htmlStr.push('
'); htmlStr.push('
'); } htmlStr.push('
'); //丢入最后一个环节的信息 htmlStr.push('
'); htmlStr.push('
'); htmlStr.push('
'); var colorCss = ' blue-bg'; if(valid){ if(_data[nodesize].nodename == _current){ colorCss = ' blue-bg'; isused = true; }else{ if(isused==true){ colorCss = ''; } } }else{ colorCss = ''; } htmlStr.push('
'+i+'
'); htmlStr.push('
'+_data[nodesize].nodetitle+'
'); htmlStr.push('
'); htmlStr.push('
'); htmlStr.push('
'); htmlStr.push('
'); var domObj = $(htmlStr.join('')); //$('#'+_containerid).append(); domObj.find('.wf-node').css("top",_top+"px"); domObj.find('.wf-area').append(""); domObj.find('.wf-area').append(""); if(_returntype && _returntype == WF_PARAMS.RENDER_TYPE_DOM){ return domObj; }else{ $('#'+_containerid).empty(); domObj.appendTo('#'+_containerid); } }else{ if(_returntype && _returntype == WF_PARAMS.RENDER_TYPE_DOM){ return $(''); } } } ,wfPanelGrid:function(jparam){ var _bdl_code = jparam.bdl_code?jparam.bdl_code:''; var _manageunituuid = jparam.manage_unit_uuid?jparam.manage_unit_uuid:''; var _isReload = jparam.reload; if(!_isReload == true){ if(!_bdl_code){ alert('参数bdl_code不允许为空!'); return; } if(!_manageunituuid){ alert('参数manage_unit_uuid不允许为空!'); return; } } var _containHeight = jparam.rowHeight?jparam.rowHeight:90; var _width = jparam.width?jparam.width:30; var _rowRender = jparam.rowRender?jparam.rowRender:function(){}; jparam.rowRender = wfRowRender; if(!_isReload == true){ $.cuajax({ url : 'wdk?action=wdk.pub&method=call_service&ajaxparam='+ new Date().getTime(), method : "post", timeout : WDK_Timeout, data : { _SRVNAME : 'service.bdl.run', _SRVMETHOD : 'queryWfNodeListByBdlCode', _DATA : $.json2str({ bdlcode : _bdl_code, manage_unit_uuid : _manageunituuid }) }, success : function(result) { $.wait_close(); var jres = $.str2json(result);//返回值字符串转json if (jres && jres.code == "1") { //操作成功 _nodedata = jres.result; var gridid = $.panelGrid(jparam); } else { alert(jres.desc); } }, error : function(result) { $.wait_close(); alert('网络错误!result=' + result); } }); }else{ var gridid = $.panelGrid(jparam); } function wfRowRender(row,index,data){ var wfdom = $.wfchat({ containerid:'wf_chat_'+index ,containerheight:_containHeight ,width:_width ,returntype:WF_PARAMS.RENDER_TYPE_DOM ,data:_nodedata ,current:row.currentstepcode ,blink:jparam.blink?jparam.blink:'' }); var wfchart = wfdom.prop('outerHTML'); return _rowRender(row,index,data,wfchart); } }, wfPanelGrid_reload:function(jparam){ jparam.reload = true; $.wfPanelGrid(jparam); /* $.cuajax({ url : 'wdk?action=wdk.pub&method=call_service&ajaxparam='+ new Date().getTime(), method : "post", timeout : WDK_Timeout, data : { _SRVNAME : 'service.bdl.run', _SRVMETHOD : 'queryWfNodeListByBdlCode', _DATA : $.json2str({ bdlcode : _bdl_code, manage_unit_uuid : _manageunituuid }) }, success : function(result) { $.wait_close(); var jres = $.str2json(result);//返回值字符串转json if (jres.code == "1") { //操作成功 _nodedata = jres.result; var params = getGridQueryParam(); var gridid=$.panelGrid({ containerid:'#layout_grid', url : 'wdk?action=wdk.pub&method=call_service&ajaxparam=' + new Date().getTime(), queryParams : params, onClick:function(index, row){ }, rowRender:_rowRender }); } else { alert(jres.desc); } }, error : function(result) { $.wait_close(); alert('网络错误!result=' + result); } });*/ /*var wfdom = $.wfchat({ containerid:'wf_chat_'+index ,containerheight:90 ,width:30 ,returntype:WF_PARAMS.RENDER_TYPE_DOM ,data:_nodedata ,current:row.currentstepcode }); if(wfdom){ rowHtmlStr.push(wfdom.prop('outerHTML')); }*/ } });