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 $('