Fixiaobai
2023-10-13 e8308ddac0ba4a1f406e8f63d7e6b6f2541cb770
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>流程图-导出图片</title>
    <!--[if lt IE 9]>
      <?import namespace="v" implementation="#default#VML" ?>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../codebase/GooFlow.css" />
    <script type="text/javascript" src="../plugin/jquery.min.js"></script>
    <script type="text/javascript" src="../codebase/GooFunc.js"></script>
    <script type="text/javascript" src="../plugin/json2.js"></script>
 
    <script type="text/javascript" src="../codebase/GooFlow.js"></script>
    <script type="text/javascript" src="../codebase/GooFlow.color.js"></script>
 
    <script type="text/javascript" src="../plugin/promise.min.js"></script>
    <script type="text/javascript" src="../plugin/html2canvas.min.js"></script>
    <!--[if lte IE 11]-->
    <script type="text/javascript" src="../plugin/canvg.js"></script>
    <!--[endif]-->
    <script type="text/javascript" src="../codebase/GooFlow.export.js"></script>
 
    <script type="text/javascript">
      var property = {
        width: 1200,
        height: 540,
        toolBtns: [
          'start round mix',
          'end round',
          'task',
          'node',
          'chat',
          'state',
          'plug',
          'join',
          'fork',
          'complex mix'
        ],
        haveHead: true,
        headLabel: true,
        headBtns: ['new', 'open', 'save', 'undo', 'redo', 'reload', 'print'], //如果haveHead=true,则定义HEAD区的按钮
        haveTool: true,
        haveGroup: true,
        useOperStack: true
      }
      var remark = {
        cursor: '选择指针',
        direct: '结点连线',
        start: '入口结点',
        end: '结束结点',
        task: '任务结点',
        node: '自动结点',
        chat: '决策结点',
        state: '状态结点',
        plug: '附加插件',
        fork: '分支结点',
        join: '联合结点',
        complex: '复合结点',
        group: '组织划分框编辑开关'
      }
      var jsondata = {
        title: 'newFlow_1',
        nodes: {
          demo_node_1: {
            name: '开始',
            left: 42,
            top: 38,
            type: 'start round mix',
            width: 26,
            height: 26,
            alt: true
          },
          demo_node_2: {
            name: '结束',
            left: 797,
            top: 42,
            type: 'end round mix',
            width: 26,
            height: 26,
            alt: true
          },
          demo_node_3: {
            name: '入职申请',
            left: 155,
            top: 39,
            type: 'task',
            width: 104,
            height: 26,
            marked: true,
            alt: true
          },
          demo_node_4: {
            name: '人力审批',
            left: 364,
            top: 42,
            type: 'task',
            width: 104,
            height: 26,
            alt: true
          },
          demo_node_8: {
            name: '工资判断',
            left: 571,
            top: 43,
            type: 'node',
            width: 104,
            height: 26,
            alt: true
          },
          demo_node_9: {
            name: '经理终审',
            left: 559,
            top: 141,
            type: 'task',
            width: 104,
            height: 26,
            alt: true
          }
        },
        lines: {
          demo_line_5: {
            type: 'sl',
            from: 'demo_node_3',
            to: 'demo_node_4',
            name: '提交申请'
          },
          demo_line_6: {
            type: 'sl',
            from: 'demo_node_1',
            to: 'demo_node_3',
            name: ''
          },
          demo_line_7: {
            type: 'tb',
            M: 18.5,
            from: 'demo_node_4',
            to: 'demo_node_3',
            name: '不通过'
          },
          demo_line_10: {
            type: 'sl',
            from: 'demo_node_4',
            to: 'demo_node_8',
            name: '通过'
          },
          demo_line_11: {
            type: 'tb',
            M: 157,
            from: 'demo_node_9',
            to: 'demo_node_4',
            name: '不接受'
          },
          demo_line_12: {
            type: 'sl',
            from: 'demo_node_8',
            to: 'demo_node_9',
            name: '大于8000'
          },
          demo_line_13: {
            type: 'sl',
            from: 'demo_node_8',
            to: 'demo_node_2',
            name: '小于8000'
          },
          demo_line_14: {
            marked: true,
            type: 'sl',
            from: 'demo_node_9',
            to: 'demo_node_2',
            name: '接受'
          }
        },
        areas: {
          '1497581247380': {
            name: '审议会',
            left: 451,
            top: 110,
            color: 'red',
            width: 226,
            height: 108,
            alt: true
          }
        },
        initNum: 16
      }
      var demo
      $(function() {
        demo = $.createGooFlow($('#demo'), property)
        demo.setNodeRemarks(remark)
        demo.loadData(jsondata)
 
        //以下是测试导出图片功能
        //            demo.onPrintClick=function(){
        //                //0.添加临时元素
        //                $("body").append('<div id="demo_export" style="position:absolute;top:0;left:0;z-index:-1;width:0px;height:0px;overflow:hidden">'
        //                    +'<div style="color:#15428B;position:absolute;left:0;right:0;width:1160px;height:507px;overflow:hidden;float:none;" class="GooFlow GooFlow_work"></div>'
        //                    +'</div>');
        //
        //                //1.先COPY节点和区块的内容
        //                var inner = $("#demo").find(".GooFlow_work_inner");
        //                var divCanvas = $("#demo_export").children("div:eq(0)");
        //                //复制节点的内容
        //                inner.children("div").each(function(i){
        //                    var item=$(this);
        //                    if(item.hasClass("GooFlow_item")){
        //                        item.clone().removeAttr("id").css("position","absolute").appendTo(divCanvas);
        //                    }else if(item.hasClass("GooFlow_work_group")){
        //                        item.clone().removeAttr("id").css("position","absolute")
        //                            .attr("xmlns",'http://www.w3.org/1999/xhtml').appendTo(divCanvas);
        //                    }
        //                });
        //                html2canvas(divCanvas[0], {
        //                    allowTaint: false, taintTest: false,
        //                    onrendered: function(canvas) {
        //                        //2.在回调方法中,COPY连线内容
        //                        //造出临时的IMAGE
        //                        var context = canvas.getContext('2d');//取得画布的2d绘图上下文
        //                        context.save();
        //                        var strSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="1160" height="507">'
        //                                +'<defs><style type="text/css">text{font-size:14px;line-height:1.42857143;'
        //                                +'font-family:"Microsoft Yahei", "Helvetica Neue", Helvetica, Hiragino Sans GB, WenQuanYi Micro Hei, Arial, sans-serif;'
        //                                +'}</style></defs>' + window.$("<svg>").append(window.$("#draw_demo").clone()).html() +'</svg>'; //COPY连线内容
        //                        var image = null;
        //                        if(!!window.ActiveXObject || "ActiveXObject" in window){//当为IE11及以下版本浏览器时,使用Canvg第三方工具
        //                            image = document.createElement('canvas');
        //                            canvg(image, strSvg);
        //                        }else{
        //                            var image = new Image();
        //                            image.src='data:image/svg+xml,'+ encodeURIComponent(strSvg);
        //                        }
        //                        var tempFunc=function(){
        //                           context.drawImage(image, 0, 0);
        //                            //清除不需要的临时DOM
        //                            $("#demo_export").empty().remove();
        //                            try{
        //                                var blob = canvas.msToBlob();
        //                                //alert("blob2");
        //                                navigator.msSaveBlob(blob, "prettyImage.png");
        //                            }
        //                            catch(e){
        //                                //生成一个下载链接并点击
        //                                var a = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
        //                                a.href = canvas.toDataURL('image/png');  //将画布内的信息导出为png图片数据
        //                                a.download = "prettyImage.png";  //设定下载名称
        //                                document.body.appendChild(a);
        //                                a.click(); //点击触发下载
        //                                document.body.removeChild(a);
        //                            }
        //                        }
        //
        //                        if(image.complete|| (!!window.ActiveXObject || "ActiveXObject" in window)) { // 如果图片已经存在于浏览器缓存,直接调用回调函数
        //                            console.log("aaa");
        //                            tempFunc();
        //                            return;// 直接返回,不用再处理onload事件
        //                        }
        //                        image.onload=function(){
        //                            console.log("ccc");
        //                            tempFunc();
        //                        };
        //                    },
        //                    width: 1160,
        //                    height: 507
        //                });
        //            }
        demo.onPrintClick = function() {
          demo.exportDiagram('fuckyou')
        }
        //导出图片功能 END
      })
    </script>
  </head>
  <body>
    <div id="demo" style="margin:10px"></div>
    <!--demo.$workArea.width(),demo.$workArea.height(),-->
    <div id="fff"></div>
  </body>
</html>