maplayout.js
4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
layui.define(["jquery", "layer", "bootstrap"],
function (exports) {
var $ = layui.jquery;
var layer = layui.layer;
//初始化设计流程器
$.fn.flowdesign = function (options) {
var $frmpreview = $(this);
if (!$frmpreview.attr('id')) {
return false;
}
$frmpreview.html("");
var defaultcnf = {
width: 500,
height: 400,
haveHead: false,
initLabelText: "任务地图",
haveTool: true,
headLabel: true,
headBtns: ["big", "small", "reset"],
toolBtns: [
],
haveGroup: true,
useOperStack: false,
};
if (options != undefined) {
$.extend(defaultcnf, options);
}
var flowPanel = $.createGooFlow($(this), defaultcnf);
flowPanel.setNodeRemarks({
group: "编辑",
user_cangchuqu: "仓储区",
user_zhangaiqu: "障碍区",
user_shengchanxian: "生产线",
user_yunxingqu: "运行区",
user_chongdianzhuang1: "充电桩",
user_tingchequ: "停车区",
user_diantiqu_xz: "电梯区",
user_tishengjiqu_xz: "对接区",
user_quliaoqu: "取料区",
user_fangliaoqu: "放料区",
user_rfid_yxd_0000: "RFID",
user_fastmode: "快速模式",
});
flowPanel.setHeadToolsRemarks({
undo: "撤销",
redo: "重做",
big: "放大",
small: "缩小",
reset: "还原",
switch: "隐藏RFID",
info: "显示未编辑的RFID"
});
if (options != undefined
&& options.flowcontent != undefined
&& options.flowcontent != null) { //加载内容
flowPanel.loadData(options.flowcontent);
}
flowPanel.exportDataEx = function () {
var data = flowPanel.exportData();
return data;
}
flowPanel.onItemDbClick = function (id, type) {
var obj = flowPanel.getItemInfo(id, type);
if (type == "area" && obj.color.indexOf("user_rfid") > -1) {
options.OpenNode(id, obj);
}
else {
return false;
}
}
var xyHtml = '<div style="position:absolute;left:450px;margin-top:-30px;padding:3px;z-index:1000;line-height:15px;">';
xyHtml += '<div style="display: inline-block;"><span id = "xyHtml"></span></div></div>';
$frmpreview.append(xyHtml);
flowPanel.$workArea.on('mousemove', function (e) {
if (!e) e = window.event;
var X, Y;
var ev = _mouseP(e), t = _elCsys(this);
X = ev.x - t.left + this.parentNode.scrollLeft;
Y = ev.y - t.top + this.parentNode.scrollTop;
var new_X, new_Y;
new_X = Math.floor(X / 30) * 30;
new_Y = Math.floor(Y / 30) * 30;
if ($("#xyHtml") != undefined) {
$("#xyHtml").html("【" + new_X + "," + new_Y + "】");
}
});
return flowPanel;
}
exports('taskdesign/maplayout');
});
function _elCsys(dom) {
var t = dom.offsetTop;
var l = dom.offsetLeft;
dom = dom.offsetParent;
while (dom) {
t += dom.offsetTop;
l += dom.offsetLeft;
dom = dom.offsetParent;
}
return { top: t, left: l };
}
//兼容各种浏览器的,获取鼠标真实位置
function _mouseP(ev) {
if (!ev) ev = window.event;
if (ev.pageX || ev.pageY) {
return { x: ev.pageX, y: ev.pageY };
}
return {
x: ev.clientX + document.documentElement.scrollLeft - document.body.clientLeft,
y: ev.clientY + document.documentElement.scrollTop - document.body.clientTop
};
}