<%@ page contentType="text/html; charset=GBK" %>
<%@ page import = "zr.zrpower.common.util.SysPreperty" %>
<%@ page import = "zr.zrpower.entity.sys.SessionUser" %>
<%@ page import = "zr.zrpower.flowengine.mode.config.FLOW_CONFIG_PROCESS"%>
<%@ page import = "zr.zrpower.flowengine.mode.config.FLOW_CONFIG_ACTIVITY"%>
<%@ page import = "zr.zrpower.flowengine.mode.config.FLOW_CONFIG_ACTIVITY_CONNE"%>
<%@ page import = "zr.zrpower.flowengine.mode.config.FLOW_CONFIG_PROCESS_CONNECTION"%>
<%@ page import = "zr.zrpower.flowengine.mode.base.Package"%>
<%@ page import = "zr.zrpower.ejb.sys.UserService"%>
<%@ page import = "zr.zrpower.ejb.sys.UIService" %>
<%@ page import = "zr.zrpower.flowengine.service.FlowConfig" %>
<%@ page import = "zr.zrpower.flowengine.service.FlowControl"%>
<%@ page import = "java.util.Hashtable"%>
<%@ page import = "java.lang.Object"%>
<HTML>
<%
SessionUser user = (SessionUser)session.getAttribute("userinfo");
UIService userUI =new UIService();
UserService name=new UserService();
FLOW_CONFIG_PROCESS[] PROCESS = null;
Package[] Package = null;
FlowConfig Fconfig =new FlowConfig();

FLOW_CONFIG_ACTIVITY[] Activity = null;
FLOW_CONFIG_ACTIVITY_CONNE[] ActivityConne = null;
FLOW_CONFIG_PROCESS_CONNECTION[] ProcessConne = null;
FlowControl FControl = new FlowControl();

String strWorkflow_No = request.getParameter("Workflow_No");
String strAID = request.getParameter("AID");

String PData = "";
int row=0;
int low=0;
String flow_ico="icon-th";
String XYCSS[]=null;
String toflows[]=null;
String toflow = "";
String toflow1 = "";
String SID = "";
String EID = "";
String HA = "";
String HB = "";
String strWidth="";
String SE="";
String strSub = "";
String dq="";

