system.js 118 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
var SelectorSource = {},
    importFileName = ["form", "table", "tableEdit", "element", "jquery"];
if (typeof customImportFileName != "undefined") importFileName = customImportFileName;

/*时间格式化 new Date(n).format("yyyymmddhhMMss") */
Date.prototype.format = function (format) {
    var o =
    {
        "M+": this.getMonth() + 1,                   //month
        "d+": this.getDate(),                        //day
        "h+": this.getHours(),                       //hour
        "m+": this.getMinutes(),                     //minute
        "s+": this.getSeconds(),                     //second
        "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
        "S": this.getMilliseconds()                  //millisecond
    }
    if (/(y+)/.test(format))
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    return format;
}

/*时间差*/
String.prototype.GetDateDiff = function (statr, end) {
    if (statr == null || end == null) return "";
    var diff = new Date(end).getTime() - new Date(statr).getTime();   //时间差的毫秒数

    //计算出相差天数
    var days = Math.floor(diff / (24 * 3600 * 1000));

    //计算出小时数
    var leave1 = diff % (24 * 3600 * 1000);      //计算天数后剩余的毫秒数
    var hours = Math.floor(leave1 / (3600 * 1000));

    //计算相差分钟数
    var leave2 = leave1 % (3600 * 1000);        //计算小时数后剩余的毫秒数
    var minutes = Math.floor(leave2 / (60 * 1000));

    //计算相差秒数
    var leave3 = leave2 % (60 * 1000);         //计算分钟数后剩余的毫秒数
    var seconds = Math.round(leave3 / 1000);
    var value = "";
    if (days != 0) value = days + "天";
    if (hours != 0) value += hours + "小时";
    if (minutes != 0) value += minutes + "分钟";
    if (seconds != 0) value += seconds + "秒";
    return value;
}

/* 数组去掉重复*/
Array.prototype.unique5 = function () {
    var x = new Set(this);
    return [...x];
}

//判断元素是否在数组中 nowValue比较的值、field字段
Array.prototype.contains = function (nowValue, field,) {
    for (var i = 0; i < this.length; i++) {
        if (nowValue == this[i][field]) {
            return true;
        }
    }
    return false;
}

//根据索引删除数组
Array.prototype.removeIndex = function (dx) {
    if (isNaN(dx) || dx > this.length) { return false; }
    this.splice(dx, 1);
}

//根据某个特定的值删除数组中的指定元素
Array.prototype.removeByVal = function (field, nowValue) {
    if (isNaN(nowValue) || this.length==0) { return false; }
    for (var i = 0; i < this.length; i++) {
        if (this[i][field] == nowValue ) {
            this.splice(i, 1);
            return true;
        }
    }
    return false;
}


//取数组对象某个值  keys:条件的列名,comparisonValue:条件值,comparisonKeys:返回的列名
Array.prototype.GetArrValue = function (keys, comparisonValue = "", comparisonKeys = "", isRetrunString = true) {
    var temp = this.map(function (e) {
        if (comparisonValue != "") {
            if (e[keys] == comparisonValue) return e[comparisonKeys];
        } else {
            return e[keys];
        }
    });
    if (temp.length === 0) {
        console.log("GetArrValue is null");
        return null;
    }
    return isRetrunString ? temp.filter(d => d).join() : temp;
}

//取数组对象符合符合条件的行,返回是数组对象
Array.prototype.GetArrValueRow = function (key, val) {
    return this.filter(item => item[key] == val);
}

/*数组插入指定位置 */
Array.prototype.insertExtend = function (index, value) {
    this.splice(index, 0, value);
};

//最大值
Array.prototype.max = function () {
    return Math.max.apply({}, this);
}

//最小值
Array.prototype.min = function () {
    return Math.min.apply({}, this);
}
//数组复制
Array.prototype.copy = function () {
    let [...tempArr] = this;
    return tempArr;
}

//类型判断
String.prototype.typeX = function (obj) {
    return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
}

//对象复制
String.prototype.copyObj = function (obj) {
    let { ...json2 } = obj;
    return json2;
}

//对象浅复制 
String.prototype.copyObj2 = function (obj) {
    let objA = Object.assign({}, obj);
    return objA;
}

//参数拼接  id=1&id2=2 格式 
String.prototype.parseParamExtend = function (obj) {
    var str = [];
    for (var p in obj) {
        if (!Object.prototype.hasOwnProperty.call(obj, p)) continue;
        str.push(p + "=" + obj[p]);
    }
    return str.join("&");
}

//获取url中指定参数值,没有值返回 null 如果出现乱码 请使用 encodeURIComponent 编码
String.prototype.GetUrlParam = function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return decodeURIComponent(r[2]); return null;
}

/*数字每隔三位加逗号分开*/
String.prototype.Locale = function (value) {
    if (typeof value === 'undefined' || value == null) return 0;
    const temp = Number(value);
    return temp < 999 ? value : Number(value).toLocaleString();
};

/*获取状态*/
String.prototype.GetState = function (data, value) {
	if (!data) console.error("GetState方法 数据源data is null")
    let isOk = false;
    let val = "";
    for (var item in data) {
        if (!Object.prototype.hasOwnProperty.call(data, item)) continue;
        if (data[item] == value) {
            isOk = true;
            val = item;
            break;
        }
    }
    return isOk ? val : value;
}


/*获取物料名称*/
String.prototype.GetMaterialName = function (data, key, returnKey, value) {
    let isOk = false;
    let val = "";
    for (var i = 0; i < data.length; i++) {
        if (data[i][key] == "") continue;
        if (data[i][key] == value) {
            val = data[i][returnKey];
            isOk = true;
            break;
        }
    }
    return isOk ? val : value;
}

/*判断是否为空*/
String.prototype.isEmpty = function (value) {
    return typeof value === 'undefined' || value === null || value.length <= 0;
}
/*判断是数字 true:数字*/
String.prototype.isNumber = function (value) {
    if ("".isEmpty(value)) return false;
    return /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);
}

/*判断是正数字 true:正整数*/
String.prototype.isDigits = function (value) {
    if ("".isEmpty(value)) return false;
    return /^\d+$/.test(value);
}

