GooFlow.js 202 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 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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689
/**
 * Gooflow在线流程图设计器
 * Version: 1.3.2
 * Copyright: foolegg126(sdlddr)
 */


layui.define("jquery",
    function (exports) {

        var jQuery = layui.jquery;
        var $ = layui.jquery;

        var pixWidth = 30;
        //预先定义几个公用方法
        //获取一个DIV的绝对坐标的功能函数,即使是非绝对定位,一样能获取到
        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
            };
        }
        //计算两个结点间要连折线的话,连线的所有坐标
        function calcPolyPoints(n1, n2, type, M, scale) {
            if (!scale) scale = 1.0;
            var N1 = { left: n1.left * scale, top: n1.top * scale, width: n1.width * scale, height: n1.height * scale };
            var N2 = { left: n2.left * scale, top: n2.top * scale, width: n2.width * scale, height: n2.height * scale };
            M = M * scale;
            //开始/结束两个结点的中心
            var SP = { x: N1.left + N1.width / 2, y: N1.top + N1.height / 2 };
            var EP = { x: N2.left + N2.width / 2, y: N2.top + N2.height / 2 };
            var m1 = [], m2 = [], sp, ep;
            //如果是允许中段可左右移动的折线,则参数M为可移动中段线的X坐标
            //粗略计算起始点
            sp = [SP.x, SP.y];
            ep = [EP.x, EP.y];
            if (type === "lr") {
                //粗略计算2个中点
                m1 = [M, SP.y];
                m2 = [M, EP.y];
                //再具体分析修改开始点和中点1
                if (m1[0] > N1.left && m1[0] < N1.left + N1.width) {
                    m1[1] = (SP.y > EP.y ? N1.top : N1.top + N1.height);
                    sp[0] = m1[0]; sp[1] = m1[1];
                }
                else {
                    sp[0] = (m1[0] < N1.left ? N1.left : N1.left + N1.width)
                }
                //再具体分析中点2和结束点
                if (m2[0] > N2.left && m2[0] < N2.left + N2.width) {
                    m2[1] = (SP.y > EP.y ? N2.top + N2.height : N2.top);
                    ep[0] = m2[0]; ep[1] = m2[1];
                }
                else {
                    ep[0] = (m2[0] < N2.left ? N2.left : N2.left + N2.width)
                }
            }
            //如果是允许中段可上下移动的折线,则参数M为可移动中段线的Y坐标
            else if (type === "tb") {
                //粗略计算2个中点
                m1 = [SP.x, M];
                m2 = [EP.x, M];
                //再具体分析修改开始点和中点1
                if (m1[1] > N1.top && m1[1] < N1.top + N1.height) {
                    m1[0] = (SP.x > EP.x ? N1.left : N1.left + N1.width);
                    sp[0] = m1[0]; sp[1] = m1[1];
                }
                else {
                    sp[1] = (m1[1] < N1.top ? N1.top : N1.top + N1.height)
                }
                //再具体分析中点2和结束点
                if (m2[1] > N2.top && m2[1] < N2.top + N2.height) {
                    m2[0] = (SP.x > EP.x ? N2.left + N2.width : N2.left);
                    ep[0] = m2[0]; ep[1] = m2[1];
                }
                else {
                    ep[1] = (m2[1] < N2.top ? N2.top : N2.top + N2.height);
                }
            }
            return { start: sp, m1: m1, m2: m2, end: ep };
        }
        //计算两个结点间要连直线的话,连线的开始坐标和结束坐标
        function calcStartEnd(n1, n2, scale) {
            if (!scale) scale = 1.0;
            var X_1, Y_1, X_2, Y_2;
            //X判断:
            var x11 = n1.left * scale, x12 = n1.left * scale + n1.width * scale, x21 = n2.left * scale, x22 = n2.left * scale + n2.width * scale;
            //结点2在结点1左边
            if (x11 >= x22) {
                X_1 = x11; X_2 = x22;
            }
            //结点2在结点1右边
            else if (x12 <= x21) {
                X_1 = x12; X_2 = x21;
            }
            //结点2在结点1水平部分重合
            else if (x11 <= x21 && x12 >= x21 && x12 <= x22) {
                X_1 = (x12 + x21) / 2; X_2 = X_1;
            }
            else if (x11 >= x21 && x12 <= x22) {
                X_1 = (x11 + x12) / 2; X_2 = X_1;
            }
            else if (x21 >= x11 && x22 <= x12) {
                X_1 = (x21 + x22) / 2; X_2 = X_1;
            }
            else if (x11 <= x22 && x12 >= x22) {
                X_1 = (x11 + x22) / 2; X_2 = X_1;
            }

            //Y判断:
            var y11 = n1.top * scale, y12 = n1.top * scale + n1.height * scale, y21 = n2.top * scale, y22 = n2.top * scale + n2.height * scale;
            //结点2在结点1上边
            if (y11 >= y22) {
                Y_1 = y11; Y_2 = y22;
            }
            //结点2在结点1下边
            else if (y12 <= y21) {
                Y_1 = y12; Y_2 = y21;
            }
            //结点2在结点1垂直部分重合
            else if (y11 <= y21 && y12 >= y21 && y12 <= y22) {
                Y_1 = (y12 + y21) / 2; Y_2 = Y_1;
            }
            else if (y11 >= y21 && y12 <= y22) {
                Y_1 = (y11 + y12) / 2; Y_2 = Y_1;
            }
            else if (y21 >= y11 && y22 <= y12) {
                Y_1 = (y21 + y22) / 2; Y_2 = Y_1;
            }
            else if (y11 <= y22 && y12 >= y22) {
                Y_1 = (y11 + y22) / 2; Y_2 = Y_1;
            }
            return { "start": [X_1, Y_1], "end": [X_2, Y_2] };
        }
        //初始化折线中段的X/Y坐标,mType='rb'时为X坐标,mType='tb'时为Y坐标
        function getMValue(n1, n2, mType, scale) {
            if (!scale) scale = 1.0;
            if (mType === "lr") {
                return (n1.left * scale + n1.width * scale / 2 + n2.left * scale + n2.width * scale / 2) / 2;
            }
            else if (mType === "tb") {
                return (n1.top * scale + n1.height * scale / 2 + n2.top * scale + n2.height * scale / 2) / 2;
            }
        }
        //构造类:
        var GooFlow = function (selector, property) {
            //console.log('Your browser\'s navigator.userAgent is:', navigator.userAgent);
            if (navigator.userAgent.indexOf("MSIE 8.0") > 0 || navigator.userAgent.indexOf("MSIE 7.0") > 0 || navigator.userAgent.indexOf("MSIE 6.0") > 0)
                GooFlow.prototype.useSVG = "";
            else GooFlow.prototype.useSVG = "1";
            //初始化区域图的对象
            this.$bgDiv = $(selector);//最父框架的DIV
            this.$bgDiv.addClass("GooFlow");
            this.$id = this.$bgDiv.attr("id") || 'GooFlow_' + new Date().getTime();
            if (property.colors && typeof property.colors === 'object') {
                $.extend(GooFlow.color, property.colors);
            }
            this.$bgDiv.css("color", GooFlow.color.font);
            if (GooFlow.color.main) {
                this.$bgDiv.append('<style>.GooFlow_tool_btndown{background-color:' + GooFlow.color.main + '}</style>');
            }
            var width = (property.width || this.$bgDiv.width());
            var height = (property.height || this.$bgDiv.height());
            this.$bgDiv.css({ width: width + "px", height: height + "px" });
            this.$tool = null;//左侧工具栏对象
            this.$head = null;//顶部标签及工具栏按钮
            this.$title = "newFlow_1";//流程图的名称
            this.$nowType = "cursor";//当前要绘制的对象类型
            this.$fastMode = false;//快速模式
            this.$lineData = {};
            this.$lineCount = 0;
            this.$nodeData = {};
            this.$nodeCount = 0;
            this.$areaData = {};
            this.$areaCount = 0;
            this.$lineDom = {};
            this.$nodeDom = {};
            this.$areaDom = {};
            this.$max = property.initNum || 1;//计算默认ID值的起始SEQUENCE
            this.$focus = "";//当前被选定的结点/转换线ID,如果没选中或者工作区被清空,则为""
            //this.$cursor="default";//鼠标指针在工作区内的样式
            this.$editable = false;//工作区是否可编辑
            this.$deletedItem = {};//在流程图的编辑操作中被删除掉的元素ID集合,元素ID为KEY,元素类型(node,line.area)为VALUE
            this.$workExtendStep = 200;//在自动/手动扩展可编辑区时,一次扩展后宽/高增加多少像素
            this.$scale = 1.00;//工作区内容的缩放比例,从0.1至无穷大,初始默认为1
            var headHeight = 0;
            var tmp = "", titleText;
            if (property.haveHead) {
                tmp = "<div class='GooFlow_head' " + (GooFlow.color.main ? "style='border-bottom-color:" + GooFlow.color.main + "'" : "") + ">";
                if (property.headLabel) {
                    tmp += "<label title='" + (property.initLabelText || "newFlow_1") + "' "
                        + (GooFlow.color.main ? "style='background:" + GooFlow.color.main + "'" : "") + ">"
                        + (property.initLabelText || "newFlow_1") + "</label>";
                }
                if (property.headBtns)
                    for (var x = 0; x < property.headBtns.length; ++x) {
                        if (!property.useOperStack && (property.headBtns[x] === 'undo' || property.headBtns[x] === 'redo')) continue;
                        titleText = GooFlow.remarks.headBtns[property.headBtns[x]] ? " title='" + GooFlow.remarks.headBtns[property.headBtns[x]] + "'" : "";
                        tmp += "<a href='javascript:void(0)' class='GooFlow_head_btn'" + titleText + "><i class='ico_" + property.headBtns[x] + "'></i></a>"
                    }
                tmp += "</div>";
                this.$head = $(tmp);
                this.$bgDiv.append(this.$head);
                if (property.headBtns) {
                    this.$head.find(".ico_undo").parent().addClass("a_disabled");
                    this.$head.find(".ico_redo").parent().addClass("a_disabled");
                    //以下是当工具栏按钮被点击时触发的事件自定义(虚函数),格式为function(),因为可直接用THIS操作对象本身,不用传参;用户可自行重定义:
                    this.onBtnNewClick = null;//新建流程图按钮被点中
                    this.onBtnOpenClick = null;//打开流程图按钮定义
                    this.onBtnSaveClick = null;//保存流程图按钮定义
                    this.onFreshClick = null;//重载流程图按钮定义
                    this.onPrintClick = null;//打印流程图按钮定义
                    this.$headBtnEvents = property.headBtnEvents;//用户对头部栏另行自定义类型按钮的事件绑定json集合,key为按钮类型名,value为方法定义
                    this.$head.on("click", { inthis: this }, function (e) {
                        if (!e) e = window.event;
                        var tar = e.target;
                        if (tar.tagName === "DIV" || tar.tagName === "SPAN") return;
                        else if (tar.tagName === "A") tar = tar.childNodes[0];
                        var This = e.data.inthis, Class = $(tar).attr("class");
                        //定义顶部操作栏按钮的事件
                        switch (Class) {
                            case "ico_new": if (This.onBtnNewClick !== null) This.onBtnNewClick(); break;
                            case "ico_open": if (This.onBtnOpenClick !== null) This.onBtnOpenClick(); break;
                            case "ico_save": if (This.onBtnSaveClick !== null) This.onBtnSaveClick(); break;
                            case "ico_undo": This.undo(); break;
                            case "ico_redo": This.redo(); break;
                            case "ico_reload": if (This.onFreshClick !== null) This.onFreshClick(); break;
                            case "ico_print": if (This.onPrintClick !== null) This.onPrintClick(); break;
                            case "ico_ReCalibrateData": if (This.ReCalibrateData !== null) This.ReCalibrateData(); break;

                            default:
                                if (typeof This.$headBtnEvents !== 'undefined' && typeof This.$headBtnEvents[Class] === 'function') {
                                    This.$headBtnEvents[Class]();
                                }
                        }
                    });
                }
                headHeight = 28;
            }
            var toolWidth = 0;
            //修改工具条背景色
            if (property.haveTool) {
                this.$bgDiv.append("<div class='GooFlow_tool'" + (property.haveHead ? "" : " style='margin-top:3px;'") + "><div style='height:" + (height - headHeight - (property.haveHead ? 5 : 8)) + "px; background-color:rgba(217,217,217,0.1)' class='GooFlow_tool_div'></div></div>");
                this.$tool = this.$bgDiv.find(".GooFlow_tool div");
                //加入绘图工具按钮
                //加入区域划分框工具开关按钮
                if (property.haveGroup) {
                    var titleGroup = GooFlow.remarks.toolBtns["group"] ? " title='" + GooFlow.remarks.toolBtns["group"] + "'" : "";
                    this.$tool.append("<a href='javascript:void(0)'" + titleGroup + " type='group' class='GooFlow_tool_btn' id='" + this.$id + "_btn_group' style='margin-top:20px;border: solid 1px gray;'><i class='ico_group'/><i style='float:left;margin-left:30px;margin-top:-20px;width: 65px;font-size:16px;text-align:left;'></i></a>");
                }

                if (property.toolBtns && property.toolBtns.length > 0) {
                    tmp = "<span/>";
                    for (var i = 0; i < property.toolBtns.length; ++i) {
                        var tmpType = property.toolBtns[i].split(" ")[0];
                        titleText = GooFlow.remarks.toolBtns[tmpType] ? " title='" + GooFlow.remarks.toolBtns[tmpType] + "'" : '';
                        //加入自定义按钮//不使用图标,使用背景图片
                        tmp += "<a href='javascript:void(0)'" + titleText + " type='" + property.toolBtns[i] + "' id='" + this.$id + "_btn_" + tmpType + "' class='GooFlow_tool_btn ico_" + property.toolBtns[i] + "' style='background-size:100%;margin-top:20px;'><i style='float:left;margin-left:30px;width: 65px;font-size:16px;text-align:left;'></i></a>";
                    }
                    this.$tool.append(tmp);
                }

                toolWidth = 310;
                this.$nowType = "cursor";
                //绑定各个按钮的点击事件
                this.$tool.on("click", { inthis: this }, function (e) {
                    if (!e) e = window.event;
                    var tar;
                    switch (e.target.tagName) {
                        case "SPAN": return false;
                        case "DIV": return false;
                        case "I": tar = e.target.parentNode; break;
                        case "A": tar = e.target;
                    }
                    var type = $(tar).attr("type");
                    e.data.inthis.switchToolBtn(type);
                    return false;
                });
                this.$editable = true;//只有具有工具栏时可编辑
            }

            //确定工作区在设计器中的位置、宽高
            width = width - toolWidth - 9;
            height = height - headHeight - (property.haveHead ? 5 : 8);
            this.$bgDiv.append("<div class='GooFlow_work' style='" + (property.haveHead ? "top:28px;" : "") + (property.haveTool ? "left:114px" : "") + "'></div>");
            this.$workArea = $("<div class='GooFlow_work_inner' style='width:" + width + "px;height:" + height + "px'></div>")
                .attr({ "unselectable": "on", "onselectstart": 'return false', "onselect": 'document.selection.empty()' });
            this.$bgDiv.children(".GooFlow_work").append(this.$workArea);
            //计算工作区相对GooFlow父框架的绝对定位运算值,并保存
            this.t = { top: property.haveHead ? 28 : 3, left: property.haveTool ? 114 : 3 };

            //绑定工作区事件
            this.$workArea.on("click", { inthis: this }, function (e) {
                if (!e) e = window.event;
                var This = e.data.inthis;
                var type = This.$nowType;
                if (type === "cursor") {
                    var tar = $(e.target);
                    var n = tar.prop("tagName");
                    if (n === "svg" || (n === "DIV" && tar.prop("class").indexOf("GooFlow_work") > -1) || n === "LABEL") {
                        console.log(n);
                        if (This.$lineOper && This.$lineOper.data("tid")) {
                            This.focusItem(This.$lineOper.data("tid"), false);
                        }
                        else { This.blurItem(); }
                    }
                    return;
                }
                else if (type === "direct" || type === "dashed" || type === "group") return;
                if (!This.$editable) return;
                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;

                if (This.$nowType.indexOf("user_rfid") > -1) {
                    //RFID点必须放在运行区、放料区、取料区、停车区、电梯区、对接区中
                    var _in = false;
                    for (var i in This.$areaData) {
                        if (This.$areaData[i].color == "user_yunxingqu" || This.$areaData[i].color == "user_fangliaoqu" || This.$areaData[i].color == "user_quliaoqu" || This.$areaData[i].color == "user_tingchequ" || This.$areaData[i].color.indexOf("user_diantiqu") > -1 || This.$areaData[i].color.indexOf("user_tishengjiqu") > -1) {
                            var json1 = {
                                Left: Math.floor(X / pixWidth) * pixWidth,
                                Top: Math.floor(Y / pixWidth) * pixWidth,
                                Width: pixWidth,
                                Height: pixWidth,
                            };
                            var json2 = {
                                Left: This.$areaData[i].left,
                                Top: This.$areaData[i].top,
                                Width: This.$areaData[i].width,
                                Height: This.$areaData[i].height,
                            };

                            if (This.CheckPut(json1, json2) == "equal" || This.CheckPut(json1, json2) == "in") {
                                _in = true;
                                break;
                            }
                        }
                    }

                    if (_in) {
                        //RFID点不能重合
                        for (var i in This.$areaData) {
                            if (This.$areaData[i].color.indexOf("user_rfid") > -1) {
                                var json1 = {
                                    Left: Math.floor(X / pixWidth) * pixWidth,
                                    Top: Math.floor(Y / pixWidth) * pixWidth,
                                    Width: pixWidth,
                                    Height: pixWidth,
                                };
                                var json2 = {
                                    Left: This.$areaData[i].left,
                                    Top: This.$areaData[i].top,
                                    Width: This.$areaData[i].width,
                                    Height: This.$areaData[i].height,
                                };

                                if (This.CheckPut(json1, json2) == "equal" || This.CheckPut(json1, json2) == "in") {
                                    _in = false;
                                    console.log("RFID点不能重合!");
                                    break;
                                }
                            }
                        }
                    }

                    if (_in) {
                        This.addArea(new Date().getTime().toString(),
                            { name: name, left: X / This.$scale, top: Y / This.$scale, color: This.$nowType, width: pixWidth, height: pixWidth });
                    }
                    else {
                        console.log("RFID点必须放置在运行区,放料区,取料区,停车区上!");
                    }
                }
                else {
                    //增加区域时,判断是否重合
                    var _flag = false;
                    if (This.$nowType == "user_group") {
                        var _in = false;
                        var _out = true;

                        for (var i in This.$areaData) {
                            var json1 = {
                                Left: Math.floor(X / pixWidth) * pixWidth,
                                Top: Math.floor(Y / pixWidth) * pixWidth,
                                Width: pixWidth,
                                Height: pixWidth,
                            };
                            var json2 = {
                                Left: This.$areaData[i].left,
                                Top: This.$areaData[i].top,
                                Width: This.$areaData[i].width,
                                Height: This.$areaData[i].height,
                            };

                            if (This.$areaData[i].color == "user_yunxingqu") {
                                if (This.CheckPut(json1, json2) == "equal" || This.CheckPut(json1, json2) == "in") {
                                    _in = true;
                                }
                            }
                            else {
                                if (This.$areaData[i].color == "user_group") {
                                    if (This.CheckPut(json1, json2) !== "out" || This.CheckPut(json2, json1) !== "out") {
                                        _out = false;
                                        break;
                                    }
                                }
                            }
                        }

                        if (_in && _out) {
                            _flag = true;
                        }

                        if (!_flag) {
                            console.log("通道分组 必须放在运行区,且不能重合!");
                        }
                    }
                    else {
                        var _out = true;

                        for (var i in This.$areaData) {
                            var json1 = {
                                Left: Math.floor(X / pixWidth) * pixWidth,
                                Top: Math.floor(Y / pixWidth) * pixWidth,
                                Width: pixWidth,
                                Height: pixWidth,
                            };
                            var json2 = {
                                Left: This.$areaData[i].left,
                                Top: This.$areaData[i].top,
                                Width: This.$areaData[i].width,
                                Height: This.$areaData[i].height,
                            };

                            if (This.CheckPut(json1, json2) !== "out") {
                                _out = false;
                                break;
                            }
                        }

                        if (_out) {
                            _flag = true;
                        }

                        if (!_flag) {
                            console.log("所有区域模块互相干涉,不能重叠!");
                        }
                    }

                    if (_flag) {
                        var name = "area_" + This.$max;
                        if (This.$nowType == "user_cangchuqu") {
                            name = "仓储区";
                        }
                        if (This.$nowType == "user_zhangaiqu") {
                            name = "障碍区";
                        }
                        if (This.$nowType == "user_shengchanxian") {
                            name = "线体区";
                        }
                        if (This.$nowType == "user_yunxingqu") {
                            name = "运行区";
                        }
                        if (This.$nowType.indexOf("user_chongdianzhuang") > -1) {
                            name = "充电桩";
                        }
                        if (This.$nowType == "user_tingchequ") {
                            name = "停车区" + This.$max;
                        }
                        if (This.$nowType.indexOf("user_diantiqu") > -1) {
                            name = "电梯区" + This.$max;
                        }
                        if (This.$nowType.indexOf("user_tishengjiqu") > -1) {
                            name = "对接区" + This.$max;
                        }
                        if (This.$nowType == "user_fangliaoqu") {
                            name = null;
                            //name = "放料区" + This.$max;
                        }
                        if (This.$nowType == "user_quliaoqu") {
                            name = "取料区" + This.$max;
                        }
                        This.addArea(new Date().getTime().toString(),
                            { name: name, left: X / This.$scale, top: Y / This.$scale, color: This.$nowType, width: pixWidth, height: pixWidth });
                        //非充电桩的区域模块,添加完成后立刻切换到编辑模式
                        if (This.$nowType !== "user_chongdianzhuang1" && This.$nowType !== "user_chongdianzhuang0" && !This.$fastMode) {
                            This.switchToolBtn("group");
                        }
                    }
                }

                This.$max++;
            });

            this.$draw = null;//画矢量线条的容器
            this._initDraw("draw_" + this.$id, width, height);
            this.$group = null;//画区域块(泳道)的容器
            if (property.haveGroup)
                this._initGroup(width, height);
            //为了节点而增加的一些集体绑定
            this._initWorkForNode();

            //一些基本的元素事件,这些事件可直接通过this访问对象本身
            //当操作某个单元(结点/线)被由不选中变成选中时,触发的方法,返回FALSE可阻止选中事件的发生
            //格式function(id,type):id是单元的唯一标识ID,type是单元的种类,有"node","line"两种取值,"area"不支持被选中
            this.onItemFocus = null;
            //当操作某个单元(结点/线)被由选中变成不选中时,触发的方法,返回FALSE可阻止取消选中事件的发生
            //格式function(id,type):id是单元的唯一标识ID,type是单元的种类,有"node","line"两种取值,"area"不支持被取消选中
            this.onItemBlur = null;
            //当用重色标注某个结点/转换线时触发的方法,返回FALSE可阻止重定大小/造型事件的发生
            //格式function(id,type,mark):id是单元的唯一标识ID,type是单元类型("node"结点,"line"转换线),mark为布尔值,表示是要标注TRUE还是取消标注FALSE
            this.onItemMark = null;
            //当操作某个单元(结点/线/区域块)被双击时,触发的方法,返回FALSE可阻止取消原来双击事件(双击后直接编辑)的发生
            //格式function(id,type):id是单元的唯一标识ID,type是单元的种类,有"node","line","area"三种取值
            this.onItemDbClick = null;
            //当操作某个单元(结点/线/区域块)被右键点击时,触发的方法,返回FALSE可阻止取消原来右击事件(一般是浏览器默认的右键菜单)的发生
            //格式function(id,type):id是单元的唯一标识ID,type是单元的种类,有"node","line","area"三种取值
            this.onItemRightClick = null;

            if (this.$editable) {
                //绑定当结点/线/分组块的一些操作事件,这些事件可直接通过this访问对象本身
                //当操作某个单元(结点/线/分组块)被添加时,触发的方法,返回FALSE可阻止添加事件的发生
                //格式function(id,type,json):id是单元的唯一标识ID,type是单元的种类,有"node","line","area"三种取值,json即addNode,addLine或addArea方法的第二个传参json.
                this.onItemAdd = null;
                //当操作某个单元(结点/线/分组块)被删除时,触发的方法,返回FALSE可阻止删除事件的发生
                //格式function(id,type):id是单元的唯一标识ID,type是单元的种类,有"node","line","area"三种取值
                this.onItemDel = null;
                //当操作某个单元(结点/分组块)被移动时,触发的方法,返回FALSE可阻止移动事件的发生
                //格式function(id,type,left,top):id是单元的唯一标识ID,type是单元的种类,有"node","area"两种取值,线line不支持移动,left是新的左边距坐标,top是新的顶边距坐标
                this.onItemMove = null;
                //当操作某个单元(结点/线/分组块)被重命名时,触发的方法,返回FALSE可阻止重命名事件的发生
                //格式function(id,name,type):id是单元的唯一标识ID,type是单元的种类,有"node","line","area"三种取值,name是新的名称
                this.onItemRename = null;
                //当操作某个单元(结点/分组块)被重定义大小或造型时,触发的方法,返回FALSE可阻止重定大小/造型事件的发生
                //格式function(id,type,width,height):id是单元的唯一标识ID,type是单元的种类,有"node","line","area"三种取值;width是新的宽度,height是新的高度
                this.onItemResize = null;
                //当移动某条折线中段的位置,触发的方法,返回FALSE可阻止重定大小/造型事件的发生
                //格式function(id,M):id是单元的唯一标识ID,M是中段的新X(或Y)的坐标
                this.onLineMove = null;
                //当变换某条连接线的类型,触发的方法,返回FALSE可阻止重定大小/造型事件的发生
                //格式function(id,type):id是单元的唯一标识ID,type是连接线的新类型,"sl":直线,"lr":中段可左右移动的折线,"tb":中段可上下移动的折线
                this.onLineSetType = null;
                //当变换某条连接线的端点变更连接的结点时,触发的方法,返回FALSE可阻止重定大小/造型事件的发生
                //格式function(id,newStart,newEnd):id是连线单元的唯一标识ID,newStart,newEnd分别是起始结点的ID和到达结点的ID
                this.onLinePointMove = null;
                this._initExpendFunc();//初始化手动扩展工作区宽高的功能
                //对节点、区域块进行移动或者RESIZE时用来显示的遮罩层
                this.$ghost = $("<div class='rs_ghost'></div>").attr({ "unselectable": "on", "onselectstart": 'return false', "onselect": 'document.selection.empty()' });
                this.$bgDiv.append(this.$ghost);
                this._initEditFunc(property.useOperStack);
            }
        };

        GooFlow.prototype = {
            useSVG: "", //浏览器是否能用SVG?
            _getSvgMarker: function (id, color) {
                var m = document.createElementNS("http://www.w3.org/2000/svg", "marker");
                m.setAttribute("id", id);
                m.setAttribute("viewBox", "0 0 6 6");
                m.setAttribute("refX", '5');
                m.setAttribute("refY", '3');
                m.setAttribute("markerUnits", "strokeWidth");
                m.setAttribute("markerWidth", '6');
                m.setAttribute("markerHeight", '6');
                m.setAttribute("orient", "auto");
                var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
                path.setAttribute("d", "M 0 0 L 6 3 L 0 6 z");
                path.setAttribute("fill", color);
                path.setAttribute("stroke-width", '0');
                m.appendChild(path);
                return m;
            },
            //初始化连线层
            _initDraw: function (id, width, height) {
                if (GooFlow.prototype.useSVG !== "") {
                    this.$draw = document.createElementNS("http://www.w3.org/2000/svg", "svg");//可创建带有指定命名空间的元素节点
                    this.$workArea.prepend(this.$draw);
                    var defs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
                    this.$draw.appendChild(defs);
                    defs.appendChild(GooFlow.prototype._getSvgMarker("arrow1", GooFlow.color.line));
                    defs.appendChild(GooFlow.prototype._getSvgMarker("arrow2", GooFlow.color.mark));
                    defs.appendChild(GooFlow.prototype._getSvgMarker("arrow3", GooFlow.color.mark));
                }
                else {
                    this.$draw = document.createElement("v:group");
                    this.$draw.coordsize = width + "," + height;
                    this.$workArea.prepend("<div class='GooFlow_work_vml' style='position:relative;width:" + width + "px;height:" + height + "px'></div>");
                    this.$workArea.children("div")[0].insertBefore(this.$draw, null);
                }
                this.$draw.id = id;
                this.$draw.style.width = width + "px";
                this.$draw.style.height = height + "px";
                //绑定连线的点击选中以及双击编辑事件
                var tmpClk = null;
                if (GooFlow.prototype.useSVG !== "") tmpClk = "g";
                else tmpClk = "PolyLine";
                //绑定选中事件
                $(this.$draw).on("click", tmpClk, { inthis: this }, function (e) {
                    e.data.inthis.focusItem(this.id, true);
                });
                if (!this.$editable) return;

                //绑定右键事件
                $(this.$draw).on("contextmenu", tmpClk, { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if (typeof This.onItemRightClick === 'function' && This.onItemRightClick(this.id, "line") === false) {
                        window.event ? window.event.returnValue = false : e.preventDefault();
                        return false;
                    }
                });
                $(this.$draw).on("dblclick", tmpClk, { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if (typeof This.onItemDbClick === 'function' && This.onItemDbClick(this.id, "line") === false) return;
                    var oldTxt, x, y, from, to;
                    if (GooFlow.prototype.useSVG !== "") {
                        oldTxt = this.childNodes[2].textContent;
                        from = this.getAttribute("from").split(",");
                        to = this.getAttribute("to").split(",");
                    } else {
                        oldTxt = this.childNodes[1].innerHTML;
                        var n = this.getAttribute("fromTo").split(",");
                        from = [n[0], n[1]];
                        to = [n[2], n[3]];
                    }
                    if (This.$lineData[this.id].type === "lr") {
                        from[0] = This.$lineData[this.id].M * This.$scale;
                        to[0] = from[0];
                    }
                    else if (This.$lineData[this.id].type === "tb") {
                        from[1] = This.$lineData[this.id].M * This.$scale;
                        to[1] = from[1];
                    }
                    x = (parseInt(from[0], 10) + parseInt(to[0], 10)) / 2 - 64;
                    y = (parseInt(from[1], 10) + parseInt(to[1], 10)) / 2 - 18;
                    var t = This.t;//t=_elCsys(This.$workArea[0]);
                    This.$textArea.val(oldTxt).css({
                        display: "block", width: 130, height: 26,
                        left: t.left + x - This.$workArea[0].parentNode.scrollLeft,
                        top: t.top + y - This.$workArea[0].parentNode.scrollTop
                    }).data("id", This.$focus).focus();
                    This.$workArea.parent().one("mousedown", function (e) {
                        if (e.button === 2) return false;
                        This.setName(This.$textArea.data("id"), This.$textArea.val(), "line");
                        This.$textArea.val("").removeData("id").hide();
                    });
                });
            },
            //初始化区域块(泳道)层
            _initGroup: function (width, height) {
                this.$group = $("<div class='GooFlow_work_group' style='width:" + width + "px;height:" + height + "px'></div>");//存放背景区域的容器
                this.$workArea.prepend(this.$group);
                if (!this.$editable) return;

                //绑定点击事件
                this.$group.on("click", ".GooFlow_area", { inthis: this }, function (e) {
                    console.log("click");
                    e.data.inthis.focusItem(this.id, true);
                    //TODO 控件点击
                    //$(this).removeClass("item_mark");
                });

                //绑定双击事件
                this.$group.on("dblclick", ".GooFlow_area", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if (typeof This.onItemDbClick === 'function' && This.onItemDbClick(this.id, "area") === false) {
                        window.event ? window.event.returnValue = false : e.preventDefault();
                        return false;
                    }
                });

                //绑定右键事件
                this.$group.on("contextmenu", ".GooFlow_area", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if (typeof This.onItemRightClick === 'function' && This.onItemRightClick(this.id, "area") === false) {
                        window.event ? window.event.returnValue = false : e.preventDefault();
                        return false;
                    }
                });
                //区域划分框操作区的事件绑定
                this.$group.on("mousedown", { inthis: this }, function (e) {//绑定RESIZE功能以及移动功能
                    if (e.button === 2) return false;
                    var This = e.data.inthis;
                    if (This.$nowType !== "group") return;
                    if (!e) e = window.event;
                    var cursor = $(e.target).css("cursor");
                    var id = e.target.parentNode;
                    switch (cursor) {
                        case "nw-resize": id = id.parentNode; break;
                        case "w-resize": id = id.parentNode; break;
                        case "n-resize": id = id.parentNode; break;
                        case "move": break;
                        default: return;
                    }
                    id = id.id;

                    var ev = _mouseP(e), t = This.t;//t=_elCsys(This.$workArea[0]);
                    var X, Y, vX, vY;
                    X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
                    Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
                    if (cursor !== "move") {
                        This.$ghost.css({
                            display: "block",
                            width: This.$areaData[id].width * This.$scale + "px",
                            height: This.$areaData[id].height * This.$scale + "px",
                            top: This.$areaData[id].top * This.$scale + t.top - This.$workArea[0].parentNode.scrollTop + "px",
                            left: This.$areaData[id].left * This.$scale + t.left - This.$workArea[0].parentNode.scrollLeft + "px",
                            cursor: cursor
                        });
                        vX = (This.$areaData[id].left * This.$scale + This.$areaData[id].width * This.$scale) - X;
                        vY = (This.$areaData[id].top * This.$scale + This.$areaData[id].height * This.$scale) - Y;
                    }
                    //else {
                    //    vX = X - This.$areaData[id].left * This.$scale;
                    //    vY = Y - This.$areaData[id].top * This.$scale;
                    //}
                    var isMove = false;
                    This.$ghost.css("cursor", cursor);
                    document.onmousemove = function (e) {
                        if (!e) e = window.event;
                        var ev = _mouseP(e);
                        if (cursor !== "move") {
                            X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft - This.$areaData[id].left * This.$scale + vX;
                            Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop - This.$areaData[id].top * This.$scale + vY;
                            //if (X < 200 * This.$scale) X = 200 * This.$scale;
                            //if (Y < 100 * This.$scale) Y = 100 * This.$scale;
                            //修改最小大小限制
                            if (X < pixWidth * This.$scale) X = pixWidth * This.$scale;
                            if (Y < pixWidth * This.$scale) Y = pixWidth * This.$scale;
                            switch (cursor) {
                                case "nw-resize": This.$ghost.css({ width: X + "px", height: Y + "px" }); break;
                                case "w-resize": This.$ghost.css({ width: X + "px" }); break;
                                case "n-resize": This.$ghost.css({ height: Y + "px" }); break;
                            }
                        }
                        //else {
                        //    if (This.$ghost.css("display") === "none") {
                        //        This.$ghost.css({
                        //            display: "block",
                        //            width: This.$areaData[id].width * This.$scale + "px", height: This.$areaData[id].height * This.$scale + "px",
                        //            top: This.$areaData[id].top * This.$scale + t.top - This.$workArea[0].parentNode.scrollTop + "px",
                        //            left: This.$areaData[id].left * This.$scale + t.left - This.$workArea[0].parentNode.scrollLeft + "px", cursor: cursor
                        //        });
                        //    }
                        //    X = ev.x - vX; Y = ev.y - vY;
                        //    if (X < t.left - This.$workArea[0].parentNode.scrollLeft)
                        //        X = t.left - This.$workArea[0].parentNode.scrollLeft;
                        //    else if (X + This.$workArea[0].parentNode.scrollLeft + This.$areaData[id].width * This.$scale > t.left + This.$workArea.width())
                        //        X = t.left + This.$workArea.width() - This.$workArea[0].parentNode.scrollLeft - This.$areaData[id].width * This.$scale;
                        //    if (Y < t.top - This.$workArea[0].parentNode.scrollTop)
                        //        Y = t.top - This.$workArea[0].parentNode.scrollTop;
                        //    else if (Y + This.$workArea[0].parentNode.scrollTop + This.$areaData[id].height * This.$scale > t.top + This.$workArea.height())
                        //        Y = t.top + This.$workArea.height() - This.$workArea[0].parentNode.scrollTop - This.$areaData[id].height * This.$scale;
                        //    This.$ghost.css({ left: X + "px", top: Y + "px" });
                        //}
                        isMove = true;
                    };
                    document.onmouseup = function () {
                        This.$ghost.empty().hide();
                        document.onmousemove = null;
                        document.onmouseup = null;
                        if (!isMove) return;
                        if (cursor !== "move")
                            This.resizeArea(id, This.$ghost.outerWidth() / This.$scale, This.$ghost.outerHeight() / This.$scale);
                        //else
                        //    This.moveArea(id, (X + This.$workArea[0].parentNode.scrollLeft - t.left) / This.$scale, (Y + This.$workArea[0].parentNode.scrollTop - t.top) / This.$scale);
                        return false;
                    }
                });
                //绑定修改文字说明功能
                this.$group.on("dblclick", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if (This.$nowType !== "group") return;
                    if (!e) e = window.event;
                    if (e.target.tagName !== "LABEL") return false;
                    var p = e.target.parentNode;
                    if (typeof This.onItemDbClick === 'function' && This.onItemDbClick(p.id, "area") === false) return;

                    var oldTxt = e.target.innerHTML;
                    var x = parseInt(p.style.left, 10) + 18, y = parseInt(p.style.top, 10) + 1;
                    var t = This.t;//t=_elCsys(This.$workArea[0]);
                    This.$textArea.val(oldTxt).css({
                        display: "block", width: 130, height: 26,
                        left: t.left + x - This.$workArea[0].parentNode.scrollLeft,
                        top: t.top + y - This.$workArea[0].parentNode.scrollTop
                    }).data("id", p.id).focus();
                    This.$workArea.parent().one("mouseup", function (e) {
                        if (e.button === 2) return false;
                        if (This.$textArea.css("display") === "block") {
                            This.setName(This.$textArea.data("id"), This.$textArea.val(), "area");
                            This.$textArea.val("").removeData("id").hide();
                        }
                        return false;
                    });
                    return false;
                });
                //绑定点击事件
                this.$group.mouseup({ inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if (This.$textArea.css("display") === "block") {
                        This.setName(This.$textArea.data("id"), This.$textArea.val(), "area");
                        This.$textArea.val("").removeData("id").hide();
                        return false;
                    }

                    if (This.$nowType !== "group") return;
                    if (!e) e = window.event;
                    switch ($(e.target).attr("class")) {
                        case "rs_close": This.delArea(e.target.parentNode.parentNode.id); return false;//删除该分组区域
                        case "bg": return;
                    }
                    switch (e.target.tagName) {
                        case "LABEL": return false;
                        case "I"://绑定变色功能
                            var id = e.target.parentNode.id;
                            switch (This.$areaData[id].color) {
                                case "red": This.setAreaColor(id, "yellow"); break;
                                case "yellow": This.setAreaColor(id, "blue"); break;
                                case "blue": This.setAreaColor(id, "green"); break;
                                case "green": This.setAreaColor(id, "red"); break;
                            }
                            return false;
                    }
                    if (e.data.inthis.$ghost.css("display") === "none") {
                        //取消添加group类型
                        //var X, Y;
                        //var ev = _mouseP(e), t = _elCsys(this);
                        //X = ev.x - t.left + this.parentNode.parentNode.scrollLeft;
                        //Y = ev.y - t.top + this.parentNode.parentNode.scrollTop;
                        //var color = ["red", "yellow", "blue", "green"];

                        //e.data.inthis.addArea(new Date().getTime(),
                        //    //{ name: "area_" + e.data.inthis.$max, left: X / This.$scale, top: Y / This.$scale, color: color[e.data.inthis.$max % 4], width: 200, height: 100 }
                        //    //修改默认的大小
                        //    { name: "area_" + e.data.inthis.$max, left: X / This.$scale, top: Y / This.$scale, color: color[e.data.inthis.$max % 4], width: pixWidth * 2, height: pixWidth }
                        //);
                        //e.data.inthis.$max++;
                        return false;
                    }
                });
            },
            //初始化节点绘制层
            _initWorkForNode: function () {
                //绑定点击事件
                this.$workArea.on("click", ".GooFlow_item", { inthis: this }, function (e) {
                    e.data.inthis.focusItem(this.id, true);
                    $(this).removeClass("item_mark");
                });
                //绑定右键事件
                this.$workArea.on("contextmenu", ".GooFlow_item", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if (typeof This.onItemRightClick === 'function' && This.onItemRightClick(this.id, "node") === false) {
                        window.event ? window.event.returnValue = false : e.preventDefault();
                        return false;
                    }
                });

                //绑定双击功能
                var tmpDbClickFunc = function (This) {
                    This.$workArea.parent().one("mousedown", function (e) {
                        if (e.button === 2) return false;
                        This.setName(This.$textArea.data("id"), This.$textArea.val(), "node");
                        This.$textArea.val("").removeData("id").hide();
                    });
                };
                this.$workArea.on("dblclick", ".ico", { inthis: this }, function (e) {
                    var id = $(this).parents(".GooFlow_item").attr("id");
                    var This = e.data.inthis;
                    if (typeof This.onItemDbClick === 'function' && This.onItemDbClick(id, "node") === false) return false;
                });
                //绑定双击(包括双击编辑)事件
                this.$workArea.on("dblclick", ".GooFlow_item > .span", { inthis: this }, function (e) {
                    var id = this.parentNode.id;
                    var This = e.data.inthis;
                    if (typeof This.onItemDbClick === 'function' && This.onItemDbClick(id, "node") === false) return false;
                    if (!This.$editable) return;
                    var oldTxt = this.innerHTML;
                    var t = This.t;//t=_elCsys(This.$workArea[0]);
                    This.$textArea.val(oldTxt).css({
                        display: "block", height: $(this).height() + 6, width: 100,
                        left: t.left + This.$nodeData[id].left * This.$scale - This.$workArea[0].parentNode.scrollLeft - 26,
                        top: t.top + This.$nodeData[id].top * This.$scale - This.$workArea[0].parentNode.scrollTop + 26
                    })
                        .data("id", This.$focus).focus();
                    tmpDbClickFunc(This);
                });
                this.$workArea.on("dblclick", ".ico + td", { inthis: this }, function (e) {
                    var id = $(this).parents(".GooFlow_item").attr("id");
                    var This = e.data.inthis;
                    if (typeof This.onItemDbClick === 'function' && This.onItemDbClick(id, "node") === false) return false;
                    if (!This.$editable) return;
                    var oldTxt = this.childNodes[0].innerHTML;
                    var t = This.t;//t=_elCsys(This.$workArea[0]);
                    This.$textArea.val(oldTxt).css({
                        display: "block", width: $(this).width() + 26, height: $(this).height() + 6,
                        left: t.left + 26 + This.$nodeData[id].left * This.$scale - This.$workArea[0].parentNode.scrollLeft,
                        top: t.top + 2 + This.$nodeData[id].top * This.$scale - This.$workArea[0].parentNode.scrollTop
                    })
                        .data("id", This.$focus).focus();
                    tmpDbClickFunc(This);
                });
                if (!this.$editable) return;

                //以下是工作区为编辑模式时才绑定的事件
                //绑定用鼠标移动事件
                this.$workArea.on("mousedown", ".ico", { inthis: this }, function (e) {
                    if (!e) e = window.event;
                    if (e.button === 2) return false;
                    var This = e.data.inthis;
                    if (This.$nowType === "direct" || This.$nowType === "dashed") return;
                    var Dom = $(this).parents(".GooFlow_item");
                    var id = Dom.attr("id");
                    This.focusItem(id, true);

                    var ev = _mouseP(e), t = This.t;//t=_elCsys(This.$workArea[0]);

                    Dom.children("table").clone().prependTo(This.$ghost);
                    var X, Y;
                    X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
                    Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
                    var vX = X - This.$nodeData[id].left * This.$scale, vY = Y - This.$nodeData[id].top * This.$scale;
                    var isMove = false;
                    document.onmousemove = function (e) {
                        if (!e) e = window.event;
                        var ev = _mouseP(e);
                        if (X === ev.x - vX && Y === ev.y - vY) return false;
                        X = ev.x - vX; Y = ev.y - vY;

                        if (isMove && This.$ghost.css("display") === "none") {
                            This.$ghost.css({
                                display: "block",
                                width: This.$nodeData[id].width * This.$scale + "px", height: This.$nodeData[id].height * This.$scale + "px",
                                top: This.$nodeData[id].top * This.$scale + t.top - This.$workArea[0].parentNode.scrollTop + "px",
                                left: This.$nodeData[id].left * This.$scale + t.left - This.$workArea[0].parentNode.scrollLeft + "px",
                                cursor: "move"
                            });
                        }

                        if (X < t.left - This.$workArea[0].parentNode.scrollLeft)
                            X = t.left - This.$workArea[0].parentNode.scrollLeft;
                        else if (X + This.$workArea[0].parentNode.scrollLeft + This.$nodeData[id].width * This.$scale > t.left + This.$workArea.width())
                            X = t.left + This.$workArea.width() - This.$workArea[0].parentNode.scrollLeft - This.$nodeData[id].width * This.$scale;
                        if (Y < t.top - This.$workArea[0].parentNode.scrollTop)
                            Y = t.top - This.$workArea[0].parentNode.scrollTop;
                        else if (Y + This.$workArea[0].parentNode.scrollTop + This.$nodeData[id].height * This.$scale > t.top + This.$workArea.height())
                            Y = t.top + This.$workArea.height() - This.$workArea[0].parentNode.scrollTop - This.$nodeData[id].height * This.$scale;
                        This.$ghost.css({ left: X + "px", top: Y + "px" });
                        isMove = true;
                    };
                    document.onmouseup = function () {
                        if (isMove) This.moveNode(id, (X + This.$workArea[0].parentNode.scrollLeft - t.left) / This.$scale, (Y + This.$workArea[0].parentNode.scrollTop - t.top) / This.$scale);
                        This.$ghost.empty().hide();
                        document.onmousemove = null;
                        document.onmouseup = null;
                    }
                });
                //绑定鼠标覆盖/移出事件
                this.$workArea.on("mouseenter", ".GooFlow_item", { inthis: this }, function (e) {
                    if ((e.data.inthis.$nowType !== "direct" && e.data.inthis.$nowType !== "dashed") && !document.getElementById("GooFlow_tmp_line")) return;
                    $(this).addClass("item_mark").addClass("crosshair").css("border-color", GooFlow.color.mark);
                });
                this.$workArea.on("mouseleave", ".GooFlow_item", { inthis: this }, function (e) {
                    if ((e.data.inthis.$nowType !== "direct" && e.data.inthis.$nowType !== "dashed") && !document.getElementById("GooFlow_tmp_line")) return;
                    $(this).removeClass("item_mark").removeClass("crosshair");
                    if (this.id === e.data.inthis.$focus) {
                        $(this).css("border-color", GooFlow.color.line);
                    } else {
                        $(this).css("border-color", GooFlow.color.node);
                    }
                });

                //绑定连线时确定初始点
                this.$workArea.on("mousedown", ".GooFlow_item", { inthis: this }, function (e) {
                    if (e.button === 2) return false;
                    var This = e.data.inthis;
                    if (This.$nowType !== "direct" && This.$nowType !== "dashed") return;
                    var ev = _mouseP(e), t = _elCsys(This.$workArea[0]);
                    var X, Y;
                    X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
                    Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
                    This.$workArea.data("lineStart", { "x": X, "y": Y, "id": this.id }).css("cursor", "crosshair");
                    var line = GooFlow.prototype.drawLine("GooFlow_tmp_line", [X, Y], [X, Y], true, true, 1);
                    This.$draw.appendChild(line);
                });
                //绑定连线时确定结束点
                this.$workArea.on("mouseup", ".GooFlow_item", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if ((This.$nowType !== "direct" && This.$nowType !== "dashed") && !This.$mpTo.data("p")) return;
                    var lineStart = This.$workArea.data("lineStart");
                    var lineEnd = This.$workArea.data("lineEnd");
                    if (lineStart && !This.$mpTo.data("p")) {
                        var tmp = { from: lineStart.id, to: this.id, name: "" };
                        if (This.$nowType === "dashed") {
                            tmp.dash = true;
                        }
                        This.addLine(new Date().getTime().toString(), tmp);
                        This.$max++;
                    }
                    else {
                        if (lineStart) {
                            This.moveLinePoints(This.$focus, lineStart.id, this.id);
                        } else if (lineEnd) {
                            This.moveLinePoints(This.$focus, this.id, lineEnd.id);
                        }
                        if (!This.$nodeData[this.id].marked) {
                            $(this).removeClass("item_mark");
                            if (this.id !== This.$focus) {
                                $(this).css("border-color", GooFlow.color.node);
                            }
                            else {
                                $(this).css("border-color", GooFlow.color.line);
                            }
                        }
                    }
                });

                //绑定结点的删除功能
                this.$workArea.on("click", ".rs_close", { inthis: this }, function (e) {
                    if (!e) e = window.event;
                    e.data.inthis.delNode(e.data.inthis.$focus);
                    return false;
                });
                //绑定结点的RESIZE功能
                this.$workArea.on("mousedown", ".GooFlow_item > div > div[class!=rs_close]", { inthis: this }, function (e) {
                    if (!e) e = window.event;
                    if (e.button === 2) return false;
                    var cursor = $(this).css("cursor");
                    if (cursor === "pointer") { return; }
                    var This = e.data.inthis;
                    var id = This.$focus;
                    This.switchToolBtn("cursor");
                    e.cancelBubble = true;
                    e.stopPropagation();

                    var ev = _mouseP(e), t = This.t;//t=_elCsys(This.$workArea[0]);
                    This.$ghost.css({
                        display: "block",
                        width: This.$nodeData[id].width * This.$scale + "px", height: This.$nodeData[id].height * This.$scale + "px",
                        top: This.$nodeData[id].top * This.$scale + t.top - This.$workArea[0].parentNode.scrollTop + "px",
                        left: This.$nodeData[id].left * This.$scale + t.left - This.$workArea[0].parentNode.scrollLeft + "px",
                        cursor: cursor
                    });
                    var X, Y;
                    X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
                    Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
                    var vX = (This.$nodeData[id].left * This.$scale + This.$nodeData[id].width * This.$scale) - X;
                    var vY = (This.$nodeData[id].top * This.$scale + This.$nodeData[id].height * This.$scale) - Y;
                    var isMove = false;
                    This.$ghost.css("cursor", cursor);
                    document.onmousemove = function (e) {
                        if (!e) e = window.event;
                        var ev = _mouseP(e);
                        X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft - This.$nodeData[id].left * This.$scale + vX;
                        Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop - This.$nodeData[id].top * This.$scale + vY;
                        //if(X<104*This.$scale)	X=104*This.$scale;
                        //if(Y<28*This.$scale)	Y=28*This.$scale;
                        //huaheng 修改最小尺寸
                        if (X < (pixWidth - 2) * This.$scale) X = (pixWidth - 2) * This.$scale;
                        if (Y < (pixWidth - 2) * This.$scale) Y = (pixWidth - 2) * This.$scale;
                        isMove = true;
                        switch (cursor) {
                            case "nw-resize": This.$ghost.css({ width: X + "px", height: Y + "px" }); break;
                            case "w-resize": This.$ghost.css({ width: X + "px" }); break;
                            case "n-resize": This.$ghost.css({ height: Y + "px" }); break;
                        }
                    };
                    document.onmouseup = function () {
                        document.onmousemove = null;
                        document.onmouseup = null;
                        This.$ghost.hide();
                        if (!isMove) return;
                        //if(!e)e=window.event;
                        This.resizeNode(id, This.$ghost.outerWidth() / This.$scale, This.$ghost.outerHeight() / This.$scale);
                    };
                });
            },
            //加入手动扩展编辑区功能,一次扩展200px
            _initExpendFunc: function () {
                var titleExendRight = GooFlow.remarks.extendRight ? ' title="' + GooFlow.remarks.extendRight + '"' : '';
                var titleExendBottom = GooFlow.remarks.extendBottom ? ' title="' + GooFlow.remarks.extendBottom + '"' : '';
                this.$workArea.append('<div class="Gooflow_extend_right"' + titleExendRight + '></div><div class="Gooflow_extend_bottom"' + titleExendBottom + '></div>');
                this.$workArea.children(".Gooflow_extend_right").on("click", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    var w = This.$workArea.width() + This.$workExtendStep;
                    var h = This.$workArea.height();
                    This.$workArea.css({ width: w + "px" });
                    if (GooFlow.prototype.useSVG === "") {
                        This.$draw.coordsize = w + "," + h;
                    }
                    This.$draw.style.width = w + "px";
                    if (This.$group != null) {
                        This.$group.css({ width: w + "px" });
                    }
                    var parentDiv = This.$workArea.parent()[0];
                    parentDiv.scrollLeft = parentDiv.scrollWidth;
                    This.$workArea.parent().css("overflow", "scroll");
                    return false;
                });
                this.$workArea.children(".Gooflow_extend_bottom").on("click", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    var w = This.$workArea.width();
                    var h = This.$workArea.height() + This.$workExtendStep;
                    This.$workArea.css({ height: h + "px" });
                    if (GooFlow.prototype.useSVG === "") {
                        This.$draw.coordsize = w + "," + h;
                    }
                    This.$draw.style.height = h + "px";
                    if (This.$group != null) {
                        This.$group.css({ height: h + "px" });
                    }
                    var parentDiv = This.$workArea.parent()[0];
                    parentDiv.scrollTop = parentDiv.scrollHeight;
                    This.$workArea.parent().css("overflow", "scroll");
                    return false;
                });
            },
            //初始化用来改变连线的连接端点的两个小方块的操作事件
            _initLinePointsChg: function () {
                this.$mpFrom.on("mousedown", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    This.switchToolBtn("cursor");
                    var ps = This.$mpFrom.data("p").split(",");
                    var pe = This.$mpTo.data("p").split(",");
                    $(this).hide();
                    This.$workArea.data("lineEnd", { "x": pe[0], "y": pe[1], "id": This.$lineData[This.$lineOper.data("tid")].to }).css("cursor", "crosshair");
                    var line = GooFlow.prototype.drawLine("GooFlow_tmp_line", [ps[0], ps[1]], [pe[0], pe[1]], true, true, 1);
                    This.$draw.appendChild(line);
                    return false;
                });
                this.$mpTo.on("mousedown", { inthis: this }, function (e) {
                    var This = e.data.inthis;
                    This.switchToolBtn("cursor");
                    var ps = This.$mpFrom.data("p").split(",");
                    var pe = This.$mpTo.data("p").split(",");
                    $(this).hide();
                    This.$workArea.data("lineStart", { "x": ps[0], "y": ps[1], "id": This.$lineData[This.$lineOper.data("tid")].from }).css("cursor", "crosshair");
                    var line = GooFlow.prototype.drawLine("GooFlow_tmp_line", [ps[0], ps[1]], [pe[0], pe[1]], true, true, 1);
                    This.$draw.appendChild(line);
                    return false;
                });
            },
            //初始化设计器的编辑功能
            _initEditFunc: function (useOperStack) {
                //划线或改线时用的绑定
                this.$workArea.mousemove({ inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if ((This.$nowType !== "direct" && This.$nowType !== "dashed") && !This.$mpTo.data("p")) return;
                    var lineStart = $(this).data("lineStart");
                    var lineEnd = $(this).data("lineEnd");
                    if (!lineStart && !lineEnd) return;

                    var ev = _mouseP(e), t = _elCsys(this);
                    var X, Y;
                    X = ev.x - t.left + this.parentNode.scrollLeft;
                    Y = ev.y - t.top + this.parentNode.scrollTop;
                    var line = document.getElementById("GooFlow_tmp_line");
                    if (lineStart) {
                        if (GooFlow.prototype.useSVG !== "") {
                            line.childNodes[0].setAttribute("d", "M " + lineStart.x + " " + lineStart.y + " L " + X + " " + Y);
                            line.childNodes[1].setAttribute("d", "M " + lineStart.x + " " + lineStart.y + " L " + X + " " + Y);
                            if (line.childNodes[1].getAttribute("marker-end") === 'url("#arrow2")')
                                line.childNodes[1].setAttribute("marker-end", "url(#arrow3)");
                            else line.childNodes[1].setAttribute("marker-end", "url(#arrow2)");
                        }
                        else line.points.value = lineStart.x + "," + lineStart.y + " " + X + "," + Y;
                    } else if (lineEnd) {
                        if (GooFlow.prototype.useSVG !== "") {
                            line.childNodes[0].setAttribute("d", "M " + X + " " + Y + " L " + lineEnd.x + " " + lineEnd.y);
                            line.childNodes[1].setAttribute("d", "M " + X + " " + Y + " L " + lineEnd.x + " " + lineEnd.y);
                            if (line.childNodes[1].getAttribute("marker-end") === 'url("#arrow2")')
                                line.childNodes[1].setAttribute("marker-end", "url(#arrow3)");
                            else line.childNodes[1].setAttribute("marker-end", "url(#arrow2)");
                        }
                        else line.points.value = X + "," + Y + " " + lineEnd.x + "," + lineEnd.y;
                    }
                });
                this.$workArea.mouseup({ inthis: this }, function (e) {
                    var This = e.data.inthis;
                    if ((This.$nowType !== "direct" && This.$nowType !== "dashed") && !This.$mpTo.data("p")) return;
                    var tmp = document.getElementById("GooFlow_tmp_line");
                    if (tmp) {
                        $(this).css("cursor", "auto").removeData("lineStart").removeData("lineEnd");
                        This.$mpTo.hide().removeData("p");
                        This.$mpFrom.hide().removeData("p");
                        This.$draw.removeChild(tmp);
                        This.focusItem(This.$focus, false);
                    } else {
                        This.$lineOper.removeData("tid");
                    }
                });

                this.$textArea = $("<textarea></textarea>");
                this.$bgDiv.append(this.$textArea);
                this.$lineMove = $('<div class="GooFlow_linemove" style="display:none"></div>');//操作折线时的移动框
                this.$workArea.append(this.$lineMove);
                this.$lineMove.on("mousedown", { inthis: this }, function (e) {
                    if (e.button === 2) return false;
                    var lm = $(this);
                    lm.css({ "background-color": "#333" });
                    var This = e.data.inthis;
                    var ev = _mouseP(e), t = _elCsys(This.$workArea[0]);
                    var X, Y;
                    X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
                    Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
                    var p = This.$lineMove.position();
                    var vX = X - p.left, vY = Y - p.top;
                    var isMove = false;
                    document.onmousemove = function (e) {
                        if (!e) e = window.event;
                        var ev = _mouseP(e);
                        //var ps=This.$lineMove.position();
                        X = ev.x - t.left + This.$workArea[0].parentNode.scrollLeft;
                        Y = ev.y - t.top + This.$workArea[0].parentNode.scrollTop;
                        if (This.$lineMove.data("type") === "lr") {
                            X = X - vX;
                            if (X < 0) X = 0;
                            else if (X > This.$workArea.width())
                                X = This.$workArea.width();
                            This.$lineMove.css({ left: X + "px" });
                        }
                        else if (This.$lineMove.data("type") === "tb") {
                            Y = Y - vY;
                            if (Y < 0) Y = 0;
                            else if (Y > This.$workArea.height())
                                Y = This.$workArea.height();
                            This.$lineMove.css({ top: Y + "px" });
                        }
                        isMove = true;
                    };
                    document.onmouseup = function () {
                        if (isMove) {
                            var p = This.$lineMove.position();
                            if (This.$lineMove.data("type") === "lr")
                                This.setLineM(This.$lineMove.data("tid"), (p.left + 3) / This.$scale);
                            else if (This.$lineMove.data("type") === "tb")
                                This.setLineM(This.$lineMove.data("tid"), (p.top + 3) / This.$scale);
                        }
                        This.$lineMove.css({ "background-color": "transparent" });
                        if (This.$focus === This.$lineMove.data("tid")) {
                            This.focusItem(This.$lineMove.data("tid"));
                        }
                        document.onmousemove = null;
                        document.onmouseup = null;
                    };
                });

                //选定一条转换线后出现的浮动操作栏,有改变线的样式和删除线等按钮。
                //huaheng 去除线的其他样式
                //this.$lineOper = $("<div class='GooFlow_line_oper' style='display:none'><i class='b_l1'></i><i class='b_l2'></i><i class='b_l3'></i><i class='b_x'></i></div>");//选定线时显示的操作框
                this.$lineOper = $("<div class='GooFlow_line_oper' style='display:none'><i class='b_x'></i></div>");//选定线时显示的操作框
                this.$workArea.parent().append(this.$lineOper);
                this.$lineOper.on("click", { inthis: this }, function (e) {
                    if (!e) e = window.event;
                    if (e.target.tagName !== "I") return;
                    var This = e.data.inthis;
                    var id = $(this).data("tid");
                    switch ($(e.target).attr("class")) {
                        case "b_x":
                            This.delLine(id);
                            this.style.display = "none"; break;
                        case "b_l1":
                            This.setLineType(id, "lr"); break;
                        case "b_l2":
                            This.setLineType(id, "tb"); break;
                        case "b_l3":
                            This.setLineType(id, "sl"); break;
                    }
                });
                //新增移动线两个端点至新的结点功能移动功能,这里要提供移动用的DOM
                this.$mpFrom = $("<div class='GooFlow_line_mp' style='display:none'></div>");
                this.$mpTo = $("<div class='GooFlow_line_mp' style='display:none'></div>");
                this.$workArea.append(this.$mpFrom).append(this.$mpTo);
                this._initLinePointsChg();

                if (useOperStack) {//如果要使用堆栈记录操作并提供“撤销/重做”的功能,只在编辑状态下有效
                    this.$undoStack = [];
                    this.$redoStack = [];
                    this.$isUndo = 0;
                    ///////////////以下是构造撤销操作/重做操作的方法
                    //检查撤销栈与重做栈处理好头部按钮的显示
                    this._checkStack = function (type) {
                        if (this.$head === null) return;
                        if (!type || type === 'undo') {
                            if (this.$undoStack.length === 0) {
                                this.$head.find(".ico_undo").parent().addClass("a_disabled");
                            } else {
                                this.$head.find(".ico_undo").parent().removeClass("a_disabled");
                            }
                        }
                        if (!type || type === 'redo') {
                            if (this.$redoStack.length === 0) {
                                this.$head.find(".ico_redo").parent().addClass("a_disabled");
                            } else {
                                this.$head.find(".ico_redo").parent().removeClass("a_disabled");
                            }
                        }
                    };
                    //为了节省浏览器内存空间,undo/redo中的操作缓存栈,最多只可放10步操作;超过10步时,将自动删掉最旧的一个缓存
                    this.pushOper = function (funcName, paras) {
                        if (this.$isUndo === 1) {
                            this.$redoStack.push([funcName, paras]);
                            this.$isUndo = 0;
                            if (this.$redoStack.length > 10) this.$redoStack.shift();
                            this._checkStack('redo');
                        } else {
                            this.$undoStack.push([funcName, paras]);
                            if (this.$undoStack.length > 10) this.$undoStack.shift();
                            if (this.$isUndo === 0) {
                                this.$redoStack.splice(0, this.$redoStack.length);
                            }
                            this.$isUndo = 0;
                            this._checkStack();
                        }
                    };
                    //将外部的方法加入到GooFlow对象的事务操作堆栈中,在过后的undo/redo操作中可以进行控制,一般用于对流程图以外的附加信息进行编辑的事务撤销/重做控制;
                    //传参func为要执行方法对象,jsonPara为外部方法仅有的一个面向字面的JSON传参,由JSON对象带入所有要传的信息;
                    //提示:为了让外部方法能够被UNDO/REDO,需要在编写这些外部方法实现时,加入对该方法执行后效果回退的另一个执行方法的pushExternalOper
                    this.pushExternalOper = function (func, jsonPara) {
                        this.pushOper("externalFunc", [func, jsonPara]);
                    };
                    //撤销上一步操作
                    this.undo = function () {
                        if (this.$undoStack.length === 0) return;
                        this.blurItem();
                        var tmp = this.$undoStack.pop();
                        this.$isUndo = 1;
                        if (tmp[0] === "externalFunc") {
                            tmp[1][0](tmp[1][1]);
                        }
                        else {
                            //传参的数量,最小0个最多12个.
                            this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2], tmp[1][3], tmp[1][4], tmp[1][5],
                                tmp[1][6], tmp[1][7], tmp[1][8], tmp[1][9], tmp[1][10], tmp[1][11]);
                        }
                        this._checkStack();
                    };
                    //重做最近一次被撤销的操作
                    this.redo = function () {
                        if (this.$redoStack.length === 0) return;
                        this.blurItem();
                        var tmp = this.$redoStack.pop();
                        this.$isUndo = 2;
                        if (tmp[0] === "externalFunc") {
                            tmp[1][0](tmp[1][1]);
                        }
                        else {
                            //传参的数量,最小0个最多12个.
                            this[tmp[0]](tmp[1][0], tmp[1][1], tmp[1][2], tmp[1][3], tmp[1][4], tmp[1][5],
                                tmp[1][6], tmp[1][7], tmp[1][8], tmp[1][9], tmp[1][10], tmp[1][11]);
                        }
                        this._checkStack();
                    };

                    this.ReCalibrateData = function () {
                        //console.log("暂未实现");
                        if (this.$areaData) {
                            try {
                                for (let key in this.$areaData) {
                                    let obj1 = this.$areaData[key];
                                    if (!!!obj1.setInfo || obj1.color == "user_yunxingqu" || obj1.color.indexOf("user_rfid_yxd") > -1) continue;
                                    for (let key1 in this.$areaData) {
                                        let obj2 = this.$areaData[key1];
                                        if (!!!obj2.setInfo || obj2.color.indexOf("user_rfid_yxd") <= -1) continue;

                                        let container = {
                                            Left: obj1.left,
                                            Top: obj1.top,
                                            Width: obj1.width,
                                            Height: obj1.height,
                                        };
                                        let node = {
                                            Left: obj2.left,
                                            Top: obj2.top,
                                            Width: obj2.width,
                                            Height: obj2.height,
                                        };
                                        if (this.CheckPut(node, container) == "in" || this.CheckPut(node, container) == "equal") {
                                            obj1.setInfo.RFID = obj2.setInfo.RFID;
                                            break;
                                        }
                                    }
                                }
                                alert("数据校正完成");
                            } catch (e) {
                                console.log(e);
                                alert("数据校正失败");

                            }

                        }
                        else {
                            alert("数据不存在");

                        }
                    }
                }
                $(document).keydown({ inthis: this }, function (e) {
                    //绑定键盘操作
                    var This = e.data.inthis;
                    if (This.$focus === "") return;
                    switch (e.keyCode) {
                        case 46://删除
                            This.delNode(This.$focus, true);
                            This.delLine(This.$focus);
                            break;
                    }
                });
            },

            //对头部栏自定义按钮的事件绑定,用户可用来对另行加入的头部按钮自定义功能
            //传参为json结构,key为按钮的类型名(需另行写好'ico_'+按钮类型名的样式类定义),value为相关事件的方法实现定义
            bindHeadBtnEvent: function (funcs) {
                if (this.$head != null)
                    this.$headBtnEvents = funcs;
            },
            //每一种类型结点及其按钮的说明文字
            setNodeRemarks: function (remark) {
                if (this.$tool == null) return;
                this.$tool.children("a").each(function () {
                    try {
                        this.title = remark[$(this).attr("id").split("btn_")[1]];
                        $(this.lastChild).html(remark[$(this).attr("id").split("btn_")[1]]);
                    } catch (e) { }
                });
            },
            //(当有顶部工具栏按钮组时)设定顶部工具栏按钮的说明文字
            setHeadToolsRemarks: function (remark) {
                if (this.$head == null) return;
                this.$head.children("a").each(function () {
                    try {
                        this.title = remark[$(this).children("i").attr("class").split('ico_')[1]];
                    } catch (e) { }
                });
            },
            //设定扩展工作区宽高的长条按钮的说明文字
            setExtWorkRemarks: function (remark) {
                this.$workArea.children(".Gooflow_extend_right").attr("title", remark.extendRight);
                this.$workArea.children(".Gooflow_extend_bottom").attr("title", remark.extendBottom);
            },

            //切换左边工具栏按钮,传参TYPE表示切换成哪种类型的按钮
            switchToolBtn: function (type) {

                //快速模式单独处理
                if (type == "user_fastmode") {
                    var id = `#${this.$id}_btn_${type.split(" ")[0]}`
                    var fastTool = this.$tool.children(id);
                    if (this.$fastMode) {
                        fastTool.addClass("GooFlow_tool_btn_fast_model");
                        fastTool.addClass("GooFlow_tool_btn");
                        fastTool.removeClass("GooFlow_tool_btndown_fast_model");
                    } else {
                        fastTool.removeClass("GooFlow_tool_btn_fast_model");
                        fastTool.removeClass("GooFlow_tool_btn");
                        fastTool.addClass("GooFlow_tool_btndown_fast_model");
                    }
                    this.$fastMode = !this.$fastMode;
                    return;
                }
                if (type == "group") {
                    if (this.$fastMode) {
                        var fastTool = this.$tool.children(id);
                        fastTool.addClass("GooFlow_tool_btn_fast_model");
                        fastTool.addClass("GooFlow_tool_btn");
                        fastTool.removeClass("GooFlow_tool_btndown_fast_model");
                    }
                    this.$fastMode = false;


                }

                var id = `#${this.$id}_btn_${this.$nowType.split(" ")[0]}`
                var lastTool = this.$tool.children(id);
                var flag = this.$nowType == type && lastTool.hasClass("GooFlow_tool_btndown");
                //&& (this.$nowType != "user_fastmode" || this.$nowType == "user_fastmode" && type == this.$nowType)
                if (this.$tool != null) {
                    if (!lastTool.hasClass("GooFlow_tool_btn")) {
                        lastTool.toggleClass("GooFlow_tool_btn");
                    }
                    if (lastTool.hasClass("GooFlow_tool_btndown")) {
                        lastTool.toggleClass("GooFlow_tool_btndown");
                    }
                }
                if (this.$nowType === "group") {
                    this.$workArea.prepend(this.$group);
                    for (var k in this.$areaDom) this.$areaDom[k].addClass("lock").children("div:eq(1)").css("display", "none");
                }

                if (this.$textArea && this.$textArea.css("display") === "none") this.$textArea.removeData("id").val("").hide();
                if (flag) return;
                this.$nowType = type;
                var id = `#${this.$id}_btn_${this.$nowType.split(" ")[0]}`
                var nowTool = this.$tool.children(id);
                if (this.$tool != null) {
                    if (!nowTool.hasClass("GooFlow_tool_btndown")) {
                        nowTool.toggleClass("GooFlow_tool_btndown");
                    }
                    if (nowTool.hasClass("GooFlow_tool_btn")) {
                        nowTool.toggleClass("GooFlow_tool_btn");
                    }
                }
                if (this.$nowType === "group") {
                    this.blurItem();
                    this.$workArea.append(this.$group);
                    for (var key in this.$areaDom) this.$areaDom[key].removeClass("lock").children("div:eq(1)").css("display", "");
                } else if (this.$nowType === "direct" || this.$nowType === "dashed") {
                    this.blurItem();
                }
            },

            //获取结点/连线/分组区域的详细信息
            getItemInfo: function (id, type) {
                switch (type) {
                    case "node": return this.$nodeData[id] || null;
                    case "line": return this.$lineData[id] || null;
                    case "area": return this.$areaData[id] || null;
                }
            },
            //取消所有结点/连线被选定的状态
            blurItem: function () {
                if (this.$focus !== "") {
                    var jq = $("#" + this.$focus);
                    if (jq.prop("tagName") === "DIV") {
                        if (typeof this.onItemBlur === 'function' && this.onItemBlur(this.$focus, "node") === false) return false;

                        if (jq[0].className.indexOf("user_") > -1) {
                            $(jq[0]).removeClass("item_focus");
                            //控件取消选中的操作
                            this.$focus = "";
                            this.switchToolBtn("group");
                            return true;
                        }

                        jq.removeClass("item_focus").children("div:eq(0)").css("display", "none");
                        if (this.$nodeData[this.$focus].marked) {
                            jq.addClass("item_mark").css("border-color", GooFlow.color.mark);
                        }
                    }
                    else {
                        if (typeof this.onItemBlur === 'function' && this.onItemBlur(this.$focus, "line") === false) return false;
                        if (GooFlow.prototype.useSVG !== "") {
                            if (!this.$lineData[this.$focus].marked) {
                                jq[0].childNodes[1].setAttribute("stroke", GooFlow.color.line);
                                jq[0].childNodes[1].setAttribute("marker-end", "url(#arrow1)");
                            }
                        }
                        else {
                            if (!this.$lineData[this.$focus].marked) {
                                jq[0].strokeColor = GooFlow.color.line;
                            }
                        }
                        if (this.$editable) {
                            this.$lineMove.hide().removeData("type").removeData("tid");
                            this.$lineOper.hide().removeData("tid");
                            this.$mpFrom.hide().removeData("p");
                            this.$mpTo.hide().removeData("p");
                        }
                    }
                }
                this.$focus = "";
                return true;
            },
            //选定某个结点/转换线 bool:TRUE决定了要触发选中事件,FALSE则不触发选中事件,多用在程序内部调用。
            focusItem: function (id, bool) {
                var jq = $("#" + id);
                if (jq.length === 0) return;
                if (!this.blurItem()) return;//先执行"取消选中",如果返回FLASE,则也会阻止选定事件继续进行.
                if (bool && typeof this.onItemFocus === 'function' && this.onItemFocus(id, "node") === false) return;
                this.$focus = id;
                if (jq.prop("tagName") === "DIV") {
                    jq.addClass("item_focus");
                    if (GooFlow.color.line) {
                        jq.css("border-color", GooFlow.color.line);
                    }
                    if (this.$editable) jq.children("div:eq(0)").css("display", "block");
                    //this.$workArea.append(jq);
                } else {//如果是连接线
                    if (GooFlow.prototype.useSVG !== "") {
                        jq[0].childNodes[1].setAttribute("stroke", GooFlow.color.mark);
                        jq[0].childNodes[1].setAttribute("marker-end", "url(#arrow2)");
                    }
                    else {
                        jq[0].strokeColor = GooFlow.color.mark;
                    }
                    if (!this.$editable) return;
                    var x, y, from, to, n;
                    if (GooFlow.prototype.useSVG !== "") {
                        from = jq.attr("from").split(",");
                        to = jq.attr("to").split(",");
                        n = [from[0], from[1], to[0], to[1]];
                    } else {
                        n = jq[0].getAttribute("fromTo").split(",");
                        from = [n[0], n[1]];
                        to = [n[2], n[3]];
                    }
                    from[0] = parseInt(from[0], 10);
                    from[1] = parseInt(from[1], 10);
                    to[0] = parseInt(to[0], 10);
                    to[1] = parseInt(to[1], 10);
                    //var t=_elCsys(this.$workArea[0]);
                    if (this.$lineData[id].type === "lr") {
                        from[0] = this.$lineData[id].M * this.$scale;
                        to[0] = from[0];

                        this.$lineMove.css({
                            width: "5px", height: (to[1] - from[1]) * (to[1] > from[1] ? 1 : -1) + "px",
                            left: from[0] - 3 + "px",
                            top: (to[1] > from[1] ? from[1] : to[1]) + 1 + "px",
                            cursor: "e-resize", display: "block"
                        }).data({ "type": "lr", "tid": id });
                    }
                    else if (this.$lineData[id].type === "tb") {
                        from[1] = this.$lineData[id].M * this.$scale;
                        to[1] = from[1];
                        this.$lineMove.css({
                            width: (to[0] - from[0]) * (to[0] > from[0] ? 1 : -1) + "px", height: "5px",
                            left: (to[0] > from[0] ? from[0] : to[0]) + 1 + "px",
                            top: from[1] - 3 + "px",
                            cursor: "s-resize", display: "block"
                        }).data({ "type": "tb", "tid": id });
                    }
                    x = (from[0] + to[0]) / 2 - 40;
                    y = (from[1] + to[1]) / 2 + 4;
                    this.$lineOper.css({ display: "block", left: x + "px", top: y + "px" }).data("tid", id);
                    if (this.$editable) {
                        this.$mpFrom.css({ display: "block", left: n[0] - 4 + "px", top: n[1] - 4 + "px" }).data("p", n[0] + "," + n[1]);
                        this.$mpTo.css({ display: "block", left: n[2] - 4 + "px", top: n[3] - 4 + "px" }).data("p", n[2] + "," + n[3]);
                    }
                    this.$draw.appendChild(jq[0]);
                }

                this.switchToolBtn("cursor");
            },
            //传入一个节点的ID,判断在图中的哪个区域组(泳道)的范围内
            _node2Area: function (nodeId) {
                if (this.$group === null) return;
                var node = this.$nodeData[nodeId];
                var lane = false;
                for (var key in this.$areaData) {
                    var area = this.$areaData[key];
                    if (node.left >= area.left && node.left < area.left + area.width &&
                        node.top >= area.top && node.top < area.top + area.height
                    ) {
                        node.areaId = key;
                        lane = true;
                        break;
                    }
                }
                if (!lane) { delete node.areaId; } //不属于任何区域组(泳道)的情况
            },
            //增加一个流程结点,传参为一个JSON,有id,name,top,left,width,height,type(结点类型)等属性
            addNode: function (id, json) {
                if (json.id == undefined) {
                    $.extend(json, { id: id });
                }
                if (typeof this.onItemAdd === 'function' && this.onItemAdd(id, "node", json) === false) return;
                if (this.$undoStack && this.$editable) {
                    this.pushOper("delNode", [id]);
                }
                var mark = json.marked ? " item_mark" : "";
                if (json.type.indexOf(" round") < 0) {
                    //if(!json.width||json.width<104)json.width=104;
                    //if(!json.height||json.height<26)json.height=26;
                    //huaheng 修改最小尺寸
                    if (!json.width || json.width < (pixWidth - 2)) json.width = (pixWidth - 2);
                    if (!json.height || json.height < (pixWidth - 2)) json.height = (pixWidth - 2);
                    if (!json.top || json.top < 0) json.top = 0;
                    if (!json.left || json.left < 0) json.left = 0;
                    //在此修改尺寸为30整数
                    json.top = Math.floor(json.top / pixWidth) * pixWidth;
                    json.left = Math.floor(json.left / pixWidth) * pixWidth;

                    //图块节点不显示图标
                    //this.$nodeDom[id] = $("<div class='GooFlow_item" + mark + "' id='" + id + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px'><table cellspacing='1' style='width:" + (json.width * this.$scale - 2) + "px;height:" + (json.height * this.$scale - 2) + "px;'><tr><td class='ico'><i class='ico_" + json.type + "'></i></td><td></td></tr></table><div style='display:none'><div class='rs_bottom'></div><div class='rs_right'></div><div class='rs_rb'></div><div class='rs_close'></div></div></div>");
                    if (json.type == "user_shengchanxian" || json.type == "user_cangchuqu" || json.type == "user_zhangaiqu") {
                        //超出文字自动隐藏
                        this.$nodeDom[id] = $("<div class='GooFlow_item" + mark + "' id='" + id + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px'><table cellspacing='1' style='width:" + (json.width * this.$scale - 2) + "px;height:" + (json.height * this.$scale - 2) + "px;border: 0px none; table-layout: fixed;'><tr><td class='ico'><i class='ico_" + json.type + "'></i></td><td style=' overflow: hidden; white-space: nowrap; text-overflow: ellipsis;'><div>" + json.name + "</div></td></tr></table><div style='display:none'><div class='rs_bottom'></div><div class='rs_right'></div><div class='rs_rb'></div><div class='rs_close'></div></div></div>");
                    }
                    else {
                        this.$nodeDom[id] = $("<div class='GooFlow_item" + mark + "' id='" + id + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px'><table cellspacing='1' style='width:" + (json.width * this.$scale - 2) + "px;height:" + (json.height * this.$scale - 2) + "px;'><tr><td class='ico'></td><td></td></tr></table><div style='display:none'><div class='rs_bottom'></div><div class='rs_right'></div><div class='rs_rb'></div><div class='rs_close'></div></div></div>");
                    }
                }
                else {
                    json.width = (pixWidth - 2); json.height = (pixWidth - 2);

                    //在此修改尺寸为30整数
                    json.top = Math.floor(json.top / pixWidth) * pixWidth;
                    json.left = Math.floor(json.left / pixWidth) * pixWidth;

                    var json_type = json.type;
                    if (json.setInfo != undefined) {
                        var icorfid = 'start';
                        if (json.setInfo.chk_up) {
                            icorfid = icorfid + '1';
                        }
                        else {
                            icorfid = icorfid + '0';
                        }
                        if (json.setInfo.chk_right) {
                            icorfid = icorfid + '1';
                        }
                        else {
                            icorfid = icorfid + '0';
                        }
                        if (json.setInfo.chk_down) {
                            icorfid = icorfid + '1';
                        }
                        else {
                            icorfid = icorfid + '0';
                        }
                        if (json.setInfo.chk_left) {
                            icorfid = icorfid + '1';
                        }
                        else {
                            icorfid = icorfid + '0';
                        }
                        json_type = json_type.replace('start', icorfid);
                    }

                    this.$nodeDom[id] = $("<div title='" + "id:【" + id + "】, 名称:【" + json.name + "】" + "' class='GooFlow_item item_round" + mark + "' id='" + id + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px'><table cellspacing='0' style='width:" + (json.width * this.$scale - 2) + "px;height:" + (json.height * this.$scale - 2) + "px;'><tr><td class='ico'><i class='ico_" + json_type + "'></i></td></tr></table><div  style='display:none'><div class='rs_close'></div></div></div>");
                }
                //节点样式 huaheng
                if (GooFlow.color.node) {
                    if (json.type.indexOf(" mix") > -1) {
                        this.$nodeDom[id].css({ "background-color": GooFlow.color.mix, "border-color": GooFlow.color.mix });
                        if (GooFlow.color.mixFont) {
                            this.$nodeDom[id].find("td:eq(1)").css("color", GooFlow.color.mixFont);
                            this.$nodeDom[id].find(".span").css("color", GooFlow.color.mixFont);
                        }
                    } else if (json.type.indexOf("user_") > -1) {
                        var bgclass = json.type;
                        this.$nodeDom[id].css({ "background-color": GooFlow.color[bgclass], "border-color": GooFlow.color.mix });
                        if (GooFlow.color.mixFont) {
                            this.$nodeDom[id].find("td:eq(1)").css("color", GooFlow.color.mixFont);
                            this.$nodeDom[id].find(".span").css("color", GooFlow.color.mixFont);
                        }
                    } else if (json.type.indexOf("rfid_") > -1) {
                        var bgclass = json.type.split(" ")[2];
                        this.$nodeDom[id].css({ "background-color": GooFlow.color[bgclass], "border-color": GooFlow.color.mix });
                        if (GooFlow.color.mixFont) {
                            this.$nodeDom[id].find("td:eq(1)").css("color", GooFlow.color.mixFont);
                            this.$nodeDom[id].find(".span").css("color", GooFlow.color.mixFont);
                        }
                    } else {
                        this.$nodeDom[id].css({ "background-color": GooFlow.color.node, "border-color": GooFlow.color.node });
                    }

                    if (mark && GooFlow.color.mark) {
                        this.$nodeDom[id].css({ "border-color": GooFlow.color.mark });
                    }
                }
                if (json.type.indexOf(" mix") > -1) {
                    this.$nodeDom[id].addClass("item_mix");
                }

                var ua = navigator.userAgent.toLowerCase();
                if (ua.indexOf('msie') !== -1 && ua.indexOf('8.0') !== -1)
                    this.$nodeDom[id].css("filter", "progid:DXImageTransform.Microsoft.Shadow(color=#94AAC2,direction=135,strength=2)");
                this.$workArea.append(this.$nodeDom[id]);
                this.$nodeData[id] = json;
                ++this.$nodeCount;
                if (this.$editable) {
                    this.$nodeData[id].alt = true;
                    this._node2Area(id);
                    if (this.$deletedItem[id]) delete this.$deletedItem[id];//在回退删除操作时,去掉该元素的删除记录
                }
            },
            //移动结点到一个新的位置
            moveNode: function (id, left, top) {
                //取消节点的移动
                return;
                ////移动纠正
                //top = Math.floor(top / pixWidth) * pixWidth;
                //left = Math.floor(left / pixWidth) * pixWidth;
                //if (!this.$nodeData[id]) return;
                //if (typeof this.onItemMove === 'function' && this.onItemMove(id, "node", left, top) === false) return;
                ////增加RFID不可移动
                //var nodeobj = this.getItemInfo(id, 'node');
                //if (nodeobj != undefined && nodeobj.type.indexOf('rfid') > -1) {
                //    return;
                //}

                //if (this.$undoStack) {
                //    var paras = [id, this.$nodeData[id].left, this.$nodeData[id].top];
                //    this.pushOper("moveNode", paras);
                //}
                //if (left < 0) left = 0;
                //if (top < 0) top = 0;
                //$("#" + id).css({ left: left * this.$scale + "px", top: top * this.$scale + "px" });
                //this.$nodeData[id].left = left;
                //this.$nodeData[id].top = top;
                ////重画转换线
                //this.resetLines(id, this.$nodeData[id]);
                //if (this.$editable) {
                //    this.$nodeData[id].alt = true;
                //    this._node2Area(id);
                //}
            },
            //设置结点/连线/分组区域的文字信息
            setName: function (id, name, type, setInfo) {
                var oldName;
                //节点形式的区域处理
                var _type;
                if (this.$nodeData[id] != undefined) {
                    _type = "node";
                }
                else if (this.$areaData[id] != undefined) {
                    _type = "area";
                }
                else if (this.$lineData[id] != undefined) {
                    _type = "line";
                }
                if (_type === "node") {//如果是结点
                    this.$nodeData[id].setInfo = setInfo;
                    if (!this.$nodeData[id]) return;
                    if (this.$nodeData[id].name === name) return;
                    if (typeof this.onItemRename === 'function' && this.onItemRename(id, name, "node") === false) return;
                    oldName = this.$nodeData[id].name;
                    this.$nodeData[id].name = name;
                    if (this.$nodeData[id].type.indexOf("round") > 1) {
                        this.$nodeDom[id].children(".span").text(name);
                    }
                    else {
                        this.$nodeDom[id].find("td:eq(1)").children("div").text(name);

                        var width = this.$nodeDom[id].outerWidth();
                        var height = this.$nodeDom[id].outerHeight();
                        if (this.$nodeData[id].width !== width || this.$nodeData[id].height !== height) {
                            this.$nodeDom[id].children("table").css({ width: width - 2 + "px", height: height - 2 + "px" });
                            if (this.$undoStack) {
                                var para = [id, this.$nodeData[id].width, this.$nodeData[id].height];
                                this.pushOper("resizeNode", para);
                            }
                            this.$nodeData[id].width = width;
                            this.$nodeData[id].height = height;
                        }
                    }
                    if (this.$editable) {
                        this.$nodeData[id].alt = true;
                    }
                    //重画转换线
                    this.resetLines(id, this.$nodeData[id]);
                }
                else if (_type === "line") {//如果是线
                    this.$lineData[id].setInfo = setInfo;
                    if (!this.$lineData[id]) return;
                    if (this.$lineData[id].name === name) return;
                    if (typeof this.onItemRename === 'function' && this.onItemRename(id, name, "node") === false) return;
                    oldName = this.$lineData[id].name;
                    this.$lineData[id].name = name;
                    if (GooFlow.prototype.useSVG !== "") {
                        this.$lineDom[id].childNodes[2].textContent = name;
                    }
                    else {
                        this.$lineDom[id].childNodes[1].innerHTML = name;
                        var n = this.$lineDom[id].getAttribute("fromTo").split(",");
                        var x;
                        if (this.$lineData[id].type !== "lr") {
                            x = (n[2] - n[0]) / 2;
                        }
                        else {
                            var Min = n[2] > n[0] ? n[0] : n[2];
                            if (Min > this.$lineData[id].M) Min = this.$lineData[id].M;
                            x = this.$lineData[id].M - Min;
                        }
                        if (x < 0) x = x * -1;
                        this.$lineDom[id].childNodes[1].style.left = x - this.$lineDom[id].childNodes[1].offsetWidth / 2 + 4 + "px";
                    }
                    if (this.$editable) {
                        this.$lineData[id].alt = true;
                    }
                }
                else if (_type === "area") {//如果是分组区域
                    this.$areaData[id].setInfo = setInfo;
                    if (!this.$areaData[id]) return;
                    if (this.$areaData[id].name === name) return;
                    if (typeof this.onItemRename === 'function' && this.onItemRename(id, name, "node") === false) return;
                    oldName = this.$areaData[id].name;
                    this.$areaData[id].name = name;
                    this.$areaDom[id].children("label").text(name);
                    if (this.$editable) {
                        this.$areaData[id].alt = true;
                    }
                }
                if (this.$undoStack) {
                    var paras = [id, oldName, type];
                    this.pushOper("setName", paras);
                }
            },
            //设置结点的尺寸,仅支持非开始/结束结点
            resizeNode: function (id, width, height) {
                //修改尺寸填充底格
                width = Math.ceil(width / pixWidth) * pixWidth;
                height = Math.ceil(height / pixWidth) * pixWidth;

                if (!this.$nodeData[id]) return;
                if (typeof this.onItemResize === 'function' && this.onItemResize(id, "node", width, height) === false) return;
                if (this.$nodeData[id].type === "start" || this.$nodeData[id].type === "end") return;
                if (this.$undoStack) {
                    var paras = [id, this.$nodeData[id].width, this.$nodeData[id].height];
                    this.pushOper("resizeNode", paras);
                }

                this.$nodeDom[id].children("table").css({ width: (width - 2) * this.$scale + "px", height: (height - 2) * this.$scale + "px" });
                //确保因内部文字太多而撑大时,宽高尺寸仍然是精确的
                width = this.$nodeDom[id].outerWidth();
                height = this.$nodeDom[id].outerHeight();

                this.$nodeDom[id].children("table").css({ width: width - 2 + "px", height: height - 2 + "px" });
                //确保因内部文字太多而撑大时,宽高尺寸仍然是精确的 END
                this.$nodeData[id].width = width;
                this.$nodeData[id].height = height;
                if (this.$editable) {
                    this.$nodeData[id].alt = true;
                }
                //重画转换线
                this.resetLines(id, this.$nodeData[id]);
                this._node2Area(id);
            },
            //删除结点
            delNode: function (id, trigger) {
                if (!this.$nodeData[id]) return;
                if (false !== trigger && typeof this.onItemDel === 'function' && this.onItemDel(id, "node") === false) return;

                //先删除可能的连线
                for (var k in this.$lineData) {
                    if (this.$lineData[k].from === id || this.$lineData[k].to === id) {
                        //this.$draw.removeChild(this.$lineDom[k]);
                        //delete this.$lineData[k];
                        //delete this.$lineDom[k];
                        this.delLine(k, false);
                    }
                }
                //再删除结点本身
                if (this.$undoStack) {
                    var paras = [id, this.$nodeData[id]];
                    this.pushOper("addNode", paras);
                }
                delete this.$nodeData[id];
                this.$nodeDom[id].remove();
                delete this.$nodeDom[id];
                --this.$nodeCount;
                if (this.$focus === id) this.$focus = "";

                if (this.$editable) {
                    //在回退新增操作时,如果节点ID以this.$id+"_node_"开头,则表示为本次编辑时新加入的节点,这些节点的删除不用加入到$deletedItem中
                    //if(id.indexOf(this.$id+"_node_")<0)
                    this.$deletedItem[id] = "node";
                }
            },
            //设置流程图的名称
            setTitle: function (text) {
                this.$title = text;
                if (this.$head) this.$head.children("label").attr("title", text).text(text);
            },
            //仅供内部使用:计算流程图的实际宽高(单位像素)
            _suitSize: function () {
                var maxW = 0, maxH = 0;
                for (var k1 in this.$nodeData) {
                    var node = this.$nodeData[k1];
                    if (maxW < node.width + node.left) {
                        maxW = node.width + node.left;
                    }
                    if (maxH < node.height + node.top) {
                        maxH = node.height + node.top;
                    }
                }
                for (var k2 in this.$areaData) {
                    var area = this.$areaData[k2];
                    if (maxW < area.width + area.left) {
                        maxW = area.width + area.left;
                    }
                    if (maxH < area.height + area.top) {
                        maxH = area.height + area.top;
                    }
                }
                for (var k3 in this.$lineData) {
                    var line = this.$lineData[k3];
                    if (line.M && line.type === "lt" && maxW < line.M) {
                        maxW = M + 4;
                    }
                    if (line.M && line.type === "tb" && maxH < line.M) {
                        maxH = M + 4;
                    }
                }
                return { width: maxW, height: maxH }

            },
            //载入一组数据
            loadData: function (data) {
                this.clearData();  //载入之前先清空数据 yubaolee
                var t = this.$editable;
                this.$editable = false;
                if (data.title) this.setTitle(data.title);
                if (data.initNum) this.$max = data.initNum;

                if (data != "") {
                    var length, k;
                    for (k = 0, length = data.nodes.length; k < length; k++) {
                        this.addNode(data.nodes[k].id, data.nodes[k]);
                    }
                    //huaheng 不划线
                    //for (k = 0, length = data.lines.length; k < length; k++) {
                    //    this.addLine(data.lines[k].id, data.lines[k]);
                    //}
                    for (k = 0, length = data.areas.length; k < length; k++) {
                        this.addArea(data.areas[k].id, data.areas[k]);
                    }
                }

                this.$editable = t;
                this.$deletedItem = {};
                //自行重构工作区,使之大小自适应
                var width = this.$workArea.width();
                var height = this.$workArea.height();
                var max = this._suitSize();
                while (max.width > width) {
                    width += this.$workExtendStep;
                }
                while (max.height > height) {
                    height += this.$workExtendStep;
                }
                this.$workArea.css({ height: height + "px", width: width + "px" });
                if (GooFlow.prototype.useSVG === "") {
                    this.$draw.coordsize = width + "," + height;
                }
                this.$draw.style.width = width + "px";
                this.$draw.style.height = height + "px";
                if (this.$group != null) {
                    this.$group.css({ height: height + "px", width: width + "px" });
                }
            },
            //用AJAX方式,远程读取一组数据
            //参数para为JSON结构,与JQUERY中$.ajax()方法的传参一样
            loadDataAjax: function (para) {
                var This = this;
                $.ajax({
                    type: para.type,
                    url: para.url,
                    dataType: "json",
                    data: para.data,
                    success: function (msg) {
                        if (para['dataFilter']) para['dataFilter'](msg, "json");
                        This.loadData(msg);
                        if (para.success) para.success(msg);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        if (para.error) para.error(textStatus, errorThrown);
                    }
                })
            },
            //把画好的整个流程图导出到一个变量中(其实也可以直接访问GooFlow对象的$nodeData,$lineData,$areaData这三个JSON属性)
            exportData: function () {
                var ret = {};
                ret.title = this.$title;
                ret.nodes = [];
                ret.lines = [];
                ret.areas = [];
                ret.initNum = this.$max;
                for (var k1 in this.$nodeData) {
                    if (!this.$nodeData[k1].marked) {
                        delete this.$nodeData[k1]["marked"];
                    }
                    ret.nodes.push(JSON.parse(JSON.stringify(this.$nodeData[k1])));
                    //ret.nodes[k1]=JSON.parse(JSON.stringify(this.$nodeData[k1]));
                }
                for (var k2 in this.$lineData) {
                    if (!this.$lineData[k2].marked) {
                        delete this.$lineData[k2]["marked"];
                    }
                    ret.lines.push(JSON.parse(JSON.stringify(this.$lineData[k2])));
                    // ret.lines[k2]=JSON.parse(JSON.stringify(this.$lineData[k2]));
                }
                for (var k3 in this.$areaData) {
                    if (!this.$areaData[k3].marked) {
                        delete this.$areaData[k3]["marked"];
                    }

                    ret.areas.push(JSON.parse(JSON.stringify(this.$areaData[k3])));
                    // ret.areas[k3]=JSON.parse(JSON.stringify(this.$areaData[k3]));
                }
                return ret;
            },
            //只把本次编辑流程图中作了变更(包括增删改)的元素导出到一个变量中,以方便用户每次编辑载入的流程图后只获取变更过的数据
            exportAlter: function () {
                var ret = { nodes: {}, lines: {}, areas: {} };
                for (var k1 in this.$nodeData) {
                    if (this.$nodeData[k1].alt) {
                        ret.nodes[k1] = this.$nodeData[k1];
                    }
                }
                for (var k2 in this.$lineData) {
                    if (this.$lineData[k2].alt) {
                        ret.lines[k2] = this.$lineData[k2];
                    }
                }
                for (var k3 in this.$areaData) {
                    if (this.$areaData[k3].alt) {
                        ret.areas[k3] = this.$areaData[k3];
                    }
                }
                ret.deletedItem = this.$deletedItem;
                return ret;
            },
            //变更元素的ID,一般用于快速保存后,将后台返回新元素的ID更新到页面中;type为元素类型(节点,连线,区块)
            transNewId: function (oldId, newId, type) {
                var tmp;
                switch (type) {
                    case "node":
                        if (this.$nodeData[oldId]) {
                            tmp = this.$nodeData[oldId];
                            delete this.$nodeData[oldId];
                            this.$nodeData[newId] = tmp;
                            tmp = this.$nodeDom[oldId].attr("id", newId);
                            delete this.$nodeDom[oldId];
                            this.$nodeDom[newId] = tmp;
                        }
                        break;
                    case "line":
                        if (this.$lineData[oldId]) {
                            tmp = this.$lineData[oldId];
                            delete this.$lineData[oldId];
                            this.$lineData[newId] = tmp;
                            tmp = this.$lineDom[oldId].attr("id", newId);
                            delete this.$lineDom[oldId];
                            this.$lineDom[newId] = tmp;
                        }
                        break;
                    case "area":
                        if (this.$areaData[oldId]) {
                            tmp = this.$areaData[oldId];
                            delete this.$areaData[oldId];
                            this.$areaData[newId] = tmp;
                            tmp = this.$areaDom[oldId].attr("id", newId);
                            delete this.$areaDom[oldId];
                            this.$areaDom[newId] = tmp;
                        }
                        break;
                }
            },
            //清空工作区及已载入的数据
            clearData: function () {
                for (var k1 in this.$nodeData) {
                    this.delNode(k1);
                }
                for (var k2 in this.$lineData) {
                    this.delLine(k2);
                }
                for (var k3 in this.$areaData) {
                    this.delArea(k3);
                }
                this.$deletedItem = {};
            },
            //销毁自己
            destrory: function () {
                this.$bgDiv.empty();
                this.$lineData = null;
                this.$nodeData = null;
                this.$lineDom = null;
                this.$nodeDom = null;
                this.$areaDom = null;
                this.$areaData = null;
                this.$nodeCount = 0;
                this.$areaCount = 0;
                this.$areaCount = 0;
                this.$deletedItem = {};
            },
            ///////////以下为有关画线的方法
            //绘制一条箭头线,并返回线的DOM
            drawLine: function (id, sp, ep, mark, dash, $scale) {
                var line, text;
                var x = (ep[0] + sp[0]) / 2, y = (ep[1] + sp[1]) / 2;
                if (GooFlow.prototype.useSVG !== "") {
                    line = document.createElementNS("http://www.w3.org/2000/svg", "g");
                    var hi = document.createElementNS("http://www.w3.org/2000/svg", "path");
                    var path = document.createElementNS("http://www.w3.org/2000/svg", "path");

                    if (id !== "") line.setAttribute("id", id);
                    line.setAttribute("from", sp[0] + "," + sp[1]);
                    line.setAttribute("to", ep[0] + "," + ep[1]);
                    hi.setAttribute("visibility", "hidden");
                    hi.setAttribute("stroke-width", '9');
                    hi.setAttribute("fill", "none");
                    hi.setAttribute("stroke", "white");
                    hi.setAttribute("d", "M " + sp[0] + " " + sp[1] + " L " + ep[0] + " " + ep[1]);
                    hi.setAttribute("pointer-events", "stroke");
                    path.setAttribute("d", "M " + sp[0] + " " + sp[1] + " L " + ep[0] + " " + ep[1]);
                    path.setAttribute("stroke-width", mark ? '2.4' : '1.4');
                    path.setAttribute("stroke-linecap", "round");
                    path.setAttribute("fill", "none");
                    if (dash) path.setAttribute("style", "stroke-dasharray:6,5");
                    if (mark) {
                        path.setAttribute("stroke", GooFlow.color.mark);
                        path.setAttribute("marker-end", "url(#arrow2)");
                    }
                    else {
                        path.setAttribute("stroke", GooFlow.color.line);
                        path.setAttribute("marker-end", "url(#arrow1)");
                    }
                    line.appendChild(hi);
                    line.appendChild(path);
                    line.style.cursor = "crosshair";
                    if (id !== "" && id !== "GooFlow_tmp_line") {
                        text = document.createElementNS("http://www.w3.org/2000/svg", "text");
                        text.setAttribute("fill", GooFlow.color.lineFont);
                        line.appendChild(text);

                        text.setAttribute("text-anchor", "middle");
                        text.setAttribute("x", x + '');
                        text.setAttribute("y", y + '');
                        text.style.cursor = "text";
                        text.style.fontSize = 14 * $scale + "px";
                        line.style.cursor = "pointer";
                    }
                } else {
                    line = document.createElement("v:polyline");
                    if (id !== "") line.id = id;
                    //line.style.position="absolute";
                    line.points.value = sp[0] + "," + sp[1] + " " + ep[0] + "," + ep[1];
                    line.setAttribute("fromTo", sp[0] + "," + sp[1] + "," + ep[0] + "," + ep[1]);
                    line.strokeWeight = "1.2";
                    line.stroke.EndArrow = "Block";
                    line.style.cursor = "crosshair";
                    if (id !== "" && id !== "GooFlow_tmp_line") {
                        text = document.createElement("div");
                        //text.innerHTML=id;
                        line.appendChild(text);
                        if (x < 0) x = x * -1;
                        if (y < 0) y = y * -1;
                        text.style.left = x + "px";
                        text.style.top = y - 6 + "px";
                        text.style.color = GooFlow.color.lineFont;
                        text.style.fontSize = 14 * $scale + "px";
                        line.style.cursor = "pointer";
                    }
                    if (dash) line.stroke.dashStyle = "Dash";
                    if (mark) line.strokeColor = GooFlow.color.mark;
                    else line.strokeColor = GooFlow.color.line;
                    line.fillColor = GooFlow.color.line;
                }
                return line;
            },
            //画一条只有两个中点的折线
            drawPoly: function (id, sp, m1, m2, ep, mark, dash, $scale) {
                var poly, strPath, text;
                var x = (m2[0] + m1[0]) / 2, y = (m2[1] + m1[1]) / 2;
                if (GooFlow.prototype.useSVG !== "") {
                    poly = document.createElementNS("http://www.w3.org/2000/svg", "g");
                    var hi = document.createElementNS("http://www.w3.org/2000/svg", "path");
                    var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
                    if (id !== "") poly.setAttribute("id", id);
                    poly.setAttribute("from", sp[0] + "," + sp[1]);
                    poly.setAttribute("to", ep[0] + "," + ep[1]);
                    hi.setAttribute("visibility", "hidden");
                    hi.setAttribute("stroke-width", '9');
                    hi.setAttribute("fill", "none");
                    hi.setAttribute("stroke", "white");
                    strPath = "M " + sp[0] + " " + sp[1];
                    if (m1[0] !== sp[0] || m1[1] !== sp[1])
                        strPath += " L " + m1[0] + " " + m1[1];
                    if (m2[0] !== ep[0] || m2[1] !== ep[1])
                        strPath += " L " + m2[0] + " " + m2[1];
                    strPath += " L " + ep[0] + " " + ep[1];
                    hi.setAttribute("d", strPath);
                    hi.setAttribute("pointer-events", "stroke");
                    path.setAttribute("d", strPath);
                    path.setAttribute("stroke-width", mark ? '2.4' : '1.4');
                    path.setAttribute("stroke-linecap", "round");
                    path.setAttribute("fill", "none");
                    if (dash) path.setAttribute("style", "stroke-dasharray:6,5");
                    if (mark) {
                        path.setAttribute("stroke", GooFlow.color.mark);
                        path.setAttribute("marker-end", "url(#arrow2)");
                    }
                    else {
                        path.setAttribute("stroke", GooFlow.color.line);
                        path.setAttribute("marker-end", "url(#arrow1)");
                    }
                    poly.appendChild(hi);
                    poly.appendChild(path);
                    text = document.createElementNS("http://www.w3.org/2000/svg", "text");
                    text.setAttribute("fill", GooFlow.color.lineFont);
                    poly.appendChild(text);
                    text.setAttribute("text-anchor", "middle");
                    text.setAttribute("x", x + '');
                    text.setAttribute("y", y + '');
                    text.style.cursor = "text";
                }
                else {
                    poly = document.createElement("v:Polyline");
                    if (id !== "") poly.id = id;
                    poly.filled = "false";
                    strPath = sp[0] + "," + sp[1];
                    if (m1[0] !== sp[0] || m1[1] !== sp[1])
                        strPath += " " + m1[0] + "," + m1[1];
                    if (m2[0] !== ep[0] || m2[1] !== ep[1])
                        strPath += " " + m2[0] + "," + m2[1];
                    strPath += " " + ep[0] + "," + ep[1];
                    poly.points.value = strPath;
                    poly.setAttribute("fromTo", sp[0] + "," + sp[1] + "," + ep[0] + "," + ep[1]);
                    poly.strokeWeight = mark ? "2.4" : "1.2";
                    poly.stroke.EndArrow = "Block";
                    text = document.createElement("div");
                    //text.innerHTML=id;
                    poly.appendChild(text);
                    if (x < 0) x = x * -1;
                    if (y < 0) y = y * -1;
                    text.style.left = x + "px";
                    text.style.top = y - 4 + "px";
                    text.style.color = GooFlow.color.lineFont;
                    if (dash) poly.stroke.dashStyle = "Dash";
                    if (mark) poly.strokeColor = GooFlow.color.mark;
                    else poly.strokeColor = GooFlow.color.line;
                }
                poly.style.cursor = "pointer";
                text.style.fontSize = 14 * $scale + "px";
                return poly;
            },
            //原lineData已经设定好的情况下,只在绘图工作区画一条线的页面元素
            addLineDom: function (id, lineData) {
                var n1 = this.$nodeData[lineData.from], n2 = this.$nodeData[lineData.to];//获取开始/结束结点的数据
                if (!n1 || !n2) return;
                //开始计算线端点坐标
                var res;
                if (lineData.type && lineData.type !== "sl")
                    res = calcPolyPoints(n1, n2, lineData.type, lineData.M, this.$scale);
                else
                    res = calcStartEnd(n1, n2, this.$scale);
                if (!res) return;

                if (lineData.type === "sl")
                    this.$lineDom[id] = GooFlow.prototype.drawLine(id, res.start, res.end, lineData.marked, lineData.dash, this.$scale);
                else
                    this.$lineDom[id] = GooFlow.prototype.drawPoly(id, res.start, res.m1, res.m2, res.end, lineData.marked, lineData.dash, this.$scale);
                this.$draw.appendChild(this.$lineDom[id]);
                if (GooFlow.prototype.useSVG === "") {
                    this.$lineDom[id].childNodes[1].innerHTML = lineData.name;
                    if (lineData.type !== "sl") {
                        var Min = (res.start[0] > res.end[0] ? res.end[0] : res.start[0]);
                        if (Min > res.m2[0]) Min = res.m2[0];
                        if (Min > res.m1[0]) Min = res.m1[0];
                        this.$lineDom[id].childNodes[1].style.left = (res.m2[0] + res.m1[0]) / 2 - Min - this.$lineDom[id].childNodes[1].offsetWidth / 2 + 4;
                        Min = (res.start[1] > res.end[1] ? res.end[1] : res.start[1]);
                        if (Min > res.m2[1]) Min = res.m2[1];
                        if (Min > res.m1[1]) Min = res.m1[1];
                        this.$lineDom[id].childNodes[1].style.top = (res.m2[1] + res.m1[1]) / 2 - Min - this.$lineDom[id].childNodes[1].offsetHeight / 2;
                    } else
                        this.$lineDom[id].childNodes[1].style.left =
                            ((res.end[0] - res.start[0]) * (res.end[0] > res.start[0] ? 1 : -1) - this.$lineDom[id].childNodes[1].offsetWidth) / 2 + 4;
                }
                else {
                    this.$lineDom[id].childNodes[2].textContent = lineData.name;
                }
            },
            //增加一条线
            addLine: function (id, json) {
                if (json.id == undefined) {
                    $.extend(json, { id: id });
                }
                if (typeof this.onItemAdd === 'function' && this.onItemAdd(id, "line", json) === false) return;
                if (this.$undoStack && this.$editable) {
                    this.pushOper("delLine", [id]);
                }
                if (json.from === json.to) return;
                var n1 = this.$nodeData[json.from], n2 = this.$nodeData[json.to];//获取开始/结束结点的数据
                if (!n1 || !n2) return;
                //避免两个节点间不能有一条以上同向接连线
                for (var k in this.$lineData) {
                    if ((json.from === this.$lineData[k].from && json.to === this.$lineData[k].to && json.dash === this.$lineData[k].dash))
                        return;
                }
                //设置$lineData[id]
                this.$lineData[id] = {};
                if (json.type) {
                    this.$lineData[id].type = json.type;
                    this.$lineData[id].M = json.M;
                }
                else this.$lineData[id].type = "sl";//默认为直线
                this.$lineData[id].from = json.from;
                this.$lineData[id].to = json.to;
                this.$lineData[id].id = json.id;  //赋值ID
                this.$lineData[id].setInfo = json.setInfo;
                this.$lineData[id].name = json.name;
                if (json.marked) this.$lineData[id].marked = json.marked;
                else this.$lineData[id].marked = false;
                if (json.dash) this.$lineData[id].dash = json.dash;
                else this.$lineData[id].dash = false;
                //设置$lineData[id]完毕

                this.addLineDom(id, this.$lineData[id]);

                ++this.$lineCount;
                if (this.$editable) {
                    this.$lineData[id].alt = true;
                    if (this.$deletedItem[id]) delete this.$deletedItem[id];//在回退删除操作时,去掉该元素的删除记录
                }
            },
            //重构所有连向某个结点的线的显示,传参结构为$nodeData数组的一个单元结构
            resetLines: function (id, node) {
                for (var i in this.$lineData) {
                    var other = null;//获取结束/开始结点的数据
                    var res;
                    if (this.$lineData[i].from === id) {//找结束点
                        other = this.$nodeData[this.$lineData[i].to] || null;
                        if (other == null) continue;
                        if (this.$lineData[i].type === "sl")
                            res = calcStartEnd(node, other, this.$scale);
                        else
                            res = calcPolyPoints(node, other, this.$lineData[i].type, this.$lineData[i].M, this.$scale);
                        if (!res) break;
                    }
                    else if (this.$lineData[i].to === id) {//找开始点
                        other = this.$nodeData[this.$lineData[i].from] || null;
                        if (other == null) continue;
                        if (this.$lineData[i].type === "sl")
                            res = calcStartEnd(other, node, this.$scale);
                        else
                            res = calcPolyPoints(other, node, this.$lineData[i].type, this.$lineData[i].M, this.$scale);
                        if (!res) break;
                    }
                    if (other == null) continue;
                    this.$draw.removeChild(this.$lineDom[i]);
                    if (this.$lineData[i].type === "sl") {
                        this.$lineDom[i] = GooFlow.prototype.drawLine(i, res.start, res.end, this.$lineData[i].marked, this.$lineData[i].dash, this.$scale);
                    }
                    else {
                        this.$lineDom[i] = GooFlow.prototype.drawPoly(i, res.start, res.m1, res.m2, res.end, this.$lineData[i].marked, this.$lineData[i].dash, this.$scale);
                    }
                    this.$draw.appendChild(this.$lineDom[i]);
                    if (GooFlow.prototype.useSVG === "") {
                        this.$lineDom[i].childNodes[1].innerHTML = this.$lineData[i].name;
                        if (this.$lineData[i].type !== "sl") {
                            var Min = (res.start[0] > res.end[0] ? res.end[0] : res.start[0]);
                            if (Min > res.m2[0]) Min = res.m2[0];
                            if (Min > res.m1[0]) Min = res.m1[0];
                            this.$lineDom[i].childNodes[1].style.left = (res.m2[0] + res.m1[0]) / 2 - Min - this.$lineDom[i].childNodes[1].offsetWidth / 2 + 4;
                            Min = (res.start[1] > res.end[1] ? res.end[1] : res.start[1]);
                            if (Min > res.m2[1]) Min = res.m2[1];
                            if (Min > res.m1[1]) Min = res.m1[1];
                            this.$lineDom[i].childNodes[1].style.top = (res.m2[1] + res.m1[1]) / 2 - Min - this.$lineDom[i].childNodes[1].offsetHeight / 2 - 4;
                        } else
                            this.$lineDom[i].childNodes[1].style.left =
                                ((res.end[0] - res.start[0]) * (res.end[0] > res.start[0] ? 1 : -1) - this.$lineDom[i].childNodes[1].offsetWidth) / 2 + 4;
                    }
                    else this.$lineDom[i].childNodes[2].textContent = this.$lineData[i].name;
                }
            },
            //重新设置连线的样式 newType= "sl":直线, "lr":中段可左右移动型折线, "tb":中段可上下移动型折线
            setLineType: function (id, newType, M) {
                if (!newType || newType == null || newType === "" || newType === this.$lineData[id].type) return false;
                if (typeof this.onLineSetType === 'function' && this.onLineSetType(id, newType) === false) return;
                if (this.$undoStack) {
                    var paras = [id, this.$lineData[id].type, this.$lineData[id].M];
                    this.pushOper("setLineType", paras);
                }
                var from = this.$lineData[id].from;
                var to = this.$lineData[id].to;
                this.$lineData[id].type = newType;
                var res;
                //如果是变成折线
                if (newType !== "sl") {
                    //res=calcPolyPoints(this.$nodeData[from],this.$nodeData[to],this.$lineData[id].type,this.$lineData[id].M, this.$scale);
                    if (M) {
                        this.setLineM(id, M, true);
                    } else {
                        this.setLineM(id, getMValue(this.$nodeData[from], this.$nodeData[to], newType), true);
                    }
                }
                //如果是变回直线
                else {
                    delete this.$lineData[id].M;
                    this.$lineMove.hide().removeData("type").removeData("tid");
                    res = calcStartEnd(this.$nodeData[from], this.$nodeData[to], this.$scale);
                    if (!res) return;
                    this.$draw.removeChild(this.$lineDom[id]);
                    this.$lineDom[id] = GooFlow.prototype.drawLine(id, res.start, res.end, this.$lineData[id].marked, this.$lineData[id].dash, this.$scale);
                    this.$draw.appendChild(this.$lineDom[id]);
                    if (GooFlow.prototype.useSVG === "") {
                        this.$lineDom[id].childNodes[1].innerHTML = this.$lineData[id].name;
                        this.$lineDom[id].childNodes[1].style.left =
                            ((res.end[0] - res.start[0]) * (res.end[0] > res.start[0] ? 1 : -1) - this.$lineDom[id].childNodes[1].offsetWidth) / 2 + 4;
                    }
                    else
                        this.$lineDom[id].childNodes[2].textContent = this.$lineData[id].name;
                }
                if (this.$focus === id) {
                    this.focusItem(id);
                }
                if (this.$editable) {
                    this.$lineData[id].alt = true;
                }
            },
            //设置折线中段的X坐标值(可左右移动时)或Y坐标值(可上下移动时)
            setLineM: function (id, M, noStack) {
                if (!this.$lineData[id] || M < 0 || !this.$lineData[id].type || this.$lineData[id].type === "sl") return false;
                if (typeof this.onLineMove === 'function' && this.onLineMove(id, M) === false) return false;
                if (this.$undoStack && !noStack) {
                    var paras = [id, this.$lineData[id].M];
                    this.pushOper("setLineM", paras);
                }
                var from = this.$lineData[id].from;
                var to = this.$lineData[id].to;
                this.$lineData[id].M = M;
                var ps = calcPolyPoints(this.$nodeData[from], this.$nodeData[to], this.$lineData[id].type, this.$lineData[id].M, this.$scale);
                this.$draw.removeChild(this.$lineDom[id]);
                this.$lineDom[id] = GooFlow.prototype.drawPoly(id, ps.start, ps.m1, ps.m2, ps.end, this.$lineData[id].marked, this.$lineData[id].dash, this.$scale);
                this.$draw.appendChild(this.$lineDom[id]);
                if (GooFlow.prototype.useSVG === "") {
                    this.$lineDom[id].childNodes[1].innerHTML = this.$lineData[id].name;
                    var Min = (ps.start[0] > ps.end[0] ? ps.end[0] : ps.start[0]);
                    if (Min > ps.m2[0]) Min = ps.m2[0];
                    if (Min > ps.m1[0]) Min = ps.m1[0];
                    this.$lineDom[id].childNodes[1].style.left = (ps.m2[0] + ps.m1[0]) / 2 - Min - this.$lineDom[id].childNodes[1].offsetWidth / 2 + 4;
                    Min = (ps.start[1] > ps.end[1] ? ps.end[1] : ps.start[1]);
                    if (Min > ps.m2[1]) Min = ps.m2[1];
                    if (Min > ps.m1[1]) Min = ps.m1[1];
                    this.$lineDom[id].childNodes[1].style.top = (ps.m2[1] + ps.m1[1]) / 2 - Min - this.$lineDom[id].childNodes[1].offsetHeight / 2 - 4;
                }
                else this.$lineDom[id].childNodes[2].textContent = this.$lineData[id].name;
                if (this.$editable) {
                    this.$lineData[id].alt = true;
                }
            },
            //删除转换线
            delLine: function (id, trigger) {
                if (!this.$lineData[id]) return;
                if (false !== trigger && typeof this.onItemDel === 'function' && this.onItemDel(id, "node") === false) return;

                if (this.$undoStack) {
                    var paras = [id, this.$lineData[id]];
                    this.pushOper("addLine", paras);
                }
                this.$draw.removeChild(this.$lineDom[id]);
                delete this.$lineData[id];
                delete this.$lineDom[id];
                if (this.$focus === id) this.$focus = "";
                --this.$lineCount;
                if (this.$editable) {
                    //在回退新增操作时,如果节点ID以this.$id+"_line_"开头,则表示为本次编辑时新加入的节点,这些节点的删除不用加入到$deletedItem中
                    // if(id.indexOf(this.$id+"_line_")<0)
                    this.$deletedItem[id] = "line";
                    this.$mpFrom.hide().removeData("p");
                    this.$mpTo.hide().removeData("p");
                }
                if (this.$lineOper) {
                    this.$lineOper.hide().removeData("tid");
                }
            },
            //变更连线两个端点所连的结点
            //参数:要变更端点的连线ID,新的开始结点ID、新的结束结点ID;如果开始/结束结点ID是传入null或者"",则表示原端点不变
            moveLinePoints: function (lineId, newStart, newEnd, noStack) {
                if (newStart === newEnd) return;
                if (!lineId || !this.$lineData[lineId]) return;
                if (newStart == null || newStart === "")
                    newStart = this.$lineData[lineId].from;
                if (newEnd == null || newEnd === "")
                    newEnd = this.$lineData[lineId].to;

                //避免两个节点间不能有一条以上同向接连线
                for (var k in this.$lineData) {
                    if ((newStart === this.$lineData[k].from && newEnd === this.$lineData[k].to))
                        return;
                }
                if (typeof this.onLinePointMove === 'function' && this.onLinePointMove(lineId, newStart, newEnd) === false) return;
                if (this.$undoStack && !noStack) {
                    var paras = [lineId, this.$lineData[lineId].from, this.$lineData[lineId].to];
                    this.pushOper("moveLinePoints", paras);
                }
                if (newStart != null && newStart !== "") {
                    this.$lineData[lineId].from = newStart;
                }
                if (newEnd != null && newEnd !== "") {
                    this.$lineData[lineId].to = newEnd;
                }
                //重建转换线
                this.$draw.removeChild(this.$lineDom[lineId]);
                this.addLineDom(lineId, this.$lineData[lineId]);
                if (this.$editable) {
                    this.$lineData[lineId].alt = true;
                }
            },

            //用颜色标注/取消标注一个结点或转换线,常用于显示重点或流程的进度。
            //这是一个在编辑模式中无用,但是在纯浏览模式中非常有用的方法,实际运用中可用于跟踪流程的进度。
            markItem: function (id, type, mark) {
                if (type === "node") {
                    if (!this.$nodeData[id]) return;
                    if (typeof this.onItemMark === 'function' && this.onItemMark(id, "node", mark) === false) return;
                    this.$nodeData[id].marked = mark || false;
                    if (mark) {
                        this.$nodeDom[id].addClass("item_mark").css("border-color", GooFlow.color.mark);
                    }
                    else {
                        this.$nodeDom[id].removeClass("item_mark");
                        if (id !== this.$focus) this.$nodeDom[id].css("border-color", "transparent");
                    }

                } else if (type === "line") {
                    if (!this.$lineData[id]) return;
                    if (this.onItemMark != null && !this.onItemMark(id, "line", mark)) return;
                    this.$lineData[id].marked = mark || false;
                    if (GooFlow.prototype.useSVG !== "") {
                        if (mark) {
                            this.$lineDom[id].childNodes[1].setAttribute("stroke", GooFlow.color.mark);
                            this.$lineDom[id].childNodes[1].setAttribute("marker-end", "url(#arrow2)");
                            this.$lineDom[id].childNodes[1].setAttribute("stroke-width", 2.4);
                        } else {
                            this.$lineDom[id].childNodes[1].setAttribute("stroke", GooFlow.color.line);
                            this.$lineDom[id].childNodes[1].setAttribute("marker-end", "url(#arrow1)");
                            this.$lineDom[id].childNodes[1].setAttribute("stroke-width", 1.4);
                        }
                    } else {
                        if (mark) {
                            this.$lineDom[id].strokeColor = GooFlow.color.mark;
                            this.$lineDom[id].strokeWeight = "2.4";
                        }
                        else {
                            this.$lineDom[id].strokeColor = GooFlow.color.line;
                            this.$lineDom[id].strokeWeight = "1.2";
                        }
                    }
                }
                if (this.$undoStack) {
                    var paras = [id, type, !mark];
                    this.pushOper("markItem", paras);
                }
            },
            ////////////////////////以下为区域分组块操作
            //传入一个区域组(泳道)的ID,判断图中所有结点在此区域组(泳道)的范围内
            _areaFixNodes: function (areaId) {
                var area = this.$areaData[areaId];
                for (var key in this.$nodeData) {
                    var node = this.$nodeData[key];
                    if (node.left >= area.left && node.left < area.left + area.width &&
                        node.top >= area.top && node.top < area.top + area.height
                    ) {
                        node.areaId = areaId;
                    } else if (node.areaId && node.areaId === areaId) {
                        this._node2Area(key);
                    }
                }
            },
            moveArea: function (id, left, top) {
                //取消区域的移动
                return;

                //if (!this.$areaData[id]) return;
                //if (this.onItemMove != null && !this.onItemMove(id, "area", left, top)) return;
                //if (this.$undoStack) {
                //    var paras = [id, this.$areaData[id].left, this.$areaData[id].top];
                //    this.pushOper("moveArea", paras);
                //}
                //if (left < 0) left = 0;
                //if (top < 0) top = 0;
                //$("#" + id).css({ left: left * this.$scale + "px", top: top * this.$scale + "px" });
                //this.$areaData[id].left = left;
                //this.$areaData[id].top = top;
                //if (this.$editable) {
                //    this.$areaData[id].alt = true;
                //    this._areaFixNodes(id);
                //}
            },
            //删除区域分组
            delArea: function (id, trigger) {
                if (!this.$areaData[id]) return;
                if (this.$undoStack) {
                    var paras = [id, this.$areaData[id]];
                    this.pushOper("addArea", paras);
                }
                if (false !== trigger && typeof this.onItemDel === 'function' && this.onItemDel(id, "node") === false) return;
                delete this.$areaData[id];
                this.$areaDom[id].remove();
                delete this.$areaDom[id];
                --this.$areaCount;
                if (this.$editable) {
                    //在回退新增操作时,如果节点ID以this.$id+"_area_"开头,则表示为本次编辑时新加入的节点,这些节点的删除不用加入到$deletedItem中
                    //if(id.indexOf(this.$id+"_area_")<0)
                    for (var key in this.$nodeData) {
                        var node = this.$nodeData[key];
                        if (node.areaId === id) {
                            delete node.areaId
                        }
                    }
                    this.$deletedItem[id] = "area";
                }
            },
            //设置区域分组的颜色
            setAreaColor: function (id, color) {
                if (!this.$areaData[id]) return;
                if (this.$undoStack) {
                    var paras = [id, this.$areaData[id].color];
                    this.pushOper("setAreaColor", paras);
                }
                if (color === "red" || color === "yellow" || color === "blue" || color === "green") {
                    this.$areaDom[id].removeClass("area_" + this.$areaData[id].color).addClass("area_" + color);
                    this.$areaData[id].color = color;
                }
                if (this.$editable) {
                    this.$areaData[id].alt = true;
                }
            },
            //设置区域分块的尺寸
            resizeArea: function (id, width, height) {
                //修改尺寸填充底格
                width = Math.ceil(width / pixWidth) * pixWidth;
                height = Math.ceil(height / pixWidth) * pixWidth;
                if (!this.$areaData[id]) return;
                if (typeof this.onItemResize === 'function' && this.onItemResize(id, "area", width, height) === false) return;
                var This = this.$areaData[id];
                var _flag = false;

                if (This.color == "user_group") {
                    var _in = false;
                    var _out = true;
                    //通道分组 必须放在运行区,且与别的通道分组不能重合!
                    for (var i in this.$areaData) {
                        //不检查自身
                        if (this.$areaData[i].id !== This.id) {
                            var json1 = {
                                Left: This.left,
                                Top: This.top,
                                Width: width,
                                Height: height,
                            };
                            var json2 = {
                                Left: this.$areaData[i].left,
                                Top: this.$areaData[i].top,
                                Width: this.$areaData[i].width,
                                Height: this.$areaData[i].height,
                            };

                            if (this.$areaData[i].color == "user_yunxingqu") {
                                if (width == pixWidth && height == pixWidth) {
                                    if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                                        _in = true;
                                    }
                                }
                                else {
                                    _in = true;
                                }
                            }
                            else {
                                if (this.$areaData[i].color == "user_group") {
                                    if (this.CheckPut(json1, json2) !== "out" || this.CheckPut(json2, json1) !== "out") {
                                        _out = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (_in && _out) {
                        if (width !== pixWidth || height !== pixWidth) {
                            //横向判断每个单元格是否都在运行区中
                            for (var j = 0; j < width; j = j + pixWidth) {
                                _in = false;
                                var json1 = {
                                    Left: This.left + j,
                                    Top: This.top,
                                    Width: pixWidth,
                                    Height: pixWidth,
                                };

                                for (var i in this.$areaData) {
                                    //不检查自身
                                    if (this.$areaData[i].id !== This.id) {
                                        var json2 = {
                                            Left: this.$areaData[i].left,
                                            Top: this.$areaData[i].top,
                                            Width: this.$areaData[i].width,
                                            Height: this.$areaData[i].height,
                                        };

                                        if (this.$areaData[i].color == "user_yunxingqu") {
                                            if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                                                _in = true;
                                                break;
                                            }
                                        }
                                    }
                                }

                                if (!_in) {
                                    break;
                                }
                            }

                            if (_in) {
                                //纵向判断每个单元格是否都在运行区中
                                for (var j = 0; j < height; j = j + pixWidth) {
                                    _in = false;
                                    var json1 = {
                                        Left: This.left,
                                        Top: This.top + j,
                                        Width: pixWidth,
                                        Height: pixWidth,
                                    };

                                    for (var i in this.$areaData) {
                                        //不检查自身
                                        if (this.$areaData[i].id !== This.id) {
                                            var json2 = {
                                                Left: this.$areaData[i].left,
                                                Top: this.$areaData[i].top,
                                                Width: this.$areaData[i].width,
                                                Height: this.$areaData[i].height,
                                            };

                                            if (this.$areaData[i].color == "user_yunxingqu") {
                                                if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                                                    _in = true;
                                                    break;
                                                }
                                            }
                                        }
                                    }

                                    if (!_in) {
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (_in && _out) {
                        _flag = true;
                    }

                    if (!_flag) {
                        console.log("通道分组 必须放在运行区,且与别的通道分组不能重合!");
                    }
                }
                else {
                    //生产线,仓储区,运行区, 停车区,放料区, 取料区 改变尺寸时,不能出现重叠!
                    var _out = true;
                    for (var i in this.$areaData) {
                        //不检查自身,不检查rfid点
                        if (this.$areaData[i].id !== This.id && this.$areaData[i].color.indexOf("user_rfid") == -1 && this.$areaData[i].color !== "user_group") {
                            var json1 = {
                                Left: This.left,
                                Top: This.top,
                                Width: width,
                                Height: height,
                            };
                            var json2 = {
                                Left: this.$areaData[i].left,
                                Top: this.$areaData[i].top,
                                Width: this.$areaData[i].width,
                                Height: this.$areaData[i].height,
                            };
                            console.log(this.CheckPut(json1, json2));
                            console.log(this.CheckPut(json2, json1));
                            if (this.CheckPut(json1, json2) !== "out" || this.CheckPut(json2, json1) !== "out") {
                                _out = false;
                                break;
                            }
                        }
                    }
                    if (_out) {
                        _flag = true;
                    }
                    if (!_flag) {
                        console.log("所有区域模块互相干涉,不能重叠!");
                    }
                }

                if (!_flag) {
                    return;
                }

                //对象改变尺寸时,不能漏出内部的对象
                if (This.color !== "user_group") {
                    _flag = false;
                    var _inNum_before = 0;
                    var _inNum_after = 0;
                    //分别计算改变前后区域中的对象数
                    //for (var i in this.$nodeData) {
                    //    if (this.$nodeData[i].id !== This.id) {
                    //        var json1 = {
                    //            Left: this.$nodeData[i].left,
                    //            Top: this.$nodeData[i].top,
                    //            Width: pixWidth,
                    //            Height: pixWidth,
                    //        };
                    //        var json2 = {
                    //            Left: This.left,
                    //            Top: This.top,
                    //            Width: This.width,
                    //            Height: This.height,
                    //        };
                    //        var json3 = {
                    //            Left: This.left,
                    //            Top: This.top,
                    //            Width: width,
                    //            Height: height,
                    //        };
                    //        if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                    //            _inNum_before++;
                    //        }
                    //        if (this.CheckPut(json1, json3) == "equal" || this.CheckPut(json1, json3) == "in") {
                    //            _inNum_after++;
                    //        }
                    //    }
                    //}

                    for (var i in this.$areaData) {
                        if (this.$areaData[i].id !== This.id) {
                            var json1 = {
                                Left: this.$areaData[i].left,
                                Top: this.$areaData[i].top,
                                Width: pixWidth,
                                Height: pixWidth,
                            };
                            var json2 = {
                                Left: This.left,
                                Top: This.top,
                                Width: This.width,
                                Height: This.height,
                            };
                            var json3 = {
                                Left: This.left,
                                Top: This.top,
                                Width: width,
                                Height: height,
                            };
                            if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                                _inNum_before++;
                            }
                            if (this.CheckPut(json1, json3) == "equal" || this.CheckPut(json1, json3) == "in") {
                                _inNum_after++;
                            }
                        }
                    }

                    //运行区改变尺寸时,才计算内部的区域数
                    if (This.color == "user_yunxingqu") {
                        for (var i in this.$areaData) {
                            if (this.$areaData[i].id !== This.id) {
                                var json1 = {
                                    Left: this.$areaData[i].left,
                                    Top: this.$areaData[i].top,
                                    Width: this.$areaData[i].width,
                                    Height: this.$areaData[i].height,
                                };
                                var json2 = {
                                    Left: This.left,
                                    Top: This.top,
                                    Width: This.width,
                                    Height: This.height,
                                };
                                var json3 = {
                                    Left: This.left,
                                    Top: This.top,
                                    Width: width,
                                    Height: height,
                                };

                                if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                                    _inNum_before++;
                                }
                                if (this.CheckPut(json1, json3) == "equal" || this.CheckPut(json1, json3) == "in") {
                                    _inNum_after++;
                                }
                            }
                        }
                    }

                    if (_inNum_before == _inNum_after) {
                        _flag = true;
                    }

                    if (!_flag) {
                        console.log("尺寸改变后,内部对象不能漏出!");
                    }
                }

                if (!_flag) {
                    return;
                }

                if (this.$undoStack) {
                    var paras = [id, this.$areaData[id].width, this.$areaData[id].height];
                    this.pushOper("resizeArea", paras);
                }

                this.$areaDom[id].children(".bg").css({ width: width * this.$scale + "px", height: height * this.$scale + "px" });
                this.$areaData[id].width = width;
                this.$areaData[id].height = height;
                if (this.$editable) {
                    this.$areaData[id].alt = true;
                    this._areaFixNodes(id);
                }

                //增加变更尺寸时文字居中
                if (This.color == "user_cangchuqu" || This.color == "user_zhangaiqu" || This.color == "user_shengchanxian") {
                    this.$areaDom[id].children("label").css({ left: "0px", "line-height": height * this.$scale + "px", width: width * this.$scale + "px", });
                }
            },
            addArea: function (id, json) {
                if (json.id == undefined) {
                    $.extend(json, { id: id });
                }

                if (!json.width || json.width < (pixWidth - 2)) json.width = (pixWidth - 2);
                if (!json.height || json.height < (pixWidth - 2)) json.height = (pixWidth - 2);
                if (!json.top || json.top < 0) json.top = 0;
                if (!json.left || json.left < 0) json.left = 0;
                //在此修改尺寸为30整数
                json.top = Math.floor(json.top / pixWidth) * pixWidth;
                json.left = Math.floor(json.left / pixWidth) * pixWidth;

                if (typeof this.onItemAdd === 'function' && this.onItemAdd(id, "area", json) === false) return;

                if (this.$undoStack && this.$editable) {
                    this.pushOper("delArea", [id]);
                }


                //修改区域图块样式,不显示名称和图标
                if (json.color == "user_shengchanxian") {
                    this.$areaDom[id] = $("<div id='" + id + "' class='GooFlow_area area_" + json.color
                        + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px'><div class='bg' style='width:" + (json.width * this.$scale) + "px;height:" + (json.height * this.$scale) + "px'></div>"
                        + "<label style='color:green;left:0px;pointer-events: none;line-height:" + (json.height * this.$scale) + "px;text-align:center;width:" + (json.width * this.$scale) + "px;'>" + json.name + "</label><div><div class='rs_bottom'></div><div class='rs_right'></div><div class='rs_rb'></div><div class='rs_close'></div></div></div>");
                }
                else if (json.color == "user_cangchuqu" || json.color == "user_zhangaiqu") {
                    this.$areaDom[id] = $("<div id='" + id + "' class='GooFlow_area area_" + json.color
                        + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px'><div class='bg' style='width:" + (json.width * this.$scale) + "px;height:" + (json.height * this.$scale) + "px'></div>"
                        + "<label style='color:orange;left:0px;pointer-events: none;line-height:" + (json.height * this.$scale) + "px;text-align:center;width:" + (json.width * this.$scale) + "px;'>" + json.name + "</label><div><div class='rs_bottom'></div><div class='rs_right'></div><div class='rs_rb'></div><div class='rs_close'></div></div></div>");
                }
                else if (json.color == "user_group") {
                    //不显示尺寸变更和删除图标
                    this.$areaDom[id] = $("<div id='" + id + "' class='GooFlow_area area_" + json.color
                        + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px;border: solid 2px red;pointer-events: none;margin: -2px;'><div style='width:" + (json.width * this.$scale) + "px;height:" + (json.height * this.$scale) + "px;pointer-events: none;'></div>"
                        + "</div></div>");
                }
                else if (json.color == "user_chongdianzhuang1" || json.color == "user_chongdianzhuang0") {
                    //不显示尺寸变更图标
                    this.$areaDom[id] = $("<div id='" + id + "' class='GooFlow_area area_" + json.color
                        + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px'><div class='bg' style='width:" + (json.width * this.$scale) + "px;height:" + (json.height * this.$scale) + "px'></div>"
                        + "<label style='color:blue;font-size:12px;font-weight:bold;left:0px;pointer-events: none;line-height:" + (json.height * this.$scale) + "px;text-align:center;width:" + (json.width * this.$scale) + "px;'>" + json.name + "</label><div><div class='rs_close'></div></div></div>");
                }

                else if (json.color.indexOf("user_rfid") > -1) {
                    //不显示尺寸变更图标,显示RFID
                    var rfid = json.name;

                    if (this.$fastMode) {
                        if (json.setInfo == undefined || json.setInfo == null) {
                            let row = json.top / 30 + 1;
                            let col = (json.left / 30 + 1).toString().padStart(2, '0');
                            var last = Object.keys(this.$areaData)
                                .find(i => this.$areaData[i].top == json.top
                                    && this.$areaData[i].left == json.left - 30
                                    && !!this.$areaData[i].setInfo && !!this.$areaData[i].setInfo.RFID && this.$areaData[i].color != "user_fangliaoqu");
                            last = this.$areaData[last];

                            json.setInfo = {};
                            // json.color = "user_yunxingqu";
                            json.height = 30;
                            json.width = 30;
                            json.alt = true;
                            json.setInfo.Id = id;


                            for (var i in this.$areaData) {
                                var _area = this.$areaData[i];
                                if (_area.color.indexOf("user_rfid") > -1) {
                                    if (!json.setInfo.chk_up) {
                                        json.setInfo.chk_up = _area.left == json.left && _area.top < json.top;
                                    }
                                    if (!json.setInfo.chk_down) {
                                        json.setInfo.chk_down = _area.left == json.left && _area.top > json.top;
                                    }
                                    if (!json.setInfo.chk_left) {
                                        json.setInfo.chk_left = _area.top == json.top && _area.left < json.left;
                                    }
                                    if (!json.setInfo.chk_right) {
                                        json.setInfo.chk_right = _area.top == json.top && _area.left > json.left;
                                    }

                                }
                            }


                            var color = json.color.slice(0, -4);
                            color = color + Number(json.setInfo.chk_up || 0) + Number(json.setInfo.chk_right || 0) + Number(json.setInfo.chk_down || 0) + Number(json.setInfo.chk_left || 0);
                            //json.setInfo.chk_down = last?.chk_down ?? false;
                            //json.setInfo.chk_up = last?.chk_up ?? false;
                            //json.setInfo.chk_left = last?.chk_left ?? false;
                            //json.setInfo.chk_right = last?.chk_right ?? false;
                            json.color = color;
                            //json.setInfo.pint_area = json.color;
                            json.setInfo.point_type = "1";//运行点
                            json.setInfo.IntXC = 0;
                            json.setInfo.IntYC = 0;
                            json.setInfo.DialDirectionXPos = 0;
                            json.setInfo.DialDirectionXNeg = 0;
                            json.setInfo.DialDirectionYPos = 0;
                            json.setInfo.DialDirectionYNeg = 0;
                            json.setInfo.AgvDirectionXPos = 0;
                            json.setInfo.AgvDirectionXNeg = 0;
                            json.setInfo.AgvDirectionYPos = 0;
                            json.setInfo.AgvDirectionYNeg = 0;

                            json.setInfo.SpeedXPos = 30;
                            json.setInfo.SpeedXNeg = 30;
                            json.setInfo.SpeedYPos = 30;
                            json.setInfo.SpeedYNeg = 30;

                            json.setInfo.RadarXPos = 3;
                            json.setInfo.RadarXNeg = 3;
                            json.setInfo.RadarYPos = 3;
                            json.setInfo.RadarYNeg = 3;
                            json.setInfo.AdjustIn = 0;
                            json.setInfo.AdjustOut = 0;
                            json.setInfo.ArcingLevel = 0;
                            json.setInfo.RFID = row + col;

                            json.name = json.setInfo.RFID;
                            json.setInfo.point_area = this.getPointArea(json);
                        }

                    }


                    if (json.setInfo != undefined && json.setInfo != null) {
                        if (json.setInfo.RFID != undefined && json.setInfo.RFID != null) {
                            rfid = json.setInfo.RFID;
                        }
                    }

                    var dom = `<div id='${id}' class='GooFlow_area area_${json.color}' style='z-index:1; top:${json.top * this.$scale}px;left:${json.left * this.$scale}px'>
                        <div class='bg' style='width:${json.width * this.$scale}px;height:${json.height * this.$scale}px'></div>
                        <label class='switchRFID' style='color:blue;font-size:12px;font-weight:bold;left:0px;pointer-events: none;line-height:${json.height * this.$scale}px;text-align:center;width:${json.width * this.$scale}px;'>${rfid}</label>
                        <div><div class='rs_close'></div></div>
                        </div>`;
                    this.$areaDom[id] = $(dom);
                }
                else {
                    this.$areaDom[id] = $("<div id='" + id + "' class='GooFlow_area area_" + json.color
                        + "' style='top:" + json.top * this.$scale + "px;left:" + json.left * this.$scale + "px'><div class='bg' style='width:" + (json.width * this.$scale) + "px;height:" + (json.height * this.$scale) + "px'></div>"
                        + "<div><div class='rs_bottom'></div><div class='rs_right'></div><div class='rs_rb'></div><div class='rs_close'></div></div></div>");
                }




                this.$areaData[id] = json;

                if (json.color.indexOf("user_agv") > -1) {
                    this.$workArea.append(this.$areaDom[id]);
                } else {
                    this.$group.append(this.$areaDom[id]);
                }

                $(".GooFlow_area.area_user_cangchuqu .bg").css("background-image", "url('/images/map/qy/ccq/ccq_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_zhangaiqu .bg").css("background-image", "url('/images/map/qy/zaq/zaq_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_shengchanxian .bg").css("background-image", "url('/images/map/qy/xtq/xtq_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_yunxingqu .bg").css("background-image", "url('/images/map/qy/yxq/yxq_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_tingchequ .bg").css("background-image", "url('/images/map/qy/tcq/tcq_" + Math.floor(30 * this.$scale) + ".png')");

                $(".GooFlow_area.area_user_diantiqu_xz .bg").css("background-image", "url('/images/map/qy/dtq_xz/dtq_xz_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_diantiqu_yx .bg").css("background-image", "url('/images/map/qy/dtq_yx/dtq_yx_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_diantiqu_gz .bg").css("background-image", "url('/images/map/qy/dtq_gz/dtq_gz_" + Math.floor(30 * this.$scale) + ".png')");

                $(".GooFlow_area.area_user_tishengjiqu_xz .bg").css("background-image", "url('/images/map/qy/tsjq_xz/tsjq_xz_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_tishengjiqu_yx .bg").css("background-image", "url('/images/map/qy/tsjq_yx/tsjq_yx_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_tishengjiqu_gz .bg").css("background-image", "url('/images/map/qy/tsjq_gz/tsjq_gz_" + Math.floor(30 * this.$scale) + ".png')");

                $(".GooFlow_area.area_user_fangliaoqu .bg").css("background-image", "url('/images/map/qy/flq/flq_" + Math.floor(30 * this.$scale) + ".png')");
                $(".GooFlow_area.area_user_quliaoqu .bg").css("background-image", "url('/images/map/qy/qlq/qlq_" + Math.floor(30 * this.$scale) + ".png')");

                if (this.$nowType !== "group")
                    this.$areaDom[id].children("div:eq(1)").css("display", "none");
                ++this.$areaCount;
                if (this.$editable) {
                    this.$areaData[id].alt = true;
                    this._areaFixNodes(id);
                    if (this.$deletedItem[id]) delete this.$deletedItem[id];//在回退删除操作时,去掉该元素的删除记录
                }
            },
            reloadArea: function (id) {

                var json = this.$areaData[id];
                var ele = this.$areaDom[id]?.[0];
                if (ele) {
                    delete this.$areaDom[id];
                    this.$group[0].removeChild(ele);
                }
                this.addArea(id, json)
                    ;
            },
            getPointArea: function (object) {

                var point_area = "";
                var areas = this.$areaData;
                for (var i in areas) {
                    if (areas[i].color !== "user_group") {
                        var json1 = {
                            Left: object.left,
                            Top: object.top,
                            Width: object.width,
                            Height: object.height,
                        };
                        var json2 = {
                            Left: areas[i].left,
                            Top: areas[i].top,
                            Width: areas[i].width,
                            Height: areas[i].height,
                        };
                        if (this.CheckPut(json1, json2) == "in" || this.CheckPut(json1, json2) == "equal") {
                            if (areas[i].color == "user_yunxingqu") {
                                point_area = areas[i].color;
                                break;
                            }
                            else if (areas[i].color == "user_tingchequ") {
                                point_area = areas[i].color;
                                break;
                            }
                            else if (areas[i].color == "user_quliaoqu" || areas[i].color == "user_fangliaoqu") {
                                point_area = areas[i].color;
                                break;
                            }
                            else if (areas[i].color.indexOf("user_diantiqu") > -1) {
                                point_area = areas[i].color;
                                break;
                            }
                            else if (areas[i].color.indexOf("user_tishengjiqu") > -1) {
                                point_area = areas[i].color;
                                break;
                            }
                        }
                    }
                }

                return point_area;

            },
            //重构整个流程图设计器的宽高
            reinitSize: function (width, height) {
                var w = (width || this.$bgDiv.width());
                var h = (height || this.$bgDiv.height());
                this.$bgDiv.css({ height: h + "px", width: w + "px" });
                var headHeight = 0, hack = 8;
                if (this.$head != null) {
                    headHeight = 26;
                    hack = 5;
                }
                if (this.$tool != null) {
                    this.$tool.css({ height: h - headHeight - hack + "px" });
                    w -= 31;
                }
                w -= 9;
                h = h - headHeight - (this.$head != null ? 5 : 8);
                //this.$workArea.parent().css({height:h+"px",width:w+"px"});

                if (this.$workArea.width() > w) {
                    w = this.$workArea.width();
                }
                if (this.$workArea.height() > h) {
                    h = this.$workArea.height();
                }

                this.$workArea.css({ height: h + "px", width: w + "px" });
                if (GooFlow.prototype.useSVG === "") {
                    this.$draw.coordsize = w + "," + h;
                }
                this.$draw.style.width = w + "px";
                this.$draw.style.height = h + "px";
                if (this.$group != null) {
                    this.$group.css({ height: h + "px", width: w + "px" });
                }
            },
            //重设整个工作区内容的显示缩放比例,从0.5至4倍
            resetScale: function (scale) {
                if (!scale) scale = 1.0;
                else if (scale < 0.5) scale = 0.5;
                else if (scale > 4) scale = 4;
                //以上是固定死取值范围:不让用户缩放过大或过小,已免无意中影响的显示效果
                if (this.$scale === scale) return;
                var oldS = this.$scale;
                this.$scale = scale;
                var factor = oldS / scale;//因数(旧缩放比例除以新缩放比例),元素的现有值除以该因子,就能得到新的缩放后的值
                var W = 0, H = 0, P = {};//宽、高、左及上的临时变量
                //开始正式的缩放(节点、连线、泳道块有宽高和定位,其它编辑工具元素则只有定位)(全部以左上角为原点)
                this.blurItem();
                //先缩放工作区
                W = this.$workArea.width() / factor;
                H = this.$workArea.height() / factor;
                this.$workArea.css({ "height": H + "px", "width": W + "px" });
                if (GooFlow.prototype.useSVG !== "") {

                } else {
                    this.$draw.coordsize = W + "," + H;
                }
                this.$draw.style.width = W + "px";
                this.$draw.style.height = H + "px";
                if (this.$group != null) {
                    this.$group.css({ height: H + "px", width: W + "px" });
                }
                //缩放节点
                var isWebkit = navigator.userAgent.toLowerCase().indexOf('webkit') > -1;
                this.$workArea.children(".GooFlow_item").each(function () {
                    var This = $(this);
                    P = This.position();
                    This.css({ "left": P.left / factor + "px", "top": P.top / factor + "px" });
                    This = This.children("table");
                    W = This.outerWidth() / factor;
                    H = This.outerHeight() / factor;
                    This.css({ "width": W + "px", "height": H + "px" });
                    var tmp = 18 * scale;
                    This.find("td[class='ico']").css({ width: tmp + "px" });
                    var newSize = {};
                    if (tmp < 12 && isWebkit) {
                        newSize["width"] = "18px"; newSize["height"] = "18px";
                        newSize["font-size"] = "18px";
                        newSize["transform"] = "scale(" + (tmp / 18) + ")";
                        newSize["margin"] = -((18 - tmp) / 2) + "px";
                    } else {
                        newSize["width"] = tmp + "px"; newSize["height"] = tmp + "px";
                        newSize["font-size"] = tmp + "px";
                        newSize["transform"] = "none";
                        newSize["margin"] = "0px auto";
                    }
                    This.find("td[class='ico']").children("i").css(newSize);

                    tmp = 14 * scale;
                    if (This.parent().find(".span").length === 1) {
                        This.parent().css("border-radius", W / 2 + "px");
                        This = This.parent().find(".span");
                        This.css({ "font-size": tmp + "px" });
                    } else {
                        This = This.find("td:eq(1) div");
                        newSize = {};
                        if (tmp < 12 && isWebkit) {
                            newSize["font-size"] = "14px";
                            newSize["transform"] = "scale(" + (tmp / 14) + ")";
                            var mW = (W / scale - 18 - (W - 18 * scale)) / 2;
                            var mH = (H / scale - H) / 2;
                            newSize["margin"] = -mH + "px " + (-mW) + "px";
                        } else {
                            newSize["transform"] = "none";
                            newSize["font-size"] = tmp + "px";
                            newSize["margin"] = "0px";
                        }
                        This.css(newSize);
                    }
                });
                //缩放区域图
                var ifs = 16 * scale + 2;
                if (this.$group != null) {
                    this.$group.children(".GooFlow_area").each(function () {
                        var This = $(this);
                        P = This.position();
                        This.css({ "left": P.left / factor + "px", "top": P.top / factor + "px" });
                        This = This.children("div:eq(0)");
                        W = This.outerWidth() / factor;
                        H = This.outerHeight() / factor;
                        This.css({ "width": W + "px", "height": H + "px" });
                        This.next("label").css({
                            "font-size": 14 * scale + "px",
                            "left": ifs + 3 + "px"
                        }).next("i").css({
                            "font-size": ifs - 2 + "px",
                            width: ifs + "px",
                            height: ifs + "px",
                            "line-height": ifs + "px"
                        });

                        //增加变更尺寸时文字居中
                        var _class = This.context.attributes["class"].nodeValue;
                        if (_class.indexOf("user_cangchuqu") > -1 || _class.indexOf("user_zhangaiqu") > -1 || _class.indexOf("user_shengchanxian") > -1) {
                            $(This.prevObject[0].childNodes[1]).css({ left: "0px", "line-height": H + "px", width: W + "px", });
                        }
                    });
                }
                //缩放连线
                for (var id in this.$lineDom) {
                    this.$draw.removeChild(this.$lineDom[id]);
                    delete this.$lineDom[id];
                }
                for (var key in this.$lineData) {
                    this.addLineDom(key, this.$lineData[key]);
                }
            },
            CheckPut: function (putobj, container) {
                //判断对象是否在容器中
                if (
                    (putobj.Left == container.Left && putobj.Width == container.Width)
                    && (putobj.Top == container.Top && putobj.Height == container.Height)
                ) {
                    //完全相等
                    return "equal";
                }
                else if (
                    (putobj.Left >= container.Left && putobj.Left + putobj.Width <= container.Left + container.Width) //对象水平方向包含在容器中
                    && (putobj.Top >= container.Top && putobj.Top + putobj.Height <= container.Top + container.Height) //对象垂直方向包含在容器中
                ) {
                    //在容器中
                    return "in";
                }
                else if (
                    (putobj.Left > container.Left && putobj.Left < container.Left + container.Width && putobj.Top > container.Top && putobj.Top < container.Top + container.Height) //对象左上顶点在容器中
                    || (putobj.Left + putobj.Width > container.Left && putobj.Left + putobj.Width < container.Left + container.Width && putobj.Top > container.Top && putobj.Top < container.Top + container.Height) //对象右上顶点在容器中
                    || (putobj.Left > container.Left && putobj.Left < container.Left + container.Width && putobj.Top + putobj.Height > container.Top && putobj.Top + putobj.Height < container.Top + container.Height) //对象左下顶点在容器中
                    || (putobj.Left + putobj.Width > container.Left && putobj.Left + putobj.Width < container.Left + container.Width && putobj.Top + putobj.Height > container.Top && putobj.Top + putobj.Height < container.Top + container.Height) //对象右下顶点在容器中
                ) {
                    //有个别顶点在容器中重合部分
                    return "cover";
                }
                else if (
                    (putobj.Height == container.Height && putobj.Top == container.Top && ((putobj.Left > container.Left && putobj.Left < container.Left + container.Width) || (putobj.Left + putobj.Width > container.Left && putobj.Left + putobj.Width < container.Left + container.Width))) //水平方向重叠
                    || (putobj.Width == container.Width && putobj.Left == container.Left && ((putobj.Top > container.Top && putobj.Top < container.Top + container.Height) || (putobj.Top + putobj.Height > container.Top && putobj.Top + putobj.Height < container.Top + container.Height))) //垂直方向重叠
                ) {
                    //有个别边在容器中重合部分
                    return "cover";
                }
                else {
                    //如果对象的面积小于容器面积时
                    var obj1, obj2;
                    if (putobj.Width * putobj.Height >= container.Width * container.Height) {
                        obj1 = putobj;
                        obj2 = container;
                    }
                    else {
                        obj1 = container;
                        obj2 = putobj;
                    }

                    //横向判断每个单元格是否都在容器外中
                    for (var j = 0; j < obj1.Width; j = j + pixWidth) {
                        var json1 = {
                            Left: obj1.Left + j,
                            Top: obj1.Top,
                            Width: pixWidth,
                            Height: pixWidth,
                        };

                        var json2 = {
                            Left: obj2.Left,
                            Top: obj2.Top,
                            Width: obj2.Width,
                            Height: obj2.Height,
                        };

                        if (
                            (json1.Left == json2.Left && json1.Width == json2.Width)
                            && (json1.Top == json2.Top && json1.Height == json2.Height)
                        ) {
                            return "cover";
                        }
                        else if (
                            (json1.Left >= json2.Left && json1.Left + json1.Width <= json2.Left + json2.Width) //对象水平方向包含在容器中
                            && (json1.Top >= json2.Top && json1.Top + json1.Height <= json2.Top + json2.Height) //对象垂直方向包含在容器中
                        ) {
                            return "cover";
                        }
                    }

                    //纵向判断每个单元格是否都在运行区中
                    for (var j = 0; j < obj1.Height; j = j + pixWidth) {
                        var json1 = {
                            Left: obj1.Left,
                            Top: obj1.Top + j,
                            Width: pixWidth,
                            Height: pixWidth,
                        };

                        var json2 = {
                            Left: obj2.Left,
                            Top: obj2.Top,
                            Width: obj2.Width,
                            Height: obj2.Height,
                        };

                        if (
                            (json1.Left == json2.Left && json1.Width == json2.Width)
                            && (json1.Top == json2.Top && json1.Height == json2.Height)
                        ) {
                            return "cover";
                        }
                        else if (
                            (json1.Left >= json2.Left && json1.Left + json1.Width <= json2.Left + json2.Width) //对象水平方向包含在容器中
                            && (json1.Top >= json2.Top && json1.Top + json1.Height <= json2.Top + json2.Height) //对象垂直方向包含在容器中
                        ) {
                            return "cover";
                        }
                    }

                    //否则就是在外面
                    return "out";
                }
            },
            CheckGroup: function (groupObj) {
                var _flag = false;

                var This = groupObj;
                var width = This.width;
                var height = This.height;

                if (This.color == "user_group") {
                    var _in = false;
                    var _out = true;

                    //通道分组 必须放在运行区,且与别的通道分组不能重合!
                    for (var i in this.$areaData) {
                        var json1 = {
                            Left: This.left,
                            Top: This.top,
                            Width: width,
                            Height: height,
                        };
                        var json2 = {
                            Left: this.$areaData[i].left,
                            Top: this.$areaData[i].top,
                            Width: this.$areaData[i].width,
                            Height: this.$areaData[i].height,
                        };

                        if (this.$areaData[i].color == "user_yunxingqu") {
                            //if (width == pixWidth && height == pixWidth) {
                            //    if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                            //        _in = true;
                            //    }
                            //}
                            //else {
                            //    _in = true;
                            //}
                            //限行区不一定完全在运行区中, 2020/09/16 处理公共区域互斥问题
                            _in = true;
                        }
                        else {
                            if (this.$areaData[i].color == "user_group") {
                                if (this.CheckPut(json1, json2) !== "out" || this.CheckPut(json2, json1) !== "out") {
                                    _out = false;
                                    break;
                                }
                            }
                        }
                    }

                    if (_in && _out) {
                        //限行区不一定完全在运行区中, 2020/09/16 处理公共区域互斥问题

                        //if (width !== pixWidth || height !== pixWidth) {
                        //    //横向判断每个单元格是否都在运行区中
                        //    for (var j = 0; j < width; j = j + pixWidth) {
                        //        _in = false;
                        //        var json1 = {
                        //            Left: This.left + j,
                        //            Top: This.top,
                        //            Width: pixWidth,
                        //            Height: pixWidth,
                        //        };
                        //        for (var i in this.$areaData) {
                        //            var json2 = {
                        //                Left: this.$areaData[i].left,
                        //                Top: this.$areaData[i].top,
                        //                Width: this.$areaData[i].width,
                        //                Height: this.$areaData[i].height,
                        //            };

                        //            if (this.$areaData[i].color == "user_yunxingqu") {
                        //                if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                        //                    _in = true;
                        //                    break;
                        //                }
                        //            }
                        //        }
                        //        if (!_in) {
                        //            break;
                        //        }
                        //    }

                        //    if (_in) {
                        //        //纵向判断每个单元格是否都在运行区中
                        //        for (var j = 0; j < height; j = j + pixWidth) {
                        //            _in = false;
                        //            var json1 = {
                        //                Left: This.left,
                        //                Top: This.top + j,
                        //                Width: pixWidth,
                        //                Height: pixWidth,
                        //            };
                        //            for (var i in this.$areaData) {
                        //                var json2 = {
                        //                    Left: this.$areaData[i].left,
                        //                    Top: this.$areaData[i].top,
                        //                    Width: this.$areaData[i].width,
                        //                    Height: this.$areaData[i].height,
                        //                };

                        //                if (this.$areaData[i].color == "user_yunxingqu") {
                        //                    if (this.CheckPut(json1, json2) == "equal" || this.CheckPut(json1, json2) == "in") {
                        //                        _in = true;
                        //                        break;
                        //                    }
                        //                }
                        //            }

                        //            if (!_in) {
                        //                break;
                        //            }
                        //        }
                        //    }
                        //}
                    }

                    if (_in && _out) {
                        _flag = true;
                    }
                }

                return _flag;
            },
            GetUserArea: function (dir, type, length) {
                if (dir === "left") {
                    var last = Object.keys(this.$areaData)
                        .find(i => {
                            let node = this.$areaData[i];
                            return node.top == json.top
                                && node.left == json.left - length
                                && node.color == type;
                        });
                }

                return this.$areaData[last];

            }
        };
        //默认的颜色样式
        GooFlow.color = {
            //main:"#20A0FF",
            font: "#15428B",
            node: "#C0CCDA",
            line: "#1D8CE0",
            lineFont: "#777",
            mark: "#ff8800",
            mix: "#B6F700",
            mixFont: "#777"
        };
        //默认的文字说明注释内容
        GooFlow.remarks = {
            headBtns: {},
            toolBtns: {},
            extendRight: undefined,
            extendBottom: undefined
        };
        //当不想使用jquery插件式初始化方法时,另一种通过直接调用GooFlow内部构造方法进行的初始化
        GooFlow.init = function (selector, property) {
            return new GooFlow(selector, property);
        };
        //在初始化出一个对象前的公用方法:覆盖设定GooFlow默认的颜色定义
        GooFlow.setColors = function (colors) {
            $.extend(GooFlow.color, colors);
        };
        //扩展GooFlow方法的扩展用接口,一般用在CMD,AMD
        GooFlow.extend = function (json) {
            for (var funcName in json) {
                GooFlow.prototype[funcName] = json[funcName];
            }
        };
        //将此类的构造函数加入至JQUERY对象中
        $.extend({
            createGooFlow: function (selector, property) {
                return new GooFlow(selector, property);
            }
        });

        exports('mapdesign/gooflow');
    });