Activity = FControl.GetActivityList(strWorkflow_No);
     if (Activity!=null && Activity.length>0){
       PData = PData + "{\"total\":"+String.valueOf(Activity.length)+",\"list\":[";
       //特殊处理老数据的关系-----
        Hashtable gxHashtable = new Hashtable();
        for(int i=0;i<Activity.length;i++){
         if (Activity[i].getTYPE().equals("1"))
         {
            SID = Activity[i].getID();
         }
         if (Activity[i].getTYPE().equals("2"))
         {
            EID = Activity[i].getID();
         }
         if (Activity[i].getTYPE().equals("5"))
         {strSub = strSub + ","+Activity[i].getID();}

         XYCSS = Activity[i].getXYCSS().split("/");
         if (XYCSS[0].equals("1"))//老格式的数据
         {
            if (XYCSS[3].length()>0)
            {
               HA = XYCSS[3];
               HB = XYCSS[1];
               if (HA.equals("0")){HA= "S"+SID;}
               if (HA.equals("-1")){HA= "E"+EID;}
               if (HB.equals("0")){HB= "S"+SID;}
               if (HB.equals("-1")){HB= "E"+EID;}

               gxHashtable.put(HA,HB);
            }
         }

        }

       //----------------------

       for(int i=0;i<Activity.length;i++){

         XYCSS = Activity[i].getXYCSS().split("/");
         if (XYCSS[0].equals("1"))
         {
            XYCSS[5]=XYCSS[5].substring(0,XYCSS[5].length()-3)+"px";
            XYCSS[6]=XYCSS[6].substring(0,XYCSS[6].length()-3)+"px";
         }

         if (Activity[i].getTYPE().equals("1"))
         {
           flow_ico= "icon-play";
           SE="S";
         }
         if (Activity[i].getTYPE().equals("2"))
         {
           flow_ico= "icon-ok";
           SE="E";
         }
         if (Activity[i].getTYPE().equals("3"))
         {
           flow_ico= "icon-th";
           SE="";
         }
         if (Activity[i].getTYPE().equals("5"))
         {
           flow_ico= "icon-random";
           SE="Z";

         }


          if (XYCSS[0].equals("1"))
          {
             toflow = (String) gxHashtable.get(Activity[i].getID());
          }else
          {
             toflow = XYCSS[3];

             toflows = toflow.split(",");
             for (int y=0;y<toflows.length;y++)
             {
             toflow = toflows[y];
             if (toflow.equals(SID))
             {
                toflow = "S"+toflow;
             }
             if (toflow.equals(EID))
             {
                toflow = "E"+toflow;
             }


             if (toflow.length()>0 && strSub.indexOf(toflow) != -1)
             {
                toflow = "Z"+toflow;
             }
             if (y==0)
             {
               toflow1 = toflow;
             }else
             {
               toflow1 = toflow1 +","+toflow;
             }

             }
          }
          if (Activity[i].getTYPE().equals("1") || Activity[i].getTYPE().equals("2"))
          {
              strWidth="80px";
          }else
          {
              strWidth="120px";
          }

          if (Activity[i].getTYPE().equals("5"))
          {
              strWidth="200px";
          }

         if (Activity[i].getID().equals(strAID))
         {
            dq="当前步骤：";
            if (Activity[i].getTYPE().equals("1") || Activity[i].getTYPE().equals("2"))
            {
              strWidth="120px";
            }else
            {
              strWidth="180px";
            }

         }else
         {
           dq="";
         }

         if (i==0)
         {
           PData = PData + "{\"id\":\""+SE+Activity[i].getID()+"\",\"flow_id\":\"4\",\"process_name\":\""+dq+Activity[i].getNAME()+"\",\"process_to\":\""+toflow1+"\",\"icon\":\""+flow_ico+"\",\"style\":\"width:"+strWidth+";height:40px;line-height:40px;color:#0e76a8;left:"+XYCSS[5]+";top:"+XYCSS[6]+";\"}";
         }else
         {
           PData = PData + ",{\"id\":\""+SE+Activity[i].getID()+"\",\"flow_id\":\"4\",\"process_name\":\""+dq+Activity[i].getNAME()+"\",\"process_to\":\""+toflow1+"\",\"icon\":\""+flow_ico+"\",\"style\":\"width:"+strWidth+";height:40px;line-height:40px;color:#0e76a8;left:"+XYCSS[5]+";top:"+XYCSS[6]+";\"}";
         }

         if (i!=0 && (i+1) % 5==0)
         {
            row=row+1;
            low = 0;
         }else
         {
            low = low + 1;
         }


       }
       PData = PData + "]}";
      }



%>
<HTML>
 <head>
 <title>流程显示</title>
 <meta name="keyword" content="">
 <meta name="description" content="">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1">
    <meta name="author" content="leipi.org">
    <link href="../../flowconfig/Public/css/bootstrap/css/bootstrap.css?2025" rel="stylesheet" type="text/css" />
    <!--[if lte IE 6]>
    <link rel="stylesheet" type="text/css" href="../../flowconfig/Public/css/bootstrap/css/bootstrap-ie6.css?2025">
    <![endif]-->
    <!--[if lte IE 7]>
    <link rel="stylesheet" type="text/css" href="../../flowconfig/Public/css/bootstrap/css/ie.css?2025">
    <![endif]-->
    <link href="../../flowconfig/Public/css/site.css?2025" rel="stylesheet" type="text/css" />


    <script type="text/javascript">
        var _root='http://www.zrpower.cn/index.php?s=/',_controller = 'flowdesign';
    </script>


<link rel="stylesheet" type="text/css" href="../../flowconfig/Public/js/flowdesign/flowdesign.css"/>

<!--select 2-->
<link rel="stylesheet" type="text/css" href="../../flowconfig/Public/js/jquery.multiselect2side/css/jquery.multiselect2side.css"/>


 </head>
<body>

<FORM id=Form1 name=Form1 action="../../../flowdesign.do" method=post>
<INPUT type=hidden name=tmp_save>
<input type="hidden" name="type" value="show">

<!--contextmenu div-->
<div id="processMenu" style="display:none;">

