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


1.品项填写的次数不能超过当前品项的剩余次数
2.每个品项下面最少选择一个健康师 健康师的业绩必须填写
3.每个品项的健康师业绩之和必须要等于 这个品项的金额(单价乘以次数)
4.每个品项的健康手工费之和必须要等于 这个品项的手工费(手工费乘以次数)
5.每个品项的健康次数之和必须要等于 这个品项的次数
6.如果这个品项是科美 那么所有的限制都要和健康师一样


把健康师和科技部老师放在品项里面选择 和品项相关联 健康师和科技部老师是多选 科技部根据品项是否是科美来判断  在提交的时候需要验证品项的金额之和要等于健康师业绩之和,品项的金额之和要等于科技部业绩之和  仔细阅读我的需求 只处理需要处理的部分不要把我其他的逻辑影响了

把健康师和科技部老师放在品项里面选择 和品项相关联 健康师和科技部老师是多选 科技部根据品项是否是科美来判断  改动内容可以参考开单  但是参数要按之前发的数据格式 

<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>绿纤协同平台 - 开单</title>
		<!-- 引入配置文件 -->
		<script src="config.js"></script>
		<!-- 引入认证工具 -->
		<script src="auth-utils.js"></script>
		<style>
			*,  
			*::before,
			*::after {
				box-sizing: border-box;
			} 
 
			body {
				font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
				margin: 0;
				min-height: 100vh;
				background: linear-gradient(135deg, #e8f5e9 0%, #b2dfdb 100%);
				padding: 20px;
			}

			.container {
				width: 100%;
				max-width: 480px;
				margin: 0 auto;
			}

			.header {
				background: linear-gradient(120deg, #43e97b 0%, #38f9d7 100%);
				border-radius: 18px;
				padding: 24px;
				text-align: center;
				margin-bottom: 24px;
				box-shadow: 0 4px 24px 0 rgba(76, 175, 80, 0.10);
			}

			.header-title {
				color: #fff;
				font-size: 1.3em;
				font-weight: bold;
				letter-spacing: 2px;
				margin: 0;
			}

			.form-card {
				background: #fff;
				border-radius: 18px;
				box-shadow: 0 4px 24px 0 rgba(76, 175, 80, 0.10);
				border: 1.5px solid #c8e6c9;
				overflow: hidden;
			}

			.form-content {
				padding: 24px;
			}

			.form-group {
				margin-bottom: 20px;
			}

			.form-group:last-child {
				margin-bottom: 0;
			}

			label {
				display: block;
				margin-bottom: 8px;
				font-weight: bold;
				color: #388e3c;
				letter-spacing: 1px;
				font-size: 0.95em;
			}

			.input-wrapper {
				position: relative;
			}

			.input-icon {
				position: absolute;
				left: 12px;
				top: 50%;
				transform: translateY(-50%);
				width: 20px;
				height: 20px;
				color: #6a9c6a;
			}

			input,
			.select-input,
			select,
			textarea {
				width: 100%;
				padding: 12px 12px 12px 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				transition: all 0.2s ease;
				background: #f9fff9;
				color: #2e7d32;
				font-family: inherit;
			}

			input:focus,
			.select-input:focus,
			select:focus,
			textarea:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			textarea {
				resize: vertical;
				min-height: 80px;
			}

			input:disabled {
				background: #f5f5f5;
				color: #666;
				cursor: not-allowed;
			}

			.select-input {
				cursor: pointer;
				position: relative;
			}

			.select-input::after {
				content: "";
				position: absolute;
				right: 12px;
				top: 50%;
				transform: translateY(-50%);
				color: #6a9c6a;
				font-size: 0.8em;
			}

			/* 优化select下拉框样式 */
			select {
				cursor: pointer;
				appearance: none;
				background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a9c6a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
				background-repeat: no-repeat;
				background-position: right 12px center;
				background-size: 16px;
				padding-right: 40px;
			}

			select:hover {
				border-color: #43a047;
				background-color: #fff;
			}

			select option {
				padding: 8px 12px;
				background: #fff;
				color: #2e7d32;
			}

			select option:hover {
				background: #e8f5e9;
			}

			/* 数字输入框样式优化 */
			input[type="number"] {
				-moz-appearance: textfield;
				/* Firefox */
			}

			input[type="number"]::-webkit-outer-spin-button,
			input[type="number"]::-webkit-inner-spin-button {
				-webkit-appearance: none;
				margin: 0;
			}

			input[type="number"]:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.btn-group {
				position: fixed;
				bottom: 0;
				width: 100%;
				display: flex;
				gap: 12px;
				margin-top: 24px;
			}

			.btn {
				flex: 1;
				padding: 14px 20px;
				border: none;
				border-radius: 10px;
				font-size: 1em;
				font-weight: bold;
				cursor: pointer;
				transition: all 0.2s ease;
				letter-spacing: 1px;
			}

			.btn-primary {
				background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
				color: #fff;
				box-shadow: 0 2px 8px rgba(67, 233, 123, 0.3);
			}

			.btn-primary:hover {
				box-shadow: 0 4px 16px rgba(67, 233, 123, 0.4);
				transform: translateY(-1px);
			}

			.btn-secondary {
				background: #f5f5f5;
				color: #666;
				border: 1.5px solid #ddd;
			}

			.btn-secondary:hover {
				background: #e8e8e8;
				border-color: #ccc;
			}

			/* 弹窗样式 */
			.modal-overlay {
				position: fixed;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				background: rgba(0, 0, 0, 0.5);
				display: none;
				align-items: center;
				justify-content: center;
				z-index: 10001;
				padding: 20px;
			}

			.modal-content {
				background: #fff;
				border-radius: 18px;
				width: 100%;
				max-width: 400px;
				max-height: 80vh;
				overflow: hidden;
				box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
			}

			.modal-header {
				background: linear-gradient(120deg, #43e97b 0%, #38f9d7 100%);
				padding: 20px;
				text-align: center;
			}

			.modal-title {
				color: #fff;
				font-size: 1.2em;
				font-weight: bold;
				margin: 0;
				letter-spacing: 1px;
			}

			.modal-body {
				padding: 20px;
			}

			.search-input {
				width: 100%;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				margin-bottom: 16px;
				background: #f9fff9;
			}

			.search-input:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
			}

			.option-list {
				max-height: 300px;
				overflow-y: auto;
				border: 1px solid #e0e0e0;
				border-radius: 8px;
			}

			.option-item {
				padding: 12px 16px;
				border-bottom: 1px solid #f0f0f0;
				cursor: pointer;
				transition: background 0.2s ease;
			}

			.option-item:hover {
				background: #f5f5f5;
			}

			.option-item:last-child {
				border-bottom: none;
			}

			.option-item.selected {
				background: #e8f5e9;
				color: #2e7d32;
				font-weight: bold;
			}

			.loading-message {
				text-align: center;
				padding: 40px 20px;
				color: #666;
				font-size: 0.95em;
			}

			.loading-spinner {
				display: inline-block;
				width: 20px;
				height: 20px;
				border: 2px solid #e0e0e0;
				border-top: 2px solid #43a047;
				border-radius: 50%;
				animation: spin 1s linear infinite;
				margin-right: 8px;
			}

			@keyframes spin {
				0% {
					transform: rotate(0deg);
				}

				100% {
					transform: rotate(360deg);
				}
			}

			.modal-footer {
				padding: 16px 20px;
				border-top: 1px solid #e0e0e0;
				display: flex;
				gap: 12px;
			}

			.modal-btn {
				flex: 1;
				padding: 10px 16px;
				border: none;
				border-radius: 8px;
				font-size: 0.95em;
				cursor: pointer;
				transition: all 0.2s ease;
			}

			.modal-btn-primary {
				background: #43a047;
				color: #fff;
			}

			.modal-btn-primary:hover {
				background: #388e3c;
			}

			.modal-btn-secondary {
				background: #f5f5f5;
				color: #666;
				border: 1px solid #ddd;
			}

			.modal-btn-secondary:hover {
				background: #e8e8e8;
			}

			@media (max-width: 520px) {
				.container {
					max-width: 100%;
				}

				.header {
					border-radius: 12px;
					padding: 20px;
				}

				.form-card {
					border-radius: 12px;
				}

				.form-content {
					padding: 20px;
				}

				.btn-group {
					flex-direction: column;
				}
			}

			h2 {
				text-align: center;
				color: #388e3c;
				margin-bottom: 18px;
				letter-spacing: 2px;
			}

			/* 消息提示样式 */
			.message-toast {
				position: fixed;
				top: 20px;
				right: 20px;
				max-width: 300px;
				padding: 16px 20px;
				border-radius: 10px;
				color: #fff;
				font-weight: 500;
				z-index: 10000;
				transform: translateX(200%);
				transition: all 0.3s ease;
				box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
				text-align: center;
			}

			.message-toast.show {
				top: 50%;
				left: 50%;
				transform: translateX(-50%) translateY(-100%);
			}

			.message-toast.success {
				background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
			}

			.message-toast.error {
				background: linear-gradient(135deg, #f44336 0%, #ef5350 100%);
			}

			.message-toast.warning {
				background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%);
			}

			.message-toast.info {
				background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%);
			}

			/* 健康师相关样式 */
			.jks-container {
				margin-bottom: 16px;
			}

			.jks-row {
				display: flex;
				gap: 12px;
				margin-bottom: 12px;
				align-items: center;
			}

			.jks-select {
				flex: 2;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				background: #f9fff9;
				color: #2e7d32;
				cursor: pointer;
				position: relative;
			}

			.jks-select:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.jks-select::after {
				content: "";
				position: absolute;
				right: 12px;
				top: 50%;
				transform: translateY(-50%);
				width: 0;
				height: 0;
				border-left: 4px solid transparent;
				border-right: 4px solid transparent;
				border-top: 6px solid #6a9c6a;
			}

			.jks-amount {
				flex: 1;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				background: #f9fff9;
				color: #2e7d32;
			}

			.jks-amount:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.jks-delete {
				padding: 12px 16px;
				border: 1.5px solid #ddd;
				border-radius: 10px;
				background: #f5f5f5;
				color: #666;
				cursor: pointer;
				font-size: 0.9em;
				transition: all 0.2s ease;
			}

			.jks-delete:hover {
				background: #e8e8e8;
				border-color: #ccc;
			}

			.btn-add-jks {
				width: 100%;
				padding: 12px 20px;
				border: 1.5px solid #43a047;
				border-radius: 10px;
				background: #e8f5e9;
				color: #2e7d32;
				cursor: pointer;
				font-size: 1em;
				font-weight: bold;
				transition: all 0.2s ease;
			}

			.btn-add-jks:hover {
				background: #c8e6c9;
				border-color: #388e3c;
			}

			/* 科技部人员相关样式 */
			.kjb-container {
				margin-bottom: 16px;
			}

			.kjb-row {
				display: flex;
				gap: 12px;
				margin-bottom: 12px;
				align-items: center;
			}

			.kjb-select {
				flex: 2;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				background: #f9fff9;
				color: #2e7d32;
				cursor: pointer;
				position: relative;
			}

			.kjb-select:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.kjb-select::after {
				content: "";
				position: absolute;
				right: 12px;
				top: 50%;
				transform: translateY(-50%);
				width: 0;
				height: 0;
				border-left: 4px solid transparent;
				border-right: 4px solid transparent;
				border-top: 6px solid #6a9c6a;
			}

			.kjb-amount {
				flex: 1;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				background: #f9fff9;
				color: #2e7d32;
			}

			.kjb-amount:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.kjb-delete {
				padding: 12px 16px;
				border: 1.5px solid #ddd;
				border-radius: 10px;
				background: #f5f5f5;
				color: #666;
				cursor: pointer;
				font-size: 0.9em;
				transition: all 0.2s ease;
			}

			.kjb-delete:hover {
				background: #e8e8e8;
				border-color: #ccc;
			}

			.btn-add-kjb {
				width: 100%;
				padding: 12px 20px;
				border: 1.5px solid #43a047;
				border-radius: 10px;
				background: #e8f5e9;
				color: #2e7d32;
				cursor: pointer;
				font-size: 1em;
				font-weight: bold;
				transition: all 0.2s ease;
			}

			.btn-add-kjb:hover {
				background: #c8e6c9;
				border-color: #388e3c;
			}

			/* 品项相关样式 */
			.px-container {
				margin-bottom: 16px;
			}

			.px-row {
				display: flex;
				flex-direction: column;
				gap: 12px;
				margin-bottom: 16px;
				padding: 16px;
				border: 1px solid #e0e0e0;
				border-radius: 10px;
				background: #fafafa;
			}

			.px-row-first {
				display: flex;
				gap: 12px;
				align-items: center;
			}

			.px-row-second {
				display: flex;
				gap: 12px;
				align-items: center;
			}

			.px-select {
				flex: 2;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				background: #f9fff9;
				color: #2e7d32;
				cursor: pointer;
				position: relative;
			}

			.px-select:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.px-select::after {
				content: "";
				position: absolute;
				right: 12px;
				top: 50%;
				transform: translateY(-50%);
				width: 0;
				height: 0;
				border-left: 4px solid transparent;
				border-right: 4px solid transparent;
				border-top: 6px solid #6a9c6a;
			}

			.px-amount {
				flex: 1;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				background: #f9fff9;
				color: #2e7d32;
			}

			.px-amount:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.px-count {
				flex: 1;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				background: #f9fff9;
				color: #2e7d32;
			}

			.px-count:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.px-type {
				flex: 1;
				padding: 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 10px;
				font-size: 1em;
				background: #f9fff9;
				color: #2e7d32;
				cursor: pointer;
			}

			.px-type:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.px-delete {
				padding: 12px 16px;
				border: 1.5px solid #ddd;
				border-radius: 10px;
				background: #f5f5f5;
				color: #666;
				cursor: pointer;
				font-size: 0.9em;
				transition: all 0.2s ease;
			}

			.px-delete:hover {
				background: #e8e8e8;
				border-color: #ccc;
			}

			.btn-add-px {
				width: 100%;
				padding: 12px 20px;
				border: 1.5px solid #43a047;
				border-radius: 10px;
				background: #e8f5e9;
				color: #2e7d32;
				cursor: pointer;
				font-size: 1em;
				font-weight: bold;
				transition: all 0.2s ease;
			}

			
/* 品项中的健康师和科技部老师选择样式 */
.px-row-third, .px-row-fourth {
display: flex;
flex-direction: column;
gap: 8px;
margin-top: 8px;
}

.px-sub-label {
font-size: 0.9em;
font-weight: bold;
color: #388e3c;
margin: 0;
}

.px-multi-select {
padding: 10px 12px;
border: 1.5px solid #c8e6c9;
border-radius: 8px;
font-size: 0.9em;
background: #f9fff9;
color: #2e7d32;
cursor: pointer;
position: relative;
min-height: 20px;
}

.px-multi-select:focus {
outline: none;
border-color: #43a047;
box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
background: #fff;
}

.px-multi-select::after {
content: "";
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 6px solid #6a9c6a;
}

.px-selected-item {
display: inline-block;
background: #e8f5e9;
color: #2e7d32;
padding: 4px 8px;
margin: 2px;
border-radius: 4px;
font-size: 0.8em;
position: relative;
}

.px-selected-item .remove-btn {
margin-left: 4px;
cursor: pointer;
font-weight: bold;
color: #f44336;
}

.px-selected-item .remove-btn:hover {
color: #d32f2f;
}


.btn-add-px:hover {

			/* 签名弹窗样式 */
			.modal-sign {
				display: none;
				position: fixed;
				z-index: 9999;
				left: 0;
				top: 0;
				right: 0;
				bottom: 0;
				background: rgba(0, 0, 0, 0.35);
				justify-content: center;
				align-items: center;
			}

			.modal-sign.active {
				display: flex;
			}

			.modal-sign-content {
				background: #fff;
				border-radius: 14px;
				padding: 18px 12px 12px 12px;
				box-shadow: 0 4px 24px 0 rgba(76, 175, 80, 0.18);
				max-width: 95vw;
				width: 340px;
				display: flex;
				flex-direction: column;
				align-items: center;
			}

			.modal-sign-title {
				color: #388e3c;
				font-weight: bold;
				margin-bottom: 10px;
				font-size: 1.1em;
			}

			.modal-sign-canvas {
				border: 1.5px solid #c8e6c9;
				border-radius: 8px;
				background: #f9fff9;
				touch-action: none;
				margin-bottom: 10px;
			}

			.modal-sign-btns {
				display: flex;
				gap: 12px;
				width: 100%;
				margin-top: 8px;
			}

			.modal-sign-btns button {
				flex: 1;
				padding: 12px 16px;
				font-size: 0.95em;
				font-weight: 500;
				border-radius: 8px;
				border: none;
				cursor: pointer;
				transition: all 0.2s ease;
				letter-spacing: 0.5px;
				box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
			}

			.modal-sign-btns button:hover {
				transform: translateY(-1px);
				box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
			}

			.modal-sign-btns button:active {
				transform: translateY(0);
				box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
			}

			#clearSignBtn {
				background: linear-gradient(135deg, #b2dfdb 0%, #80cbc4 100%);
				color: #00695c;
				border: 1px solid #4db6ac;
			}

			#clearSignBtn:hover {
				background: linear-gradient(135deg, #80cbc4 0%, #4db6ac 100%);
				color: #004d40;
			}

			#okSignBtn {
				background: linear-gradient(135deg, #43a047 0%, #388e3c 100%);
				color: #fff;
				border: 1px solid #2e7d32;
			}

			#okSignBtn:hover {
				background: linear-gradient(135deg, #388e3c 0%, #2e7d32 100%);
			}

			#cancelSignBtn {
				background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
				color: #616161;
				border: 1px solid #bdbdbd;
			}

			#cancelSignBtn:hover {
				background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
				color: #424242;
			}

			.sign-preview {
				margin-top: 8px;
				text-align: center;
			}

			.sign-preview img {
				max-width: 100%;
				max-height: 80px;
				border: 1px solid #c8e6c9;
				border-radius: 6px;
				background: #f9fff9;
				margin-top: 4px;
			}

			/* 文件上传样式优化 */
			.file-upload-area {
				border: 2px dashed #c8e6c9;
				border-radius: 12px;
				padding: 24px;
				text-align: center;
				background: linear-gradient(135deg, #f9fff9 0%, #e8f5e9 100%);
				cursor: pointer;
				transition: all 0.3s ease;
				min-height: 120px;
				display: flex;
				flex-direction: column;
				justify-content: center;
				position: relative;
				overflow: hidden;
			}

			.file-upload-area::before {
				content: '';
				position: absolute;
				top: 0;
				left: -100%;
				width: 100%;
				height: 100%;
				background: linear-gradient(90deg, transparent, rgba(67, 233, 123, 0.1), transparent);
				transition: left 0.5s ease;
			}

			.file-upload-area:hover {
				border-color: #43a047;
				background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
				transform: translateY(-2px);
				box-shadow: 0 8px 25px rgba(67, 233, 123, 0.15);
			}

			.file-upload-area:hover::before {
				left: 100%;
			}

			.file-upload-area.dragover {
				border-color: #43a047;
				background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
				transform: scale(1.02);
				box-shadow: 0 12px 30px rgba(67, 233, 123, 0.2);
			}

			.file-upload-text {
				display: flex;
				flex-direction: column;
				align-items: center;
				gap: 12px;
				color: #6a9c6a;
				font-size: 0.95em;
				position: relative;
				z-index: 1;
			}

			.file-upload-icon {
				font-size: 2.5em;
				opacity: 0.8;
				transition: all 0.3s ease;
			}

			.file-upload-area:hover .file-upload-icon {
				transform: scale(1.1);
				opacity: 1;
			}

			.file-upload-text span:last-child {
				font-weight: 500;
				letter-spacing: 0.5px;
			}

			.file-list {
				margin-top: 16px;
				text-align: left;
				max-height: 200px;
				overflow-y: auto;
			}

			.file-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 12px 16px;
				background: #fff;
				border: 1px solid #e0e0e0;
				border-radius: 8px;
				margin-bottom: 8px;
				font-size: 0.9em;
				transition: all 0.2s ease;
				box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
			}

			.file-item:hover {
				box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
				transform: translateY(-1px);
			}

			.file-item:last-child {
				margin-bottom: 0;
			}

			.file-info {
				display: flex;
				align-items: center;
				gap: 12px;
				flex: 1;
				min-width: 0;
			}

			.file-icon {
				font-size: 1.4em;
				width: 24px;
				text-align: center;
			}

			.file-name {
				color: #2e7d32;
				font-weight: 500;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				max-width: 200px;
			}

			.file-size {
				color: #666;
				font-size: 0.85em;
				background: #f5f5f5;
				padding: 2px 6px;
				border-radius: 4px;
			}

			.file-actions {
				display: flex;
				align-items: center;
				gap: 8px;
			}

			.file-remove {
				background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
				color: #fff;
				border: none;
				border-radius: 6px;
				padding: 6px 12px;
				font-size: 0.8em;
				font-weight: 500;
				cursor: pointer;
				transition: all 0.2s ease;
				box-shadow: 0 2px 4px rgba(244, 67, 54, 0.3);
			}

			.file-remove:hover {
				background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
				transform: translateY(-1px);
				box-shadow: 0 4px 8px rgba(244, 67, 54, 0.4);
			}

			.file-remove:active {
				transform: translateY(0);
			}

			.upload-progress {
				width: 100%;
				height: 4px;
				background: #e0e0e0;
				border-radius: 2px;
				overflow: hidden;
				margin-top: 4px;
			}

			.upload-progress-bar {
				height: 100%;
				background: linear-gradient(90deg, #43a047, #66bb6a, #4caf50);
				width: 0%;
				transition: width 0.3s ease;
				position: relative;
			}

			.upload-progress-bar::after {
				content: '';
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
				animation: shimmer 1.5s infinite;
			}

			@keyframes shimmer {
				0% {
					transform: translateX(-100%);
				}

				100% {
					transform: translateX(100%);
				}
			}

			.file-status {
				display: flex;
				align-items: center;
				gap: 4px;
				font-size: 0.8em;
				font-weight: 500;
			}

			.file-status.success {
				color: #4caf50;
			}

			.file-status.error {
				color: #f44336;
			}

			.file-status.uploading {
				color: #ff9800;
			}

			/* 空状态样式 */
			.file-list:empty::after {
				content: '暂无文件';
				display: block;
				text-align: center;
				color: #999;
				font-size: 0.9em;
				padding: 20px;
				font-style: italic;
			}

			/* 响应式优化 */
			@media (max-width: 520px) {
				.file-upload-area {
					padding: 20px 16px;
					min-height: 100px;
				}

				.file-upload-icon {
					font-size: 2em;
				}

				.file-item {
					padding: 10px 12px;
					flex-direction: column;
					align-items: flex-start;
					gap: 8px;
				}

				.file-info {
					width: 100%;
					justify-content: space-between;
				}

				.file-name {
					max-width: 150px;
				}

				.file-actions {
					width: 100%;
					justify-content: flex-end;
				}
			}

			/* 建档按钮样式 */
			.btn-add-member {
				width: 100%;
				padding: 8px 16px;
				border: 1.5px solid #43a047;
				border-radius: 8px;
				background: #e8f5e9;
				color: #2e7d32;
				cursor: pointer;
				font-size: 0.9em;
				font-weight: 500;
				transition: all 0.2s ease;
			}

			.btn-add-member:hover {
				background: #c8e6c9;
				border-color: #388e3c;
			}

			/* 建档弹窗样式 */
			.modal-member-create {
				display: none;
				position: fixed;
				z-index: 9999;
				left: 0;
				top: 0;
				right: 0;
				bottom: 0;
				background: rgba(0, 0, 0, 0.35);
				justify-content: center;
				align-items: center;
			}

			.modal-member-create.active {
				display: flex;
			}

			.modal-member-create-content {
				background: #fff;
				border-radius: 14px;
				padding: 20px;
				box-shadow: 0 4px 24px 0 rgba(76, 175, 80, 0.18);
				max-width: 95vw;
				width: 400px;
				max-height: 80vh;
				overflow-y: auto;
			}

			.modal-member-create-title {
				color: #388e3c;
				font-weight: bold;
				margin-bottom: 20px;
				font-size: 1.2em;
				text-align: center;
			}

			.modal-member-create .form-group {
				margin-bottom: 16px;
			}

			.modal-member-create .form-group:last-child {
				margin-bottom: 0;
			}

			.modal-member-create label {
				display: block;
				margin-bottom: 6px;
				font-weight: bold;
				color: #388e3c;
				font-size: 0.9em;
			}

			.modal-member-create input,
			.modal-member-create select {
				width: 100%;
				padding: 10px 12px;
				border: 1.5px solid #c8e6c9;
				border-radius: 8px;
				font-size: 0.95em;
				background: #f9fff9;
				color: #2e7d32;
			}

			.modal-member-create input:focus,
			.modal-member-create select:focus {
				outline: none;
				border-color: #43a047;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
				background: #fff;
			}

			.modal-member-create-btns {
				display: flex;
				gap: 12px;
				margin-top: 20px;
			}

			.modal-member-create-btns button {
				flex: 1;
				padding: 10px 16px;
				font-size: 0.95em;
				font-weight: 500;
				border-radius: 8px;
				border: none;
				cursor: pointer;
				transition: all 0.2s ease;
			}

			.modal-member-create-btns button:hover {
				transform: translateY(-1px);
				box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
			}

			.modal-member-create-btns button:active {
				transform: translateY(0);
			}

			#createMemberBtn {
				background: linear-gradient(135deg, #43a047 0%, #388e3c 100%);
				color: #fff;
			}

			#createMemberBtn:hover {
				background: linear-gradient(135deg, #388e3c 0%, #2e7d32 100%);
			}

			#cancelMemberBtn {
				background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
				color: #616161;
				border: 1px solid #bdbdbd;
			}

			#cancelMemberBtn:hover {
				background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
				color: #424242;
			}

			/* 只读输入框样式 */
			input[readonly]:not(.select-input) {
				background: #f5f5f5 !important;
				color: #666 !important;
				cursor: not-allowed;
				border-color: #ddd !important;
			}

			input[readonly]:not(.select-input):focus {
				box-shadow: none !important;
				border-color: #ddd !important;
				background: #f5f5f5 !important;
			}

			/* 选择输入框样式(开单会员和金三角) */
			.select-input {
				background: #f9fff9 !important;
				color: #2e7d32 !important;
				cursor: pointer;
				border-color: #c8e6c9 !important;
			}

			.select-input:focus {
				outline: none;
				border-color: #43a047 !important;
				box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1) !important;
				background: #fff !important;
			}

			.select-input:hover {
				border-color: #43a047 !important;
				background: #fff !important;
			}
		</style>
	</head>
	<body>
		<div class="container">
			<h2>绿纤开单</h2>

			<div class="form-card">
				<div class="form-content">
					<form id="orderForm">
						<div class="form-group">
							<label for="kdhy">开单会员</label>
							<div class="input-wrapper">
								<input type="text" id="kdhy" class="select-input" placeholder="请选择开单会员" readonly>
							</div>
							<div style="margin-top: 8px;">
								<button type="button" class="btn-add-member" onclick="openMemberCreateModal()">+ 建档</button>
							</div>
						</div>

						<!-- <div class="form-group">
							<label for="djmd">单据门店</label>
							<div class="input-wrapper">
								<input type="text" id="djmd" class="select-input" placeholder="请选择单据门店" readonly>
							</div>
						</div> -->

						<!-- <div class="form-group">
							<label for="jsj">金三角</label>
							<div class="input-wrapper">
								<input type="text" id="jsj" class="select-input" placeholder="请选择金三角" readonly>
							</div>
						</div> -->



						<div class="form-group" style="display: none;">
							<label for="kdrq">开单日期</label>
							<div class="input-wrapper">
								<input type="date" id="kdrq" placeholder="请选择开单日期">
							</div>
						</div>

						<div class="form-group" style="display: none;">
							<label for="gjlx">顾客类型</label>
							<div class="input-wrapper">
								<select id="gjlx">
									<option value="">请选择顾客类型</option>
									<option value="会员">会员</option>
									<option value="非会员">非会员</option>
								</select>
							</div>
						</div>

						<div class="form-group">
							<label for="zdyj">整单业绩</label>
							<div class="input-wrapper">
								<input type="number" id="zdyj" placeholder="请输入整单业绩" min="0" step="0.01">
							</div>
						</div>

						<div class="form-group">
							<label for="sfyj">实付业绩</label>
							<div class="input-wrapper">
								<input type="number" id="sfyj" placeholder="自动计算" min="0" step="0.01" readonly>
							</div>
						</div>
						<div class="form-group">
							<label>品项明细</label>
							<div class="px-container" id="pxContainer">
								<!-- 品项行将通过JavaScript动态生成 -->
							</div>
							<button type="button" class="btn-add-px" onclick="addPxRow()">添加品项</button>
						</div>
						<div class="form-group">
							<label for="qk">欠款</label>
							<div class="input-wrapper">
								<input type="number" id="qk" placeholder="请输入欠款" min="0" step="0.01">
							</div>
						</div>

						<div class="form-group">
							<label>健康师及业绩分配</label>
							<div class="jks-container" id="jksContainer">
								<!-- 健康师行将通过JavaScript动态生成 -->
							</div>
							<button type="button" class="btn-add-jks" onclick="addJksRow()">添加健康师</button>
						</div>

						<div class="form-group" id="kjbGroup" style="display: none;">
							<label>科技部人员及业绩分配</label>
							<div class="kjb-container" id="kjbContainer">
								<!-- 科技部人员行将通过JavaScript动态生成 -->
							</div>
							<button type="button" class="btn-add-kjb" onclick="addKjbRow()">添加科技部人员</button>
						</div>
						<div class="form-group">
							<label for="sfck">是否储扣</label>
							<div class="input-wrapper">
								<select id="sfck">
									<option value="">请选择是否储扣</option>
									<option value="是"></option>
									<option value="否"></option>
								</select>
							</div>
						</div>
						<div class="form-group" id="ckfsGroup" style="display: none;">
							<label for="ckfs">储扣方式</label>
							<div class="input-wrapper">
								<select id="ckfs">
									<option value="">请选择储扣方式</option>
									<option value="储值卡">储值卡</option>
									<option value="扣项">扣项</option>
									<option value="套餐">套餐</option>
								</select>
							</div>
						</div>

						<div class="form-group" id="ckmxGroup" style="display: none;">
							<label for="ckmx">储扣明细</label>
							<div class="input-wrapper">
								<input type="text" id="ckmx" placeholder="请输入储扣明细">
							</div>
						</div>

						<div class="form-group">
							<label for="fkfs">付款方式</label>
							<div class="input-wrapper">
								<select id="fkfs">
									<option value="">请选择付款方式</option>
									<option value="现金">现金</option>
									<option value="微信">微信</option>
									<option value="支付宝">支付宝</option>
									<option value="银行卡">银行卡</option>
									<option value="合作">合作</option>
									<option value="医院">医院</option>
								</select>
							</div>
						</div>
						<div class="form-group" id="hgjgGroup" style="display: none;">
							<label for="hgjg">合作机构</label>
							<div class="input-wrapper">
								<input type="text" id="hgjg" class="select-input" placeholder="请选择合作机构" readonly>
							</div>
						</div>
						<div class="form-group" id="fkyyGroup" style="display: none;">
							<label for="fkyy">付款医院</label>
							<div class="input-wrapper">
								<input type="text" id="fkyy" class="select-input" placeholder="请选择付款医院" readonly>
							</div>
						</div>

						<div class="form-group" style="display: none;">
							<label for="fkpd">付款判断</label>
							<div class="input-wrapper">
								<input type="text" id="fkpd" placeholder="请输入付款判断">
							</div>
						</div>

						<div class="form-group" style="display: none;">
							<label for="khly">客户来源</label>
							<div class="input-wrapper">
								<select id="khly">
									<option value="">请选择客户来源</option>
									<option value="自然到店">自然到店</option>
									<option value="会员推广">会员推广</option>
									<option value="网络推广">网络推广</option>
								</select>
							</div>
						</div>

						<div class="form-group" style="display: none;">
							<label for="tjr">推荐人</label>
							<div class="input-wrapper">
								<input type="text" id="tjr" placeholder="请输入推荐人">
							</div>
						</div>

						<div class="form-group">
							<label for="sfskdd">是否首开订单</label>
							<div class="input-wrapper">
								<select id="sfskdd">
									<option value="">请选择是否首开订单</option>
									<option value="是"></option>
									<option value="否"></option>
								</select>
							</div>
						</div>




						<div class="form-group">
							<label for="jj">简介</label>
							<div class="input-wrapper">
								<textarea id="jj" placeholder="请输入简介" rows="3"></textarea>
							</div>
						</div>
						<div class="form-group">
							<label for="scwj">上传文件</label>
							<div class="input-wrapper">
								<input type="file" id="fileInput" multiple accept="image/*,.pdf,.doc,.docx"
									style="display: none;">
								<div class="file-upload-area">
									<div class="file-upload-text">
										<span class="file-upload-icon">??</span>
										<span>点击选择文件或拖拽文件到此处</span>
									</div>
									<div class="file-list" id="fileList"></div>
								</div>
							</div>
						</div>
						<!-- <div class="form-group">
							<label for="sign">会员签字</label>
							<div class="input-wrapper">
								<input type="text" id="sign" placeholder="请点击签名" readonly
									style="background:#f9fff9;cursor:pointer;">
								<div class="sign-preview" id="signPreview"></div>
							</div>
						</div> -->
						<div class="form-group">
							<label for="bz">备注</label>
							<div class="input-wrapper">
								<textarea id="bz" placeholder="请输入备注" rows="3"></textarea>
							</div>
						</div>
						<div class="btn-group">
							<button type="submit" class="btn btn-primary">开单</button>
						</div>
					</form>
				</div>
			</div>
			<!-- 签名弹窗 -->
			<div class="modal-sign" id="modalSign">
				<div class="modal-sign-content">
					<div class="modal-sign-title">请在下方签名</div>
					<canvas id="signCanvas" class="modal-sign-canvas" width="300" height="100"></canvas>
					<div class="modal-sign-btns">
						<button type="button" id="clearSignBtn">清除</button>
						<button type="button" id="okSignBtn">确认签名</button>
						<button type="button" id="cancelSignBtn">取消</button>
					</div>
				</div>
			</div>
		</div>

		<!-- 消息提示 -->
		<div id="messageToast" class="message-toast"></div>

		<!-- 弹窗选择器 -->
		<div class="modal-overlay" id="selectModal">
			<div class="modal-content">
				<div class="modal-header">
					<h3 class="modal-title" id="modalTitle">选择</h3>
				</div>
				<div class="modal-body">
					<input type="text" class="search-input" id="searchInput" placeholder="请输入搜索内容">
					<div class="option-list" id="optionList">
						<!-- 选项列表将通过JavaScript动态生成 -->
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="modal-btn modal-btn-secondary" onclick="closeModal()">取消</button>
					<button type="button" class="modal-btn modal-btn-primary" onclick="confirmSelection()">确定</button>
				</div>
			</div>
		</div>

		<!-- 建档弹窗 -->
		<div class="modal-member-create" id="modalMemberCreate">
			<div class="modal-member-create-content">
				<div class="modal-member-create-title">新建会员档案</div>
				<form id="memberCreateForm">
					<div class="form-group">
						<label for="memberName">会员名称</label>
						<input type="text" id="memberName" placeholder="请输入会员名称" required>
					</div>
					<div class="form-group">
						<label for="memberPhone">手机号</label>
						<input type="tel" id="memberPhone" placeholder="请输入手机号" required>
					</div>
					<div class="form-group" style="display: none;">
						<label for="memberType">客户类型</label>
						<select id="memberType">
							<option value="老客" selected>老客</option>
							<option value="新客">新客</option>
						</select>
					</div>
					<div class="form-group">
						<label for="memberSource">客户来源</label>
						<select id="memberSource" onchange="handleMemberSourceChange()">
							<option value="嘉宾">嘉宾</option>
							<option value="自然到店">自然到店</option>
						</select>
					</div>
					<div class="form-group" id="referrerGroup" style="display: none;">
						<label for="referrer">推荐人</label>
						<input type="text" id="referrer" class="select-input" placeholder="请选择推荐人" readonly>
					</div>
				</form>
				<div class="modal-member-create-btns">
					<button type="button" id="cancelMemberBtn" onclick="closeMemberCreateModal()">取消</button>
					<button type="button" id="createMemberBtn" onclick="createMember()">确定</button>
				</div>
			</div>
		</div>

		<script>
			// 全局变量
			let currentSelectField = null;
			let currentOptions = [];
			let selectedOption = null;
			let userInfo = null;
			let jksList = []; // 健康师列表
			let jksOptions = []; // 健康师选项数据
			let kjbList = []; // 科技部人员列表
			let kjbOptions = []; // 科技部人员选项数据
			let pxList = []; // 品项列表
			let pxOptions = []; // 品项选项数据
			let scwjList = []; // 上传文件列表

			// 页面加载完成后初始化
			document.addEventListener("DOMContentLoaded", function() {
				initializePage();
				bindEvents();
				initSignModal(); // 初始化签名功能
				initFileUpload(); // 初始化文件上传功能
			});

			// 初始化签名功能
			function initSignModal() {
				const signInput = document.getElementById('sign');
				const modalSign = document.getElementById('modalSign');
				const signCanvas = document.getElementById('signCanvas');

				if (signInput && modalSign && signCanvas) {
					const ctx = signCanvas.getContext('2d');
					let drawing = false,
						lastX = 0,
						lastY = 0;

					function drawLine(x, y, isDown) {
						if (isDown) {
							ctx.lineWidth = 2;
							ctx.strokeStyle = '#388e3c';
							ctx.lineCap = 'round';
							ctx.lineJoin = 'round';
							ctx.beginPath();
							ctx.moveTo(lastX, lastY);
							ctx.lineTo(x, y);
							ctx.stroke();
						}
						lastX = x;
						lastY = y;
					}

					// 鼠标事件
					signCanvas.addEventListener('mousedown', function(e) {
						drawing = true;
						const rect = signCanvas.getBoundingClientRect();
						lastX = e.clientX - rect.left;
						lastY = e.clientY - rect.top;
					});

					signCanvas.addEventListener('mousemove', function(e) {
						if (!drawing) return;
						const rect = signCanvas.getBoundingClientRect();
						drawLine(e.clientX - rect.left, e.clientY - rect.top, true);
					});

					signCanvas.addEventListener('mouseup', function() {
						drawing = false;
					});
					signCanvas.addEventListener('mouseleave', function() {
						drawing = false;
					});

					// 触摸事件
					signCanvas.addEventListener('touchstart', function(e) {
						e.preventDefault();
						drawing = true;
						const rect = signCanvas.getBoundingClientRect();
						const t = e.touches[0];
						lastX = t.clientX - rect.left;
						lastY = t.clientY - rect.top;
					});

					signCanvas.addEventListener('touchmove', function(e) {
						e.preventDefault();
						if (!drawing) return;
						const rect = signCanvas.getBoundingClientRect();
						const t = e.touches[0];
						drawLine(t.clientX - rect.left, t.clientY - rect.top, true);
					});

					signCanvas.addEventListener('touchend', function() {
						drawing = false;
					});
					signCanvas.addEventListener('touchcancel', function() {
						drawing = false;
					});

					// 点击签名输入框打开弹窗
					signInput.addEventListener('click', function() {
						modalSign.classList.add('active');
					});

					// 取消签名
					document.getElementById('cancelSignBtn').onclick = function() {
						modalSign.classList.remove('active');
					};

					// 清除签名
					document.getElementById('clearSignBtn').onclick = function() {
						ctx.clearRect(0, 0, signCanvas.width, signCanvas.height);
					};

					// 确认签名
					document.getElementById('okSignBtn').onclick = function() {
						const dataURL = signCanvas.toDataURL('image/png');

						// 将base64转换为blob
						const blob = dataURLToBlob(dataURL);
						uploadFile(blob);
						// 生成文件名(使用时间戳)
						const timestamp = new Date().getTime();
						const fileName = `signature_${timestamp}.png`;
						console.log(blob, fileName);
						signInput.value = '已签名';
						// 显示预览
						document.getElementById('signPreview').innerHTML = '<img src="' + dataURL + '" alt="签名">';
						modalSign.classList.remove('active');
					};
				}
			}

			// 添加base64转blob的辅助函数
			function dataURLToBlob(dataURL) {
				console.log(dataURL);
				try {
					// 检查dataURL格式
					if (!dataURL || typeof dataURL !== 'string') {
						throw new Error('Invalid dataURL');
					}

					// 分离MIME类型和base64数据
					const parts = dataURL.split(',');
					if (parts.length !== 2) {
						throw new Error('Invalid dataURL format');
					}

					const mimeType = parts[0].match(/data:([^;]+)/)?.[1] || 'image/png';
					const base64Data = parts[1];

					// 解码base64数据
					const bytes = window.atob(base64Data);

					// 创建ArrayBuffer和Uint8Array
					const ab = new ArrayBuffer(bytes.length);
					const ia = new Uint8Array(ab);

					// 将字符转换为字节
					for (let i = 0; i < bytes.length; i++) {
						ia[i] = bytes.charCodeAt(i);
					}

					return new Blob([ab], {
						type: mimeType
					});
				} catch (error) {
					console.error('dataURLToBlob error:', error);
					// 返回一个空的PNG blob作为fallback
					return new Blob([], {
						type: 'image/png'
					});
				}
			}

			// 初始化页面
			async function initializePage() {
				// 获取当前登录用户
				userInfo = JSON.parse(localStorage.getItem("userInfo"));
				if (!userInfo || Object.keys(userInfo).length === 0) {
					// 没有登录,跳转到登录页面
					window.location.href = "login.html";
					return;
				}
				console.log(userInfo);

				// 设置开单日期默认为今天(使用本地时间)
				const today = new Date();
				const year = today.getFullYear();
				const month = String(today.getMonth() + 1).padStart(2, '0');
				const day = String(today.getDate()).padStart(2, '0');
				const todayString = `${year}-${month}-${day}`;
				document.getElementById("kdrq").value = todayString;

				// 添加默认的健康师行
				addJksRow();
				// 添加默认的科技部人员行
				addKjbRow();
				// 添加默认的品项行
				addPxRow();
				
				// 初始化时计算实付业绩
				calculateShifuYej();
			}

			// 绑定事件
			function bindEvents() {
				// 绑定选择输入框点击事件(只绑定需要弹窗的字段)
				const selectInputs = document.querySelectorAll(".select-input");
				selectInputs.forEach(input => {
					input.addEventListener("click", function() {
						openSelectModal(this);
					});
				});

				// 绑定表单提交事件
				document.getElementById("orderForm").addEventListener("submit", handleFormSubmit);

				// 绑定搜索输入框事件
				document.getElementById("searchInput").addEventListener("input", handleSearch);

				// 绑定数字输入框事件
				bindNumberInputEvents();

				// 绑定是否储扣字段变化事件
				document.getElementById("sfck").addEventListener("change", handleSfckChange);

				// 绑定付款方式字段变化事件
				document.getElementById("fkfs").addEventListener("change", handleFkfsChange);
			}

			// 处理是否储扣字段变化
			function handleSfckChange() {
				const sfck = document.getElementById("sfck").value;
				const ckfsGroup = document.getElementById("ckfsGroup");
				const ckmxGroup = document.getElementById("ckmxGroup");
				const ckfs = document.getElementById("ckfs");
				const ckmx = document.getElementById("ckmx");

				if (sfck === "是") {
					// 显示储扣相关字段
					ckfsGroup.style.display = "block";
					ckmxGroup.style.display = "block";
					// 不设置required属性,使用自定义验证
				} else {
					// 隐藏储扣相关字段
					ckfsGroup.style.display = "none";
					ckmxGroup.style.display = "none";
					// 清空值
					ckfs.value = "";
					ckmx.value = "";
				}
			}

			// 处理付款方式字段变化
			function handleFkfsChange() {
				const fkfs = document.getElementById("fkfs").value;
				const hgjgGroup = document.querySelector('.form-group:has(#hgjg)');
				const fkyyGroup = document.querySelector('.form-group:has(#fkyy)');
				const hgjg = document.getElementById("hgjg");
				const fkyy = document.getElementById("fkyy");

				// 重置所有相关字段
				hgjg.value = "";
				hgjg.dataset.selectedValue = "";
				fkyy.value = "";
				fkyy.dataset.selectedValue = "";

				if (fkfs === "合作") {
					// 显示合作机构,隐藏付款医院
					if (hgjgGroup) {
						hgjgGroup.style.display = "block";
					}
					if (fkyyGroup) {
						fkyyGroup.style.display = "none";
					}
					// 不设置required属性,使用自定义验证
				} else if (fkfs === "医院") {
					// 显示付款医院,隐藏合作机构
					if (hgjgGroup) {
						hgjgGroup.style.display = "none";
					}
					if (fkyyGroup) {
						fkyyGroup.style.display = "block";
					}
					// 不设置required属性,使用自定义验证
				} else {
					// 其他付款方式,隐藏两个字段
					if (hgjgGroup) {
						hgjgGroup.style.display = "none";
					}
					if (fkyyGroup) {
						fkyyGroup.style.display = "none";
					}
					// 取消必填
					hgjg.required = false;
					fkyy.required = false;
				}
			}

			// 绑定数字输入框事件
			function bindNumberInputEvents() {
				const numberInputs = ['zdyj', 'qk']; // 移除sfyj,因为它是自动计算的

				numberInputs.forEach(inputId => {
					const input = document.getElementById(inputId);

					// 输入时验证
					input.addEventListener('input', function() {
						validateNumberInput(this);
						// 如果是整单业绩,自动计算欠款
						if (inputId === 'zdyj') {
							calculateQiankuan();
						}
					});

					// 失去焦点时验证
					input.addEventListener('blur', function() {
						validateNumberInput(this);
						// 如果是整单业绩,自动计算欠款
						if (inputId === 'zdyj') {
							calculateQiankuan();
						}
					});
				});

				// 添加品项次数输入框的验证
				document.addEventListener('input', function(e) {
					if (e.target.classList.contains('px-count')) {
						const rowIndex = parseInt(e.target.dataset.rowIndex);
						const value = parseInt(e.target.value) || 0;
						
						if (value < 1) {
							e.target.style.borderColor = '#f44336';
							e.target.style.backgroundColor = '#ffebee';
						} else {
							e.target.style.borderColor = '#c8e6c9';
							e.target.style.backgroundColor = '#f9fff9';
						}
					}
				});

				// 添加品项次数输入框的失去焦点验证
				document.addEventListener('blur', function(e) {
					if (e.target.classList.contains('px-count')) {
						const rowIndex = parseInt(e.target.dataset.rowIndex);
						const value = parseInt(e.target.value) || 0;
						
						if (value < 1) {
							e.target.value = 1;
							e.target.style.borderColor = '#c8e6c9';
							e.target.style.backgroundColor = '#f9fff9';
							updatePxCount(rowIndex, 1);
							showMessage("次数已自动调整为1", "warning");
						} else {
							// 确保正常值也更新数据
							updatePxCount(rowIndex, value);
						}
					}
				}, true);

				// 添加品项次数输入框的输入限制
				document.addEventListener('input', function(e) {
					if (e.target.classList.contains('px-count')) {
						// 只允许输入数字,移除小数点
						e.target.value = e.target.value.replace(/[^\d]/g, '');
					}
				});
			}

			// 验证数字输入
			function validateNumberInput(input) {
				const value = parseFloat(input.value);

				// 字段名称映射
				const fieldNames = {
					'zdyj': '整单业绩',
					'sfyj': '实付业绩',
					'qk': '欠款'
				};

				const fieldName = fieldNames[input.id] || '该字段';

				if (input.value && (isNaN(value) || value < 0)) {
					input.style.borderColor = '#f44336';
					input.style.backgroundColor = '#ffebee';
					showMessage(`${fieldName}必须为大于等于0的数字`, "error");
					return false;
				} else {
					input.style.borderColor = '#c8e6c9';
					input.style.backgroundColor = '#f9fff9';
					return true;
				}
			}

			// 自动计算欠款
			function calculateQiankuan() {
				const zdyj = parseFloat(document.getElementById('zdyj').value) || 0;
				const sfyj = parseFloat(document.getElementById('sfyj').value) || 0;
				const qk = zdyj - sfyj;
				
				// 设置欠款值
				document.getElementById('qk').value = qk.toFixed(2);
				
				// 验证欠款字段
				validateNumberInput(document.getElementById('qk'));
			}

			// 打开选择弹窗
			async function openSelectModal(inputField) {
				currentSelectField = inputField;
				const fieldId = inputField.id;

				// 显示加载状态
				showModal("加载中...", []);

				try {
					let options = [];

					// 根据字段类型获取不同的选项数据
					switch (fieldId) {
						case "kdhy":
							options = await getMemberOptions();
							showModal("选择开单会员", options);
							break;
						case "djmd":
							options = await getStoreOptions();
							showModal("选择单据门店", options);
							break;
						case "jsj":
							options = await getJsjOptions();
							showModal("选择金三角", options);
							break;
						case "hgjg":
							options = await getHgjgOptions();
							showModal("选择合作机构", options);
							break;
						case "fkyy":
							options = await getHgjgOptions();
							showModal("选择付款医院", options);
							break;
						case "khly":
							options = await getKhlyOptions();
							showModal("选择客户来源", options);
							break;
						case "lqKdJksyjList":
							options = await getJksOptions();
							showModal("选择健康师", options);
							break;
						case "lqKdKjbsyjList":
							options = await getKjbOptions();
							showModal("选择科技部人员", options);
							break;
						case "lqKdPxmxList":
							options = await getPxOptions();
							showModal("选择品项", options);
							break;
					}
				} catch (error) {
					console.error("获取选项数据失败:", error);
					showModal("加载失败", []);
					// 显示错误提示
					setTimeout(() => {
						showMessage("数据加载失败,请检查网络连接或联系管理员", "error");
					}, 500);
				}
			}

			// 显示弹窗
			function showModal(title, options) {
				currentOptions = options;
				document.getElementById("modalTitle").textContent = title;
				document.getElementById("searchInput").value = "";

				// 如果是加载状态,隐藏搜索框
				const searchInput = document.getElementById("searchInput");
				if (title === "加载中..." || title === "加载失败") {
					searchInput.style.display = "none";
				} else {
					searchInput.style.display = "block";
				}

				// 统一使用单选模式
				renderOptions(options);

				document.getElementById("selectModal").style.display = "flex";
			}

			// 关闭弹窗
			function closeModal() {
				document.getElementById("selectModal").style.display = "none";
				currentSelectField = null;
				currentOptions = [];
				selectedOption = null;
			}

			// 渲染选项列表
			function renderOptions(options) {
				const optionList = document.getElementById("optionList");
				optionList.innerHTML = "";

				if (!options || options.length === 0) {
					const emptyMessage = document.createElement("div");
					emptyMessage.className = "loading-message";
					emptyMessage.innerHTML = "<span class=\"loading-spinner\"></span>暂无数据";
					optionList.appendChild(emptyMessage);
					return;
				}

				options.forEach(option => {
					const optionItem = document.createElement("div");
					optionItem.className = "option-item";
					optionItem.textContent = option.label;
					optionItem.dataset.value = option.value;

					// 存储额外的属性到dataset中
					Object.keys(option).forEach(key => {
						if (key !== "value" && key !== "label") {
							optionItem.dataset[key] = option[key];
						}
					});
					optionItem.addEventListener("click", function() {
						// 移除之前的选中状态
						document.querySelectorAll(".option-item").forEach(item => {
							item.classList.remove("selected");
						});

						// 设置当前选中状态
						this.classList.add("selected");
						selectedOption = {
							value: this.dataset.value,
							label: this.textContent
						};
						// 添加会员特有的属性
						if (this.dataset.sjh) {
							selectedOption.sjh = this.dataset.sjh;
						}
						// 添加会员类型属性
						if (this.dataset.khlx) {
							selectedOption.khlx = this.dataset.khlx;
						}
						// 添加健康师特有的属性
						if (this.dataset.jks) {
							selectedOption.jks = this.dataset.jks;
						}
						if (this.dataset.jksxm) {
							selectedOption.jksxm = this.dataset.jksxm;
						}
						if (this.dataset.jkszh) {
							selectedOption.jkszh = this.dataset.jkszh;
						}

						// 添加科技部人员特有的属性
						if (this.dataset.kjbls) {
							selectedOption.kjbls = this.dataset.kjbls;
						}
						if (this.dataset.kjblsxm) {
							selectedOption.kjblsxm = this.dataset.kjblsxm;
						}
						if (this.dataset.kjblszh) {
							selectedOption.kjblszh = this.dataset.kjblszh;
						}

						// 添加品项特有的属性
						if (this.dataset.px) {
							selectedOption.px = this.dataset.px;
						}
						if (this.dataset.pxmc) {
							selectedOption.pxmc = this.dataset.pxmc;
						}
						if (this.dataset.pxzh) {
							selectedOption.pxzh = this.dataset.pxzh;
						}
						if (this.dataset.qt2) {
							selectedOption.qt2 = this.dataset.qt2;
						}
					});

					optionList.appendChild(optionItem);
				});
			}

			// 处理搜索
			function handleSearch() {
				const searchTerm = document.getElementById("searchInput").value;
				if (!searchTerm) {
					// 如果搜索词为空,显示所有选项
					renderOptions(currentOptions);
					return;
				}

				const filteredOptions = currentOptions.filter(option =>
					option.label && option.label.toLowerCase().includes(searchTerm.toLowerCase())
				);
				renderOptions(filteredOptions);
			}

			// 添加健康师行
			function addJksRow() {
				const container = document.getElementById("jksContainer");
				const rowIndex = jksList.length;

				const rowDiv = document.createElement("div");
				rowDiv.className = "jks-row";
				rowDiv.innerHTML = `
        <div class="jks-select" onclick="selectJks(${rowIndex})" data-row-index="${rowIndex}">
          选择健康师
        </div>
        <input type="number" class="jks-amount" placeholder="业绩金额" min="0" step="0.01" 
               data-row-index="${rowIndex}" oninput="updateJksAmount(${rowIndex}, this.value)">
        <button type="button" class="jks-delete" onclick="deleteJksRow(${rowIndex})">删除</button>
      `;

				container.appendChild(rowDiv);
				jksList.push({
					jks: "",
					jksxm: "",
					jkszh: "",
					jksyj: ""
				});
			}

			// 删除健康师行
			function deleteJksRow(rowIndex) {
				const container = document.getElementById("jksContainer");
				const rows = container.querySelectorAll(".jks-row");

				if (rows.length > 1) {
					rows[rowIndex].remove();
					jksList.splice(rowIndex, 1);

					// 重新渲染所有行,更新索引
					renderJksRows();
				} else {
					showMessage("至少需要保留一个健康师", "warning");
				}
			}

			// 重新渲染健康师行
			function renderJksRows() {
				const container = document.getElementById("jksContainer");
				container.innerHTML = "";

				jksList.forEach((jks, index) => {
					const rowDiv = document.createElement("div");
					rowDiv.className = "jks-row";
					rowDiv.innerHTML = `
          <div class="jks-select" onclick="selectJks(${index})" data-row-index="${index}">
            ${jks.jksxm || "选择健康师"}
          </div>
          <input type="number" class="jks-amount" placeholder="业绩金额" min="0" step="0.01" 
                 value="${jks.jksyj}" data-row-index="${index}" oninput="updateJksAmount(${index}, this.value)">
          <button type="button" class="jks-delete" onclick="deleteJksRow(${index})">删除</button>
        `;
					container.appendChild(rowDiv);
				});
			}

			// 选择健康师
			async function selectJks(rowIndex) {
				currentSelectField = {
					type: 'jks',
					rowIndex: rowIndex
				};

				// 显示加载状态
				showModal("加载中...", []);

				try {
					jksOptions = await getJksOptions();
					showModal("选择健康师", jksOptions);
				} catch (error) {
					console.error("获取健康师列表失败:", error);
					showModal("加载失败", []);
					setTimeout(() => {
						showMessage("数据加载失败,请检查网络连接或联系管理员", "error");
					}, 500);
				}
			}

			// 更新健康师业绩金额
			function updateJksAmount(rowIndex, value) {
				console.log("更新业绩金额:", rowIndex, value);
				if (jksList[rowIndex]) {
					jksList[rowIndex].jksyj = value;
					console.log("更新后的健康师数据:", jksList[rowIndex]);
				}
			}

			// 添加科技部人员行
			function addKjbRow() {
				const container = document.getElementById("kjbContainer");
				const rowIndex = kjbList.length;

				const rowDiv = document.createElement("div");
				rowDiv.className = "kjb-row";
				rowDiv.innerHTML = `
        <div class="kjb-select" onclick="selectKjb(${rowIndex})" data-row-index="${rowIndex}">
          选择科技部
        </div>
        <input type="number" class="kjb-amount" placeholder="业绩金额" min="0" step="0.01" 
               data-row-index="${rowIndex}" oninput="updateKjbAmount(${rowIndex}, this.value)">
        <button type="button" class="kjb-delete" onclick="deleteKjbRow(${rowIndex})">删除</button>
      `;

				container.appendChild(rowDiv);
				kjbList.push({
					kjbls: "",
					kjblsxm: "",
					kjblszh: "",
					kjblsyj: ""
				});
			}

			// 删除科技部人员行
			function deleteKjbRow(rowIndex) {
				const container = document.getElementById("kjbContainer");
				const rows = container.querySelectorAll(".kjb-row");

				if (rows.length > 1) {
					rows[rowIndex].remove();
					kjbList.splice(rowIndex, 1);

					// 重新渲染所有行,更新索引
					renderKjbRows();
				} else {
					showMessage("至少需要保留一个科技部人员", "warning");
				}
			}

			// 重新渲染科技部人员行
			function renderKjbRows() {
				const container = document.getElementById("kjbContainer");
				container.innerHTML = "";

				kjbList.forEach((kjb, index) => {
					const rowDiv = document.createElement("div");
					rowDiv.className = "kjb-row";
					rowDiv.innerHTML = `
          <div class="kjb-select" onclick="selectKjb(${index})" data-row-index="${index}">
            ${kjb.kjblsxm || "选择科技部人员"}
          </div>
          <input type="number" class="kjb-amount" placeholder="业绩金额" min="0" step="0.01" 
                 value="${kjb.kjblsyj}" data-row-index="${index}" oninput="updateKjbAmount(${index}, this.value)">
          <button type="button" class="kjb-delete" onclick="deleteKjbRow(${index})">删除</button>
        `;
					container.appendChild(rowDiv);
				});
			}

			// 选择科技部人员
			async function selectKjb(rowIndex) {
				currentSelectField = {
					type: 'kjb',
					rowIndex: rowIndex
				};

				// 显示加载状态
				showModal("加载中...", []);

				try {
					kjbOptions = await getKjbOptions();
					showModal("选择科技部人员", kjbOptions);
				} catch (error) {
					console.error("获取科技部人员列表失败:", error);
					showModal("加载失败", []);
					setTimeout(() => {
						showMessage("数据加载失败,请检查网络连接或联系管理员", "error");
					}, 500);
				}
			}

			// 更新科技部人员业绩金额
			function updateKjbAmount(rowIndex, value) {
				console.log("更新科技部人员业绩金额:", rowIndex, value);
				if (kjbList[rowIndex]) {
					kjbList[rowIndex].kjblsyj = value;
					console.log("更新后的科技部人员数据:", kjbList[rowIndex]);
				}
			}

			// 添加品项行
			function addPxRow() {
				const container = document.getElementById("pxContainer");
				const rowIndex = pxList.length;

				const rowDiv = document.createElement("div");
				rowDiv.className = "px-row";
				rowDiv.innerHTML = `
		<div class="px-row-first">
			<div class="px-select" onclick="selectPx(${rowIndex})" data-row-index="${rowIndex}">
				选择品项
			</div>
			<input type="number" class="px-amount" placeholder="价格" min="0" step="0.01" 
				   data-row-index="${rowIndex}" oninput="updatePxAmount(${rowIndex}, this.value)">
			<button type="button" class="px-delete" onclick="deletePxRow(${rowIndex})">删除</button>
		</div>
		<div class="px-row-second">
			<input type="number" class="px-count" placeholder="次数" min="1" step="1" 
				   value="1" data-row-index="${rowIndex}" oninput="updatePxCount(${rowIndex}, this.value)">
			<select class="px-type" data-row-index="${rowIndex}" onchange="updatePxType(${rowIndex}, this.value)">
				<option value="购买" selected>购买</option>
				<option value="体验">体验</option>
				<option value="赠送">赠送</option>
			</select>
		</div>
	`;

				container.appendChild(rowDiv);
				pxList.push({
					px: "",
					pxmc: "",
					pxjg: 0,
					projectNumber: 1,
					sourceType: "购买"
				});
			}

			// 删除品项行
			function deletePxRow(rowIndex) {
				const container = document.getElementById("pxContainer");
				const rows = container.querySelectorAll(".px-row");

				if (rows.length > 1) {
					rows[rowIndex].remove();
					pxList.splice(rowIndex, 1);

					// 重新渲染所有行,更新索引
					renderPxRows();
					
					// 重新计算实付业绩
					calculateShifuYej();
					
					// 检查是否需要显示科技部人员
					checkKjbVisibility();
				} else {
					showMessage("至少需要保留一个品项", "warning");
				}
			}

			// 重新渲染品项行
			function renderPxRows() {
				const container = document.getElementById("pxContainer");
				container.innerHTML = "";

				pxList.forEach((px, index) => {
					const rowDiv = document.createElement("div");
					rowDiv.className = "px-row";
					rowDiv.innerHTML = `
						<div class="px-row-first">
							<div class="px-select" onclick="selectPx(${index})" data-row-index="${index}">
								${px.pxmc || "选择品项"}
							</div>
							<input type="number" class="px-amount" placeholder="价格" min="0" step="0.01" 
								   value="${px.pxjg || 0}" data-row-index="${index}" oninput="updatePxAmount(${index}, this.value)">
							<button type="button" class="px-delete" onclick="deletePxRow(${index})">删除</button>
						</div>
						<div class="px-row-second">
							<input type="number" class="px-count" placeholder="次数" min="1" step="1" 
								   value="${Math.max(px.projectNumber || 1, 1)}" data-row-index="${index}" oninput="updatePxCount(${index}, this.value)">
							<select class="px-type" data-row-index="${index}" onchange="updatePxType(${index}, this.value)">
								<option value="购买" ${px.sourceType === '购买' ? 'selected' : ''}>购买</option>
								<option value="体验" ${px.sourceType === '体验' ? 'selected' : ''}>体验</option>
								<option value="赠送" ${px.sourceType === '赠送' ? 'selected' : ''}>赠送</option>
							</select>
						</div>
					`;
					container.appendChild(rowDiv);
				});
			}

			// 选择品项
			async function selectPx(rowIndex) {
				currentSelectField = {
					type: 'px',
					rowIndex: rowIndex
				};

				// 显示加载状态
				showModal("加载中...", []);

				try {
					pxOptions = await getPxOptions();
					showModal("选择品项", pxOptions);
				} catch (error) {
					console.error("获取品项列表失败:", error);
					showModal("加载失败", []);
					setTimeout(() => {
						showMessage("数据加载失败,请检查网络连接或联系管理员", "error");
					}, 500);
				}
			}
			// 更新品项价格
			function updatePxAmount(rowIndex, value) {
				console.log("更新品项价格:", rowIndex, value);
				if (pxList[rowIndex]) {
					pxList[rowIndex].pxjg = parseFloat(value) || 0;
					console.log("更新后的品项数据:", pxList[rowIndex]);
					
					// 重新计算实付业绩
					calculateShifuYej();
					
					// 重新检查科技部显示状态
					checkKjbVisibility();
				}
			}

			// 确认选择
			async function confirmSelection() {
				if (currentSelectField) {
					if (currentSelectField.type === 'jks') {
						console.log('健康师选择:', selectedOption);
						// 处理健康师选择
						if (selectedOption) {
							const rowIndex = currentSelectField.rowIndex;
							jksList[rowIndex] = {
								jks: selectedOption.jks,
								jksxm: selectedOption.jksxm,
								jkszh: selectedOption.jkszh,
								jksyj: jksList[rowIndex].jksyj || ""
							};

							// 更新显示
							const selectElement = document.querySelector(`[data-row-index="${rowIndex}"].jks-select`);
							if (selectElement) {
								selectElement.textContent = selectedOption.jksxm;
							}
							const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/lqycsdjsj/Actions/GetThisMonthJsjInfo?userId=`+selectedOption.value;
							const response = await fetch(apiUrl, {
								method: "GET",
								headers: {
									"Authorization": `${getAuthToken()}`,
									"Content-Type": "application/json"
								}
							});

							if (response.ok) {
								const result = await response.json();
								if (result.code == 200 && result.data) {
									console.log('金三角信息:', result.data);
									jksList[rowIndex].jsj_id = result.data.jsjId
									jksList[rowIndex].jsjName = result.data.jsjName
								}
							}
							closeModal();
						} else {
							showMessage("请先选择一个健康师", "warning");
						}
					} else if (currentSelectField.type === 'kjb') {
						// 处理科技部人员选择
						if (selectedOption) {
							const rowIndex = currentSelectField.rowIndex;
							kjbList[rowIndex] = {
								kjbls: selectedOption.kjbls,
								kjblsxm: selectedOption.kjblsxm,
								kjblszh: selectedOption.kjblszh,
								kjblsyj: kjbList[rowIndex].kjblsyj || ""
							};

							// 更新显示
							const selectElement = document.querySelector(`[data-row-index="${rowIndex}"].kjb-select`);
							if (selectElement) {
								selectElement.textContent = selectedOption.kjblsxm;
							}

							closeModal();
						} else {
							showMessage("请先选择一个科技部人员", "warning");
						}
					} else if (currentSelectField.type === 'px') {
						// 处理品项选择
						if (selectedOption) {
							const rowIndex = currentSelectField.rowIndex;
							pxList[rowIndex] = {
								px: selectedOption.px,
								pxmc: selectedOption.pxmc,
								pxjg: pxList[rowIndex].pxjg || 0,
								projectNumber: pxList[rowIndex].projectNumber || 1,
								sourceType: pxList[rowIndex].sourceType || "购买",
								qt2: selectedOption.qt2 || ""
							};

							// 更新显示
							const selectElement = document.querySelector(`[data-row-index="${rowIndex}"].px-select`);
							if (selectElement) {
								selectElement.textContent = selectedOption.pxmc;
							}

							closeModal();
							
							// 重新计算实付业绩
							calculateShifuYej();
							
							// 检查是否需要显示科技部人员
							checkKjbVisibility();
						} else {
							showMessage("请先选择一个品项", "warning");
						}
					} else {
						// 处理其他字段的单选
						if (selectedOption) {

							currentSelectField.value = selectedOption.label;
							currentSelectField.dataset.selectedValue = selectedOption.value;

							// 设置额外的属性到输入框的dataset中
							Object.keys(selectedOption).forEach(key => {
								if (key !== "value" && key !== "label") {
									currentSelectField.dataset[key] = selectedOption[key];
								}
							});

							// 如果是开单会员字段,自动设置相关字段
							if (currentSelectField.id === 'kdhy') {
								console.log('选中的会员选项:', selectedOption);
								// 设置会员名称和手机号到对应的dataset中
								if (selectedOption.label) {
									currentSelectField.dataset.kdhyc = selectedOption.label;
								}
								if (selectedOption.sjh) {
									currentSelectField.dataset.kdhysjh = selectedOption.sjh;
								}
								if (selectedOption.khlx) {
									currentSelectField.dataset.khlx = selectedOption.khlx;
								}
								console.log('开单会员信息已设置:', {
									label: selectedOption.label,
									sjh: selectedOption.sjh,
									khlx: selectedOption.khlx
								});
							}

							closeModal();
						} else {
							showMessage("请先选择一个选项", "warning");
						}
					}
				}
			}

			// 检查是否需要显示科技部人员
			function checkKjbVisibility() {
				console.log("检查品项列表:", pxList);
				const hasKemei = pxList.some(px => px.qt2 === '科美');
				const kjbGroup = document.querySelector('.form-group:has(.kjb-container)');
				
				console.log("是否包含科美品项:", hasKemei);
				
				if (hasKemei) {
					// 显示科技部人员组
					if (kjbGroup) {
						kjbGroup.style.display = 'block';
					}
					// 如果科技部列表为空,添加一个默认行
					if (kjbList.length === 0) {
						addKjbRow();
					}
				} else {
					// 隐藏科技部人员组
					if (kjbGroup) {
						kjbGroup.style.display = 'none';
					}
					// 清空科技部列表
					kjbList = [];
					document.getElementById("kjbContainer").innerHTML = "";
				}
			}

			// 计算科美品项总额
			function calculateKemeiTotal() {
				return pxList.reduce((sum, px) => {
					if (px.qt2 === '科美') {
						const price = parseFloat(px.pxjg) || 0;
						const count = parseInt(px.projectNumber) || 1;
						return sum + (price * count);
					}
					return sum;
				}, 0);
			}

			// 获取会员选项(从API获取)
			async function getMemberOptions() {
				try {
					const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/LqKhxx?page=1&pageSize=1000`;
					const response = await fetch(apiUrl, {
						method: "GET",
						headers: {
							"Authorization": `${getAuthToken()}`,
							"Content-Type": "application/json"
						}
					});

					if (response.ok) {
						const result = await response.json();
						if (result.code == 200 && result.data) {
							return result.data.list.map(item => ({
								value: item.id,
								label: `${item.khmc}`,
								sjh: item.sjh, // 会员手机号
								khlx: item.khlx || '未知' // 客户来源/类型,默认为会员
							}));
						}
					}

					// 如果API调用失败,返回默认数据
					console.warn("获取会员列表失败,使用默认数据");
					return getDefaultMemberOptions();
				} catch (error) {
					console.error("获取会员列表出错:", error);
					return getDefaultMemberOptions();
				}
			}

			// 获取门店选项(从API获取)
			async function getStoreOptions() {
				try {
					const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/LqMdxx?page=1&pageSize=1000`;
					const response = await fetch(apiUrl, {
						method: "GET",
						headers: {
							"Authorization": `${getAuthToken()}`,
							"Content-Type": "application/json"
						}
					});

					if (response.ok) {
						const result = await response.json();
						if (result.code == 200 && result.data) {
							return result.data.list.map(item => ({
								value: item.id,
								label: item.dm
							}));
						}
					}

					// 如果API调用失败,返回默认数据
					console.warn("获取门店列表失败,使用默认数据");
					return getDefaultStoreOptions();
				} catch (error) {
					console.error("获取门店列表出错:", error);
					return getDefaultStoreOptions();
				}
			}

			// 获取金三角选项(从API获取)
			async function getJsjOptions() {
				try {
					const apiUrl =
						`${APP_CONFIG.getApiBaseUrl()}/api/system/DataInterface/733894897408410885/Actions/Response?n=1757161536`;
					const response = await fetch(apiUrl, {
						method: "GET",
						headers: {
							"Authorization": `${getAuthToken()}`,
							"Content-Type": "application/json"
						}
					});

					if (response.ok) {
						const result = await response.json();
						if (result.code == 200 && result.data) {
							return result.data.map(item => ({
								value: item.id,
								label: item.fullName
							}));
						}
					}

					// 如果API调用失败,返回默认数据
					console.warn("获取金三角列表失败,使用默认数据");
					return getDefaultJsjOptions();
				} catch (error) {
					console.error("获取金三角列表出错:", error);
					return getDefaultJsjOptions();
				}
			}

			// 获取合作机构选项(从API获取)
			async function getHgjgOptions() {
				try {
					const apiUrl =
						`${APP_CONFIG.getApiBaseUrl()}/api/system/DataInterface/733896629660157189/Actions/Response?n=1757162571`;
					const response = await fetch(apiUrl, {
						method: "GET",
						headers: {
							"Authorization": `${getAuthToken()}`,
							"Content-Type": "application/json"
						}
					});

					if (response.ok) {
						const result = await response.json();
						if (result.code == 200 && result.data) {
							return result.data.map(item => ({
								value: item.id,
								label: item.fullName || item.name || item.label
							}));
						}
					}

					// 如果API调用失败,返回默认数据
					console.warn("获取合作机构列表失败,使用默认数据");
					return getDefaultHgjgOptions();
				} catch (error) {
					console.error("获取合作机构列表出错:", error);
					return getDefaultHgjgOptions();
				}
			}

			// 获取客户来源选项(从API获取)
			async function getKhlyOptions() {
				try {
					const apiUrl =
						`${APP_CONFIG.getApiBaseUrl()}/api/system/DataInterface/733896629660157189/Actions/Response?n=1757162571`;
					const response = await fetch(apiUrl, {
						method: "GET",
						headers: {
							"Authorization": `${getAuthToken()}`,
							"Content-Type": "application/json"
						}
					});

					if (response.ok) {
						const result = await response.json();
						if (result.code == 200 && result.data) {
							return result.data.map(item => ({
								value: item.id,
								label: item.fullName || item.name || item.label
							}));
						}
					}

					// 如果API调用失败,返回默认数据
					console.warn("获取客户来源列表失败,使用默认数据");
					return getDefaultKhlyOptions();
				} catch (error) {
					console.error("获取客户来源列表出错:", error);
					return getDefaultKhlyOptions();
				}
			}

			// 获取健康师选项(从API获取)
			async function getJksOptions() {
				try {
					const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/user?page=1&pageSize=1000&mdid=${userInfo.mdid}&gw=健康师`;
					const response = await fetch(apiUrl, {
						method: "GET",
						headers: {
							"Authorization": `${getAuthToken()}`,
							"Content-Type": "application/json"
						}
					});

					if (response.ok) {
						const result = await response.json();
						if (result.code == 200 && result.data) {
							return result.data.list.map(item => ({
								value: item.id,
								label: item.realName || item.name || item.userName,
								jks: item.id,
								jksxm: item.realName || item.name || item.userName,
								jkszh: item.mobilePhone || item.account || item.userName
							}));
						}
					}

					// 如果API调用失败,返回默认数据
					console.warn("获取健康师列表失败,使用默认数据");
					return getDefaultJksOptions();
				} catch (error) {
					console.error("获取健康师列表出错:", error);
					return getDefaultJksOptions();
				}
			}

			// 获取科技部人员选项(从API获取)
			async function getKjbOptions() {
				const response1 = await fetch(`${APP_CONFIG.getApiBaseUrl()}/api/Extend/LqMdxx/${userInfo.mdid}`, {
					method: "GET",
					headers: {
						"Authorization": `${getAuthToken()}`,
						"Content-Type": "application/json"
					}
				});
				console.log(response1);
				let organizeId = "";
				if (response1.ok) {
					const result = await response1.json();
					if (result.code == 200 && result.data) {
						console.log(result.data);
						organizeId = result.data.kjb || "";
					}
				}
				try {
					const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/user?page=1&pageSize=1000&organizeId=${organizeId}&gw=科技老师`;
					const response = await fetch(apiUrl, {
						method: "GET",
						headers: {
							"Authorization": `${getAuthToken()}`,
							"Content-Type": "application/json"
						}
					});

					if (response.ok) {
						const result = await response.json();
						if (result.code == 200 && result.data) {
							return result.data.list.map(item => ({
								value: item.id,
								label: item.realName || item.name || item.userName,
								kjbls: item.id,
								kjblsxm: item.realName || item.name || item.userName,
								kjblszh: item.mobilePhone || item.account || item.userName
							}));
						}
					}

					// 如果API调用失败,返回默认数据
					console.warn("获取科技部人员列表失败,使用默认数据");
					return getDefaultKjbOptions();
				} catch (error) {
					console.error("获取科技部人员列表出错:", error);
					return getDefaultKjbOptions();
				}
			}

			// 获取品项选项(从API获取)
			async function getPxOptions() {
				try {
					const apiUrl =
						`${APP_CONFIG.getApiBaseUrl()}/api/Extend/LqXmzl?page=1&pageSize=1000`;
					const response = await fetch(apiUrl, {
						method: "GET",
						headers: {
							"Authorization": `${getAuthToken()}`,
							"Content-Type": "application/json"
						}
					});

					if (response.ok) {
						const result = await response.json();
						if (result.code == 200 && result.data.list.length>0) {
							return result.data.list.map(item => ({
								value: item.id,
								label: item.xmmc,
								px: item.id,
								pxmc: item.xmmc,
								qt2: item.qt2,
							}));
						}
					}
					// 如果API调用失败,返回默认数据
					console.warn("获取品项列表失败,使用默认数据");
					return getDefaultPxOptions();
				} catch (error) {
					console.error("获取品项列表出错:", error);
					return getDefaultPxOptions();
				}
			}

			// 默认会员选项(API失败时的备用数据)
			function getDefaultMemberOptions() {
				return [{
						value: "MEMBER001",
						label: "张三",
						sjh: "13800138001"
					},
					{
						value: "MEMBER002",
						label: "李四",
						sjh: "13800138002"
					},
					{
						value: "MEMBER003",
						label: "王五",
						sjh: "13800138003"
					},
					{
						value: "MEMBER004",
						label: "赵六",
						sjh: "13800138004"
					}
				];
			}

			// 默认门店选项(API失败时的备用数据)
			function getDefaultStoreOptions() {
				return [{
						value: "MD.101",
						label: "绿纤旗舰店"
					},
					{
						value: "MD.102",
						label: "绿纤体验店"
					},
					{
						value: "MD.103",
						label: "绿纤服务中心"
					},
					{
						value: "MD.104",
						label: "绿纤直营店"
					}
				];
			}

			// 默认金三角选项(API失败时的备用数据)
			function getDefaultJsjOptions() {
				return [{
						value: "JSJ001",
						label: "金三角A区"
					},
					{
						value: "JSJ002",
						label: "金三角B区"
					},
					{
						value: "JSJ003",
						label: "金三角C区"
					},
					{
						value: "JSJ004",
						label: "金三角D区"
					}
				];
			}

			// 默认合作机构选项(API失败时的备用数据)
			function getDefaultHgjgOptions() {
				return [{
						value: "HGJG001",
						label: "绿纤合作机构A"
					},
					{
						value: "HGJG002",
						label: "绿纤合作机构B"
					},
					{
						value: "HGJG003",
						label: "绿纤合作机构C"
					},
					{
						value: "HGJG004",
						label: "绿纤合作机构D"
					}
				];
			}

			// 默认客户来源选项(API失败时的备用数据)
			function getDefaultKhlyOptions() {
				return [{
						value: "KHLX001",
						label: "自然到店"
					},
					{
						value: "KHLX002",
						label: "会员推广"
					},
					{
						value: "KHLX003",
						label: "网络推广"
					}
				];
			}

			// 默认健康师选项(API失败时的备用数据)
			function getDefaultJksOptions() {
				return [{
						value: "JKS001",
						label: "张医生",
						jks: "JKS001",
						jksxm: "张医生",
						jkszh: "zhangys"
					},
					{
						value: "JKS002",
						label: "李医生",
						jks: "JKS002",
						jksxm: "李医生",
						jkszh: "liys"
					},
					{
						value: "JKS003",
						label: "王医生",
						jks: "JKS003",
						jksxm: "王医生",
						jkszh: "wangys"
					},
					{
						value: "JKS004",
						label: "赵医生",
						jks: "JKS004",
						jksxm: "赵医生",
						jkszh: "zhaoys"
					}
				];
			}

			// 默认科技部人员选项(API失败时的备用数据)
			function getDefaultKjbOptions() {
				return [{
						value: "KJB001",
						label: "张工程师",
						kjbls: "KJB001",
						kjblsxm: "张工程师",
						kjblszh: "zhanggcs"
					},
					{
						value: "KJB002",
						label: "李工程师",
						kjbls: "KJB002",
						kjblsxm: "李工程师",
						kjblszh: "ligcs"
					},
					{
						value: "KJB003",
						label: "王工程师",
						kjbls: "KJB003",
						kjblsxm: "王工程师",
						kjblszh: "wanggcs"
					},
					{
						value: "KJB004",
						label: "赵工程师",
						kjbls: "KJB004",
						kjblsxm: "赵工程师",
						kjblszh: "zhaogcs"
					}
				];
			}

			// 默认品项选项(API失败时的备用数据)
			function getDefaultPxOptions() {
				return [{
						value: "PX001",
						label: "品项A"
					},
					{
						value: "PX002",
						label: "品项B"
					},
					{
						value: "PX003",
						label: "品项C"
					},
					{
						value: "PX004",
						label: "品项D"
					}
				];
			}

			// 处理表单提交
			function handleFormSubmit(event) {
				event.preventDefault();
				let jsj = '';
				// 使用 Set 来去重,同时过滤掉空值
				const uniqueNames = [...new Set(
					jksList
						.map(item => item.jsjName)  // 提取 jsjName
						.filter(name => name && name.trim() !== '')  // 过滤掉空值和空字符串
				)];

				// 拼接结果,如果没有有效名称则显示"暂无"
				jsj = uniqueNames.length > 0 ? uniqueNames.join(',') : '暂无';
				console.log('jksList:', jksList,jsj);

				// 1. 验证开单会员
				if (!document.getElementById("kdhy").dataset.selectedValue) {
					showMessage("请选择开单会员", "error");
					return;
				}
				
				
				// // 3. 验证金三角
				// if (!document.getElementById("jsj").dataset.selectedValue) {
				// 	showMessage("请选择金三角", "error");
				// 	return;
				// }

				// 4. 验证整单业绩
				const zdyj = parseFloat(document.getElementById("zdyj").value);
				if (isNaN(zdyj) || zdyj < 0) {
					showMessage("请输入有效的整单业绩(大于等于0)", "error");
					return;
				}

				// 5. 验证实付业绩
				const sfyj = parseFloat(document.getElementById("sfyj").value);
				if (isNaN(sfyj) || sfyj < 0) {
					showMessage("请输入有效的实付业绩(大于等于0)", "error");
					return;
				}

				// 6. 验证欠款
				const qk = parseFloat(document.getElementById("qk").value);
				if (isNaN(qk) || qk < 0) {
					showMessage("请输入有效的欠款(大于等于0)", "error");
					return;
				}

				// 7. 验证品项
				if (pxList.length === 0) {
					showMessage("请至少添加一个品项", "error");
					return;
				}

				// 验证每个品项的信息
				for (let i = 0; i < pxList.length; i++) {
					const px = pxList[i];
					console.log(px);
					if (!px.px || !px.pxmc) {
						showMessage(`第${i + 1}个品项信息不完整,请重新选择`, "error");
						return;
					}
					if (!px.pxjg || parseFloat(px.pxjg) < 0) {
						showMessage(`第${i + 1}个品项的价格必须大于等于0`, "error");
						return;
					}
					if (!px.projectNumber || parseInt(px.projectNumber) < 1) {
						showMessage(`第${i + 1}个品项的次数必须大于等于1`, "error");
						return;
					}
					if (!px.sourceType) {
						showMessage(`第${i + 1}个品项的类型不能为空`, "error");
						return;
					}
				}



				// 9. 验证健康师
				if (jksList.length === 0) {
					showMessage("请至少添加一个健康师", "error");
					return;
				}

				// 验证每个健康师的业绩金额
				for (let i = 0; i < jksList.length; i++) {
					const jks = jksList[i];
					console.log(jks);
					if (!jks.jks || !jks.jksxm || !jks.jkszh) {
						showMessage(`第${i + 1}个健康师信息不完整,请重新选择`, "error");
						return;
					}
					if (!jks.jksyj || parseFloat(jks.jksyj) < 0) {
						showMessage(`第${i + 1}个健康师的业绩金额必须大于等于0`, "error");
						return;
					}
				}

				// 10. 验证科技部人员(根据品项类型决定是否必填)
				const hasKemei = pxList.some(px => px.qt2 === '科美');
				if (hasKemei) {
					if (kjbList.length === 0) {
						showMessage("选择了科美品项,请至少添加一个科技部人员", "error");
						return;
					}

					// 验证每个科技部人员的业绩金额
					for (let i = 0; i < kjbList.length; i++) {
						const kjb = kjbList[i];
						console.log(kjb);
						if (!kjb.kjbls || !kjb.kjblsxm || !kjb.kjblszh) {
							showMessage(`第${i + 1}个科技部人员信息不完整,请重新选择`, "error");
							return;
						}
						if (!kjb.kjblsyj || parseFloat(kjb.kjblsyj) < 0) {
							showMessage(`第${i + 1}个科技部人员的业绩金额必须大于等于0`, "error");
							return;
						}
					}
				}
				// 8. 验证是否储扣
				const sfck = document.getElementById("sfck").value;
				if (!sfck) {
					showMessage("请选择是否储扣", "error");
					return;
				}

				// 11. 验证储扣相关字段(条件显示)
				if (sfck === "是") {
					const ckfsGroup = document.getElementById("ckfsGroup");
					const ckmxGroup = document.getElementById("ckmxGroup");
					
					// 确保字段组是可见的
					if (ckfsGroup.style.display === "none" || ckmxGroup.style.display === "none") {
						showMessage("储扣相关字段未正确显示,请重新选择是否储扣", "error");
						return;
					}
					
					if (!document.getElementById("ckfs").value) {
						showMessage("请选择储扣方式", "error");
						return;
					}

					if (!document.getElementById("ckmx").value.trim()) {
						showMessage("请输入储扣明细", "error");
						return;
					}
				}

				// 12. 验证付款方式
				if (!document.getElementById("fkfs").value) {
					showMessage("请选择付款方式", "error");
					return;
				}

				// 13. 根据付款方式验证对应字段
				const fkfs = document.getElementById("fkfs").value;
				if (fkfs === "合作") {
					if (!document.getElementById("hgjg").dataset.selectedValue) {
						showMessage("请选择合作机构", "error");
						return;
					}
				} else if (fkfs === "医院") {
					if (!document.getElementById("fkyy").dataset.selectedValue) {
						showMessage("请选择付款医院", "error");
						return;
					}
				}

				// 14. 验证是否首开订单
				if (!document.getElementById("sfskdd").value) {
					showMessage("请选择是否首开订单", "error");
					return;
				}

				// 15. 验证科美品项与科技部业绩的匹配
				const kemeiValidation = validateKemeiKjbMatch();
				if (!kemeiValidation.valid) {
					showMessage(kemeiValidation.message, "error");
					return;
				}

				// 16. 验证健康师业绩总和等于实付业绩
				const jksTotal = jksList.reduce((sum, jks) => {
					return sum + (parseFloat(jks.jksyj) || 0);
				}, 0);
				
				if (sfyj > 0 && Math.abs(jksTotal - sfyj) > 0.01) {
					showMessage(`健康师业绩总和(${jksTotal.toFixed(2)})必须等于实付业绩(${sfyj.toFixed(2)})`, "error");
					return;
				}

				// 收集表单数据
				const formData = {
					kdhy: document.getElementById("kdhy").dataset.selectedValue || "",
					djmd: userInfo.mdid || "",
					jsj: jsj || "暂无",
					hgjg: document.getElementById("hgjg").dataset.selectedValue || "",
					kdrq: document.getElementById("kdrq").value || "",
					gjlx: document.getElementById("kdhy").dataset.khlx || "",
					zdyj: parseFloat(document.getElementById("zdyj").value) || 0,
					sfyj: parseFloat(document.getElementById("sfyj").value) || 0,
					qk: parseFloat(document.getElementById("qk").value) || 0,
					sfck: document.getElementById("sfck").value || "",
					ckfs: document.getElementById("ckfs").value || "",
					ckmx: document.getElementById("ckmx").value.trim() || "",
					fkfs: document.getElementById("fkfs").value || "",
					fkyy: document.getElementById("fkyy").dataset.selectedValue || "",
					fkpd: document.getElementById("fkpd").value.trim() || "",
					khly: document.getElementById("khly").value || "",
					tjr: document.getElementById("tjr").value.trim() || "",
					sfskdd: document.getElementById("sfskdd").value || "",
					jj: document.getElementById("jj").value.trim() || "",
					bz: document.getElementById("bz").value.trim() || "",
					lqKdJksyjList: jksList,
					lqKdKjbsyjList: kjbList,
					lqKdPxmxList: pxList.map(px => ({
						px: px.px,
						pxmc: px.pxmc,
						pxjg: parseFloat(px.pxjg) || 0,
						projectNumber: parseInt(px.projectNumber) || 1,
						sourceType: px.sourceType || "购买"
					})),
					scwj: scwjList,

					// 从开单会员字段的dataset中获取会员信息
					kdhyc: document.getElementById("kdhy").dataset.kdhyc || '',
					kdhysjh: document.getElementById("kdhy").dataset.kdhysjh || '',
				};

				console.log("开单数据:", formData);

				// 提交数据到API
				submitOrder(formData);
			}

			// 提交开单数据
			function submitOrder(data) {
				const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/LqKdKdjlb`;

				fetch(apiUrl, {
						method: "POST",
						headers: {
							"Content-Type": "application/json",
							"Authorization": `${getAuthToken()}`
						},
						body: JSON.stringify(data)
					})
					.then(response => response.json())
					.then(result => {
						if (result.code == 200) {
							// 显示成功提示
							showMessage("开单成功!", "success");
							clearForm();
						} else {
							// 显示失败提示
							showMessage(`开单失败:${result.message || "未知错误"}`, "error");
						}
					})
					.catch(error => {
						console.error("提交失败:", error);
						showMessage("网络错误,请检查连接后重试", "error");
					});
			}

			// 清空表单
			function clearForm() {
				document.getElementById("kdhy").value = "";
				document.getElementById("kdhy").dataset.selectedValue = "";
				// document.getElementById("jsj").value = "";
				// document.getElementById("jsj").dataset.selectedValue = "";
				document.getElementById("hgjg").value = "";
				document.getElementById("hgjg").dataset.selectedValue = "";
				document.getElementById("kdrq").value = "";
				document.getElementById("gjlx").value = "";
				document.getElementById("zdyj").value = "";
				document.getElementById("sfyj").value = "";
				document.getElementById("qk").value = "";
				document.getElementById("ckfs").value = "";
				document.getElementById("ckmx").value = "";
				document.getElementById("fkfs").value = "";
				document.getElementById("fkyy").value = "";
				document.getElementById("fkyy").dataset.selectedValue = "";
				document.getElementById("fkpd").value = "";
				document.getElementById("khly").value = "";
				document.getElementById("tjr").value = "";
				document.getElementById("sfskdd").value = "";
				document.getElementById("jj").value = "";
				document.getElementById("bz").value = "";

				// 重置储扣相关字段的显示状态
				document.getElementById("ckfsGroup").style.display = "none";
				document.getElementById("ckmxGroup").style.display = "none";

				// 重置付款方式相关字段的显示状态
				const hgjgGroup = document.querySelector('.form-group:has(#hgjg)');
				const fkyyGroup = document.querySelector('.form-group:has(#fkyy)');
				if (hgjgGroup) {
					hgjgGroup.style.display = "block";
				}
				if (fkyyGroup) {
					fkyyGroup.style.display = "block";
				}
				
				// 清空健康师列表
				jksList = [];
				document.getElementById("jksContainer").innerHTML = "";
				addJksRow();

				// 清空科技部人员列表
				kjbList = [];
				document.getElementById("kjbContainer").innerHTML = "";
				const kjbGroup = document.querySelector('.form-group:has(.kjb-container)');
				if (kjbGroup) {
					kjbGroup.style.display = 'none';
				}

				// 清空品项列表
				pxList = [];
				document.getElementById("pxContainer").innerHTML = "";
				addPxRow();

				// 清空上传文件列表
				scwjList = [];
				document.getElementById("fileList").innerHTML = "";
				document.getElementById("fileInput").value = "";
			}

			// 取消开单
			function cancelOrder() {
				if (confirm("确定要取消开单吗?")) {
					clearForm();
					showMessage("已取消开单", "info");
				}
			}

			// 显示消息提示
			function showMessage(message, type = "info") {
				const toast = document.getElementById("messageToast");
				toast.textContent = message;
				toast.className = `message-toast ${type}`;
				toast.classList.add("show");

				setTimeout(() => {
					toast.classList.remove("show");
				}, 3000);
			}

			// 文件上传方法
			async function uploadFile(file) {
				try {
					// 创建FormData对象
					const formData = new FormData();

					// 添加文件到FormData
					formData.append('file', file);
					// 构建API URL
					const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/file/Uploader/annexpic`;

					// 发送请求
					const response = await fetch(apiUrl, {
						method: 'POST',
						headers: {
							'Authorization': `${getAuthToken()}`
							// 注意:不要设置Content-Type,让浏览器自动设置multipart/form-data
						},
						body: formData
					});

					// 检查响应状态
					if (!response.ok) {
						throw new Error(`HTTP error! status: ${response.status}`);
					}

					// 解析响应
					const result = await response.json();

					// 返回结果
					return {
						success: true,
						data: result,
						message: '文件上传成功'
					};

				} catch (error) {
					console.error('文件上传失败:', error);
					return {
						success: false,
						error: error.message,
						message: '文件上传失败'
					};
				}
			}

			// 上传签名图片的方法
			async function uploadSignature(signCanvas) {
				try {
					// 将canvas转换为blob
					const dataURL = signCanvas.toDataURL('image/png');
					const blob = dataURLToBlob(dataURL);

					// 生成文件名
					const timestamp = new Date().getTime();
					const fileName = `signature_${timestamp}.png`;

					// 创建File对象
					const file = new File([blob], fileName, {
						type: 'image/png'
					});

					// 上传文件
					const result = await uploadFile(file, {
						params: {
							type: 'signature' // 可以添加文件类型标识
						}
					});

					return result;

				} catch (error) {
					console.error('签名上传失败:', error);
					return {
						success: false,
						error: error.message,
						message: '签名上传失败'
					};
				}
			}

			// 初始化文件上传功能
			function initFileUpload() {
				const fileInput = document.getElementById('fileInput');
				const fileUploadArea = document.querySelector('.file-upload-area');
				const fileList = document.getElementById('fileList');

				// 点击上传区域触发文件选择
				fileUploadArea.addEventListener('click', function(e) {
					e.preventDefault();
					e.stopPropagation();
					fileInput.click();
				});

				// 文件选择事件
				fileInput.addEventListener('change', function(e) {
					handleFileSelect(e.target.files);
				});

				// 拖拽事件
				fileUploadArea.addEventListener('dragover', function(e) {
					e.preventDefault();
					fileUploadArea.classList.add('dragover');
				});

				fileUploadArea.addEventListener('dragleave', function(e) {
					e.preventDefault();
					fileUploadArea.classList.remove('dragover');
				});

				fileUploadArea.addEventListener('drop', function(e) {
					e.preventDefault();
					fileUploadArea.classList.remove('dragover');
					handleFileSelect(e.dataTransfer.files);
				});
			}

			// 处理文件选择
			async function handleFileSelect(files) {
				for (let i = 0; i < files.length; i++) {
					const file = files[i];

					// 验证文件类型
					if (!validateFileType(file)) {
						showMessage(`文件 ${file.name} 类型不支持`, "error");
						continue;
					}

					// 验证文件大小 (限制为10MB)
					if (file.size > 10 * 1024 * 1024) {
						showMessage(`文件 ${file.name} 大小超过10MB限制`, "error");
						continue;
					}

					// 上传文件
					await uploadSingleFile(file);
				}
			}

			// 验证文件类型
			function validateFileType(file) {
				const allowedTypes = [
					'image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp',
					'application/pdf',
					'application/msword',
					'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
				];
				return allowedTypes.includes(file.type);
			}

			// 上传单个文件
			async function uploadSingleFile(file) {
				const fileId = `file_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;

				// 添加到文件列表显示
				addFileToList(file, fileId, 'uploading');

				try {
					// 创建FormData
					const formData = new FormData();
					formData.append('file', file);

					// 上传文件
					const response = await fetch(`${APP_CONFIG.getApiBaseUrl()}/api/file/Uploader/annexpic`, {
						method: 'POST',
						headers: {
							'Authorization': `${getAuthToken()}`
						},
						body: formData
					});

					if (response.ok) {
						const result = await response.json();

						// 更新文件状态为成功
						updateFileStatus(fileId, 'success');

						// 添加到scwjList
						scwjList.push({
							name: file.name,
							fileId: result.data.name,
							url: result.data.url
						});

						showMessage(`文件上传成功`, "success");
					} else {
						throw new Error(`上传失败: ${response.status}`);
					}
				} catch (error) {
					console.error('文件上传失败:', error);
					updateFileStatus(fileId, 'error');
					showMessage(`文件 ${file.name} 上传失败`, "error");
				}
			}

			// 添加文件到列表显示
			function addFileToList(file, fileId, status) {
				const fileList = document.getElementById('fileList');
				const fileItem = document.createElement('div');
				fileItem.className = 'file-item';
				fileItem.dataset.fileId = fileId;

				const fileIcon = getFileIcon(file.type);
				const fileSize = formatFileSize(file.size);

				fileItem.innerHTML = `
					<div class="file-info">
						<span class="file-icon">${fileIcon}</span>
						<span class="file-name">${file.name}</span>
						<span class="file-size">${fileSize}</span>
					</div>
					<div class="file-actions">
						${status === 'uploading' ? 
							'<div class="file-status uploading">上传中...</div><div class="upload-progress"><div class="upload-progress-bar"></div></div>' : 
							status === 'success' ? 
							'<div class="file-status success">? 已上传</div><button class="file-remove" onclick="event.stopPropagation(); event.preventDefault(); removeFile(\'${fileId}\')">删除</button>' : 
							'<div class="file-status error">? 上传失败</div>'
						}
					</div>
				`;

				fileList.appendChild(fileItem);

				// 如果是上传中状态,模拟进度条
				if (status === 'uploading') {
					simulateProgress(fileId);
				}
			}

			// 更新文件状态
			function updateFileStatus(fileId, status) {
				const fileItem = document.querySelector(`[data-file-id="${fileId}"]`);
				if (fileItem) {
					const fileActions = fileItem.querySelector('.file-actions');
					if (status === 'success') {
						fileActions.innerHTML =
							'<div class="file-status success">? 已上传</div><button class="file-remove" onclick="event.stopPropagation(); event.preventDefault(); removeFile(\'' +
							fileId + '\')">删除</button>';
					} else if (status === 'error') {
						fileActions.innerHTML = '<div class="file-status error">? 上传失败</div>';
					}
				}
			}

			// 模拟上传进度
			function simulateProgress(fileId) {
				const progressBar = document.querySelector(`[data-file-id="${fileId}"] .upload-progress-bar`);
				if (progressBar) {
					let progress = 0;
					const interval = setInterval(() => {
						progress += Math.random() * 20;
						if (progress >= 100) {
							progress = 100;
							clearInterval(interval);
						}
						progressBar.style.width = progress + '%';
					}, 200);
				}
			}

			// 获取文件图标
			function getFileIcon(fileType) {
				if (fileType.startsWith('image/')) {
					return '?';
				} else if (fileType === 'application/pdf') {
					return '??';
				} else if (fileType.includes('word')) {
					return '??';
				} else {
					return '??';
				}
			}

			// 格式化文件大小
			function formatFileSize(bytes) {
				if (bytes === 0) return '0 Bytes';
				const k = 1024;
				const sizes = ['Bytes', 'KB', 'MB', 'GB'];
				const i = Math.floor(Math.log(bytes) / Math.log(k));
				return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
			}

			// 删除文件
			function removeFile(fileId) {
				// 阻止事件冒泡
				event.stopPropagation();
				event.preventDefault();

				// 从显示列表中移除
				const fileItem = document.querySelector(`[data-file-id="${fileId}"]`);
				if (fileItem) {
					fileItem.remove();
				}

				// 从scwjList中移除
				scwjList = scwjList.filter(file => file.fileId !== fileId);
			}

			// 建档相关功能
			// 打开建档弹窗
			function openMemberCreateModal() {
				document.getElementById('modalMemberCreate').classList.add('active');
				// 重置表单
				document.getElementById('memberCreateForm').reset();
				// 设置默认值(客户类型字段已隐藏,但需要确保值为老客)
				document.getElementById('memberType').value = '老客';
				document.getElementById('memberSource').value = '嘉宾';
				// 显示推荐人字段(因为默认选择嘉宾)
				document.getElementById('referrerGroup').style.display = 'block';
				// 加载推荐人选项
				loadReferrerOptions();
			}

			// 关闭建档弹窗
			function closeMemberCreateModal() {
				document.getElementById('modalMemberCreate').classList.remove('active');
			}

			// 处理客户来源变化
			function handleMemberSourceChange() {
				const memberSource = document.getElementById('memberSource').value;
				const referrerGroup = document.getElementById('referrerGroup');
				
				if (memberSource === '嘉宾') {
					referrerGroup.style.display = 'block';
					// 加载推荐人选项
					loadReferrerOptions();
				} else {
					referrerGroup.style.display = 'none';
					document.getElementById('referrer').value = '';
					document.getElementById('referrer').dataset.selectedValue = '';
				}
			}

			// 加载推荐人选项
			async function loadReferrerOptions() {
				try {
					const referrerOptions = await getMemberOptions();
					// 设置推荐人输入框的点击事件
					const referrerInput = document.getElementById('referrer');
					referrerInput.onclick = function() {
						currentSelectField = referrerInput;
						showModal("选择推荐人", referrerOptions);
					};
				} catch (error) {
					console.error("加载推荐人选项失败:", error);
				}
			}

			// 创建会员
			async function createMember() {
				const memberName = document.getElementById('memberName').value.trim();
				const memberPhone = document.getElementById('memberPhone').value.trim();
				const memberType = document.getElementById('memberType').value;
				const memberSource = document.getElementById('memberSource').value;
				const referrer = document.getElementById('referrer').dataset.selectedValue || '';

				// 验证必填字段
				if (!memberName) {
					showMessage("请输入会员名称", "error");
					return;
				}

				if (!memberPhone) {
					showMessage("请输入手机号", "error");
					return;
				}

				// 验证手机号格式
				const phoneRegex = /^1[3-9]\d{9}$/;
				if (!phoneRegex.test(memberPhone)) {
					showMessage("请输入正确的手机号格式", "error");
					return;
				}

				// 如果是嘉宾,必须选择推荐人
				if (memberSource === '嘉宾' && !referrer) {
					showMessage("选择嘉宾时必须选择推荐人", "error");
					return;
				}

				// 构建提交数据
				const memberData = {
					khmc: memberName,
					sjh: memberPhone,
					khlx: memberType,
					jdqd: memberSource,
					tjr: referrer
				};

				try {
					// 提交到API
					const response = await fetch(`${APP_CONFIG.getApiBaseUrl()}/api/Extend/LqKhxx`, {
						method: 'POST',
						headers: {
							'Content-Type': 'application/json',
							'Authorization': `${getAuthToken()}`
						},
						body: JSON.stringify(memberData)
					});

					const result = await response.json();
					console.log(result);
					if (result.code === 200) {
						showMessage("会员建档成功!", "success");
						closeMemberCreateModal();
						
						// // 刷新会员列表
						// await refreshMemberList();
						
						// 自动选择新创建的会员
						// selectNewMember(memberData);
					} else {
						showMessage(`建档失败:${result.message || "未知错误"}`, "error");
					}
				} catch (error) {
					console.error("建档失败:", error);
					showMessage("网络错误,请检查连接后重试", "error");
				}
			}

			// 刷新会员列表
			async function refreshMemberList() {
				try {
					// 重新获取会员选项
					const memberOptions = await getMemberOptions();
					console.log("会员列表已刷新");
				} catch (error) {
					console.error("刷新会员列表失败:", error);
				}
			}

			// 选择新创建的会员
			function selectNewMember(memberData) {
				// 设置开单会员字段
				const kdhyInput = document.getElementById('kdhy');
				kdhyInput.value = memberData.khmc || memberData.name;
				kdhyInput.dataset.selectedValue = memberData.id;
				kdhyInput.dataset.kdhyc = memberData.khmc || memberData.name;
				kdhyInput.dataset.kdhysjh = memberData.sjh || memberData.phone;
				kdhyInput.dataset.khlx = memberData.khlx || '老客';
			}

			// 更新品项次数
			function updatePxCount(rowIndex, value) {
				console.log("更新品项次数:", rowIndex, value);
				if (pxList[rowIndex]) {
					const countValue = parseInt(value) || 0;
					pxList[rowIndex].projectNumber = countValue;
					console.log("更新后的品项数据:", pxList[rowIndex]);
					
					// 重新计算实付业绩
					calculateShifuYej();
					
					// 重新检查科技部显示状态
					checkKjbVisibility();
				}
			}

			// 更新品项类型
			function updatePxType(rowIndex, value) {
				console.log("更新品项类型:", rowIndex, value);
				if (pxList[rowIndex]) {
					pxList[rowIndex].sourceType = value;
					console.log("更新后的品项数据:", pxList[rowIndex]);
				}
			}

			// 计算实付业绩(品项价格×数量之和)
			function calculateShifuYej() {
				const totalAmount = pxList.reduce((sum, px) => {
					const price = parseFloat(px.pxjg) || 0;
					const count = parseInt(px.projectNumber) || 1;
					return sum + (price * count);
				}, 0);
				
				// 设置实付业绩值
				document.getElementById('sfyj').value = totalAmount.toFixed(2);
				
				// 重新计算欠款
				calculateQiankuan();
				
				console.log('实付业绩已自动计算:', totalAmount);
			}

			// 计算科技部业绩总和
			function calculateKjbTotal() {
				return kjbList.reduce((sum, kjb) => {
					return sum + (parseFloat(kjb.kjblsyj) || 0);
				}, 0);
			}
 
			// 验证科美品项与科技部业绩的匹配
			function validateKemeiKjbMatch() {
				const hasKemei = pxList.some(px => px.qt2 === '科美');
				if (!hasKemei) {
					return { valid: true, message: '' };
				}
				
				const kemeiTotal = calculateKemeiTotal();
				const kjbTotal = calculateKjbTotal();
				
				if (kemeiTotal > 0 && Math.abs(kjbTotal - kemeiTotal) > 0.01) {
					return {
						valid: false,
						message: `科技部业绩总和(${kjbTotal.toFixed(2)})必须等于科美总额(${kemeiTotal.toFixed(2)})`
					};
				}
				
				return { valid: true, message: '' };
			}
		</script>
	</body>
</html>