/*XSS 编码*/
String.prototype.XssEscape = function (e) {
    return e === undefined || null === e ? "" : /[<"'>]|&(?=#[a-zA-Z0-9]+)/g.test(e += "") ? e.replace(/&(?!#?[a-zA-Z0-9]+;)/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&#39;").replace(/"/g, "&quot;") : e
}
/*XSS 解码*/
String.prototype.XssUnescape = function (e) {
    return e !== undefined && null !== e || (e = ""),
        (e += "").replace(/\&amp;/g, "&").replace(/\&lt;/g, "<").replace(/\&gt;/g, ">").replace(/\&#39;/g, "'").replace(/\&quot;/g, '"')
}


/*ztree 获取当前选中节点的子节点集合 */
String.prototype.GetChildNodes = function (ztreeObj, treeNode, arrReturnKey = "id") {
    var childNodes = ztreeObj.transformToArray(treeNode);
    var nodes = new Array();
    for (let i = 0; i < childNodes.length; i++) {
        nodes[i] = childNodes[i][arrReturnKey];
    }
    return nodes;
}

/**
 * name layui合并tbody中单元格的方法
 * @param fieldName  要合并列的field属性值
 * @param index 表格的索引值 从1开始
 * @desc 此方式适用于没有列冻结=的单元格合并
 */
String.prototype.tableRowSpan = function (fieldName, index) {
    var fixedNode = document.getElementsByClassName("layui-table-body")[index - 1];
    if (!fixedNode) {
        return false;
    }
    var child = fixedNode.getElementsByTagName("td");
    var childFilterArr = [];
    // 获取data-field属性为fieldName的td
    for (let i = 0; i < child.length; i++) {
        if (child[i].getAttribute("data-field") == fieldName) {
            childFilterArr.push(child[i]);
        }
    }
    // 获取td的个数和种类
    var childFilterTextObj = {};
    for (let i = 0; i < childFilterArr.length; i++) {
        var childText = childFilterArr[i].textContent;
        if (childFilterTextObj[childText] == undefined) {
            childFilterTextObj[childText] = 1;
        } else {
            var num = childFilterTextObj[childText];
            childFilterTextObj[childText] = num * 1 + 1;
        }
    }
    // 给获取到的td设置合并单元格属性
    for (var key in childFilterTextObj) {
        var tdNum = childFilterTextObj[key];
        var canRowSpan = true;
        for (let i = 0; i < childFilterArr.length; i++) {
            if (childFilterArr[i].textContent == key) {
                if (canRowSpan) {
                    childFilterArr[i].setAttribute("rowspan", tdNum);
                    canRowSpan = false;
                } else {
                    childFilterArr[i].style.display = "none";
                }
            }
        }
    }
    return true;
}


layui.define(importFileName, function (exports) {
    var form = layui.form,
        carousel = layui.carousel,
        element = layui.element,
        layer = layui.layer,
        laydate = layui.laydate,
        $ = layui.jquery,
        tableEdit = layui.tableEdit,
        $document = $(document),
        tableSelect = layui.tableSelect,
        excel = layui.excel,
        table = layui.table,
        flow = layui.flow,
        treeTable = layui.treeTable,
        timeStamprowClick = 0,
        timeInitFormEvent = 0,
        timeDocumentClick = 0,
        footerSuffix = "Footer",
        descSuffix = "Desc";
    if (treeTable != undefined) table = treeTable;

    let systemAction = null, sU;

    var u = function () {
        this.config = {
            tokenInvalid: "登入信息已失效,系统将自动跳转到登入页!",
            urlLogin: "/Login/Index",
            titleError: "请检查服务是否开启,反复出现请联系管理员",
            titleAdd: "新增",
            titleEdit: "编辑<span style=\"color:red;font-weight: bold;\">(系统编码请谨慎修改!)</span>",

            titleDeleteId: "删除操作keys值为空,请确认核实!",
            titleDeleteSuccess: "删除成功",
            titleUpdateSuccess: "修改成功",
            titleAddSuccess: "新增成功",
            titleSchedulingSuccess: "排产成功",
            titleSelectOneRowData: "请至少选择一条数据!",
            titleSelectOne: "请选择一条数据!",
            titleOpen: "提示",
            titleConfirmDelete: "确定要删除所选信息吗?",
            titleTime: "开始时间不能大于结束时间",
            titleActionSuccess: "操作成功",
            titleDataNull: "查询无数据!",
            title404: "您访问的页面资源不存在,请核实!",

            titleCopyAdd: "复制新增",
            titleQcCodePrint: "二维码打印",
            errorTime: 5000,
            msgOpenTime: 2000,
            iconoOk: 1,
            iconoError: 2,
            ignoreEvent: ["LAYTABLE_COLS"],

            btnRefreshLoadIndex: -1,

            checkTableRowData: null,
            checkTableALLRowData: null,
            colsWidthFlag:"_colsWidth"
        }
    }
    //cookie Token 失效返回登入页
    u.prototype.cookieVerification = function () {
        var i = this;
        var cookie = i.cookie("Token");
        if (cookie == null) {
            layer.msg(i.config.tokenInvalid, { icon: i.config.iconoError, shade: 0.4, time: 2000 });
            setTimeout(function () {
                window.location.href = i.config.urlLogin;
            }, 2500);
        }
    }

    //cookie set ,read[value 是空 read]
    u.prototype.cookie = function (key, value, options) {
        if (typeof value !== "undefined") {//write
            options = options || {}
            var cookie = encodeURIComponent(key) + "=" + encodeURIComponent(value);
            if (typeof options.expries === "number") {
                var date = new Date();
                date.setDate(date.getDate() + options.expries);
                cookie += ";expries=" + date.toUTCString();
            }
            if (options.path) cookie += ";path=" + options.path;
            if (options.domain) cookie += ";domain=" + options.domain;
            if (options.secure) cookie += ";secure";
            document.cookie = cookie;
        }
        var cookies = document.cookie.split(";");
        for (var i = 0; i < cookies.length; i++) {
            var readCookie = cookies[i].split("=");
            var name = decodeURIComponent(readCookie.shift());
            if ($.trim(name) === key) return decodeURIComponent(readCookie.join("="));
        }
        return null;
    }

    //ajax //服务器返回json存在特殊字符或者是对象里面包含字符串需要手动拼接json,案例参考homeController 
    u.prototype.ajax = function (parameter) {
        var i = this;
        i.cookieVerification();
        //在这里可以判断cooke 失效 重定性
        //let index = layer.load();
        let index = -1;
        if (parameter.loading == undefined) {
            index = layer.load();
        }
        let data = parameter.data;
        if (parameter.jsonStr) {
            data = JSON.stringify(parameter.data);
        }
        var objs = $.extend({
            dataType: "json",
            data: data,
            error: function (xmlHttpRequest, textStatus, errorThrown) {
                layer.alert(i.config.titleError + ":" + xmlHttpRequest.responseText, { icon: i.config.iconoError, shadeClose: true, title: i.config.titleError });
                console.error(XMLHttpRequest + "-----" + textStatus + "---" + errorThrown);
                console.error(JSON.stringify(parameter));
                console.trace();
            },
            dataFilter: function (data, type) {
                if (parameter.url.indexOf("PostMan") > -1 || typeof (parameter.isDataFilter) != "undefined") return data;
                //返回处理后的数据
                return data.replaceAll("\\", "").replaceAll("`", "").replaceAll("'", "").replaceAll("<", "").replace(/(^")|("$)/g, "").replaceAll(">", "");
            },
            success: parameter.success,
            type: "post",
            //timeout: 6000,  //超时时间设置,单位毫秒
            beforeSend: function (request) {
                //request.setRequestHeader("Authorization", "x");
            },
            complete: function (xmlHttpRequest, status) {
                if (parameter.loading == undefined) {
                    layer.close(index);
                }
                if (status === 'timeout') {
                    console.error("请求时间超时6秒 问题频繁出现请联系管理员");
                    console.trace();
                }
            }
        }, parameter);
        $.ajax(objs);
    }

    //ajax global error  listen 
    u.prototype.ajaxError = function () {
        var i = this;
        $document.ajaxError(function (event, xhr, options, exc) {
            if (xhr.status == 'undefined') return;
            switch (xhr.status) {
                case 404:
                    layer.alert(`${i.config.title404} ${options.url}】`, { icon: i.config.iconoError, shadeClose: true, title: i.config.titleError });
                    console.trace();
                    break;
                default:
                    layer.alert(`${xhr.statusText} ${options.url}】`, { icon: i.config.iconoError, shadeClose: true, title: i.config.titleError });
                    console.trace();
                    break;
            }
        });
    }

    /**
     * initTable
     * parseDataExtend:一定要return 只处理Result 数据源,其他格式不要破坏、
     * contentType 直接写在 parameter里面
     * 修改分页请求参数request: {  pageName: "当前第几页", limitName: "每页总条数",},
     * @returns
     */
    u.prototype.initTable = function (parameter) {
        let i = this;
        var tempTable = table;
        if (typeof (parameter.treeTable) != "undefined") {
            tempTable = treeTable;
        }
        if (typeof (parameter.elem) == "undefined") {
            layer.alert("initTable方法 参数,parameter.elem为空!", { icon: 2, shadeClose: true, title: i.config.titleError });
            return false;
        }
        if ($(parameter.elem).length == 0) {
            layer.alert("initTable方法 参数,parameter.elem 节点不存在!", { icon: 2, shadeClose: true, title: i.config.titleError });
            return false;
        }
        let index = layer.load(0); //添加laoding,0-2两种方式
        var objs = $.extend({
            method: !parameter.method ? "post" : parameter.method,
            limit: 50,
            limits: [50],
            loading: false,
            even: true,
            page: typeof parameter.page == "undefined" ? { layout: ['prev', 'page', 'next', 'skip', 'count', 'limit', 'refresh'] } : parameter.page,
            height: typeof parameter.height == "undefined" ? "full-1" : parameter.height,
            cellMinWidth: 80,
            parseData: function (res) {
                var result = {
                    Code: res.Code == 200 ? res.Code : -1,
                    Message: res.Message,
                    Count: res.Count,
                    Result: res.Result
                };
                if (!parameter.parseDataExtend) return result
                return parameter.parseDataExtend && parameter.parseDataExtend.call(this, res);
            },
            done: function (res) {
                if (sU.config.btnRefreshLoadIndex != -1) layer.close(sU.config.btnRefreshLoadIndex);

                layer.close(index);
                if (typeof res.code != "undefined" && (res.code === 0 || (res.data != null && res.data.length > 0))) {
                    var selectColKey = "".GetUrlParam("selectColKey");
                    if (selectColKey != null) {
                        var targetArrValue = "".GetUrlParam("targetArrValue");
                        if (targetArrValue != "" && targetArrValue != null) {
                            i.SetTableCheck(targetArrValue.split(","), res, selectColKey, parameter.elem);
                        }
                    }
                }
                var elem = parameter.elem.replace("#", "");
                //表格工具栏事件
                system.registerEvent(elem);
                //查询搜索框事件
                system.query();
                //表格自带事件
                i.bindTableEvents({ elem: elem, url: parameter.url });
                //表格完成事件
                parameter.doneExtend && parameter.doneExtend.call(this, res, arguments[1]);

                if (typeof parameter.setTableBgColor != "undefined") i.SetTableBgColor(parameter);

                tempTable.on('edit(' + elem + ')', function (obj) {
                    parameter.editExtend && parameter.editExtend.call(this, obj.value, obj.field, obj.data);
                });
            },
            size: 'sm',
            defaultToolbar: ['filter']
        }, parameter);
        let tableIns = tempTable.render(objs);        
        return tableIns;
    }

    //表格选中单条件
    u.prototype.SetTableCheck = function (targetArrValue, resData, resDataKey, tableElem) {
        if (targetArrValue == null || targetArrValue =="" ) {
            console.log("SetTableCheck 方法 url targetArrValue 参数值为空,q");
            return;
        }
        if ("".typeX(targetArrValue) == "string") {
            targetArrValue = targetArrValue.split(',');
        }
        for (var i = 0; i < targetArrValue.length; i++) {
            for (var j = 0; j < resData.Result.length; j++) {
                if (targetArrValue[i] != resData.Result[j][resDataKey]) continue;
                resData.Result[j]["LAY_CHECKED"] = true;
                var trIndex = resData.Result[j]["LAY_TABLE_INDEX"],
                    tableCheckbox = $(".layui-table-fixed-l tr[data-index=" + trIndex + '] input[type="checkbox"]');
                tableCheckbox.prop("checked", true);
                tableCheckbox.next().addClass("layui-form-checked");
            }
        }
        //如果构成全选
        var checkStatus = table.checkStatus(tableElem.replace("#", "")),
            tableHeaderTh = $('.layui-table-header th[data-field="0"] input[type="checkbox"]');
        if (checkStatus.isAll) {
            tableHeaderTh.prop('checked', true);
            tableHeaderTh.next().addClass('layui-form-checked');
        }
    }

    //表格选中多条件
    u.prototype.SetTableMoreCheck = function (targetArrValue, resData, resDataKey, tableElem) {
        var resDataKeys = resDataKey.split(',');
        if (targetArrValue == null || typeof targetArrValue == "undefined" || targetArrValue.count == 0) {
            console.log("SetTableMoreCheck 方法 url targetArrValue 参数值为空");
            return;
        }
        if (resDataKeys.length == 0) {
            console.log("SetTableMoreCheck 方法 url resDataKey 参数值为空");
            return;
        }
        var finish = 0;
        for (var i = 0; i < resData.Result.length; i++) {
            for (var j = 0; j < targetArrValue.count; j++) {
                for (var u = 0; u < resDataKeys.length; u++) {
                    if (targetArrValue[resDataKeys[u]][j] != resData.Result[i][resDataKeys[u]]) { finish++ }
                }
                if (finish > 0) {
                    finish = 0;
                    continue;
                };
                resData.Result[i]["LAY_CHECKED"] = true;
                var trIndex = resData.Result[i]["LAY_TABLE_INDEX"],
                    tableCheckbox = $(".layui-table-fixed-l tr[data-index=" + trIndex + '] input[type="checkbox"]');
                tableCheckbox.prop("checked", true);
                tableCheckbox.next().addClass("layui-form-checked");
            }
        }
        //如果构成全选
        var checkStatus = table.checkStatus(tableElem.replace("#", "")),
            tableHeaderTh = $('.layui-table-header th[data-field="0"] input[type="checkbox"]');
        if (checkStatus.isAll) {
            tableHeaderTh.prop('checked', true);
            tableHeaderTh.next().addClass('layui-form-checked');
        }
    }

    //表格设置背景颜色 val可以是值 也可以定义函数
    u.prototype.SetTableBgColor = function (parameter) {
        var td = $(parameter.elem).next().find(`.layui-table-body tbody td[data-field='${parameter.setTableBgColor.colsName}']`),
            val = parameter.setTableBgColor.colsValue,
            css = parameter.setTableBgColor["css"];
        if (td.length == 0) {
            console.error(`表格设置背景颜色方法:SetTableBgColor 元素【${parameter.elem} tddata-field='${parameter.setTableBgColor.colsName}'】节点不存在!`)
            return;
        }
        if (!val) {
            console.error(`表格设置背景颜色方法:parameter.setTableBgColor.colsValue 值是空!`);
            return;
        }
        if (!css) css = { "background-color": "#f2dede" };
        for (var j = 0; j < td.length; j++) {
            var tdElem = $(td[j]),
                tdElemVal = tdElem.text().trim();
            let index;
            if (typeof val === "function") {
                index = val(tdElemVal, tdElem);
            } else {
                index = val.find(item => {
                    return item == tdElemVal;
                });
            }
            if (index != undefined) tdElem.parent().css(css);
        }
    }

    //bind table all events
    u.prototype.bindTableEvents = function (parameter) {
        let i = this;
        //https://www.cnblogs.com/XuYuFan/p/11733546.html
        var tableId = parameter.elem.replace("#", "");
        $document.on("click", ".layui-table-body table.layui-table tbody tr", function (e) {
            var now = +new Date();
            if (now - timeDocumentClick < 200) return;
            timeDocumentClick = now;
            var thisInfo = $(this),
                index = thisInfo.attr("data-index"),
                tableBox = thisInfo.parents(".layui-table-box"),
                tableDiv;
            if (tableBox.find(".layui-table-fixed.layui-table-fixed-l").length > 0) {
                tableDiv = tableBox.find(".layui-table-fixed.layui-table-fixed-l");
            } else {
                tableDiv = tableBox.find(".layui-table-body.layui-table-main");
            }
            var trElem = tableDiv.find("tr[data-index=" + index + "]"),
                checkboxCellElem = trElem.find("td div.laytable-cell-checkbox div.layui-form-checkbox I"),
                radioCellElem = trElem.find(".layui-form-radio");
            if (checkboxCellElem.length > 0) checkboxCellElem.click();
            if (radioCellElem.length > 0) radioCellElem.click();
        });
        $document.on("click", "td div.laytable-cell-checkbox div.layui-form-checkbox", function (e) {
            e.stopPropagation();
        });

        //点击行选中复选框, 时间时间戳解决重复执行
        table.on(`row(${tableId})`, function (obj) {
            var now = +new Date();
            if (now - timeStamprowClick < 200) return;
            timeStamprowClick = now;
            obj.tr.addClass("layui-table-click").siblings().removeClass("layui-table-click");
            obj.tr.find("i[class=\"layui-anim layui-icon\"]").trigger("click");
        });

        //监听表格排序 initSort 【field】排序字段、【排序方式】、【initSort】记录初始排序,如果不设的话,将无法标记表头的排序状态
        table.on(`sort(${tableId})`, function (obj) {
            table.reload(tableId, { url: parameter.url, initSort: obj, method: "post", where: { field: obj.field, order: obj.type } });
        });

        let objData;
        //监听表格行单击事件
        table.on(`row(${tableId})`, function (obj) {
            objData = obj.data;
            var rowDataClcik = action["rowData"],
                bgColor = { "background-color": "#5FB878", "color": "#000000", "font-weight": 600 }
                customKeys = "customTableCelClick",
                tableRowOneClick = action["tableRowOneClick"];
            var trSiblingsEle = obj.tr.siblings();
            for (var j = 0; j < trSiblingsEle.length; j++) {
                $(trSiblingsEle[j]).removeAttr("style");
            }
            $(obj.tr[0]).css(bgColor);
            if (typeof rowDataClcik != "undefined") action.rowData = obj.data;
            tableRowOneClick != null ? tableRowOneClick.call(this, obj) : console.log("table checkbox没有找到action对应的tableRowOneClick方法,业务不需要请忽略! 参数 obj");
            if (action[customKeys] != null) action[customKeys].call(this, obj, tableId);
        });

        //监听表格行双击事件(默认执行表格切换),监听表格行自定义双击事件
        table.on(`rowDouble(${tableId})`, function (obj) {
            var keys = "tableRowClick",
                customKeys = "customTableRowClick",
                bgColor = { "background-color": "#5FB878", "color": "#000000", "font-weight":600};
			//var trSiblingsEle = obj.tr.siblings();
   //         for (var j = 0; j < trSiblingsEle.length; j++) {
   //             $(trSiblingsEle[j]).removeAttr("style");
   //         }
   //         $(obj.tr[0]).css(bgColor);
            systemAction[keys].call(this, obj, tableId);
            if (action[customKeys] != null) action[customKeys].call(this, obj, tableId);
        });

        /**
         * 单元格点击事件   使用方法在表格列 添加属性 event:"x"
         * 目前扩展的类型 fileEvent:图片预览、openBlank:打开子窗口、openBlank:打开新标签页、openBlankPdf:pdf 预览
         */
        table.on(`tool(${tableId})`, function (obj) {
            let data = obj.data,
                thisInfo = $(this);
            if (obj.event === 'fileEvent' && data.url) {
                var url = $(this).find("a[data-href]").attr("data-href").split(",");
                i.initCarousel(url);
                return false;
            }
            //第一个位是menuFlag
            if (obj.event === 'pageOpen') {
                let urlContent = thisInfo.find("a[data-href]").attr("data-href"),
                    title = urlContent.split("?")[1];
                var tempTitle = thisInfo.find("a[data-href]").attr("data-title");
                if (tempTitle) title = tempTitle;
                layer.open({
                    type: 2,
                    title: `【${thisInfo.text()}】信息【${title}】`,
                    content: urlContent,
                    area: ['1000px', '580px']
                });
                return false;
            }
            else if (obj.event === 'openBlank') {
                let url = thisInfo.find("a[data-href]").attr("data-href");
                if (url == null || url == "") {
                    console.error("table 单元格事件tool,参数url 不存在!");
                    return false;
                }
                window.open(url, url);
                return false;
            }
            else if (obj.event === 'openBlankPdf') {
                let url = thisInfo.find("a[data-href]").attr("data-href");
                if (url == null || url == ""||url.indexOf("pdf") == -1) {
                    alert("pdf预览url后缀需要包含pdf名称!")
                    return;
                }
                window.open("/htmlTemp/pdf.html?" + url, url);  
                return false;
            }
            var eventFn = action[obj.event];
            eventFn != null ? eventFn(obj) : console.log(`table tool 单元格没有找到action对应的方法${obj.event},实现方式【cols某一列属性 event:${obj.event},action注册事件:${obj.event},业务不需要请忽略,参数 obj!`);
        });

        //监听表格复选框时间事件
        table.on(`checkbox(${tableId})`, function (obj) {
            if ($.isEmptyObject(obj.data) && obj.type == "one") {
                obj.data = objData;
                action["checkTableRowData"] = objData;
                localStorage.setItem("checkTableRowData", JSON.stringify(objData));
            }
            var checkTableALLRowData = table.cache[tableId].filter(x => { if (x["LAY_CHECKED"]) return x; });
            action["checkTableALLRowData"] = checkTableALLRowData;
            sU.config.checkTableALLRowData = checkTableALLRowData;
            localStorage.setItem("checkTableALLRowData", JSON.stringify(checkTableALLRowData))

            var eventFn = action["checkboxMethod"];
            eventFn != null ? eventFn(obj) : console.log("table checkbox没有找到action对应的checkboxMethod方法,业务不需要请忽略,参数 obj !");
        });

        //监听表格列 选中状态
        form.on("checkbox()", function (data) {
            i.columnSelectedStatus(data);
        });

        //table.on('edit(' + tableId + ')', function (obj) {
        //    //console.log(obj.value); // 得到编辑修改后的值
        //    //console.log(obj.field); // 得到编辑的字段名
        //    //console.log(obj.data); // 得到修改后该行的数据
        //    parameter.editExtend && parameter.editExtend.call(this, obj.value, obj.field, obj.data);
        //});


        //单元格编辑 表格数据是否编辑判断属性【】isEdit 不为undefined
        //table.on(`edit(${tableId})`, function (obj) {
        //    var value = obj.value, //得到修改后的值
        //        data = obj.data, //得到所在行所有键值
        //        field = obj.field; //得到字段
        //    var update = {};
        //    update[field] = value;
        //    obj.update(update);
        //});
    }

    //获取表格当前页所有数据
    u.prototype.getTableAllData = (elem) => { return table.cache[elem]; }

    //注册表单 "select", "checkbox", "radio" 事件  dom 元素name+FromEvent
    u.prototype.initFormEvent = function (parameter) {
        if (typeof action == "undefined") {
            console.log("initFormEvent:action is null");
            return false;
        }
        if (typeof form == "undefined") {
            console.log("initFormEvent:form is null");
            return false;
        }
        ["select", "checkbox", "radio"].forEach(x => {
            form.on(x, function (data) {
                if (typeof (data.value) != "undefined" && data.value === "on") return;
                var now = +new Date();
                if (now - timeInitFormEvent < 200) return;
                let temp = data.elem.name + "FromEvent";
                var eventFn = action[temp];
                if (typeof data.elem.selectedIndex !== "undefined") {
                    data["text"] = data.elem[data.elem.selectedIndex].text;
                } else {
                    data["text"] = "";
                }
                if (eventFn != null) eventFn(data);
                if (eventFn == null) console.log(`fromEvent 没有找到action对应的方法:${temp},参数data包含 elemvaluetext 参数等 业务不需要请忽略!`);
            });
        });
    }

    //openAddOrEdit
    u.prototype.openAddOrEdit = function (parameter) {
        var area = parameter["area"] == undefined ? ["750px", "500px"] : parameter.area,
            content = parameter["content"] == undefined ? $('#modifyForm') : parameter.content,
            title = parameter["title"],
            btn = parameter["btn"] == undefined ? ["保存", "关闭"] : parameter.btn,
            maxmin = parameter["maxmin"] == undefined ? true : parameter.maxmin;
        if (content.length == 0) {
            console.error("方法openAddOrEdit,参数content元素dom不存在!");
            return;
        }

        layer.open({
            title: title,
            area: area,
            maxmin: maxmin,
            type: 1,
            content: content,
            btn: btn,
            end: function (index, layero) {
                $(parameter.fromId)[0].reset();
                //最后触发关闭事件,一定会执行
                if (action["closeAfter"] != null) {
                    action["closeAfter"].call(this, function () {
                        layer.close(index);
                    });
                } else {
                    layer.close(index);
                }
            },
            success: function () {
                if (action["editAfter"] != null) {
                    action["editAfter"].call(this, function () { parameter.success(layer.index); });
                } else {
                    parameter.success(layer.index);
                }
            },
            yes: function (index, layero) {
                if (btn.length > 1) {
                    if (parameter["btnOpenYes"] == null || parameter["btnOpenYes"] == undefined) {
                        console.error("表单隐藏提交按钮 flag: button[name=fromxxx] 为空");
                    }
                    var ele = layero.find(parameter["btnOpenYes"]);
                    if (ele.length == 0) {
                        console.error(`表单元素隐藏提交按钮${parameter["btnOpenYes"]} 为空`);
                        layer.msg(`表单元素隐藏提交按钮${parameter["btnOpenYes"]} 为空`, { icon: 2, shade: 0.4, time: 2500 });
                        return;
                    }
                    ele.click();
                } else {
                    layer.close(index);
                }
            }
        });
    }

    // 表格删除
    u.prototype.deleteConfirm = function (parameter, sysU, selectData) {
        var conTitleDelete = sysU.config.titleConfirmDelete;
        if (typeof (parameter["titleConfirmDelete"]) != "undefined") {
            conTitleDelete = parameter["titleConfirmDelete"];
        }
        layer.confirm(conTitleDelete +` 当前选择的行数【${selectData.length}】条`, { icon: 3 }, function (index) {
            var ids = selectData.map(function (e) { return e[parameter.keyId]; });
            if (ids[0] == undefined) {
                layer.alert(`${sysU.config.titleDeleteId}action deleteOptions 配置keyId:${parameter.keyId}】不存在!` , { icon: sysU.config.iconoError, shade: 0.4, time: sysU.config.errorTime });
                console.error(`${sysU.config.titleDeleteId}action deleteOptions 配置keyId:${parameter.keyId}】不存在!`);
                return false;
            }
            if (parameter["deleteCount"] != "undefined" && parameter["deleteCount"] == 1) {
                if (selectData.length > 1) {
                    layer.msg("不支持批量删除,请选择一条数据!", { icon: sysU.config.iconoError, shade: 0.4, time: sysU.config.errorTime });
                    return false;
                }
            }
            var ajaxConfig = {
                data: { ids: ids },
                url: parameter.url,
                success: function (result) {
                    if (parameter["refresh"] != undefined) {
                        $("#" + parameter["toolbarId"]).next().children(".layui-table-page").find(".layui-icon-refresh").click();
                    }
                    if (sysU.successBefore(result)) return;
                    layer.close(index);
                    layer.msg(result.Message, { icon: sysU.config.iconoOk, shade: 0.4, time: sysU.config.msgOpenTime });
                    //$("#" + parameter["toolbarId"]).next().children(".layui-table-page").find(".layui-icon-refresh").click();
                    if (action["actionSuccess"] !== undefined) action["actionSuccess"].call(null, parameter["actionSuccessFlag"]);
                }
            };
            sysU.ajax(ajaxConfig);
        });
    }

    // 打印二维码
    u.prototype.printBarCode = function (parameter, sysU, selectData) {
        var area = parameter["area"] == undefined ? ["800px", "600px"] : parameter.area,
            qcCodeHead = parameter["qcCodeHead"] == undefined ? $('#qcCodeHead') : parameter.qcCodeHead,
            qcCodeBody = parameter["qcCodeBody"] == undefined ? $('#qcCodeBody') : parameter.qcCodeBody,
            title = parameter["title"] == undefined ? sysU.config.titleQcCodePrint : parameter.title;
        parameter["qcCodeBody"] = qcCodeBody;
        if (qcCodeHead.length == 0) {
            layer.alert("printBarCode:打印二维码外层跟节点元素dom不存在:" + qcCodeHead.selector, { icon: 2, shadeClose: true, title: i.config.titleError });
            return;
        }
        if (qcCodeBody.length == 0) {
            layer.alert("printBarCode:打印二维码内容节点元素dom不存在:" + qcCodeBody.selector, { icon: 2, shadeClose: true, title: i.config.titleError });
            return;
        }
        qcCodeBody.empty();  //清空上一次数据
        var result = parameter.customFn(sysU, parameter, selectData);
        if (typeof result == "undefined") {
            layer.alert("printBarCode:打印二维码 自定义方法执行错误customFn 返回值不能为undefined!", { icon: 2, shadeClose: true, title: i.config.titleError });
            return;
        }
        layer.open({
            type: 1,
            title: title,
            area: area,
            content: qcCodeHead,
            scrollbar: true,
            skin: 'qcCode-class',
            btn: ["打印"],
            yes: function (index, layero) {
                qcCodeHead.jqprint({});
                layer.close(index);
            }
        });
    }

    // 二维码写入Dom
    u.prototype.qRCodeWirtDom = function (parameter, qrcodeElem, qrcodeId, qcCodeValue) {
        parameter.qcCodeBody.append(qrcodeElem);
        var qrcodeObj = new QRCode(document.getElementById(qrcodeId), {
            width: 100,
            height: 100
        });
        qrcodeObj.makeCode(qcCodeValue);
    }

    //表单扩展验证 layui 自带的 存在bug 在某些时候额外处理一遍
    u.prototype.requiredExtend = function (form) {
        var result = true;
        for (var i = 0; i < form.length; i++) {
            if (form[i].nodeName === "SELECT") {
                var seElem = $(form[i]),
                    seValue = seElem.find("option:selected").val(),
                    seVerify = seElem.attr("lay-verify");
                if (seVerify === "required" && (seValue == null || seValue === "")) {
                    result = false;
                    layer.msg("必填项不能为空", { icon: 2, shift: 6 });
                    $(form[i + 1]).focus();
                    form[i + 1].style.cssText += 'border-color: red !important;';
                    break;
                }
            }
        }
        return result;
    }

    //ajax 成功状态判断
    u.prototype.successBefore = function (result) {
        var i = this;
        var isOk = false;
        if (result.Code != 200 || !result.Status) {
            if (result["code"] == 200 || result["Code"] == 200) return isOk;
            layer.alert(result.Message || result.msg, { icon: i.config.iconoError, shadeClose: true, title: i.config.errorTitle });
            isOk = true;
        }
        return isOk;
    }

    //对象是否是数组
    u.prototype.isArray = function (obj) {
        return (typeof obj == 'object') && obj.constructor == Array;
    }

    //excel  导出数据【tableObj】当前表格信息,【result】后台返回的数据 http://excel.wj2015.com/
    u.prototype.ExcelExportData = function (parameter, results) {
        let index = layer.load();
        setTimeout(function () {
            var resultDatas = [],         //第一行是列头,第2行是列对应的数据
                dataKey = ["head", "body", "footer"],
                curMenu = JSON.parse(sessionStorage.getItem("curmenu")),
                newTime = new Date().format("yyyymmddhhMMss"),
                fileName = curMenu == null ? newTime : curMenu.title + newTime;
            if (typeof parameter.excelCols == "undefined" || parameter.excelCols == null) {
                layer.alert("导出配置参数exportOptions【excelCols】必须是head,body,footer,请核实配置参数!", { icon: i.config.iconoError, shadeClose: true, title: i.config.errorTitle });
                return;
            }
            for (var i = 0; i < dataKey.length; i++) {
                var columnNameTemp = parameter.excelCols[dataKey[i]];
                if (typeof columnNameTemp == "undefined") {
                    console.log(`导出配置参数exportOptionsexcelColsheadbody,footer,配置参数${dataKey[i]}不存在公共方法dataKey中,如果没有请忽略提示!`)
                    continue;
                }
                var columnName = columnNameTemp[0]
                var dataSource = results.Result == null || sU.isArray(results.Result) ? results.Result : results.Result[dataKey[i]];
                if (sU.isArray(results.Result) && i == 1) break;
                if (dataSource != undefined) {
                    resultDatas.push(sU.GetExcelData(columnName, dataSource));
                }
                //不存在,false不导明细(单表导出 false)
                if (typeof parameter.isDefault == "undefined" || !parameter.isDefault) break;
            }
            var excelData = {};//{sheet1: x, sheet2: x}
            if (resultDatas.length > 0) {
                for (var xp = 0; xp < resultDatas.length; xp++) {
                    excelData["sheet" + (xp + 1)] = resultDatas[xp];
                }
                excel.exportExcel(excelData, fileName + ".xlsx", 'xlsx');
            }
            layer.close(index);
            layer.msg(Object.keys(excelData).join(',') + "导出完成!", { icon: 6, shade: 0.4, time: 1500 });

        }, 0);
    }

    //excel方法 ExcelExportData  数据处理
    u.prototype.GetExcelData = function (tableCols, resultdata) {
        var resultData = [],
            exelData = [],
            tempChTitle = [];
        for (var i = 0; i < tableCols.length; i++) {
            if (!tableCols[i].fixed) {
                exelData[tableCols[i].field] = tableCols[i].title;
                tempChTitle.push(tableCols[i].title);
            }
        }
        resultData.push(tempChTitle);
        var title = Object.keys(exelData);
        for (var xp = 0; xp < resultdata.length; xp++) {
            var nowData = [];
            for (var j = 0; j < title.length; j++) {
                var cols = title[j];
                let value = resultdata[xp][cols];
                if (typeof (value) == "undefined") {
                    console.log("数据源 resultdata:" + JSON.stringify(resultdata[xp]));
                    console.group();
                    console.log("后台返回数据源的字段和列表table页面cols的字段不一致: " + cols);
                }
                nowData.push(resultdata[xp][cols]);
            }
            resultData.push(nowData);
        }
        return resultData;
    }

    //excel  下载模板 读取的表格table 列 过滤 noExel属性(和导出没有关系), 且读取 type=normal的
    u.prototype.exelDownTemplate = function (tableObj) {
        var tableCols = tableObj.config.cols[0],
            //第一行是列头,第2行是列对应的数据
            resultData = [],
            englishTitle = [],
            chTitle = [];
        for (var i = 0; i < tableCols.length; i++) {
            if (typeof (tableCols[i].noExel) != "undefined" || tableCols[i].noExel) continue;
            if (tableCols[i].type === "normal") {
                englishTitle[tableCols[i].field] = tableCols[i].title;
                chTitle.push(tableCols[i].title);
            }
        }
        resultData.push(Object.keys(englishTitle));
        resultData.push(chTitle);
        var curmenu = JSON.parse(sessionStorage.getItem("curmenu")),
            newTime = new Date().format("yyyymmddhhMMss"),
            fileName = curmenu == null ? newTime : curmenu.title + newTime;
        excel.exportExcel({ sheet1: resultData }, "模板" + fileName + ".xlsx", 'xlsx');
    }

    //表格列 恢复记忆
    u.prototype.columnRecord = function (tablelid, colsArr) {
        let i = this;
        var account = localStorage.getItem("Account");
        var paths = window.location.pathname.split("/");
        var controller = paths[paths.length - 2];
        var cookieName = account + "_" + controller + "_" + tablelid;
        var cookieval = localStorage.getItem(cookieName);
        if (cookieval == null) return colsArr;
        var colsetting = JSON.parse(cookieval);
        if (colsetting == null) return
        colsArr[0].forEach(function (item, len) {
            if (colsetting[item.field] !== undefined) {
                item.hide = !(colsetting[item.field]);
            }
            //设置列宽
            var colsWidth = colsetting[item.field + i.config.colsWidthFlag]
            if (colsWidth !== undefined) {
                item.width = colsWidth;
            }
        });
        return colsArr;
    }

    //表格列 设置选中或者取消
    u.prototype.columnSelectedStatus = function (data) {
        var attributes = data.elem.attributes;
        if (attributes['lay-filter'] === undefined) return;
        if (attributes['lay-filter'].nodeValue != 'LAY_TABLE_TOOL_COLS') return;

        var tb = data.elem.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
        var account = localStorage.getItem("Account");
        var paths = window.location.pathname.split("/");
        var controller = paths[paths.length - 2];
        var tablelid = tb.previousElementSibling.id;
        var checkflag = data.elem.checked;
        var colname = attributes['name'].nodeValue;
        var cookieName = account + "_" + controller + "_" + tablelid;
        var cookieval = localStorage.getItem(cookieName);
        var colsetting = {};
        if (cookieval == undefined) {
            colsetting[colname] = checkflag;
        }
        else {
            colsetting = JSON.parse(cookieval);
            colsetting[colname] = checkflag;
        }
        localStorage.setItem(cookieName, JSON.stringify(colsetting));
    }

    //表格列 设置宽度
    u.prototype.setColumnWidth = function () {
        let i = this;
        $document.on('mouseup', '.layui-table-header th', function (e) {
            var thisInfo = $(this);
            //复选框排除
            if (thisInfo.find("input[type=checkbox]").length > 0) return false
            var account = localStorage.getItem("Account");
            var paths = window.location.pathname.split("/");
            var controller = paths[paths.length - 2];
            var tablelid = thisInfo[0].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.previousElementSibling.id
            var colname = thisInfo.attr("data-field") + i.config.colsWidthFlag;
            var width = thisInfo.width();

            var cookieName = account + "_" + controller + "_" + tablelid;
            var cookieval = localStorage.getItem(cookieName);
            var colsetting = {};
            if (cookieval == undefined) {
                colsetting[colname] = width;
            }
            else {
                colsetting = JSON.parse(cookieval);
                colsetting[colname] = width;
            }
            localStorage.setItem(cookieName, JSON.stringify(colsetting));
        });
    }

    //initSelect   字典、url、本地静态数据源(需要指定dataSource: sysLocalDataSource.libraryOptions,)
    u.prototype.initSelect = function (selectOption, fnCallBack) {
        var sysU = new u();
		if (selectOption == null) {
            layer.alert("initSelectBatches 方法 参数【selectOption】不能为空! ", { icon: sysU.config.iconoOk, shadeClose: true, title: sysU.config.errorTitle });
            return;
        }
        let fn = fnCallBack;
        var allSelector = Object.keys(selectOption);
        allSelector.pop();
        var seLength = allSelector.length,
            index = 0,
            indexAjax = 0;
        if (seLength == 0) console.log("initSelect方法 配置参数selectOption:节点属性配置为空,如果没有请忽略提示!");
        allSelector.forEach(function (key) {
            let selectObj = {
                Dom: selectOption[key]["Dom"],
                SelType: selectOption[key].SelType,
                SelFrom: selectOption[key].SelFrom,
                SelLabel: selectOption[key].SelLabel,
                OptGroup: selectOption[key]["OptGroup"],
                SelValue: selectOption[key].SelValue,
                Where: selectOption[key]["Where"],
                isFirstSelected: selectOption[key]["isFirstSelected"] ?? true//是否默认选择第一个下拉选项
            };
            if (selectObj.SelType === "FromUrl") {
                let data = { limit: 1000 };
                if (selectObj.Where != undefined && selectObj.Where != null) {
                    let allKeyArr = Object.keys(selectObj.Where);
                    for (var xp = 0; xp < allKeyArr.length; xp++) {
                        data[allKeyArr[xp]] = selectObj.Where[allKeyArr[xp]];
                    }
                }
                var ajaxConfig = {
                    data: data,
                    url: selectObj.SelFrom,
                    success: function (result) {
                        indexAjax++;
                        if (result.Code != 200 && result.Count === 0) {
                            layer.alert(result.Message, { icon: sysU.config.iconoError, shadeClose: true, title: sysU.config.errorTitle });
                            return;
                        }
                        SelectorSource[key] = result.Result;
                        if (typeof selectOption.selectData != "undefined") selectOption.selectData[key] = result.Result;
                        sysU.createSelectElement(selectObj, result.Result);
                        form.render("select");
                        if (index + indexAjax >= seLength) {
                            if (fn != null) fn();
                            form.render("select");
                        }
                    }
                };
                sysU.ajax(ajaxConfig);
            }
            else if (selectObj.SelType === "FromDict") {
                index++;
                var tempData = sysU.arrFilterByProperty("DictType", selectObj.SelFrom);
                SelectorSource[key] = tempData;
                if (typeof selectOption.selectData != "undefined" && selectOption.selectData != null) selectOption.selectData[key] = tempData;
                sysU.createSelectElement(selectObj, tempData);
                if (index + indexAjax >= seLength) {
                    if (fn != null) fn();
                    form.render("select");
                }
            }
            else if (selectObj.SelType === "sysLocalDataSource") {
                index++;
                var tempData = selectOption[key].dataSource;
                SelectorSource[key] = tempData;
                if (typeof selectOption.selectData != "undefined" && selectOption.selectData != null) selectOption.selectData[key] = tempData;
                sysU.createSelectElement(selectObj, tempData);
                if (index + indexAjax >= seLength) {
                    if (fn != null) fn();
                    form.render("select");
                }
            }
        });
    }

   /**
    * initSelectBatches  级联关系 省、市案例
    * nowNode 当前Josn节点名称 字符串格式
    * rootNode 当前节点的根节点
    * fnCallBack
    */
    u.prototype.initSelectBatches = function (nowNode, rootNode, fnCallBack) {
        var sysU = new u();
        let selectOpt = rootNode[nowNode];
        let key = nowNode;
        if (selectOpt == null) {
            layer.alert("initSelectBatches 方法 参数【nowNode,rootNode】的值不能为空,rootNode:是nowNode的上层节点! ", { icon: sysU.config.iconoOk, shadeClose: true, title: sysU.config.errorTitle });
            return;
        }
        let fn = fnCallBack;
        let selectObj = {
            Dom: selectOpt["Dom"],
            SelType: selectOpt.SelType,
            SelFrom: selectOpt.SelFrom,
            SelLabel: selectOpt.SelLabel,
            OptGroup: selectOpt["OptGroup"],
            SelValue: selectOpt.SelValue,
            Where: selectOpt["Where"],
        };
        if (selectObj.SelType === "FromUrl") {
            let data = { limit: 1000 };
            if (selectObj.Where != undefined && selectObj.Where != null) {
                let allKeyArr = Object.keys(selectObj.Where);
                for (var xp = 0; xp < allKeyArr.length; xp++) {
                    data[allKeyArr[xp]] = selectObj.Where[allKeyArr[xp]];
                }
            }
            var ajaxConfig = {
                data: data,
                url: selectObj.SelFrom,
                success: function (result) {
                    if (result.Result.length === 0 && result.Code != 200) {
                        layer.alert(result.Message, { icon: sysU.config.iconoOk, shadeClose: true, title: sysU.config.errorTitle });
                        return;
                    }
                    SelectorSource[key] = result.Result;
                    if (typeof rootNode.selectData != "undefined") rootNode.selectData[key] = result.Result;
                    sysU.createSelectElement(selectObj, result.Result);
                    if (fn != null) fn();
                    form.render("select");
                }
            };
            sysU.ajax(ajaxConfig);
        }
        else if (selectObj.SelType === "FromDict") {
            var tempData = sysU.arrFilterByProperty("dictType", selectObj.SelFrom);
            SelectorSource[key] = tempData;
            if (typeof rootNode.selectData != "undefined" && rootNode.selectData != null) rootNode.selectData[key] = tempData;
            sysU.createSelectElement(selectObj, tempData);
            if (fn != null) fn();
            form.render("select");
        }
        else if (selectObj.SelType === "sysLocalDataSource") {
            var tempData = selectOpt.dataSource;
            SelectorSource[key] = tempData;
            if (typeof rootNode.selectData != "undefined" && rootNode.selectData != null) rootNode.selectData[key] = tempData;
            sysU.createSelectElement(selectObj, tempData);
            if (fn != null) fn();
            form.render("select");
        }
    }

    //initSelect  Local data source  注意dataSource 数据源是对象格式
    u.prototype.initSelecteByEnum = function (selectOption, fnCallBack) {
        var sysU = new u();
		if (selectOption == null) {
            layer.alert("initSelecteByEnum方法:数据是枚举 、参数【selectOption】不能为空! ", { icon: sysU.config.iconoOk, shadeClose: true, title: sysU.config.errorTitle });
            return;
        }
        let fn = fnCallBack;
        var allSelector = Object.keys(selectOption);
        allSelector.pop();
        var seLength = allSelector.length,
            index = 0;
        if (seLength == 0) console.log("initSelect方法 配置参数selectOption:节点属性配置为空,如果没有请忽略提示!");
        allSelector.forEach(function (key) {
            index++;
            let selectObj = {
                Dom: selectOption[key]["Dom"],
                SelType: selectOption[key].SelType,
                SelFrom: selectOption[key].SelFrom,
                SelLabel: selectOption[key].SelLabel,
                OptGroup: selectOption[key]["OptGroup"],
                SelValue: selectOption[key].SelValue,
                dataSource: selectOption[key].dataSource,
                isFirstSelected: selectOption[key]["isFirstSelected"] ?? true//是否默认选择第一个下拉选项
            };
            SelectorSource[key] = selectObj.dataSource;
            if (typeof selectOption.selectData != "undefined" && selectOption.selectData != null) selectOption.selectData[key] = selectObj.dataSource;
            sysU.createSelectElement(selectObj, selectObj.dataSource);
            if (index >= seLength) {
                if (fn != null) fn();
                form.render("select");
            }
        });
    }

    //创建select【dom】 $dom,【dataSource】数据源,【selLabel】 text, 【selValue】 value,【isRender】layui 重新渲染 次方法有可能多次调用
    u.prototype.createSelectElement = function (selectOption, dataSource, isRender = false) {
        if (dataSource == null || dataSource.length === 0) {
            console.log("createSelectElement 数据源:[" + selectOption["SelFrom"] + "]配置有误或该url查询无数据!");
            //清空
            for (let i = 0; i < selectOption.Dom.length; i++) {
                if (selectOption.Dom[i].length === 0) continue;
                selectOption.Dom[i].empty();
            }
            return false;
        }
        if (selectOption.Dom == null) return false;
        //组装html 元素 一次性写入文档节点
        var tempArr = [];
        tempArr.push("<option  value='' >-请选择(支持模糊搜索)-</option>");

        //OptGroup:开启分组,group 组数,data 数据源
        if (selectOption["OptGroup"] != null) {
            var groupData = dataSource.groupData;
            var allData = dataSource.data;
            var groupDataKeys = Object.keys(groupData);
            for (var j = 0; j < groupDataKeys.length; j++) {
                tempArr.push(`<optgroup  label='${groupData[groupDataKeys[j]]}'>`);
                var nowGroupNextData = allData[groupDataKeys[j]];
                for (var l = 0; l < nowGroupNextData.length; l++) {
                    tempArr.push("<option value = '" + nowGroupNextData[l][selectOption.SelValue] + "'>" + nowGroupNextData[l][selectOption.SelLabel] + "</option>");
                }
                tempArr.push("<optgroup>");
            }
        } else {
            //本地数据源提前读取出来
            if (selectOption.SelFrom == "dataSource") {
                var dt = Object.keys(dataSource);
                if (dt == "undefined") console.log(`reateSelectElement dataSource selectOption.SelValue 为空${selectOption.SelValue} `);
                dt.forEach(x => {
                    let keys = dataSource[x];
                    //key的值也是文本
                    if (selectOption.SelValue == "key") keys = x;
                    tempArr.push("<option value = '" + keys + "'>" + x + "</option>");
                });
            } else {
                for (var k = 0; k < dataSource.length; k++) {
                    var temp = dataSource[k][selectOption.SelValue];
                    if (temp == "undefined") console.log(`reateSelectElement dataSource  为空,目前值支持读取的枚举数据!${selectOption.SelType} `);
                    if (k == 0 && selectOption.isFirstSelected) {
                        tempArr.push("<option selected value = '" + temp + "'>" + dataSource[k][selectOption.SelLabel] + "</option>");
                    } else {
                        tempArr.push("<option value = '" + temp + "'>" + dataSource[k][selectOption.SelLabel] + "</option>");
                    }
                }
            }
        }
        //写入元素
        for (var i = 0; i < selectOption.Dom.length; i++) {
            if (selectOption.Dom[i].length === 0) continue;
            selectOption.Dom[i].empty();
            selectOption.Dom[i].append(tempArr.join(""));
            selectOption.Dom[i][0].setAttribute("lay-search", "");
        }
        if (isRender) form.render('select');
    }

    // 字典数组对象查询 通过属性 Property
    u.prototype.arrFilterByProperty = function (property, propertyValue) {
        if (window.top.sysDic.data == null) {
            window.top.sysDic.method();
        }
        return window.top.sysDic.data.filter(item => item[property] === propertyValue);
    }

    //文本框下拉表格 checkedKey和key必须一致:表格的主键,lableName:文本显示的元素dom
    u.prototype.initSelectTable = function (parameter) {
        var i = this;
        var searchPlaceholder = parameter["searchPlaceholder"] == undefined ? "名称搜索" : parameter.searchPlaceholder;
        let doneKey = parameter["doneKey"],
            searchKey = parameter["searchKey"],
            page = true,
            par = parameter;
        if (parameter.checkedKey != doneKey.key) {
            var msg1 = `initSelectTable:文本框下拉表格传入参数 checkedKey${parameter.checkedKey}】和doneKey=>key${doneKey.key}】表格的主键必须一致!`;
            console.error(msg1);
            layer.alert(msg1, { icon: i.config.iconoError, shadeClose: true, title: i.config.titleError });
            console.error();
            return;
        }
        if ($(parameter.elem).length <= 0) {
            var msg = `initSelectTable:文本框下拉表格传入参数【elem${parameter.elem} DOM元素不存在请确认!`;
            console.error(msg);
            layer.alert(msg, { icon: i.config.iconoError, shadeClose: true, title: i.config.titleError });
            return;
        }
        if (par["isCache"] == "true") page = false;
        //before 不支持异步 函数
        if (typeof parameter.before != "undefined") {
            var result = parameter.before.call(this, parameter);
            if (!result) return;
        }
        tableSelect.render({
            elem: parameter.elem,
            checkedKey: parameter.checkedKey,
            searchPlaceholder: searchPlaceholder,
            searchKey: searchKey == undefined ? "keyword" : searchKey,
            table: {
                limit: 50,
                limits: [50],
                url: parameter.url,
                page: page,
                where: parameter.where,
                //纠正数据源格式
                parseData: function (res) {
                    var resultData = res;
                    //对缓存数据搜索
                    if (tableSelect.data != null && par["isCache"] === "true") {
                        var keys = Object.keys(tableSelect.data.field);
                        var fieldNmae = keys[0];
                        if (keys.length > 0 && $.trim(tableSelect.data.field[fieldNmae]).length > 0) {
                            resultData.Result = resultData.Result.filter(x => {
                                var value = tableSelect.data.field[fieldNmae];
                                return x[keys].indexOf(value) > -1;
                            });
                        }
                    }
                    if (resultData.length === 0) {
                        return { code: 0, msg: "查询无数据", count: 0, data: null };
                    } else if (resultData.Code === 0) {
                        return resultData;
                    }
                    else {
                        return {
                            Code: resultData.Code,
                            Message: resultData.Message,
                            Count: resultData.Count,
                            Result: resultData.Result
                        };
                    }
                },
                method: "post",
                cols: parameter.cols,
            },
            done: function (elem, data, $nowElem,otherObj) {
                var keys = data.data.map((obj) => { return obj[doneKey.key] }).join(",");
                $nowElem.val(keys);
                $nowElem.attr("ts-selected", keys);

                var lableValues = data.data.map((obj) => { return obj[doneKey.lableValue] }).join(",");
                //显示名称
                $nowElem.next(doneKey.lableName).val(lableValues);
                //回调函数
                var allData = i.getTableAllData(otherObj.tableId)
                parameter.doneExtend && parameter.doneExtend.call(this, elem, data, $nowElem, otherObj);
            }
        });
    }

    //物料下拉表格
    u.prototype.initSelectMaterial = function (parameter) {
        var i = this;
        var objs = $.extend({
            url: "/material/Material/Load",
            searchPlaceholder: parameter.searchName == null ? "物料名称" : parameter.searchName,
            cols: [[
                { type: "radio", fixed: true },
                { field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },
                { field: 'id', width: 100, hide: true, title: 'Id' },
                { field: 'MaterialCode', width: 160, title: '物料编号' },
                { field: 'MaterialName', width: 150, title: '物料名称' },
                { field: 'Types', width: 150, title: '材质' },
                //{ field: 'typeName', width: 150,  title: '材质名称' },
                { field: 'Diameter', width: 150, title: '公称直径' },
                //{ field: 'outerDiameter', width: 150,  title: '外径' },
                { field: 'Thickness', width: 150, title: '壁厚' }
            ]]

        }, parameter);
        i.initSelectTable(objs);
    }

    //产品下拉表格
    u.prototype.initSelectProduct = function (parameter) {
        var i = this;
        var objs = $.extend({
            url: "/configure/ProductHeader/Load",
            searchPlaceholder: parameter.searchName == null ? "产品名称" : parameter.searchName,
            cols: [[
                { type: "radio", fixed: true },
                { field: 'id', width: 100, hide: true, title: 'Id' },
                { field: 'keys', width: 160, hide: true, title: 'keys' },

                { field: 'productCode', width: 150, title: '产品编码' },
                { field: 'productName', width: 150, title: '产品名称' },
                { field: 'externalCode', width: 150, title: '外部编码' },
                { field: 'processCode', width: 150, title: '工艺路线编码' }
            ]]

        }, parameter);
        i.initSelectTable(objs);
    }

    //员工下拉表格 isCache true取的是缓存 启用js搜索
    u.prototype.initSelectUser = function (parameter) {
        var i = this;
        var objs = $.extend({
            url: "/HomeRedis/GetBaseInfoByKey?key=user",
            isCache: "true",
            searchPlaceholder: "员工名称",
            cols: [[
                { type: "checkbox", fixed: true },
                { field: "id", width: 80, title: "Id" },
                { field: "account", width: 160, title: "员工编码" },
                { field: "name", width: 150, title: "员工名称" }]]

        }, parameter);
        i.initSelectTable(objs);
    }

    //工位人员下拉表格 isCache true取的是缓存,将不会进行分页 启用js搜索
    u.prototype.initSelectStation = function (parameter) {
        var i = this;
        var objs = $.extend({
            url: "/HomeRedis/GetBaseInfoByKey?key=base_station",
            isCache: "true",
            searchPlaceholder: "工位名称",
            cols: [[
                { type: "radio", fixed: true },
                { field: "id", width: 80, title: "Id" },
                { field: "workStationCode", width: 160, title: "工位编码" },
                { field: "workStationName", width: 150, title: "工位名称" },
                { field: "lineId", width: 80, title: "线体id" },
                { field: "lineCode", width: 150, title: "线体编码" }]]

        }, parameter);
        i.initSelectTable(objs);
    }

    //设备下拉表格
    u.prototype.initSelectEquipment = function (parameter) {
        var i = this;
        var objs = $.extend({
            url: "/HomeRedis/GetBaseInfoByKey?key=equipment",
            isCache: "true",
            searchPlaceholder: "设备名称",
            cols: [[
                { type: "radio", fixed: true },
                { field: "id", width: 80, title: "id" },
                { field: "code", width: 120, title: "设备编码" },
                { field: "name", width: 150, title: "设备名称" },
                { field: "lineId", width: 80, title: "线体id" },
                { field: "lineCode", width: 150, title: "线体编码" },
                { field: "Ip", width: 150, title: "Ip" }
            ]]
        }, parameter);
        i.initSelectTable(objs);
    }

    //工序
    u.prototype.initSelectStep = function (parameter) {
        var i = this;
        var objs = $.extend({
            url: "/HomeRedis/GetBaseInfoByKey?key=step",
            isCache: "true",
            searchPlaceholder: "工序名称",
            cols: [[
                { type: "radio", fixed: true },
                { field: "Code", width: 160, title: "工序编码" },
                { field: "Name", width: 150, title: "工序名称" },
                { field: "ProductCode", width: 150, title: "产品标识" },
                { field: "MachineType", width: 150, title: "机型" }]]

        }, parameter);
        i.initSelectTable(objs);
    }

    //物料下拉表格 送料单带出 批次、炉号、sn信息
    u.prototype.initSelectMaterialFeed1 = function (parameter) {
        var i = this;
        var objs = $.extend({
            url: "/material/Material/GetMaterialInfoAll",
            searchPlaceholder: parameter.searchName == null ? "物料编码/炉号" : parameter.searchName,
            cols: [[
                { type: "radio", fixed: true },
                { field: "id", width: 100, hide: true, title: 'Id' },

                { field: "MaterialCode", width: 150, title: '物料编码' },
                //{ field: "MaterialName", width: 150, title: '物料名称' },
                //{ field: "FurnaceNo", width: 150, title: '炉号' },
                //{ field: "LotNo", width: 150, title: '批号' },
                //{ field: "BatchNo", width: 150, title: '批次号' },

                { field: "Specification", width: 150, title: '规格' }
                //{ field: "PipeSN", width: 150, title: '管材SN' },
                //{ field: "PipeLen", width: 100, title: '长度/数量' },
                //{ field: "UnitCode", width: 100, title: '单位' },

                //{ field: "Diameter", width: 100, title: '直径' },
                //{ field: 'Thickness', width: 100, title: '壁厚' }
            ]]

        }, parameter);
        i.initSelectTable(objs);
    }


    //装料模板下拉表格
    u.prototype.initLoadDataTemplate = function (parameter) {
        var i = this;
        var objs = $.extend({
            url: "/distribution/MaterialDistributeLoadTemplate/Load",
            searchPlaceholder: parameter.searchName == null ? "产品编码" : parameter.searchName,
            cols: [[
                { type: "radio", fixed: true },
                { field: "id", width: 70, title: "Id" },
                { field: "keys", width: 120, hide: true, title: "keys" },
                { field: "productCode", width: 159, title: "产品编码" },

                { field: "wcsProductType", width: 150, title: "产品WCS编码" },
                { field: "loadQty", width: 150, title: "装料套数" }
            ]]
        }, parameter);
        i.initSelectTable(objs);
    }

    //初始化日期控件 dateFormat 时间格式 默认 datetime,type=time
    var fn1 = [];
    u.prototype.initDate = function (fn) {
        if (fn != null && typeof fn != "undefined") {
            fn1.push(fn);
        }
        $(".layui-date").each(function () {
            let thisInfo = $(this),
                type = thisInfo.attr("time") || thisInfo.attr("typeTime"),
                format = thisInfo.attr("dateFormat"),
                showBottom = thisInfo.attr("showBottom");
            var laydateObj = {
                elem: this,
                btns: ["confirm"],
                calendar: true,
                trigger: "click",
                done: function (value, date, endDate) {
                    if (fn1.length <= 0) return;
                    for (var i = 0; i < fn1.length; i++) {
                        fn1[i](value, date, endDate, thisInfo);
                    }
                }
            };
            if (format != undefined) laydateObj["format"] = format;
            if (showBottom != undefined) laydateObj["showBottom"] = showBottom;
            if (type != undefined) laydateObj["type"] = type;
            laydate.render(laydateObj);
        });
    }

    //防抖
    u.prototype.debounce = function (fn, delay) {
        let timeout = null;
        return function () {
            clearTimeout(timeout);
            timeout = setTimeout(() => {
                fn.apply(this, arguments);
            }, delay);
        };
    }

    //轮播图 sysU.initCarousel(["","",""]);
    u.prototype.initCarousel = function (img) {
        var arr = [],
            height = 480,
            width = 680,
            area = ["700px", "500px"],
            parameter = action["carouselOptions"],
            carouselId = Number(Math.random().toString().substr(3, 3) + Date.now()).toString(36);
        arr.push(`<div class="layui-carousel" id='${carouselId}'> <div carousel-item=''>`);
        for (var i = 0; i < img.length; i++) {
            if (img[i] == "" || img[i] == null) continue;
            arr.push(` <div><img src="${img[i]}" /></div>`);
        }
        arr.push("</div></div>");
        if (parameter != undefined) {
            parameter = parameter();
            height = parameter.height,
                width = parameter.width,
                area = parameter.area;
        }
        layer.open({
            title: null,
            content: arr.join(" "),
            area: area,
            btn: null,
            success: function (layero, index) {
                var objs = $.extend({
                    elem: "#" + carouselId,
                    height: height,
                    width: width,
                    autoplay: true,
                    arrow: "always"
                }, parameter);
                carousel.render(objs);
            }
        });
    }

    //流加载;
    u.prototype.initFlow = function (parameter) {
        if (typeof flow == "undefined") return false;
        flow.load({
            elem: parameter.elem,
            done: function (page, next) {
                var lis = [];
                if (typeof parameter.ajax != "undefined") {
                    parameter.data["page"] = page;
                    sU.ajax(parameter.ajax);
                }
                next("xxx", page < 10);
            }
        });
    }

    //调用父页面方法, 用于子页面调用父页面方法;
    u.prototype.initParentEvent = function (obj) {
        var parDoc = parent.$(window.parent.document);
        if (parDoc == null || parDoc.length == 0) {
            console.log("initParentEvent:parDoc is null");
            return false;
        }
        parent.$(window.parent.document).trigger('props', obj);
    }

    //父页面监听子页面注册 props 事件(action["WatchChild"]);
    u.prototype.initWatchChild = function () {
        $document.on('props', function (event, obj) {
            if (typeof action == "undefined") {
                console.log("initWatchChild:action is null");
                return false;
            }
            action["WatchChild"].call(this, event, obj);
            var openIndex = localStorage.getItem("openIndex");
            layer.close(openIndex);
        });
    }

    //获取页面高度 用于:需要动态设置高度
    u.prototype.getFrameHeight = function () {
        return $document.height();
    }

    //将分钟转换成x天x小时x分钟
    u.prototype.getMinutesIntoTime = function (value) {
        var values = '';
        var day = parseInt(value / 1440);
        var hour = parseInt(value % 1440 / 60);
        var minute = parseInt(value % 1440 % 60);
        if (day > 0) {
            values += day + '天';
        }
        if (hour > 0) {
            values += hour + '小时';
        }
        if (minute > 0) {
            values += minute + '分钟';
        }
        return values == '' ? '0分钟' : values;
    }


    //公共事件用于全局、system方法调用、外部js不要使用
    u.prototype.initRegisterEvent = function () {
        var i = this;
        $('body').on('click', '.layui-table-grid-down .layui-icon-down', function () {
            setTimeout(function () {
                var div = document.getElementsByClassName('layui-table-tips-main')[0];
                if (document.body.createTextRange) {
                    let range = document.body.createTextRange();
                    range.moveToElementText(div);
                    range.select();
                } else if (window.getSelection) {
                    var selection = window.getSelection();
                    let range = document.createRange();
                    range.selectNodeContents(div);
                    selection.removeAllRanges();
                    selection.addRange(range);
                } else {
                    console.warn("none");
                }
                document.execCommand("Copy");
                //layer.alert("文本内容已复制好,可贴粘使用。", { icon: 6, shade: 0.4, time: i.config.msgOpenTime });
            });
        });
    }

    /**
     * 表单验证 手动调用
     * @param {*} formId 表单所在容器id
     * @returns 是否通过验证
     */
    u.prototype.VerifyForm = function (formId) {
        var stop = null,  //验证不通过状态
            verify = layui.form.config.verify,  //验证规则
            DANGER = 'layui-form-danger',  //警示样式
            formElem = $('#' + formId),  //当前所在表单域
            verifyElem = formElem.find('*[lay-verify]'),  //获取需要校验的元素
            device = layui.device();

        //开始校验
        layui.each(verifyElem, function (_, item) {
            var othis = $(this),
                vers = othis.attr('lay-verify').split('|'),
                verType = othis.attr('lay-verType'),//提示方式
                value = othis.val();

            othis.removeClass(DANGER); //移除警示样式

            //遍历元素绑定的验证规则
            layui.each(vers, function (_, thisVer) {
                var isTrue, //是否命中校验
                    errorText = '', //错误提示文本
                    isFn = typeof verify[thisVer] === 'function';
                //匹配验证规则
                if (verify[thisVer]) {
                    isTrue = isFn ? errorText = verify[thisVer](value, item) : !verify[thisVer][0].test(value);
                    errorText = errorText || verify[thisVer][1];
                    if (thisVer === 'required') {
                        errorText = othis.attr('lay-reqText') || errorText;
                    }
                    //如果是必填项或者非空命中校验,则阻止提交,弹出提示
                    if (isTrue) {
                        //提示层风格
                        if (verType === 'tips') {
                            layer.tips(errorText, function () {
                                if (typeof othis.attr('lay-ignore') !== 'string') {
                                    if (item.tagName.toLowerCase() === 'select' || /^checkbox|radio$/.test(item.type)) {
                                        return othis.next();
                                    }
                                }
                                return othis;
                            }(), { tips: 1 });
                        } else if (verType === 'alert') {
                            layer.alert(errorText, { title: '提示', shadeClose: true });
                        } else {
                            layer.msg(errorText, { icon: 5, shift: 6 });
                        }
                        //非移动设备自动定位焦点
                        if (!device.android && !device.ios) {
                            setTimeout(function () {
                                item.focus();
                            }, 7);
                        }
                        othis.addClass(DANGER);
                        return stop = true;
                    }
                }
            });
            if (stop) return stop;
        });
        if (stop) return false;
        return true;
    }

    /**
    * 刷新head,删除操作刷新主子表
    */
    u.prototype.refreshTable = function (app, sysU, sendDataDesc, falg, callBack) {
        //主表    
        if (falg.indexOf(descSuffix) == -1) {
            sysU.refreshHead(app, sysU, sendDataDesc, falg);
        }
        //子表
        else if (falg.indexOf(descSuffix) > -1) {
            sysU.refreshTableDesc(app, sysU, sendDataDesc, falg);
        }
        if (callBack != null) callBack();
    },

    /**
    * 刷新head,删除操作刷新主子表
    */
    u.prototype.refreshHead = function (app, sysU, sendDataDesc, falg) {
        if (falg == "delete") {
            if (sysU.getTableAllData(app.data.tableElem).length == 0) {
                app.data.tableIns.config.where = {};
                app.data.tableIns.config.page.curr = app.data.tableIns.config.page.curr;
                app.data.tableIns.reload(app.data.tableElem, {});
            }

            if (sendDataDesc != null) sysU.refreshTableDesc(app, sysU, sendDataDesc, falg);
        }
        if (sysU.getTableAllData(app.data.tableElem).length == 0) {
            app.data.tableIns.config.where = {};
            app.data.tableIns.config.page.curr = app.data.tableIns.config.page.curr;
            app.data.tableIns.reload(app.data.tableElem, {});
        }
        //修复页面搜索后,在新增数据成功后刷新列表(ps:layui 表格自身bug导致)
        var ele = $("#" + app.data.tableElem).next().children(".layui-table-page").find(".layui-icon-refresh");
        if (ele.length == 0) {
            app.data.tableIns.config.where = {};
            app.data.tableIns.config.page.curr = app.data.tableIns.config.page.curr;
            app.data.tableIns.reload(app.data.tableElem, {});
        } else {
            ele.click()
        }
    },

    /**
        * 刷新子表
    */
    u.prototype.refreshTableDesc = function (app, sysU, sendDataDesc) {
        if (typeof app.data.tableInsDesc != "undefined" && app.data.tableInsDesc != null) {
            if (sysU.getTableAllData(app.data.tableElemDesc).length == 0) {
                app.data.tableInsDesc.config.where = sendDataDesc;
                app.data.tableInsDesc.config.page.curr = app.data.tableInsDesc.config.page.curr;
                app.data.tableInsDesc.reload(app.data.tableElemDesc, {});
            }
            //修复页面搜索后,在新增数据成功后刷新列表(ps:layui 表格自身bug导致)
            var ele = $("#" + app.data.tableElemDesc).next().children(".layui-table-page").find(".layui-icon-refresh");
            if (ele.length == 0) {
                app.data.tableInsDesc.config.where = sendDataDesc;
                app.data.tableInsDesc.config.page.curr = app.data.tableInsDesc.config.page.curr;
                app.data.tableInsDesc.reload(app.data.tableElemDesc, {});
            } else{
                ele.click()
            }
        }
    }

    /**
     * 打开新页面
    */
    u.prototype.openPage = function (config) {
        //默认参数
        var opt = {
            title: "新增",
           /* fromFlag:n,*/
            //checkTableRowDataCount:1,//选择表格行数据 ,确定按钮返回选择行的数据
            type: 1,//0(信息框)1( $('#modifyRateForm' ) 默认)2(iframe层  页面url地址 常用)3(加载层)4(tips层)
            btn: null,//['保存', '关闭']
            area: ["750px", "500px"]
        };
        Object.assign(opt, config)
        layer.open({
            title: opt.title,
            area: opt.area,
            maxmin: true,
            type: opt.type,
            content: opt.content,
            btn: opt.btn,
            end: function (index, layero) {
                if (opt.endCallBackFn) opt.endCallBackFn()
            },
            success: function (layero, index) {
                if (config["iframeAddHeight"]) {
                    var he = document.querySelector("iframe").style.height;
                    var resultHe = parseInt(he.replace("px", "")) + 10 + "px";
                    document.querySelector("iframe").style.height = resultHe
                }
                if (opt.successCallBackFn) opt.successCallBackFn(layero, index)
            },
            yes: function (index, layero) {
                if (!opt.yesCallBackFn) {
                    layer.close(index);
                    return false;
                }
                //返回当前选中表格行数
                var rowDataAll = null;
                if (typeof (opt["checkTableRowDataCount"]) != "undefined") {
                    rowDataAll = JSON.parse(localStorage.getItem("checkTableALLRowData"))
                    if (rowDataAll.length != 1 && opt["checkTableRowDataCount"] == 1) {
                        layer.alert(sU.config.titleSelectOne, { icon: sU.config.iconoError, shade: 0.4, time: sU.config.errorTime });
                        return false;
                    }
                    else if ((rowDataAll.length == 0 || rowDataAll == "null") && opt["checkTableRowDataCount"] > 1) {
                        layer.alert(sU.config.titleSelectOneRowData, { icon: sU.config.iconoError, shade: 0.4, time: sU.config.errorTime });
                        return false;
                    }
                } else if (opt["fromFlag"] != null) {
                }
                //执行yes 父页面的方法 ,并将值回传过去
                if (opt.yesBeforeCallBackFn != null) {
                    var result = opt.yesBeforeCallBackFn(index, layero);
                    if (result=="-1") return;
                    opt.yesCallBackFn(result, function () {
                        layer.close(index);
                    })
                    return false
                }
                opt.yesCallBackFn(rowDataAll, function () {
                    layer.close(index);
                })                
            }
        });

    }


    /**
     * 打开新页面
    */
    u.prototype.tabClick = function (tabfilterEle) {
        element.on(`tab(${tabfilterEle})`, function (data) {
            if (data.index == 0) {
                systemAction.config.panelSearchDesc.hide();
                systemAction.config.panelSearchFooter.hide();  
            } else if (data.index == 1) {
                systemAction.config.panelSearch.hide();
                systemAction.config.panelSearchFooter.hide();  
            } else if (data.index == 2) {
                systemAction.config.panelSearch.hide();
                systemAction.config.panelSearchDesc.hide();  
            }
        });
    }


    /**
     * PdF预览 第一位不需要?号
    */
    u.prototype.pdfPreview = function (url = "sampleDemo.pdf") {
        if (url.indexOf("pdf") == -1) {
            alert("pdf预览url后缀需要包含pdf名称!")
            return;
        }
        window.open("/htmlTemp/pdf.html?" + url, "pdf预览");  
    }

    /*btn 
        * action 是对应引入js 全局变量配置
    */
    sU = new u();
    systemAction = {
        config: {
            panelSearch: $("#panelSearch"),
            panelSearchDesc: $("#panelSearchDesc"),
            panelSearchFooter: $("#panelSearchFooter")
        },

        btnAdd: (sysU, toolbarId) => {
            var parm = null, before = null, addSaveBefore = null, actionSuccessFlag = null;
            if (toolbarId.indexOf(descSuffix) > -1) {
                parm = action.addOptionsDesc();
                before = action["addBeforeDesc"];
                addSaveBefore = action["addSaveBeforeDesc"];
                actionSuccessFlag = "addDesc";
                parm["btnOpenYes"] = "button[name=fromAddDesc]";
            } else {
                parm = action.addOptions();
                before = action["addBefore"];
                addSaveBefore = action["addSaveBefore"];
                actionSuccessFlag = "add";
                parm["btnOpenYes"] = "button[name=fromAdd]";
            }
            parm["title"] = sysU.config.titleAdd + (parm["title"] == undefined ? "" : parm["title"]);
            //成功回调函数
            parm.success = function (index) {
                let addOpenIndex = index;
                form.on(parm.submit, function (data) {
                    var result = sysU.requiredExtend(data.form);
                    if (!result) return false;
                    function ajax() {
                        var ajaxConfig = {
                            data: { entity: data.field },
                            url: parm.url,
                            success: function (result) {
                                if (sysU.successBefore(result)) return false;
                                layer.close(addOpenIndex);
                                $(parm.fromId)[0].reset();
                                layer.msg(sysU.config.titleAddSuccess, { icon: sysU.config.iconoOk, shade: 0.4, time: sysU.config.msgOpenTime });
                                $("#" + toolbarId).next().children(".layui-table-page").find(".layui-icon-refresh").click();
                                if (action["actionSuccess"] !== undefined) action["actionSuccess"].call(null, actionSuccessFlag);
                            }
                        };
                        sysU.ajax(ajaxConfig);
                    }
                    if (addSaveBefore === undefined) {
                        ajax();
                        return false;
                    }
                    addSaveBefore.call(null, data, function () { ajax() });
                    return false;
                });
            }

            if (before == undefined) {
                sysU.openAddOrEdit(parm, sysU);
                return false;
            }
            before.call(null, function () { sysU.openAddOrEdit(parm, sysU); });
            return false;
        },

        btnCopyAdd: (sysU, toolbarId) => {
            var checkStatus = table.checkStatus(toolbarId),
                //选中的行数
                selectRow = checkStatus.data.length;
            if (selectRow === 0 || selectRow > 1) {
                layer.alert(`请选择一条数据后,在复制新增。当前选择的行数【${selectRow}】条!`, { icon: sysU.config.iconoError, shadeClose: true, title: "错误信息" });
                return false;
            }
            var parm = null, editBefore = null, before = null, addSaveBefore = null, actionSuccessFlag = null;
            if (toolbarId.indexOf(descSuffix) > -1) {
                parm = action.addOptionsDesc();
                editBefore = action["editBeforeDesc"];
                before = action["addBeforeDesc"];
                addSaveBefore = action["addSaveBeforeDesc"];
                actionSuccessFlag = "addDesc";
                parm["btnOpenYes"] = "button[name=fromAddDesc]";
            } else {
                parm = action.addOptions();
                editBefore = action["editBefore"];
                before = action["addBefore"];
                addSaveBefore = action["addSaveBefore"];
                actionSuccessFlag = "add";
                parm["btnOpenYes"] = "button[name=fromAdd]";
            }
            parm["title"] = sysU.config.titleCopyAdd + (parm["title"] == undefined ? "" : parm["title"]);
            //成功回调函数
            parm.success = function (index) {
                let addOpenIndex = index;
                form.on(parm.submit, function (data) {
                    var result = sysU.requiredExtend(data.form);
                    if (!result) return false;
                    function ajax() {
                        var ajaxConfig = {
                            data: { entity: data.field },
                            url: parm.url,
                            success: function (result) {
                                if (sysU.successBefore(result)) return false;
                                layer.close(addOpenIndex);
                                $(parm.fromId)[0].reset();
                                layer.msg(sysU.config.titleAddSuccess, { icon: sysU.config.iconoOk, shade: 0.4, time: sysU.config.msgOpenTime });
                                $("#" + toolbarId).next().children(".layui-table-page").find(".layui-icon-refresh").click();
                                if (action["actionSuccess"] !== undefined) action["actionSuccess"].call(null, actionSuccessFlag);
                            }
                        };
                        sysU.ajax(ajaxConfig);
                    }
                    if (addSaveBefore === undefined) {
                        ajax();
                        return false;
                    }
                    addSaveBefore.call(null, data, function () { ajax() });
                    return false;
                });
            }

            if (before == undefined) {
                layer.alert("【复制新增】请先配置addBeforeXXX配置!", { icon: sysU.config.iconoError, shade: 0.4, time: sysU.config.errorTime });
                return false;
            }
            before.call(null, function () {
                editBefore.call(null, checkStatus.data[0], function () {
                    sysU.openAddOrEdit(parm, sysU);
                });
            });
            return false;
        },

        btnEdit: function (sysU, toolbarId) {
            var checkStatus = {};
            if (!table.checkStatus) {
                checkStatus["data"] = [action.rowData];
            } else {
                checkStatus = table.checkStatus(toolbarId);
            }
            var selectRow = checkStatus.data.length;//选中的行数
            if (selectRow === 0 || selectRow > 1) {
                layer.alert(`请选择一条数据后,在编辑。当前选择的行数【${selectRow}】条!`, { icon: sysU.config.iconoError, shadeClose: true, title: "错误信息" });
                return false;
            }
            var parm = null, before = null, editSaveBefore = null, actionSuccessFlag = null;
            if (toolbarId.indexOf(descSuffix) > -1) {
                parm = action.editOptionsDesc();
                before = action["editBeforeDesc"];
                editSaveBefore = action["editSaveBeforeDesc"];
                actionSuccessFlag = "editDesc";
                parm["btnOpenYes"] = "button[name=fromUpdateDesc]";
            } else {
                parm = action.editOptions(checkStatus.data[0]);
                before = action["editBefore"];
                editSaveBefore = action["editSaveBefore"];
                actionSuccessFlag = "edit";
                parm["btnOpenYes"] = "button[name=fromUpdate]";
            }
            parm["title"] = sysU.config.titleEdit + (parm["title"] == undefined ? "" : parm["title"]);
            var fromId = $(parm.fromId);
            if (fromId.length === 0) {
                layer.alert(`btnEdit方法,表单节点${parm.fromId}不存在!请核实xxx.cshtml页面!`, { icon: sysU.config.iconoError, shadeClose: true, title: "错误信息" });
                return false;
            }
            $(parm.fromId)[0].reset();

            parm.success = function (index) {
                let addOpenIndex = index;
                form.on(parm.submit, function (data) {
                    var result = sysU.requiredExtend(data.form);
                    if (!result) return false;
                    function ajax() {
                        var ajaxConfig = {
                            data: { entity: data.field },
                            url: parm.url,
                            success: function (result) {
                                if (sysU.successBefore(result)) return;
                                layer.close(addOpenIndex);
                                layer.msg(sysU.config.titleUpdateSuccess, { icon: sysU.config.iconoOk, shade: 0.4, time: sysU.config.msgOpenTime });
                                $("#" + toolbarId).next().children(".layui-table-page").find(".layui-icon-refresh").click();
                                if (action["actionSuccess"] !== undefined) action["actionSuccess"].call(null, actionSuccessFlag);
                            }
                        };
                        sysU.ajax(ajaxConfig);
                    }
                    if (editSaveBefore === undefined) {
                        ajax();
                        return false;
                    }
                    editSaveBefore.call(null, data, function () { ajax() });
                    return false;
                });
            }
            if (before == undefined) {
                sysU.openAddOrEdit(parm, sysU);
                return false;
            }
            before.call(null, checkStatus.data[0], function () { sysU.openAddOrEdit(parm, sysU) });
            return false;
        },

        btnDelete: (sysU, toolbarId) => {
            var checkStatus = {};
            if (!table.checkStatus) {
                checkStatus["data"] = [action.rowData] ;
            } else {
                checkStatus = table.checkStatus(toolbarId);
            }
            var parm = null, before = null;
            if (toolbarId.indexOf(descSuffix) > -1) {
                parm = action.deleteOptionsDesc();
                before = action["deleteBeforeDesc"];
                parm["actionSuccessFlag"] = "deleteDesc";
            } else {
                parm = action.deleteOptions();
                before = action["deleteBefore"];
                parm["actionSuccessFlag"] = "delete";
            }
            parm["toolbarId"] = toolbarId;

            if (checkStatus.data.length === 0) {
                layer.alert(sysU.config.titleSelectOneRowData, { icon: sysU.config.iconoError, shadeClose: true, title: sysU.config.titleSelectOneRowData });
                return false;
            }
            if (before == undefined) {
                sysU.deleteConfirm(parm, sysU, checkStatus.data);
                return false;
            }
            before.call(null, checkStatus.data, function () { sysU.deleteConfirm(parm, sysU, checkStatus.data) });
        },

        btnRefresh: (sysU, toolbarId) => {
            //actionSuccess 删除需要刷新,其他的不需要 
            var flag = toolbarId == null ? "" : toolbarId.indexOf(descSuffix) > -1 ? "refreshDesc" : "refresh";
            sU.config.btnRefreshLoadIndex = layer.load(0); //添加laoding,0-2两种方式
            var refreshElem = $("#" + toolbarId).next(),
                pageArr = refreshElem.attr("lay-filter").split('-'),
                lastPage = pageArr[pageArr.length - 1];
            //var pageElem = "#layui-table-page" + lastPage,
            //    $pageElem = $(pageElem).find(".layui-icon-refresh");
            //if ($pageElem.length > 0) {
            //    $pageElem.click();
            //} 
			layer.close(sU.config.btnRefreshLoadIndex);
            if (action["actionSuccess"] !== undefined) action["actionSuccess"].call(null, flag, toolbarId);
        },

        btnSelect: (sysU, toolbarId) => {
            if (toolbarId.indexOf(descSuffix) > -1) {
                systemAction.config.panelSearchDesc.toggle("fast");
            } else if (toolbarId.indexOf(footerSuffix) > -1) {
                systemAction.config.panelSearchFooter.toggle("fast");
            } else {
                systemAction.config.panelSearch.toggle("fast");
            }
        },

        btnUpload: (sysU, toolbarId, tableObj) => {
            var parm = null, before = null, uploadSaveBefore = null, actionSuccessFlag = null;
            if (toolbarId.indexOf(descSuffix) > -1) {
                parm = action.uploadOptionsDesc();
                before = action["uploadBeforeDesc"];
                uploadSaveBefore = action["uploadSaveBeforeDesc"];
                actionSuccessFlag = "uploadDesc";
            } else {
                parm = action.uploadOptions();
                before = action["uploadBefore"];
                uploadSaveBefore = action["uploadSaveBefore"];
                actionSuccessFlag = "upload";
            }
            if (typeof parm.content == "undefined") {
                console.log("btnUpload 方法 uploadOptions 参数不存在 content ");
            }
            var area = parm["area"] == undefined ? ['420px', '300px'] : parm.area;
            //是否要选择数据 上传
            var selectRow = table.checkStatus(toolbarId);
            if (selectRow.data.length > 1) {
                layer.alert(sysU.config.titleSelectOne, { icon: sysU.config.iconoError, shadeClose: true, title: "错误信息" });
                return false;
            }
            if (selectRow.data.length === 0) {
                //'#modifyForm form'
                var keyEle = "#" + parm.content[0].id + " form"
                if ($(keyEle).length > 0) $(keyEle)[0].reset();
            }
            $(parm.fromFile).val("");
            if (before != undefined) {
                var result = before.call(null, selectRow, parm);
                if (typeof result != "undefined" && !result) return false;
            }
            layer.open({
                type: 1,
                skin: "layui-layer-molv",
                anim: 1,
                id: "LAY_layuipro", //设定一个id,防止重复弹出
                moveType: 1, //拖拽模式,0或者1
                title: "请选择导入的文件<span style=\"color:red;font-weight: bold;\">(时间可能比较久,请耐心等待...)</span>", //不显示标题
                area: area, //宽高
                content: parm.content, //捕获的元素
                scrollbar: false,
                btn: ['导入', '关闭'],
                yes: function (index) {
                    var index1 = layer.load();
                    let tempId = parm.fromFile.replace("#", "");
                    var fileEle = document.getElementById(tempId); // js 获取文件对象
                    if (fileEle == null) {
                        layer.alert(`上传配置文件元素节点【${tempId}】不存在`, { skin: 'layui-layer-molv', anim: 1, icon: sysU.config.iconoError });
                        layer.close(index1);
                        return false;
                    }
                    var fileObj = fileEle.files;
                    //上传和编辑使用同一方法,此处在后端进行验证
                    //if (typeof (fileObj) == "undefined" || fileObj.length <= 0) {
                    //    layer.alert("请先选择需要上传的文件!", { skin: 'layui-layer-molv', anim: 1, icon: sysU.config.iconoError });
                    //    layer.close(index1);
                    //    return false;
                    //}
                    var formFile = new FormData(),
                        keys = "excelfile";
                    for (var i = 0; i < fileObj.length; i++) {
                        formFile.append(keys, fileObj[i]); //加入文件对象
                    }
                    //填充表单值
                    var fromValue = form.val(parm.content[0].id);
                    delete fromValue.excelfile;
                    var allFormNamekeys = Object.keys(fromValue);
                    for (var item in allFormNamekeys) {
                        if (!Object.prototype.hasOwnProperty.call(keys, item)) continue;
                        var closName = allFormNamekeys[item],
                            val = fromValue[closName];
                        formFile.append(closName, val);
                    }

                    function ajax() {
                        var ajaxConfig = {
                            data: formFile,
                            url: parm.url,
                            timeout: 300000,//超时5分钟
                            cache: false,//上传文件无需缓存
                            processData: false,//用于对data参数进行序列化处理 这里必须false
                            contentType: false, //必须
                            success: function (result) {
                                if (sysU.successBefore(result)) return;
                                layer.msg(result.Message, { icon: sysU.config.iconoOk, shade: 0.4, time: sysU.config.msgOpenTime });
                                if (action["actionSuccess"] !== undefined) action["actionSuccess"].call(null, actionSuccessFlag);
                                setTimeout(() => { layer.closeAll(); }, 2000);
                            }
                        };
                        sysU.ajax(ajaxConfig);
                    }
                    if (uploadSaveBefore === undefined) {
                        ajax();
                        return false;
                    }
                    uploadSaveBefore.call(null, { formFile, parm, closeIndex: index1, keys: keys }, selectRow, function () { ajax() });
                },
                cancel: function (index) {
                    layer.close(index);
                }
            });
        },

        btnExport: (sysU, toolbarId, tableObj) => {
            var parm = action.exportOptions(),
                data = form.val(parm.fromId);
            data["Exel"] = true;
            //附加查询条件 exportOptions: sendDataWhere
            if (typeof (parm.sendDataWhere) != "undefined") {
                var allKeys = Object.keys(parm.sendDataWhere);
                for (var tempKey in allKeys) {
                    if (Object.prototype.hasOwnProperty.call(allKeys, tempKey)) {
                        let resultKey = allKeys[tempKey];
                        data[resultKey] = parm.sendDataWhere[resultKey];
                    }
                }
            }
            function fnCallBack() {
                var ajaxConfig = $.extend({
                    data: data,
                    url: parm.url,
                    success: function (result) {
                        if (sysU.successBefore(result)) return false;
                        var excelParm = typeof parm.isDefault == "undefined" ? tableObj : parm;
                        //ajax成功之后对数据二次处理
                        if (typeof (parm.ExcelExportFn) != "undefined") {
                            parm.ExcelExportFn(excelParm, result, toolbarId, (function (excelParm, result, toolbarId) {
                                sysU.ExcelExportData(excelParm, result, toolbarId)
                            }));
                        } else {
                            sysU.ExcelExportData(excelParm, result, toolbarId);
                        }
                    }
                }, parm.ajaxOpt);
                sysU.ajax(ajaxConfig);
            }
            var keysMethodName = "btnExportBefore";
            if (action[keysMethodName] !== undefined) {
                action[keysMethodName].call(null, sysU, parm, data, tableObj, fnCallBack);
                return false;
            }
            fnCallBack();
        },

        btnQuery: function (sysU, parameter) {
            var tempTable = table;
            //用于判断是否为树形表格
            if (parameter.isTable == true) {
                tempTable = treeTable;
            }
            let index = layer.load(0);
            if (typeof parameter.isDefault != "undefined" && !parameter.isDefault) {
                var result = parameter.customFn(sysU, parameter);
                if (result != "0" || typeof result == "undefined") systemAction.config.panelSearch.toggle("fast");
                return false;
            }
            var sendDataWhere = form.val(parameter.fromId);
            if (typeof parameter.sendDataWhere != "undefined" && typeof parameter.isAddWhereExtend == "undefined") {
                $.extend(sendDataWhere, parameter.sendDataWhere);
            }
            let toolbarId = parameter.mainTable.config.id;
            function fnCallBack() {
                var ajaxConfig = $.extend({
                    page: { curr: 1 },
                    url: parameter.urlQuery,
                    method: "post",
                    where: sendDataWhere,
                    done: function (x, y, z) {
                        layer.close(index);
                        //回调函数
                        parameter.doneExtend && parameter.doneExtend.call(this, x, y, z);
                    }
                }, parameter.ajaxOpt);
                tempTable.reload(parameter.mainTable.config.id, ajaxConfig);
                systemAction.btnSelect(sysU, toolbarId);
            }
            var keysMethodName = "queryBefore";
            if (action[keysMethodName] !== undefined) {
                action[keysMethodName].call(null, sysU, toolbarId, sendDataWhere, fnCallBack);
                return false;
            }
            fnCallBack();
        },

        /*
         * 0:layui方式引入 jqprint
         * 1:传统方式引入qrcode.js文件,
         * 2:qrCodeValueKey是二维码值 对应的key
         * 3:customFn 自定义填充的内容显示数据
        */
        btnPrint: (sysU, toolbarId) => {
            var checkStatus = table.checkStatus(toolbarId);
            var parm = null, before = null;
            if (toolbarId.indexOf(descSuffix) > -1) {
                parm = action.qcCodePrintOptionsDesc();
                before = action["qcCodePrintBeforeDesc"];
            } else {
                parm = action.qcCodePrintOptions();
                before = action["qcCodePrintBefore"];
            }
            if (checkStatus.data.length === 0) {
                layer.alert(sysU.config.titleSelectOneRowData, { icon: sysU.config.iconoError, shadeClose: true, title: sysU.config.titleSelectOneRowData });
                return false;
            }
            for (var i = 0; i < checkStatus.data.length; i++) {
                var qcValue = checkStatus.data[i][parm.qrCodeValueKey];
                if (qcValue == null || qcValue == "") {
                    layer.alert(`选择的行数据二维码行号【${i + 1}key:${parm.qrCodeValueKey}】值为空!`, { icon: 2, shadeClose: true, title: sysU.config.titleSelectOneRowData });
                    console.error("打印二维码 btnPrint 二维码值对月的值是空:" + parm.qrCodeValueKey);
                    return false;
                }
            }
            if (before == undefined) {
                sysU.printBarCode(parm, sysU, checkStatus.data);
                return false;
            }
            before.call(null, checkStatus.data, function () { sysU.printBarCode(parm, sysU, checkStatus.data) });
        },

        //reset
        btnReset: (sysU, parameter) => { $(parameter.resetFrom)[0].reset(); },

        //close
        btnClose: (sysU, parameter) => {
           // systemAction.btnSelect(sysU, parameter.mainTable.config.id);

            systemAction.config.panelSearchDesc.hide("fast");
            systemAction.config.panelSearchFooter.hide("fast");
            systemAction.config.panelSearch.hide("fast");
        },

        //down
        btnTemplate: (sysU, parameter) => { sysU.exelDownTemplate(parameter.mainTable); },

        tableRowClick: function (obj) {
            if (typeof action == "undefined" || typeof action.rowClickOptions == "undefined") {
                console.log("action is null or action rowClickOptions is null");
                return false;
            }
            var parm = action.rowClickOptions(obj),
                tableId = $(obj.tr[0]).closest(".layui-tab-item").children("table");
            if (tableId.length == 0) {
                element.tabChange(parm.tabfilter, parm.tabId);
                parm.customFn(obj);
            } else {
                tableId = tableId[0].id;
                if (tableId.indexOf(descSuffix) > -1 && typeof action.rowClickOptionsFooter != "undefined") {
                    parm = action.rowClickOptionsFooter();
                    systemAction.config.panelSearchFooter.hide();
                } else {
                    systemAction.config.panelSearch.hide();
                }
                if (!parm.isDefault) {
                    parm.customFn(obj);
                    return false;
                }
                if (tableId === parm.targetTableId) {
                    element.tabChange(parm.tabfilter, parm.tabId);
                    parm.customFn(obj);
                } else {
                    console.log("tableRowClick 没有找到对应的表格targetTableId:" + JSON.stringify(parm));
                }
            }
        }
    }

    sU.initFormEvent();
    sU.initDate();
    sU.initRegisterEvent();
    sU.initWatchChild();
    sU.ajaxError();
    sU.setColumnWidth();
    //外部入口
    var system = {
        u: u,
        /*
        * table 工具栏事件
        */
        registerEvent: function (toolbarId, detailId = "") {
            table.on(`toolbar(${toolbarId})`, function (obj) {
                if (sU.config.ignoreEvent.includes(obj.event)) return false;
                sU.cookieVerification();
                //公共方法 【systemAction】
                var event = systemAction[obj.event];
                if (event != null) event(sU, toolbarId, obj);
                //自定义方法【action】
                if (event == null && action[obj.event] != null) action[obj.event](sU, toolbarId, obj);
                if (event == null && action[obj.event] == null) console.error("主表toolbar没有找到对应的方法:" + obj.event +"参数 sU, toolbarId, obj");
            });

            //明细表格
            if (detailId !== "") {
                table.on(`toolbar(${detailId})`, function (obj) {
                    if (sU.config.ignoreEvent.includes(obj.event)) return false;
                    sU.cookieVerification();
                    var event = systemAction[obj.event];
                    if (event != null) event(sU, detailId, obj);
                    if (event == null && action[obj.event] != null) action[obj.event](sU, detailId, obj);
                    if (event == null && action[obj.event] == null) console.error("明细表格toolbar没有找到对应的方法:" + obj.event);
                });
            }
        },

        query: () => {
            //查询、重置、关闭
            $("#ImportData .layui-btn,.toolList .layui-btn").unbind('click').click(function () {
                var type = $(this).data('type'),
                    falg = $(this).data('flag')                    ;
                if (!type) {
                    console.log("query方法type没有找到对应方法:" + type);
                    return;
                }
                var parm = action.queryOptions();
                if (typeof falg != "undefined") {
                    parm = eval(`action.queryOptions${falg}()`);
                }
                systemAction[type] ? systemAction[type].call(this, sU, parm) : console.error("query方法type没有找到对应方法:" + type);
            });
        },

		//自定义table tool点击事件(不是table 也想使用公共方法) 需要手动注册事件,默认 【system】.queryExtend();
        //layui-btn-container class下面的layui-btn 元素
        queryExtend: () => {
            $(".layui-btn-container .layui-btn").unbind('click').click(function () {
                var type = $(this).attr("lay-event");
                sU.cookieVerification();
                //公共方法 【systemAction】
                var event = systemAction[type];
                if (event != null) event(sU, "queryExtend", null);
                //自定义方法【action】
                if (event == null && action[type] != null) action[type](sU, null, null);

                if (event == null && action[type] == null)  
                    console.log(`自定义table tool点击事件【lay-event:${type}】为空请留意,业务不需要请忽略!`);
            });
        }
    };
    exports('system', system);
});

///dataSourceKey:数据源 ,comparisonField:数据源属性的值(一般是code) retrunKey:返回字段的值(一般是name) , comparisonValue:具体的值
function GetDicLabel(dataSourceKey, comparisonField, retrunKey, comparisonValue) {
    var temp = SelectorSource[dataSourceKey];
    if (temp == null) {
        console.error(`GetDicLabel 读取数据不存在,dataSourceKey:${dataSourceKey}comparisonField:${comparisonField}、返回字段:${retrunKey}、当前比较的值:${comparisonValue}、`);
        return comparisonValue;
    }
    var result = "";
    for (var i = 0; i < temp.length; i++) { 
        if (temp[i][comparisonField] != comparisonValue) continue;
        result = temp[i][retrunKey];
    }
    return result;
}

var sbList = {};
function loadMenus(modulecode, areaMenus) {
    var menuFlag = "".GetUrlParam("menuFlag");
    //-2无菜单,用于子页面弹窗公用layui-table-tool
    if (menuFlag == -2) {
        $(".layui-table-tool").remove();
        return "";
    }
    if (sbList[areaMenus] != undefined) { return sbList[areaMenus]; }
    var urlMenu = `/base/SysModule/LoadAuthorizedMenus?modulecode=${modulecode}&AreaMenus=${areaMenus}`;
    var strArr = [];
    $.ajax({
        url: urlMenu,
        success: function (data) {
            if (data === "") { return }
            var elementJosn = JSON.parse(data);
            for (var i = 0; i < elementJosn.length; i++) {
                strArr.push(`<a href='javascript:;' lay-event=${elementJosn[i].DomId} class='layui-btn layui-btn-sm ${elementJosn[i].Class}'>`);
                if (elementJosn[i].Icon != null && elementJosn[i].Icon != '') {
                    strArr.push(`<i class='layui-icon'>${elementJosn[i].Icon}</i>`);
                }
                strArr.push(`${elementJosn[i].Name} </a>`);
            }
            var tempStr = strArr.join("");
            sbList[areaMenus] = tempStr;
            var quanxian = $(".layui-btn-container");
            if (quanxian.length > 1) {
                quanxian.eq(1).append(tempStr);
            } else {
                quanxian.append(tempStr);
            }
        }
    });
}