</div>

<!--end div-->

<div class="container mini-layout" id="flowdesign_canvas">
</div>








<script type="text/javascript" src="../../flowconfig/Public/js/jquery-1.7.2.min.js?2025"></script>
<script type="text/javascript" src="../../flowconfig/Public/css/bootstrap/js/bootstrap.min.js?2025"></script>
<script type="text/javascript" src="../../flowconfig/Public/js/jquery-ui/jquery-ui-1.9.2-min.js?2025" ></script>
<script type="text/javascript" src="../../flowconfig/Public/js/jsPlumb/jquery.jsPlumb-1.3.16-all-min.js?2025"></script>
<script type="text/javascript" src="../../flowconfig/Public/js/jquery.contextmenu.r2.js?2025"></script>
<!--select 2-->
<script type="text/javascript" src="../../flowconfig/Public/js/jquery.multiselect2side/js/jquery.multiselect2side.js?2025" ></script>
<!--flowdesign-->
<script type="text/javascript" src="../../flowconfig/Public/js/flowdesign/leipi.flowdesign.v3.js?2025"></script>

<SCRIPT language=jscript src="../../js/Control.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../../../zrsysmanage/script/Public.js"></SCRIPT>
<script src="../../../zrsysmanage/html5/layer/layer.js" type="text/jscript" ></script>

<script type="text/javascript">
var the_flow_id = '4';


function callbackSuperDialog(selectValue){
     var aResult = selectValue.split('@leipi@');
     $('#'+window._viewField).val(aResult[0]);
     $('#'+window._hidField).val(aResult[1]);
    //document.getElementById(window._hidField).value = aResult[1];

}


$(function(){
    var alertModal = $('#alertModal'),attributeModal =  $("#attributeModal");
    //消息提示
    mAlert = function(messages,s)
    {
        if(!messages) messages = "";
        if(!s) s = 2000;
        alertModal.find(".modal-body").html(messages);
        alertModal.modal('toggle');
        setTimeout(function(){alertModal.modal("hide")},s);
    }

    //属性设置
    attributeModal.on("hidden", function() {
        $(this).removeData("modal");//移除数据，防止缓存
    });
    ajaxModal = function(url,fn)
    {
        url += url.indexOf('?') ? '&' : '?';
        url += '_t='+ new Date().getTime();
        attributeModal.find(".modal-body").html('<img src="../../flowconfig/Public/images/loading.gif"/>');
        attributeModal.modal({
            remote:url
        });

        //加载完成执行
        if(fn)
        {
            attributeModal.on('shown',fn);
        }


    }


    /*
    jsp 命名习惯 单词用下划线_隔开
    js 命名习惯：首字母小写 + 其它首字线大写
    */
    /*步骤数据*/
    var processData = <%=PData%>;



    /*创建流程设计器*/
    var _canvas = $("#flowdesign_canvas").Flowdesign({
                      "processData":processData

                      /*画面右键*/
                      ,canvasMenus:{



                      }
                      /*步骤右键*/
                      ,processMenus: {





                      }

                      ,fnDbClick:function(){
                          //和 pmAttribute 一样
                          var activeId = _canvas.getActiveId();//右键当前的ID


                      }
                  });

    /*保存*/
    $("#leipi_save").bind('click',function(){
        var processInfo = _canvas.getProcessInfo();//连接信息


    });


});


function __doPostBack(eventTarget, eventArgument) {
		var theform;

		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			theform = document.Form1;
		}
		else {
			theform = document.forms["Form1"];
		}

		theform.submit();
	}

   function repl(s,y,t)
    {
     var i;
     var s2=s;
     var y2=y;
     var t2=t;

     while(s2.indexOf(y2)>=0)
     {
     i = s2.indexOf(y2);
     s2 = s2.substring(0, i) + t2 + s2.substring(i + y2.length, s2.length);
     }
     return s2;
    }



//保存数据
function btnSave_onclick()
{
   document.getElementById("leipi_save").click();

}


</script>
</FORM>
</body>
</html>
<%
//清空相关对象
user = null;
userUI = null;
name = null;
Package = null;
FControl = null;
Fconfig = null;
%>
