set_main.js
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:12k
源码类别:

OA系统

开发平台:

C#

  1. //--- 图形化设计 ---
  2. var dragapproved = false;
  3. var eventsource,x,y;
  4. var popeventsource = "";
  5. var temp1 = 0;
  6. var temp2 = 0;
  7. function nocontextmenu()
  8. {
  9.  event.cancelBubble = true
  10.  event.returnValue = false;
  11.  return false;
  12. }
  13. //-- 初始化移动参数 --
  14. function nodrags()
  15. {
  16.    dragapproved = false;
  17. }
  18. function move()
  19. {
  20. if (event.button == 1 && dragapproved)
  21. {
  22. var newleft = temp1 + event.clientX - x;
  23. var newtop = temp2 + event.clientY - y;
  24. eventsource.style.pixelLeft = newleft;
  25. eventsource.style.pixelTop = newtop;
  26. drawLine();
  27. return false;
  28. }
  29. }
  30. function drags()
  31. {
  32.   if (event.button != 1)
  33.      return;
  34. var objRect = event.srcElement;
  35. if (event.srcElement.tagName.toLowerCase() == 'textbox') objRect = event.srcElement.parentElement;
  36. if ((objRect.tagName == 'roundrect') && (!event.ctrlKey))
  37. {
  38. dragapproved = true;
  39. eventsource = objRect;
  40. temp1 = eventsource.style.pixelLeft;
  41. temp2 = eventsource.style.pixelTop;
  42. x = event.clientX;
  43. y = event.clientY;
  44. document.onmousemove = move;
  45. }
  46. }
  47. //-- 画线 --
  48. function drawLine()
  49. {
  50.   var source;
  51.   var object;
  52.   var sourceObj;
  53.   var objectObj;
  54.   var x0,y0,x1,y1;
  55.   var p0,p1;
  56.   var a = document.getElementsByTagName('line');
  57.   for (var i = 0; i < a.length; i++)
  58.   {
  59.      source = a[i].getAttribute('source');
  60.      object = a[i].getAttribute('object');
  61.      if ((source != null) && (object != null))
  62.      {
  63.         sourceObj = document.getElementById(source);
  64.         objectObj = document.getElementById(object);
  65.         if ((sourceObj == null) || (objectObj == null)) continue;
  66.         if (sourceObj.style.pixelLeft > objectObj.style.pixelLeft)
  67.         {
  68.            if ((sourceObj.style.pixelLeft - objectObj.style.pixelLeft) <= objectObj.style.pixelWidth)
  69.            {
  70.   x0 = sourceObj.style.pixelLeft + sourceObj.style.pixelWidth / 2;
  71.   x1 = objectObj.style.pixelLeft + objectObj.style.pixelWidth / 2;
  72.                if (sourceObj.style.pixelTop >  objectObj.style.pixelTop)
  73.                {
  74.       y0 = sourceObj.style.pixelTop;
  75.       y1 = objectObj.style.pixelTop  + objectObj.style.pixelHeight;
  76.                }
  77.                else
  78.                {
  79.       y0 = sourceObj.style.pixelTop + sourceObj.style.pixelHeight;
  80.       y1 = objectObj.style.pixelTop;
  81.      }
  82.            }
  83.            else
  84.            {
  85.                x0 = sourceObj.style.pixelLeft;
  86.                x1 = objectObj.style.pixelLeft + objectObj.style.pixelWidth;
  87.      y0 = sourceObj.style.pixelTop + sourceObj.style.pixelHeight / 2;
  88.      y1 = objectObj.style.pixelTop + objectObj.style.pixelHeight / 2;
  89.            }
  90.         }
  91.         else
  92.         {
  93.            if ((objectObj.style.pixelLeft - sourceObj.style.pixelLeft) <= objectObj.style.pixelWidth)
  94.            {
  95.   x0 = sourceObj.style.pixelLeft + sourceObj.style.pixelWidth / 2;
  96.   x1 = objectObj.style.pixelLeft + objectObj.style.pixelWidth / 2;
  97.                if (sourceObj.style.pixelTop >  objectObj.style.pixelTop)
  98.                {
  99.       y0 = sourceObj.style.pixelTop;
  100.       y1 = objectObj.style.pixelTop  + objectObj.style.pixelHeight;
  101.                }
  102.                else
  103.                {
  104.       y0 = sourceObj.style.pixelTop + sourceObj.style.pixelHeight;
  105.       y1 = objectObj.style.pixelTop;
  106.      }
  107.            }
  108.            else
  109.            {
  110. x0 = sourceObj.style.pixelLeft + sourceObj.style.pixelWidth;
  111. x1 = objectObj.style.pixelLeft;
  112. y0 = sourceObj.style.pixelTop + sourceObj.style.pixelHeight / 2;
  113. y1 = objectObj.style.pixelTop + objectObj.style.pixelHeight / 2;
  114.              }
  115.         }
  116.         a[i].from = String(x0) + ',' + String(y0);
  117.         a[i].to = String(x1) + ',' + String(y1);
  118.         a[i].style.pixelLeft = x0 + 'px';
  119.         a[i].style.pixelTop = y0 + 'px';
  120.         //条件
  121.         strIF = a[i].getAttribute('title');
  122.         if ((strIF != null) && (strIF != ''))
  123.         {
  124. var id = 'if_' + source + '_' + object;
  125. var obj = document.getElementById(id);
  126. var left = (x0 + (x1 - x0) / 2 - 30);
  127. var top = (y0 + (y1 - y0) / 2 - 15);
  128. if (obj != null)
  129. {
  130. obj.style.pixelLeft = left + 'px';
  131. obj.style.pixelTop = top + 'px';
  132. obj.style.left = left + 'px';
  133. obj.style.top = top + 'px';
  134. obj.style.display = '';
  135. }
  136.         }
  137.         a[i].style.display = '';
  138.      }
  139.   }
  140. }
  141. //表单加载完成
  142. function document.onreadystatechange()
  143. {
  144.    if (document.readyState=='complete')
  145.    {
  146.       drawLine();
  147.       document.onmousedown = drags;  //开始移动
  148.       document.onmouseup = nodrags;  //结束移动
  149.    }
  150. }
  151. // 形成菜单行
  152. function getMenuRow(s_Event, s_Html) {
  153. var s_MenuRow = "";
  154. s_MenuRow = "<tr><td align=center valign=middle nowrap><TABLE border=0 cellpadding=0 cellspacing=0 width=132><tr><td nowrap valign=middle height=20 class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut';";
  155. s_MenuRow += " onclick="parent."+s_Event+";parent.oPopupMenu.hide();"";
  156. s_MenuRow += ">&nbsp;";
  157. s_MenuRow += s_Html+"</td></tr></TABLE></td></tr>";
  158. return s_MenuRow;
  159. }
  160. //-- 右键菜单 --
  161. var sMenuHr = "<tr><td align=center valign=middle height=2><TABLE border=0 cellpadding=0 cellspacing=0 width=128 height=2><tr><td height=1 class=HrShadow></td></tr><tr><td height=1 class=HrHighLight></td></tr></TABLE></td></tr>";
  162. var sMenu1 = "<TABLE onmousedown='if (event.button==1) return true; else return false;' border=0 cellpadding=0 cellspacing=0 class=Menu width=150><tr><td width=18 valign=bottom align=center style='background:url(/images/bg_left.gif.gif);background-position:bottom;'></td><td width=132 class=RightBg><TABLE border=0 cellpadding=0 cellspacing=0>";
  163. var sMenu2 = "</TABLE></td></tr></TABLE>";
  164. var oPopupMenu = null;
  165. oPopupMenu = window.createPopup();
  166. function showContextMenu(event,type)
  167. {
  168. var style = "";
  169. style = "BODY {margin:0px;border:0px}";
  170. style += " TD {font-size:9pt;font-family:宋体,Verdana,Arial}";
  171. style += " TABLE.Menu {border-top:window 1px solid;border-left:window 1px solid;border-bottom:buttonshadow 1px solid;border-right:buttonshadow 1px solid;background-color:#0072BC}";
  172. style += "TD.RightBg {background-color:buttonface}";
  173. style += "TD.MouseOver {background-color:highlight;color:highlighttext;cursor:default;}";
  174. style += "TD.MouseOut {background-color:buttonface;color:buttontext;cursor:default;}";
  175. style += "TD.HrShadow {background-color:buttonshadow;}";
  176. style += "TD.HrHighLight {background-color:buttonhighlight;}";
  177. style = "<style>" + style + "</style>";
  178. var width = 150;
  179. var height = 0;
  180. var lefter = event.clientX;
  181. var topper = event.clientY;
  182. var oPopDocument = oPopupMenu.document;
  183. var oPopBody = oPopupMenu.document.body;
  184.    //object
  185. var objRect = event.srcElement;
  186. if (event.srcElement.tagName.toLowerCase() == 'textbox')
  187.     objRect = event.srcElement.parentElement;
  188. var sMenu = style;
  189.   switch(type)
  190.   {
  191.       case 1:
  192.           var Process_ID = objRect.getAttribute('table_id');
  193.           sMenu += getMenuRow("Edit_Process(" + Process_ID + ")", "步骤基本属性");
  194.           height += 20;
  195.           if (objRect.getAttribute('is_child_flow') == "false") {
  196.               sMenu += getMenuRow("set_user(" + Process_ID + ")", "经办权限");
  197.               height += 20;
  198.               sMenu += getMenuRow("set_item(" + Process_ID + ")", "可写字段");
  199.               height += 20;
  200.               sMenu += getMenuRow("set_hidden(" + Process_ID + ")", "保密字段");
  201.               height += 20;
  202.           }
  203.           sMenu += getMenuRow("set_condition(" + Process_ID + ")", "条件设置");
  204.           height += 20;
  205.           sMenu += sMenuHr;
  206.           height += 2;
  207.           sMenu += getMenuRow("Del_Process(" + Process_ID + ")", "删除该步骤");
  208.           height += 20;
  209.           break;
  210.   case 2:
  211.    sMenu += getMenuRow("Add_Process()", "新建步骤");
  212.    height += 20;
  213.    sMenu += sMenuHr;
  214.    height += 2;
  215.    sMenu += getMenuRow("SavePosition()", "保存布局");
  216.    height += 20;
  217.    sMenu += getMenuRow("Refresh()", "刷新视图");
  218.    height += 20;
  219.    break;
  220. /*
  221.   case 3:
  222.     var fid =  objRect.getAttribute('mfrID');
  223. sMenu += getMenuRow("DelFlowRun(" + fid + ")",  "删除连线");
  224.   height += 20;
  225.   break;
  226. */
  227.   }
  228. sMenu = sMenu1 + sMenu + sMenu2;
  229. height += 2;
  230. if (lefter+width > document.body.clientWidth) lefter = lefter - width + 2;
  231. if (topper+height > document.body.clientHeight) topper = topper - height + 2;
  232. oPopupMenu.document.body.innerHTML = sMenu;
  233. oPopupMenu.show(lefter, topper, width, height,document.body);
  234. return false;
  235. }
  236. //-- 鼠标右击 --
  237. function DoRightClick()
  238. {
  239. pub_x = event.clientX;
  240. pub_y = event.clientY;
  241.   SetSel();
  242. var objRect = event.srcElement;
  243. if (event.srcElement.tagName.toLowerCase() == 'textbox') objRect = event.srcElement.parentElement;
  244.     if (objRect.tagName.toLowerCase() == 'roundrect')
  245.     {
  246.         if (event.button == 2) return showContextMenu(event,1);
  247.     }
  248.     else
  249.     {
  250.         if (objRect.tagName.toLowerCase() == 'line')
  251.         {
  252.            //if (event.button == 2) return showContextMenu(event,3);
  253.         }
  254.         else
  255.         {
  256.            if (event.button == 2) return showContextMenu(event,2);
  257.         }
  258. }
  259. }
  260. //-- 选择步骤 --
  261. function SetSel()
  262. {
  263.    var flowType = '';
  264.    var flowID = 0;
  265.    var passCount = 0;
  266.    var flowColor = '';
  267.    var strStart="#00EE00";
  268.    var strEnd="#F4A8BD";
  269.    var strOut="#EEEEEE";
  270.    var strSelect ="#8E83F5";
  271.    var vml = document.getElementsByTagName('roundrect');
  272.    for (var i = 0; i < vml.length; i++)
  273.    {
  274.       flowType = vml[i].getAttribute('flowType');
  275.       if (flowType == 'start')
  276.       {
  277.          flowColor = strStart;
  278.       }
  279.       else if (flowType == 'end')
  280.       {
  281.          flowColor = strEnd;
  282.       }
  283.       else
  284.       {
  285.          flowColor = strOut;
  286.       }
  287.       vml[i].fillcolor = flowColor;
  288.    }
  289.    var objRect = event.srcElement;
  290.    if(event.srcElement.tagName.toLowerCase() == 'textbox')
  291.       objRect = event.srcElement.parentElement;
  292.    //步骤类型
  293.    //flowType = objRect.getAttribute('flowType');
  294.    try { if (objRect.tagName == 'roundrect') objRect.fillcolor = strSelect; } catch(e){}
  295. }
  296. //-- 删除流程线 --
  297. function SetSqlDelFlow(fid)
  298. {
  299.    var strSql = '';
  300.    strSql = "delete from office_missive_flow_run where office_missive_flow_run_id='" + fid + "' ";
  301.    document.all('tbSQL').value += strSql;
  302. }
  303. //-- 保存布局 --
  304. function SavePosition()
  305. {
  306.    var id = 0;
  307.    var strSql = '';
  308.    var mf_pixel_left = 0;
  309.    var mf_pixel_top = 0;
  310.    a = document.getElementsByTagName('roundrect');
  311.    for (var i = 0; i < a.length; i++)
  312.    {
  313.       table_id = eval(a[i].getAttribute('table_id'));
  314.       mf_pixel_left = a[i].style.pixelLeft;
  315.       mf_pixel_top = a[i].style.pixelTop;
  316.       if (table_id > 0)
  317.       {
  318.          strSql += "SetLeft=" + mf_pixel_left + ",SetTop=" + mf_pixel_top + " where ID="+table_id+";";
  319.       }
  320.    }
  321.    document.Form1.SET_SQL.value += strSql;
  322.    document.Form1.submit();
  323. }
  324. //-- 删除流程线 --
  325. function DelFlowRun(fid)
  326. {
  327.    if ((fid == null) || (fid == 0)) return;
  328.    SavePosition();
  329.    SetSqlDelFlow(fid);
  330.    document.all('btnSave').click();
  331. }
  332. //-- 刷新 --
  333. function Refresh()
  334. {
  335.    location.href = location.href;
  336. }
  337. function LoadWindow(URL)
  338. {
  339.   loc_x=(screen.availWidth-700)/2;
  340.   loc_y=(screen.availHeight-550)/2;
  341.   URL+="&graph=1";
  342.   window.open(URL,"set_process","height=550,width=700,status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,top="+loc_y+",left="+loc_x+",resizable=yes");
  343. }
  344. //新建步骤
  345. function Add_Process()
  346. {
  347.    LoadWindow("type_process_new.aspx?flow_id="+flow_id);
  348. }
  349. //编辑步骤属性
  350. function Edit_Process(Process_ID)
  351. {
  352. LoadWindow("type_process_edit.aspx?flow_id="+flow_id+"&id="+Process_ID);
  353. }
  354. function set_item(Process_ID)
  355. {
  356. LoadWindow("type_process_item.aspx?flow_id="+flow_id+"&id="+Process_ID);
  357. }
  358. function set_user(Process_ID)
  359. {
  360. LoadWindow("type_process_user.aspx?flow_id="+flow_id+"&id="+Process_ID);
  361. }
  362. function set_hidden(Process_ID)
  363. {
  364. LoadWindow("type_process_sethidden.aspx?flow_id="+flow_id+"&ID="+Process_ID);
  365. }
  366. function set_condition(Process_ID)
  367. {
  368. LoadWindow("type_process_setcondition.aspx?flow_id="+flow_id+"&ID="+Process_ID);
  369. }
  370. //删除步骤
  371. function Del_Process(Process_ID)
  372. {
  373. msg='确认要删除该步骤么?';
  374. if(window.confirm(msg))
  375. window.location="type_process_delete.aspx?flow_id="+flow_id+"&graph=1&id="+Process_ID;
  376. }