index.js
150 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
import moment from "moment";
import React, { Component, createRef } from "react";
import reactComponentDebounce from "@/components/Common/ReactDebounce";
import * as commonFunc from "@/components/Common//commonFunc"; /* 通用单据方法 */ /* 通用单据方法 */
// import '@ant-design/compatible/assets/index.css';
import InstructSetSetting from "@/components/Common/InstructSetSetting"
import {
InputNumber,
Checkbox,
DatePicker,
Input,
Cascader,
Select,
AutoComplete,
Spin,
message,
Form,
Upload,
Image,
Button,
Space,
Table,
Pagination,
Tooltip,
Modal,
} from "antd-v4";
import {
DeleteOutlined,
EyeOutlined,
FilePdfOutlined,
FileWordOutlined,
FileExcelOutlined,
FileOutlined,
RightOutlined,
PlaySquareOutlined,
EditOutlined,
} from "@ant-design/icons";
import * as commonUtils from "@/utils/utils";
import styles from "@/index.less";
import Provinces from "@/assets/provinces.json";
import Cities from "@/assets/cities.json";
import Areas from "@/assets/areas.json";
import commonConfig from "@/utils/config";
import { VirtualKeyboard } from "@/oee/common/oeeKeyBoard"; // 虚拟软键盘
import "braft-editor/dist/output.css";
import SvgBox from "../BoxDesignCompontent/svg";
const FormItem = Form.Item;
const { Option } = Select;
const { TextArea } = Input;
const { Search } = Input;
const InputNumberA1 = reactComponentDebounce(300)(InputNumber);
const InputA1 = reactComponentDebounce(300)(Input);
const AutoCompleteA1 = reactComponentDebounce(300)(AutoComplete); /* 处理快速选择产品后离开 产品无法赋值问题s */
const TextAreaA1 = reactComponentDebounce(500)(TextArea);
// const InputNumberA = InputNumber;
// const InputA = Input;
// const AutoCompleteA = AutoComplete;
// const TextAreaA = TextArea;
const { RangePicker, MonthPicker } = DatePicker;
export default class CommonComponent extends Component {
/** 构造函数 */
constructor(props) {
super(props);
this.state = {
dataValue: props.dataValue /* 本showType数据 */,
enabled: props.enabled /* 是否是查看状态(数据格式:布尔) */,
dropDownData: [] /* 下拉数据集(如果不是下拉控件该值为空,数据格式:数组对象) */,
conditonValues: {},
sFieldName: props.showConfig.sName, // 字段名
bNotEmpty: props.showConfig.bNotEmpty,
mode: props.showConfig.bMultipleChoice ? "multiple" : "default",
bNewRecord: props.showConfig.bNewRecord /* 是否有新纪录 */,
sActiveDisplay: true,
pageNum: 0,
totalPageCount: 1,
searchValue: "",
searchDropDownData: [],
searchTotalPageCount: 1,
searchPageNum: 0,
spinState: false,
currentPage: 1,
selectTableData: [],
buttonLoading: false,
key: 0,
selectTableIndex: 0,
};
this.firstDataIndex = props.showConfig.sName.substring(0, 1); /* 控件首字母(数据格式:字符串) */
this.max = props.showConfig.sMaxValue; /* 最大值(数据格式:数字) */
this.min = props.showConfig.sMinValue; /* 最小值(数据格式:数字) */
// 重构修改
this.getFieldDecorator = commonUtils.isUndefined(props.form) ? undefined : props.form.getFieldDecorator; /* 字段验证(数据格式:数字) */
// this.getFieldDecorator = commonUtils.isUndefined(props.form) ? undefined : undefined; /* 字段验证(数据格式:数字) */
this.floatNum = this.props.getFloatNum(props.showConfig.sName); /* 数字格式化规范转换(数据格式:数字) */
this.floatPrice = this.getFloatPrice(this.floatNum); /* 价格格式化规范转换(数据格式:数字) */
this.formItemLayout = commonUtils.isNotEmptyObject(props.formItemLayout)
? props.formItemLayout
: location.pathname.toLowerCase().indexOf("oee") > -1
? { labelCol: { span: 7, style: { color: "rgba(0, 0, 0, 0.65)", backgroundColor: "#BFEFFF" } }, wrapperCol: { span: 15 } }
: {
labelCol: { span: 7, style: { height: "27.82px", color: "rgba(0, 0, 0, 0.65)", backgroundColor: "#BFEFFF" } },
wrapperCol: { span: 15 },
}; /* 表格样式(主要是colspan和rowspan,数据格式:对象) */
this.isDropdownFilter = false;
this.V = { value: props.dataValue };
this.myRef = createRef();
this.dropDownCount = 0;
this.bSpecial = location.pathname?.includes("ResearchTableTree") && props.showConfig.sName === "sProductName";
}
/** 渲染前只执行一次 */
componentWillMount() {
this.mounted = true;
if (this.props.showConfig.sDropDownType === "const") {
/* 常量下拉 */
/* 常量下拉其实只取一次数据就可以啦,去过数据的会给state中的dropDownData赋值,所以dropDownData有值的情况就不需要再获取了 */
const showDropDown = commonUtils.isNotEmptyArr(this.props.showConfig.dropDownData)
? this.props.showConfig.dropDownData
: typeof this.props.showConfig.showDropDown === "object"
? this.props.showConfig.showDropDown
: commonUtils.objectToArr(commonUtils.convertStrToObj(this.props.showConfig.showDropDown));
/* 给state赋值 */
if (this.mounted) {
this.setState({
dropDownData: showDropDown,
});
}
} else if (this.props.showConfig.sDropDownType === "sql" && !commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) {
if (this.mounted) {
this.setState({
dropDownData: this.props.showConfig.dropDownData,
});
}
}
}
componentDidMount() {
const currentNode = this.myRef.current;
const selectInputNode = currentNode.querySelector("input[class*='ant-select-selection-search-input']");
const antInput = currentNode.querySelector("input[class*='ant-input']");
const oInput = selectInputNode || antInput;
if (oInput && !this.props.noDebounce) {
oInput.addEventListener("compositionstart", () => {
this.chineseInputting = true;
});
oInput.addEventListener("compositionend", () => {
this.chineseInputting = false;
if (this.handleCompleteInputEventCache) {
this.handleCompleteInputEventCache();
}
});
}
if (currentNode) {
if (["t", "m", "y"].includes(this.firstDataIndex)) {
const oInput = currentNode.querySelector(`input[id*="${this.props.showConfig.sName}"]`);
if (oInput) {
let { sDateFormat } = this.props.showConfig;
if (commonUtils.isEmptyStr(sDateFormat)) {
if (this.firstDataIndex === "m") {
sDateFormat = "YYYY-MM";
} else if (this.firstDataIndex === "y") {
sDateFormat = "YYYY";
} else {
sDateFormat = this.props.getDateFormat();
}
}
oInput.oninput = e => {
const { value } = e.target;
const isValidDate = moment(value, sDateFormat, true).isValid();
if (isValidDate) {
this.handleSelectOptionEvent(moment(this.state.dataValue), value);
}
};
}
}
}
document.addEventListener("mousedown", this.handleSelectClick);
}
/** props改变的时候触发 */
componentWillReceiveProps(nextProps) {
/* 如果是下拉控件,则要获取数据(获取下拉数据前要先更新sqlCondition) */
const { dataValue, enabled, sFieldName, bNotEmpty, showName, sDropDownType } = this.state;
if (nextProps.showConfig === undefined || this.props.showConfig === undefined) return;
this.firstDataIndex = nextProps.showConfig.sName.substring(0, 1); /* 控件首字母(数据格式:字符串) */
if (nextProps.showConfig.sDropDownType === "const") {
/* 常量下拉 */
/* 常量下拉其实只取一次数据就可以啦,去过数据的会给state中的dropDownData赋值,所以dropDownData有值的情况就不需要再获取了 */
const showDropDown = commonUtils.isNotEmptyArr(nextProps.showConfig.dropDownData)
? nextProps.showConfig.dropDownData
: typeof nextProps.showConfig.showDropDown === "object"
? nextProps.showConfig.showDropDown
: commonUtils.objectToArr(commonUtils.convertStrToObj(nextProps.showConfig.showDropDown));
// 对应工序单独处理
// if (this.props.showConfig.showName === '对应工序') {
// showDropDown = nextProps.customDropData;
// }
/* 给state赋值 */
if (this.mounted) {
this.setState({
dropDownData: showDropDown,
});
}
} else if (nextProps.showConfig.sDropDownType === "sql" && !commonUtils.isEmptyArr(nextProps.showConfig.dropDownData)) {
if (this.mounted) {
this.setState({
dropDownData: nextProps.showConfig.dropDownData,
});
}
}
/* 把需要更新的数据setState */
if (
dataValue !== nextProps.dataValue ||
enabled !== nextProps.enabled ||
bNotEmpty !== nextProps.showConfig.bNotEmpty ||
sFieldName !== nextProps.showConfig.sName ||
showName !== nextProps.showConfig.showName ||
!showName ||
sDropDownType !== nextProps.showConfig.sDropDownType ||
(this.bSpecial && this.props.record.sProductNo !== nextProps.record.sProductNo)
) {
if (this.mounted) {
if (commonUtils.isEmpty(nextProps.dataValue)) {
this.lastValue = nextProps.dataValue;
}
const addState = {
dataValue: nextProps.dataValue,
enabled: nextProps.enabled,
sFieldName: nextProps.showConfig.sName,
sDropDownType: nextProps.showConfig.sDropDownType,
bNotEmpty: nextProps.showConfig.bNotEmpty,
showName: nextProps.showConfig.showName,
};
if (this.bSpecial && this.completeSelectFlag) {
addState.key = this.state.key + 1;
}
this.completeSelectFlag = false;
this.setState(addState);
}
}
}
shouldComponentUpdate(nextProps, nextState) {
const {
dataValue,
enabled,
dropDownData,
searchValue,
searchDropDownData,
sFieldName,
bNotEmpty,
sActiveDisplay,
sDropDownType,
spinState,
showConfig,
} = this.state;
return (
nextProps.showConfig !== undefined &&
(dataValue !== nextState.dataValue ||
enabled !== nextState.enabled ||
sFieldName !== nextState.sFieldName ||
sDropDownType !== nextState.sDropDownType ||
bNotEmpty !== nextState.bNotEmpty ||
JSON.stringify(dropDownData) !== JSON.stringify(nextState.dropDownData) ||
searchValue !== nextState.searchValue ||
JSON.stringify(searchDropDownData) !== JSON.stringify(nextState.searchDropDownData) ||
JSON.stringify(sActiveDisplay) !== JSON.stringify(nextState.sActiveDisplay) ||
nextProps.showTime !== this.props.showTime ||
spinState !== nextState.spinState ||
JSON.stringify(nextState.selectTableData) !== JSON.stringify(this.state.selectTableData) ||
JSON.stringify(nextProps.showConfig) !== JSON.stringify(showConfig))
);
}
componentWillUnmount() {
this.mounted = false;
document.removeEventListener("mousedown", this.handleSelectClick);
}
onFocus = () => {
this.isDropdownFilter = false;
this.setState({ sActiveDisplay: false });
};
onBlur = event => {
if (this.onExecInstructSet("blur")) return;
this.isDropdownFilter = false;
if (commonUtils.isNotEmptyStr(this.props.showConfig.sTableTitleSql) && this.props.showConfig.iVisCount > 1) {
this.setState({
searchPageNum: 1,
searchTotalPageCount: 1,
searchDropDownData: [],
searchValue: "",
spinState: false,
sActiveDisplay: true,
});
} else if (
this.state.searchValue !== "" &&
this.props.showConfig.sDropDownType === "sql" &&
commonUtils.isEmptyArr(this.props.showConfig.dropDownData)
) {
if (!this.props.showConfig.bCanInput) {
this.handleSelectOptionEvent("");
}
this.setState({
searchPageNum: 1,
searchTotalPageCount: 1,
// searchDropDownData: [],
// searchValue: '',
spinState: false,
sActiveDisplay: true,
});
} else {
this.setState({
sActiveDisplay: true,
});
}
/* 若下拉配置了movesql 则离开时 调用下拉sql数据 */
if (
this.props.showConfig &&
(this.props.showConfig.sDropDownType === "movesql" || commonUtils.isNotEmptyObject(this.props.showConfig.sButtonParam))
) {
this.props.onDropDownBlur(this.props.name, this.props.showConfig.sName, this.props.record, this.props.showConfig);
}
this.onCheckFields(500);
this.onBlurText(event, 500);
};
onBlurText = (event, timeout = 0) => {
if (this.onExecInstructSet("blur")) return;
const currentValue = event?.target?.value;
if (currentValue === this.lastValue) return;
setTimeout(() => {
const { name, record, sBtnSendDialogConfigList, onToolBarBtnClick } = this.props;
if (name !== "master") return;
if (commonUtils.isEmptyArr(sBtnSendDialogConfigList)) return;
const { sName } = this.props.showConfig;
if (!record[sName]) return;
const { sActiveKey, sControlName } =
sBtnSendDialogConfigList.find(item => {
const { sActiveKey = "" } = item;
return sActiveKey.split(",").includes(`${name}.${sName}`);
}) || {};
if (sControlName !== "BtnSendDialog") {
if (!sActiveKey) return;
this.lastValue = currentValue;
onToolBarBtnClick({ key: sControlName });
}
}, timeout);
};
onExecInstructSet = type => {
const { sInstruct: sInstructStr, showName, sOnChangeInstruct } = this.props.showConfig;
const sInstruct = commonUtils.convertStrToObj(sInstructStr, {});
let { [type]: instructType } = sInstruct;
if (type === "change") {
const onChangeNew = commonUtils.convertStrToObj(sOnChangeInstruct, {});
instructType = onChangeNew[type];
}
if (instructType) {
if (this.props.onExecInstructSet) {
this.props.onExecInstructSet({
type,
sInstruct: instructType,
showName: `${showName}-${type === "blur" ? "离焦" : "变化"}`,
});
} else {
message.error("未定义调用指令集事件!");
}
return true;
}
return false;
};
onCheckFields = () => {
// 手机号、邮箱校验等校验
// setTimeout(() => {
const sDateFormatTypeList = ["phone", "mobile", "mail", "postcode"];
const { sName, showName, sDateFormat } = this.props.showConfig;
const { record } = this.props;
const IncorrectFormat = commonFunc.showLocalMessage(this.props, "IncorrectFormat", "格式不正确");
const value = record[sName];
if (value !== undefined && value !== "" && sDateFormatTypeList.includes(sDateFormat)) {
let flag = false;
if (sDateFormat === "phone") {
const reg = /^0\d{2,3}-\d{7,8}$/;
const reg1 = /^1[0-9]{10}$/;
const reg2 = /^0\d{2,3}-\d{7,8}-\d{1,8}$/;
if (!reg.test(value) && !reg1.test(value) && !reg2.test(value)) {
flag = true;
}
} else if (sDateFormat === "mobile") {
const reg = /^0\d{2,3}-\d{7,8}$/;
const reg1 = /^1[0-9]{10}$/;
const reg2 = /^0\d{2,3}-\d{7,8}-\d{1,8}$/;
if (!reg.test(value) && !reg1.test(value) && !reg2.test(value)) {
flag = true;
}
} else if (sDateFormat === "mail") {
const reg = /^[a-zA-Z0-9]{1,20}@[a-zA-Z0-9]{1,5}\.[a-zA-Z0-9]{1,5}$/;
if (!reg.test(value)) {
flag = true;
}
} else if (sDateFormat === "postcode") {
const reg = /^[1-9][0-9]{5}$/;
if (!reg.test(value)) {
flag = true;
}
}
if (flag) {
this.props.onChange(
this.props.name,
"verificationFailed",
{ verificationFailed: true, verificationFailedMsg: `【${showName}】【${sName}】${IncorrectFormat}!` },
this.props.sId,
[]
);
message.warning(`【${showName}】【${sName}】${IncorrectFormat}!`);
} else if (record.verificationFailed) {
record.verificationFailed = undefined;
}
}
// }, timeout);
};
/** 下拉时看是否要重新获取数据 */
onDropdownVisibleChange = open => {
const { dropDownData, bNewRecord, pageNum: pageNumOld, totalPageCount: totalPageCountOld, searchValue, conditonValues } = this.state;
if (this.mounted && open) {
const conditonValuesNew = this.props.getSqlCondition(this.props.showConfig, this.props.name, this.props.record);
const pageNum = JSON.stringify(conditonValuesNew) !== JSON.stringify(conditonValues) ? 1 : pageNumOld === 0 ? 1 : pageNumOld;
const totalPageCount = conditonValuesNew !== conditonValues ? 1 : totalPageCountOld;
if (pageNum === 1 && this.props.showConfig.sDropDownType === "sql" && commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) {
this.setState({ spinState: true });
this.getDropDownData(pageNum, totalPageCount, searchValue, this.dropDownCount);
}
} else {
// if (searchValue !== '' && this.props.showConfig.sDropDownType === 'sql' && commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) {
// this.setState({
// searchPageNum: 1, searchTotalPageCount: 1, searchDropDownData: [], searchValue: '', spinState: false,
// });
// }
this.isDropdownFilter = false;
}
if (this.props.onDropdownVisibleChange !== undefined) {
if (dropDownData.length === 0 && !bNewRecord) {
/* 如果没有值并且没有新纪录,则不展开 */
open = false;
}
this.props.onDropdownVisibleChange(open);
}
};
onDoubleClick = () => {
const sMemo = this.props.showConfig.sName;
const title = this.props.showConfig.showName;
const bSParamValue = sMemo === "sParamValue";
if (
(commonUtils.isNotEmptyObject(sMemo) && sMemo.indexOf("Memo") > -1) ||
(bSParamValue && !this.props.record.sDropDownData) ||
(this.props.showConfig.sControlName && this.props.showConfig.sControlName.toLowerCase().indexOf("memo") > -1)
) {
const sCurrMemoProps = {
title,
name: this.props.name,
sValue: this.props.dataValue,
sMemoField: sMemo,
bVisibleMemo: true,
sRecord: this.props.record,
sMemoConfig: this.props.showConfig,
bOnlyShow: !this.props.enabled,
};
if (this.props.bInSlaveMemo) {
this.props.onSaveState({ sCurrMemoProps1: sCurrMemoProps });
} else if (this.props.onSaveState) {
this.props.onSaveState({ sCurrMemoProps });
}
} else if (commonUtils.isNotEmptyObject(sMemo) && sMemo.indexOf("sName") > -1) {
/* 计算方案 变量设置双击弹出 */
this.props.onFieldDoubleClick(this.props.record, this.state.dataValue, this.props.showConfig, this.props.name);
} else if (commonUtils.isNotEmptyObject(sMemo) && sMemo.indexOf("sValue") > -1) {
/* 计算方案 变量设置双击弹出 */
this.props.onFieldDoubleClick(this.props.record, this.state.dataValue, this.props.showConfig, this.props.name);
} else if (commonUtils.isNotEmptyObject(sMemo) && sMemo.indexOf("sAssignField") > -1) {
/* 赋值字段 变量设置双击弹出 */
this.props.onFieldDoubleClick(this.state.dataValue, this.props.showConfig, this.props.name);
} else if (commonUtils.isNotEmptyObject(sMemo) && sMemo.toLowerCase().includes('instruct')) {
/* 赋值字段 变量设置双击弹出 */
// this.props.onFieldDoubleClick(this.state.dataValue, this.props.showConfig, this.props.name);
this.handleEditInstruct();
}
};
onEditorClick = () => {
// if (this.props.enabled) {
//
// }
const curEditorProps = {
title: this.props.showConfig.showName,
name: this.props.name,
value: this.props.dataValue,
sName: this.props.showConfig.sName,
visible: true,
record: this.props.record,
config: this.props.showConfig,
};
this.props.onSaveState({ curEditorProps });
};
onKeyUp = e => {
if (this.props.onKeyUp) {
this.props.onKeyUp(e);
}
};
onKeyDown = e => {
// 如果输入的是字母数字或者中文
if (!this.state.bDropDownOpen && /^[a-zA-Z0-9\u4e00-\u9fa5]+$/.test(e.keyCode)) {
this.setState({ bDropDownOpen: true });
}
if (e.ctrlKey && e.keyCode === 82) {
/* CTRL+ALT+R 代替右击事件 */
this.onContextMenu(e);
} else if (e.key === "F10") {
message.info(this.props.showConfig.sName);
} else if (e.ctrlKey && (e.altKey || e.metaKey) && e.keyCode === 71) {
/* CTRL+ALT+G F7 设置界面 */
const { sType } = this.props?.app?.userinfo || {};
if (!["sysadmin"].includes(sType)) {
return;
}
if (commonUtils.isNotEmptyObject(this.props)) {
const { name, tableConfig, record, configName } = this.props;
if (commonUtils.isNotEmptyObject(tableConfig)) {
const myTableConfig = JSON.parse(JSON.stringify(tableConfig));
myTableConfig.sActiveId = "16411004790004762980820285096000";
myTableConfig.sName = this.props.showConfig.sName;
const myTableConfigArr = [];
myTableConfigArr.push(myTableConfig);
if (this.props.name === "master") {
/* 主表 */
this.props.onViewClick(name, "myTableConfig", record, 0, myTableConfigArr, configName);
} else {
/* 从表 */
this.props.onViewClick(name, "myTableConfig", record, 0, myTableConfigArr, configName);
}
}
}
} else if (this.props.onKeyDown) {
const { showConfig, record, name } = this.props;
this.props.onKeyDown(e, record, showConfig.sName, name);
}
};
/* CommonList列表onkeydown-F10处理 */
onKeyDownDiv = e => {
if (this.props.onKeyDown) {
this.props.onKeyDown(e);
}
if (e.key === "F10") {
message.info(this.props.showConfig.sName);
} else if (e.ctrlKey && e.keyCode === 67) {
console.log("复制成功!");
} else if (e.ctrlKey && e.keyCode === 65) {
console.log("全选成功!");
} else {
e.preventDefault();
return false;
}
};
/* 单击右键全部更新,弹出窗选择后,更新此列所有数据 (只更新非只读字段) */
onContextMenu = e => {
if (
this.state.enabled &&
commonUtils.isNotEmptyObject(this.props) &&
this.props.name !== "master" &&
commonUtils.isNotEmptyObject(this.props.showConfig)
) {
const { showConfig, name } = this.props;
const { bReadonly } = showConfig;
if (bReadonly) {
return;
}
e.preventDefault(); /* 阻止浏览器本身的右击事件 */
if (this.props.onContextMenu) {
const { showConfig, record } = this.props;
this.props.onContextMenu(e, record, showConfig, name);
}
}
};
/* 字段选择弹窗 */
onFieldPopupModal = (showConfig, name, open) => {
if (open !== undefined) {
this.props.onFieldPopupModal(showConfig, name);
}
};
/** 获取selectprops对象 */
getSelectProps = () => {
/* 返回值声明 */
const obj = {
id: `${this.props.showConfig.sName}${this.props.record ? this.props.record.sId : commonUtils.createSid()}`,
showSearch: true /* 是否有查找功能 */,
// disabled: !this.state.enabled /* 修改的时候传过来的数据 */
onSelect: () => {
if (this.state.mode !== "multiple") {
this.setState({ bDropDownOpen: false, bNotFirstEnter: true });
}
},
onChange: this.handleSelectOptionEvent /* 选择触发事件 */,
filterOption: this.filterOption /* 搜索时过滤对应的 option 属性 */,
onDropdownVisibleChange: this.onDropdownVisibleChange,
onPopupScroll: this.handlePopupScroll,
onSearch: this.handleSearch,
notFoundContent: this.state.spinState ? <Spin /> : "暂无数据",
// getPopupContainer: this.props.name === 'slave' || this.props.name === 'searchColumnShow' ? this.getPopupContainer : null,/*解决下拉框不随浏览器滚动问题 */
onFocus: this.onFocus,
// onBlur: this.onBlur,
onBlur: e => {
this.setState({ bDropDownOpen: false, bNotFirstEnter: false });
this.onBlur(e);
},
mode: this.state.mode,
onPaste: event => {
if (this.props.showConfig.bMultipleChoice) {
const clipboardText = event.clipboardData.getData("text/plain").trim();
if (clipboardText) {
const { dataValue = "" } = this.state;
let dataValueNew = dataValue;
if (dataValueNew === "") {
dataValueNew += clipboardText;
} else {
dataValueNew += `,${clipboardText}`;
}
this.handleSelectOptionEvent(dataValueNew, []);
document.activeElement.blur();
}
}
},
};
if (this.props.showConfig.sDropDownType === "sql") {
obj.optionLabelProp = "title";
}
if (this.props.readOnly) {
obj.readOnly = "readOnly";
} else {
obj.disabled = !this.state.enabled;
}
obj.placeholder = this.props.showConfig.placeholder;
/* 区分Oee设置字体与其他系统设置字体 */
obj.dropdownStyle =
commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1
? { fontSize: "1.3rem" }
: { fontSize: "12px" };
obj.dropdownClassName =
commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1
? location.pathname.toLowerCase().indexOf("loginoee") > -1
? "loginOeeDropDown"
: "oeeDropDown"
: "";
/* 主表时才赋值value */
if (this.props.bTable) {
if (this.props.showConfig.bMultipleChoice) {
obj.value = !commonUtils.isEmpty(this.state.dataValue) ? this.state.dataValue.split(",") : []; /* 数据值 */
} else {
obj.value = this.state.dataValue; /* 数据值 */
}
obj.className = this.props.costomClassName === undefined ? styles.editSelect : this.props.costomClassName;
}
if (this.props.showConfig.iDropWidth > 0) {
obj.dropdownMatchSelectWidth = false; /* true时 下拉菜单和选择器同宽。默认将设置 min-width,当值小于选择框宽度时会被忽略。 */
obj.dropdownStyle.width = this.props.showConfig.iDropWidth;
}
obj.onInputKeyDown = e => {
const { bDropDownOpen, bNotFirstEnter } = this.state;
if (bDropDownOpen && [38, 40, 13].includes(e.keyCode)) {
// eslint-disable-next-line no-console
} else if (bDropDownOpen && [27].includes(e.keyCode)) {
this.setState({ bDropDownOpen: false });
} else if (e.keyCode === 13 && !bNotFirstEnter) {
this.setState({ bDropDownOpen: true, bNotFirstEnter: true });
} else {
this.onKeyDown(e);
}
};
obj.onKeyUp = this.onKeyUp;
obj.open = this.state.bDropDownOpen !== undefined ? this.state.bDropDownOpen : false;
// obj.onBlur = () => {
// this.setState({ bDropDownOpen: false });
// };
obj.onMouseMove = () => {
this.bInputIn = true;
};
obj.onMouseLeave = () => {
this.bInputIn = false;
};
/* 返回值 */
return obj;
};
getLocalizedString = (jsonStr, language) => {
try {
const data = JSON.parse(jsonStr);
return data[language] || "";
} catch (e) {
console.error("Error parsing JSON:", e);
return "";
}
};
getSelectTableProps = () => {
const { currentPage, tempCurrentPage, searchValue } = this.state;
const pageNum = searchValue === "" ? currentPage : tempCurrentPage;
/* 返回值声明 */
const obj = {
id: `${this.props.showConfig.sName}${this.props.record ? this.props.record.sId : commonUtils.createSid()}`,
dropdownMatchSelectWidth: false,
filterOption: this.filterOption /* 搜索时过滤对应的 option 属性 */,
onDropdownVisibleChange: open => {
this.onDropdownVisibleChange(open);
if (open === false) {
clearTimeout(this.blurtimer);
this.blurtimer = setTimeout(() => {
this.onBlur();
}, 500);
} else {
clearTimeout(this.blurtimer);
this.onFocus();
}
},
onSearch: this.selectTableSearch,
showSearch: true,
// onFocus: this.onFocus,
// onBlur: this.onBlur,
};
if (this.props.showConfig.sDropDownType === "sql") {
obj.optionLabelProp = "title";
}
if (this.props.readOnly) {
obj.readOnly = "readOnly";
} else {
obj.disabled = !this.state.enabled;
}
obj.placeholder = this.props.showConfig.placeholder;
/* 区分Oee设置字体与其他系统设置字体 */
obj.dropdownStyle =
commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1
? { fontSize: "1.3rem" }
: { fontSize: "12px" };
obj.dropdownClassName =
commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1
? location.pathname.toLowerCase().indexOf("loginoee") > -1
? "loginOeeDropDown"
: "oeeDropDown"
: "";
/* 主表时才赋值value */
if (this.props.bTable) {
obj.value =
this.props.showConfig.bMultipleChoice && !commonUtils.isEmpty(this.state.dataValue)
? this.state.dataValue.split(",")
: this.state.dataValue; /* 数据值 */
obj.className = this.props.costomClassName === undefined ? styles.editSelect : this.props.costomClassName;
}
if (this.props.showConfig.iDropWidth > 0) {
obj.dropdownMatchSelectWidth = false; /* true时 下拉菜单和选择器同宽。默认将设置 min-width,当值小于选择框宽度时会被忽略。 */
}
obj.onInputKeyDown = e => {
const { selectTableData = [], selectTableIndex = 0, bDropDownOpen, bNotFirstEnter } = this.state;
const { keyCode } = e;
try {
if (bDropDownOpen) {
const oTBody = this.selectTableRef1.querySelector(".ant-table-body");
const { scrollTop } = oTBody;
const oTr = this.selectTableRef1.querySelector(".selected-record-row");
const trRect = oTr.getBoundingClientRect();
const tbodyRect = oTBody.getBoundingClientRect();
const tbodyTop = tbodyRect.top + window.scrollY;
const tbodyBottom = tbodyRect.bottom + window.scrollY;
const trTop = trRect.top + window.scrollY;
const trBottom = trRect.bottom + window.scrollY;
if (keyCode === 40) {
const selectTableIndexNew = Math.min(selectTableIndex + 1, selectTableData.length - 1);
if (selectTableIndex !== selectTableIndexNew) {
const bInView = trTop + 29 >= tbodyTop && trBottom + 29 <= tbodyBottom;
if (!bInView) {
oTBody.scrollTop = scrollTop + 29;
}
this.setState({
selectTableIndex: selectTableIndexNew,
});
}
} else if (keyCode === 38) {
const selectTableIndexNew = Math.max(selectTableIndex - 1, 0);
if (selectTableIndex !== selectTableIndexNew) {
const bInView = trTop - 29 >= tbodyTop && trBottom - 29 <= tbodyBottom;
if (!bInView) {
oTBody.scrollTop = scrollTop - 29;
}
this.setState({
selectTableIndex: selectTableIndexNew,
});
}
} else if (keyCode === 13) {
e.stopPropagation();
this.setState({ bNotFirstEnter: true });
setTimeout(() => {
oTr.click();
}, 10);
} else {
this.onKeyDown(e);
}
} else if (![37, 38, 39, 40, 13].includes(keyCode)) {
this.setState({ bDropDownOpen: true });
} else if (keyCode === 13 && !bNotFirstEnter) {
this.setState({ bDropDownOpen: true, bNotFirstEnter: true });
} else {
this.onKeyDown(e);
}
} catch (error) {
console.log(error);
}
};
obj.open = this.state.bDropDownOpen !== undefined ? this.state.bDropDownOpen : false;
obj.onBlur = () => {
if (!this.bInPagination) {
this.setState({ bDropDownOpen: false, bNotFirstEnter: false });
}
};
obj.onMouseMove = () => {
this.bInputIn = true;
};
obj.onMouseLeave = () => {
this.bInputIn = false;
};
obj.onKeyUp = this.onKeyUp;
/* eslint-disable */
obj.dropdownRender = menu => (
<>
{/* <div className="select-search">
<Search allowClear onSearch={e => this.selectTableSearch(e)}/>
</div> */}
{menu}
<div
className="select-pagination"
onMouseEnter={() => {
this.bInPagination = true;
}}
onMouseLeave={() => {
this.bInPagination = false;
if (this.selectTableRef) {
this.selectTableRef.focus();
}
}}
>
<Pagination
onChange={e => this.selectTableChange(e)}
showSizeChanger={false}
current={pageNum}
pageSize={20}
size="small"
total={this.state.totalCount}
/>
<Space>
{this.props.showConfig.bFirstEmpty && (
<Button
type="link"
onClick={() => {
document.querySelectorAll(".ant-select-dropdown").forEach(item => {
item.classList.add("ant-select-dropdown-hidden");
const displayBak = item.style.display;
item.style.display = "none";
setTimeout(() => {
item.style.display = displayBak;
}, 200);
});
this.setState({ tempCurrentPage: null });
this.handleSelectOptionEvent("");
}}
>
清空
</Button>
)}
{this.props.showConfig.bNewRecord && (
<Button
type="link"
onClick={() => {
document.querySelectorAll(".ant-select-dropdown").forEach(item => {
item.classList.add("ant-select-dropdown-hidden");
const displayBak = item.style.display;
item.style.display = "none";
setTimeout(() => {
item.style.display = displayBak;
}, 200);
});
this.setState({ tempCurrentPage: null });
this.handleSelectOptionEvent("@#*000@");
}}
>
NEW RECORD
</Button>
)}
</Space>
</div>
</>
);
/* eslint-enable */
/* 返回值 */
return obj;
};
getSelectTableOption = () => {
const { selectTableData, selectTableIndex = 0 } = this.state;
const { showConfig, app } = this.props;
const { userinfo } = app;
let { sTableTitleSql } = showConfig;
/* 根据用户配置语言 设置表格标题 */
if (commonUtils.isJSON(sTableTitleSql) && sTableTitleSql.includes("Chinese")) {
sTableTitleSql = this.getLocalizedString(sTableTitleSql, userinfo.sLanguage);
}
const tempColumnArr = sTableTitleSql.split(",");
let scrollX = 0;
const columns = tempColumnArr.map((item, index) => {
const tempArr = item.split(":");
const [value, title, columnWidth] = tempArr;
let width;
if (!Number.isNaN(Number(columnWidth))) {
// 如果配置了列宽
width = Number(columnWidth);
} else {
// 没有配置列宽,就根据字符数算宽度
// 获取中文字数、非中文字数, 中文12px,其它8px
const titleStr = title;
const totalStringLen = titleStr.length;
const otherStrLen = titleStr.replace(/[^\x00-\xff]/g, "").length; // eslint-disable-line
const chineseStrLen = totalStringLen - otherStrLen;
const defaultWidth = chineseStrLen * 12 + otherStrLen * 8;
const maxStrLen = selectTableData.reduce((res, pre) => {
let tempValue = pre[value] !== undefined ? pre[value] : "";
if (tempValue === "") {
return res;
}
tempValue = typeof tempValue === "string" ? tempValue : JSON.stringify(tempValue);
const totalStringLen = tempValue.length;
const otherStrLen = tempValue.replace(/[^\x00-\xff]/g, "").length; // eslint-disable-line
const chineseStrLen = totalStringLen - otherStrLen;
const tempWidth = chineseStrLen * 12 + otherStrLen * 8;
return Math.max(tempWidth, res);
}, defaultWidth);
width = Math.min(maxStrLen + 8, 300);
}
scrollX += width;
return {
title,
dataIndex: value,
key: value,
width: index !== tempColumnArr.length - 1 ? width : undefined,
render: text => {
return (
<Tooltip placement="topRight" title={text}>
{text}
</Tooltip>
);
},
};
});
return (
<Option key="" className="select-table-option">
<div
style={{ width: scrollX + 8, maxWidth: "calc(100vw - 16px)", minWidth: "100%" }}
ref={ref => {
this.selectTableRef1 = ref;
}}
>
<Table
size="small"
className="select-table"
rowClassName={(_, index) => {
return selectTableIndex === index ? "selected-record-row" : "";
}}
rowKey="sId"
onRow={(record, index) => {
return {
index,
onMouseEnter: () => {
this.setState({
selectTableIndex: index,
});
},
onClick: () => {
this.setState({ tempCurrentPage: null, bDropDownOpen: false, bNotFirstEnter: true });
this.handleSelectOptionEvent(record.sSlaveId || record.sId);
},
};
}}
pagination={false}
scroll={{
y: 256 - 10 - 29 - 32,
x: scrollX,
}}
dataSource={selectTableData}
columns={columns}
/>
</div>
</Option>
);
};
/** 获取complete对象 */
getCompleteProps = () => {
/* 返回值声明 */
const obj = {
id: `${this.props.showConfig.sName}${this.props.record ? this.props.record.sId : commonUtils.createSid()}`,
// disabled: !this.state.enabled /* 修改的时候传过来的数据 */
onChange: this.handleCompleteInputEvent /* 选择触发事件 */,
onSelect: value => {
this.setState({ bDropDownOpen: false, bNotFirstEnter: true });
this.completeSelectFlag = true;
if (value === "") {
if (this.props.showConfig.sDropDownType === "sql") {
this.props.handleSqlDropDownNewRecord(this.props.showConfig, this.props.name);
}
} else if (this.state.dataValue === value) {
this.completeFlag = true;
this.handleCompleteInputEvent(value);
if (this.myRef && this.myRef.current) {
const oInput = this.myRef.current.querySelector(`#${this.props.showConfig.sName}`);
if (oInput) {
setTimeout(() => {
oInput.blur();
}, 1000);
}
}
} else if (this.myRef && this.myRef.current) {
const oInput = this.myRef.current.querySelector(`#${this.props.showConfig.sName}`);
if (oInput) {
oInput.blur();
}
}
},
filterOption: this.filterOption /* 搜索时过滤对应的 option 属性 */,
onDropdownVisibleChange: this.onDropdownVisibleChange,
onPopupScroll: this.handlePopupScroll,
/* 区分Oee设置字体与其他系统设置字体 */
dropdownClassName:
commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1
? location.pathname.toLowerCase().indexOf("loginoee") > -1
? "loginOeeDropDown"
: "oeeDropDown"
: "",
onSearch: this.handleSearch,
notFoundContent: this.state.spinState ? <Spin /> : "暂无数据",
onFocus: this.onFocus,
onBlur: e => {
this.setState({ bDropDownOpen: false, bNotFirstEnter: false });
this.onBlur(e);
},
};
if (this.props.readOnly) {
obj.readOnly = "readOnly";
} else {
obj.disabled = !this.state.enabled;
}
obj.placeholder = this.props.showConfig.placeholder;
/* 区分Oee设置字体与其他系统设置字体 */
obj.dropdownStyle =
commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase().indexOf("oee") > -1
? { fontSize: "1.3rem" }
: { fontSize: "12px" };
/* 主表时才赋值value */
if (this.props.bTable) {
obj.value =
this.props.showConfig.bMultipleChoice && !commonUtils.isEmpty(this.state.dataValue)
? this.state.dataValue.split(",")
: this.state.dataValue; /* 数据值 */
obj.className = this.props.costomClassName === undefined ? styles.editSelect : this.props.costomClassName;
}
if (this.props.showConfig.iDropWidth > 0) {
obj.dropdownMatchSelectWidth = false; /* true时 下拉菜单和选择器同宽。默认将设置 min-width,当值小于选择框宽度时会被忽略。 */
obj.dropdownStyle.width = this.props.showConfig.iDropWidth;
}
if (
typeof commonUtils.convertStrToNumber(this.max) === "number" &&
commonUtils.convertStrToNumber(this.max) !== 0 &&
this.max.indexOf(".d") === -1 &&
this.max.indexOf(".i") === -1
) {
obj.maxLength = this.max; /* 最大长度 */
}
obj.onInputKeyDown = e => {
const { bDropDownOpen, bNotFirstEnter } = this.state;
if (bDropDownOpen && [38, 40, 13].includes(e.keyCode)) {
// eslint-disable-next-line no-console
} else if (e.keyCode === 13 && !bNotFirstEnter) {
this.setState({ bDropDownOpen: true, bNotFirstEnter: true });
} else {
this.onKeyDown(e);
}
};
obj.onKeyUp = this.onKeyUp;
obj.open = this.state.bDropDownOpen !== undefined ? this.state.bDropDownOpen : false;
obj.onMouseMove = () => {
this.bInputIn = true;
};
obj.onMouseLeave = () => {
this.bInputIn = false;
};
/* 返回值 */
return obj;
};
getSearchProps = () => {
let chooseTitle = "选择";
if (commonUtils.isNotEmptyObject(this.props.app) && commonUtils.isNotEmptyObject(this.props.app.commonConst)) {
chooseTitle = commonFunc.showMessage(this.props.app.commonConst, "choose");
}
const obj = {
onKeyDown: this.onKeyDown,
onChange: e => this.handleSelectOptionEvent(e.target.value) /* 数据改变回带到父组件 */,
value: commonUtils.isUndefined(this.state.dataValue) ? chooseTitle : commonUtils.strUndefinedToEmpty(this.state.dataValue) /* 数据值 */,
};
return obj;
};
/** 获取optionValue对象 */
getOptionValues = data => {
/* 返回值声明 */
let res = "";
/* 计数器 */
let count = 1;
/* 遍历每一条数据 */
const iVisCount =
commonUtils.isEmpty(this.props.showConfig.iVisCount) || this.props.showConfig.iVisCount === 0 ? 1 : this.props.showConfig.iVisCount;
if (commonUtils.isNotEmptyStr(this.props.showConfig.sVisColumnName)) {
res = data[this.props.showConfig.sVisColumnName];
} else {
for (const key of Object.keys(data)) {
/* 这里主要是为了实现配置中控制下拉的展现列数 */
if (count <= iVisCount && key !== "sId") {
if (res === "") {
res = data[key];
} else {
res = res.concat("-").concat(data[key]);
}
count += 1;
}
}
}
// 如果res值为''时,下拉会显示value值,为了解决这种情况,返回' '
if (res === "") {
res = " ";
}
/* 返回值 */
return res;
};
// 获取上传组件props
getUploadProps = () => {
const { formId, app, enabled } = this.props;
const { token } = app;
return {
listType: "picture-card",
className: "avatar-uploader",
action: `${commonConfig.file_host}file/upload?sModelsId=${formId}&token=${token}&sUploadType=model`,
disabled: !enabled || false,
onChange: info => {
const { file } = info;
if (file.response && file.response.code === 1) {
const sPicturePath = file.response.dataset.rows[0].savePathStr;
this.props.onChange(this.props.name, this.props.showConfig.sName, { [this.props.showConfig.sName]: sPicturePath }, this.props.sId, []);
} else if (file.response && file.response.code === -1) {
message.error(file.response.msg);
}
},
accept: "image/*",
showUploadList: false,
};
};
// 获取上传组件内容
getUploadContents = () => {
const fileName = commonUtils.isUndefined(this.state.dataValue) ? "" : commonUtils.strUndefinedToEmpty(this.state.dataValue);
const imageUrl = `${commonConfig.file_host}file/download?savePathStr=${fileName}&sModelsId=100&token=${this.props.token}`;
return fileName ? (
<Image
key={fileName}
src={imageUrl}
alt={fileName.split("/").pop()}
style={{
width: "100%",
}}
preview={!this.props.enabled}
/>
) : (
<div>
<div style={{ marginTop: 8 }}>上传</div>
</div>
);
};
// 获取上传图片右上角清空按钮属性
getUploadButtonProps = () => {
const fileName = commonUtils.isUndefined(this.state.dataValue) ? "" : commonUtils.strUndefinedToEmpty(this.state.dataValue);
return {
type: "link",
style: {
position: "absolute",
top: 0,
left: 75,
display: this.props.enabled && fileName ? "" : "none",
},
onClick: () => {
this.props.onChange(this.props.name, this.props.showConfig.sName, { [this.props.showConfig.sName]: "" }, this.props.sId, []);
},
};
};
/** 获取innerinput控件1 */
getInnerInput = innerInputProps => {
const { noDebounce } = this.props;
const InputNumberA = noDebounce ? InputNumber : InputNumberA1;
const InputA = noDebounce ? Input : InputA1;
const AutoCompleteA = noDebounce ? AutoComplete : AutoCompleteA1;
const TextAreaA = noDebounce ? TextArea : TextAreaA1;
const { sTableTitleSql, iVisCount, sName, sDateFormat } = this.props.showConfig;
let chooseTitle = "选择";
if (commonUtils.isNotEmptyObject(this.props.app) && commonUtils.isNotEmptyObject(this.props.app.commonConst)) {
chooseTitle = commonFunc.showMessage(this.props.app.commonConst, "choose");
}
if (commonUtils.isNotEmptyStr(sTableTitleSql) && iVisCount > 1) {
return (
<Select
ref={ref => {
this.selectTableRef = ref;
}}
{...this.getSelectTableProps()}
>
{this.getSelectTableOption()}
</Select>
);
}
if (sName === "sIcon") {
return (
<>
<Upload {...this.getUploadProps()}>{this.getUploadContents()}</Upload>
<Button {...this.getUploadButtonProps()}>X</Button>
</>
);
}
const removeExtension = (filename) => {
const lastDotIndex = filename.lastIndexOf('.');
if (lastDotIndex === -1) {
// 如果字符串中没有点,则返回原字符串
return filename;
}
return filename.substring(0, lastDotIndex);
}
if (sName === "sPackPath" || sName === "sPackDetailPathUpLoad" || sName === "sSvgPath") {
let imageUrls = "";
const uploadProps = {
listType: "picture-card",
className: "avatar-uploader",
action: `${commonConfig.server_host}file/uploadPrice?sLogoName=logo${sName}${this.props.record.sName}`,
disabled: !this.props.enabled,
onChange: info => {
const { fileList } = info;
const file = fileList[fileList.length - 1];
const { status, response } = file;
if (status === "done") {
if (response && response.code === 1) {
const imageUrl = removeExtension(response.dataset.rows[0].savePathStr);
// const imageUrlNew = `${commonConfig.server_host}file/downloadPrice?sLogoName=logo${removeExtension(imageUrl)}${this.props.record.sName
// }&date=${new Date().getTime()}`;
if (sName === "sPackPath") {
this.props.onChange(this.props.name, sName, { sPackPath: imageUrl }, this.props.sId, []);
} else if (sName === "sPackDetailPathUpLoad") {
this.props.onChange(this.props.name, sName, { sPackDetailPathUpLoad: imageUrl }, this.props.sId, []);
} else {
this.props.onChange(this.props.name, sName, { sSvgPath: imageUrl }, this.props.sId, []);
}
imageUrls = imageUrl;
} else if (response && response.code === -1) {
message.error(response.msg);
}
}
},
accept: "image/*",
showUploadList: false,
openFileDialogOnClick: this.props.enabled,
};
const getImageUrl = (sName) => {
const imageUrlNew = `${commonConfig.server_host}file/downloadPrice?sLogoName=${sName}&date=${new Date().getTime()}`;
return imageUrlNew
}
const uploadName = commonFunc.showLocalMessage(this.props, "BtnUpload", "上传");
const imageUrl = sName === "sPackPath" ? (this.props.record.sPackPath ? getImageUrl(this.props.record.sPackPath) : '') : sName === "sPackDetailPathUpLoad" ? (this.props.record.sPackDetailPathUpLoad ? getImageUrl(this.props.record.sPackDetailPathUpLoad) : '') : (this.props.record.sSvgPath ? getImageUrl(this.props.record.sSvgPath) : '');
return (
<div>
<Upload {...uploadProps}>
{imageUrl ? (
<Image
key={imageUrl}
src={imageUrl}
alt="avatar"
style={{ width: '100%' }}
preview={!this.props.enabled}
/>
) : (
<div>
<div style={{ marginTop: 8 }}>{uploadName}</div>
</div>
)}
</Upload>
<Button {...this.getUploadButtonProps()}><DeleteOutlined /></Button>
</div>
);
}
if (sName === "sPackDetailPath") {
const boxList = [];
const tables = [
{ name: "盒型类别", value: this.props.record.sBoxType, type: null },
{ name: "盒身", value: this.props.record.sBoxBody, type: this.props.record.sTypes },
{ name: "盒长", value: this.props.record.dBoxLength, type: null },
{ name: "盒宽", value: this.props.record.dBoxWidth, type: null },
{ name: "盒高", value: this.props.record.dBoxHeight, type: null },
];
const { slaveData = [] } = this.props;
const titleList1 = [
{ name: "上方盒舌", value: "dSFHS" },
{ name: "盒底组件", value: "dHDC" },
{ name: "下方盒舌", value: "dXFHS" },
{ name: "左(上)插位组件", value: "dZSCW" },
{ name: "左贴边位", value: "dZTBW" },
{ name: "左(下)插位组件", value: "dZXCW" },
{ name: "右(上)插位组件", value: "dYSCW" },
{ name: "右贴边位", value: "dYTBW" },
{ name: "右(下)插位组件", value: "dYXCW" },
];
slaveData.forEach(x => {
let key = 0;
if (x.sTypes && x.sTypes.includes('09')) {
if (x.sCode === 'dZTBW' || x.sCode === 'dYTBW') {
key = x.iSLength + x.iCLength
} else {
key = x.iSWidth+ x.iCWidth
}
} else {
key = x.iValue
}
boxList.push({
value: key,
sName: titleList1.find(item => item.value === x.sCode)?.name || "",
isEditable: true,
isSelect: false,
selectValue: null,
selectLabel: "",
selectImage: null,
type: x.sTypes || null,
show: true,
showName: x.sName, // 参数名称
sLength: x.iSLength,
sWidth: x.iSWidth,
sType: x.iSType,
sTypeName: Number(x.iSType) === 0 ? "矩形" : "梯形",
sOffset: x.sSOffset,
sQuantity: x.iSQuantity,
cLength: x.iCLength,
cWidth: x.iCWidth,
cType: x.iCType,
cTypeName: Number(x.iCType) === 0 ? "矩形" : "梯形",
cOffset: x.sCOffset,
cQuantity: x.iCQuantity,
});
});
tables.forEach(x => {
boxList.push({
value: x.value,
sName: x.name,
isEditable: true,
isSelect: false,
selectValue: null,
selectLabel: "",
selectImage: null,
type: x.type || null,
show: true,
showName: x.name, // 参数名称
});
});
const svgProps = {
...this.props,
boxList,
dSvgBoxWidth: 100,
dSvgBoxHeight: 100,
showNew: 1,
};
return (
<div style={{ width: "100px", height: "100px" }}>
<SvgBox {...svgProps} />
</div>
);
}
if (this.props.showConfig.sName && this.props.showConfig.sName.toLowerCase().includes("fullmemo")) {
const row = commonUtils.isNotEmptyNumber(this.props.showConfig.iRowValue) ? this.props.showConfig.iRowValue : 1;
const minHeight = row * 20 + 6 + 4 + 2;
return (
<div
onDoubleClick={this.onEditorClick}
style={{ minHeight }}
className="braft-output-content"
dangerouslySetInnerHTML={{ __html: this.state.dataValue }}
/>
);
}
if ((this.props.showConfig.sDropDownType === "sql" || this.props.showConfig.sDropDownType === "const")
&& this.props.showConfig.sName?.includes('sParam') && this.props.showConfig.showDropDown?.includes('\\n')
) {
const row = commonUtils.isNotEmptyNumber(this.props.showConfig.iRowValue) ? this.props.showConfig.iRowValue : 1;
const minHeight = row * 20 + 6 + 4 + 2;
const correctText = commonUtils.isNotEmptyObject(this.state?.dataValue) ? this.state.dataValue :
commonUtils.isNotEmptyObject(this.props.showConfig?.showDropDown) ? this.props.showConfig?.showDropDown?.replace(/\\n/g, "\n") : '111';
return (
<div><TextAreaA
disabled={!this.state.enabled}
defaultValue={correctText}
onChange={e => this.handleSelectOptionEvent(e)}
style={{ minHeight }}
/></div>
);
} else if (
(this.props.showConfig.sDropDownType === "sql" || this.props.showConfig.sDropDownType === "const") &&
(this.firstDataIndex === "i" || this.firstDataIndex === "d" || this.firstDataIndex === "s")
) {
/* 下拉选择框(数字和文本选择框才会下拉) */
if (this.props.showConfig.bCanInput) {
/* 文本输入下拉框 */
const propsObj = { ...this.getCompleteProps() };
return <AutoCompleteA {...propsObj}>{this.getSelectOption("autoComplete")}</AutoCompleteA>;
} else {
/* 普通下拉框 */
return <Select {...this.getSelectProps()}>{this.getSelectOption()}</Select>;
}
} else if (this.state.enabled && commonUtils.isNotEmptyObject(this.props.showConfig.sName) && this.props.showConfig.sDropDownType === "popup") {
/* 通用弹窗 */
return (
<Search
placeholder={chooseTitle}
defaultValue={chooseTitle}
{...this.getSearchProps()}
onSearch={this.onFieldPopupModal.bind(this, this.props.showConfig, this.props.name)}
/>
);
} else if (this.firstDataIndex === "i" || this.firstDataIndex === "d") {
/* 数字输入框(整形i和浮点型d) */
return innerInputProps.readOnly ? (
<span onKeyDown={this.onKeyDown} suppressContentEditableWarning contentEditable="true">
<InputNumberA {...innerInputProps} />
</span>
) : location.pathname.includes("quotationPackTableTree") && this.props.name === "control" && this.props.showConfig.sName === "dSinglePQty" ? (
<span style={{ position: "relative" }}>
<InputNumberA {...innerInputProps} />
<span onClick={this.handleViewClick} style={{ position: "absolute", right: "2px" }}>
<EyeOutlined />
</span>
</span>
) : (
<InputNumberA {...innerInputProps} style={{ width: "100%" }} />
);
} else if (this.firstDataIndex === "b") {
/* 选择框(布尔类型b) */
return <Checkbox {...innerInputProps}>{this.showName}</Checkbox>;
// return <span onKeyDown={this.onKeyDownDiv} suppressContentEditableWarning contentEditable="true"> <Checkbox {...innerInputProps}>{this.showName}</Checkbox></span>;
} else if (this.firstDataIndex === "m" || sDateFormat === "YYYY-MM" || sDateFormat === "YYYYMM") {
/* 月份选择框(月份类型m) */
return this.props.bTable ? (
<span onKeyDown={this.onKeyDown} suppressContentEditableWarning contentEditable="true">
<MonthPicker {...innerInputProps} />
</span>
) : (
<MonthPicker {...innerInputProps} />
);
} else if (this.firstDataIndex === "t") {
/* 时间选择框(时间类型t) */
if (["tYear"].includes(this.props.showConfig.sName)) {
innerInputProps.picker = "year";
innerInputProps.format = "YYYY";
innerInputProps.allowClear = false;
}
return this.props.bTable ? (
<span onKeyDown={this.onKeyDown} suppressContentEditableWarning contentEditable="true">
<DatePicker {...innerInputProps} />
</span>
) : (
<DatePicker {...innerInputProps} dropdownClassName="datePickerWrapper" />
);
} else if (this.firstDataIndex === "y") {
/* 年份选择框(年份类型y) */
return this.props.bTable ? (
<span onKeyDown={this.onKeyDown} suppressContentEditableWarning contentEditable="true">
<DatePicker {...innerInputProps} />
</span>
) : (
<DatePicker {...innerInputProps} picker="year" />
);
} else if (this.firstDataIndex === "p") {
/* 时间选择框(时间类型t) */
return <RangePicker {...innerInputProps} />;
} else if (this.firstDataIndex === "s") {
/* 文本输入框(文本s) */
if (this.props.textArea) {
/* 大文本输入框 */
return <TextAreaA {...innerInputProps} />;
} else {
/* 普通文本输入框 */
return <InputA {...innerInputProps} />;
}
} else if (this.firstDataIndex === "c") {
/* 地址联动框(联动下拉类型c) */
return <Cascader {...innerInputProps} />;
} else {
/* 文本输入框(默认类型) */
return <InputA {...innerInputProps} />;
}
};
// 获取innerinput控件后面的按钮
getInnerButton = () => {
const props = {
onClick: () => {
const { slaveConfig = { gdsconfigformslave: [] } } = this.props;
const { gdsconfigformslave } = slaveConfig;
const { sName } = this.props.showConfig;
const config = gdsconfigformslave.find(item => item.sControlName === `BtnPopup.${sName}`);
if (config && this.props.onFieldPopupModal) {
this.props.onFieldPopupModal(config, this.props.name, "CommonListSelect");
}
},
};
return (
<Button {...props}>
<span style={{ fontWeight: "bold" }}>...</span>
</Button>
);
};
// 获取innerinput控件后面的按钮(自定义)
getInnerButtonCostom = showConfig => {
const { name, sysEnabled } = this.props;
const { showName } = showConfig;
let disabled = this.props.showConfig?.buttonbReadonly;
if (!disabled) {
disabled = !sysEnabled;
}
const props = {
type: "primary",
disabled,
loading: this.state.buttonLoading,
onClick: () => {
if (this.props.onCostomChange) {
this.props.onCostomChange(name, showConfig);
}
},
};
return <Button {...props}>{showName}</Button>;
};
/** 获取selectOption对象 */
getSelectOption = type => {
/* 返回值声明 */
const options = [];
/* 执行条件 */
const { searchValue, dropDownData, searchDropDownData } = this.state;
const dropDownDataNew = commonUtils.isEmpty(searchValue) ? dropDownData : searchDropDownData;
if (commonUtils.isNotEmptyArr(dropDownDataNew)) {
/* 遍历下拉数据 */
for (const each of dropDownDataNew) {
if (commonUtils.isNotEmptyObject(each)) {
/* 拼接optoin对象 */
let keyValue = !commonUtils.isEmpty(each.sSlaveId) ? each.sSlaveId : each.sId;
if (this.firstDataIndex === "i") {
keyValue = parseInt(keyValue, 0);
} else if (this.firstDataIndex === "d") {
keyValue = parseFloat(keyValue);
}
let res = "";
if (commonUtils.isNotEmptyStr(this.props.showConfig.sVisColumnName)) {
res = each[this.props.showConfig.sVisColumnName];
} else {
res = Object.keys(each).length > 0 ? each[Object.keys(each)[0]] : "";
}
keyValue = commonUtils.isEmpty(keyValue) ? "" : keyValue;
if (type === "autoComplete") {
// 为autoComplete作特殊处理
const option = this.props.showConfig.bCanInput ? (
<Option key={keyValue.toString()} label={res} value={res} title={res}>
{this.getOptionValues(each)}
</Option>
) : (
<Option key={keyValue} value={res} label={res} title={res}>
{this.getOptionValues(each)}
</Option>
);
/* 返回值赋值s */
options.push(option);
} else {
const option = this.props.showConfig.bCanInput ? (
<Option key={keyValue.toString()} label={res} value={keyValue.toString()} title={res}>
{this.getOptionValues(each)}
</Option>
) : (
<Option key={keyValue} value={keyValue} label={res} title={res}>
{this.getOptionValues(each)}
</Option>
);
/* 返回值赋值 */
options.push(option);
}
}
}
}
if (this.state.searchValue === "") {
/* 下拉空处理 */
if (this.props.showConfig.bFirstEmpty) {
// 重构修改 options.unshift(<Option className="dropdown-empty" key=" " value="=+@" />);
if (type === "autoComplete") {
// options.unshift(<Option className="dropdown-empty" key=" " value="=+@" />);/* 解决销售订单-产品名称,五笔输入法输入不支持直接输入中文 */
} else {
options.unshift(<Option className="dropdown-empty" key=" " value="" />);
}
}
/* 下拉新增处理 */
if (this.props.showConfig.bNewRecord) {
// 重构修改 options.unshift(<Option key="@#*000@" value="">NEW RECORD</Option>);
if (type === "autoComplete") {
options.unshift(<Option value="">NEW RECORD</Option>);
} else {
options.unshift(
<Option key="@#*000@" title="">
NEW RECORD
</Option>
);
}
}
}
/* 返回值 */
return options;
};
/* 获取sqlCondition对象 */
getFloatPrice = floatNum => {
/* 返回值声明 */
let floatPrice = "";
/* 返回值赋值 */
if (!commonUtils.isUndefined(floatNum)) {
for (let i = 0; i < floatNum; i += 1) {
floatPrice += "\\d";
}
}
/* 返回值 */
return floatPrice;
};
/** 获取下拉值 */
getDropDownData = async (pageNum, totalPageCount, searchValue, dropDownCount) => {
if (this.chineseInputting) {
return;
}
/** 下拉类型区分
1、判断是否直接传下拉,如果传了就直接用,并存储到store中去
2、没有传看 getStoreDropDownData有没有存储,存储后直接取用
3、 没有存储时直接调用后台SQL语句去下拉 */
if (this.props.showConfig.sDropDownType === "sql") {
/* 数据下拉 */
const { dropDownData: dropDownDataOld, searchDropDownData: searchDropDownDataOld } = this.state;
if (pageNum <= totalPageCount) {
const sqlDropDownData = await this.props.getSqlDropDownData(
this.props.formId,
this.props.name,
this.props.showConfig,
this.props.record,
searchValue,
pageNum
);
if (dropDownCount !== undefined && dropDownCount < this.dropDownCount) {
return;
}
if (this.mounted) {
if (searchValue !== "") {
const dropDownData = [];
if (commonUtils.isNotEmptyArr(sqlDropDownData.dropDownData)) {
if (pageNum !== 1) {
dropDownData.push(...searchDropDownDataOld);
}
dropDownData.push(...sqlDropDownData.dropDownData);
}
this.setState({
searchDropDownData: dropDownData,
conditonValues: sqlDropDownData.conditonValues,
searchTotalPageCount: sqlDropDownData.totalPageCount,
searchPageNum: sqlDropDownData.currentPageNo,
spinState: false,
searchValue,
totalCount: sqlDropDownData.totalCount,
selectTableData: sqlDropDownData.dropDownData,
});
} else {
const dropDownData = [];
if (commonUtils.isNotEmptyArr(sqlDropDownData.dropDownData)) {
if (pageNum !== 1) {
dropDownData.push(...dropDownDataOld);
}
dropDownData.push(...sqlDropDownData.dropDownData);
}
this.setState({
dropDownData,
conditonValues: sqlDropDownData.conditonValues,
totalPageCount: sqlDropDownData.totalPageCount,
pageNum: sqlDropDownData.currentPageNo,
spinState: false,
searchValue: "",
totalCount: sqlDropDownData.totalCount,
selectTableData: sqlDropDownData.dropDownData,
});
}
}
}
}
};
/** 获取innerinput控件参数 */
getInnerInputProps = () => {
/* 主表和从表的innerinputprops对象有区别 */
if (!this.props.bTable) {
/* 主表 */
return this.getInnerInputPropsMaster();
} else {
/* 主从表 */
return this.getInnerInputPropsSlave();
}
};
/** 获取innerinput控件参数(从) */
getInnerInputPropsSlave = () => {
/* 返回值声明 */
let obj = {};
if (this.firstDataIndex === "i" || this.firstDataIndex === "d") {
/* 数字输入框(整形i和浮点型d) */
obj = this.getNumberInnerInputPropsSlave();
} else if (this.firstDataIndex === "b") {
/* 选择框(布尔类型b) */
obj = this.getBooleanInnerInputPropsSlave();
} else if (this.firstDataIndex === "t" || this.firstDataIndex === "p" || this.firstDataIndex === "m" || this.firstDataIndex === "y") {
/* 时间选择框(时间类型t) */
obj = this.getDateInnerInputPropsSlave();
} else if (this.firstDataIndex === "s") {
/* 文本输入框(文本s) */
obj = this.getTextInnerInputPropsSlave();
obj.onDoubleClick = this.onDoubleClick;
} else if (this.firstDataIndex === "c") {
/* 地址联动框(联动下拉类型c) */
obj = this.getAddressInnerInputPropsSlave();
}
obj.onKeyDown = this.onKeyDown;
obj.onFocus = this.onFocus;
obj.onBlur = this.onBlur;
obj.onMouseEnter = this.onFocus;
obj.id = `${this.props.showConfig.sName}${this.props.record ? this.props.record.sId : commonUtils.createSid()}`; /* 所有从表组件添加id */
obj["data-name"] = this.props.showConfig.sName;
obj["data-control-name"] = this.props.showConfig.sControlName;
obj.placeholder = this.props.showConfig.placeholder || "";
/* 返回值 */
return obj;
};
/* 获取地址innerinputprops对象(从) */
getAddressInnerInputPropsSlave = () => {
/* 返回值 */
const obj = {
// disabled: !this.state.enabled, /* 是否可编辑 */
placeholder: "请选择省市区" /* 预期值的提示信息 */,
options: this.getProvinceCityAreaData() /* 数据 */,
changeOnSelect: true /* 对每个选择值进行更改 */,
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
value: commonUtils.isUndefined(this.state.dataValue)
? []
: typeof this.state.dataValue === "string"
? this.state.dataValue.split(",")
: commonUtils.convertUndefinedToEmptyArr(this.state.dataValue) /* 数据值 */,
};
if (this.props.readOnly) {
obj.readOnly = "readOnly";
} else {
obj.disabled = !this.state.enabled;
}
/* 返回值 */
return obj;
};
/* 获取文本innerinputprops对象(从) */
getTextInnerInputPropsSlave = () => {
/* 返回值声明 */
const bShowSuffix =
this.props.showConfig.sName === "sSaveProName" ||
this.props.showConfig.sName === "sDeleteProName" ||
this.props.showConfig.sName === "sSaveProNameBefore" ||
this.props.showConfig.sName === "sProcName" ||
this.props.showConfig.sName === "sButtonParam"; /* 是否展示后缀图标 */
const bShowArrow = this.props.showConfig.sName === "dNeedAuxiliaryQty";
const obj = {
// disabled: !this.state.enabled, /* 是否可编辑 */
id: `${this.props.showConfig.sName}${commonUtils.createSid()}` /* 虚拟数字键盘使用id获取光标 */,
onChange: e => this.handleSelectOptionEvent(e) /* 数据改变回带到父组件 */,
value: commonUtils.isUndefined(this.state.dataValue) ? "" : commonUtils.strUndefinedToEmpty(this.state.dataValue) /* 数据值 */,
// eslint-disable-next-line no-return-assign
ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 */,
onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */,
suffix: bShowSuffix ? (
<span style={{ width: "8px" }} onClick={this.handleOpenWin}>
<EyeOutlined style={{ color: "rgba(0,0,0,.85)" }} />
</span>
) : bShowArrow ? (
<span style={{ width: "8px" }} onClick={this.handleRightArrow}>
<RightOutlined style={{ color: "rgba(0,0,0,.85)" }} />
</span>
) : (
""
),
rows: commonUtils.isNotEmptyNumber(this.props.showConfig.iRowValue) ? this.props.showConfig.iRowValue : 1,
};
if (this.props.showConfig.sName.toLowerCase().includes('instruct') && this.props.enabled) {
obj.suffix = (
<span style={{ width: "8px" }} onClick={this.handleEditInstruct}>
<EditOutlined style={{ color: "rgba(0,0,0,.85)" }} />
</span>
);
}
if (this.props.readOnly) {
obj.readOnly = "readOnly";
} else {
obj.disabled = !this.state.enabled;
}
/* 最大值最小值 */
if (
typeof commonUtils.convertStrToNumber(this.max) === "number" &&
commonUtils.convertStrToNumber(this.max) !== 0 &&
this.max.indexOf(".d") === -1 &&
this.max.indexOf(".i") === -1
) {
obj.maxLength = this.max; /* 最大长度 */
obj.title = obj.value;
}
obj.placeholder = this.props.showConfig.placeholder;
obj.autocomplete = "new-password";
/* 返回值 */
return obj;
};
/* 获取日期innerinputprops对象(从) */
getDateInnerInputPropsSlave = () => {
let { sDateFormat } = this.props.showConfig;
if (commonUtils.isEmptyStr(sDateFormat)) {
if (this.firstDataIndex === "m") {
sDateFormat = "YYYY-MM";
} else if (this.firstDataIndex === "y") {
sDateFormat = "YYYY";
} else {
sDateFormat = this.props.getDateFormat();
}
}
let showtimeFormat = false;
// if (sDateFormat === 'YYYY-MM-DD HH:mm:ss') {
if (sDateFormat.length > 11) {
showtimeFormat = true;
} else {
showtimeFormat = false;
}
/* 返回值声明 */
const obj = {
placeholder: "" /* 时间的提示信息 */,
disabled: !this.state.enabled /* 是否可编辑 */,
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
format: sDateFormat, // this.props.getDateFormat(), /* 格式化规则 */
disabledDate: this.getDataMaxAndMin /* 不可选日期 */,
showTime: showtimeFormat,
style: { width: "100%" } /* 样式 */,
onBlur: () => {
this.onExecInstructSet("blur");
},
};
// if (this.props.readOnly) {
// obj.readOnly = 'readOnly';
// } else {
// obj.disabled = !this.state.enabled;
// }
if (!this.state.enabled) {
obj.suffixIcon = <span />;
}
/* 值填充 */
obj.value = commonUtils.isEmpty(this.state.dataValue) ? null : moment(this.state.dataValue);
/* 返回值 */
return obj;
};
/* 获取布尔innerinputprops对象(从) */
getBooleanInnerInputPropsSlave = () => {
/* 返回值声明 */
const obj = {
disabled: !this.state.enabled /* 是否可编辑 */,
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
checked: commonUtils.isUndefined(this.state.dataValue) ? false : commonUtils.converNumStrToBoolean(this.state.dataValue) /* 是否选中 */,
};
// if (this.props.readOnly) {
// obj.readOnly = true;
// } else {
// obj.disabled = !this.state.enabled;
// }
/* 返回值 */
return obj;
};
/* 获取数字innerinputprops对象(从) */
getNumberInnerInputPropsSlave = () => {
const bShowArrow = this.props.showConfig.sName === "dNeedAuxiliaryQty" && this.props.showConfig.sControlName !== "slaveInfo";
/* 返回值声明 */
const obj = {
id: `${this.props.showConfig.sName}${this.props.showConfig.sId}` /* 虚拟数字键盘使用id获取光标 */,
className: styles.inputNum /* 样式名称 */,
// disabled: !this.state.enabled, /* 是否可编辑 */
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
parser: oldValue => {
const value = this.handleCheckNumberInnerInput(oldValue);
return value;
},
// eslint-disable-next-line no-return-assign
ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 */,
onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */,
};
if (bShowArrow) {
obj.addonAfter = (
<span style={{ width: "5px" }} onClick={this.handleRightArrow}>
<RightOutlined style={{ color: "rgba(0,0,0,.85)" }} />
</span>
);
}
if (this.props.readOnly) {
obj.readOnly = true;
} else {
obj.disabled = !this.state.enabled;
}
/* 最大值最小值 */
if (
typeof commonUtils.convertStrToNumber(this.max) === "number" &&
commonUtils.convertStrToNumber(this.max) !== 0 &&
this.max.indexOf(".d") === -1 &&
this.max.indexOf(".i") === -1
) {
obj.max = this.max; /* 最大值 */
} else if (!commonUtils.isEmpty(this.max) && this.max.indexOf(".") > -1 && commonUtils.isNotEmptyObject(this.props.record)) {
obj.max = this.props.record[this.max.substring(this.max.indexOf(".") + 1)];
}
if (typeof commonUtils.convertStrToNumber(this.min) === "number" && commonUtils.convertStrToNumber(this.min) !== 0) {
obj.min = this.min; /* 最小值 */
}
if (obj.max < 0) {
/* 为解决收付款单据未收款为负数时收款金额不能大于未收款问题,当最大值小于0时,变更为设为最小值 */
obj.min = obj.max;
obj.max = 0;
}
/* 浮点型需要格式化 */
if (this.firstDataIndex === "d") {
// obj.formatter = value => this.toFamatter(value);
// obj.parser = value => this.toFamatter(value);
// obj.precision = this.floatNum;
// obj.formatter = value => this.limitDecimals(value);
// obj.parser = value => this.limitDecimals(value);
}
/* 值填充 */
const { dNetPrice } = this.props.app.decimals;
const { showConfig } = this.props;
const { sName, showName } = showConfig;
const digit = sName.includes("Price") ? dNetPrice : 6;
const numCheck = new RegExp(`^(-?\\d+)(\\.?)(\\d{1,${digit}})?$`);
const numValue = this.state.dataValue;
if (!isNaN(+numValue)) {
if (!numCheck.test(numValue) && numValue) {
message.warning(`【${showName}】【${sName}】最多${digit}位小数`);
}
}
obj.value = this.state.dataValue;
obj.step = 0;
/* 返回值 */
return obj;
};
/** 获取innerinput控件参数(主) */
getInnerInputPropsMaster = () => {
/* 返回值声明 */
let obj = {};
if (this.firstDataIndex === "i" || this.firstDataIndex === "d") {
/* 数字输入框(整形i和浮点型d) */
obj = this.getNumberInnerInputPropsMaster();
} else if (this.firstDataIndex === "b") {
/* 选择框(布尔类型b) */
obj = this.getBooleanInnerInputPropsMaster();
} else if (this.firstDataIndex === "t" || this.firstDataIndex === "p" || this.firstDataIndex === "m" || this.firstDataIndex === "y") {
/* 时间选择框(时间类型t) */
obj = this.getDateInnerInputPropsMaster();
} else if (this.firstDataIndex === "s") {
/* 文本输入框(文本s) */
if (this.props.textArea) {
/* 大文本输入框 */
obj = this.getTextAreaInnerInputPropsMaster();
obj.onDoubleClick = this.onDoubleClick;
} else {
/* 普通文本输入框 */
obj = this.getTextInnerInputPropsMaster();
if (this.props?.showConfig?.sName === "sInstruct") {
obj.onDoubleClick = this.onDoubleClick;
}
}
} else if (this.firstDataIndex === "c") {
/* 地址联动框(联动下拉类型c) */
obj = this.getAddressInnerInputPropsMaster();
}
obj.onKeyDown = this.onKeyDown;
obj.onKeyUp = this.onKeyUp;
obj.onBlur = this.onBlur;
if (this.props.allowClear) {
obj.allowClear = this.props.allowClear; /* 带移除图标 */
}
obj.placeholder = this.props.showConfig.placeholder || "";
// obj.onContextMenu = this.onContextMenu;
/* 返回值 */
return obj;
};
/* 获取地址innerinputprops对象(主) */
getAddressInnerInputPropsMaster = () => {
const obj = {
// disabled: !this.state.enabled, /* 是否可编辑 */
placeholder: "请选择省市区" /* 预期值的提示信息 */,
options: this.getProvinceCityAreaData() /* 数据 */,
changeOnSelect: true /* 对每个选择值进行更改 */,
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
};
if (this.props.readOnly) {
obj.readOnly = "readOnly";
} else {
obj.disabled = !this.state.enabled;
}
return obj;
};
/* 获取文本innerinputprops对象(主) */
getTextInnerInputPropsMaster = () => {
/* 返回值声明 */
const bShowSuffix =
this.props.showConfig.sName === "sButtonParam" ||
this.props.showConfig.sName === "sSqlStr" ||
this.props.showConfig.sName === "sConfigSqlStr" ||
this.props.showConfig.sName === "sProcName"; /* 是否展示后缀图标 */
const obj = {
id: `${this.props.showConfig.sName}${commonUtils.createSid()}` /* 虚拟数字键盘使用id获取光标 */,
// disabled: !this.state.enabled, /* 是否可编辑 */
onChange: e => this.handleSelectOptionEvent(e) /* 数据改变回带到父组件 */,
// eslint-disable-next-line no-return-assign
ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 */,
onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */,
suffix: bShowSuffix ? (
<span onClick={this.handleOpenWin}>
<EyeOutlined style={{ color: "rgba(0,0,0,.85)" }} />
</span>
) : (
""
),
};
if (this.props.showConfig.sName.toLowerCase().includes('instruct') && this.props.enabled) {
obj.suffix = (
<span style={{ width: "8px" }} onClick={this.handleEditInstruct}>
<EditOutlined style={{ color: "rgba(0,0,0,.85)" }} />
</span>
);
}
if (this.props.readOnly) {
obj.readOnly = "readOnly";
} else {
obj.disabled = !this.state.enabled;
}
if (this.props.bPassWord) {
obj.type = "password"; /* 文本密码类型 */
}
/* 最大值最小值 */
// if (this.props.showConfig.sName === 'sZmmGgxh') {
// console.log('sZmmGgxhsZmmGgxh', this.max, (typeof commonUtils.convertStrToNumber(this.max) === 'number' && commonUtils.convertStrToNumber(this.max) !== 0 && this.max.indexOf('.d') === -1 && this.max.indexOf('.i') === -1));
// }
if (
typeof commonUtils.convertStrToNumber(this.max) === "number" &&
commonUtils.convertStrToNumber(this.max) !== 0 &&
this.max.indexOf(".d") === -1 &&
this.max.indexOf(".i") === -1
) {
obj.maxLength = this.max; /* 最大长度 */
}
obj.onBlur = this.onBlurText;
obj.autocomplete = "new-password";
/* 返回值 */
return obj;
};
/* 获取大文本innerinputprops对象(主) */
getTextAreaInnerInputPropsMaster = () => {
/* 返回值声明 */
const obj = {
id: `${this.props.showConfig.sName}${commonUtils.createSid()}` /* 虚拟数字键盘使用id获取光标 */,
// disabled: !this.state.enabled, /* 是否可编辑 */
// rows: 3, /* 纵跨度 */
rows: commonUtils.isNotEmptyNumber(this.props.showConfig.iRowValue) ? this.props.showConfig.iRowValue : 1 /* 产品部要求 备注设置成一行到底 */,
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
// eslint-disable-next-line no-return-assign
ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 */,
onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */,
};
if (this.props.readOnly) {
obj.readOnly = "readOnly";
}
if (commonUtils.isNotEmptyObject(this.props.showConfig.sName) && this.props.showConfig.sName.toLowerCase().endsWith("memo")) {
if (!this.state.enabled) {
/* 非编辑模式下 */
obj.readOnly = true;
obj.style = { backgroundColor: "#f1f2f8" };
} else {
obj.disabled = !this.state.enabled;
}
} else {
obj.disabled = !this.state.enabled;
}
/* 最大值最小值 */
if (
typeof commonUtils.convertStrToNumber(this.max) === "number" &&
commonUtils.convertStrToNumber(this.max) !== 0 &&
this.max.indexOf(".d") === -1 &&
this.max.indexOf(".i") === -1
) {
obj.maxLength = this.max; /* 最大长度 */
}
return obj;
};
/* 获取日期最大值和最小值 */
getDataMaxAndMin = current => {
return this.getDataMax(current) || this.getDataMin(current);
};
/* 获取日期最大值 */
getDataMax = current => {
const showtimeFormat = this.props.showConfig.sDateFormat?.length > 11;
if (commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && this.props.showConfig.sMaxValue.split(".").length > 1) {
const conditionValues = this.props.getSqlCondition({ sSqlCondition: this.props.showConfig.sMaxValue }, "", {});
const sMaxValue = Object.keys(conditionValues).length > 0 ? conditionValues[Object.keys(conditionValues)[0]] : this.props.showConfig.sMaxValue;
const tDate = this.props.showConfig.sMaxValue === "now" ? moment() : moment(sMaxValue);
return showtimeFormat
? commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && current > tDate
: commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && current.endOf("day") > tDate.endOf("day");
} else {
const tDate = this.props.showConfig.sMaxValue === "now" ? moment() : moment(this.props.showConfig.sMaxValue);
return showtimeFormat
? commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && current > tDate
: commonUtils.isNotEmptyStr(this.props.showConfig.sMaxValue) && current.endOf("day") > tDate.endOf("day");
}
};
/* 获取日期最小值 */
getDataMin = current => {
const showtimeFormat = this.props.showConfig.sDateFormat?.length > 11;
if (commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && this.props.showConfig.sMinValue.split(".").length > 1) {
const conditionValues = this.props.getSqlCondition({ sSqlCondition: this.props.showConfig.sMinValue }, "", {});
const sMinValue = Object.keys(conditionValues).length > 0 ? conditionValues[Object.keys(conditionValues)[0]] : this.props.showConfig.sMinValue;
const tDate = this.props.showConfig.sMinValue === "now" ? moment() : moment(sMinValue);
return showtimeFormat
? commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && current < tDate
: commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && current.endOf("day") < tDate.endOf("day");
} else {
const tDate = this.props.showConfig.sMinValue === "now" ? moment() : moment(this.props.showConfig.sMinValue);
return showtimeFormat
? commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && current < tDate
: commonUtils.isNotEmptyStr(this.props.showConfig.sMinValue) && current.endOf("day") < tDate.endOf("day");
}
};
/* 获取时间innerinputprops对象(主) */
getDateInnerInputPropsMaster = () => {
let { sDateFormat } = this.props.showConfig;
if (commonUtils.isEmptyStr(sDateFormat)) {
if (this.firstDataIndex === "m") {
sDateFormat = "YYYY-MM";
} else if (this.firstDataIndex === "y") {
sDateFormat = "YYYY";
} else {
sDateFormat = this.props.getDateFormat();
}
}
let showtimeFormat = false;
// if (sDateFormat === 'YYYY-MM-DD HH:mm:ss') {
if (sDateFormat.length > 11) {
showtimeFormat = true;
} else {
showtimeFormat = false;
}
// 2021-6-5日修改,生产排程日期选择精确到小时
const obj = {
placeholder: "" /* 时间的提示信息 */,
disabled: !this.state.enabled /* 是否可编辑 */,
style: { width: "100%" } /* 样式 */,
// showTime: this.props.showTime ? { format: 'HH:mm', defaultValue: [moment('00:00', 'HH:mm'), moment('00:00', 'HH:mm')] } : '',
// showTime: this.props.showTime,
showTime: showtimeFormat,
format: this.props.showTime ? "YYYY-MM-DD HH:mm:ss" : sDateFormat, // this.props.getDateFormat(), /* 格式化规则 */
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
disabledDate: this.getDataMaxAndMin /* 不可选日期 */,
onBlur: () => {
this.onExecInstructSet("blur");
},
};
// if (this.props.readOnly) {
// obj.readOnly = 'readOnly';
// } else {
// obj.disabled = !this.state.enabled;
// }
return obj;
};
/* 获取布尔innerinputprops对象(主) */
getBooleanInnerInputPropsMaster = () => {
const obj = {
disabled: !this.state.enabled /* 是否显示 */,
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
checked: commonUtils.isUndefined(this.state.dataValue) ? false : commonUtils.converNumStrToBoolean(this.state.dataValue) /* 是否选中 */,
};
// if (this.props.readOnly) {
// obj.readOnly = true;
// } else {
// obj.disabled = !this.state.enabled;
// }
return obj;
};
// eslint-disable-next-line react/sort-comp
handleInputOnClick = id => {
// 判断是否是oee系统,否则不显示虚拟键盘
if (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.indexOf("/indexOee") > -1) {
if (VirtualKeyboard.isKeyBoard()) {
// 关闭上次键盘
VirtualKeyboard.closeKeyboard();
}
const keyboardValue = {};
if (commonUtils.isNotEmptyObject(this.props.dataValue)) {
keyboardValue.value = this.props.dataValue;
} else {
keyboardValue.value = "";
}
VirtualKeyboard.showKeyboardSetState(keyboardValue, this, id);
}
if (this.props.onInputClick) {
// eslint-disable-next-line prefer-destructuring
const sName = this.props.showConfig.sName;
const rowId = this.props.record.sId;
this.props.onInputClick(rowId, sName);
}
};
/* 获取数字innerinputprops对象(主) */
getNumberInnerInputPropsMaster = () => {
/* 如果是浮点型并且有格式规定,display类型需要变为block */
let display = "inline-block";
if (this.firstDataIndex === "d" && this.floatNum !== 0) {
display = "block";
}
// const sInputId = `id${commonUtils.createSid()}`;
/* 返回值赋值 */
const obj = {
id: `${this.props.showConfig.sName}${commonUtils.createSid()}` /* 虚拟数字键盘使用id获取光标 */,
style: { width: "auto", display, marginRight: 0 } /* 样式 */,
// disabled: !this.state.enabled, /* 是否显示 */
onChange: this.handleSelectOptionEvent /* 数据改变回带到父组件 */,
parser: oldValue => {
const value = this.handleCheckNumberInnerInput(oldValue);
return value;
},
// eslint-disable-next-line no-return-assign
ref: ref => (this[this.props.showConfig.sName] = ref) /* 虚拟数字键盘获得光标需用 这里得ref中得变量必须是input得id */,
onClick: this.handleInputOnClick.bind(this, this.props.showConfig.sName) /* 虚拟数字键盘 第二个参数必须id */,
};
if (this.props.readOnly) {
obj.readOnly = true;
} else {
obj.disabled = !this.state.enabled;
}
/* 最大值最小值 */
if (
typeof commonUtils.convertStrToNumber(this.max) === "number" &&
commonUtils.convertStrToNumber(this.max) !== 0 &&
this.max.indexOf(".d") === -1 &&
this.max.indexOf(".i") === -1
) {
obj.max = this.max; /* 最大值 */
} else if (!commonUtils.isEmpty(this.max) && this.max.indexOf(".") > -1 && commonUtils.isNotEmptyObject(this.props.record)) {
obj.max = this.props.record[this.max.substring(this.max.indexOf(".") + 1)];
}
if (typeof commonUtils.convertStrToNumber(this.min) === "number" && commonUtils.convertStrToNumber(this.min) !== 0) {
obj.min = this.min; /* 最小值 */
}
obj.placeholder = this.props.showConfig.placeholder;
/* 格式规格不为0就在props里设置一下 */
// if (this.firstDataIndex === 'd' && this.floatNum !== 0) {
// obj.precision = this.floatNum;
// }
/* 返回值 */
return obj;
};
/* 获取省市区数据 */
getProvinceCityAreaData = () => {
/* 返回值声明 */
const options = [];
/* 获取省数据 */
this.getProvinceData(options);
/* 获取市数据 */
this.getCityData(options);
/* 获取区数据 */
this.getAreaData(options);
/* 返回值 */
return options;
};
/* 获取省数据 */
getProvinceData = options => {
Provinces.forEach(childProvince => {
options.push({
value: childProvince.name /* 文字 */,
label: childProvince.name /* 标签 */,
code: childProvince.code /* 编码 */,
children: [] /* 子节点(city) */,
});
});
};
/* 获取市数据 */
getCityData = options => {
options.forEach(childProvince => {
const cities = Cities.filter(item => item.provinceCode === childProvince.code);
if (cities.length > 0) {
cities.forEach(childCity => {
childProvince.children.push({
value: childCity.name /* 文字 */,
label: childCity.name /* 标签 */,
code: childCity.code /* 编码 */,
children: [] /* 子节点(area) */,
});
});
}
});
};
/* 获取区数据 */
getAreaData = options => {
options.forEach(childProvince => {
const cities = childProvince.children;
cities.forEach(childCity => {
const areas = Areas.filter(item => item.cityCode === childCity.code);
if (areas.length > 0) {
areas.forEach(area => {
childCity.children.push({
value: area.name /* 文字 */,
label: area.name /* 标签 */,
code: area.code /* 编码 */,
});
});
}
});
});
};
/* 获取formitemprops对象 */
getOutFormItemProps = () => {
/* 主表和从表的formitemprops对象有区别 */
if (!this.props.bTable) {
/* 主表 */
return this.getOutFormItemPropsMaster();
} else if (this.props.bViewTable) {
/* 表格单行显示 */
return this.getOutFormItemPropsViewSlave();
} else {
/* 从表 */
return this.getOutFormItemPropsSlave();
}
};
/* 获取formitemprops对象(主) */
getOutFormItemPropsMaster = () => {
/* 返回值声明 */
let obj = {};
if (
this.firstDataIndex === "i" ||
this.firstDataIndex === "d" ||
this.firstDataIndex === "p" ||
this.firstDataIndex === "t" ||
this.firstDataIndex === "m" ||
this.firstDataIndex === "s" ||
this.firstDataIndex === "c"
) {
/* 数字输入框(整形i和浮点型d),
时间选择框(时间类型t),
文本输入框(文本s),
地址联动框(联动下拉类型c) */
obj = {
label: this.props.showConfig.showName /* 标签 */,
className: styles.formItemMargin /* 样式名称 */,
...this.formItemLayout /* 主要是rowspan和colspan */,
};
} else if (this.firstDataIndex === "b") {
/* 选择框(布尔类型b) */
obj = {
label: this.props.showConfig.showName /* 标签 */,
className: styles.formItemMag10 /* 样式名称 */,
...this.formItemLayout /* 主要是rowspan和colspan */,
};
}
if (this.props.itemLabel === "hide") {
delete obj.label;
}
/* 设置标题颜色 */
if (this.props.showConfig.sFontColor) {
// eslint-disable-next-line prefer-destructuring
const sFontColor = this.props.showConfig.sFontColor;
obj.labelCol.style = { color: sFontColor, fontWeight: "bold", backgroundColor: "#BFEFFF" };
}
/* 返回值 */
return obj;
};
/* 获取formitemprops对象(单条从表数据) */
getOutFormItemPropsViewSlave = () => {
/* 返回值声明 */
let obj = {};
if (
this.firstDataIndex === "i" ||
this.firstDataIndex === "d" ||
this.firstDataIndex === "p" ||
this.firstDataIndex === "t" ||
this.firstDataIndex === "m" ||
this.firstDataIndex === "s" ||
this.firstDataIndex === "c"
) {
/* 数字输入框(整形i和浮点型d),
时间选择框(时间类型t),
文本输入框(文本s),
地址联动框(联动下拉类型c) */
obj = {
label: this.props.showConfig.showName /* 标签 */,
className: styles.formItemMargin /* 样式名称 */,
...this.formItemLayout /* 主要是rowspan和colspan */,
};
} else if (this.firstDataIndex === "b") {
/* 选择框(布尔类型b) */
obj = {
label: this.props.showConfig.showName /* 标签 */,
className: styles.formItemMag10 /* 样式名称 */,
...this.formItemLayout /* 主要是rowspan和colspan */,
};
}
if (this.props.itemLabel === "hide") {
delete obj.label;
}
/* 设置标题颜色 */
if (this.props.showConfig.sFontColor) {
// eslint-disable-next-line prefer-destructuring
const sFontColor = this.props.showConfig.sFontColor;
obj.labelCol.style = { color: sFontColor, fontWeight: "bold", backgroundColor: "#BFEFFF" };
}
/* 返回值 */
return obj;
};
/* 获取formitemprops对象(从) */
getOutFormItemPropsSlave = () => {
/* 返回值声明 */
let obj = {};
if (
this.firstDataIndex === "i" ||
this.firstDataIndex === "d" ||
this.firstDataIndex === "c" ||
this.props.showConfig.sDropDownType === "sql" ||
this.props.showConfig.sDropDownType === "const"
) {
/* 数字输入框(整形i和浮点型d),
时间选择框(时间类型t),
文本输入框(文本s),
地址联动框(联动下拉类型c),
所有的下拉(从表只有文字下拉,分常量和sql两种) */
obj = {
className: styles.formItemMargin0 /* 样式名称 */,
};
} else if (this.firstDataIndex === "b") {
/* 选择框(布尔类型b) */
obj = {
className: styles.tableCheckBox /* 样式名称 */,
};
} else if (this.firstDataIndex === "t" || this.firstDataIndex === "p" || this.firstDataIndex === "m" || this.firstDataIndex === "y") {
/* 时间选择框(时间类型t) */
obj = {
className: styles.tableDataPicker /* 样式名称 */,
};
} else if (this.firstDataIndex === "s") {
/* 文本输入框(文本s) */
obj = {
className: styles.editInput /* 样式名称 */,
};
}
/* 返回值 */
return obj;
};
/* 获取fielddecoratorprops对象 */
getFieldDecoratorProps = () => {
/* 返回值声明 */
let obj = {};
if (
this.firstDataIndex === "i" ||
this.firstDataIndex === "d" ||
this.firstDataIndex === "t" ||
this.firstDataIndex === "p" ||
this.firstDataIndex === "s" ||
this.firstDataIndex === "b"
) {
/* 数字输入框(整形i和浮点型d),时间选择框(时间类型t),文本输入框(文本s),选择框(布尔类型b) */
obj = { rules: [{ required: this.props.showConfig.bNotEmpty, message: `${this.props.showConfig.showName}为必填项` }] };
} else if (this.firstDataIndex === "c") {
/* 地址联动框(联动下拉类型c) */
obj = {
initialValue: ["北京市", "市辖区", "东城区"] /* 默认值 */,
rules: [{ required: this.props.showConfig.bNotEmpty, message: `${this.props.showConfig.showName}为必填项` }] /* 规则 */,
};
}
/* 返回值 */
return obj;
};
getPopupContainer = triggerNode => {
const trigger = triggerNode;
if (commonUtils.isNotEmptyObject(trigger)) {
return triggerNode;
}
};
handleCancel = () => {
this.state.previewOpen = false;
};
handleSelectClick = () => {
if (this.bInputIn) {
this.setState({ bDropDownOpen: true });
}
};
// 限制数字位数
handleCheckNumberInnerInput = value => {
const { sDateFormat: sDateFormatOld, sFieldValidation: sFieldValidationOld, sName } = this.props.showConfig;
const { record = {}, app = {} } = this.props;
const { auxiliaryQty = {} } = app;
let sDateFormat = sDateFormatOld;
let sFieldValidation = sFieldValidationOld;
if (sName === "dAuxiliaryQty" && commonUtils.isNotEmptyObject(record.sAuxiliaryUnit)) {
const decimal = auxiliaryQty[record.sAuxiliaryUnit];
if (decimal !== undefined) {
sDateFormat = "decimalPoint";
sFieldValidation = `,${decimal}`;
}
}
if (sDateFormat !== "decimalPoint" || sFieldValidation === undefined || value === null || (typeof value === "string" && !value)) {
return value;
}
const [length1, length2] = sFieldValidation.split(",");
let newValue = value;
if (length2 !== undefined) {
newValue = commonUtils.convertFixNum(value, Number(length2));
}
if (isNaN(newValue) || Object.is(newValue, -0)) {
return value;
}
if (length1 !== undefined && length1 !== "") {
const str = newValue.toString();
const [integerPart, decimalPart] = str.split(".");
if (integerPart.length > length1) {
const truncatedInteger = integerPart.slice(0, length1);
if (decimalPart !== undefined) {
newValue = Number(`${truncatedInteger}.${decimalPart}`);
} else {
newValue = Number(truncatedInteger);
}
}
}
return newValue;
};
selectTableChange = pageNum => {
if (this.selectTableRef) {
this.selectTableRef.focus();
}
if (this.state.searchValue) {
this.setState({ tempCurrentPage: pageNum, selectTableIndex: 0 });
} else {
this.setState({ currentPage: pageNum, selectTableIndex: 0 });
}
this.selectTableRef1.querySelector(".ant-table-body").scrollTop = 0;
this.getDropDownData(pageNum, this.state.totalPageCount, this.state.searchValue);
};
selectTableSearch = searchValue => {
if (this.dropDownTimer) {
clearTimeout(this.dropDownTimer);
}
this.dropDownTimer = setTimeout(() => {
this.setState({
searchValue,
tempCurrentPage: searchValue ? 1 : undefined,
});
const pageNum = searchValue ? 1 : this.state.currentPage;
this.dropDownCount += 1;
this.getDropDownData(pageNum, this.state.totalPageCount, searchValue, this.dropDownCount);
}, 500);
};
toFamatter = values => {
if (values !== 0 && commonUtils.isNotEmptyNumber(values) && values !== null) {
const { sDateFormat } = this.props.showConfig;
const { dNetMoney, dNetPrice } = this.props.app.decimals;
/* 如果配置时间格式中设置了0.0000则以配置为准,没有设置时间格式 则以系统设定为主 */
if (commonUtils.isNotEmptyObject(sDateFormat)) {
/* 取小数点位数 */
let point = 0;
const strIndex = sDateFormat.indexOf(".");
if (strIndex > -1 && sDateFormat.length > 1) {
point = sDateFormat.substring(strIndex + 1, sDateFormat.length).length;
if (commonUtils.isNotEmptyNumber(values) && values !== null) {
const dConfigResult = commonUtils.convertFixNum(Number(values), point).toFixed(point);
if (!isNaN(dConfigResult)) {
values = dConfigResult;
}
}
}
} else if (this.props.showConfig.sName.toLowerCase().endsWith("price")) {
/* 单价格式化显示1 */
if (commonUtils.isNotEmptyNumber(values) && values !== null) {
const dResult = commonUtils.convertFixNum(Number(values), dNetPrice).toFixed(dNetPrice);
if (!isNaN(dResult)) {
values = dResult;
}
}
} else if (this.props.showConfig.sName.toLowerCase().endsWith("money")) {
/* 金额格式化显示 */
if (commonUtils.isNotEmptyNumber(values) && values !== null) {
const dResult = commonUtils.convertFixNum(Number(values), dNetMoney).toFixed(dNetMoney);
if (!isNaN(dResult)) {
values = dResult;
}
}
}
return values;
} else {
return values;
}
};
/** 处理下拉选择事件 */
handleSelectOptionEvent = (newValue, dateString) => {
if (this.chineseInputting) {
return;
}
// if (location.pathname?.includes('productionScheduleTree') && this.props.showConfig.sName && this.props.showConfig.sName.includes('sThird-')) {
// return;
// }
// antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到;
// 做了兼容处理
// if (newValue === undefined || newValue == null) {
// return;
// }
if (newValue === undefined) return;
if (newValue !== null && newValue.target && newValue.target.type !== "checkbox") {
newValue = newValue.target.value;
}
/* 下拉新增单独处理 */
const dEmptyValue =
this.props.showConfig.sName === "dMachineLength" || this.props.showConfig.sName === "dMachineWidth"
? newValue
: null; /* 设置数值型为空值时 数据置为0 或空值 */
let value =
this.firstDataIndex === "s" && !this.props.textArea && commonUtils.isEmpty(newValue)
? newValue.replace("--", "")
: ["t", "m"].includes(this.firstDataIndex)
? dateString
: (this.firstDataIndex === "d" || this.firstDataIndex === "i") && commonUtils.isEmpty(newValue)
? dEmptyValue
: newValue;
value = this.props.showConfig.bMultipleChoice ? value.toString() : value;
// if (value === 0) {
// setTimeout(() => {
// if (document.getElementById(`${this.props.showConfig.sName}${this.props.sId}`)) {
// document.getElementById(`${this.props.showConfig.sName}${this.props.sId}`).select();
// }
// }, 51);
// }
this.isDropdownFilter = true;
if (this.props.showConfig.sDropDownType === "sql" && value === "@#*000@") {
this.props.handleSqlDropDownNewRecord(this.props.showConfig, this.props.name);
if (this.mounted) {
this.setState({ dataValue: "" });
}
return;
}
if (this.props.showConfig.sDropDownType === "sql" && value === "=+@") {
/* 如果是选择空值,则将特殊字符过滤为空值 */
value = "";
}
if (this.props.showConfig.sDropDownType === "const" && value === "=+@") {
/* 如果是选择空值,则将特殊字符过滤为空值 */
value = "";
}
/* 回带值声明 */
const returnValue = {};
const { searchValue, searchDropDownData, dropDownData, selectTableData } = this.state;
let dropDownDataNew = [];
/* 如果是表格下拉的话 */
if (commonUtils.isNotEmptyStr(this.props.showConfig?.sTableTitleSql) && this.props.showConfig?.iVisCount > 1) {
dropDownDataNew = commonUtils.isEmptyArr(selectTableData) ? dropDownData : selectTableData;
} else {
dropDownDataNew = commonUtils.isEmptyArr(searchValue) ? dropDownData : searchDropDownData;
}
const getTValue = value => {
const { sDateFormat = "YYYY-MM-DD" } = this.props.showConfig;
if (moment(value, sDateFormat, true).isValid()) return value; // 如果数据满足日期格式,则直接返回
if (commonUtils.isEmpty(value)) {
return null;
} else if (sDateFormat) {
return moment(value).format(this.props.showConfig.sDateFormat);
} else {
return value;
}
};
/* 回带值赋值(sName:value) */
returnValue[this.props.showConfig.sName] =
// this.firstDataIndex === 's' && this.props.textArea ? value.target.value :
this.firstDataIndex === "i"
? commonUtils.isEmpty(value)
? undefined
: this.props.showConfig.sName === "iOrder"
? value
: parseInt(value, 0)
: this.firstDataIndex === "d"
? commonUtils.isEmpty(value)
? undefined
: this.floatNumberCheck(value)
: this.firstDataIndex === "t"
? getTValue(value)
: this.firstDataIndex === "b"
? value.target.checked
: value === null
? undefined
: value;
if (!this.props.showConfig.bMultipleChoice) {
const { sAssignField } = this.props.showConfig;
const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(item.sSlaveId) ? item.sSlaveId : item.sId) === value.toString());
if (!commonUtils.isEmpty(sAssignField)) {
/* 赋值数组 */
const sAssignFieldObj = sAssignField.split(",");
if (commonUtils.isNotEmptyObject(changeData)) {
for (const child of sAssignFieldObj) {
if (child.indexOf(":") > -1) {
const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim();
const sValueName = child.split(":")[1].trim();
// returnValue[sFieldName] = changeData[sValueName] || changeData.value;
returnValue[sFieldName] = changeData[sValueName] === 0 ? 0 : changeData[sValueName] || changeData.value;
}
}
} else if (!this.props.showConfig.bCanInput) {
// 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了
for (const child of sAssignFieldObj) {
if (child.indexOf(":") > -1) {
const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim();
returnValue[sFieldName] = "";
}
}
}
}
} else {
const { sAssignField } = this.props.showConfig;
const changeData = dropDownDataNew.filter(item =>
`,${value.toString()},`.includes(!commonUtils.isEmpty(item.sSlaveId) ? `,${item.sSlaveId},` : `,${item.sId},`)
);
if (!commonUtils.isEmpty(sAssignField)) {
/* 赋值数组 */
const sAssignFieldObj = sAssignField.split(",");
if (commonUtils.isNotEmptyArr(changeData)) {
for (const child of sAssignFieldObj) {
if (child.indexOf(":") > -1) {
const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim();
const sValueName = child.split(":")[1].trim();
const valueArr = [];
changeData.forEach(itemData => {
valueArr.push(itemData[sValueName]);
});
returnValue[sFieldName] = valueArr.toString();
}
}
} else if (!this.props.showConfig.bCanInput) {
// 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了
for (const child of sAssignFieldObj) {
if (child.indexOf(":") > -1) {
const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim();
returnValue[sFieldName] = "";
}
}
}
}
// 如果returnValue的第一个key对应的value的数据和上文的value个数不一致, 则取value的数据;
// 处理原因:如果已选数据不在下拉数据中时(比如懒加载模式),会过滤掉已选数据
if (commonUtils.isNotEmptyArr(Object.keys(returnValue))) {
const [returnValueKey0, returnValueValue0] = [Object.keys(returnValue)[0], Object.values(returnValue)[0]];
if (returnValueValue0.split(",").length !== value.split(",").length || (returnValueValue0 === "" && value !== "")) {
returnValue[returnValueKey0] = value;
}
}
}
if (
this.state.searchPageNum !== 0 ||
this.state.searchTotalPageCount !== 1 ||
this.state.searchDropDownData !== [] ||
this.state.searchValue !== "" ||
this.state.spinState !== false
) {
this.setState({
searchPageNum: 0,
searchTotalPageCount: 1,
searchDropDownData: [],
searchValue: "",
spinState: false,
});
}
// /* 调用父组件的回带函数 */
this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew);
clearTimeout(this.onChangeTimer);
this.onChangeTimer = setTimeout(() => {
this.onExecInstructSet("change");
}, 500);
};
/** 处理autoComplete下拉选择事件 */
// handleCompleteInputEvent = (newValue) => {
// // antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到;
// // 做了兼容处理
// if (newValue === undefined || newValue == null) {
// return;
// }
// if (newValue === undefined) return;
// if (newValue.target && newValue.target.type !== 'checkbox') {
// newValue = newValue.target.value;
// }
// const returnValue = {};
// const { searchValue, searchDropDownData, dropDownData } = this.state;
// const dropDownDataNew = commonUtils.isEmptyArr(searchValue) ? dropDownData : searchDropDownData;
// returnValue[this.props.showConfig.sName] = newValue;
// if (this.state.searchPageNum !== 0 || this.state.searchTotalPageCount !== 1 || this.state.searchDropDownData !== [] || this.state.searchValue !== '' || this.state.spinState !== false) {
// this.setState({
// searchPageNum: 0, searchTotalPageCount: 1, searchDropDownData: [], searchValue: '', spinState: false,
// });
// }
// this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew);
// };
handleCompleteInputEvent = (newValue, dateString) => {
// 输入完成后的半秒内,如果触发了输入事件,则不执行
if (this.chineseInputting) {
this.handleCompleteInputEventCache = () => {
this.chineseInputtingTimer = setTimeout(() => {
this.handleCompleteInputEvent(newValue, dateString);
this.handleCompleteInputEventCache = null;
}, 500);
};
return;
}
clearTimeout(this.chineseInputtingTimer);
// antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到;
// eslint-disable-next-line no-unused-vars
// const newKey = newValue.key || 0;
newValue = commonUtils.isNotEmptyObject(newValue.value) ? newValue.value : newValue; /* 处理可输入下拉框 输入数据时 没触发onChange事件 */
// antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到;
// 做了兼容处理
if (newValue === undefined) {
return;
}
if (newValue.target && newValue.target.type !== "checkbox") {
newValue = newValue.target.value;
}
/* 下拉新增单独处理 */
const dMachine = ["dMachineLength", "dMachineWidth"].includes(this.props.showConfig.sName);
if (dMachine) {
if (!/^\d+(\.\d+)?(\*\d+(\.\d+)?)?$/.test(newValue)) {
newValue = "";
setTimeout(() => {
this.setState({ searchValue: "" });
}, 1200);
}
}
const dEmptyValue =
this.props.showConfig.sName === "dMachineLength" || this.props.showConfig.sName === "dMachineWidth"
? newValue
: 0; /* 设置数值型为空值时 数据置为0 或空值 */
let value =
this.firstDataIndex === "s" && !this.props.textArea && commonUtils.isEmpty(newValue)
? newValue.replace("--", "")
: this.firstDataIndex === "t"
? dateString
: (this.firstDataIndex === "d" || this.firstDataIndex === "i") && commonUtils.isEmpty(newValue)
? dEmptyValue
: newValue;
value = this.props.showConfig.bMultipleChoice ? value.toString() : value;
// if (this.props.showConfig.sName === 'dMachineLength' || this.props.showConfig.sName === 'dMachineWidth') { /* 处理上机长宽 下拉数据 数据分割错误问题 */
// value = this.floatNumberCheck(value);
// }
this.isDropdownFilter = true;
if (this.props.showConfig.sDropDownType === "sql" && value === "@#*000@") {
this.props.handleSqlDropDownNewRecord(this.props.showConfig, this.props.name);
if (this.mounted) {
this.setState({ dataValue: "" });
}
return;
}
if (this.props.showConfig.sDropDownType === "sql" && value === "=+@") {
/* 如果是选择空值,则将特殊字符过滤为空值 */
value = "";
}
if (this.props.showConfig.sDropDownType === "const" && value === "=+@") {
/* 如果是选择空值,则将特殊字符过滤为空值 */
value = "";
}
/* 回带值声明 */
const returnValue = {};
const { searchValue, searchDropDownData, dropDownData } = this.state;
const dropDownDataNew = commonUtils.isEmptyArr(searchValue) ? dropDownData : searchDropDownData;
/* 回带值赋值(sName:value) */
returnValue[this.props.showConfig.sName] =
// this.firstDataIndex === 's' && this.props.textArea ? value.target.value :
this.firstDataIndex === "i"
? commonUtils.isEmpty(value)
? undefined
: this.props.showConfig.sName === "iOrder"
? value
: parseInt(value, 0)
: this.firstDataIndex === "d"
? commonUtils.isEmpty(value)
? dMachine
? ""
: undefined
: value // this.floatNumberCheck(value) :
: this.firstDataIndex === "t"
? commonUtils.isEmpty(value)
? null
: value
: this.firstDataIndex === "b"
? value.target.checked
: value === null
? undefined
: value;
if (!this.props.showConfig.bMultipleChoice) {
const { sAssignField } = this.props.showConfig;
// const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(item.sSlaveId) ? item.sSlaveId : item.sId) === newKey.toString());
let res = "";
if (dropDownDataNew.length > 0) {
if (commonUtils.isNotEmptyStr(this.props.showConfig.sVisColumnName)) {
res = this.props.showConfig.sVisColumnName;
} else {
res = Object.keys(dropDownDataNew[0]).length > 0 ? Object.keys(dropDownDataNew[0])[0] : "";
}
}
const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(res) ? item[res] : item.sId) === value.toString());
if (!commonUtils.isEmpty(sAssignField)) {
/* 赋值数组 */
const sAssignFieldObj = sAssignField.split(",");
if (commonUtils.isNotEmptyObject(changeData)) {
for (const child of sAssignFieldObj) {
if (child.indexOf(":") > -1) {
const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim();
const sValueName = child.split(":")[1].trim();
returnValue[sFieldName] = changeData[sValueName] || changeData.value;
}
}
} else if (!this.props.showConfig.bCanInput) {
// 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了
for (const child of sAssignFieldObj) {
if (child.indexOf(":") > -1) {
const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim();
returnValue[sFieldName] = "";
}
}
}
}
} else {
const { sAssignField } = this.props.showConfig;
const changeData = dropDownDataNew.filter(item =>
`,${value.toString()},`.includes(!commonUtils.isEmpty(item.sSlaveId) ? `,${item.sSlaveId},` : `,${item.sId},`)
);
if (!commonUtils.isEmpty(sAssignField)) {
/* 赋值数组 */
const sAssignFieldObj = sAssignField.split(",");
if (commonUtils.isNotEmptyArr(changeData)) {
for (const child of sAssignFieldObj) {
if (child.indexOf(":") > -1) {
const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim();
const sValueName = child.split(":")[1].trim();
const valueArr = [];
changeData.forEach(itemData => {
valueArr.push(itemData[sValueName]);
});
returnValue[sFieldName] = valueArr.toString();
}
}
} else if (!this.props.showConfig.bCanInput) {
// 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了
for (const child of sAssignFieldObj) {
if (child.indexOf(":") > -1) {
const sFieldName = child.split(":")[0].trim() === "self" ? this.props.showConfig.sName : child.split(":")[0].trim();
returnValue[sFieldName] = "";
}
}
}
}
}
if (
this.state.searchPageNum !== 0 ||
this.state.searchTotalPageCount !== 1 ||
this.state.searchDropDownData !== [] ||
this.state.searchValue !== "" ||
this.state.spinState !== false
) {
this.setState({
searchPageNum: 0,
searchTotalPageCount: 1,
searchDropDownData: [],
searchValue: "",
spinState: false,
});
}
// /* 调用父组件的回带函数 */
let bSpecial = true;
if (location.pathname && location.pathname.includes("ResearchTableTree")) {
bSpecial = false;
}
if (bSpecial && this.state.dataValue === returnValue[this.props.showConfig.sName]) {
if (!this.completeFlag) {
const addState = {};
addState[this.props.showConfig.sName] = undefined;
this.props.onChange(this.props.name, this.props.showConfig.sName, { ...returnValue, ...addState }, this.props.sId, dropDownDataNew);
setTimeout(() => {
this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew);
}, 200);
}
this.completeFlag = false;
} else {
this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew);
}
clearTimeout(this.onChangeTimer);
this.onChangeTimer = setTimeout(() => {
this.onExecInstructSet("change");
}, 500);
};
// handleCompleteOptionEvent = (newValue, dateString) => {
// // antd autocomplete官方组件用到了react高版本的事件合成,但checkbox没用到;
// const newKey = newValue.key;
// newValue = newValue.value;
// /* 下拉新增单独处理 */
// const dEmptyValue = this.props.showConfig.sName === 'dMachineLength' || this.props.showConfig.sName === 'dMachineWidth' ? newValue : 0; /* 设置数值型为空值时 数据置为0 或空值 */
// let value = this.firstDataIndex === 's' && !this.props.textArea && commonUtils.isEmpty(newValue) ? newValue.replace('--', '') :
// this.firstDataIndex === 't' ? dateString : (this.firstDataIndex === 'd' || this.firstDataIndex === 'i') && commonUtils.isEmpty(newValue) ? dEmptyValue : newValue;
// value = this.props.showConfig.bMultipleChoice ? value.toString() : value;
// // let value = this.firstDataIndex === 's' && !this.props.textArea && commonUtils.isEmpty(newValue) ? newValue.replace('--', '') :
// // this.firstDataIndex === 't' ? dateString : (this.firstDataIndex === 'd' || this.firstDataIndex === 'i') && commonUtils.isEmpty(newValue) ? 0 : newValue;
// // value = this.props.showConfig.bMultipleChoice ? value.toString() : value;
// this.isDropdownFilter = true;
// if (this.props.showConfig.sDropDownType === 'sql' && value === '@#*000@') {
// this.props.handleSqlDropDownNewRecord(this.props.showConfig, this.props.name);
// if (this.mounted) {
// this.setState({ dataValue: '' });
// }
// return;
// }
// if (this.props.showConfig.sDropDownType === 'sql' && value === '=+@') { /* 如果是选择空值,则将特殊字符过滤为空值 */
// value = '';
// }
// if (this.props.showConfig.sDropDownType === 'const' && value === '=+@') { /* 如果是选择空值,则将特殊字符过滤为空值 */
// value = '';
// }
// /* 回带值声明 */
// const returnValue = {};
// const { searchValue, searchDropDownData, dropDownData } = this.state;
// const dropDownDataNew = commonUtils.isEmptyArr(searchValue) ? dropDownData : searchDropDownData;
// /* 回带值赋值(sName:value) */
// returnValue[this.props.showConfig.sName] =
// // this.firstDataIndex === 's' && this.props.textArea ? value.target.value :
// this.firstDataIndex === 'i' ? commonUtils.isEmpty(value) ? undefined : this.props.showConfig.sName === 'iOrder' ? value : parseInt(value, 0) :
// this.firstDataIndex === 'd' ? commonUtils.isEmpty(value) ? undefined : this.floatNumberCheck(value) :
// this.firstDataIndex === 't' ? commonUtils.isEmpty(value) ? null : value :
// this.firstDataIndex === 'b' ? value.target.checked : value === null ? undefined : value;
// if (!this.props.showConfig.bMultipleChoice) {
// const { sAssignField } = this.props.showConfig;
// let res = '';
// if (dropDownDataNew.length > 0) {
// if (commonUtils.isNotEmptyStr(this.props.showConfig.sVisColumnName)) {
// res = this.props.showConfig.sVisColumnName;
// } else {
// res = Object.keys(dropDownDataNew[0]).length > 0 ? dropDownDataNew[0][Object.keys(dropDownDataNew[0])[0]] : '';
// }
// }
// const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(res) ? item[res] : item.sId) === value.toString());
//
// if (!commonUtils.isEmpty(sAssignField)) {
// /* 赋值数组 */
// const sAssignFieldObj = sAssignField.split(',');
// if (commonUtils.isNotEmptyObject(changeData)) {
// for (const child of sAssignFieldObj) {
// if (child.indexOf(':') > -1) {
// const sFieldName = child.split(':')[0].trim() === 'self' ? this.props.showConfig.sName : child.split(':')[0].trim();
// const sValueName = child.split(':')[1].trim();
// returnValue[sFieldName] = changeData[sValueName] || changeData.value;
// }
// }
// } else if (!this.props.showConfig.bCanInput) {
// // 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了
// for (const child of sAssignFieldObj) {
// if (child.indexOf(':') > -1) {
// const sFieldName = child.split(':')[0].trim() === 'self' ? this.props.showConfig.sName : child.split(':')[0].trim();
// returnValue[sFieldName] = '';
// }
// }
// }
// }
// } else {
// const { sAssignField } = this.props.showConfig;
// const changeData = dropDownDataNew.filter(item => (`,${value.toString()},`).includes((!commonUtils.isEmpty(item.sSlaveId) ? `,${item.sSlaveId},` : `,${item.sId},`)));
// if (!commonUtils.isEmpty(sAssignField)) {
// /* 赋值数组 */
// const sAssignFieldObj = sAssignField.split(',');
// if (commonUtils.isNotEmptyArr(changeData)) {
// for (const child of sAssignFieldObj) {
// if (child.indexOf(':') > -1) {
// const sFieldName = child.split(':')[0].trim() === 'self' ? this.props.showConfig.sName : child.split(':')[0].trim();
// const sValueName = child.split(':')[1].trim();
// const valueArr = [];
// changeData.forEach((itemData) => {
// valueArr.push(itemData[sValueName]);
// });
// returnValue[sFieldName] = valueArr.toString();
// }
// }
// } else if (!this.props.showConfig.bCanInput) {
// // 下拉选择空时,需要, bCanInput一定要为false不然印件名称输入时也被置空了
// for (const child of sAssignFieldObj) {
// if (child.indexOf(':') > -1) {
// const sFieldName = child.split(':')[0].trim() === 'self' ? this.props.showConfig.sName : child.split(':')[0].trim();
// returnValue[sFieldName] = '';
// }
// }
// }
// }
// }
// if (this.state.searchPageNum !== 0 || this.state.searchTotalPageCount !== 1 || this.state.searchDropDownData !== [] || this.state.searchValue !== '' || this.state.spinState !== false) {
// this.setState({
// searchPageNum: 0, searchTotalPageCount: 1, searchDropDownData: [], searchValue: '', spinState: false,
// });
// }
// // /* 调用父组件的回带函数 */
// console.log('returnValue', returnValue);
// this.props.onChange(this.props.name, this.props.showConfig.sName, returnValue, this.props.sId, dropDownDataNew);
// };
/** 搜索时过滤对应的 option 属性 */
filterOption = (input, option) => {
const { pageNum, totalPageCount } = this.state;
const newInput = input.toString().trim(); /* 下拉框默认为空 不需要替换'--’ */
if (pageNum <= totalPageCount && this.props.showConfig.sDropDownType === "sql" && commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) {
return true;
} else if (commonUtils.isNotEmptyObject(option.props.children)) {
try {
return !this.isDropdownFilter && this.props.showConfig.bCanInput
? true
: option.props.children.toLowerCase().indexOf(newInput.toLowerCase()) >= 0;
} catch (error) {
return false;
}
}
};
/**
* 小数校验
*/
floatNumberCheck = num => {
const dNetPrice = this.props.app?.decimals?.dNetPrice;
const Maximum = commonFunc.showLocalMessage(this.props, "Maximum", "最多输入${digit}位小数");
const { showConfig } = this.props;
const { sName, showName } = showConfig;
const digit = sName.includes("Price") && dNetPrice ? dNetPrice : 6;
const Maximun = Maximum.replace("${digit}", digit);
if (typeof num === "string") {
num = num.replace("*", "");
}
const checkRule = new RegExp(`^(-?\\d+)(\\.?)(\\d{1,${digit}})?$`);
if (!checkRule.test(num) && num && num !== "-" && num !== ".") {
message.warning(`【${showName}】【${sName}】${Maximun}`);
return undefined;
} else {
return num;
}
};
/** 小数位控制 noinspection JSAnnotator控制 string | number */
limitDecimals = values => {
let reg = "";
if (this.floatNum > 0) {
reg = `^(\\d+).(${this.floatPrice})*$`;
} else {
reg = "^(\\d+).(\\d\\d\\d\\d\\d\\d)*$";
}
if (typeof values === "string") {
if (values !== undefined && values.indexOf(".") <= -1) {
reg = "^(\\d+)*$";
return !isNaN(Number(values)) ? values.replace(new RegExp(reg), "$1") : "";
} else {
return !isNaN(Number(values)) ? values.replace(new RegExp(reg), "$1.$2") : "";
}
} else if (typeof values === "number") {
if (values !== undefined && String(values).indexOf(".") <= -1) {
reg = "^(\\d+)*$";
return !isNaN(values) ? String(values).replace(new RegExp(reg), "$1") : "";
} else {
return !isNaN(values) ? String(values).replace(new RegExp(reg), "$1.$2") : "";
}
} else {
return "";
}
};
handleViewClick = () => {
const { record, app, showConfig } = this.props;
const { sControlName, sActiveKey } = showConfig; /* 弹出标志,弹出界面对应数据主字段 */
if (commonUtils.isNotEmptyObject(sControlName) && commonUtils.isNotEmptyObject(sActiveKey)) {
const printPdf = sControlName;
if (commonUtils.isNotEmptyObject(printPdf) && printPdf === "printPdf" && commonUtils.isNotEmptyObject(sActiveKey)) {
const { token } = app;
const sActiveId =
this.props.showConfig.sActiveId === "1"
? commonUtils.isEmpty(record.sFormId)
? record.sSrcFormId
: record.sFormId
: this.props.showConfig.sActiveId;
const printsId = record[sActiveKey];
const urlPrint = `${
commonConfig.file_host
}printReport/printPdfByFromDataId/${printsId}.pdf?sModelsId=${sActiveId}&sId=${printsId}&token=${encodeURIComponent(token)}`;
// const urlPrint = `${commonConfig.file_host}printReport/printPdfByFromDataId?sModelsId=${sActiveId}&sId=${printsId}&token=${encodeURIComponent(token)}`;
window.open(urlPrint);
} else if (showConfig.sDropDownType && showConfig.sDropDownType.toLowerCase().includes("picarrmodal")) {
/* 蓝色链接跳转用Modal呈现 */
// this.props.onTabModalClick(name, sName, record, index, showConfig, configName);
this.props.onTabModalClick(this.props.name, this.props.showConfig.sName, record, undefined, showConfig, this.props.sName);
} else {
this.props.onViewClick(this.props.name, this.props.showConfig.sName, this.props.record);
}
} else if (showConfig.sDropDownType && showConfig.sDropDownType.toLowerCase().includes("picarrmodal")) {
/* 蓝色链接跳转用Modal呈现 */
// this.props.onTabModalClick(name, sName, record, index, showConfig, configName);
this.props.onTabModalClick(this.props.name, this.props.showConfig.sName, record, undefined, showConfig, this.props.sName);
} else {
this.props.onViewClick(this.props.name, this.props.showConfig.sName, this.props.record);
}
};
/* 打开新窗口查看SQL编辑器 */
handleOpenWin = () => {
const { dataValue, showConfig, record } = this.props;
// eslint-disable-next-line prefer-destructuring
const sBtnName = showConfig.sName;
const sBtnContent = commonUtils.isNotEmptyObject(dataValue) ? encodeURIComponent(dataValue) : "";
const sBtnControlName = commonUtils.isNotEmptyObject(showConfig.sName) ? showConfig.sName : "";
if (commonUtils.isNotEmptyObject(sBtnContent) && commonUtils.isNotEmptyObject(record)) {
const sFormId = commonUtils.isNotEmptyObject(record.sParentId) ? record.sParentId : "";
const urlPrint = `${commonConfig.server_host}template/getSql/${sBtnName}/?sBtnContent=${sBtnContent}&sBtnControlName=${sBtnControlName}&sFormId=${sFormId}`;
const w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
const h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
// const newWin = window.open('','_blank');
const features = `width=${w + 350},height=${
h + 300
}, top=0, left=0, toolbar=no, menubar=no,scrollbars=no,resizable=no, location =no, status=no`;
const newWin = window.open("", "SQL查看器", features);
newWin.document.write(
`<body scroll="no" style="margin: 0px;padding: 0px;border:0px;overflow:hidden;"><iframe style="margin: 0px;padding: 0px;border: 0px;width:100%;height:100%" src="${urlPrint}"></iframe></body>`
);
// window.open(urlPrint);
} else {
message.error("未找到对应过程名");
}
};
/* 右箭头点击 */
handleRightArrow = () => {
if (this.props.onRightArrow) {
const { name, record, showConfig } = this.props;
this.props.onRightArrow(name, showConfig.sName, record, undefined, showConfig);
}
};
// 编辑指令集
handleEditInstruct = () => {
this.setState({
instructSetSettingProps: {
...this.props,
...this.state,
instructSetSettingVisible: true,
instructSetSettingId: commonUtils.createSid(),
onSaveData: (value) => {
this.handleSelectOptionEvent(value);
this.setState({ instructSetSettingProps: {} });
},
onCancelInstructSetSettingModal: () => this.setState({ instructSetSettingProps: {} }),
}
});
}
handlePreviewImage = (e, dataUrl) => {
e.stopPropagation();
this.props.onPreviewImage(e, dataUrl);
};
handleViewChoose = () => {
if (this.props?.showConfig?.sName.includes('Color')) {
this.props.onViewChoose(this.props.name, this.props.showConfig.sName, this.props.record, null, true);
return
}
const bGycs = this.props.showConfig?.showName?.includes("工艺参数");
if (this.state.enabled || bGycs) this.props.onViewChoose(this.props.name, this.props.showConfig.sName, this.props.record);
};
handleMemoShow = () => {
this.props.onMemoShow(this.props.name, this.props.showConfig.sName, this.props.record, 0, this.props.showConfig);
};
handlePreviewOffice = dataUrl => {
this.props.onPreviewOffice(dataUrl);
};
handlePopupScroll = e => {
e.persist();
const { target } = e;
if (
Math.ceil(target.scrollTop + target.offsetHeight) >= target.scrollHeight &&
this.props.showConfig.sDropDownType === "sql" &&
commonUtils.isEmptyArr(this.props.showConfig.dropDownData)
) {
const { pageNum, searchPageNum, searchTotalPageCount, searchValue, totalPageCount } = this.state;
const nextPageNum = pageNum + 1;
const nextSearchPageNum = searchPageNum + 1;
if (searchValue !== "") {
this.getDropDownData(nextSearchPageNum, searchTotalPageCount, searchValue);
} else {
this.getDropDownData(nextPageNum, totalPageCount, searchValue);
}
}
};
handleSearch = value => {
if (this.dropDownTimer) {
clearTimeout(this.dropDownTimer);
}
this.dropDownTimer = setTimeout(() => {
if (this.props.showConfig.sDropDownType === "sql" && commonUtils.isEmptyArr(this.props.showConfig.dropDownData)) {
this.setState({ spinState: true });
this.getDropDownData(1, 1, value);
}
}, 500);
};
/** 渲染 */
render() {
/* 获取innerinput控件参数 */
const innerInputProps = this.getInnerInputProps();
const { slaveConfig = { gdsconfigformslave: [] }, bSColorSerialMemo } = this.props;
const { gdsconfigformslave } = slaveConfig;
const { sName } = this.props.showConfig;
const btPopIndex = gdsconfigformslave.findIndex(item => item.sControlName === `BtnPopup.${sName}`);
const btCostomIndex = gdsconfigformslave.findIndex(item => item.sControlName === `BtnCustom.${sName}`);
/* 获取innerinput控件 */
const innerInput =
btPopIndex > -1 && btCostomIndex > -1 ? (
<Space className={styles.commonAntSpace} size={3}>
{this.getInnerInput(innerInputProps)}
{this.getInnerButton()}
{this.getInnerButtonCostom(gdsconfigformslave[btCostomIndex])}
<div />
</Space>
) : btPopIndex !== -1 ? (
<Space className={styles.commonAntSpace} size={3}>
{this.getInnerInput(innerInputProps)}
{this.getInnerButton()}
<div />
</Space>
) : btCostomIndex !== -1 ? (
<Space className={styles.commonAntSpace} size={3}>
{this.getInnerInput(innerInputProps)}
{this.getInnerButtonCostom(gdsconfigformslave[btCostomIndex])}
<div />
</Space>
) : (
this.getInnerInput(innerInputProps)
);
let viewInfo = "";
if (
this.props.showConfig.sDropDownType !== "popup" &&
!commonUtils.isEmpty(this.props.showConfig.sActiveId) &&
!commonUtils.isEmpty(this.props.showConfig.sActiveKey) &&
(commonUtils.isNotEmptyObject(this.props.dataValue) || commonUtils.isNotEmptyNumber(this.props.dataValue)) &&
!location.pathname.includes("mobile")
) {
viewInfo = (
<div
className={this.state.sActiveDisplay ? "sActiveIdStyle sActiveIdStyleBlock" : "sActiveIdStyle sActiveIdStyleNone"}
title={this.props.dataValue}
style={{
display: this.state.sActiveDisplay ? "block" : "none",
// top: this.props.name === 'slaveInfo' ? '1px' : '',
// left: this.props.name === 'slaveInfo' ? '2px' : this.props.name === 'master' ? '1px' : '',
position: "absolute",
height: "100%",
overflow: "hidden",
}}
>
<span
onClick={this.handleViewClick}
className="masterLinkSpan"
style={{
transform: "none",
top: 0,
}}
>
{this.props.dataValue}
</span>
</div>
);
}
const sModelsType =
commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app) ? this.props.app.currentPane.sModelsType : "";
const pleaseSelect =
commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app)
? commonFunc.showMessage(this.props.app.commonConst, "pleaseSelect")
: "请选择";
const combinedInfo =
commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app)
? commonFunc.showMessage(this.props.app.commonConst, "CombinedInfo")
: "合版信息";
let bParamColor = false;
if (this.props && sName === "sParamValue" && this.props.dataValue) {
if (this.props.dataValue === "选择色序" || this.props.record.sParamKey === "sParam1001") {
bParamColor = true;
}
}
if (
sName === "sCombinedMemo" ||
sName === "sColorSerialMemo" ||
bSColorSerialMemo ||
bParamColor ||
sName === "sPositiveColor" ||
sName === "sOppositeColor" ||
sName === "sCombineProductNameNew" ||
sName === "sParams" ||
sName === "sParamsNew" ||
sName === "sQuoParams" ||
(commonUtils.isNotEmptyObject(sModelsType) && !sModelsType.includes("Set") && sName === "sCombinePartsNameNew")
) {
let sValue = "";
/* 将合版信息json解析成需要的字符串形式 */
if (sName === "sCombinedMemo") {
let JsonData = [];
if (commonUtils.isNotEmptyObject(this.props.dataValue)) {
try {
JsonData = JSON.parse(this.props.dataValue);
} catch (e) {
JsonData = [];
}
}
if (commonUtils.isNotEmptyArr(JsonData)) {
JsonData.forEach(item => {
sValue += `${item.sProductNo}:排${item.dCombineQty}个,`;
});
sValue = commonUtils.isNotEmptyObject(sValue) ? sValue.substr(0, sValue.length - 1) : "";
}
} else if (sName === "sColorSerialMemo" || bSColorSerialMemo || sName === "sPositiveColor" || sName === "sOppositeColor" || bParamColor) {
let JsonData = [];
if (commonUtils.isNotEmptyObject(this.props.dataValue)) {
try {
JsonData = JSON.parse(this.props.dataValue);
} catch (e) {
JsonData = [];
}
}
if (typeof JsonData === "object" && commonUtils.isNotEmptyArr(JsonData)) {
JsonData.forEach(item => {
sValue += `${item.sName}+`;
});
sValue = commonUtils.isNotEmptyObject(sValue) ? sValue.substr(0, sValue.length - 1) : "";
}
} else if (sName === "sParams" || sName === "sQuoParams" || sName === "sParamsNew") {
if (this.props.onGetParamsValue) {
// 页面自行处理sparams的sValue
sValue = this.props.onGetParamsValue({ sName, sValue: this.props.dataValue, record: this.props.record });
} else {
let JsonData = [];
if (commonUtils.isNotEmptyObject(this.props.dataValue)) {
try {
JsonData = JSON.parse(this.props.dataValue);
} catch (e) {
JsonData = [];
}
}
if (commonUtils.isNotEmptyArr(JsonData)) {
JsonData.forEach(item => {
if (item.bSelfCbx) {
const strValue = commonUtils.isNotEmptyObject(item.sParamValue) ? item.sParamValue : "";
sValue += `${item.sParamName}:${strValue},`;
}
});
sValue = commonUtils.isNotEmptyObject(sValue) ? sValue.substr(0, sValue.length - 1) : "";
}
}
} else {
sValue = this.props.dataValue;
}
viewInfo = (
<div
className="sActiveIdStyle sActiveIdStyle_viewChooseSpan"
title={sValue}
style={{
display: "block",
position: "relative",
// top: this.props.name === 'slaveInfo' ? '1px' : '',
// left: this.props.name === 'slaveInfo' ? '2px' : this.props.name === 'master' ? '1px' : '',
}}
>
<span
onClick={this.handleViewChoose}
className="viewChooseSpan"
style={{
width: "100%",
overflow: "hidden",
color: "#2f54eb",
background: "transparent",
}}
>
{" "}
{commonUtils.isNotEmptyObject(sValue) ? sValue : sName === "sCombinedMemo" ? combinedInfo : pleaseSelect}
</span>
</div>
);
}
/* commonClassify 制单日期、制单人员新增时设置保存时自动生成 */
let speacilNote = "";
const { record } = this.props;
const afterSave =
commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.app)
? commonFunc.showMessage(this.props.app.commonConst, "afterSave")
: "保存后自动生成";
if (
commonUtils.isNotEmptyObject(record) &&
commonUtils.isEmptyObject(record[sName]) &&
commonUtils.isNotEmptyObject(sName) &&
(sName === "tCreateDate" || sName === "sMakePerson")
) {
speacilNote = (
<div className="speacialNote" style={{ position: "absolute", padding: "0px 4px" }}>
{" "}
{afterSave}
</div>
);
}
const bShowMemo =
false &&
commonUtils.isNotEmptyObject(sName) &&
sName.indexOf("sMemo") > -1 &&
!sName.includes("ProcessMemo"); /* 非编辑状态下 备注以蓝色链接呈现 */
/* 如果是图片类型 ,加载图片 */
let imgBox = "";
if (commonUtils.isNotEmptyObject(sName) && sName.indexOf("picture") > -1) {
const picAddr = commonUtils.isNotEmptyObject(record[sName]) ? record[sName].split(",") : "";
if (commonUtils.isNotEmptyObject(picAddr)) {
const { token } = this.props.app;
const dataUrl = picAddr[0].includes("xlyerpfiles")
? `${commonConfig.file_host}file/download?savePathStr=${picAddr[0]}&scale=0.1&sModelsId=100&token=${token}`
: picAddr[0]; /* 缩略图 */
// const dataPriviewUrl = `${commonConfig.server_host}file/download?savePathStr=${picAddr}&width=800&&height=500&sModelsId=100&token=${token}`; /* 预览 */
const officeFileTypeList = ["PDF", "DOCX", "XLSX", "MP4", "WEBM", "OGG"];
const imgTypeList = ["PNG", "SVG", "JPG", "JPEG", "GIF", "BMP", "TIFF", "ICO"];
const officeFileType = picAddr[0].split(".").pop().toUpperCase();
let fileIcon = <FilePdfOutlined />;
if (officeFileType === "DOCX") {
fileIcon = <FileWordOutlined />;
} else if (officeFileType === "XLSX") {
fileIcon = <FileExcelOutlined />;
} else if (["MP4", "WEBM", "OGG"].includes(officeFileType)) {
fileIcon = <PlaySquareOutlined />;
}
let imgBox1 = "";
if (officeFileTypeList.includes(officeFileType)) {
imgBox1 = (
<span
style={{
width: "100%",
overflow: "hidden",
background: "transparent",
cursor: "pointer",
paddingTop: 14,
}}
onClick={() => {
this.handlePreviewOffice(picAddr[0]);
}}
>
{fileIcon}
</span>
);
} else if (imgTypeList.includes(officeFileType)) {
imgBox1 = (
<span
style={{
width: "100%",
overflow: "hidden",
background: "transparent",
cursor: "pointer",
}}
onClick={e => this.handlePreviewImage(e, picAddr)}
>
<img src={dataUrl} alt="img" onFocus={() => 0} style={{ width: "30px", height: "20px" }} />
</span>
);
} else {
imgBox1 = (
<span
style={{
width: "100%",
overflow: "hidden",
background: "transparent",
paddingTop: 14,
}}
>
<FileOutlined />
</span>
);
}
imgBox = (
<div
className="sActiveIdStyle"
title={this.props.dataValue}
style={{
position: "absolute",
padding: "0px 11px 0 4px",
width: "97%",
height: "93%",
fontSize: "12px",
zIndex: "10",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
overflow: "hidden",
backgroundColor: "#fff",
marginTop: 1,
boxShadow: "none",
}}
>
{imgBox1}
</div>
);
}
} else if (
this.props.name === "master" &&
sName !== "sQualityRequirementsMemo" &&
!this.props.enabled &&
commonUtils.isNotEmptyObject(sName) &&
bShowMemo
) {
/* 所有备注非编辑状态下点击链接可以弹出备注窗体 */
imgBox = (
<div
className={`sActiveIdStyle sActiveIdStyle-${this.props.showConfig.sName} masterMemo`}
title={this.props.dataValue}
style={{
position: "absolute",
padding: "0px 4px",
width: "100%",
height: "100%",
fontSize: "12px",
zIndex: "10",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
overflow: "hidden",
}}
>
<span
onClick={this.handleMemoShow}
style={{
width: "100%",
overflow: "hidden",
color: "#2f54eb",
background: "transparent",
}}
>
{" "}
<pre>{this.props.dataValue} </pre>
</span>
</div>
);
// 富文本处理
// if (this.props.showConfig.bEditor) {
// imgBox = (<></>);
// }
if (this.props.showConfig.sName && this.props.showConfig.sName.toLowerCase().includes("fullmemo")) {
imgBox = <></>;
}
}
/* 获取outformitem控件参数 */
const outFormItemProps = this.getOutFormItemProps();
/* 获取fieldDecorator参数 */
const fieldDecoratorProps = this.getFieldDecoratorProps();
/* 通用组件(主表存在getFieldDecorator表单验证,而从表则不需要) */
const commonAssembly = (
<FormItem {...outFormItemProps} required={this.props.showConfig.bNotEmpty}>
{" "}
{speacilNote}
{imgBox}
{!this.props.bTable ? this.getFieldDecorator(this.props.showConfig.sName, fieldDecoratorProps)(innerInput) : innerInput}
{viewInfo}{" "}
</FormItem>
);
const { iColValue, showConfig } = this.props;
const readonlyStyle = showConfig.bReadonly || showConfig.iTag === 1 ? "readonlyStyle" : "";
const costomStyle = showConfig.costomStyle || "";
/* 页面输出 */
return (
<div
ref={this.myRef}
className={iColValue === 24 ? "input24" : iColValue === 18 ? "input18" : iColValue === 12 ? "input12" : "changeClassName"}
key={this.state.key}
>
<div className={`${this.props.className} ${readonlyStyle} ${costomStyle}`} onClick={this.props.onCostomClick?.bind(this, showConfig)}>
{commonAssembly}
</div>
<InstructSetSetting {...this.state.instructSetSettingProps} />
</div>
);
}
}