<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style>
vml\:*
{
FONT-SIZE: 12px;
behavior: url(#default#VML);
}
</style>
<style>
.itemnode
{
fill: #00EE00; stroke: #000000; stroke-width: 1; position: absolute;
vertical-align: middle; cursor: pointer; text-align: center; z-index: 1
}
.itemline
{
stroke: rgb(99,99,99); z-index: 2; stroke-width: 2;
}
.itemtext
{
font-size: 12px; opacity: 1; position: absolute; text-anchor: middle; fill: #000000;
cursor:pointer;display:block;
}
.itempolygon
{
fill: #000000; stroke: #000000; stroke-width: 1; transform:translate(70,200)
}
.classp
{
font-size: 12px; opacity: 1;fill: #000000;
cursor:pointer;display:block;margin-top:5px;text-align:center;
}
</style>
</head>
<body>
<div ms-controller="controller">
<svg id='contextsvg' xml:space='preserve' ms-css="@svgconfig" xmlns='http://www.w3.org/2000/svg'>
<g ms-for="el in @data" ms-attr="{id:el.id}">
<rect ms-attr="el.rect" ms-css="{fill:el.rect.fill}" />
<g>
<text ms-attr="el.text" onselectstart='return false;'>
<tspan >{{el.text.text}}</tspan>
</text>
<foreignObject width="100" height="50" ms-attr="{x:el.text.x,y:el.text.y,id:'fr_'+el.rect.id}" class="itemtext">
<body xmlns="http://www.w3.org/1999/xhtml">
<p class="classp">{{el.text.opter}}</p>
<p class="classp">{{el.text.msg}}</p>
</body>
</foreignObject>
</g>
<line ms-for="x in el.link" ms-attr="x" />
<polygon ms-for="x in el.polygon" ms-attr="x" />
</g>
</svg>
</div>
<div id="contextBody" style="font-size: 12px;display:none">
</div>
</body>
<script src="/Components/js/avalon2.2.8.js" type="text/javascript"></script>
<script>
var data = [
{
name: "申報", opter: "操做人1", next: ["聯審1", "聯審2", "聯審3", "聯審4", "聯審5"]
, msg: "操做結果", state: 3
}
, { name: "聯審1", opter: "聯審人1", next: ["匯籤"], msg: "贊成", state: 3 }
, { name: "聯審2", opter: "聯審人2", next: ["匯籤"], msg: "贊成", state: 3 }
, { name: "聯審3", opter: "聯審人3", next: ["匯籤"], msg: "贊成", state: 3 }
, { name: "聯審4", opter: "聯審人4", next: ["匯籤"], msg: "贊成", state: 3 }
, { name: "聯審5", opter: "聯審人5", next: ["匯籤"], msg: "贊成", state: 3 }
, { name: "匯籤", opter: "匯籤審覈人", next: ["主管部門受理"], msg: "贊成", state: 3 }
, { name: "主管部門受理", opter: "受理", next: ["主管領導審覈"], msg: "贊成", state: 3 }
, { name: "主管領導審覈", opter: "領導審覈", next: ["財政受理"], msg: "贊成", state: 3 }
, { name: "財政受理", opter: "財政受理", next: ["財政審覈"], msg: "贊成", state: 3 }
, { name: "財政審覈", opter: "財政審覈", next: ["系統分析"], msg: "贊成", state: 3 }
, { name: "系統分析", opter: "系統分析", next: ["專家評審A", "專家評審B", "專家評審C"], msg: "贊成", state: 3 }
, { name: "專家評審A", opter: "天風國際專家評審A", next: ["資金安排"], msg: "贊成", state: 3 }
, { name: "專家評審B", opter: "專家評審B", next: ["資金安排"], msg: "贊成", state: 3 }
, { name: "專家評審C", opter: "專家評審C", next: ["資金安排"], msg: "贊成", state: 3 }
, { name: "資金安排", opter: "資金安排", next: ["項目立項"], msg: "贊成", state: 3 }
, { name: "項目立項", opter: "項目立項", next: ["項目公示"], msg: "贊成", state: 3 }
, { name: "項目公示", opter: "項目公示", next: ["項目歸檔"], msg: "贊成", state: 1 }
, { name: "項目歸檔", opter: "項目歸檔", next: [], msg: "贊成項目歸檔", state: 0 }
];
</script>
<script type="text/javascript">
function createRectObj() {
return { id: '', x: '312', y: '170', rx: '5', ry: '5', width: '100', height: '50', "class": "itemnode", x: '20', y: '50', rx: '5', ry: '5', transform: "matrix(1 0 0 1 0 0)" }
}
function createLineObj() {
return { x1: '0', y1: '0', x2: '0', y2: '0', 'class': "itemline", source: '0', object: '0' }
}
function createPolygonObj() {
return { id: 'polygon', points: "-3,-6 3,-6 0,0", transform: 'translate(70,200)', 'class': "itempolygon" }
}
function createTextObj() {
return { id: 'text_', x: '20', y: '0', dx: '0', dy: '0', 'class': "itemtext", text: "", stroke: "black" }
}
function fillStyle(state) {
switch (state) {
case 0: return "#B2B2B3";
case 1: return "#EA3241";
case 3: return "#32C833";
default: return "";
}
}
function getPosition(index, item) {
var obj = { x: 20, y: ystart + 30 };
if (index == 0) {
return obj
}
var flag = avalon.Array.remove(exists, index);
if (flag == true) {
obj.x += (item.index) * 150;
obj.y = (item.px) * 100 + 30;
}
else {
obj.x += (item.index) * 150;
obj.y = ystart + 30;
}
var m = avalon(window).width()
if (obj.x + 100 > m) {
obj.x = (obj.x - m) < 0 ? 0 : (obj.x + 100 - m);
obj.y += 200 + (flag ? 200 : 0);
obj.x += (m / 2);
}
return obj;
}
var maxchild = 0, lineheight = 100, index = 0;
var maxnext;
avalon.each(data, function(index, el) {
if (el.next.length > maxchild) {
maxchild = el.next.length;
maxnext = el;
index = index;
}
})
var xstart = 100;
var ystart = 100;
var nodedata = [];
var existsPosition = [];
var exists = [];
var currIndex = 0;
var pindex = 0;
avalon.each(data, function(index, item) {
if (item.next.length > 1) {
item.index = pindex;
avalon.each(data, function(i, x) {
avalon.each(item.next, function(j, y) {
if (x.name == y) {
x.index = pindex + 1;
x.px = j;
}
});
});
pindex += 2;
}
else {
if (item.index) { }
else {
item.index = pindex;
pindex++;
}
}
});
avalon.each(data, function(index, item) {
if (item.next.length > 1) {
avalon.Array.merge(exists, avalon.range(index + 1, item.next.length + index + 1));
existsPosition.push({ name: item.name, index: index + 1, node: avalon.range(index + 1, item.next.length + index + 1) });
}
var p = getPosition(index, item);
var g = { id: 'g' + item.name };
g.rect = createRectObj();
g.rect.state = item.state;
g.rect.fill = fillStyle(item.state)
g.rect.x = p.x;
g.rect.y = p.y;
g.rect.id = item.name;
g.text = createTextObj();
g.text.id += item.name;
g.text.text = item.name;
g.text.opter = item.opter;
g.text.msg = item.msg;
g.text.x = g.rect.x;
g.text.y = g.rect.y;
g.polygon = []
g.link = [];
avalon.each(item.next, function(i, x) {
var l = createLineObj();
l.source = item.name;
l.object = x;
g.link.push(l);
var p = createPolygonObj();
p.id = item.name + x;
g.polygon.push(p);
})
nodedata.push(g);
})
avalon.each(nodedata, function(index, item) {
})
var model = avalon.define({
$id: 'controller'
, d: new Date().getTime()
, data: nodedata
, svgconfig: { width: avalon(window).width() - 40, height: 500 }
, polygonpoints: "-3,-6 3,-6 0,0"
, rectAttr: { width: '100', height: '50', "class": "itemnode", _x: '20', _y: '50', _rx: '5', _ry: '5', transform: "matrix(1 0 0 1 0 0)" }
, lineAttr: { x1: '0', y1: '0', x2: '0', y2: '0', 'class': "itemline", _source: '1', _object: '2' }
, polygonAttr: { points: "-3,-6 3,-6 0,0", transform: 'translate(70,200)', 'class': "itempolygon" }
, textAttr: { _id: 'text_1', _x: '20', _y: '50', _dx: '56', _dy: '30', 'class': "itemtext" }
});
setTimeout(function() {
document.getElementById("contextsvg").innerHTML = document.getElementById("contextsvg").innerHTML;
drawLine();
}, 1000);
</script>
<script type="text/javascript" src="set_main.js"></script>
</html>
//--- 圖形化設計 ---
/**
* 是否開始拖拽
**/
var dragapproved = false;
/**
* 拖拽的對象,拖拽前鼠標的位置
**/
var eventsource, x, y;
/**
* 拖拽前對象的位置
**/
var temp1 = 0;
var temp2 = 0;
/**
* 拖拽前矩形中文字的位置
**/
var textX = 0;
var textY = 0;
/**
* svg vml類型初始化
**/
var VGType = function () { return window.SVGAngle || document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"; }
var isSVG = function () { return VGType() == "SVG" ? true : false; }
var isVML = function () { return VGType() == "VML" ? true : false; }
//得到event對象方法
function getEvent() {
if (document.all) return window.event; //若是瀏覽器中可直接獲得event對象 則直接返回
func = getEvent.caller;
while (func != null) {
var arg0 = func.arguments[0];
if (arg0) {
if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
return arg0;
}
}
func = func.caller;
}
return null;
}
//獲取瀏覽器類型
var Browser = GetBrowser();
function GetBrowser() {
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var ie11;
try {
ie11 = window.ActiveXObject.length;
}
catch (e) { }
if (s = ua.match(/msie ([\d.]+)/))
Sys.ie = s[1];
else if (window.ActiveXObject)
Sys.ie = 11;
else if (ie11)
Sys.ie = 11;
else if (s = ua.match(/firefox\/([\d.]+)/))
Sys.firefox = s[1];
else if (s = ua.match(/chrome\/([\d.]+)/))
Sys.chrome = s[1];
else if (s = ua.match(/opera.([\d.]+)/))
Sys.opera = s[1];
else if (s = ua.match(/version\/([\d.]+).*safari/))
Sys.safari = s[1];
return Sys;
}
/**
* 初始化
**/
drawLine();
document.onmousedown = drags; //開始移動
document.onmouseup = nodrags; //結束移動
//document.oncontextmenu = DoRightClick; //提示菜單
//-- 初始化移動參數 --
function nodrags()//中止拖動
{
dragapproved = false;
}
function move()//移動中執行
{
var event = getEvent();
var context = document.getElementById("contextBody");
var newleft = temp1 + event.clientX - x; //得到矩形當前位置
var newtop = temp2 + event.clientY - y;
var newwidth = newleft + 120;
var newheight = newtop + 60;
if (isSVG()) {
if (event.button == 0 && dragapproved) {//若是鼠標左鍵點擊而且移動開始
eventsource.setAttribute("x", newleft); //設定矩形位置
eventsource.setAttribute("y", newtop);
var text = document.getElementById("text_" + eventsource.id); //得到矩形對應文本
var newX = textX + event.clientX - x; //得到文本當前位置
var newY = textY + event.clientY - y;
text.setAttribute("x", newX); //設定文本位置
text.setAttribute("y", newY);
var fr = document.getElementById("fr_" + eventsource.id); //得到矩形對應文本
fr.setAttribute("x", newX); //設定文本位置
fr.setAttribute("y", newY);
drawLine(); //設定箭頭位置
//寬度高度自適應
var objsvg = document.getElementById("contextsvg");
var w = objsvg.getAttribute("width");
var h = objsvg.getAttribute("height");
if (newwidth > w) {
objsvg.setAttribute("width", newwidth);
context.style.width = newwidth + 'px'
}
if (newheight > h) {
objsvg.setAttribute("height", newheight);
context.style.height = newheight + 'px';
}
return false;
}
}
else if (isVML()) {
if (event.button == 1 && dragapproved) {
eventsource.style.pixelLeft = newleft;
eventsource.style.pixelTop = newtop;
drawLine();
//寬度高度自適應
var w = context.offsetWidth;
var h = context.offsetHeight;
if (newwidth > w)
context.style.width = newwidth;
if (newheight > h)
context.style.height = newheight;
return false;
}
}
}
function drags()//拖拽開始
{
var event = getEvent();
oPopupMenuHide(event);
SetSel(event);
if (isSVG()) {
if (event.button != 0)//若是不是鼠標左鍵操做 則直接返回
return;
}
else if (isVML()) {
if (event.button != 1)
return;
}
var objRect = null;
if (isSVG()) {
objRect = event.target; //得到鼠標點擊對象
}
else if (isVML()) {
objRect = event.srcElement;
}
if (isSVG()) {
if (objRect.tagName == 'text' || objRect.tagName == 'tspan'
|| objRect.tagName == 'rect' || objRect.tagName == 'svg') {
// var menu = document.getElementById("menu");
// menu.style.display = "none";
}
if (event.target.tagName.toLowerCase() == 'tspan') {
objRect = objRect.parentNode;
}
if (event.target.tagName.toLowerCase() == 'foreignobject') {
objRect = objRect.parentNode;
}
if (event.target.tagName.toLowerCase() == 'p') {
objRect = objRect.parentNode.parentNode.parentNode.children[0];
}
if (objRect.tagName.toLowerCase() == 'text') {//若是鼠標點擊對象爲文本
var temp = objRect.id.split("_"); //經過文本id得到對應矩形對象
var parantId = temp[1];
objRect = document.getElementById(parantId);
}
if ((objRect.tagName == 'rect') && (!event.ctrlKey))//拖拽對象爲矩形
{
dragapproved = true; //拖拽開始
eventsource = objRect; //將矩形對象賦給全局變量
temp1 = parseFloat(eventsource.getAttribute("x")); //存儲未拖拽前矩形的位置
temp2 = parseFloat(eventsource.getAttribute("y"));
var text = document.getElementById("text_" + eventsource.id); //得到與矩形對應的文本
textX = parseFloat(text.getAttribute("x")); //得到未拖拽前文本的位置
textY = parseFloat(text.getAttribute("y"));
x = event.clientX; //得到未拖拽前鼠標的位置
y = event.clientY;
document.onmousemove = move; //爲鼠標移動添加監聽
}
}
else if (isVML()) {
if (event.srcElement.tagName.toLowerCase() == 'textbox') objRect = event.srcElement.parentElement;
if ((objRect.tagName == 'roundrect') && (!event.ctrlKey)) {
dragapproved = true;
eventsource = objRect;
temp1 = eventsource.style.pixelLeft;
temp2 = eventsource.style.pixelTop;
x = event.clientX;
y = event.clientY;
document.onmousemove = move;
}
}
}
//-- 畫線 --
function drawLine() {
var source; //箭頭的開始對象id
var object; //箭頭結束對象id
var sourceObj; //箭頭開始對象
var objectObj; //箭頭結束對象
var x0, y0, x1, y1; //箭頭開始位置與結束位置
var a = document.getElementsByTagName('line'); //全部箭頭對象
for (var i = 0; i < a.length; i++) {
source = a[i].getAttribute('source');
object = a[i].getAttribute('object');
if ((source != null) && (object != null)) {
sourceObj = document.getElementById(source);
objectObj = document.getElementById(object);
if ((sourceObj == null) || (objectObj == null)) continue;
//計算箭頭開始位置與結束位置
var sourceX = isSVG() ? parseFloat(sourceObj.getAttribute("x")) : sourceObj.style.pixelLeft;
var sourceY = isSVG() ? parseFloat(sourceObj.getAttribute("y")) : sourceObj.style.pixelTop;
var sourceWidth = isSVG() ? parseFloat(sourceObj.getAttribute("width")) : sourceObj.style.pixelWidth;
var sourceHeight = isSVG() ? parseFloat(sourceObj.getAttribute("height")) : sourceObj.style.pixelHeight;
var objectX = isSVG() ? parseFloat(objectObj.getAttribute("x")) : objectObj.style.pixelLeft;
var objectY = isSVG() ? parseFloat(objectObj.getAttribute("y")) : objectObj.style.pixelTop;
var objectWidth = isSVG() ? parseFloat(objectObj.getAttribute("width")) : objectObj.style.pixelWidth;
var objectHeight = isSVG() ? parseFloat(objectObj.getAttribute("height")) : objectObj.style.pixelHeight;
if (sourceX > objectX) {
if ((sourceX - objectX) <= objectWidth) {
x0 = sourceX + sourceWidth / 2;
x1 = objectX + objectWidth / 2;
if (sourceY > objectY) {
y0 = sourceY;
y1 = objectY + objectHeight;
} else {
y0 = sourceY + sourceHeight;
y1 = objectY;
}
} else {
x0 = sourceX;
x1 = objectX + objectWidth;
y0 = sourceY + sourceHeight / 2;
y1 = objectY + objectHeight / 2;
}
} else {
if ((objectX - sourceX) <= objectWidth) {
x0 = sourceX + sourceWidth / 2;
x1 = objectX + objectWidth / 2;
if (sourceY > objectY) {
y0 = sourceY;
y1 = objectY + objectHeight;
} else {
y0 = sourceY + sourceHeight;
y1 = objectY;
}
} else {
x0 = sourceX + sourceWidth;
x1 = objectX;
y0 = sourceY + sourceHeight / 2;
y1 = objectY + objectHeight / 2;
}
}
if (isSVG()) {
a[i].setAttribute("x1", x0);
a[i].setAttribute("y1", y0);
a[i].setAttribute("x2", x1);
a[i].setAttribute("y2", y1);
}
else if (isVML()) {
a[i].from = String(x0) + ',' + String(y0);
a[i].to = String(x1) + ',' + String(y1);
a[i].style.pixelLeft = x0 + 'px';
a[i].style.pixelTop = y0 + 'px';
}
if (isSVG()) {
//設定箭頭位置
var arrow = document.getElementById(source + object);
var temp = -(objectX - sourceX) / (objectY - sourceY);
if (objectY - sourceY >= 0) {
arrow.setAttribute("transform", "rotate(" + Math.atan(temp) * 180 / Math.PI + "," + x1 + "," + y1 + ") translate(" + x1 + "," + y1 + ")");
} else {
arrow.setAttribute("transform", "rotate(" + (Math.PI + Math.atan(temp)) * 180 / Math.PI + "," + x1 + "," + y1 + ") translate(" + x1 + "," + y1 + ")");
}
}
if (isVML()) {
//條件
strIF = a[i].getAttribute('title');
if ((strIF != null) && (strIF != '')) {
var id = 'if_' + source + '_' + object;
var obj = document.getElementById(id);
var left = (x0 + (x1 - x0) / 2 - 30);
var top = (y0 + (y1 - y0) / 2 - 15);
if (obj != null) {
obj.style.pixelLeft = left + 'px';
obj.style.pixelTop = top + 'px';
obj.style.left = left + 'px';
obj.style.top = top + 'px';
obj.style.display = '';
}
}
a[i].style.display = '';
}
}
}
}
function SetSel(event)//選中的矩形改變顏色
{
var flowType = '';
var flowID = 0;
var passCount = 0;
var flowColor = '';
/*
var strStart = "#00EE00";
var strEnd = "#F4A8BD";
var strOut = "#EEEEEE";
var strSelect = "#8E83F5";
*/
var strStart = "#8E83F5";
var strEnd = "#8E83F5";
var strOut = "#00EE00";
var strSelect = "#8E83F5";
var rect = isSVG() ? document.getElementsByTagName('rect') : document.getElementsByTagName('roundrect');
for (var i = 0; i < rect.length; i++) {
flowType = rect[i].getAttribute('flowtype');
if (flowType == 'start') {
flowColor = strStart;
}
else if (flowType == 'end') {
flowColor = strEnd;
}
else {
flowColor = strOut;
}
if (isSVG()) {
// rect[i].setAttribute("style", "stroke:#000000;fill:" + flowColor);
}
else if (isVML()) {
rect[i].fillcolor = flowColor;
}
}
var objRect = isSVG() ? event.target : event.srcElement;
if (isSVG()) {
if (event.target.tagName.toLowerCase() == 'tspan') {
var temp = objRect.parentNode.id.split("_");
var parantId = temp[1];
objRect = document.getElementById(parantId);
}
if (event.target.tagName.toLowerCase() == 'text') {//若是鼠標點擊當前對象是文本對象 則獲取它對應的矩形對象
var temp = objRect.id.split("_");
var parantId = temp[1];
objRect = document.getElementById(parantId);
}
}
else if (isVML()) {
if (event.srcElement.tagName.toLowerCase() == 'textbox')
objRect = event.srcElement.parentElement;
}
//步驟類型
if (isSVG()) {
try {
if (objRect.tagName == 'rect') {
//objRect.setAttribute("style", "stroke:#000000;fill:" + strSelect);
}
} catch (e) { }
}
else if (isVML()) {
try { if (objRect.tagName == 'roundrect') objRect.fillcolor = strSelect; } catch (e) { }
}
}
// 造成菜單行
function getMenuRow(s_Event, s_Html) {
var s_MenuRow = "";
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';";
if (Browser.id) {
s_MenuRow += " onclick=\"window.parent." + s_Event + ";window.parent.oPopupMenu.hide();\"";
}
else {
s_MenuRow += " onclick=\"" + s_Event + ";oPopupMenu.hide();\"";
}
s_MenuRow += "> ";
s_MenuRow += s_Html + "<\/td><\/tr><\/TABLE><\/td><\/tr>";
return s_MenuRow;
}
//-- 右鍵菜單 --
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>";
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>";
var sMenu2 = "<\/TABLE><\/td><\/tr><\/TABLE>";
var oPopupMenu = null;
MyCreatePopup();
oPopupMenu = window.createPopup();
function oPopupMenuHide(event) {
var opkey = false;
if (Browser.firefox || Browser.chrome || Browser.ie == 11) {
if (event.button == 0) {
opkey = true;
}
}
else {
if (Browser.ie) {
if (event.button == 1) {
opkey = true;
}
}
}
if (opkey) {
var obje = isSVG() ? event.target : event.srcElement;
if (obje.tagName == 'TABLE' && obje.className == 'Menu')
return false;
for (i = 0; i < 15; i++) {
obje = obje.parentNode;
if (!obje)
break;
if (obje.tagName == 'TABLE' && obje.className == 'Menu')
return false;
}
oPopupMenu.document.body.innerHTML = "";
oPopupMenu.hide();
return false;
}
}
function showContextMenu(event, type) {
oPopupMenuHide(event);
var style = "";
style = "BODY {margin:0px;border:0px}";
style += " TD {font-size:9pt;font-family:宋體,Verdana,Arial}";
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}";
style += "TD.RightBg {background-color:buttonface}";
style += "TD.MouseOver {background-color:highlight;color:highlighttext;cursor:default;}";
style += "TD.MouseOut {background-color:buttonface;color:buttontext;cursor:default;}";
style += "TD.HrShadow {background-color:buttonshadow;}";
style += "TD.HrHighLight {background-color:buttonhighlight;}";
style = "<style>" + style + "</style>";
var width = 150;
var height = 0;
var lefter = event.clientX;
var topper = event.clientY;
var oPopDocument = oPopupMenu.document;
var oPopBody = oPopupMenu.document.body;
//object
var objRect = isSVG() ? event.target : event.srcElement;
var Process_ID = null;
if (isSVG()) {
if (objRect.tagName.toLowerCase() == 'tspan')
objRect = objRect.parentNode;
Process_ID = objRect.getAttribute('table_id');
}
else if (isVML()) {
if (objRect.tagName.toLowerCase() == 'textbox')
objRect = objRect.parentElement;
Process_ID = objRect.getAttribute('table_id');
}
var sMenu = style;
switch (type) {
case 1:
sMenu += getMenuRow("viewPage(" + Process_ID + ")", "查看該節點頁面");
height += 20;
sMenu += getMenuRow("Edit_Process(" + Process_ID + ")", "步驟基本屬性");
height += 20;
sMenu += getMenuRow("set_next(" + Process_ID + ")", "在此步驟下追加");
height += 20;
sMenu += getMenuRow("set_item(" + Process_ID + ")", "可寫字段");
height += 20;
sMenu += getMenuRow("set_condition(" + Process_ID + ")", "條件設置");
height += 20;
sMenu += getMenuRow("set_user(" + Process_ID + ")", "經辦人");
height += 20;
sMenu += getMenuRow("set_dept(" + Process_ID + ")", "下一步驟設置");
height += 20;
sMenu += sMenuHr;
height += 2;
sMenu += getMenuRow("Del_Process(" + Process_ID + ")", "刪除該步驟");
height += 20;
break;
case 2:
sMenu += getMenuRow("Add_Process()", "新建步驟");
height += 20;
sMenu += getMenuRow("SavePosition()", "保存佈局");
height += 20;
sMenu += getMenuRow("Refresh()", "刷新視圖");
height += 20;
break;
}
sMenu = sMenu1 + sMenu + sMenu2;
height += 2;
if (lefter + width > document.body.clientWidth) lefter = lefter - width + 2;
if (topper + height > document.body.clientHeight) topper = topper - height + 2;
oPopupMenu.document.body.innerHTML = sMenu;
oPopupMenu.show(lefter, topper, width, height, document.body);
return false;
}
//-- 鼠標右擊 --
function DoRightClick(event) {
event = event || window.event;
pub_x = event.clientX;
pub_y = event.clientY;
SetSel(event);
var objRect = isSVG() ? event.target : event.srcElement;
if (isSVG()) {
if (event.target.tagName.toLowerCase() == 'tspan') objRect = objRect.parentNode;
if (objRect.tagName.toLowerCase() == 'rect' || objRect.tagName.toLowerCase() == 'text') {
if (event.button == 2 || event.button == 0) {
return showContextMenu(event, 1);
}
}
else {
if (objRect.tagName.toLowerCase() == 'line') {
//if (event.button == 2 || event.button == 0) return showContextMenu(event,3);
}
else {
if (event.button == 2 || event.button == 0) return showContextMenu(event, 2);
}
}
}
else if (isVML()) {
// var objRect = event.srcElement;
if (event.srcElement.tagName.toLowerCase() == 'textbox') objRect = event.srcElement.parentElement;
if (objRect.tagName.toLowerCase() == 'roundrect') {
if (event.button == 2 || event.button == 0) {
return showContextMenu(event, 1);
}
}
else {
if (objRect.tagName.toLowerCase() == 'line') {
//if (event.button == 2 || event.button == 0) return showContextMenu(event,3);
}
else {
if (event.button == 2 || event.button == 0) return showContextMenu(event, 2);
}
}
}
return false;
}
//-- 刪除流程線 --
function SetSqlDelFlow(fid) {
var strSql = '';
strSql = "delete from office_missive_flow_run where office_missive_flow_run_id='" + fid + "' ";
document.all('tbSQL').value += strSql;
}
//-- 保存佈局 --
function SavePosition() {
var id = 0;
var strSql = '';
var mf_pixel_left = 0;
var mf_pixel_top = 0;
if (isSVG()) {
a = document.getElementsByTagName('rect');
for (var i = 0; i < a.length; i++) {
table_id = eval(a[i].getAttribute('table_id'));
mf_pixel_left = a[i].getAttribute('x');
mf_pixel_top = a[i].getAttribute('y');
if (table_id > 0) {
strSql += "SetLeft=" + mf_pixel_left + ",SetTop=" + mf_pixel_top + " where ID=" + table_id + ";";
}
}
}
else if (isVML()) {
a = document.getElementsByTagName('roundrect');
for (var i = 0; i < a.length; i++) {
table_id = eval(a[i].getAttribute('table_id'));
mf_pixel_left = a[i].style.pixelLeft;
mf_pixel_top = a[i].style.pixelTop;
if (table_id > 0) {
strSql += "SetLeft=" + mf_pixel_left + ",SetTop=" + mf_pixel_top + " where ID=" + table_id + ";";
}
}
}
}
//-- 刪除流程線 --
function DelFlowRun(fid) {
if ((fid == null) || (fid == 0)) return;
SavePosition();
SetSqlDelFlow(fid);
document.all('btnSave').click();
}
//自定義createPopup
function MyCreatePopup() {
if (!window.createPopup) {
var __createPopup = function () {
var SetElementStyles = function (element, styleDict) {
var style = element.style;
for (var styleName in styleDict) style[styleName] = styleDict[styleName];
}
var eDiv = document.createElement('div');
SetElementStyles(eDiv, { 'position': 'absolute', 'top': 0 + 'px', 'left': 0 + 'px', 'width': 0 + 'px', 'height': 0 + 'px', 'zIndex': 1000, 'display': 'none', 'overflow': 'hidden' });
eDiv.body = eDiv;
var opened = false;
var setOpened = function (b) {
opened = b;
}
var getOpened = function () {
return opened;
}
var getCoordinates = function (oElement) {
var coordinates = { x: 0, y: 0 };
while (oElement) {
coordinates.x += oElement.offsetLeft;
coordinates.y += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return coordinates;
}
return { htmlTxt: '', document: eDiv, isOpen: getOpened(), isShow: false, hide: function () { SetElementStyles(eDiv, { 'top': 0 + 'px', 'left': 0 + 'px', 'width': 0 + 'px', 'height': 0 + 'px', 'display': 'none' }); eDiv.innerHTML = ''; this.isShow = false; }, show: function (iX, iY, iWidth, iHeight, oElement) {
if (!getOpened()) { document.body.appendChild(eDiv); setOpened(true); }; this.htmlTxt = eDiv.innerHTML; if (this.isShow) { this.hide(); }; eDiv.innerHTML = this.htmlTxt; var coordinates = getCoordinates(oElement); eDiv.style.left = (iX + coordinates.x) + 'px'; eDiv.style.top = (iY + coordinates.y) + 'px'; eDiv.style.width = iWidth + 'px';
eDiv.style.height = iHeight + 'px';
eDiv.style.display = 'block'; this.isShow = true;
}
}
}
window.createPopup = function () {
return __createPopup();
}
}
}