quchenming
2018-03-29 52efbcf92a8053ee2c9041e8349ab08214a3f132
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
layoutStrings = {
    en: {
    },
    zh: {
        title: "自定义表单设计引擎",
        saveButton: "保存",
        shareButton: "预览",
    }
 
}
var customBase = customBase || {};
customBase.uploaderTemp = 0;
toastr.options = {
    closeButton: false,
    debug: false,
    progressBar: false,
    positionClass: "toast-top-center",
    onclick: null,
    showDuration: "300",
    hideDuration: "1000",
    timeOut: "2000",
    extendedTimeOut: "1000",
    showEasing: "swing",
    hideEasing: "linear",
    showMethod: "fadeIn",
    hideMethod: "fadeOut",
    }
 
//customBase.query_set_value = function(itemId,type,value,num){
//
//    var itemvalue;
//    if(num != undefined){
//        itemvalue = customBase.getItemValue(itemId,type)[num];
//    }else{
//        itemvalue = customBase.getItemValue(itemId,type);
//    }
//    if(value == 8888){
//        ////console.log(itemvalue)
//    }
//    if(itemvalue == undefined || itemvalue == '' || itemvalue == 0){
//        customBase.setItemValue(itemId,type,value,"","",num);
//    }
//}
 
//customBase.submitForm = function(){
//    ////console.log(window.customBase);
//    ////console.log(window.customShow);
//    var submit_data = {
//        "formId":customShow.options.formid,
//        "dataRowNUm":customShow.options.dataRowNum
//    };
//
//    var submit_request =  window.commonAjax("/datamanagement/getBudget",submit_data,"POST",true);
//    submit_request.done(function(res){
//
//    })
//}
//   2017/10/17 李元杰  点击计算费用后  msgInfo渲染
 
customBase.groupInfo = function (_data) {
    var groupTitle,
        groupData
    var container = $('#itemId_12subform').append('<div class="container"></div>')
    var subform = $('#itemId_12subform .container');
    // 点击后先清空在渲染页面数据
    subform.empty();
    for (var i = 0; i < _data.msgInfo.length; i++) {
        subform.append(`<li  style="position: relative;float:left;"></li>`);
        groupTitle = `<span style="color:${_data.msgInfo[i].groupColor}">${_data.msgInfo[i].groupName}</span>`
        subform.find("li").eq(i).append(groupTitle);
        subform.find("li").eq(i).append("<div class='ulContent'></div>");
        for (var j = 0; j < _data.msgInfo[i].groupData.length; j++) {
            subform.find("li").eq(i).find('.ulContent').append(`<div  style="color:${_data.msgInfo[i].groupColor}" >${_data.msgInfo[i].groupData[j].data}</div>`)
        }
    }
}
//customBase.listen_check = function(res_data,classname){// 实时验证
//    var customBase = window.customBase;
//    var customShow = window.customShow;
//  //  2017/10/17 李元杰  msgInfo渲染
//    customBase.groupInfo(res_data)
////    ////console.log(window.customBase);
//    _.each(res_data.data,function(redata){
//        var cu_item = customBase.options.customItems[redata.fieldKey];
//        ////console.log(cu_item)
//        if(cu_item != undefined && cu_item.type != "dropdownlist" && cu_item.type != "subform"){
//            customBase.query_set_value(cu_item.id,cu_item.type,redata.value);
//        }
//
//        var base_item = $("[fieldKey='" + redata.fieldKey + "']");
//        if(base_item.length > 0){
//            var base_item_id = base_item.attr('id');
//            var base_item_type = base_item.attr('type');
//            if(redata.type != "subform"){
//                $("#"+base_item_id+"ActiveId").find("." + classname).remove();
//                if(redata.msgInfo){
//                    var check_minfo = undefined;
//                    _.each(redata.msgInfo.header,function(minfo){
//                        if(minfo.validate){
//                            //console.log(minfo)
//                            $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
//                            check_minfo = minfo;
//                        }else{
//                            $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
//                        }
//                    });
//                    if(check_minfo != undefined){
//                            customBase.bind_check(base_item_id,base_item_type,check_minfo,classname);
//                            $("#"+base_item_id).on('change', function(){
//                                customBase.bind_check(base_item_id,base_item_type,check_minfo,classname);
//                            });
//                        }
//                }
//            }else{
//                $("#"+base_item_id+"ActiveId").find("." + classname).remove();
//                if(redata.msgInfo){
//                    _.each(redata.msgInfo.header,function(minfo){
//                        $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
//                    });
//                }
//                var sub_type = customShow.options.customItemShow.item[base_item_id].tag_Attribute.allcopy;
////                ////console.log(sub_type);
//                _.each(redata.child,function(recd,i){
//                    _.each(recd.items,function(recd_item){
//                        ////console.log(recd_item);
//                        ////console.log(customShow.options.customItemShow);
//                        var cu_cd_item = customBase.options.customItems[recd_item.fieldKey];
//                        ////console.log(cu_cd_item);
//                        if(cu_cd_item != undefined && cu_cd_item.type != "dropdownlist"){
//                            customBase.query_set_value(cu_cd_item.id,cu_cd_item.type,recd_item.value,i);
//                        }
//
//                        var base_item_cd = $("[fieldKey='" + recd_item.fieldKey + "']:eq('" + i + "')");
//                        var base_item_id_cd = base_item_cd.attr('id');
//                        var base_item_type_cd = base_item_cd.attr('type');
////                        ////console.log(base_item_cd);
////                        ////console.log(base_item_id_cd);
////                        ////console.log(base_item_type_cd);
////                        ////console.log(recd_item);
//                        if(sub_type){
//                            $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("." + classname).remove();
//                        }else{
//                            $("[id='"+base_item_id_cd+"']:eq('" + i + "')").closest("tr").find("p").remove();
//                        }
//
//                        if(recd_item.msgInfo){
//                            var check_minfo_cd = undefined;
//                            _.each(recd_item.msgInfo.header,function(minfo_cd){
////                                ////console.log($("#"+base_item_id_cd+"ActiveId"));
////                                ////console.log($("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')"));
//                                if(minfo_cd.validate){
//                                    check_minfo_cd = minfo_cd;
//                                    if(sub_type){
//                                        $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
//                                    }else{
//                                        customBase.set_p($("[id='"+base_item_id_cd+"']:eq('" + i + "')"));
//                                        $("[id='"+base_item_id_cd+"']:eq('" + i + "')").prev("p").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
//                                    }
//                                }else{
//                                    if(sub_type){
//                                        $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
//                                    }else{
//                                        customBase.set_p($("[id='"+base_item_id_cd+"']:eq('" + i + "')"));
//                                        $("[id='"+base_item_id_cd+"']:eq('" + i + "')").prev("p").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
//                                    }
//                                }
//                            });
//                            if(check_minfo_cd != undefined){
//                                customBase.bind_check(base_item_id_cd,base_item_type_cd,check_minfo_cd,classname,sub_type,i);
//                                $("[id='"+base_item_id_cd+"']:eq('" + i + "')").on('change', function(){
//                                    customBase.bind_check(base_item_id_cd,base_item_type_cd,check_minfo_cd,classname,sub_type,i);
//                                });
//                            }
//                        }
//                    });
//                });
//            }
//        }
//
//    });
//
//
//
//
////        _.each(res_data,function(redata){
////            var base_item = $("[fieldKey='" + redata.fieldKey + "']");
////            if(base_item.length > 0){
////                var base_item_id = base_item.attr('id');
////                var base_item_type = base_item.attr('type');
////                ////console.log(base_item_id);
////                ////console.log($("#"+base_item_id+"ActiveId").find(".listen_check"));
////                if($("#"+base_item_id+"ActiveId").find(".listen_check").length == 0){
////                    $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='listen_check'>" + redata.amount + "</span>");
////                }else{
////                    $("#"+base_item_id+"ActiveId").find(".listen_check").html(redata.amount);
////                }
////                var now_value_s = customBase.getItemValue(base_item_id,base_item_type);
////                    $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","#333");
////                    if(now_value_s != redata.amount){
////                        $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","red");
////                    }
////                $("#"+base_item_id).on('change', function(){
////                    var now_value = customBase.getItemValue(base_item_id,base_item_type);
////                    $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","#333");
////                    if(now_value != redata.amount){
////                        $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","red");
////                    }
////                });
////            }
////        });
//}
 
//customBase.bind_check = function(base_item_id,base_item_type,minfo,classname,sub_type,i){//验证方法
//    if( i != undefined){
//        if(i == 0){
//            var now_value = customBase.getItemValue(base_item_id, base_item_type);
//        }else{
//            var now_value = customBase.getItemValue(base_item_id, base_item_type)[i];
//        }
//        ////console.log(base_item_id);
//        ////console.log($("#" + base_item_id + "ActiveId"));
//        ////console.log($("[id='"+base_item_id+"ActiveId']:eq('" + i + "')"));
//        if(sub_type){
//            $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find("." + classname).css("color", "#333");
//            if(now_value != minfo.value) {
//                $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find("." + classname).css("color", "red");
//            }
//        }else{
//            $("[id='"+base_item_id+"']:eq('" + i + "')").prev("p").find("." + classname).css("color", "#333");
//            if(now_value != minfo.value) {
//                $("[id='"+base_item_id+"']:eq('" + i + "')").prev("p").find("." + classname).css("color", "red");
//            }
//        }
//
//    }else{
//        var now_value = customBase.getItemValue(base_item_id, base_item_type);
//        $("#" + base_item_id + "ActiveId").find("." + classname).css("color", "#333");
//        if(now_value != minfo.value) {
//            $("#" + base_item_id + "ActiveId").find("." + classname).css("color", "red");
//        }
//    }
//}
 
//customBase.set_p = function(item){
//    var p_height = "19.2px";
//    if(item.closest("tr").find("p").length == 0){
//        var item_td = item.closest("tr").find("td");
//        item_td.each(function(){
//            $(this).prepend("<p style='height:" + p_height + "'></p>")
//        });
//    }
//}
customBase.options = {
    customItems: {},
    uploaderItem: {},
    uploaderItemReady: {},
    uploaderFile: {},
    fileuuid: "",
    dropdownlistText: {},
    uploaderFileName: {},
    formbaseInfo: "",
    zTreeOnClickItems: {}
}
//项目编辑(设定及取得值)
customBase.itemEdit = {
    //单行文本
    text: {
        getItem: function (itemId) {
            itemReturn = [];
            var items = $(itemId);
            for (var i = 0; i < items.length; i++) {
                itemReturn[i] = items[i].value;
            };
            if (itemReturn.length == 1) {
                return itemReturn[0];
            } else {
                return itemReturn;
            }
 
        },
        setItem: function (itemId, value, showClass) {
            if (showClass == undefined) {
                showClass = 'customViewUEditorCss';
            }
            if (value == null) {
                value = "";
            }
            var itemL = $("." + showClass + " " + itemId).length;
            if (itemL > value.length) {
                itemL = value.length;
            }
            if (itemL == 1) {
                if ('customShow' == showClass) {
                    $("." + showClass).find(itemId)[0].setAttribute("readonly", "readonly");
                }
                $("." + showClass).find(itemId)[0].value = value;
            } else if (itemL == 0) {
                for (var i = 0; i < $("." + showClass + " " + itemId).length; i++) {
                    if ('customShow' == showClass) {
                        $("." + showClass + " " + itemId)[i].setAttribute("readonly", "readonly");
                    }
                    $("." + showClass + " " + itemId)[i].value = value;
                };
            } else {
                for (var i = 0; i < itemL; i++) {
                    if ('customShow' == showClass) {
                        $("." + showClass + " " + itemId)[i].setAttribute("readonly", "readonly");
                    }
                    $("." + showClass + " " + itemId)[i].value = value[i]
                };
            }
 
        },
    },
    //单选按钮组
    checkboxRadio: {
        getItem: function (itemId, type) {
            var itemList = $("." + itemId + "value");
            var itemListReturn = [];
            // 数组循环取得
            for (var j = 0; j < itemList.length; j++) {
 
                if (type == "radio") {
                    var items = $(itemList[j]).find(".custom-radio");
                } else {
                    var items = $(itemList[j]).find(".custom-check");
                }
                var checkItem = [];
                var z = 0;
                for (var i = 0; i < items.length; i++) {
                    if (items[i].className.indexOf("cur") > 0) {
                        checkItem[z] = items[i].getAttribute("value");
                        z++;
                    } else {
                    }
                };
                itemListReturn[j] = checkItem;
                z++;
            };
            return itemListReturn;
        },
        setItem: function (itemId, type, value, showClass) {
            //被选择项目设定
            checkboxRadioItem = function (itemList, value) {
                console.log(itemList)
                if (typeof value == "string") {
                    value = [value];
                }
                for (var i = 0; i < itemList.length; i++) {
                    for (var j = 0; j < value.length; j++) {
                        if (value[j] == itemList[i].getAttribute("value")) {
 
                            $(itemList[i]).addClass('cur');
                        }
                    }
                }
            }
            var itemL = $("." + showClass + " ." + itemId + "value");
            if (typeof value == "string") {
                value = [value];
            }
 
            //数据赋值
            for (var i = 0; i < itemL.length; i++) {
                var valueTemp = value[i];
                if (type == "radio") {
                    var items = $(itemL[i]).find(".custom-radio");
                } else {
                    var items = $(itemL[i]).find(".custom-check");
                }
                items.removeClass('cur');
                checkboxRadioItem(items, valueTemp)
            }
        },
    },
    //复选框组
    checkbox: {
        getItem: function (itemId) {
            var checkItem = "";
            if ($(itemId)[0] != undefined) {
                checkItem = $(itemId)[0].className.replace("custom-check", "");
            }
            if (checkItem.indexOf("cur") > 0) {
                checkItem = true;
            } else {
                checkItem = false;
            }
            return checkItem;
        },
        setItem: function (itemId, value) {
            if (value) {
                $(itemId).addClass('cur')
            } else {
                $(itemId).removeClass('cur');
            }
        },
    },
    // HTML内容
    htmlediter: {
        getItem: function (itemId) {
            itemId = itemId + "Item";
            return UE.getEditor(itemId).getContent();
        },
        setItem: function (itemId, value, showClass) {
            itemId = itemId+"Item";
            console.log(value)
            var rValue = value.join(",");//html回显bug修改  李伟民  0201
            if(showClass ==undefined){
                showClass = 'customViewUEditorCss';
            }
            UE.getEditor(itemId).ready(function(){
                UE.getEditor(itemId).setContent(rValue);
            });
 
        },
    },
    dropdownlistView: {
        getItem: function (itemId) {
            return $(itemId).select2("val");
        },
        setItem: function (itemId, value) {
            if (value) {
                $(itemId).select2("val", value);
            } else {
                $('.selectItme').attr('value', "");
                $('.val-card').remove();
            }
        },
    },
    dropdownlist: {
        getItem: function (itemId) {
            return $(itemId).select2("val");
        },
        setItem: function (itemId, value) {
            if (value) {
                $(itemId).select2("val", value);
            } else {
                $('.selectItme').attr('value', "");
                $('.val-card').remove();
            }
        },
    },
    // 下拉框(文本取得)
    dropdownlistText: {
        getItem: function (itemId) {
            var itemList = $(".customViewUEditorCss ." + itemId + "value");
            var itemListReturn = [];
            var select2ItemList = customBase.options.dropdownlistText[itemId];
            for (var i = 0; i < itemList.length; i++) {
                var select2Item = $(itemList[i]).select2("data");
                var items = [];
                for (var j = 0; j < select2Item.length; j++) {
                    for (var z = 0; z < select2ItemList.length; z++) {
                        if (select2ItemList[z].text == select2Item[j].text) {
                            items[j] = select2ItemList[z].value;
                        }
                    }
                    // items[j] = select2Item[j].text;
                };
                itemListReturn[i] = items;
            };
 
            return itemListReturn;
        },
        setItem: function (itemId, value, showClass, dropdowntype) {
            console.log(value)
            //              var select2Item = customBase.options.dropdownlistText[itemId];
            //              //单多选框数据设定
            //              //2017/10/27 马习同修改
            //              var customItem = customBase.options.customItems;
            //              var itemAttr = "";
            //              for(let key in customItem){
            //                  if(customItem[key].id == itemId){
            //                      itemAttr = customItem[key];
            //                  }
            //              }
            //              console.log(_.cloneDeep(customItem))
            //              console.log(itemAttr);
            //              //2017/10/27 马习同修改
            //              setelect2Item = function (itemId,value){
            //                  if(typeof value == "string"){
            //                      value = [value];
            //                  }
            //                  var itemsTemp = [];
            //                  for (var i = 0; i < value.length; i++) {
            //                      for (var j = 0; j < select2Item.length; j++) {
            //                          if(select2Item[j].value ==  value[i]){
            //                              var id = select2Item[j].id;
            //                              itemsTemp[i] = id;
            //                          }
            //                      };
            //                  }
            //                  $(itemId).val(itemsTemp).trigger("change");
            //              }
            //              //多个下拉菜单  马习同
            //              var itemList = $("."+showClass+" #itemId_"+itemAttr.parentsubFormNum+" ."+itemId+"value");
            //              var itemList1 = $("."+showClass+" ."+itemId+"value");
            //                console.log(itemList);
            //                console.log(itemList1);
            //              console.log(value)
            //              if(itemList.length ==1){
            //                  setelect2Item(itemList[0],value);
            //              }else{
            //                    for (var i = 0; i < itemList.length; i++) {
            //                        console.log(value)
            //                        console.log(itemList[i],value[i])
            //                       setelect2Item(itemList1[i],value[i]);
            //                    }
            //              }
            //
            //原代码
            //                            var select2Item = customBase.options.dropdownlistText[itemId];
            //              //单多选框数据设定
            //              setelect2Item = function (itemId,value){
            //                  if(typeof value == "string"){
            //                      value = [value];
            //                  }
            //                  var itemsTemp = [];
            //                  for (var i = 0; i < value.length; i++) {
            //                      for (var j = 0; j < select2Item.length; j++) {
            //                          if(select2Item[j].value ==  value[i]){
            //                              var id = select2Item[j].id;
            //                              itemsTemp[i] = id;
            //                          }
            //                      };
            //                  }
            //                  $(itemId).val(itemsTemp).trigger("change");
            //              }
            //              //多个下拉菜单
            //              var itemList = $("."+showClass+" ."+itemId+"value");
            //              if(itemList.length ==1){
            //                  setelect2Item(itemList[0],value);
            //              }else{
            //
            //                  for (var i = 0; i < itemList.length; i++) {
            //                       setelect2Item(itemList[i],value[i]);
            //                  }
            //              }
        },
    },
    dropdownlistText2: {
        getItem: function (itemId) {
            // var itemList = $(".customViewUEditorCss ."+itemId+"value");
            // var itemListReturn =[];
            // var select2ItemList = customBase.options.dropdownlistText[itemId];
            // for (var i = 0; i < itemList.length; i++) {
            //     var select2Item = $(itemList[i]).select2("data");
            //     var items = [];
            //     for (var j = 0; j < select2Item.length; j++) {
            //         for(var z=0;z<select2ItemList.length;z++){
            //             if(select2ItemList[z].text ==  select2Item[j].text){
            //                 items[j] = select2ItemList[z].value;
            //             }
            //         }
            //         // items[j] = select2Item[j].text;
            //     };
            //     itemListReturn[i] = items;
            // };
            var itemListReturn = xhSelect.getValue(itemId);
            return itemListReturn;
        },
        setItem: function (itemId, value, showClass, dropdowntype) {
            //2017/10/27 马习同修改
            console.log(value);
            var customItem = customBase.options.customItems;
            var itemAttr = "";
            for (let key in customItem) {
                if (customItem[key].id == itemId) {
                    itemAttr = customItem[key];
                }
            }
            //2017/10/27 马习同修改
 
            var select2Item = customBase.options.dropdownlistText[itemId];
            if (itemAttr.parentsubFormNum != 0) {//非子表单中 无需添加parentformnum 李伟民  11-14
                var itemList = $("#itemId_" + itemAttr.parentsubFormNum + " #" + itemId);
            } else {
                var itemList = $("#" + itemId);
            }
            console.log(itemList);
            if (itemList.length == 1) {
                // setelect2Item(itemId,value,0);
                xhSelect.setValue(itemId, value, 0)
            } else {
 
                for (var i = 0; i < itemList.length; i++) {
                    //  setelect2Item(itemId,value[i],i);
                    xhSelect.setValue(itemId, value[i], i)
                }
            }
 
        },
    },
    // 下拉框(值取得)
    dropdownlisVal: {
        getItem: function (itemId) {
            var itemList = $("." + itemId + "value");
            var itemListReturn = [];
            for (var i = 0; i < itemList.length; i++) {
                var select2Item = $(itemList[i]).select2("val");
                var items = [];
                for (var j = 0; j < select2Item.length; j++) {
                    items[j] = select2Item[j].text;
                };
                itemListReturn[i] = items;
            };
            return itemListReturn;
        },
        setItem: function (itemId, value) {
            $(itemId).select2("val", value);
        },
    },
    //文件上传 图片
    fileupload: { //-------------todo------------------
        getItem: function (itemId) {
            var fileReturn = {};
            for (i in customBase.options.uploaderItem[itemId]) {
                if (customBase.options.uploaderItem[itemId].hasOwnProperty(i)) {
                    var timestamp = new Date().getTime();
                    var idt = i.replace("WU", timestamp);
                    fileReturn[idt] = customBase.options.uploaderItem[itemId][i];
                    // fileReturn.push(customBase.options.uploaderItemReady[itemId][i]);
                }
            };
            //////console.log(fileReturn);
            return fileReturn;
        },
        setItem: function (itemId, value) {
            //无此情况
        },
    },
    tree: { //-------------todo------------------
        getItem: function (itemId) {
 
            var returnItem = [];
            var treeItem = $('div#' + itemId);
            var dataItemJSson;
            for (var i = 0; i < treeItem.length; i++) {
                if (treeItem[i].getAttribute("value") == "") {
                    var treeItem = {};
                } else {
                    ////console.log(selectItme[i].getAttribute("value"));
                    dataItemJSson = $.parseJSON(treeItem[i].getAttribute("value"));
                }
 
                var jn = 0;
                returnItem[i] = [];
                for (j in dataItemJSson) {
                    returnItem[i][jn] = j;
                    jn++;
                }
            }
            return returnItem;
        },
        setItem: function (itemId, value) {
            var treeDiv = $('div#' + itemId);
            console.log(value)
            // 判断是否在子表单内
            var isSubformTree = false;
            _.forIn(customShow.options.customItemShow.item, function (value, key) {
                if (value.tag_Id == itemId && value.parentsubFormNum != 0) {
                    isSubformTree = true;
                }
            });
 
            //  不在子表单内的树
            if (!isSubformTree) {
                var dataObj = {}
                var valueData = [];
                // 更新数据的时候需要在div上绑定一个存储数据的value
                //  单选
                if(value)
                console.log(value);
                // if(value == ' '){
                //     if(value == ' '){
                //         value =  window.localStorage.getItem('businessTypeAuto');
                //     }
                // }else{
                    if (typeof value == "string") {
                        dataObj[value] = '1'
                    } else {
                        for (var j = 0; j < value.length; j++) {
                            valueData[j] = value[j].split(',')
                            dataObj[valueData[j]] = '1'
                        }
                    }
                    $('#' + itemId).attr('value', JSON.stringify(dataObj))
                    console.log(value)
                    console.log(itemId)
                    var  b = $('#'+itemId + "tree")
                    console.log($('#'+itemId + "tree"))
                    var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
                    console.log(treeObj)
                    if (treeObj == null) {
                        return;
                    }
                    if (typeof value == "string") {
                        value = [value];
                    }
                    //   2017/11/6 回显的地方
                    for (var i = 0, l = value.length; i < l; i++) {
                        if (treeObj.setting.check.chkStyle == "radio") {
                            //  单选
                            console.log(value)
                            var nodes = treeObj.getNodeByParam("id", value[i], null);
                            console.log(nodes);
                            if (_.isNull(nodes)) {
                                // treeObj.checkAllNodes(false);
                                // return false;
                            } else {
                                if (value == nodes.id) {
                                    value = nodes.name;
                                }
                                console.log(value)
                                if (nodes != null) {
                                    // 2017 /11/6 选中
                                    //选择节点设定
                                    treeObj.checkNode(nodes, true, true);
                                    treeObj.expandAll(true);
                                }
                            }
                        } else {
                            //  多选
                            for (var j = 0; j < value[i].length; j++) {
                                //取得设定节点
                                console.log(value[j]);
                                var nodes = treeObj.getNodeByParam("id", value[j], null);
                                console.log(nodes)
                                if (_.isNull(nodes)) {
                                    // treeObj.checkAllNodes(false);
                                    // return false;
                                } else {
                                    if (value[j] == nodes.id) {
                                        value[j] = nodes.name;
                                    }
                                    console.log(nodes)
                                    if (nodes != null) {
                                        // 2017 /11/6 选中
                                        //选择节点设定
                                        treeObj.checkNode(nodes, true, true);
                                        treeObj.expandAll(true);
                                    }
                                }
                            }
                        }
                    }
                    //  详细页面的回显
                    // var showTreeDiv = ` <div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClass edui-default customShowItemClassTemp">
                    //         ${value}
                    //             </div>`
                    // $('#customShow').find(`#${itemId}ActiveId`).children(':nth-child(4)').remove();
                    $('#customShow').find(`[treeitemid=${itemId}]`).html(value);//普通模式树形回显  李伟民  0130
                    // $('#customShow').find(`#${itemId}ActiveId`).append(showTreeDiv);
                    $('#' + itemId).parents('div[name="TreeWin"]').find('.citySel').val(value);
                // }
            } else {
                //  子表单里只有一颗树的时候
                if (treeDiv.length == 1) {
                    var dataObj = {}
                    var valueData = [];
                    // 更新数据的时候需要在div上绑定一个存储数据的value
                    //  单选
                    console.log(value);
                    // 不在子表单里的树更新时需要的数据
                    if(value){
                        if (typeof value[0] == "string" && value[0]!= '') {
                            dataObj[value[0]] = '1'
                        } else {
                            for (var i = 0; i < value[0].length; i++) {
                                valueData[i] = value[0][i].split(',')
                                dataObj[valueData[i]] = '1'
                            }
                        }
                        $('#' + itemId).attr('value', JSON.stringify(dataObj))
                        var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
                        if (treeObj == null) {
                            return;
                        }
                        if (typeof value == "string") {
                            value = [value];
                        }
                        //   2017/11/6 回显的地方
                        for (var i = 0, l = value.length; i < l; i++) {
                            if (treeObj.setting.check.chkStyle == "radio") {
                                // 12/6   因为会触发customShow.addtree()导致ul 的id 变更
                                var treeDiv = $('div#' + itemId);
                                var ultreeId = $(treeDiv).find('ul').attr('id');
                                var treeObj = $.fn.zTree.getZTreeObj(ultreeId);
                                // var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree1");
                                //  单选
                                var nodes = treeObj.getNodeByParam("id", value[i], null);
                                console.log(nodes)
                                if (_.isNull(nodes)) {
 
                                    var  tid = '';
                                    nodes = treeObj.getCheckedNodes(true);
                                    for (var i = 0; i < nodes.length; i++) {
                                        tid = nodes[i].tId
                                    }
                                    console.log(tid)
                                    // 强行制空
                                    $('#'+tid+'_check').click()
                                    $('#' + tid + '_check').click()
                                    $(treeDiv).prev().find('.citySel').val('')
                                } else {
                                    if (value[i] == nodes.id) {
                                        value[i] = nodes.name;
                                    }
                                    if (nodes != null) {
                                        // 2017 /11/6 选中
                                        //选择节点设定
                                        console.log(nodes)
                                        treeObj.checkNode(nodes, true, true);
                                        treeObj.expandAll(true);
                                        console.log(treeObj)
                                        var  tid = '';
                                            nodes11 = treeObj.getCheckedNodes(true);
                                            console.log(nodes11)
                                        for (var i = 0; i < nodes11.length; i++) {
                                            tid = nodes11[i].tId
                                        }
                                        console.log(tid);
                                        // console.log($('#'+tid+'_check'))
                                        // $('#'+tid+'_check').click()
                                        // $('#'+tid+'_check').click()
 
                                    }
                                }
                            } else {
                                //  多选
                                for (var j = 0; j < value[i].length; j++) {
                                    //取得设定节点
                                    console.log(value[i][j]);
                                    var nodes = treeObj.getNodeByParam("id", value[i][j], null);
                                    console.log(nodes)
                                    if (_.isNull(nodes)) {
                                        // treeObj.checkAllNodes(false);
                                        // return false;
                                    } else {
                                        if (value[i][j] == nodes.id) {
                                            value[i][j] = nodes.name;
                                        }
                                        console.log(nodes)
                                        if (nodes != null) {
                                            // 2017 /11/6 选中
                                            //选择节点设定
                                            treeObj.checkNode(nodes, true, true);
                                            treeObj.expandAll(true);
                                             console.log(treeObj)
 
                                        }
                                    }
                                }
                            }
                        }
                        //      回显到table表格里
                        var showIdTbale = $(`#${itemId}`).parents('.subformCss').attr('id');
                        $(`#${itemId}`).parent('div[name="TreeWin"]').find('.citySel').val(value);
                        var deitSubFormsTree = $(`#${showIdTbale}`).find('tbody').find('tr:nth-child(2)').find('td');
                        for (var i = 1; i < deitSubFormsTree.length - 1; i++) {
                            //  将编辑页面的树形ipnut 里面的值 放到展示页面里
                            var value = $(deitSubFormsTree[i]).find('.citySel').val();
                            $(`#customShow  #${showIdTbale}ActiveId`).find(`#${showIdTbale}`).find('.trContentClass').find(`td:nth-child(${i + 1})`).find('.customShowItemClass').html(value)
                        }
 
                    }
 
                } else {
                    // 子表单内td里面的div更改
                    var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClassTemp customShowItemClass ' + id + '_showItem edui-default">';
                    oNode += "</div>";
                    var showItem = $($(".customShow").find("#" + itemId));
                    for (var i = 0; i < showItem.length; i++) {
                        $($(showItem[i])[0]).after(oNode);
                        $($(showItem[i])[0]).remove();
                    }
                    var treeDiv = $('div#' + itemId);
                    console.log(treeDiv)
                    // 插入input里的value
                    var iptValue = [];
                    var iptValueObj = {};
                    // 更新的时候需要的数据
                    var dataObj = {}
                    var valueData = [];
                    for (var j = 0; j < treeDiv.length; j++) {
                        var ultreeId = $(treeDiv[j]).find('ul').attr('id');
                        var treeObj = $.fn.zTree.getZTreeObj(ultreeId);
                        if (treeObj == null) {
                            return;
                        }
                        if (typeof value == "string") {
                            value = [value];
                        }
                        //   2017/11/6 回显的地方
                        // 单选
                        if (treeObj.setting.check.chkStyle == "radio") {
                            console.log($(treeDiv[j]))
                            console.log(value);
                            for (var i = 0; i < value.length; i++) {
                                if (value[i] == '') {
                                    console.log(1)
                                    // dataObj = {}
                                } else {
                                    console.log(2)
                                    if (i == j) {
                                        dataObj[value[i]] = '1';
                                    }
                                }
                            }
                            $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
                            dataObj = {}
                            console.log(j)
                            console.log(value[j])
                            var nodes = treeObj.getNodeByParam("id", value[j], null);
                            console.log(nodes)
                            console.log(treeObj)
                            if (_.isNull(nodes)) {
                                // treeObj.checkAllNodes(false);
                                var  tid = '';
                                    nodes = treeObj.getCheckedNodes(true);
                                for (var i = 0; i < nodes.length; i++) {
                                    tid = nodes[i].tId
                                }
                                console.log(tid)
                                $('#' + tid + '_check').click()
                                $(treeDiv[j]).prev().find('.citySel').val('')
                            } else {
                                if (value[j] == nodes.id) {
                                    iptValue.push(nodes.name);
                                }
                                if (nodes != null) {
                                    // 2017 /11/6 选中
                                    //选择节点设定
                                    console.log(treeObj);
                                    console.log(nodes)
                                    treeObj.checkNode(nodes, true, true);
                                    treeObj.expandAll(true);
                                }
                                for (var k = 0; k < iptValue.length; k++) {
                                    $(treeDiv[j]).prev().find('.citySel').val(iptValue[k])
                                }
                            }
 
                        } else {
                            // 多选
 
                            console.log(value[j])
                            if (typeof value[j] == "string") {
                                var strValue = value[j].split(',');
                                // 导入excel时状态多选为字符串形式
                                if (strValue.length > 1) {
                                    console.log(strValue)
                                    for (var n = 0; n < strValue.length; n++) {
                                        var nodes = treeObj.getNodeByParam("id", strValue[n], null);
                                        console.log(nodes)
                                        if (strValue[n] == '') {
 
                                        } else {
                                            dataObj[strValue[n]] = '1';
                                        }
                                        if (_.isNull(nodes)) {
                                            // treeObj.checkAllNodes(false);
                                            // return false;
                                            $(treeDiv[j]).prev().find('.citySel').val('')
 
                                        } else {
                                            if (strValue[n] == nodes.id) {
                                                iptValue.push(nodes.name);
                                            }
                                            if (nodes != null) {
                                                // 2017 /11/6 选中
                                                //选择节点设定
                                                treeObj.checkNode(nodes, true, true);
                                                treeObj.expandAll(true);
                                            }
                                        }
                                        $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
 
                                    }
                                    $(treeDiv[j]).prev().find('.citySel').val(iptValue.join(','))
                                    iptValue = [];
                                    dataObj = {};
                                } else {
                                    var nodes = treeObj.getNodeByParam("id", value[j], null);
                                    for (var i = 0; i < value.length; i++) {
                                        if (value[i] == '') {
 
                                        } else {
                                            if (i == j) {
                                                dataObj[value[i]] = '1';
                                            }
                                        }
                                    }
                                    $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
                                    dataObj = {}
                                    if (_.isNull(nodes)) {
                                        // treeObj.checkAllNodes(false);
                                        // return false;
                                    } else {
                                        if (value[j] == nodes.id) {
                                            iptValue.push(nodes.name);
                                        }
                                        if (nodes != null) {
                                            // 2017 /11/6 选中
                                            //选择节点设定
                                            treeObj.checkNode(nodes, true, true);
                                            treeObj.expandAll(true);
                                        }
                                        for (var k = 0; k < iptValue.length; k++) {
                                            $(treeDiv[j]).prev().find('.citySel').val(iptValue[k])
                                        }
                                        iptValue = [];
                                    }
                                }
                            } else {
                                var dataObj = {}
                                var valueData = [];
                                for (var i = 0; i < value[j].length; i++) {
                                    valueData[i] = value[j][i].split(',')
                                    dataObj[valueData[i]] = '1'
                                }
                                $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
                                for (var k = 0; k < value[j].length; k++) {
                                    //   j是 有几个input框
                                    //   k是  value 里面的数据还会有呈现数组的形式
                                    dataObj = {}
                                    valueData = [];
                                    var nodes = treeObj.getNodeByParam("id", value[j][k], null);
                                    if (_.isNull(nodes)) {
 
                                    } else {
                                        if (value[j][k] == nodes.id) {
                                            if (k <= value[j].length) {
                                                iptValue.push(nodes.name);
                                            }
                                        }
                                        iptValueObj[k] = iptValue;
                                        // if (nodes != null) {
                                            // 2017 /11/6 选中
                                            //选择节点设定
                                            treeObj.checkNode(nodes, true, true);
                                            treeObj.expandAll(true);
                                        // }
                                    }
                                }
                                for (index in iptValueObj) {
                                    $(treeDiv[j]).prev().find('.citySel').val(iptValueObj[index].join(','))
                                }
                                iptValue = [];
                                iptValueObj = {};
                            }
 
                        }
                        //  获取父级ID
                        var showIdTable = $(`#${itemId}`).parents('.subformCss').attr('id');
                        // 获取当前树形在整个td的下标
                        var subformDataIndex = $(`#${itemId}`).parents('td').index();
                        var subformTr = $('#customShow tr#' + showIdTable + "subformTr");
                        var subformValue = $($('.tabBox' + ' #' + showIdTable + "subformTr")[j]).find('td').eq(subformDataIndex).find('.citySel').val()
                        $(subformTr[j]).children().eq(subformDataIndex).find('.customShowItemClassTemp').html(subformValue);
                    }
                }
            }
 
        },
    },
    //选择表单控件
    mytext: {
        getItem: function (itemId) {
            //                var newmytextObj = $('#'+itemId+' ul');
            //                console.log(newmytextObj);
            //                var chooseFormData = {};
            //                var str = [];
            //                _.each(newmytextObj,(opt,i)=>{
            //                    var $mytextObj = $('#'+opt.id+' [class="data1 DATAROWNUM"]');
            //              var $mytextObj2 = $('#'+opt.id+' [class="data2 DATAROWNUM"]');
            ////              console.log($mytextObj);
            ////              console.log($mytextObj2);
            ////              console.log($mytextObj.html());
            ////              console.log($mytextObj2.html());
            ////              for(let i = 0;i < $mytextObj.length ;i++){
            ////                  var $myText = $mytextObj.eq(i).html();
            ////                  console.log($myText)
            ////                  console.log($mytextObj2.eq(i).html())
            ////                                    chooseFormData[$myText] = $mytextObj2.eq(i).html();
            ////
            ////              }
            ////              dataArr1.push($mytextObj2.html());
            //                                console.log(i);
            //                                console.log(newmytextObj.length);
            //                                if(i<newmytextObj.length-1){
            //                                    str += $mytextObj2.html()+",";
            //                                }else{
            //                                    str += $mytextObj2.html();
            //                                }
            //                })
            //                console.log(str)
 
            var str = $('#' + itemId).attr("mxtVal");//关联数据 取值 11-07  李伟民
            return str;
 
 
        },
        setItem: function (itemId, value) {
            console.log(value);
            if (!_.isString(value)) {
                var new_value = [];
                _.each(value.list, function (v) {
                    if (v.DATAROWNUM) {
                        new_value.push(v.DATAROWNUM);
                    }
                });
                new_value = new_value.join();
                $('#' + itemId).attr("mxtVal", new_value);//关联数据 存值 11-07  李伟民
            } else {
                $('#' + itemId).attr("mxtVal", value);//关联数据 存值 11-07  李伟民
            }
        },
    },
};
 
 
//画面弹出信息
customBase.alert = function (type, message) {
    if (type == "E") {
        toastr.error(message);
    } else if (type == "I") {
        toastr.info(message);
    } else if (type == "W") {
        toastr.warning(message);
    } else if (type == "S") {
        toastr.success(message);
    } else {
        toastr.error(message);
    }
}
 
//根据别名取得字段Id
customBase.getfieldKeyFoItemId = function (fieldKey) {
    return customBase.options.customItems[fieldKey].id;
}
 
//取得message信息
customBase.getMessage = function (messageID) {
    // 12/11
    var strMessage = "";
    switch (messageID) {
        case "mesage_ID001":
            strMessage = "子表单中无法追加此控件!";
            break;
        case "mesage_ID002":
            strMessage = "表单别名重复,请对别名进行修改!";
            break;
        case "mesage_ID003":
            strMessage = "表单保存成功!";
            break;
        case "mesage_ID004":
            strMessage = '项目必须输入!';
            break;
        case "mesage_ID005":
            strMessage = "上传成功!";
            break;
        case "mesage_ID006":
            strMessage = "操作过于频繁,请稍后再执行!";
            break;
        case "mesage_ID007":
            strMessage = "画面字段数据过多,保存失败!";
            break;
        case "mesage_ID008":
            strMessage = "单行文本的最大长度不能超过150!";
            break;
        case "mesage_ID009":
            strMessage = "'请输入有效的手机号码!";
            break;
        case "mesage_ID010":
            strMessage = "'请输入正确的网址!";
            break;
        case "mesage_ID011":
            strMessage = "'请输入有效的身份证号!";
            break;
        case "mesage_ID012":
            strMessage = "请输入有效的邮箱!";
            break;
        case "mesage_ID013":
            strMessage = "请输入表单名!";
            break;
        case "mesage_ID014":
            strMessage = "表单版本重复,请修改!";
            break;
        case "mesage_ID015":
            strMessage = "保存成功!";
            break;
        case "mesage_ID016":
            strMessage = "表单别名必须输入,请对别名进行修改!";
            break;
        case "mesage_ID017":
            strMessage = "表单的宽高必须输入!";
            break;
        case "mesage_ID018":
            strMessage = "请输入版本信息!";
            break;
        case "mesage_ID019":
            strMessage = "请输入整数!";
            break;
        case "mesage_ID020":
            strMessage = "整数长度超出设定范围!";
            break;
        case "mesage_ID021":
            strMessage = "小数长度超出设定范围!";
            break;
        case "mesage_ID022":
            strMessage = "条形码默认值不能为空!";
            break;
        case "mesage_ID023":
            strMessage = "长度超出设定范围!";
            break;
        case "mesage_ID024":
            strMessage = "请选择正确的部门";
            break;
        case "mesage_ID025":
            strMessage = "预算余额不足,不可退回";
            break;
        case "mesage_ID026":
            strMessage = "上级预算余额不足";
            break;
        case "mesage_ID027":
            strMessage = "操作成功";
            break;
        case "mesage_ID028":
            strMessage = "上级预算无此业务类型";
            break;
        case "mesage_ID029":
            strMessage = "还款成功";
            break;
        case "mesage_ID030":
            strMessage = "还款失败";
            break;
        case "mesage_ID031":
            strMessage = "创建流程实例成功";
            break;
        case "mesage_ID032":
            strMessage = "请创建流程定义";
            break;
        case "mesage_ID033":
            strMessage = "服务器返回错误有";
            break;
        case "mesage_ID034":
            strMessage = "本条数据已创建流程";
            break;
        case "mesage_ID035":
            strMessage = "请先选择流程定义";
            break;
        default:
            strMessage = "错误信息,请与管理员联系!";
    }
    return strMessage;
}
 
 
//取得表单画面项目
customBase.getItemValue = function (itemId, type) {
 
    var item = "";
    //单行文本 多行文本 数字 日历  customBase.itemEdit   var prefix =  JSON.parse(window.localStorage.getItem("customItem"));
    if (type == 'text' || type == 'textarea' || type == 'number' || type == 'calendar' || type == "auto") {
        item = customBase.itemEdit['text'].getItem("." + itemId + "value");
    } else if (type == 'radio' || type == 'checkbox') {
        item = customBase.itemEdit['checkboxRadio'].getItem(itemId, type);
    } else if (type == 'image' || type == 'fileupload') {
        item = customBase.itemEdit['fileupload'].getItem(itemId);
    } else if (type == 'amount') {
        item = customBase.itemEdit['text'].getItem("#" + itemId + "amount");
    } else if (type == 'qrcode') {
        item = customBase.itemEdit['text'].getItem("#" + itemId + "qrcode");
    } else if (type == 'barcode') {
        item = customBase.itemEdit['text'].getItem("#" + itemId + "barcode");
    } else if (type == 'splitline' || type == 'button') {
 
    } else if (type == 'dropdownlistText') {
        // customBase.itemEdit[type].setItem(itemId,value,showClass,dropdowntype);
        // item = customBase.itemEdit["dropdownlistText"].getItem(itemId);
        item = customBase.itemEdit["dropdownlistText2"].getItem(itemId);
    } else if (type == "tree") {
        item = customBase.itemEdit["tree"].getItem(itemId);
    } else {
        item = customBase.itemEdit[type].getItem(itemId);
    }
    return item;
}
//设定表单画面项目   12/7
customBase.setItemValue = function (itemId, type, value, showClass, dropdowntype, num) {
    console.log(type)
    console.log(value)
    console.log(itemId)
    var item;
    if (showClass == "") {
        showClass = 'customViewUEditorCss';
    }
    if (type == 'text' || type == 'textarea' || type == 'number' || type == 'calendar' || type == 'auto') {
        if (num != undefined) {
            customBase.itemEdit['text'].setItem("[id=" + itemId + "]:eq('" + num + "')", value, showClass);
        } else {
            customBase.itemEdit['text'].setItem("#" + itemId, value, showClass);
        }
    } else if (type == 'htmlediter') {
        customBase.itemEdit['htmlediter'].setItem(itemId, value, showClass);
    } else if (type == 'radio' || type == 'checkbox') {
        customBase.itemEdit['checkboxRadio'].setItem(itemId, type, value, showClass);
    } else if (type == 'tree') {
        customBase.itemEdit['tree'].setItem(itemId, value);
    } else if (type == 'dropdownlistText') {
        //console.log(value);
        customBase.itemEdit[type].setItem(itemId, value, showClass, dropdowntype);
        //console.log(1);
        customBase.itemEdit["dropdownlistText2"].setItem(itemId, value, showClass, dropdowntype);
    } else if (type == 'splitline' || type == 'subform' || type == 'tag' || type == 'tab') {
    } else if (type == 'image') {
        // customBase.itemEdit[type].setItem(itemId,value,showClass);
    } else if (type == 'qrcode') {
        // customBase.itemEdit[type].setItem(itemId,value,showClass);
    } else if (type == 'barcode') {
        // customBase.itemEdit[type].setItem(itemId,value,showClass);
    } else if (type == 'link') {
        // customBase.itemEdit[type].setItem(itemId,value,showClass);
    } else if (type == 'button') {
        // customBase.itemEdit[type].setItem(itemId,value,showClass);
    } else {
        customBase.itemEdit[type].setItem(itemId, value, showClass);
    }
 
}
 
 
/**
 * 获取项目根路径1
 * @return {RootPath}
 */
customBase.getRootPath = function () {
    var strFullPath = window.document.location.href;
    var strPath = window.document.location.pathname;
    var pos = strFullPath.indexOf(strPath);
    var prePath = strFullPath.substring(0, pos);
    var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1) + "/";
    return (prePath + postPath);
}
 
 
 
//文件上传
customBase.uploaderFileShow = function (potion) {
    console.log(potion);
    var itemId = potion.id;
 
    customBase.options.uploaderItem[itemId] = {};
    var arrItemReady = 0;
    if (potion.ItemReady != undefined) {
        arrItemReady = Object.keys(potion.ItemReady).length;
        customBase.options.uploaderItem[itemId] = potion.ItemReady;
    }
    var $uploaderItem = $(".customViewUEditorCss #" + potion.id);
    $uploaderItem.empty();
    var $uploadimg = $(
        '<div id="' + potion.id + 'uploadimg">' +
        '<div id="' + potion.id + 'fileList" class="uploader-list"></div>' +
        '</div>'
    );
    var $list = $uploadimg.find("#" + potion.id + "fileList");
    var $addLi = $(
        '<div id="' + potion.id + 'imgPicker" class="file-item ">' +
        '<button type="button" class="btn btn-info designbtn right">点击选文件</button>' +
        '</div>'
    );
    $list.after($addLi);
 
    //不可见辑情况下 附件追加按钮隐藏 李伟民 0123
    if (!potion.visible) {
        $addLi.addClass("cfg_contentNone");
    }
    if (!potion.editable) {//不可编辑 附件追加按钮样式修改 李伟民 0123
        $addLi.find('button').addClass("disabled");
    }
    //默认图片追加
    if (potion.defaultvalueUrl != "") {
        var tmp = potion.defaultvalueUrl.split("/");//按照"/"分割
        var pp = tmp[tmp.length - 1];//获取最后一部分,即文件名和参数
        var $li = $(
            '<div class="thumbnail01">' +
            '<div class="info"><a href="' + potion.defaultvalueUrl + '" >' + pp + '</a></div>' +
            '</div>'
        );
        $list.prepend($li);
        // //单一图片的情况下 图片追加隐藏
        // if(potion.imagetype == "single"){
        //     $addLi.addClass("cfg_contentNone");
        // }
    }
    //数据编辑的情况下,数据表示
    if (arrItemReady > 0) {
        for (fileid in potion.ItemReady) {
            if (potion.ItemReady.hasOwnProperty(fileid)) {
                var fileItem = potion.ItemReady[fileid];
                // var $list = $("#"+potion.id+"fileList"),
                // var $list = $uploadimg,
                var fileDir = fileid.path;
                var suffix = fileDir.substr(fileDir.lastIndexOf(".")+1);
                console.log(fileItem.path)
                if(suffix == "mp4"){
                    $li = $(
                        '<div id="' + fileid + '" class="thumbnail01">' +
                        '<div class="frm_item_icons01">' +
                        '<div class="frm_item_icon remove" imgId="' + fileid + '">' +
                        '<img  alt=" " style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
                        '</div>' +
                        // '<img class = "fileQueuedAddItem" src = "'+fileItem.base64+'">' +
                        // '<div class="info"><a href="'+customBase.options.uploaderItem[itemId][file.id].path+'" >' + file.name + '</a></div>' +
                        '<div class="info"><a href="' + fileItem.path + '" " target="_blank">' + fileItem.oldName + '</a></div>' +
                        '</div>'
                    );
                }else{
                    $li = $(
                        '<div id="' + fileid + '" class="thumbnail01">' +
                        '<div class="frm_item_icons01">' +
                        '<div class="frm_item_icon remove" imgId="' + fileid + '">' +
                        '<img  alt=" " style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
                        '</div>' +
                        // '<img class = "fileQueuedAddItem" src = "'+fileItem.base64+'">' +
                        // '<div class="info"><a href="'+customBase.options.uploaderItem[itemId][file.id].path+'" >' + file.name + '</a></div>' +
                        '<div class="info"><a href="' + fileItem.path + '" >' + fileItem.oldName + '</a></div>' +
                        '</div>'
                    );
                }
                // $img = $li.find('.fileQueuedAddItem');
 
                $li.find(".frm_item_icon").on('click', function (event) {
                    var imgId = this.getAttribute("imgId");
                    $('#' + imgId).remove();
                    if (imgId.indexOf("WU") > -1) {
                        uploader.removeFile(imgId, true);
                    }
                    delete customBase.options.uploaderItem[itemId][imgId];
 
                    event.stopPropagation();
                    return false;
 
                });
                // $list为容器jQuery实例
                $list.prepend($li);
            }
        }
    }
 
    $uploaderItem.append($uploadimg);
    customBase.uploaderTemp += 500;
    setTimeout(function () {
        if (!potion.editable) {//不可编辑 点击无效果  李伟民 0123
           return false;
        }
        var uploader;
        var webUploaderJson = {
            // 选完文件后,是否自动上传。
            auto: true,
            // pick: '#'+potion.id+"dndArea",
            pick: '#' + potion.id + 'imgPicker',
            paste: potion.id,
            swf: '../../dist/Uploader.swf',
            // fileExt: '*.zip,*.doc,*.xls,*.mp3,*.mp4',
            // chunked:true,
            // chunkSize :true,
            fileSizeLimit: 20 * 1024 * 1024,    // 200 M
            fileSingleSizeLimit: 20 * 1024 * 1024,    // 50 M
            accept: {// 只允许选择图片文件格式
                title: 'File',
                extensions: 'zip,rar,mp3,mp4,xls,xlsx,doc,docx,ppt,pptx,rtf',
                mimeTypes: ''
            },
 
        }
        var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(potion.formid));
 
 
        // 初始化Web Uploader
        uploader = WebUploader.create(webUploaderJson);
 
        // uploader;
        uploader.on('ready', function () {
            debugger
            window.uploader = uploader;
        });
        uploader.on('error', function (type) {
            if (type == "Q_TYPE_DENIED") {
                customBase.alert("myModal", "请上传zip,rar,mp3,mp4,xls,xlsx,doc,docx,ppt,pptx,rtf格式文件", "");
            }
        });
        // 当有文件添加进来的时候
        uploader.on('fileQueued', function (file) {
            // var $list = $("#"+potion.id+"fileList"),
            var $list = $(".customViewUEditorCss #" + potion.id + "fileList"),
                $li = $(
                    '<div id="' + file.id + '" class="thumbnail01">' +
                    '<div class="frm_item_icons01">' +
                    '<div class="frm_item_icon remove" imgId="' + file.id + '">' +
                    '<img   style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
                    '</div>' +
                    // '<img class = "fileQueuedAddItem">' +
                    '<div class="info"><a  target="_blank" onclick=toastr.warning("加载中");>' + file.name + '</a>'+
                    '<span style="color:red">&nbsp;&nbsp;&nbsp;&nbsp;*加载中请勿保存</span></div>' +
                    '</div>'
                );
                $img = $li.find('.fileQueuedAddItem');
 
            $li.find(".frm_item_icon").on('click', function () {
                var imgId = this.getAttribute("imgId");
                $('#' + imgId).remove();
                if (imgId.indexOf("WU") > -1) {
                    uploader.removeFile(imgId, true);
                }
                delete customBase.options.uploaderItem[itemId][imgId];
 
                event.stopPropagation();
                return false;
            });
            // $list为容器jQuery实例
            $list.prepend($li);
        });
        // 文件上传过程中创建进度条实时显示。
        uploader.on('uploadProgress', function (file, percentage) {
        });
 
        // 文件上传成功,给item添加成功class, 用样式标记上传成功。
        uploader.on('uploadSuccess', function (file, response) {
            //////console.log(file);
            //////console.log(response);
 
            $("#" + itemId + "mesageErrDiv").remove();
            $(".customViewUEditorCss  #" + itemId).popover('hide')
 
            $('#' + file.id).addClass('upload-state-done');
            customBase.options.uploaderItem[itemId][file.id] = response.data;
            $('#' + file.id).find("a")[0].setAttribute("href", response.data.path);
             $('#' + file.id).find("a")[0].onclick=null;
            customBase.alert("S","上传成功");
            $('#' + file.id).find("span")[0].remove();
            // .attr("href",response.data.path);
        });
 
        // 文件上传失败,显示上传出错。
        uploader.on('uploadError', function (file) {
            var $li = $('#' + file.id),
                $error = $li.find('div.error');
 
            // 避免重复创建
            if (!$error.length) {
                $error = $('<div class="error"></div>').appendTo($li);
            }
            $('#' + file.id).find("a")[0].onclick=null;
            $('#' + file.id).find("span")[0].remove();
            $error.text('上传失败');
        });
 
        // 完成上传完了,成功或者失败,先删除进度条。
        uploader.on('uploadComplete', function (file) {
            $('#' + file.id).find('.progress').remove();
        });
    }, customBase.uploaderTemp);
}
//图片上传
customBase.uploaderShow = function (potion) {
    var customShowFlag = window.localStorage.getItem("customShowFlag")
    console.log(customShowFlag);
    console.log(customBase.options);
    console.log(customShow.options.customItemShow.item);
    var customItem = customShow.options.customItemShow.item;
    //////console.log(potion);
    var itemId = potion.id;
    // var uploader;
    customBase.options.uploaderItem[itemId] = {};
    var arrItemReady = 0;
    if (potion.ItemReady != undefined) {
        arrItemReady = Object.keys(potion.ItemReady).length;
        customBase.options.uploaderItem[itemId] = potion.ItemReady;
    }
    var $uploaderItem = $(".customViewUEditorCss #" + potion.id);
    $uploaderItem.empty();
    var $uploadimg = $(
        '<div id="' + potion.id + 'uploadimg">' +
        '<div id="' + potion.id + 'fileList" class="uploader-list"></div>' +
        '</div>'
    );
    var $list = $uploadimg.find("#" + potion.id + "fileList");
    console.log($('#' + itemId))
    var $addLi = $(
        '<div id="' + potion.id + 'imgPicker" class="file-item thumbnail">' +
        '<div  style="background:url(./../../formEngine/resources/css/image.png) no-repeat ;width: 100px;height: 100px;>"  </div>' +
        '</div>'
    );
    $list.prepend($addLi);
    // //不可编辑情况下 图片追加隐藏
    // if (!potion.editable) {
    //     $addLi.addClass("cfg_contentNone");
    // }
    //不可见辑情况下 图片追加按钮隐藏 李伟民 0123
    if (!potion.visible) {
        $addLi.addClass("cfg_contentNone");
    }
    if (!potion.editable) {//不可编辑 图片追加样式修改 李伟民 0123
        $addLi.css("cursor","not-allowed")
    }
    //默认图片追加
    if (potion.defaultvalueUrl != "") {
        var $li = $(
            '<div class="file-item thumbnail">' +
            '<img src="' + potion.defaultvalueUrl + '"' +
            '</div>'
            // `<div class="file-item thumbnail">
            //     <img src="${potion.defaultvalueUrl}" data-original="${otion.defaultvalueUrl}"
            // </div>`
        );
        $list.prepend($li);
        //单一图片的情况下 图片追加隐藏
        if (potion.imagetype == "single") {
            $addLi.addClass("cfg_contentNone");
        }
    }
    //数据编辑的情况下,数据表示
    console.log(arrItemReady)
    if (arrItemReady > 0) {
        console.log(potion.ItemReady)
        for (fileid in potion.ItemReady) {
            if (potion.ItemReady.hasOwnProperty(fileid)) {
                var fileItem = potion.ItemReady[fileid];
                // var $list = $("#"+potion.id+"fileList"),
                // var $list = $uploadimg,
                var $li = $(
                    '<div id="' + fileid + '" class="file-item thumbnail">' +
                    '<img alt=" " class = "fileQueuedAddItem" src = "1' + fileItem.path + '"  data-original ="' + fileItem.path + '" >' +
                    '<div class="frm_item_icons">' +
                    '<div class="frm_item_icon remove" imgId="' + fileid + '">' +
                    // '<img  style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
                    '<div  style="width:14px;height:14px;background:url(../../formEngine/resources/css/img/icon/delete.png);"> </div></div>' +
 
                    '</div>' +
                    // '<div class="info">' + file.name + '</div>' +
                    '</div>'
                );
 
 
                $li.find(".frm_item_icon").on('click', function () {
                    var imgId = this.getAttribute("imgId");
                    $('#' + imgId).remove();
                    if (imgId.indexOf("WU") > -1) {
                        uploader.removeFile(imgId, true);
                    }
                    delete customBase.options.uploaderItem[itemId][imgId];
                    //单一图片的情况下 图片追加隐藏
                    if (potion.imagetype == "single") {
                        $addLi.removeClass("cfg_contentNone");
                    }
                    console.log($(this))
                    event.stopPropagation();
                });
                // $list为容器jQuery实例
                $list.prepend($li);
                console.log($('#customShow').children())
 
            }
        }
    }
    //单一图片的情况下 图片追加隐藏
    if (arrItemReady > 0 && potion.imagetype == "single") {
        setTimeout(function () {
            $addLi.addClass("cfg_contentNone");
        }, 10);
        console.log($('#customShow').children())
 
    }
 
    $uploaderItem.append($uploadimg);
    customBase.uploaderTemp += 500;
    setTimeout(function () {
        if (!potion.editable) {//不可编辑 取消点击事件 李伟民 0123
           return false;
        }
        var uploader;
        //发布页面 多选图片 曲辰明 3-27
        if (potion.imagetype == "single") {
            var webUploaderJson = {
                // 选完文件后,是否自动上传。
                auto: true,
                // pick: '#'+potion.id+"dndArea",
                pick: {
                    id: '#' + potion.id + 'imgPicker',
                    multiple: false//禁止多选
                },
                paste: potion.id,
                swf: '../../dist/Uploader.swf',
            }
        }else{
            var webUploaderJson = {
                // 选完文件后,是否自动上传。
                auto: true,
                // pick: '#'+potion.id+"dndArea",
                pick: {
                    id: '#' + potion.id + 'imgPicker',
                    multiple: true//多选
                },
                paste: potion.id,
                swf: '../../dist/Uploader.swf',
            }
        }
        var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(potion.formid));
 
 
        // 初始化Web Uploader
        uploader = WebUploader.create(webUploaderJson);
 
        // uploader;
        uploader.on('ready', function () {
            window.uploader = uploader;
        });
        // 当有文件添加进来的时候
        uploader.on('fileQueued', function (file) {
            // var $list = $("#"+potion.id+"fileList"),
            var $list = $(".customViewUEditorCss #" + potion.id + "fileList"),
                $li = $(
                    '<div id="' + file.id + '" class="file-item thumbnail">' +
                    '<div class="frm_item_icons">' +
                    '<div class="frm_item_icon remove" imgId="' + file.id + '">' +
                    '<div  style="width:14px;height:14px;background:url(../../formEngine/resources/css/img/icon/delete.png)"></div></div>' +
                    '</div>' +
                    '<img  class = "fileQueuedAddItem">' +
                    // '<div class="info">' + file.name + '</div>' +
                    '</div>'
                ),
                $img = $li.find('.fileQueuedAddItem');
 
            $li.find(".frm_item_icon").on('click', function () {
                var imgId = this.getAttribute("imgId");
                $('#' + imgId).remove();
                if (imgId.indexOf("WU") > -1) {
                    uploader.removeFile(imgId, true);
                }
                delete customBase.options.uploaderItem[itemId][imgId];
                //单一图片的情况下 图片追加隐藏
                if (potion.imagetype == "single") {
                    $addLi.removeClass("cfg_contentNone");
                }
 
                event.stopPropagation();
 
            });
            // $list为容器jQuery实例
            $list.prepend($li);
 
            //单一图片的情况下 图片追加隐藏
            if (potion.imagetype == "single") {
                $addLi.addClass("cfg_contentNone");
            }
 
            // 创建缩略图
            // 如果为非图片文件,可以不用调用此方法。
            // thumbnailWidth x thumbnailHeight 为 100 x 100
            uploader.makeThumb(file, function (error, src) {
                if (error) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }
                // //////console.log(customBase.options.uploaderItem[itemId][file.id]);
                // customBase.options.uploaderItem[itemId][file.id]["base64"] = src;
                $img.attr('src', src);
                // 12/21
                console.log($img)
                $img.attr('data-original', src);
                // 发布页面查看大图  曲辰明 3-27
                var viewer = new Viewer(document.getElementById(potion.id), {
                    url: 'data-original',
                    movable: false
                });
            }, 400, 400);
        });
        // 文件上传过程中创建进度条实时显示。
        uploader.on('uploadProgress', function (file, percentage) {
            var $li = $('#' + file.id),
                $percent = $li.find('.progress span');
 
            // 避免重复创建
            if (!$percent.length) {
                $percent = $('<p class="progress"><span></span></p>')
                    .appendTo($li)
                    .find('span');
            }
            //////console.log(percentage);
            $percent.css('width', percentage * 100 + '%');
        });
 
        // 文件上传成功,给item添加成功class, 用样式标记上传成功。
        uploader.on('uploadSuccess', function (file, response) {
            //////console.log(file);
            //////console.log(response);
            $('#' + file.id).addClass('upload-state-done');
            // customBase.options.uploaderFileName[file.id] = response.data;
            customBase.options.uploaderItem[itemId][file.id] = response.data;
            // //////console.log(customBase.options.uploaderItem[itemId][file.id]);
            customBase.options.uploaderItem[itemId][file.id]["base64"] = $("#" + file.id + " .fileQueuedAddItem")[0].getAttribute("src");
        });
 
        // 文件上传失败,显示上传出错。
        uploader.on('uploadError', function (file) {
            var $li = $('#' + file.id),
                $error = $li.find('div.error');
 
            // 避免重复创建
            if (!$error.length) {
                $error = $('<div class="error"></div>').appendTo($li);
            }
 
            $error.text('上传失败');
        });
 
        // 完成上传完了,成功或者失败,先删除进度条。
        uploader.on('uploadComplete', function (file) {
            $('#' + file.id).find('.progress').remove();
        });
    }, customBase.uploaderTemp);
    // 12/19
    console.log($uploadimg)
    console.log($('#customViewUEditor').find('#itemId_1').children())
 
    var $uploaderItems = $($("#customViewUEditor #" + potion.id)[0]);
    var imgId = $uploaderItems.attr('id');
    var srcUrl = $uploaderItems.find('img').attr('src');
    // $uploaderItem.find('img').attr('data-original',srcUrl);
    console.log($('#' + imgId).children().children())
 
    console.log($('#' + imgId).find('#itemId_1fileList').find('label'))
    $('#' + imgId).find('#itemId_1fileList').find('label').css({
        'height': '150px',
        'width': '150px'
    })
    var id = $('#' + imgId).children().children().attr('id')
    //编辑
    var viewer = new Viewer(document.getElementById(id), {
        url: 'data-original',
        movable: false
    });
    console.log($('#customShow').children())
    console.log($("[style='opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255)']"))
}
 
 
//图片上传
customBase.uploaderShow_Temp = function (itemId, chunkSize, imgFlag, formID) {
    if (chunkSize.width != 0) {
        $(itemId + 'dndArea')[0].style.width = chunkSize.width + 'px';
        $(itemId + 'dndArea')[0].style.height = chunkSize.height + 'px';
    }
 
    var $wrap = $(itemId),
        // 图片容器
        $queue = $('<ul class="filelist"></ul>').appendTo($wrap.find('.queueList')),
        // 状态栏,包括进度和控制按钮
        $statusBar = $wrap.find('.statusBar'),
        // 文件总体选择信息。
        $info = $statusBar.find('.info'),
        // 上传按钮
        $upload = $wrap.find('.uploadBtn'),
        // 没选择文件之前的内容。
        $placeHolder = $wrap.find('.placeholder'),
 
        $progress = $statusBar.find('.progress').hide(),
        // 添加的文件数量
        fileCount = 0,
        // 添加的文件总大小
        fileSize = 0,
        // 优化retina, 在retina下这个值是2
        ratio = window.devicePixelRatio || 1,
        // 缩略图大小
        thumbnailWidth = 110 * ratio,
        thumbnailHeight = 110 * ratio,
        // 可能有pedding, ready, uploading, confirm, done.
        state = 'pedding',
        // 所有文件的进度信息,key为file id
        percentages = {},
        // 判断浏览器是否支持图片的base64
        isSupportBase64 = (function () {
            var data = new Image();
            var support = true;
            data.onload = data.onerror = function () {
                if (this.width != 1 || this.height != 1) {
                    support = false;
                }
            }
            data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
            return support;
        })(),
        // 检测是否已经安装flash,检测flash的版本
        flashVersion = (function () {
            var version;
 
            try {
                version = navigator.plugins['Shockwave Flash'];
                version = version.description;
            } catch (ex) {
                try {
                    version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
                        .GetVariable('$version');
                } catch (ex2) {
                    version = '0.0';
                }
            }
            version = version.match(/\d+/g);
            return parseFloat(version[0] + '.' + version[1], 10);
        })(),
 
        supportTransition = (function () {
            var s = document.createElement('p').style,
                r = 'transition' in s ||
                    'WebkitTransition' in s ||
                    'MozTransition' in s ||
                    'msTransition' in s ||
                    'OTransition' in s;
            return r;
        })(),
        //创建
        uploader;
 
    if (!WebUploader.Uploader.support('flash') && WebUploader.browser.ie) {
        // flash 安装了但是版本过低。
        if (flashVersion) {
            (function (container) {
                window['expressinstallcallback'] = function (state) {
                    switch (state) {
                        case 'Download.Cancelled':
                            customBase.alert("M", '您取消了更新!')
                            break;
 
                        case 'Download.Failed':
                            customBase.alert("M", '安装失败')
                            break;
 
                        default:
                            customBase.alert("M", '安装已成功,请刷新!');
                            break;
                    }
                    delete window['expressinstallcallback'];
                };
 
                var swf = './expressInstall.swf';
                // insert flash object
                var html = '<object type="application/' +
                    'x-shockwave-flash" data="' + swf + '" ';
 
                if (WebUploader.browser.ie) {
                    html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
                }
 
                html += 'width="100%" height="100%" style="outline:0">' +
                    '<param name="movie" value="' + swf + '" />' +
                    '<param name="wmode" value="transparent" />' +
                    '<param name="allowscriptaccess" value="always" />' +
                    '</object>';
 
                container.html(html);
 
            })($wrap);
 
            // 压根就没有安转。
        } else { }
 
        return;
    } else if (!WebUploader.Uploader.support()) {
        customBase.alert("M", 'Web Uploader 不支持您的浏览器!');
        return;
    }
    if (imgFlag) {
        labelTemp = '点击选择图片'
    } else {
        labelTemp = '点击选择文件'
    }
 
 
 
    ;
    var webUploaderJson = {
        pick: {
            id: itemId + 'filePicker',
            label: labelTemp
        },
        dnd: itemId + 'dndArea',
        paste: itemId,
        swf: '../../dist/Uploader.swf',
        chunked: false,
        chunkSize: 512 * 1024,
        // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候,把图片打开。
        disableGlobalDnd: true,
        fileNumLimit: 300,
        fileSizeLimit: 200 * 1024 * 1024,    // 200 M
        fileSingleSizeLimit: 50 * 1024 * 1024    // 50 M
    }
    var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(formID));
 
    // 实例化
    uploader = WebUploader.create(webUploaderJson);
 
    // 拖拽时不接受 js, txt 文件。
    uploader.on('dndAccept', function (items) {
        var denied = false,
            len = items.length,
            i = 0,
            // 修改js类型
            unAllowed = 'text/plain;application/javascript ';
 
        for (; i < len; i++) {
            // 如果在列表里面
            if (~unAllowed.indexOf(items[i].type)) {
                denied = true;
                break;
            }
        }
 
        return !denied;
    });
 
    // 添加“添加文件”的按钮,
    uploader.addButton({
        id: itemId + 'filePicker2',
        label: '继续添加'
    });
    //文件读取
    uploader.on('ready', function () {
        window.uploader = uploader;
        $queue.empty();
        var json = customBase.options.uploaderItemReady[itemId.replace("#", "")];
        if (json == undefined) {
            json = [];
        }
        var jsonLen = json.length;
        if (jsonLen != 0) {
            fileCount = jsonLen;
            $placeHolder.addClass('element-invisible');
            $statusBar.show();
            //显示在页面上
            $.each(json, function (i, n) {
                fileSize += n.filelen;
                var obj = {}, statusMap = {}
                    , file_id = 'WU_FILE_' + i;
                obj.id = file_id;
                obj.name = n.filebasename;
                obj.filename = n.filename;
                obj.getStatus = function () {
                    return '';
                };
                obj.statusText = '';
                obj.size = n.filelen;
                obj.version = WebUploader.Base.version;
                obj.type = n.mimeType;
                obj.filetype = n.filetype;
                obj.source = this;
                obj.path = n.filePath.path;
                obj.setStatus = function (status, text) {
 
                    var prevStatus = statusMap[this.id];
 
                    typeof text !== 'undefined' && (this.statusText = text);
 
                    if (status !== prevStatus) {
                        statusMap[this.id] = status;
                        /**
                         * 文件状态变化
                         * @event statuschange
                         */
                        uploader.trigger('statuschange', status, prevStatus);
                    }
                };
                editFile(obj);
                $("#" + file_id).append(inputStr(i, n));
            });
 
            WebUploader.Base.idSuffix = jsonLen;
 
            setState('ready');
            updateTotalProgress();
        }
        // },'json');
    });
 
    function inputStr(index, json) {
        var inputStr = '';
        var pre = itemId;
        //转化格式后的名称
        inputStr += '<input name="' + pre + 'list[' + index + '].filename"   value="' + json.filename + '" style="display:none"/>';
        //保存路径
        inputStr += '<input name="' + pre + 'list[' + index + '].filepath"   value="' + json.filepath + '" style="display:none"/>';
        //文件源名称
        inputStr += '<input name="' + pre + 'list[' + index + '].filebasename"   value="' + json.filebasename + '" style="display:none"/>';
 
        //文件类型  doc?xls?
        inputStr += '<input name="' + pre + 'list[' + index + '].filetype"   value="' + json.filetype + '" style="display:none"/>';
        //文件大小
        inputStr += '<input name="' + pre + 'list[' + index + '].filelen"   value="' + json.filelen + '" style="display:none"/>';
        //doc转为html
        inputStr += '<input name="' + pre + 'list[' + index + '].doc2htmlpath" value="' + json.doc2htmlpath + '"  style="display:none"/>';
        //mimeType
        inputStr += '<input name="' + pre + 'list[' + index + '].mimeType" value="' + json.mimeType + '"  style="display:none"/>';
        return inputStr;
    }
 
    function editFile(file) {
        if (imgFlag) {
            var $li = $('<li id="' + file.id + '" class="imgfileLiShow">' +
                '<p class="title">' + file.name + '</p>' +
                '<p class="imgWrap"></p>' +
                '<p class="progress"><span></span></p>' +
                '</li>'),
 
                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>' +
                    '<span class="rotateRight">向右旋转</span>' +
                    '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
 
                $wrap = $li.find('p.imgWrap')
 
        } else {
            var $li = $('<li id="' + file.id + '">' +
                '<div class="title" style="word-break:break-all;text-align:left;font-size:16px">' + file.filename + '</div>' +
 
                '</li>'),
                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>'
 
                    + '</div>'
                ).appendTo($li),
 
                $wrap = $li.find('p.imgWrap')
        }
 
        if (file.getStatus() === 'invalid') {
            showError(file.statusText);
        } else {
            // @todo lazyload
            $wrap.empty();
            $wrap.text('不能预览');
 
            var img;
            //判断是否是图片
            src = file.path;
            img = $('<img  src="' + src + '" style="height:100%;">');
            $wrap.empty().append(img);
 
            percentages[file.id] = [file.size, 0];
            file.rotation = 0;
        }
 
 
 
        $li.append('<span class="success"></span>');
 
        $li.on('mouseenter', function () {
            $btns.stop().animate({ height: 30 });
        });
 
        $li.on('mouseleave', function () {
            $btns.stop().animate({ height: 0 });
        });
 
        $btns.on('click', 'span', function () {
            var index = $(this).index(),
                deg;
 
            switch (index) {
                case 0:
                    // uploader.removeFile( file );
                    return;
 
                case 1:
                    file.rotation += 90;
                    break;
 
                case 2:
                    file.rotation -= 90;
                    break;
            }
 
            if (supportTransition) {
                deg = 'rotate(' + file.rotation + 'deg)';
                $wrap.css({
                    '-webkit-transform': deg,
                    '-mos-transform': deg,
                    '-o-transform': deg,
                    'transform': deg
                });
            } else {
                $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
            }
 
 
        });
 
        $li.appendTo($queue);
    }
 
 
    // 当有文件添加进来时执行,负责view的创建
    if (imgFlag) { }
    function addFile(file) {
        if (imgFlag) {
            var $li = $('<li id="' + file.id + '" class="imgfileLiShow">' +
                '<p class="title">' + file.name + '</p>' +
                '<p class="imgWrap"></p>' +
                '<p class="progress"><span></span></p>' +
                '</li>'),
 
                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>' +
                    '<span class="rotateRight">向右旋转</span>' +
                    '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
                $prgress = $li.find('p.progress span'),
                $wrap = $li.find('p.imgWrap'),
                $info = $('<p class="error"></p>')
        } else {
            var $li = $('<li id="' + file.id + '">' +
                '<div class="title" style="word-break:break-all;text-align:left;font-size:16px">' + file.name + '</div>' +
                '</li>'),
 
                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>' +
                    '</div>'
                ).appendTo($li),
                $prgress = $li.find('p.progress span'),
                $wrap = $li.find('p.imgWrap'),
                $info = $('<p class="error"></p>')
        }
 
 
        showError = function (code) {
            switch (code) {
                case 'exceed_size':
                    text = '文件大小超出';
                    break;
 
                case 'interrupt':
                    text = '上传暂停';
                    break;
 
                default:
                    text = '上传失败,请重试';
                    break;
            }
 
            $info.text(text).appendTo($li);
        };
 
        if (file.getStatus() === 'invalid') {
            showError(file.statusText);
        } else {
            // @todo lazyload
            $wrap.text('预览中');
            uploader.makeThumb(file, function (error, src) {
                var img;
 
                if (error) {
                    $wrap.text('不能预览');
                    return;
                }
                if (isSupportBase64) {
                    img = $('<img src="' + src + '">');
                    $wrap.empty().append(img);
                } else {
 
                }
            }, thumbnailWidth, thumbnailHeight);
 
            percentages[file.id] = [file.size, 0];
            file.rotation = 0;
        }
 
        file.on('statuschange', function (cur, prev) {
            if (prev === 'progress') {
                $prgress.hide().width(0);
            } else if (prev === 'queued') {
                $li.off('mouseenter mouseleave');
                $btns.remove();
            }
 
            // 成功
            if (cur === 'error' || cur === 'invalid') {
                //////////console.log( file.statusText );
                showError(file.statusText);
                percentages[file.id][1] = 1;
            } else if (cur === 'interrupt') {
                showError('interrupt');
            } else if (cur === 'queued') {
                percentages[file.id][1] = 0;
            } else if (cur === 'progress') {
                $info.remove();
                $prgress.css('display', 'block');
            } else if (cur === 'complete') {
                $li.append('<span class="success"></span>');
            }
 
            $li.removeClass('state-' + prev).addClass('state-' + cur);
        });
 
        $li.on('mouseenter', function () {
            $btns.stop().animate({ height: 30 });
        });
 
        $li.on('mouseleave', function () {
            $btns.stop().animate({ height: 0 });
        });
 
        $btns.on('click', 'span', function () {
            var index = $(this).index(),
                deg;
 
            switch (index) {
                case 0:
                    uploader.removeFile(file);
                    return;
 
                case 1:
                    file.rotation += 90;
                    break;
 
                case 2:
                    file.rotation -= 90;
                    break;
            }
 
            if (supportTransition) {
                deg = 'rotate(' + file.rotation + 'deg)';
                $wrap.css({
                    '-webkit-transform': deg,
                    '-mos-transform': deg,
                    '-o-transform': deg,
                    'transform': deg
                });
            } else {
                $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
            }
 
 
        });
 
        $li.appendTo($queue);
    }
 
    // 负责view的销毁
    function removeFile(file) {
        var $li = $('#' + file.id);
 
        delete percentages[file.id];
        updateTotalProgress();
        $li.off().find('.file-panel').off().end().remove();
    }
 
    function updateTotalProgress() {
        var loaded = 0,
            total = 0,
            spans = $progress.children(),
            percent;
 
        $.each(percentages, function (k, v) {
            total += v[0];
            loaded += v[0] * v[1];
        });
 
        percent = total ? loaded / total : 0;
 
 
        spans.eq(0).text(Math.round(percent * 100) + '%');
        spans.eq(1).css('width', Math.round(percent * 100) + '%');
        updateStatus();
    }
 
    function updateStatus() {
        var text = '', stats;
 
        if (state === 'ready') {
            if (imgFlag) {
                text = '选中' + fileCount + '张图片,共' + WebUploader.formatSize(fileSize) + '。';
            } else {
                text = '选中' + fileCount + '个文件,共' + WebUploader.formatSize(fileSize) + '。';
            }
 
        } else if (state === 'confirm') {
            stats = uploader.getStats();
            if (stats.uploadFailNum) {
                if (imgFlag) {
                    text = '已成功上传' + stats.successNum + '张照片至XX相册,' +
                        stats.uploadFailNum + '张照片上传失败,<a class="retry" href="#">重新上传</a>失败图片或<a class="ignore" href="#">忽略</a>'
                } else {
                    text = '已成功上传' + stats.successNum + '个文件至XX文件夹,' +
                        stats.uploadFailNum + '个文件上传失败,<a class="retry" href="#">重新上传</a>失败文件或<a class="ignore" href="#">忽略</a>'
                }
            }
 
        } else {
            stats = uploader.getStats();
            if (imgFlag) {
                text = '共' + fileCount + '张(' +
                    WebUploader.formatSize(fileSize) +
                    '),已上传' + stats.successNum + '张';
 
                if (stats.uploadFailNum) {
                    text += ',失败' + stats.uploadFailNum + '张';
                }
            } else {
                text = '共' + fileCount + '个文件(' +
                    WebUploader.formatSize(fileSize) +
                    '),已上传' + stats.successNum + '个文件';
 
                if (stats.uploadFailNum) {
                    text += ',失败' + stats.uploadFailNum + '个文件';
                }
            }
 
        }
 
        $info.html(text);
    }
 
    function setState(val) {
        var file, stats;
 
        if (val === state) {
            return;
        }
 
        $upload.removeClass('state-' + state);
        $upload.addClass('state-' + val);
        state = val;
 
        switch (state) {
            case 'pedding':
                $placeHolder.removeClass('element-invisible');
                $queue.hide();
                $statusBar.addClass('element-invisible');
                uploader.refresh();
                break;
 
            case 'ready':
                $placeHolder.addClass('element-invisible');
                $('#filePicker2').removeClass('element-invisible');
                $queue.show();
                $statusBar.removeClass('element-invisible');
                uploader.refresh();
                break;
 
            case 'uploading':
                $('#filePicker2').addClass('element-invisible');
                $progress.show();
                $upload.text('暂停上传');
                break;
 
            case 'paused':
                $progress.show();
                $upload.text('继续上传');
                break;
 
            case 'confirm':
                $progress.hide();
                $('#filePicker2').removeClass('element-invisible');
                $upload.text('开始上传');
 
                stats = uploader.getStats();
                if (stats.successNum && !stats.uploadFailNum) {
                    setState('finish');
                    return;
                }
                break;
            case 'finish':
                stats = uploader.getStats();
                if (stats.successNum) {
                    var strMessage = customBase.getMessage("mesage_ID005");
                    customBase.alert("S", strMessage);
                    // alert( '上传成功' );
                } else {
                    // 没有成功的图片,重设
                    state = 'done';
                    location.reload();
                }
                break;
        }
 
        updateStatus();
    }
 
    uploader.onUploadProgress = function (file, percentage) {
        var $li = $('#' + file.id),
            $percent = $li.find('.progress span');
 
        $percent.css('width', percentage * 100 + '%');
        percentages[file.id][1] = percentage;
        updateTotalProgress();
        customBase.options.uploaderItem[itemId] = uploader.getFiles();
    };
 
    uploader.onFileQueued = function (file) {
        fileCount++;
        fileSize += file.size;
 
        if (fileCount === 1) {
            $placeHolder.addClass('element-invisible');
            $statusBar.show();
        }
 
        addFile(file);
        setState('ready');
        updateTotalProgress();
    };
 
    uploader.onFileDequeued = function (file) {
        fileCount--;
        fileSize -= file.size;
 
        if (!fileCount) {
            setState('pedding');
        }
 
        removeFile(file);
        updateTotalProgress();
 
    };
 
    uploader.on('all', function (type) {
        var stats;
        switch (type) {
            case 'uploadFinished':
                setState('confirm');
                break;
 
            case 'startUpload':
                setState('uploading');
                break;
 
            case 'stopUpload':
                setState('paused');
                break;
 
        }
    });
 
    uploader.onError = function (code) {
        customBase.alert("M", 'Eroor: ' + code);
    };
 
    $upload.on('click', function () {
        if ($(this).hasClass('disabled')) {
            return false;
        }
        if (state === 'ready') {
            uploader.upload();
            uploader.on('uploadSuccess', function (file, response) {
                customBase.options.uploaderFileName[response.data.oldName] = response.data;
            })
        } else if (state === 'paused') {
            uploader.upload();
        } else if (state === 'uploading') {
            uploader.stop();
        }
    });
 
    $info.on('click', '.retry', function () {
        uploader.retry();
    });
 
    $info.on('click', '.ignore', function () {
        customBase.alert("M", 'todo');
    });
 
    $upload.addClass('state-' + state);
    updateTotalProgress();
}
 
//得到金融控件的HTMLL
customBase.getAmountHtml = function (sizeWidthHeight, flag) {
    var width = sizeWidthHeight.width;
    var linewidth = (width - 10) / 11;
    var item = sizeWidthHeight.defaultvalue;
    var height = sizeWidthHeight.height;
    var lineheight = parseInt(height) + 20;
    var margin_top = '-20';
    var itemTemp = item.split("");
    var items = [];
    var nbsp = '';
 
    if (flag) {
        nbsp = 'nbsp';
    } else {
        nbsp = '&nbsp;';
        margin_top = '10';
    }
    for (var i = 0; i < 11; i++) {
        items[i] = nbsp;
    };
    for (var i = 0; i < itemTemp.length; i++) {
        items[11 - i - 1] = itemTemp[itemTemp.length - i - 1];
    };
 
    var oNode = '<div style="width:' + (width) + 'px;">';
    oNode += '<hr style="float:left;width: 1px;height:' + lineheight + 'px;margin-top:' + margin_top + 'px;border: #fff;"/>';
    if (items[0] == "nbsp") {
        // items[0] = " ";
        oNode += '<span style="width:' + (linewidth) + ';float:left;line-height:' + height + 'px;color:#fff;">' + '&#160;' + '</span>';
    } else {
        oNode += '<span style="width:' + (linewidth) + ';float:left;line-height:' + height + 'px;">' + items[0] + '</span>';
    }
 
    var hrcolor = "";
    for (var i = 0; i < 10; i++) {
        if (i == 2 || i == 5) {
            hrcolor = '#31b0d5';
        } else if (i == 8) {
            hrcolor = '#D53137';
        } else {
            hrcolor = '#eee';
        }
        oNode += '<hr style="border:0px;background-color:' + hrcolor + ';color:' + hrcolor + ';float: left;width: 1px;height:' + lineheight + 'px;margin-top:' + margin_top + 'px;"/>';
        // oNode += '<span style="width:'+linewidth+'px;float:left;line-height:'+height+'px;">'+items[i+1]+'</span>';
        ////////////console.log(items[i+1]);
        if (items[i + 1] == "nbsp") {
            // items[0] = "0";
            oNode += '<span style="width:' + linewidth + 'px;float:left;line-height:' + height + 'px;color:#fff;">' + '&#160;' + '</span>';
        } else {
            oNode += '<span style="width:' + linewidth + 'px;float:left;line-height:' + height + 'px;">' + items[i + 1] + '</span>';
        }
 
    };
    oNode += "</div>";
    return oNode;
}
 
//条码设定
customBase.createbarcode = function (val, text, callback) {
 
    var sizeWidthHeight = { width: 88, height: 40, styleclass: "" };
    var barWidth = 1;
    var barHeight = 5;
    val = parseInt(val);
    val = val;
    if (val == 1) {
        barWidth = 1;
        barHeight = 30;
        sizeWidthHeight = { width: 88, height: 40, styleclass: "" };
    } else if (val == 2) {
        barWidth = 2;
        barHeight = 40;
        sizeWidthHeight = { width: 176, height: 50, styleclass: "" };
    } else if (val == 3) {
        barWidth = 3;
        barHeight = 50;
        sizeWidthHeight = { width: 264, height: 60, styleclass: "" };
    } else if (val == 4) {
        barWidth = 4;
        barHeight = 60;
        sizeWidthHeight = { width: 352, height: 70, styleclass: "" };
    } else if (val == 5) {
        barWidth = 5;
        barHeight = 70;
        sizeWidthHeight = { width: 440, height: 80, styleclass: "" };
    } else if (val == 6) {
        barWidth = 6;
        barHeight = 80;
        sizeWidthHeight = { width: 528, height: 90, styleclass: "" };
    }
 
    //条形码数据回调
    callback(text, barWidth, barHeight, sizeWidthHeight);
}
customBase.zTreeOnClick = function (event, treeId, treeNode) {
    console.log(this);
    console.log(event);
    console.log(treeId);
    console.log(treeNode);
 
    if (treeNode.checked) {
        // 单击事件 by kill
        if ($('#span_' + treeNode.id).val() == undefined || $('#span_' + treeNode.id).val() == "") {
            var i = $('#' + treeId).children(':first').children(':nth-child(2)').attr('class').indexOf('radio');
            if (i != -1) {
                ////console.log(i)
                ////console.log('span_'+treeId)
                $('.span_' + treeId).remove();
                $('#' + treeId.replace("tree", ""))
                    .parent().parent().children(':first').children(':nth-child(4)').remove();
            }
            //$('#'+treeId.replace("tree","")).parent().parent().children(':first')
            // .append('<span id="span_'+treeNode.id+'">|'+treeNode.name+'&nbsp</sapn>')
        }
    } else {
        $('#span_' + treeNode.id).remove();
    }
    var dofuncion = customBase.options.zTreeOnClickItems[treeId];
    if (dofuncion != undefined) {
        eval(dofuncion);
    }
};
//  2017/11/2  李元杰 单选树选中事件
customBase.zTreeOncheckRadio = function (e, treeId, treeNode) {
    //console.log($('#citySel').parents('div[name=treeWinTitle]').next().attr('id'));
 
    var zTree = $.fn.zTree.getZTreeObj(treeId);
    //console.log(zTree)
    var nodes = zTree.getCheckedNodes(true);
    var v = "";
    var dataObj = {}
    for (var i = 0, l = nodes.length; i < l; i++) {
        v += nodes[i].name + ",";
        console.log(nodes)
        dataObj[nodes[i].id] = '1'
    }
    if (v.length > 0) v = v.substring(0, v.length - 1)
    // 2017/11/6  李元杰  单选树
 
    // console.log($('#'+treeId).parents('div[name="TreeWin"]').find('.citySel'))
    // console.log(   )
 
    $(e.currentTarget).parent().attr('value', JSON.stringify(dataObj))
    $(e.currentTarget).parents('div[name="TreeWin"]').find('.citySel').val(v);
    // // cityObj.attr("value", v);
    // console.log(e);
    // console.log(treeId);
    // console.log(treeNode);
    // // $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(4)').remove();
    // console.log(  $('#'+treeId).parents('div[type="tree"]').find('h8'));
    // console.log( $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(3)'))
 
    // if(treeNode.checked){
    //     // 单击事件 by kill
    //     if($('#span_'+treeNode.id).val()==undefined||$('#span_'+treeNode.id).val()==""){
    //         //console.log($('#'+treeId))
    //       var i=$('#'+treeId).children(':first').children(':nth-child(2)').attr('class').indexOf('radio');
    //       if(i!=-1){
    //           //console.log(i)
    //           //console.log('span_'+treeId)
    //           $('.span_'+treeId).remove();
    //             $('#'+treeId.replace("tree",""))
    //             .parent().parent().children(':first').children(':nth-child(4)').remove();
    //       }
    //     }
    // }else{
    //           $('#span_'+treeNode.id).remove();
    // }
    var pitchon = `
            <span id="spanDiv'+${treeId}+'">
                 <span>|${v}</span>
            </span>
        `
    // $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(4)').remove();
    // $('#'+treeId).parents('div[type="tree"]').find('h8').append(pitchon);
    var dofuncion = customBase.options.zTreeOnClickItems[treeId];
    if (dofuncion != undefined) {
        eval(dofuncion);
    }
}
customBase.settingChkboxType = {
    check: {
        autoCheckTrigger: false,
        chkboxType: { "Y": "", "N": "" },
        chkStyle: "checkbox",
        enable: true,
        nocheckInherit: false,
        radioType: "level"
    },
    view: {
        showIcon: false,
        showLine: false,
        txtSelectedEnable: true,
    },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pId",
            rootPId: 0
        }
    },
    callback: {
        onClick: customBase.zTreeOnClick,
        onCheck: customBase.zTreeOncheckRadio,
    }
}
 
customBase.settingRadioType = {
    check: {
        enable: true,
        chkStyle: "radio",
        radioType: "all",
    },
    view: {
        showIcon: false,
        showLine: false,
        txtSelectedEnable: true,
    },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pId",
            rootPId: 0
        }
    },
    callback: {
        onClick: customBase.zTreeOnClick,
        onCheck: customBase.zTreeOncheckRadio,
    }
}
 
 
 
customBase.zNodes = [{ name: "树控件", isParent: true }];
var customShow = customShow || {};
 
customShow.button = {
    //基础字段
    printableBtn: { name: "打印", cssName: 'icon iconfont icon-dayin1 ', functionName: "customShow.onPrint" },
    exportBtn: { name: "导出", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "" },
    rejectBtn: { name: "驳回", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.rejectBtn" },
    submitBtn: { name: "提交", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickSubmit" },
    auditableBtn: { name: "审批", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.auditableBtn" },
    queryBtn: { name: "查询", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "" },
    createBtn: { name: "新建", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickSave1" },
    clearBtn: { name: "清空", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickClear" },
    disposableBtn: { name: "取消", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: 'customShow.onclickCancel' },
    //fromSaveBtn: { name: "保存", cssName: 'icon iconfont icon-bianji ', functionName: "customShow.onclickSave2" },
    editableBtn: { name: "编辑", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onEditor" },
    //添加权限按钮  马习同  2017-12-14
    billuploadingBtn: { name: "票据上传", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.billuploading" },
    reuploadBtn: { name: "重新上传票据", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.reupload" },
    checkbillBtn: { name: "查看票据", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.checkbill" },
}
console.log(Flatpickr)
Flatpickr.localize(Flatpickr.l10ns.zh); // 设置为中文
customShow.options = {
    customItem: {},
    customViewDiv: "",
    customInit: {},
    htmlediterShow: {},
    attributeList: {}, //属性一览
    // editorFlag:true,
    formID: "",        //表单ID
    customShowFlag: "",//调用标识
    dataRowNum: "",    //更新行番号
    breakFlag: false,  //父画面刷新
    datasource: {},
    customItemShow: {},
    initTempDatas: {},  //临时初始化数据
    itemFormbase: "",
    jsonLinkage: {}, //公式用
    btnFlag: { editable: "1", printable: "1", auditable: "0", disposable: "0" }, //按钮表示
    subformList: {}, //子表单List
    subformDList: {},
    dropdownlist_I: 0,
    subformDValue: {},
    formsetting: {},
    showErrId: {},
    // LinkageAnalysisSetValueFlag:false
}
 
customShow.initEvent = {
    //--------------------保存Button事件------------------------
    //画面check
    fromCheck: function (items, callback) {
        return customShow.onfromCheck(items);
        ////console.log(1)
    },
    //03检证执行
    validationRuleCheck: function (items, callback) { return true },
    //检证接口函数(第三口)
    validationRuleCheck3rd: function (items, callback) { return customShow.interfaceCheck(items) },//保存前计算费用  李伟民   10 - 31
    //发送数据到后台服务器,保存data
    fromSave: function (items, callback) {
 
    },
    //发送数据到后台服务器,保存data
    fromSave3rd: function (items, callback) { return true },
    fromSaveLinkage: function (items, callback) { return true },
    //--------------------保存Button事件------------------------
    //--------------------初期化事件----------------------------
    //01接口绑定:接口名 接口变量名 自定义函数
    interfaceBind: [],
    //02事件绑定:字段别名 字段类型 事件名 自定义事件名
    // eventBind:[{fieldKey:"项目1",tag:"text",eventName:"click",functionName:"customShow.clickBindBase001"}],
    eventBind: [],
    //初期化接口
    interfaceInit: function (customShowFlag) {
        //表示模式
        console.log(customShowFlag)
        if (customShowFlag == 2) {
            customShow.controlInit("customViewUEditorCss");
            //控件初始化
            customShow.controlInit("customShow");
        } else {
            //控件初始化
            customShow.controlInit("customViewUEditorCss");
        }
        //事件初始化
        customShow.clickBind();
        //  12/14
        if (customShowFlag == 1) {
            // customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType','cookie');
            SC.autoFieldKey();
        }
    },
    interfaceInit3rd: function (customShowFlag) { return true },
    //验证初期公式
    interfaceInitLinkage: function (customShowFlag) { return true },
    //密码输入
    passwordInputFlag: function (items, callback) { },
    //--------------------初期化事件----------------------------
    //--------------------取消事件----------------------------
    //取消接口
    cancelEvent: function (items, callback) { },
    //取消接口(第三方提供)
    cancelEvent3rd: function (items, callback) { return true },
    //取消接口
    cancelEventLinkage: function () { return true },
    //--------------------取消事件----------------------------
    //--------------------印刷事件----------------------------
    interfaceprint: function (items, callback) { },
    interfaceprint3rd: function (items, callback) { return true },
    //--------------------印刷事件----------------------------
}
 
function getProcessLog() {//获得流程信息 李雁鸣  12-25
    localStorage.setItem("processLog", null);
    if (localStorage.getItem("customItem") != undefined && localStorage.getItem("customItem") != "undefined" && localStorage.getItem("customItem") != null && localStorage.getItem("customItem") != "" && localStorage.getItem("customItem") != null) {
        var ss = { "formID": JSON.parse(localStorage.getItem("customForm")).newFormID, "dataRowNum": JSON.parse(localStorage.getItem("customItem")).DATAROWNUM };
        var requestSingleForm = window.commonAjax("/ubp-api-seache/process/inst/log", ss, "POST", true, false);
        requestSingleForm.done(function (rs) {
            console.log(rs.data);
            console.log("新改的");
            if (rs.data != undefined) {
                localStorage.setItem("processLog", JSON.stringify(rs.data.data));
            } else {
 
            }
        });
    }
};//获得流程信息 李雁鸣  12-25
 
customShow.Init = function () {
    getProcessLog() //获得流程信息 李雁鸣  12-25
    customShow.exCouldNumber = undefined;//初始化 云单编号 李伟民  12-22
    customShow.orderStatus = undefined;//初始化 表单状态 李伟民 12-26
    //数据源
 
    //数据源信息取得
    var datasource = $.parseJSON(window.localStorage.getItem("datasource"));
    customShow.options.datasource = {};
    if (datasource != null) {
 
        for (var i = 0; i < datasource.length; i++) {
            customShow.options.datasource[datasource[i].dataSourceName] = datasource[i];
        };
    }
 
    // 0:预览 1:数据管理中新建 2:数据管理中展示(数据表示) 3:发布 4:模板中心
    var customShowFlag = window.localStorage.getItem("customShowFlag");
    customShow.options.customShowFlag = customShowFlag;
    //  12/13 测试模拟用
 
    if (customShowFlag == "0" || customShowFlag == "1") {// 新建 预览  隐藏 详情页 李伟民  11-17
        console.log(customShowFlag);
        //   12/4 李元杰 日历当前时间
        // var dataObj = {
        //     "time":"yyyy-MM-dd HH:mm:ss"
        // }
        // var requestRight = window.commonAjax('/epc/getTime', dataObj, 'POST', true);
        // requestRight.done(function (res) {
        //     // if (res.rspCode == "000000") {
        //     console.log(res)
        //     // }
        // })
        var myDate = new Date();
        myDate.getFullYear();    //获取完整的年份(4位,1970-????)
        myDate.getMonth();       //获取当前月份(0-11,0代表1月)
        myDate.getDate();
        customShow.currentDate = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate();
        console.log(new Date())
        console.log(customShow.currentDate)
        $("#customShow").removeClass("fui-form");
        console.log(customBase.options.customItemShow)
        // $(".preview-edit-pane").css("display", "none");
        // 12/23
 
 
 
 
    }// 新建 预览  隐藏 详情页 李伟民  11-17
    if (customShowFlag == "2") {
        console.log(customShowFlag);
        //12/23
        $(".preview-edit-pane").css("display", "block");
        // $("#editableBtn").on("click",() => {
        //     console.log($(".preview-edit-pane"));
 
        // })
    }
    if(customShowFlag == '3'){
        $(".preview-edit-pane").css("display", "block");
    }
    if (customShowFlag == "0") {
        //表单ID
        var customlocalStorage = window.localStorage.getItem("customForm");
        customlocalStorage = $.parseJSON(customlocalStorage);
        customShow.options.formid = customlocalStorage.newFormID;
        var customViewItem = window.localStorage.getItem("customViewItem");
 
        customShow.InitShow({
            //绑定DIV
            showDiv: "customViewUEditor",
            //数据来源
            customShowFlag: customShowFlag,
            //表示模式
            designMode: customlocalStorage.mode,
            //画面表示基础数据
            customViewItem: $.parseJSON(customViewItem),
            //画面表示数据
            formbase: "",
        });
        $(".s_savebtn").hide();
        // $(".customShow .fa-calendar").addClass();
    } else {
        customShow.options.formid = window.localStorage.getItem("newFormID");
        //初期数据取得
        customDataBound.getFormbase(customShow.options.formid, function (rs) {
            if (rs.rspCode == "000000" && rs.data != null) {
                //控件属性JSON对象
                var field = JSON.parse(rs.data.fieldset);
                //转换成数组
                var fields = _.keysIn(field);
                console.log(rs.data.fieldset)
 
                //循环读取tag_Type是否含有‘auto’
                for (var i = 0; i < fields.length; i++) {
                    var attrib = field[fields[i]];
                    if (attrib.tag_Type != null && attrib.tag_Type == 'auto') {
                        //如果有那么就发送请求
                        var dataObj = {};
                        dataObj.prefix = attrib.tag_Attribute.prefixs["0"].itemtext_1 + '$in{' + attrib.tag_Attribute.prefixs["0"].itemtext_2 + '}';
                        dataObj.FormID = formid;
                        var requestRight = window.commonAjax('/datamanagement/getGenerateRandomNumService', dataObj, 'POST', true);
                        requestRight.done(function (res) {
                            if (res.rspCode == "000000") {
                                var alisN = _.keysIn(customBase.options.customItems);
                                for (var i = 0; i < alisN.length; i++) {
                                    var item = customBase.options.customItems[alisN[i]];
                                    if (item.type == "auto") {
                                        var itemID = item.id;
                                        customBase.setItemValue(itemID, 'text', res.data, '', '');
                                    }
                                }
                            }
                        })
 
                    }
                }
 
                var formbase = window.localStorage.getItem("customItem");
                //console.log(formbase)
                //////////////console.log(formbase);
                // //console.log(formbase);
                var customItem = {
                    formeditor: rs.data.resultForm,
                    item: $.parseJSON(rs.data.fieldset),
                    //表单宽度
                    fromwidth: rs.data.formWidth,
                    //表单高度
                    fromheigh: rs.data.formHeight,
                    //表单名
                    formName: rs.data.formName,
                    customFlag: rs.data.designMode,
                    Linkage: rs.data.linkage
                }
                //console.log(customItem);
                //console.log(formbase)
                customShow.InitShow({
                    //绑定DIV
                    showDiv: "customViewUEditor",
                    //数据来源
                    customShowFlag: customShowFlag,
                    //表示模式
                    designMode: rs.data.designMode,
                    //画面表示基础数据
                    customViewItem: customItem,
                    //画面表示数据
                    formbase: formbase,
                });
            } else {
 
            }
        });
    }
    //隐藏保存
    if (publishShowflag==1){
        $(".preview-edit-pane").hide();
    }
}
// 12/4 李元杰 当前时间
customShow.currentDate = '';
function changeOrderStatus(orderStatus){//修改表单状态  李伟民  01-04
    if(orderStatus == undefined){
        return false;
    }
    switch(orderStatus){
        case '10':
            $('#stateText').html('自动审单中');
            break
        case '15':
            $('#stateText').html('自动审单成功');
            break
        case '19':
            $('#stateText').html('自动审单失败');
            break
        case '20':
            $('#stateText').html('未上传单据');
            break
        case '40':
            $('#stateText').html('记账处理中');
            break
        case '45':
            $('#stateText').html('记账处理完成');
            break
        case '49':
            $('#stateText').html('记账处理失败');
            break
        case undefined:
            $('#stateText').html('test');
            break
 
    }
}
//画面初期化
customShow.InitShow = function (customInit) {
    customBase.customInit = customInit;
    //画面初期迁移源属性取得
    // 0:预览 1:数据管理中新建 2:数据管理中展示 3:发布 4:模板中心
    //console.log(customInit)
    if (customInit.customViewItem != null && customInit.customViewItem != undefined) {
        customShow.costType = customInit.customViewItem.item;
    }
    var customShowFlag = customInit.customShowFlag;
    var customViewDiv = "#" + customInit.showDiv;
    customShow.options.customInit = customInit;
    customShow.options.customViewDiv = customInit.showDiv;
    //画面初期化(画面表示基础数据)
    customShow.options.customItemShow = customInit.customViewItem;
    customShow.options.jsonLinkage = customShow.options.customItemShow.Linkage;
    var customItem = customShow.options.customItemShow;
    setTimeout(function () {
        if (customShowFlag == "4") {
            $(".customViewUEditorCss").css("height", window.innerHeight);
            $(".customShow").css("height", window.innerHeight - 200);
        } else {
            $(".customViewUEditorCss").css("height", window.innerHeight - 200);
            $(".customShow").css("height", window.innerHeight - 200);
        }
    }, 10);
    var btns = [];
    //展示数据表示
 
    if (customShowFlag == "0" || customShowFlag == "6") {
        //2017-12-27 马习同   专家模式打印
        var print_btnFlag = window.localStorage.getItem("print_btnFlag");
        if (customShowFlag == "0" && print_btnFlag == "1"){
            var btns = [
                "printableBtn"
            ];
            customShow.setToolBtn(btns);
        }
        ////console.log(window.customBase);
        //标题头表示
        $('#childclick').css("display", "none");
        $(".header")[0].style.display = "block";
        //标题设定
        $(".modal-title")[0].innerHTML = customItem.formName;
 
        //画面内容的初始化设定
        customShow.setContentHtml(customItem, customViewDiv);
        //编辑模式下表示
        $(customViewDiv)[0].style.display = "block";
 
        //1:数据管理中新建  3:发布 4:模板中心
    } else if (customShowFlag == "1" || customShowFlag == "3") {
        //标题头表示
        console.log("显示X");
        console.log($('#childclick'));
        $('#childclick').css("display", "block");
        $('#childclick').click(() => {
            customShow.onclickCancel();
            console.log("点击父元素关闭");
        });
 
        $(".header")[0].style.display = "block";
        $("title")[0].innerHTML = customItem.formName;
        //标题设定
        $(".modal-title")[0].innerHTML = customItem.formName;$(".modal-title")[0].innerHTML = customItem.formName;
        //画面内容的初始化设定
        customShow.setContentHtml(customItem, customViewDiv);
 
        // $(".footer")[0].style.display ="block";
        //编辑模式下表示
        $(customViewDiv)[0].style.display = "block";
        //2:数据管理中展示
        //第三方事件绑定
        // customShow.setEventBind();
        if (customShowFlag == "1") {
            var btns = [
                'rejectBtn',
                'submitBtn',
                'auditableBtn',
                'queryBtn',
                'clearBtn',
                // 'disposableBtn',
                //  'fromSaveBtn',
            ];
        } else {
            var btns = [
                'rejectBtn',
                'submitBtn',
                'auditableBtn',
                'queryBtn',
                'createBtn',
                // 'clearBtn',
                // 'disposableBtn',
                //'fromSaveBtn',
            ];
        }
    }
    else if (customShowFlag == "4") {
        //标题头表示
        $(".header")[0].style.display = "none";
        //标题设定
        // $(".modal-title")[0].innerHTML=customItem.formName;
        //画面内容的初始化设定
        customShow.setContentHtml(customItem, customViewDiv);
        //编辑模式下表示
        $(customViewDiv)[0].style.display = "block";
        // $(".footer")[0].style.display ="none";
        //编辑模式下表示
        // $(customViewDiv)[0].style.display ="block";
        //第三方事件绑定
        // customShow.setEventBind();
    } else if (customShowFlag == "2") {
        console.log("显示X");
        console.log($('#childclick'));
        $('#childclick').css("display", "block");
        if (JSON.parse(window.localStorage.getItem('allow')) == true) {
            $('#childclick').css("display", "none");
        } else {
            $('#childclick').css("display", "block");
        }
        $('#childclick').click(() => {
            customShow.onclickCancel();
            console.log("点击父元素关闭");
 
        });
        //按钮修改 马习同 2017-12-13
        // var btnshowFlag = {
        //     a = true,
        //     b = flase,
        // };
        // if(btnshowFlag.a == true){
        //     btns.push();
        // }
        var btns = [
            // 'checkbillBtn',//查看票据
            'rejectBtn',//驳回
            'submitBtn',//提交
            'auditableBtn',//审批
            'editableBtn',
            'printableBtn',//打印
        ];
        //画面内容的初始化设定
        console.log(customItem);
        console.log(customViewDiv);
        customShow.setContentHtml(customItem, customViewDiv);
        var items = {};
        //数据变换
        //console.log(customInit);
        //console.log(customInit.formbase)
        var formbase = $.parseJSON(customInit.formbase);
        //console.log(formbase);
        customShow.options.dataRowNum = formbase['DATAROWNUM'];
        customShow.exCouldNumber = formbase['orderCode'];//获取云单编号 李伟民 12-26
        if(customShow.exCouldNumber){
            $('#exCloudNumberText').html('云单编号:' + customShow.exCouldNumber);
        }
        customShow.orderStatus = formbase['orderStatus'];// 获取表单状态 李伟民  12-26
        changeOrderStatus(customShow.orderStatus);
        items = formbase;
        customShow.options.itemFormbase = formbase;
        console.log(_.cloneDeep(items));
        delete items['DATAROWNUM'];
        console.log(_.cloneDeep(items));
        //初期化后,数据赋值(编辑模式)
        console.log(_.cloneDeep(items));
        customShow.showCustom(items, customShow.options.customInit);
        //初期化后,数据赋值(预览)
        console.log(_.cloneDeep(items));
        customShow.setShowCustomItem(items);
        //初期化后,票据信息追加  李伟民  12-26
        SC.billInfoInit(items);
 
 
        //数据源再次追加
        // var customItems = customShow.options.customItemShow.item;
        var customItems = customBase.options.customItems;
        console.log(customItems);
        for (item in customItems) {
            if (customItems.hasOwnProperty(item)) {
                if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
                    customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
                    var datasourcetype = customShow.options.customItemShow.item[customItems[item].id].tag_Attribute.datasourcetype;
                    console.log(datasourcetype);
                    if (datasourcetype == "custom") {
                        //数据源绑定(自定义数据)
                        customShow.setDatasourceData(customItems[item]);
                    }
                }
            }
        }
        //标题头表示
        $(".header")[0].style.display = "block";
        //标题设定
        $(".modal-title")[0].innerHTML = customItem.formName;
        //  12/19
        $("#customViewUEditor")[0].style.display = "none";
        //2017/11/18  马习同修改 隐藏预览模式下  导入数据按钮
        $(".sonImportFile").addClass("cfg_contentNone");
        $(".s_savebtn").hide();
        $(".customShow .fa-calendar").addClass("cfg_contentNone");
 
        console.log($(".customShow .tdContentClass"))
        // _.each($(".customShow .tdContentClass"),opt=>{
        //     // $(opt).attr("title", $(opt).children().children().html());
        //     console.log($(opt).html())
        //     if ($(opt).children().children().attr("type") == "text"){
        //         $(opt).attr("title", $(opt).children().children().val());
        //     }else{
        //         console.log(_.cloneDeep($(opt).children().children()))
        //         console.log(opt.innerHTML)
        //         console.log($(opt).children().children()[0].innerHTML)
        //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
        //     }
        // })
 
    }
    //第三方事件绑定
    var token = localStorage.getItem('token');//页面事件绑定 李伟民 12-22
    if (token != '' && token != undefined) {
        token = JSON.parse(token);
    }
    var postdata = { 'formID': customShow.options.formid };
    _.extend(postdata, token);
    var eventBindRquest = window.commonAjax('/formevent/getFormEventListService', postdata, 'GET', true, false);
    eventBindRquest.done(function (res) {
        if (res.data != undefined) {
            // var eventBindData = [];
            // _.each(res.data,function(data){
            //     eventBindData.push({'fieldName':data.fieldName,'tag':data.fieldType,'eventName':data.event,'functionName':data.eventmethod});
            // });
            customShow.initEvent.eventBind = res.data;
        }
        customShow.setEventBind();
    });//页面事件绑定 李伟民 12-22
 
    SC.showUser()//报销人根据当前登录人自动带出  李伟民  0108
 
    customShow.setToolBtn(btns);
    $(".select2-selection").remove();
    customShow.hidesubform();
    var unvisible = customBase.options.customItems;
    for (item in unvisible) {
        if (unvisible[item].type == "subform") {
            var itemId = unvisible[item].id;
            //          var itemTwo = itemId;
            //          var itemSubform = $('.'+"customViewUEditorCss" +" #"+itemId+"ActiveId");
            ////////////console.log(item);
            //子表单删除第一条可添加  2017/10/26 马习同
            //          var divIcon = $('<div id="'+itemId+'save" class="cfg_contentNone"></div>');
            var cloneE = $('#' + itemId + 'subformTr').clone();
            //          divIcon.append(cloneE);
            console.log(cloneE);
            //          itemSubform.append(divIcon);
            customBase.options.customItems[item]['cloneDiv'] = cloneE;
        }
    }
    //2017-12-12  马习同隐藏
    SC.Superior_hide();
    if (customShowFlag == "1" || customShowFlag == "0") {
        // window.localStorage.setItem('businessTypeAuto','240');
        $(".preview-edit-pane").find('#disposableBtn').css('display', 'none');
        $(".preview-edit-pane").find('#clearBtn').css('display', 'none');
        $(".preview-edit-pane").find('#queryBtn').css('display', 'none');
        $(".preview-edit-pane").find('#auditableBtn').css('display', 'none');
        $(".preview-edit-pane").find('#submitBtn').css('display', 'none');
        $(".preview-edit-pane").find('#rejectBtn').css('display', 'none');
    }
}
//   2017/10/20   李元杰  抽出了 李伟民的计算费用的方法 最后将数据return出去了
//计算费用
//customShow.queryCostAllData = function(){
//    var post_data = [];
//    var items = customShow.getItems();
//    var items_key = _.keysIn(items);
//    var all_data = {};
//    //console.log(items);
//    _.each(items_key,function(item){
//        var control = {};
//        var item_attr = customBase.options.customItems[item];
//        if(_.isArray(items[item]) && _.isObject(items[item][0])){//判断是否为子表单
//            _.extend(control,{'fieldKey':item,'mdCode':'','value':'','type':item_attr.type,'child':[]});
//            _.each(items[item],function(cd){
//                var cd_key = _.keysIn(cd);
//                var item_cd = {
//                    "items":[],
//                    "cid":""
//                };
//                _.each(cd_key,function(cdk){
//                    var control_cd = {};
//                    var item_attr_cd = customBase.options.customItems[cdk];
//                    _.extend(control_cd,{'fieldKey':cdk,'mdCode':customShow.getmasterdataById(item_attr_cd.id),'value':cd[cdk],'type':item_attr_cd.type});
//                    item_cd.items.push(control_cd);
//                    if(cdk == "dataRowNum"){
//                        item_cd.cid = cd[cdk];
//                    }
//                });
//                control.child.push(item_cd);
//            });
//            //行程ID 预留
//        }else{
//            _.extend(control,{'fieldKey':item,'mdCode':customShow.getmasterdataById(item_attr.id),'value':items[item],'type':item_attr.type});
//        }
//        post_data.push(control);
//    });
//    var customShowFlag = window.localStorage.getItem("customShowFlag");
//    var customForm = window.localStorage.getItem("customForm");
//    if(customForm && customForm != ""){
//        customForm = JSON.parse(customForm);
//    }
//    if(customShowFlag == 2){//详情
//        var customItem = window.localStorage.getItem("customItem");
//        if(customItem && customItem != ""){
//            customItem = JSON.parse(customItem);
//            //console.log(customItem);
//        }
//        _.extend(all_data,{"data":post_data,"formId":customForm.newFormID,"id":customItem.DATAROWNUM});
//    }else{//新建或预览
//        _.extend(all_data,{'data':post_data,"formId":customForm.newFormID,"id":""});
//    }
//    _.extend(all_data,{'orderCode':""});
//    _.extend(all_data,{'ctId':"240"});// 费用类型 假
//  return all_data;
//}
//计算费用
//customShow.queryCost = function(){
//  // 2017/10/20 李元杰 queryCostAllData 抽出来存这里了
//  //   var post_data = [];
//  //   var items = customShow.getItems();
//  //   var items_key = _.keysIn(items);
//  //   var all_data = {};
//  //   //console.log(items);
//  //   //console.log(items_key)
//  //   _.each(items_key,function(item){
//  //       var control = {};
//  //       //console.log(item);
//  //       var item_attr = customBase.options.customItems[item];
//  //       //console.log(item_attr)
//  //       if(_.isArray(items[item]) && _.isObject(items[item][0])){//判断是否为子表单
//  //           _.extend(control,{'fieldKey':item,'mdCode':'','value':'','type':item_attr.type,'child':[]});
//  //           _.each(items[item],function(cd){
//  //               //console.log(cd)
//  //               var cd_key = _.keysIn(cd);
//  //               //console.log(cd_key)
//  //               var item_cd = {
//  //                   "items":[],
//  //                   "cid":""
//  //               };
//  //               _.each(cd_key,function(cdk){
//  //                   var control_cd = {};
//  //                   var item_attr_cd = customBase.options.customItems[cdk];
//  //                   //console.log(item_attr_cd);
//  //                   _.extend(control_cd,{'fieldKey':cdk,'mdCode':customShow.getmasterdataById(item_attr_cd.id),'value':cd[cdk],'type':item_attr_cd.type});
//  //                   item_cd.items.push(control_cd);
//    //                 if(cdk == "dataRowNum"){
//    //                     item_cd.cid = cd[cdk];
//    //                 }
//  //               });
//  //               control.child.push(item_cd);
//  //           });
//  //           //行程ID 预留
//  //       }else{
//  //           _.extend(control,{'fieldKey':item,'mdCode':customShow.getmasterdataById(item_attr.id),'value':items[item],'type':item_attr.type});
//  //       }
//  //       post_data.push(control);
//  //   });
//  //   var customShowFlag = window.localStorage.getItem("customShowFlag");
//  //   var customForm = window.localStorage.getItem("customForm");
//  //   if(customForm && customForm != ""){
//  //       customForm = JSON.parse(customForm);
//  //   }
//  //   if(customShowFlag == 2){//详情
//  //       var customItem = window.localStorage.getItem("customItem");
//  //       if(customItem && customItem != ""){
//  //           customItem = JSON.parse(customItem);
//    //         //console.log(customItem);
//  //       }
//  //       _.extend(all_data,{"data":post_data,"formId":customForm.newFormID,"id":customItem.DATAROWNUM});
//  //   }else{//新建或预览
//  //       _.extend(all_data,{'data':post_data,"formId":customForm.newFormID,"id":""});
//  //   }
//  //   _.extend(all_data,{'orderCode':""});
//  //   _.extend(all_data,{'ctId':"240"});// 费用类型 假
//  //   //console.log(all_data);
//  //   //console.log(JSON.stringify(all_data))
//    var all_data = customShow.queryCostAllData();
//    // 2017/10/20 李元杰 queryCostAllData 抽出来存这里了  end
//    var query_request =  window.queryAjax("epc-count/countCost",all_data,"POST",true,false);
//    ////console.log(query_request);
//    query_request.done(function(res){
//        ////console.log("6531289");
//        customBase.listen_check(res.data,"query_check");
//    })
//
//    return all_data;
//}
// 12/12  模态框
$('.closeBtn').on('click', () => {
    $('.maskLayer').css('display', 'none');
    customShow.clean();
})
//扩展费用自定义方法,yuezhw 2017-11-13
customShow.extended_budget = function (where) {
    var obj = {};
    obj.formId = localStorage.getItem("newFormID");
    obj.dataId = JSON.parse(localStorage.getItem("customItem")).DATAROWNUM;
    obj.tenantID = JSON.parse(localStorage.getItem("tenantID")).tenantID;
    var query_request;
    flatpickr("#budget_time", {
        dateFormat: "Y-m-d"
    })
 
    var budgetNumber = $('#customShow').find('div[type="auto"]').find('input').val();
    var budgetDate = $($('#customShow').find('div[type="calendar"]')[1]).find('input').val();
    $('#budget_number').val(budgetNumber)
    $('#budget_date').val(budgetDate)
    $('#extended_someThing').css("display", "block");
    $('#budget_time').css("display", "block");
    $('.maskLayer').css('display', 'block');
    $('#budget_todo').on('click', () => {
        obj.department = $('#budget_department').val();
        obj.info = $('#budget_time').val();
        var nowTime = new Date(Date.parse(obj.info));
        var endTime = new Date(Date.parse(JSON.parse(localStorage.getItem("customItem")).budgetEndDate));
        console.log(obj.info);
        console.log(nowTime);
        console.log(endTime);
        if (obj.info.length < 1) {
            alert("请输入增加时间");
        } else if (nowTime < endTime) {
            alert("扩展时间不可小于当前结束时间!");
        } else {
            var query_request = window.queryAjaxQQ("epc-form/extend/budget/time", obj, "POST", true, false);
            query_request.done(function (res) {
                console.log(typeof res.data)
                console.log(res.data)
                if (res.data === true) {
                    alert("扩展时间成功!");
                    customShow.clean();
                    $('.maskLayer').css('display', 'none');
                } else {
                    alert("服务器通信失败");
                }
            })
            query_request.error(function (rs) {
                // console.log(rs)
                toastr.error(rs.responseJSON.rspDesc);
 
            })
        }
 
    })
    $('#budget_undo,.closeModal').on('click', () => {
        customShow.clean();
    })
}
//关闭页面
customShow.clean = function () {
    $('#extended_someThing').css("display", "none");
    $('#budget_whrere').val('');
    $('#budget_money').val('');
    $('#budget_time').val('');
}
//根据别名获取主数据
customShow.getmasterdataById = function (itemid) {
    var mdata = undefined;
    ////console.log(itemid);
    if (customShow.options.customItemShow.item[itemid] != undefined) {
        if (customShow.options.customItemShow.item[itemid].tag_Attribute.masterData != undefined && customShow.options.customItemShow.item[itemid].tag_Attribute.masterData != '') {
            mdata = JSON.parse(customShow.options.customItemShow.item[itemid].tag_Attribute.masterData);
        }
    }
    if (mdata != undefined) {
        return mdata.defindCode;
    } else {
        return "";
    }
}
 
//数据赋值 ----编辑项目赋值
customShow.setShowCustomItem = function (items) {
    //   2017/10/19  李元杰  在费用明细里插入一些信息
    // 需要传给后端的对象
    //console.log(items);
    // var objData =  customShow.queryCostAllData();
    //  获取orderCode的值
 
    // if(objData.orderCode){
    // var  orderCode =  customBase.getItemValue(customBase.options.customItems.orderCode.id,customBase.options.customItems.orderCode.type)
    // objData.orderCode = orderCode[1];
    // var requestInsert  = window.commonAjax("/datamanagement/getAssociatedFormDataService", objData, "POST", true);
    // requestInsert.done(function (res) {
    //     for(var i = 0 ; i <res.data.data.length;i++){
    //         if(res.data.data[i].child){
    //             for(var j = 0;j<res.data.data[i].child.length;j++){
    //                 // 循环子表单里拥有dataRowNum的数量
    //                     $(`[id= ${customBase.options.customItems.dataRowNum.id}]`).each( (index,ipt)=>{
    //                         // 获取返回值里的value和子表单里的dataRowNum的值是否相同
    //                             if(  res.data.data[i].child[j].msgInfo.header[0].value == $(ipt).val()){
    //                                 // 寻找当前子表单的父节点里的H8标签插入数据
    //                                 $($(`[id= ${customBase.options.customItems.dataRowNum.id}]`)[index].closest('[type=subform]')).children('h8').find('.text')
    //                                 .append(` <span>${res.data.data[i].child[j].msgInfo.header[0].name}</span>`)
    //                             }
    //                     })
    //             }
    //         }
    //     }
    // });
    // }
    //delete items['DATAROWNUM']; // 子表单中  不删除datarownum  李伟民  11-16
    var items = _.cloneDeep(items);
    var customItems = customBase.options.customItems;
    //console.log(customItems);
    //数据值变换
    for (item in items) {
        if (items.hasOwnProperty(item)) {
            if (customItems[item] == undefined) {
                delete customItems[item];
                continue;
            }
            if (customItems[item].type == 'subform' || customItems[item].type == 'tag' || customItems[item].type == 'tab') {
                var subformTemp = items[item];
                console.log(subformTemp)
                if (subformTemp == undefined) {
                    subformTemp = [{}];
                }
                for (subformItem in subformTemp[0]) {
                    if (subformTemp[0].hasOwnProperty(subformItem)) {
                        items[subformItem] = [];
                    }
                }
                console.log(subformTemp.length);//主数据丢失
                for (var i = 0; i < subformTemp.length; i++) {
                    if (i != 0) {
                        //子表单项目追加
                        var subformAdd = $(".customViewUEditorCss #" + customItems[item].id + "ActiveId .subformAdd")[0];
                        customShow.addsubformList(subformAdd, "customViewUEditorCss");
                    }
                    for (subformItem in subformTemp[i]) {
                        if (subformTemp[i].hasOwnProperty(subformItem)) {
                            items[subformItem][i] = subformTemp[i][subformItem];
                        }
                    }
                };
            }
        }
    }
 
    //delete items['DATAROWNUM']; // 子表单中  不删除datarownum  李伟民  11-16
    console.log(_.cloneDeep(items))
    console.log(customItems);
    //数据赋值
    for (item in items) {
        console.log(item);
        if (items.hasOwnProperty(item)) {
            if (customItems[item] == undefined) {
                delete customItems[item];
                continue;
            }
            var type = customItems[item].type;
            var id = customItems[item].id;
            console.log(id);
            console.log(items[item]);
            if (
                // type == 'radio' || type == 'checkbox' ||
                // type == 'dropdownlist'||
                // type == 'tree'||
                // type == 'amount'||
                // type == 'barcode'||
                // type == 'qrcode' ||
                // type == 'image'||
                type == 'button'
                // || type == 'fileupload'
                || type == 'subform' || type == 'link'
                || type == 'splitline' || type == 'link' || type == 'tag' || type == 'tab'
            ) {
 
            } else if (customItems[item].type == "image" || customItems[item].type == "fileupload") {
                var itemId = customItems[item].id;
                if (items[item] != "") {
                    customBase.options.uploaderItemReady[itemId] = $.parseJSON(items[item]);
                } else {
                    customBase.options.uploaderItemReady[itemId] = [];
                }
            } else if (type == 'amount') {
                var id = id + "amount";
                customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
                $("#" + id).blur();
            } else if (type == 'qrcode') {
                var id = id + "qrcode";
                customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
                $("#" + id).blur();
            } else if (type == 'barcode') {
                var id = id + "barcode";
                customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
                $("#" + id).blur();
            } else if (type == 'dropdownlist' || type == 'radio' || type == 'checkbox' || type == 'tree') {
                //异步加载时数据临时保存
                customShow.options.initTempDatas[id] = items[item];
                // var datasourcetype = $("#"+id)[0].getAttribute("datasourcetype");
                // //主数据源
                // if(datasourcetype == "masterdata"){
                //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
                //   //数据源
                // }else if(datasourcetype == "datasource"){
                //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
                //   //自定义
                // }else if(datasourcetype == "custom"){
                //   customBase.setItemValue(id,'dropdownlistText',items[item],'customViewUEditorCss');
                //   //API接口
                // }else if(datasourcetype == "api"){
                //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
                // }
 
            } else if (customItems[item].type == 'mytext') {
                //选择表单预览回显
                var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
                var item_title = [];
                var itemVal = [];
                var $mytext = $("#customShow " + "#" + customItems[item].id + "ActiveId");
                if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
                    var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
                    var dataObj = {
                        "formID": customShow.options.formid,
                        "tenantID": "001",
                        "search": [],
                        "pageSize": "1000",
                        "pageNum": "1",
                        "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
                        "formData": {},
                        "dataRowNum": items[item]
                    };
                    var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
                    var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
                    requesTitle.done(function (res) {
                        console.log(res);
                        item_title = res.data;
                    });
                    requesData.done(function (res) {
                        console.log(res);
                        if (!_.isNull(res.data) && res.data != undefined) {
                            itemVal = res.data;
                        }
                    });
                } else {
                    var myTitle = JSON.parse(window.localStorage.getItem("title"));
                    item_title = myTitle[item];
                    itemVal = items[item];
                }
                console.log(myTitle);
                console.log(itemVal)
                console.log(item_title);
                console.log(itemVal.list);
                var iconID = "customShow #" + customItems[item].id + "ActiveId";// 关联数据回显渲染 李伟民 11-30
                createMxtTable(iconID, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
                //              var newData = [];
                //              _.each(itemVal.list,function(opt){
                //                  opt = _.mapKeys(opt,function(value,key){
                //                      _.each(item_title,function(item){
                //                          if(key == item.fieldKey){
                //                              key = item.title;
                //                          }
                //                      })
                //                      return key;
                //                  })
                //                  console.log(_.cloneDeep(opt))
                //                  newData.push(opt);
                //              })
                //              console.log(itemVal.list);
                //              console.log(newData);
                ////              var $value = newData;
                //              var show = "";
                //              var divBox = $("<div></div>");
                //              divBox.attr('id',customItems[item].id+'divBox');
                //              //console.log($value)
                //                        var sdata_head = "";
                //              _.each($value,(opt,j)=>{
                //                  //console.log(opt);
                //                  var ulBox = $("<ul></ul>");
                //                  for(let i in opt){
                //                      show = "";
                //                                sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
                //                  show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
                //                  ulBox.attr("class","addUl ulBox"+j);
                //                  ulBox.attr("id","ulBox"+j);
                //                  //console.log(show)
                //                  ulBox.append(show);
                //                  }
                //                            console.log(sdata_head);
                //                  divBox.append(ulBox);
                //              });
                //              $mytext.append(divBox);
            } else {
                //值设定
                customBase.setItemValue(id, type, items[item], 'customViewUEditorCss');
                //异步加载时数据临时保存
                customShow.options.initTempDatas[id] = items[item];
            }
        }
    };
    //赋值后绑定票据信息
}
// 定义云账房方法 10/17
var orderid = "";
function getepc() {
    window.queryAjaxsd("epc/epc-form/getOrderCode", {}, "POST", true).done(function (res) {
        //console.log("云账房id");
        //console.log(res);
        if (res.data != undefined) {
            orderid = res.data.orderCode;
            setepc(orderid);
        }
 
    })
}
function setepc(orderid) {
    //console.log(orderid);
    //console.log(customBase);
    //console.log(window.customShow);
    if (customBase.options.customItems.orderCode != undefined) {
        var id = customBase.options.customItems.orderCode.id;
        var type = customBase.options.customItems.orderCode.type;
        //console.log(id);
        //console.log(type);
 
        customBase.setItemValue(id, type, orderid);
    }
}
 
function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null;
}
 
customShow.uploadBill = function () {//票据上传
    $('#upload_iframe').show();
    var token = localStorage.getItem(token);
    if (token != '' && token != undefined) {
        token = JSON.parse(token).accessToken;
    }
    var compid = getCookie('companyId');
    var tenantId = localStorage.getItem("tenantID");
    // var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=" + token + "&compid=" + compid +"&tenantId=" + tenantId;
    var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=" + localStorage.getItem("testToken") + "&compid=" + localStorage.getItem("testCompanyId") +"&tenantId=" + localStorage.getItem("testTenantId");
    //var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=a23efb1df2303a914b1139d4e1d1859f&compid=66&tenantId=13";
    $("#upload_iframe").append("<iframe id='uploadBill' style='width:100%;overflow: auto;'></iframe>");
    ////console.log($("body"));
    var thisHeight = $("body").height();
    ////console.log(thisHeight);
    $('#upload_iframe').height(thisHeight);
    $('#uploadBill').height(thisHeight);
    $('#uploadBill').attr("src", iframe_src);
    window.addEventListener("message", customShow.getExCouldNumber);
    $("#upload_iframe .right").on("click", function () {
        customShow.uploadBillClose();
    });
 
}
 
customShow.getExCouldNumber = function (event) {
    if (event && event.data && event.data.indexOf('csc_OrderCode=') != -1) {
        var exCouldNumber = event.data.split('=')[1];
        console.log(exCouldNumber);
        customShow.exCouldNumber = exCouldNumber;
        if(localStorage.getItem('customShowFlag') == 2){//详情页上传票据需将云单编号传给后台  李伟民  01-04
            var orderData = {
                "formId":customShow.options.formid,
                "formDataId":localStorage.getItem("datarowNum"),
                "orderCode":exCouldNumber
            }
            var orderUpdate = window.cloudAjax("epc-form/formData/updataBillInfoAndForm",orderData,"POST",true);
            orderUpdate.done(function(res){
                if(res.rspCode == '000000'){
                    changeOrderStatus('10');
                    customShow.uploadBillClose();
                }
            });
        }else{
            customShow.uploadBillClose();
        }
    }
}
 
customShow.uploadBillClose = function () {
    $('#uploadBill').remove();
    $('#upload_iframe').hide();
    window.removeEventListener("message", customShow.getExCouldNumber);
    $('.bill_upload').hide();
    // getepc();
}//画面初期编辑内容设定
customShow.setContentHtml = function (customItem, customViewDiv) {
 
    //按钮状态编辑  btnFlag:{editable:"1",printable:"1",auditable:"1",disposable:"1"} //按钮表示
    var btnFlag = customShow.options.btnFlag;
    if (btnFlag.editable != "0") {
        $("#editableBtn").removeClass("cfg_contentNone");
    }
    if (btnFlag.printable != "0") {
        $("#printableBtn").removeClass("cfg_contentNone");
    }
    if (btnFlag.auditable != "0") {
        $("#auditableBtn").removeClass("cfg_contentNone");
    }
    if (btnFlag.disposable != "0") {
        $("#disposableBtn").removeClass("cfg_contentNone");
    }
 
    var div = document.createElement("div");
    div.innerHTML = customItem.formeditor;
    if (customShow.options.customInit.designMode == "1") {
        //发布页面查看大图排版问题  曲辰明 3-27
        //div.setAttribute("class", "divshow divshowEditor");
 
        if (customShow.options.customShowFlag != "4") {
            $(div).css("height", customItem.fromheigh);
            $(div).css("width", "100%");
            // $(customViewDiv).css("height",customItem.fromheigh);
            // $(customViewDiv).css("width",customItem.fromwidth);
            console.log(1);
        }
 
    } else {
        div.setAttribute("class", "divshow divshowNoEditor");
        //  $(div)[0].style.height = window.innerHeight-140 + "px";
        //  if(customShow.options.customShowFlag =="0"){
        //     $(div)[0].style.width ='98%';
        //  }else{
        //     $(div)[0].style.width ='100%';
        //  }
 
        //  $(div)[0].style.overflowY ='auto';
        $(div)[0].style.width = '100%';
        $(div)[0].style.height = '100%';
 
        $(div).css("display", "flex");
        $(div).css("justify-content", "flex-start");
        $(div).css("flex-wrap", "wrap");
    }
    $(customViewDiv).prepend(div);
 
    //基本信息List取得
    customBase.options.customItems = customShow.getItemsList();
    console.log(customShow.getItemsList())
    console.log(customShow.options.customItemShow.item)
 
    //接口绑定
    interfaceBind = customShow.initEvent.interfaceBind;
    for (var i = 0; i < interfaceBind.length; i++) {
        if(window[interfaceBind[i].customInterfacemethod] != undefined){
            customShow.initEvent[interfaceBind[i].interfacemethod] = eval(interfaceBind[i].customInterfacemethod);
        }
    };
 
    // //事件绑定
    // eventBind = customShow.initEvent.eventBind;
    // //02事件绑定:字段别名 字段类型 事件名 自定义事件名
    // for (var i = 0; i < eventBind.length; i++) {
    //   // 自定义事件名
    //   var setfunction = eval(eventBind[i].eventmethod);
    //   // 事件名
    //   var eventName = eventBind[i].event;
    //   // 字段类型
    //   // var tag = eventBind.tag;                         //------------类型绑定-------------
    //   // 字段别名
    //   var fieldKey = eventBind[i].fieldName;
    //   // 取得控件ID
    //   var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
    //   //事件绑定
    //   $("#"+itemId).on(eventName, setfunction);
    // };
    // //-------------------------主数据取得------------------------------
    //-------------------------数据源取得------------------------------
    //-------------------------API取得data-----------------------------
 
    //画面初期化
    customShow.initEvent.interfaceInit(customShow.options.customShowFlag);
    console.log(customShow.options.customItemShow.item);
    //第三方初始化
 
    customShow.initEvent.interfaceInit3rd();
 
    //密码输入----------------
    customShow.initEvent.passwordInputFlag();
    //tree控件 by kill
    // 2017/11/4  李元杰 在点击预览的时候树的按钮
    customShow.treeWinShow();
 
}
//2017/11/2  李元杰 单选树  树的显示
 
$('.customViewUEditorCss').on('click', '.citySel,.menuBtn', function () {
    debugger
    // 树里存在数据时
    if ($(this).parents('div[name="TreeWin"]').find('.ztree').children('li').length > 0) {
        //  12/16 李元杰
        $('div.drop_down_sel').remove();
        var fieldKey = $(this).parents('div[name="TreeWin"]').find('.zTreeDemoBackground').attr('fieldkey');
        $('.zTreeDemoBackground').css("display", "none");
        $(".search_input").css("display", "none");
        if (customBase.options.customItems[fieldKey].editable) {
            if (event.target.className == 'defaultHeight  citySel' || event.target.className == 'defaultHeight  citySel') {
                var ztree = $(this).parents('div[name="TreeWin"]').find('.ztree')
                for (var i = 0; i < ztree.length; i++) {
                    var treeObj = $.fn.zTree.getZTreeObj($(ztree[i]).attr('id'));
                    if (!_.isNull(treeObj)) {
                        treeObj.expandAll(true);
                    }
                }
            }
            $(this).parents('div[name="TreeWin"]').find('div[name="treeWinTitle"]').find('.search_input').css("display", "block");
            $(this).parents('div[name="TreeWin"]').find('.zTreeDemoBackground').show();
            //  12/16 end
        }
        $('.customViewUEditorCss').off('click.tree').on('click.tree', function () {
            console.log(1);
            console.log($('div.drop_down_sel'))
            $('div.drop_down_sel').remove();
            $('.zTreeDemoBackground').css("display", "none");
            $(".search_input").css("display", "none");
 
        });
 
        $('div.TreeWin').off('click.tree').on('click.tree', function (event) {
            // 展开树 12/4
            console.log($(this))
            $('div.drop_down_sel').remove();
            var fieldKey = $(this).find('.zTreeDemoBackground').attr('fieldkey');
            $('.zTreeDemoBackground').css("display", "none");
            $(".search_input").css("display", "none");
            if (customBase.options.customItems[fieldKey].editable) {
                if (event.target.className == 'defaultHeight  citySel' || event.target.className == 'defaultHeight  citySel') {
                    var ztree = $(this).find('.ztree')
                    for (var i = 0; i < ztree.length; i++) {
                        var treeObj = $.fn.zTree.getZTreeObj($(ztree[i]).attr('id'));
                        if (!_.isNull(treeObj)) {
                            treeObj.expandAll(true);
                        }
                    }
                }
 
                $(this).find('div[name="treeWinTitle"]').find('.search_input').css("display", "block");
                $(this).find('.zTreeDemoBackground').show();
            }
            event.stopPropagation();
        });
 
    }
})
//this function by kill
customShow.treeWinShow = function () {
    // $('body').append('<div id="occlusion"></div>')
    //    occlusionCss={
    //        background: 'white',
    //        filter: 'alpha(opacity=100)',
    //        opacity: '1',
    //        display: 'none',
    //        position: 'absolute',
    //        top: '0px',
    //        left: '0px',
    //        width: '100%',
    //        height: '100%',
    //        display:'none',
    //        "z-index":"99998",
    //        display:"none",
    //        height:'100%',
    //        width:'100%',
    //    };
    treeButtonDivCss = {
        position: "absolute",
        top: '85%',
        left: '30%',
    }
    treeDutton2DivCss = {
        position: "absolute",
        top: '85%',
        left: '60%',
    }
    winCss = {
        position: 'relative',
        "border-radius": "4px",
        width: "100%",
        'max-width':"190px",
        height: "30px",
 
    }
    treeWinTitleCss = {
        "margint-top": "3%"
    }
    subFormTreeCss = {
        position: "absolute",
 
        top: '56px',
        left: '0px',
 
        'background-color': '#fff',
        'z-index': '99999',
        // top:"15%",
        // "margin-left":"5%",
        width: "165px",
        border: "1px solid #CCC",
        overflow: "hidden",
        'overflow-y': "auto",
 
    }
    wintreeCss = {
        position: "absolute",
        top: '56px',
        'background-color': '#fff',
        'z-index': '99999',
        // top:"15%",
        // "margin-left":"5%",
        width: "165px",
        border: "1px solid #CCC",
        overflow: "hidden",
        'overflow-y': "auto",
    }
    if(customShow.options.customInit.designMode == 2){//快捷模式处理  李伟民  0123
        $(".ztree").parent().parent().attr("name", "TreeWin");
        $(".ztree").parent().parent().attr("class", "TreeWin");
    }else{
        $(".ztree").parent().wrapAll('<div name="TreeWin" class="TreeWin"></div>');
    }
 
 
    $('.ztree').parents('div[name="TreeWin"]').show();
    //    2017/11/4 点击预览的时候产生的树样式  李元杰
    $('div[type="Tree"]').append('<button class="btn btn-primary" name="treeButton1" style="display:none">选择</button>');
    //马习同  下拉树样式修改 11/13
    // $('div[name="TreeWin"]').prepend(`
    //     <div name="treeWinTitle">
    //         <div class="content_wrap">
    //             <div>
    //                 <ul class="list ulContent">
    //                     <div class="input-group"  >
    //                         <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
    //                         <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
    //                     </div>
 
    //                     </li>
    //                 </ul>
    //             </div>
    //         </div>
    //     </div>
    // `);
    if(customShow.options.customInit.designMode == 2){
        $('div[name="TreeWin"]').prepend(`
            <div name="treeWinTitle">
                <input  id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
                <div class="content_wrap">
                    <div>
                        <ul class="list ulContent">
                            <div class="input-group"  >
                                <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
                                <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
                            </div>
 
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        `);
    }else{
        _.each($('.ztree'),function(tree){
            if($(tree).parent().attr('class').indexOf('cfg_contentNone') != -1){
                $(tree).closest('div[name="TreeWin"]').prepend(`
                <div name="treeWinTitle" class="cfg_contentNone">
                    <input  id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
                    <div class="content_wrap">
                        <div>
                            <ul class="list ulContent">
                                <div class="input-group"  >
                                    <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
                                    <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
                                </div>
 
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            `);
            }else{
                $(tree).closest('div[name="TreeWin"]').prepend(`
                <div name="treeWinTitle">
                    <input  id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
                    <div class="content_wrap">
                        <div>
                            <ul class="list ulContent">
                                <div class="input-group"  >
                                    <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
                                    <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
                                </div>
 
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            `);
            }
        })
 
    }
 
    //    $('div[name="TreeWin"]').prepend('<div name="treeWinSearch"><input id="search_input" placeholder="Type to filter"><hr /></div>');
    //    $('div[name="TreeWin"]').append('<div name="treeButtonDiv"><button class="btn btn-primary" name="treeButton2">确定</button></div>');
    //    $('div[name="TreeWin"]').append('<div name="treeButtonDiv2"><button class="btn btn-danger" name="treeButton3">取消</button></div>');
    //    $(".ztree").parent().css(subFormTreeCss);
    //    $('.ztree').parents('.fieldOrderNum').attr('typpe');
    var ztreeParentCss = $(".ztree").parent();
    $(".ztree").parent().css(subFormTreeCss);
    for (var i = 0; i < ztreeParentCss.length; i++) {
        //  11/16 李元杰  子表单内树形搜索框定位
        console.log($(ztreeParentCss[i]).find('ul'))
        console.log($(ztreeParentCss[i]).parents('.fieldOrderNum'))
        var isAllCopyTreeIs = $(ztreeParentCss[i]).find('ul').attr('id').split('tree')[0];
        if (customShow.options.customItemShow.item[isAllCopyTreeIs].parentsubFormNum != 0) {
            $(ztreeParentCss[i]).css(subFormTreeCss);
            $(ztreeParentCss[i]).parent('div[name="TreeWin"]').find('.search_input').addClass('search_input_subform')
        } else {
 
            $(ztreeParentCss[i]).css(wintreeCss);
        }
        //  树形是否有数据的判断
        if ($(ztreeParentCss[i]).children('ul').children('li').length > 0) {
 
        } else {
 
            $(ztreeParentCss[i]).hide();
        }
    }
    //    $("#occlusion").css(occlusionCss);
    $('div[name="TreeWin"]').css(winCss);
    if(customShow.options.customInit.designMode == 1){
        $('div[name="TreeWin"]').css('width','unset');
    }
    $('div[name="treeWinTitle"]').css(treeWinTitleCss);
    $('.ztree').css("top", "%20");
    //    $(".ztree").parent().parent().hide();
    //这个换成点击新建
    //    $('button[name="treeButton1"]').click(function(){
    // 表明只有树组件时才提示是否绑定数据
    if ($('button[name="treeButton1"]').length > 0) {
        var treeId = $('button[name="treeButton1"]').prev().attr("id");
        var treeJson = $('button[name="treeButton1"]').prev().children(':nth-child(2)').attr("masterdata");
        //////console.log($(this).prev()[0]);
        // console.log(treeJson);
        //console.log(treeId);
        if (typeof (treeJson) == "undefined" || treeJson == "") {
            // alert("该控件没有进行数据绑定!")
        } else {
            //    $("#occlusion").fadeTo(200);
            console.log($('button[name="treeButton1"]'))
            $('button[name="treeButton1"]').prev().show();
            console.log($('div[name="treeWinTitle"]'))
            var treeWinTitle = $('div[name="treeWinTitle"]');
            console.log(treeWinTitle[0])
            for (var i = 0; i < treeWinTitle.length; i++) {
                console.log($(treeWinTitle[i]));
                $(treeWinTitle[i]).find('input[type="text"]').attr('id', `search_input${i}`)
            }
        }
    }
    //  12/7 李元杰 树禁止背景颜色
    var editableBgColor = $('.ztree');
    for (var i = 0; i < editableBgColor.length; i++) {
        var editableFlag = $(editableBgColor[i]).parent().attr('editable')
        if (editableFlag == 'true') {
            var a = $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel')
            $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel').removeClass('disableColor')
        } else {
            var a = $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel')
            $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel').addClass('disableColor')
        }
    }
    //  12/7 end
    $('.ztree').addClass('search_list');
    // 搜索框获得焦点时 初始化
    console.log($('.tabBox'))
    $('.tabBox').on('focus', '.search_input', function () {
        console.log($(this))
        var searchListId = $(this).parents('div[name="TreeWin"]').find('.ztree').attr('id');
        console.log($(this).parents('div[name="TreeWin"]').find('.ztree'));
        $(this).fastLiveFilter(`#${searchListId}`, {});
    })
    //    $('button[name="treeButton2"]').click(function(){
    //        //确定按钮 by kill
    //            var treeId=$(this).parent().parent().children(':nth-child(2)').attr("id")
    //            $('#spanDiv'+treeId).remove()
    //            $('#'+treeId+"ActiveId").children(':nth-child(1)').append('<span id="spanDiv'+treeId+'"></span>')
    //            $('#'+treeId+'tree').children('li').each(function(){
    //               var state=$(this).children(':nth-child(2)').attr('class')
    //               if(state.indexOf('true')!=-1){
    //                    var text=$(this).children(':nth-child(3)').attr('title');
    //                    $('#'+treeId+"ActiveId").children(':nth-child(1)').children(':nth-child(4)').append('<span>|'+text+'</span>')
    //               }
    //            })
    //         //    $("#occlusion").fadeOut(200);
    //         //    $(this).parent().parent().hide();
    //        }
    //    )
    //    $('button[name="treeButton3"]').click(function(){
    //        //取消按钮 by kill
    //        var treeId=$(this).parent().parent().children(':nth-child(2)').attr("id")
    //        var a = [];
    //        var tite=$('#spanDiv'+treeId).children().text();
    //        for(var i=0;i<tite.split("|").length;i++){
    //           $('#'+treeId+'tree').children('li').each(function(){
    //               if(tite.split("|")[i]==$(this).children(':nth-child(3)').attr('title')){
    //                   a.push($(this).children(':nth-child(2)').attr('id'))
    //               }else{
    //                   if($(this).children(':nth-child(2)').attr('class').indexOf('true')!=-1){
    //                       $(this).children(':nth-child(2)').click();
    //                   }
    //               }
    //           })
    //       }
    //           for(var x=0;x<a.length;x++){
    //               $('#'+a[x]).click();
    //               ////console.log(a[x])
    //           }
 
    //         // $("#occlusion").fadeOut(200);
    //         // $(this).parent().parent().hide();
    //    })
    // end by kill
 
 
}
 
//事件绑定 接口绑定
customShow.setEventBind = function () {
    // //接口绑定
    // interfaceBind = customShow.initEvent.interfaceBind;
    // for (var i = 0; i < interfaceBind.length; i++) {
    //   customShow.initEvent[interfaceBind[i].interfacemethod] = eval(interfaceBind[i].customInterfacemethod);
    // };
 
    //事件绑定
    eventBind = customShow.initEvent.eventBind;
    //02事件绑定:字段别名 字段类型 事件名 自定义事件名
    console.log(eventBind);
    for (var i = 0; i < eventBind.length; i++) {
        // 自定义事件名
        var funstr = eventBind[i].eventmethod + "()";//页面事件绑定 李伟民 12-22
        //页面事件绑定 李伟民 12-22
        // 事件名
        var eventName = eventBind[i].event;
        // 字段类型
        // var tag = eventBind.tag;                         //------------类型绑定-------------
        // 字段别名
        var fieldKey = eventBind[i].fieldName;
        // 取得控件ID
        var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
        $("#" + itemId).attr('funstr',funstr)
        //事件绑定
        $("#" + itemId).on(eventName, function () {
            try {//页面事件 无资源文件 JS报错解决 李伟民 0131
                eval($(this).attr('funstr'));
            } catch (error) {
                console.log('资源文件中无此方法')
            }
        });
    };
    //-------------------------主数据取得------------------------------
 
    //公式初期化
    setTimeout(function () {
        customLinkageAnalysis.bindLinkage();
    }, 200);
    //行程排序初期化
    setTimeout(function () {
        customShow.journeySort();
    }, 200);
    // customShow.options.LinkageAnalysisSetValueFlag = ture;
 
    setTimeout(function () {
        //初期化公式接口
        customShow.initEvent.interfaceInitLinkage();
    }, 200);
    //马习同   合计   2017-12-07  公式初期化后
    customShow.oneTotle();
}
 
customShow.setEventBindItem = function (eventItem) {
    //事件绑定
    eventBind = eventItem;
    //02事件绑定:字段别名 字段类型 事件名 自定义事件名
    for (var i = 0; i < eventBind.length; i++) {
        // 自定义事件名
        var setfunction = eval(eventBind[i].eventmethod);
        // 事件名
        var eventName = eventBind[i].event;
        // 字段类型
        // var tag = eventBind.tag;                         //------------类型绑定-------------
        // 字段别名
        var fieldKey = eventBind[i].fieldName;
        // 取得控件ID
        var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
        //事件绑定
        $("#" + itemId).on(eventName, setfunction);
    };
}
customShow.listData = {};
//  11/21  全局 itemId
customShow.itemId = "";
//数据设定值取得(主数据 API 数据源 自定义)
customShow.setDatasourceData = function (customItem) {
    //马习同 获取
    customItems = customShow.options.customItemShow.item;
 
    var setDataItem = {
        masterdata: function (item, callback) {
            setMasterData(item, callback);
        },
        datasource: function (item, callback) {
            setDatasource(item, callback);
        },
        custom: function (item, callback) {
            setCustom(item, callback);
        },
        api: function (item, callback) {
            setApiDatasource(item, callback);
        }
    }
    var setCallbackItem = function (itemId, listData) {
        var type = customShow.options.customItemShow.item[itemId].tag_Type;
        if (type == "dropdownlist") {
            setDropdownlist(itemId, listData);
        } else if (type == "radio" || type == "checkbox") {
            setCustomradio(itemId, listData);
        } else if (type == "tree") {
            var dropdowntype = customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype;
            if (dropdowntype == "multiple") {
                // 多选的树样式
                $('#' + itemId + "tree").parent().hide();
                setTree(itemId, customBase.settingChkboxType, listData);
 
            } else {
                // 2017/11/1  李元杰 树更改成单选
                // 单选的树样式
 
                $('#' + itemId + "tree").parent().hide();
                setTree(itemId, customBase.settingRadioType, listData);
            }
            var unvisible = customBase.options.customItems;
            for (item in unvisible) {
                if (unvisible[item].type == "subform") {
                    var itemId = unvisible[item].id;
                    //          var itemTwo = itemId;
                    //          var itemSubform = $('.'+"customViewUEditorCss" +" #"+itemId+"ActiveId");
                    ////////////console.log(item);
                    //子表单删除第一条可添加  2017/10/26 马习同
                    //          var divIcon = $('<div id="'+itemId+'save" class="cfg_contentNone"></div>');
                    var cloneE = $('#' + itemId + 'subformTr').clone();
                    //          divIcon.append(cloneE);
                    console.log(cloneE);
                    //          itemSubform.append(divIcon);
 
 
                    customBase.options.customItems[item]['cloneDiv'] = cloneE;
                }
            }
        }
    }
 
    //下拉菜单
    setDropdownlist = function (itemId, listData) {
 
 
        var dropdownlistData;
 
        var item = $('.customViewUEditorCss #' + itemId);
        //  $($('.customViewUEditorCss #'+itemId)[0]).empty();
        //  $($($('.customViewUEditorCss #'+itemId)[0]).parentNode).find(".select2").remove();
        var dropdowntype = customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype;
        var editable = customShow.options.customItemShow.item[itemId].tag_Attribute.editable;
        //        ////console.log(editable);
        var readonly = "readonly";
        if (editable) {
            readonly = "";
        }
        var width = $(item[0])[0].style.width.replace("px", "");
        width = parseInt(width);
        console.log(width)
        customBase.options.dropdownlistText[itemId] = listData;
        // $("#"+itemId).parent().empty();
        var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass  dropdowntypeCss " + itemId + "value " + readonly;
        var DropdownlistItem = $("#" + itemId).parent();
        DropdownlistItem.empty();
        DropdownlistItem.append($('<div id="' + itemId + '" class="selectClass ' + itemIdClass + '"></div>'));
        if (dropdowntype == "multiple") {
            xhSelect.setXhSelect(
                {
                    selectId: itemId,
                    multiple: true,
                    width: width,
                    listData: listData
                }
            );
        } else {
            xhSelect.setXhSelect(
                {
                    selectId: itemId,
                    multiple: false,
                    width: width,
                    listData: listData
                }
            );
        }
        //  item.find();
        // if(dropdowntype == "multiple"){
        //     item.select2({theme: "classic",
        //       width: width,
        //       data: listData,
        //       multiple: true});
        //  }else{
        //     item.select2({theme: "classic",
        //       width: width,
        //       data: listData,
        //     });
        //  }
        customShow.clickBindSubform();
 
        //数据加载
        var initTempData = customShow.options.initTempDatas[itemId];
        if (initTempData != undefined) {
            var parentsubFormNum = customShow.options.customItemShow.item[itemId].parentsubFormNum;
            initTempData = customShow.dbItemToShowItem(itemId, "dropdownlistText", initTempData, "customViewUEditorCss", dropdowntype, parentsubFormNum);
            // customShow.options.initTempDatas[itemId] = initTempData;
            customBase.setItemValue(itemId, "dropdownlistText", initTempData, "customViewUEditorCss", dropdowntype);
            customShow.setShowItem(itemId, "dropdownlistText", initTempData);
        } else {
            if (customShow.options.customItemShow.item[itemId].tag_Attribute.datasourcetype == "custom") {
                var customItemsTemp = customShow.options.customItemShow.item[itemId].tag_Attribute.custom;
                ////////console.log(customItemsTemp);
                var initTempDataCustom = []
                var j = 0;
 
                for (var i = 0; i < customItemsTemp.length; i++) {
                    if (customItemsTemp[i].ischecked) {
                        initTempDataCustom[j] = customItemsTemp[i].itemtext;
                        j++;
                        // ////////console.log(customItems[i].itemtext);
                        // ////////console.log(customItems[i]);
                    }
                }
                ////////console.log(initTempDataCustom);
                if (customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype == "single") {
                    customBase.setItemValue(itemId, "dropdownlistText", [initTempDataCustom[0]], "customViewUEditorCss", dropdowntype);
                } else {
                    customBase.setItemValue(itemId, "dropdownlistText", initTempDataCustom, "customViewUEditorCss", dropdowntype);
                }
            }
        }
    }
    setCustomradio = function (itemId, listData) {
        var tag_Type = customItems[itemId].tag_Type;
        customBase.options.dropdownlistText[itemId] = listData;
        $('.customViewUEditorCss #' + itemId).removeClass('select2Maxheight').addClass('select2Maxheight');
        var item = $('.customViewUEditorCss #' + itemId + " .line");
        var oNodeclass = "custom-check";
        if (tag_Type == "radio") {
            oNodeclass = "custom-radio";
        } else if (tag_Type == "checkbox") {
            oNodeclass = "custom-check";
        }
        var oNode = "";
        var customItemsData = customBase.options.customItems;
        for (data in customItemsData) {
            // console.log(customBase.options.customItems[data]);
            // console.log(itemId);
            for (var i = 0; i < listData.length; i++) {
                if (customBase.options.customItems[data].id == itemId) {
                    //   11/9  李元杰 是否有选中
                    console.log(customBase.options.customItems[data])
                    var curFlag = '';
                    if(listData[i].ischecked){
                        curFlag = 'cur'
                    }
                    if (customBase.options.customItems[data].editable) {
                        oNode += '<li class="ui-state-default" style="height:28px"><span class="' + oNodeclass + ' ' + curFlag +' " value="' + listData[i].value + '" ><i class="label"></i>' + listData[i].text + '</span></li>';
                    } else {
                        oNode += '<li class="ui-state-default" style="height:28px"><span class="' + oNodeclass + ' ' + curFlag +' readonly" value="' + listData[i].value + '" ><i class="label"></i>' + listData[i].text + '</span></li>';
                    }
                    // }else{
                    //   oNode += '<li class="ui-state-default" style="height:28px"><span class="'+oNodeclass+'" value="'+listData[i].value+'" ><i class="label"></i>'+listData[i].text+'</span></li>';
                }
            };
            // if(customBase.options.customItems[data].id == itemId ){
            // //    console.log(listData);
 
            // }
        }
        for (var i = 0; i < $(item).length; i++) {
            // item.empty();
            $($(item)[i]).empty();
            $(item)[i].innerHTML = oNode;
        }
        customShow.clickBindSubform();
        //数据加载
        var initTempData = customShow.options.initTempDatas[itemId];
        if (initTempData != undefined) {
            var parentsubFormNum = customShow.options.customItemShow.item[itemId].parentsubFormNum;
            initTempData = customShow.dbItemToShowItem(itemId, tag_Type, initTempData, "customViewUEditorCss", '', parentsubFormNum);
            // customShow.options.initTempDatas[itemId] = initTempData;
            customBase.setItemValue(itemId, tag_Type, initTempData, "customViewUEditorCss");
            customShow.setShowItem(itemId, tag_Type, initTempData);
        }
        console.log($(item))
        //  12/11 禁用背景
        var spanDiv = $(item).find('li').find('span');
        console.log($(item).parent().attr('editable'))
        if (($(item).parent().attr('editable') == "true")) {
            $(item).find('li').find('span').addClass("disableUrl");
            for (var i = 0; i < spanDiv.length; i++) {
                console.log($(spanDiv[i]))
                if (tag_Type == "radio") {
                    $(spanDiv[i]).removeClass("disableRadUrl");
                } else if (tag_Type == "checkbox") {
                    $(spanDiv[i]).removeClass("disableChkUrl");
                }
            }
        } else {
            for (var i = 0; i < spanDiv.length; i++) {
                console.log($(spanDiv[i]))
                if (tag_Type == "radio") {
                    $(spanDiv[i]).addClass("disableRadUrl");
                } else if (tag_Type == "checkbox") {
                    $(spanDiv[i]).addClass("disableChkUrl");
                }
 
            }
        }
    }
    setTree = function (itemId, setting, listData) {
        $('.customViewUEditorCss  #' + itemId + "tree").empty();
        // 在这里设置 树的id 和 listData
        customShow.listData[itemId] = listData;
        customShow.itemId = itemId
        var treeDiv = $('div#' + itemId);
        if (treeDiv.length != 1) {
            for (var i = 0; i < treeDiv.length - 1; i++) {
                var ultreeId = $(treeDiv[i]).find('ul').attr('id');
                ultreeId = ultreeId.split('tree')[0] + 'tree';
                $(treeDiv[i]).find('ul').attr('id', ultreeId + i);
                $.fn.zTree.init($($('.customViewUEditorCss  #' + itemId + "tree" + i)), setting, listData);
                // $('#'+itemId).parents('div[name="TreeWin"]').find('.citySel').addClass('disableColor')
                console.log('#' + itemId);
                var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree" + i);
                // customShow.setTree.disableParentNode.set(treeObj);
                if (treeObj) {
                    treeObj.expandAll(true);
                }
            }
        } else {
            $.fn.zTree.init($($('.customViewUEditorCss  #' + itemId + "tree")), setting, listData);
            var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
            var treeDefaultSet;
            if (treeObj) {
                treeObj.expandAll(true);
            }
            var defaultValue = $('#' + itemId).attr('defaultvalue');
            var dataObj, defaultValue;
            var treeDefaultSet = customShow.treeDefaultSet(treeObj, defaultValue)
            defaultValue = treeDefaultSet[0]
            dataObj = treeDefaultSet[1];
            $('#' + itemId).attr('value', JSON.stringify(dataObj))
            $('#' + itemId).prev().find('.citySel').val(defaultValue);
            //  12/8 禁止选中  李元杰'
            console.log(itemId)
            var treeArray = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'tree'])
            for (var i = 0; i < treeArray.length; i++) {
                if (treeArray[i].tag_Id == itemId) {
                    if (treeArray[i].tag_Attribute.disableParentNode) {
                        customShow.setTree.disableParentNode.set(treeObj)
                    }
                }
            }
        }
        var initTempData = customShow.options.initTempDatas[itemId];
 
        var defaultValue = $('#' + itemId).attr('defaultvalue');
        if (initTempData == 'undefined' || initTempData == undefined) {
            if (defaultValue != '' && defaultValue != 'undefined' && defaultValue != undefined) {
                initTempData = defaultValue;
            } else {
                initTempData = ' '
            }
        }
        // 010110001000010000010000001
        if (initTempData != undefined) {
            customBase.setItemValue(itemId, "tree", initTempData, "customViewUEditorCss");
        }
        customShow.clickBindSubform();
    }
 
 
 
 
    //API数据
    setApiDatasource = function (item, callback) {
        console.log(item)
        var apiUrl = item.tag_Attribute.apiUrl;
        var callbackId = item.tag_Id;
        callbackApiData = function (itemData, url) {
 
            console.log(url)
            var ItemId = url.split("callbackId=")[1];
            console.log(url)
            var item = customShow.options.customItemShow.item[ItemId];
            var apiIdKey = item.tag_Attribute.apiIdKey;//  表示项
            var apiPIdKey = item.tag_Attribute.apiPIdKey;// 表示值
            itemData = itemData.data;
 
            things = [];
            console.log(itemData);
            // var textcolumn = itemData[apiIdKey];
 
            // var valuecolumn = itemData[apiPIdKey];
            // //取得数据长度不一致时数据不设定
            // if (textcolumn.length != valuecolumn.length) {
            //     return;
            // }
            if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
                for (var i = 0; i < itemData.length; i++) {
                    if (i == 0 && item.tag_Type == 'radio') {
                        things[i] = { ischecked: true, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
                    } else {
                        things[i] = { ischecked: false, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
                    }
                };
            } else if (item.tag_Type == 'tree') {
                var apiName = item.tag_Attribute.apiName;
                console.log(apiName)
                // var namecolumn = itemData[apiName];
                // if (textcolumn.length != namecolumn.length) {
                //     return;
                // }
                for (var i = 0; i < itemData.length; i++) {
                    things[i] = { id: itemData[i][apiIdKey], pId: itemData[i][apiPIdKey], name: itemData[i][apiName] };
                };
            } else {
                console.log(itemData)
 
                for (var i = 0; i < itemData.length; i++) {
                    console.log(itemData[i])
                    console.log(apiPIdKey)
                    console.log(apiIdKey)
                    console.log(itemData[i][apiPIdKey])
                    console.log(itemData[i][apiIdKey])
                    things[i] = { id: i, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
 
                };
            }
            console.log(things);
            callback(ItemId, things);
        }
 
        customDataBound.getApiDatasource(apiUrl, callbackId, callbackApiData);
    }
    //主数据
    setMasterData = function (item, callback) {
        var callbackId = item.tag_Id;
        var code = item.tag_Attribute.masterData;
        console.log(code);
        //  11/9
 
 
 
        console.log(callbackId)
        //   if(code == ""){
        //     return;
        //   }
        callbackMasterData = function (itemid, itemData) {
            things = [];
            console.log('√')
            console.log(itemData);
            console.log(itemid);
            var customItems = customBase.options.customItems;
            for (item in customItems) {
                if (customBase.options.customItems[item].id == callbackId) {
 
                }
            }
            item = customShow.options.customItemShow.item[itemid];
            if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
                for (var i = 0; i < itemData.length; i++) {
                    if (i == 0 && item.tag_Type == 'radio') {
                        things[i] = { ischecked: true, value: itemData[i].code, text: itemData[i].value };
                    } else {
                        things[i] = { ischecked: false, value: itemData[i].code, text: itemData[i].value };
                    }
                };
            } else if (item.tag_Type == 'tree') {
                //-------------------------
                console.log(itemData)
                if (itemData != null) {
                    for (var i = 0; i < itemData.length; i++) {
                        things[i] = {
                            id: itemData[i].code,
                            pId: itemData[i].pid,
                            name: itemData[i].value
                        };
                    };
                }
 
            } else if (item.tag_Type == 'dropdownlist') {
                if(itemData != undefined && !_.isNull(itemData)){
                   for (var i = 0; i < itemData.length; i++) {
                        things[i] = { id: i, value: itemData[i].code, text: itemData[i].value };
 
                    };
                }
            } else {
                //其他控件主数据--
            }
            callback(itemid, things);
        }
 
        //数据源数据取得
        customDataBound.getElement(code, callbackId, function (rs) {
            // 修改下拉框样式统一
            if (rs.data == null) {
                callbackMasterData(callbackId, []);
            }
            for (itemid in rs.data) {
                if (rs.data.hasOwnProperty(itemid)) {
                    callbackMasterData(itemid, rs.data[itemid]);
                }
            }
 
 
        });
    }
    //数据源
    setDatasource = function (item, callback) {
        var temp = {};
        datasourceName = item.tag_Attribute.datasource;
        if (datasourceName == "") {
            return;
        }
        if (customShow.options.datasource[datasourceName] == undefined) {
            return;
        }
        temp.columnNames = item.tag_Attribute.textcolumn + "," + item.tag_Attribute.valuecolumn;
        temp.datasource = customShow.options.datasource[datasourceName].datasource;
        temp.databaseName = customShow.options.datasource[datasourceName].databaseName;
        temp.callbackId = item.tag_Id;
        if (item.tag_Type == 'tree') {
            temp.columnNames += "," + item.tag_Attribute.namecolumn;
        }
 
        callbackDatasource = function (rs) {
            console.log(this);
            console.log(this.url);
            var ItemId = this.url.split("callbackId=")[1];
 
            item = customShow.options.customItemShow.item[ItemId];
 
            datasourceName = rs.data;
 
            things = [];
            var textcolumn = datasourceName[item.tag_Attribute.textcolumn];
            var valuecolumn = datasourceName[item.tag_Attribute.valuecolumn];
            if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
                for (var i = 0; i < textcolumn.length; i++) {
                    if (i == 0 && item.tag_Type == 'radio') {
                        things[i] = { ischecked: true, value: valuecolumn[i], text: textcolumn[i] };
                    } else {
                        things[i] = { ischecked: false, value: valuecolumn[i], text: textcolumn[i] };
                    }
                };
            } else if (item.tag_Type == 'tree') {
                var namecolumn = datasourceName[item.tag_Attribute.namecolumn];
                for (var i = 0; i < valuecolumn.length; i++) {
                    things[i] = { id: valuecolumn[i], pId: textcolumn[i], name: namecolumn[i] };
                };
 
            } else {
                for (var i = 0; i < valuecolumn.length; i++) {
                    things[i] = { id: i, value: valuecolumn[i], text: textcolumn[i] };
 
                };
            }
 
            callback(ItemId, things);
        }
 
        //数据源数据取得
        customDataBound.getFieldDatasource(temp, callbackDatasource);
    }
    //自定义数据 ------1001--------
    setCustom = function (item, callback) {
        var custom = item.tag_Attribute.custom;
        things = [];
        if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
            for (var i = 0; i < custom.length; i++) {
                things[i] = { ischecked: custom[i].ischecked, value: custom[i].itemtext, text: custom[i].itemtext };
            };
 
        } else {
            for (var i = 0; i < custom.length; i++) {
                things[i] = { id: i, value: custom[i].itemtext, text: custom[i].itemtext };
            };
        }
        var ItemId = customItem.id;
        callback(ItemId, things);
    }
 
    //树 单选按钮 多选按钮 下拉菜单
    var type = customItems[customItem.id].tag_Type;
    if (type == 'dropdownlist' || type == 'radio' || type == 'checkbox' || type == 'tree') {
        //数据取得顺序
        //按照 选择的情况? 按照主数据?TODO
        var item = customShow.options.customItemShow.item[customItem.id];
 
        //数据清空
        if (type == 'dropdownlist') {
            $($('.customViewUEditorCss #' + customItem.id)[0]).empty();
            $($($('.customViewUEditorCss #' + customItem.id)[0]).parentNode).find(".select2").remove();
            var visibleTemp = customShow.options.customItemShow.item[customItem.id].tag_Attribute.visible;
            if (!visibleTemp) {
                $($($('.customViewUEditorCss #' + customItem.id)[0]).parentNode).remove();
                return;
            } else {
                $('.customViewUEditorCss #' + customItem.id).select2({ theme: "classic", width: '240' });
            }
        } else if (type == 'radio' || type == 'checkbox') {
            //  var item = $('.customViewUEditorCss #'+customItem.id +" .line");
            $($($('.customViewUEditorCss #' + customItem.id + " .line"))[0]).empty();
        }
 
        var datasourcetype = item.tag_Attribute.datasourcetype;
        //    ////console.log(datasourcetype);
        console.log(item);
        console.log(datasourcetype);
        setDataItem[datasourcetype](item, setCallbackItem);
        // _.each($(".customShow .tdContentClass"), opt => {
        //     // $(opt).attr("title", $(opt).children().children().html());
        //     console.log($(opt).html())
        //     if ($(opt).children().children().attr("type") == "text") {
        //         $(opt).attr("title", $(opt).children().children().val());
        //     } else {
        //         console.log(_.cloneDeep($(opt).children().children()))
        //         console.log(opt.innerHTML)
        //         console.log($(opt).children().children()[0].innerHTML)
        //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
        //     }
        // })
    }
    // return itemData;
    // _.each($(".customShow .tdContentClass"), opt => {
    //     // $(opt).attr("title", $(opt).children().children().html());
    //     console.log($(opt).html())
    //     if ($(opt).children().children().attr("type") == "text") {
    //         $(opt).attr("title", $(opt).children().children().val());
    //     } else {
    //         console.log(_.cloneDeep($(opt).children().children()))
    //         console.log(opt.innerHTML)
    //         console.log($(opt).children().children()[0].innerHTML)
    //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
    //     }
    // })
}
//  12/7  设置默认值
customShow.treeDefaultSet = function (treeObj, defaultValue) {
    var objValue = {};
    var defaultValueArray = [];
    var valueData;
    var dataObj = {};
    var dataObjArray = []
    //  12/7 树的默认值
    //  判断单选多选
    // if(defaultValue.indexOf(',') == -1){
    if(defaultValue){
        //  单选
        if (defaultValue.indexOf(',') == -1) {
            var nodes = treeObj.getNodeByParam("id", defaultValue, null);
            if (!_.isNull(nodes)) {
                // 2017 /11/6 选中
                //选择节点设定
                treeObj.checkNode(nodes, true, true);
                treeObj.expandAll(true);
                dataObj[defaultValue] = '1';
                if (defaultValue == nodes.id) {
                    defaultValue = nodes.name;
                }
            }
        } else {   //多选
            defaultValueArray = defaultValue.split(',');
            for (var i = 0; i < defaultValueArray.length; i++) {
                valueData = defaultValueArray[i]
                dataObj[valueData] = '1'
            }
            for (var i = 0; i < defaultValueArray.length; i++) {
                var nodes = treeObj.getNodeByParam("id", defaultValueArray[i], null);
                if (!_.isNull(nodes)) {
                    // 2017 /11/6 选中
                    //选择节点设定
                    treeObj.checkNode(nodes, true, true);
                    treeObj.expandAll(true);
                    if (defaultValueArray[i] == nodes.id) {
                        defaultValueArray[i] = nodes.name;
                    }
                }
            }
            defaultValue = defaultValueArray.join(',')
        }
        console.log(dataObj)
        objValue[0] = defaultValue;
        objValue[1] = dataObj;
    }
    return objValue;
    // }
}
 
//画面表示项目一览取得
customShow.getItemsList = function () {
 
    var items = customShow.options.customItemShow.item;
    var itemsList = {};
 
    for (i in items) {
        if (items.hasOwnProperty(i)) {
            var item = items[i];
            itemsList[item.tag_Attribute.alias] = {
                fieldKey: item.tag_Attribute.alias,
                id: item.tag_Id,
                type: item.tag_Type,
                parentsubFormNum: item.parentsubFormNum,
                visible: item.tag_Attribute.visible,  //可见
                editable: item.tag_Attribute.editable, //可编辑
                mustcheck: item.tag_Attribute.mustcheck, //必填
                approvalmustenter: item.tag_Attribute.approvalmustenter,//审查必须
                defaultvalue: item.tag_Attribute.defaultvalue,
                // field:"",
            }
            console.log(item.tag_Attribute.defaultvalue)
        }
    };
    return itemsList;
}
 
// 子表单事件调用
customShow.clickBindSubform = function () {
    // 单选框
    $('.select .custom-radio').unbind();
    $('.select .custom-radio').on('click', function () {
        // //////////console.log(this.className);
        if (this.className.indexOf("readonly") > -1) {
            return;
        }
        $($(this).parent().parent()).find(".cur").removeClass('cur');
        $(this).addClass('cur').siblings().removeClass('cur');
    });
    customLinkageAnalysis.bindLinkageSubform("radio");
    // 多选框
    $('.select .custom-check').unbind();
    $('.select .custom-check').on('click', function () {
        if (this.className.indexOf("readonly") > -1) {
            return;
        }
        $(this).toggleClass('cur');
        // $($(this).parent().parent().parent().parent()).find(".errorItemCss").removeClass('errorItemCss');
        // //////////console.log($($(this).parent().parent().parent())[0].id);
        // var id = $($(this).parent().parent().parent())[0].id;
        // $("#"+id+"mesageErrDiv").remove();
        // $(".customViewUEditorCss  #"+id).popover('hide')
    });
    customLinkageAnalysis.bindLinkageSubform("checkbox");
    //删除子表单项目
    $('.divshowEditor .iconfontcolorTH').unbind();
    $('.divshowEditor .iconfontcolorTH').on('click', function () {
        ////////////////console.log($(this).parent().parent().parent());
        $(this).parent().parent().parent().parent().parent().remove();
    });
    $('.iconfontcolor').unbind();
    $('.iconfontcolor').on('click', function () {
        $(this).parent().parent().parent().remove();
    });
 
    //-----------------日期类型------------------------
    // $('.dateFromyyyy').unbind();
    // $('.dateFromyyyymm').unbind();
    // $('.dateFromyyyymmdd').unbind();
    // $('.dateFromhhmiss').unbind();
    // Flatpickr.localize(Flatpickr.l10ns.zh); // 设置为中文
    flatpickr('.customViewUEditorCss .dateFromyyyy', {
        dateFormat: "Y",
    });
    flatpickr('.customViewUEditorCss .dateFromyyyymm', {
        dateFormat: "Y-m",
    });
    flatpickr('.customViewUEditorCss .dateFromyyyymmdd', {
        dateFormat: "Y-m-d",
    });
    flatpickr('.customViewUEditorCss .dateFromhhmiss', {
        dateFormat: "Y-m-d H:i",
        time_24hr: true,
        enableTime: true
    });
    // customLinkageAnalysis.bindLinkageSubform("calendar");
}
 
//各控件初期
customShow.controlInit = function (showClass) {
 
    var customItems = customBase.options.customItems;
    console.log(customItems)
    if ('customShow' != showClass) {
        //HTML内容控件初期化
        var htmlediterShow = $(".customViewUEditorCss .htmlediterShowClass");
 
        for (var i = 0; i < htmlediterShow.length; i++) {
            var itemId = htmlediterShow[i].id;
            var htmlediterShowItemId = itemId.replace("Item", "");
            // var heightShow = htmlediterShow[i].getAttribute("heightShow");
            // var widthShow = htmlediterShow[i].getAttribute("widthShow");
            // ////////console.log(customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.alias);
            var heightShow = customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.height;
            var widthShow = customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.width;
            // customShow.options.customItemShow.item[itemId].tag_Attribute.alias;
            if (widthShow == undefined || heightShow == undefined) {
                widthShow = 200;
                heightShow = 200;
            }
 
            customShow.options.htmlediterShow[itemId] = {};
            customShow.options.htmlediterShow[itemId].widthShow = widthShow;
            customShow.options.htmlediterShow[itemId].heightShow = heightShow;
 
 
            UE.getEditor(itemId, {
                // serverUrl :url,
                //allowDivTransToP: false,//阻止转换div 为p
                toolleipi: true,//是否显示,设计器的 toolbars
                textarea: 'design_content',
                //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
                toolbars: [[
                    'source', '|', 'bold', 'underline', 'strikethrough', 'forecolor', 'backcolor','removeformat']],
                //关闭字数统计
                wordCount: false,
                //关闭elementPath
                elementPathEnabled: false,
                //默认的编辑区域高度
                initialFrameHeight: heightShow,
                scaleEnabled: true,
                //高度
                // initialFrameHeight:heightShow,
                // readonly:true,
                //,iframeCssUrl:"css/bootstrap/css/bootstrap.css" //引入自身 css使编辑器兼容你网站css
                //更多其他参数,请参考ueditor.config.js中的配置项
            }).ready(function () {
                ////////////console.log(customBase.options.customItems);
                id = this.key;
                for (i in customBase.options.customItems) {
                    if (customBase.options.customItems.hasOwnProperty(i)) {
                        var idItem = id.replace("Item", "");
                        if (customBase.options.customItems[i].id == idItem) {
                            if (customShow.options.itemFormbase == "") {
                                UE.getEditor(id).setContent(customBase.options.customItems[i].defaultvalue);
                            } else {
                                var defaultvalue = customShow.options.itemFormbase[i];
                                //  ////////console.log(defaultvalue);
                                //  defaultvalue=defaultvalue+" ";
                                UE.getEditor(id).setContent(defaultvalue);
                                //  setTimeout(function() {
                                //       // this.body.focus();
                                //       ////////console.log(UE.getEditor(id));
                                //       UE.getEditor(id).options.scaleEnabled =false;
                                //   }, 1000);
                            }
                        }
                        //非表示
                        //  if(!customBase.options.customItems[i].visible){
                        //     $(".customViewUEditorCss #"+id).addClass("cfg_contentNone");
                        //  }
                    }
                }
                $(".edui-editor-bottomContainer").addClass("cfg_contentNone");
                this.body.onclick = function (event, ui) {
                    //////////console.log(this);
                    //////////console.log(this.getAttribute("id"));
                    // $(this).removeClass("errorItemCss");
                    // $("#"+this.getAttribute("id")+"mesageErrDiv").remove();
                }
            })
        };
    }
    //-----------------日期类型------------------------
 
    flatpickr('.customViewUEditorCss .dateFromyyyy', {
        dateFormat: "Y",
    });
    flatpickr('.customViewUEditorCss .dateFromyyyymm', {
        dateFormat: "Y-m",
    });
    flatpickr('.customViewUEditorCss .dateFromyyyymmdd', {
        dateFormat: "Y-m-d",
    });
    flatpickr('.customViewUEditorCss .dateFromhhmiss', {
        dateFormat: "Y-m-d H:i",
        time_24hr: true,
        enableTime: true
    });
 
    if ('customShow' != showClass) {
        //删除项目(select2项目删除)
        $('.selection').remove();
        $(".ztree").empty();
    }
    //下拉列表初期化
 
    // $(".dropdowntypeCss").select2({theme: "classic",width: '240'});
    // //下拉列表不可用
    $('.' + showClass + " .editableDisabled").prop("disabled", true);
 
    // 金融控件
    for (item in customItems) {
        if (customItems.hasOwnProperty(item)) {
            //金融控件
            if (customItems[item].type == "amount") {
                if ("customViewUEditorCss" == showClass) {
                    var itemId = customItems[item].id;
                    // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("defaultvalue");
                    var showCustomItem = customShow.options.customItemShow.item[itemId];
                    // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
                    // var widthQrcode = $("#"+customItems[item].id)[0].width;
                    var itemValue = showCustomItem.tag_Attribute.defaultvalue;
                    var widthQrcode = showCustomItem.tag_Attribute.width;
                    if (widthQrcode == 0 || widthQrcode == undefined) {
                        widthQrcode = 60;
                    }
                    var divIcons = document.createElement("input");
                    divIcons.setAttribute("type", "text");
                    divIcons.setAttribute("id", customItems[item].id + "amount");
                    divIcons.setAttribute("style", "width: " + widthQrcode + "px; height:33px");
                    divIcons.setAttribute("class", "amountShowTextClass cfg_contentNone");
                    divIcons.setAttribute("value", itemValue);
                    $('.' + showClass + " #" + itemId)[0].after(divIcons);
                    $('.' + showClass + " #" + itemId).addClass("amountShowClass");
                }
                //申请单
            }
            else if (customItems[item].type == "mytext") {
                if ("customViewUEditorCss" == showClass) {
                    var itemId = customItems[item].id;
                    ////console.log(itemId);
                    var showCustomItem = customShow.options.customItemShow.item[itemId];
                    // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
                    // var widthQrcode = $("#"+customItems[item].id)[0].width;
                    var itemValue = showCustomItem.tag_Attribute.qrcodeurl;
                    var widthQrcode = showCustomItem.tag_Attribute.width;
                    if (widthQrcode == 0 || widthQrcode == undefined) {
                        widthQrcode = 60;
                    }
                    var divIcons = document.createElement("div");
                    var div = document.createElement("div");
                    divIcons.setAttribute("id", customItems[item].id + "qrcode");
                    divIcons.setAttribute("class", "boxBtn");
                    divIcons.setAttribute("myAttr", itemId);
                    divIcons.innerHTML = '选择数据';
                    divIcons.setAttribute("maxlength", 200);
                    $('.' + showClass + " #" + itemId).eq(0).after(divIcons);
                    //        $(" #"+itemId+"divid")[0].after(divIcons);
                }
                //二维码
            } else if (customItems[item].type == "qrcode") {
                if ("customViewUEditorCss" == showClass) {
                    var itemId = customItems[item].id;
                    var showCustomItem = customShow.options.customItemShow.item[itemId];
                    // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
                    // var widthQrcode = $("#"+customItems[item].id)[0].width;
                    var itemValue = showCustomItem.tag_Attribute.qrcodeurl;
                    var widthQrcode = showCustomItem.tag_Attribute.width;
                    var heightqrcode = showCustomItem.tag_Attribute.height;
                    if (heightqrcode == 0 || heightqrcode == undefined) {
                        heightqrcode = 165;
                    }
                    if (widthQrcode == 0 || widthQrcode == undefined) {
                        widthQrcode = 165;
                    }
                    
                    var divIcons = document.createElement("input");
                    divIcons.setAttribute("type", "text");
                    divIcons.setAttribute("id", customItems[item].id + "qrcode");
                    divIcons.setAttribute("style", "width: " + widthQrcode + "px;height:33px");
                    divIcons.setAttribute("class", "qrcodeShowTextClass cfg_contentNone");
                    divIcons.setAttribute("value", itemValue);
                    divIcons.setAttribute("maxlength", 200);
                    $('.' + showClass + " #" + itemId)[0].after(divIcons);
                    $('.' + showClass + " #" + itemId)[0].setAttribute("style", "width: " + widthQrcode + "px;height:" + heightqrcode + "px");
                    $('.' + showClass + " #" + itemId).addClass("qrcodeShowClass");
                }
                //条形码
            } else if (customItems[item].type == "barcode") {
                if ("customViewUEditorCss" == showClass) {
                    var itemId = customItems[item].id;
                    // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("text");
                    // var widthBarcode = $("#"+customItems[item].id)[0].width;
                    var showCustomItem = customShow.options.customItemShow.item[itemId];
                    // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
                    // var widthQrcode = $("#"+customItems[item].id)[0].width;
                    var itemValue = showCustomItem.tag_Attribute.text;
                    var widthBarcode = 165;
                    // if(widthBarcode == 0){
                    //   widthBarcode = 100;
                    // }
                    var divIcons = document.createElement("input");
                    divIcons.setAttribute("type", "text");
                    divIcons.setAttribute("id", customItems[item].id + "barcode");
                    divIcons.setAttribute("style", "width: " + widthBarcode + "px;height:33px");
                    divIcons.setAttribute("class", "barcodeShowTextClass cfg_contentNone");
                    divIcons.setAttribute("value", itemValue);
                    divIcons.setAttribute("maxlength", 200);
                    $('.' + showClass + " #" + itemId)[0].after(divIcons);
                    $('.' + showClass + " #" + itemId).addClass("barcodeShowClass");
                }
                //子表单设定
            } else if (customItems[item].type == "subform") {
                var itemId = customItems[item].id;
                var itemTwo = itemId;
                var itemSubform = $('.' + showClass + " #" + itemId + "ActiveId");
                //lym
                //位总div添加id
                $("#" + itemId + "ActiveId").find(".usfile").attr("id", itemTwo + "uld");
                //为a标签添加id
                $("#" + itemId + "ActiveId").find(".usfile a").attr("id", itemTwo + "uis");
                $("#" + itemId + "ActiveId").find(".usfile a").attr("itemId", itemTwo);
                //为inputFile添加id
                $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("itemId", itemTwo);
                $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("id", itemTwo + "btn");
                $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form").attr("itemId", itemTwo);
 
                //////////////console.log(item);
                var ulIcon = document.createElement("ul");
                var liIcon = "";
                var m_customItems = customShow.options.customItemShow.item;
                console.log(customBase.options)
                var subItems = [];
                var parentNum = itemId.replace("itemId_", "");
                _.each(m_customItems, opt => {
                    if (opt.parentsubFormNum == parentNum) {
                        subItems.push(opt);
                    }
                })
                console.log(subItems)
                _.remove(subItems, n => {
                    return n.tag_Attribute.alias == "DATAROWNUM" || n.tag_Attribute.visible == false;
                });
                //_.sortBy(orderArr, ['fieldOrderNum']);
                subItems = _.sortBy(subItems, ['fieldOrderNum']);
                _.each(subItems, opt => {
                    console.log(opt)
                    if (opt.tag_Type == "number") {
                        liIcon += "<li class='n_totle'><input class='" + opt.tag_Id + "totle textCssDiv defaultHeight' type='text' readonly></li>"
                        console.log(1)
                    } else {
                        liIcon += "<li class='p_totle'></li>"
                        console.log(2)
                    }
                });
                $(ulIcon).append(liIcon);
                $("#" + itemId + "ActiveId").find(".h_totle").append(ulIcon);
                console.log($("#" + itemId + "ActiveId").find(".h_totle"))
                console.log(ulIcon)
                // 单行文本 多行文本 数字  日历
            } else if (customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number" || customItems[item].type == "calendar") {
                var itemId = customItems[item].id;
                var defaultvalue = $("#" + itemId).attr("defaultvalue");
                //  12/4  判断是否存在当前时间
                var calendar = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'calendar'])
                for (var i = 0; i < calendar.length; i++) {
                    if (calendar[i].tag_Attribute.currentDate) {
                        if (itemId == calendar[i].tag_Id) {
                            defaultvalue = customShow.currentDate
                        }
                    }
                }
                console.log(defaultvalue)
                // 之前表单日历默认值不存在时 12/4
                if (defaultvalue == undefined || defaultvalue == 'undefined') {
                    defaultvalue = ''
                }
                customBase.setItemValue(itemId, "text", defaultvalue);
                //数字验证事件追加
                if (customItems[item].type == "number") {
                    //数值型控件验证
                    $("#" + itemId).unbind('blur');
                    $("#" + itemId).on('blur', function (e) {
                        var numbertype = $(this)[0].getAttribute("numbertype");
                        if (numbertype == "decimal") {
                            var decimalplace = $(this)[0].getAttribute("decimalplace");
                            decimalplace = parseInt(decimalplace);
                            if ($(this)[0].value != "") {
                                $(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
                            }
 
                        }
                    });
                }
            } else if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
                customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
                if ('customShow' != showClass) {
                    //数据源绑定
                    customShow.setDatasourceData(customItems[item]);
                }
            } else if (customItems[item].type == 'splitline') {
                //分割线
                var itemId = customItems[item].id;
                $('.' + showClass + " #" + itemId + "ActiveId").addClass("layoutsetting8");
            } else if (customItems[item].type == 'tree') {
                var itemId = customItems[item].id;
                var defaultvalue = $("#" + itemId)[0].getAttribute("defaultvalue");
 
                // 之前表单树形默认值不存在时 12/7
                if (defaultvalue == undefined || defaultvalue == 'undefined') {
                    defaultvalue = ''
                }
                customBase.setItemValue(itemId, "text", defaultvalue);
            }
            //初始属性设定
            if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
                customItems[item].type == 'checkbox' || customItems[item].type == 'tree' ||
                customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number"
                || customItems[item].type == "calendar" || customItems[item].type == "fileupload"
                || customItems[item].type == "qrcode" || customItems[item].type == "barcode"
                || customItems[item].type == "htmlediter" || customItems[item].type == "link"
                || customItems[item].type == "subform"
            ) {
                console.log(customBase.options.customItems[item])
                customShow.setShowAttribute(customBase.options.customItems[item]);
            }
            // 12/15
            if (customItems[item].type == "link") {
                var linkurl = customShow.costType[customItems[item].id].tag_Attribute.linkurl;
                if(linkurl == ''){
                    linkurl = 'javascript:void(0)';
                }
                if(customShow.costType[customItems[item].id].tag_Attribute.editable){//不可编辑控制  李伟民 0124
                    $('#'+customItems[item].id).attr('href',linkurl)
                }
            }
        }
    };
    //事件追加
    customShow.clickBindSubform();
 
}
 
//固定事件的绑定
var index_i = 0;
customShow.clickBind = function () {
 
    //子表单事件追加
    customShow.clickBindSubform();
 
    //  //保存按钮按下
    //  $(".fromSaveCss").on('click', function() {
    //     customShow.onclickSave();
    //   });
 
    //  //取消按钮按下
    //  $(".cancelCss").on('click', function() {
    //     customShow.onclickCancel();
    //   });
 
 
    // 子表单添加记录事件
 
    $('.subformAdd').unbind();
    function addSubFunc() {
        //子表单项目追加
        //console.log($(this)[0]);
        customShow.addsubformList($(this)[0], "customViewUEditorCss");
        //  customShow.setXhSelectListAdd();
        //子表单事件追加
        customShow.clickBindSubform();
        //公式初期化
        customLinkageAnalysis.bindLinkage();
        customShow.oneTotle();
        //console.log($('.subformAdd'));
        $('.subformAdd').unbind('click', addSubFunc);
        $('.subformAdd').on('click', addSubFunc);
        //行程排序初期化
        customShow.journeySort();
        SC.noBillCheckInit()//无票据行程验证
 
    }
    $('.subformAdd').on('click', addSubFunc);
 
    //主数据丢失
    //   $('.subformAdd').unbind();
    //   $('.subformAdd').on('click', function(){
    //       console.log(1)
    //     //子表单项目追加
    //     customShow.addsubformList($(this)[0],"customViewUEditorCss");
    //     //子表单事件追加
    //     customShow.clickBindSubform();
    //     //公式初期化
    //  customLinkageAnalysis.bindLinkage();
    //         //行程排序初期化
    //          customShow.journeySort();
    //   });
 
    //图片文件上传
    var uploaderImage = $(".customViewUEditorCss .uploaderImage");
    for (var i = 0; i < uploaderImage.length; i++) {
 
        var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
        var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
        // 参数设定
        var potion = {
            id: uploaderImage[i].id,
            width: imageItem.tag_Attribute.width,
            height: imageItem.tag_Attribute.height,
            formid: customShow.options.formid,
            imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
            editable: imageItem.tag_Attribute.editable, //是否可编辑
            defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
            ItemReady: itemList,
            visible:imageItem.tag_Attribute.visible
        }
        customBase.uploaderShow(potion);
        // customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
 
    };
 
    //lym子表单上传
    $('.sonImportFile').unbind();
    $(".sonImportFile").click(function () {
        console.log("进入点击事件");
        //var checkedObj = $("#tbody input[type=checkbox]:checked");
        console.log("fdsffddffd");
        // //创建文件上传对象
        var a = $(this).attr("itemId")
        console.log(a)
        $("#" + a + "btn").click(
 
        );
        $("#" + a + "btn").change(function () {
            console.log("uqwhdoqwhdo");
            //var objFile = $("#"+itemTwo+"btn");
            //改变
 
            let mthis = this;
            var tenantId = localStorage.getItem("tenantID");
            var formID = localStorage.getItem("newFormID");
            var tenant = JSON.parse(tenantId);
            var user = localStorage.getItem("userName");
            var userName = JSON.parse(user);
            var aba = a;
            console.log(aba);
            //结束
            console.log(tenantId);
            console.log(formID);
            var objFile = $(this);
            if (objFile.value == "") {
                return;
            } else {
                var f_content = this.value;
                var fileext = f_content.substring(f_content.lastIndexOf("."), f_content.length);
                fileext = fileext.toLowerCase()
                if (fileext != '.xls') {
                } else {
                    //改变
                    var dataObj = { "formID": formID, "tenantID": tenant.tenantID, "userName": userName.userName, "rowNum": aba }
                    //结束
 
                    var options = {
                        url: url, //上传文件的路径 
                        type: 'post',
                        dataObj: dataObj,
                        async: false,
                        success: function (data) {//异步上传成功之后的操作
                            if (data != undefined && data != null) {
                                console.log("返回参数");
                            }
 
                        }
                    };
 
                    var requestData = window.SonfiledUpload(dataObj, options, "/excel/impSonExcel", $(this).attr("itemId"), fileext);
                    var excels = JSON.parse(requestData);
                    console.log(requestData);
                    //                console.log("最后");
                    //
                    //                console.log($(this).attr("itemId"))
                    //改变
                    $(mthis).val("");
                    if (excels.data != undefined) {
                        customShow.addRow($(this).attr("itemId"), excels.data);
                        toastr.info("导入成功");
 
                    } else {
                        toastr.error("表格数据格式有误!");
                    }
                    //结束
                    //清除后台返回结果
                    window.localStorage.removeItem("seccData");
 
                }
            }
        })
    });
    //文本文件上传
    var uploaderFile = $(".customViewUEditorCss .uploaderFile");
    console.log(uploaderFile)
    for (var i = 0; i < uploaderFile.length; i++) {
 
        var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
        debugger
        var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
        // 参数设定
        var potion = {
            id: uploaderFile[i].id,
            width: imageItem.tag_Attribute.width,
            height: imageItem.tag_Attribute.height,
            formid: customShow.options.formid,
            imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
            editable: imageItem.tag_Attribute.editable, //是否可编辑
            defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
            ItemReady: itemList,
            visible:imageItem.tag_Attribute.visible
        }
        customBase.uploaderFileShow(potion);
        // customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
 
    };
 
    //必须入力验证
    // var mustcheckCss = $(".mustcheckCss");//-----------todo
    // for (var i = 0; i < mustcheckCss.length; i++) {
    //   ////////////////console.log('#'+$(mustcheckCss)[i].id);
    // };
 
    //子表单默认删除项目去掉
    //子表单第一行可删除
    // $(".iconfontcolor").addClass("cfg_contentNone");
    // $(".iconfontcolorTH").addClass("cfg_contentNone");
 
    //金融控件点击事件
    $('.amountShowClass').unbind();
    $('.amountShowClass').on('click', function () {
        var editable = $(this)[0].getAttribute("editable");
        //编辑设定
        if (editable == "false") {
            return;
        }
 
 
        $(this).addClass("cfg_contentNone");
        $("#" + $(this)[0].id + "amount").removeClass("cfg_contentNone");
        $("#" + $(this)[0].id + "amount").focus();
    });
 
    //金融控件点击事件
    $('.amountShowTextClass').unbind();
    $('.amountShowTextClass').on('blur', function () {
        var id = $(this)[0].id;
        //表示的控件ID取得
        var idTemp = id.replace("amount", "");
 
        var showCustomItem = customShow.options.customItemShow.item[idTemp];
        // var widthqrcode = $("#"+idTemp)[0].width;
        // var heightqrcode = $("#"+idTemp)[0].height;
        var widthqrcode = showCustomItem.tag_Attribute.width;
        var heightqrcode = showCustomItem.tag_Attribute.height;
        if (heightqrcode == 0 || heightqrcode == undefined) {
            heightqrcode = 24;
        }
        if (widthqrcode == 0 || widthqrcode == undefined) {
            widthqrcode = 200;
        }
 
        //金额组件
        //默认数值
        var defaultSize = {
            width: widthqrcode,
            height: heightqrcode,
            defaultvalue: "",
            styleclass: ""
        };
 
        var decimalplace = $(this)[0].getAttribute("decimalplace");
        decimalplace = parseInt(decimalplace);
        if ($(this)[0].value != "") {
            $(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
        }
 
 
        defaultSize.defaultvalue = $(this)[0].value.replace(".", "");
 
        var showItem = customBase.getAmountHtml(defaultSize, true);
        customBase.amount2Image(showItem, "amount", defaultSize, function (amountHtml) {
            // ////////////////console.log(idTemp);
            $("#" + idTemp + "amount").addClass("cfg_contentNone");
            for (var i = 0; i < $("." + idTemp + "value").length; i++) {
                $("." + idTemp + "value")[i].setAttribute("src", amountHtml);
            };
            $("#" + idTemp).removeClass("cfg_contentNone");
        })
    });
    var addVal = [];
 
    //申请单控件点击事件
    $('.chooseMenu').unbind();
    $(".mytext_icon").on("click", function () {
        $(this).closest("[type='mytext']").find('.boxBtn').click();
        console.log(customShow.options);
        console.log(customBase.options);
    })
    $('.boxBtn').on('click', (obj) => {
        console.log(customBase.options)
        addVal = [];
        //取得父页面变量
        var outWindowObj = window.parent;
        var $iconId = $(obj)[0].target.getAttribute("myAttr");
        var iconAttr = customShow.options.customItemShow.item[$iconId];
        console.log(iconAttr);
        if ($("#" + $iconId).attr("formhuixian") != undefined) {
            var formhuixian = JSON.parse($("#" + $iconId).attr("formhuixian"));
        }
        //console.log(formhuixian);
        let head = "";
        if ($(obj)[0].target.previousSibling.getAttribute("chooseForm") != "" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
            console.log(attrData);
            if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//函数分支修改 李伟民 12-05
                var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
                var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
                requestTitle.done(function (res) {
                    var formtitle = [];
                    _.each(res.data, function (tdata) {
                        formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
                    });
                    head = formtitle;
                });
                var attrData = undefined;
            } else {
                var attrData = JSON.parse($(obj)[0].target.previousSibling.getAttribute("chooseForm"));
                head = attrData.huixianObj.chooseData;
            }//函数分支修改 李伟民 12-05
            // window.localStorage.setItem("bussiness", attrData.formID.bussinessSystem)  //不用了?
            //获取id值
            //用于验证是否已经存在div
            var $divsLength = $('#' + $iconId + 'divIcons').length;
            //接收table头请求
            var formId = "";
            if (attrData && attrData.ScreenCondition != undefined) {
                //下拉框取值
                let getVal = attrData.ScreenCondition.child;
                console.log(getVal);
                _.each(getVal, opts => {
                    _.each(customBase.options.customItems, opt => {
                        if (opt.fieldKey == opts.fieldKey && opts.side == "thi") {
                            opts.value = "";
                            if (opt.type == "dropdownlist") {
                                var getVals = customBase.getItemValue(opt.id, "dropdownlistText");
                                console.log(getVals);
                                if (getVals[0][0] != undefined) {
                                    opts.value = getVals[0];
                                } else {
                                    opts.value = "";
                                }
                            } else if (opt.type == "tree") {//树控件 处理  李伟民 12-5
                                var getVals = customBase.getItemValue(opt.id, opt.type);
                                console.log(getVals);
                                if (getVals[0][0] != undefined) {
                                    opts.value = getVals[0];
                                } else {
                                    opts.value = "";
                                }
                            } else {//树控件 处理  李伟民 12-5
                                var getVals = customBase.getItemValue(opt.id, opt.type);
                                console.log(getVals);
                                if (getVals != undefined) {
                                    opts.value = getVals;
                                } else {
                                    opts.value = "";
                                }
                            }
                        }
                    })
                });
                var sCondition = {};
                //请求数据  筛选条件参数
                let getValue = {};
                getValue.child = getVal;
                getValue.count = attrData.ScreenCondition.count;
                sCondition = getValue;
                let shaixuanData = attrData.ScreenCondition.child;
            }
            if ((attrData && attrData.huixianObj != undefined) || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
                if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
                    formId = undefined;
                } else {
                    formId = attrData.formID;
                }
                if ($divsLength == 0) {
                    //外层蒙版
                    console.log(customShow.options.customItemShow.item)
                    console.log($iconId)
                    var my_text_title = customShow.options.customItemShow.item[$iconId].tag_Attribute.title;
 
                    var menuContent = document.createElement('div');
                    //数据渲染div
                    var divIcons = document.createElement('div');
                    var pageBox = document.createElement('div');
                    var buttonDiv = document.createElement("div");
                    var closeBtn = document.createElement("span");
                    var requersTable = document.createElement("table");
                    var page = document.createElement("div");
                    var bigmodule = document.createElement("div");
                    var mymodule = document.createElement("div");
                    var mymodule2 = document.createElement("div");
                    var modal_content = document.createElement("div");
                    var mymodulebody = document.createElement("div");
                    var mymoduleheader = document.createElement("div");
                    var mymodulefooter = document.createElement("div");
                    var myinput = document.createElement("input");
                    var mybtn = document.createElement("button");
                    mybtn.innerHTML = "<i class='fa fa-search'></i>";
                    mybtn.setAttribute('class', 'btn btn-default');
                    mybtn.setAttribute('onClick', 'showbtn()');
                    mybtn.setAttribute('id', 'showserch');
                    // 添加搜索
                    var serchbox = document.createElement('div');
                    var serchpage = document.createElement('div');
                    var sersrc = document.createElement('script');
                    serchpage.setAttribute('class', 'pagination');
                    serchpage.setAttribute('style', 'display:none');
                    sersrc.setAttribute('src', './../../formEngine/resources/js/dataManagement/findmany.js');
                    var header = '<div _ngcontent-c12="" aria-label="Close" class="close"><span _ngcontent-c12="" class="closeBtn" aria-hidden="true">×</span></div><h4  class="modal-title modal-title_box" id="myModalLabel">' + my_text_title + '</h4>';
                    var footer = '<div _ngcontent-c12="" class="btn btn-primary btn-info btn-action closeBtn">确定</div>';
                    serchbox.setAttribute('class', 'fui-form hides');
                    serchbox.setAttribute('id', 'findserch');
                    serchbox.setAttribute('style', 'display:none !important;');
                    serchbox.innerHTML = '<div class="search_item">' +
                        '<div class="search_column ng-scope" id="copyTemp" style="display: none;">' +
                        '<div class="ng-binding" style="font-size:10px;font-weight:700;"></div>' +
                        '<span style="display: flex;width: 100%;"></span></div>' +
 
                        '<div class="search_column findbox ng-scope" id="copyTempNumber" style="display: none;">' +
                        '<div class="ng-binding" style="font-size:10px;font-weight:700;">预算截止时间</div>' +
                        '<span style="display: flex;position:relative;width:45%;"><input id = "numberFrom" class=""  type="number"/></span>' +
                        '<span> ~ </span>' +
                        '<span style="display: flex;position:relative; width:45%;"><input id = "numberTo" class=""  type="number"/></span></div>' +
                        '<div class="search_column ng-scope" id="copyTempTime" style="display: none;">' +
                        '<div class="ng-binding" style="font-size:10px;font-weight:700;"> 预算截止时间</div>' +
                        '<span style="display: flex; position: relative;width:45%;">' +
                        '<input id = "dateFrom" class=""  type="text"/><i name = "clearFlatPickr" style="position:absolute;padding-left:3px;font-size:16px;top:6px;right:5px;" class="fa fa-calendar" aria-hidden="true"></i>' +
                        '</span><span> ~ </span><span style="display: flex;position:relative;width:45%;">' +
                        '<input id = "dateTo" class=""  type="text"/><i name = "clearFlatPickr" style="position:absolute;padding-left:3px;font-size:16px;top:6px;right:5px;" class="fa fa-calendar" aria-hidden="true"></i>' +
                        '</span></div><div class="search_column_button search_column_button_box">' +
                        '<span><button class="btn btn-info btn-action" id="search_condition"><i class="fa fa-search" aria-hidden="true"></i>&nbsp;&nbsp;查询</button></span>' +
                        '</div></div>' +
                        '<div class="condition_search_footer" style="display:none">' +
                        '<label class="first">' +
                        '<span><select class="ng-pristine ng-untouched ng-valid ng-not-empty" id="pageSelect">' +
                        '<option value="20" selected="selected">20条/页</option>'
                    '<option value="50"> 50条/页</option><option value="100">100条/页</option>' +
                        '</select></span><span class="ng-binding">共<span id = "showTotalPageLeft"></span>页</span></label>' +
                        '<label class="second"> <div class="pagination">' +
                        '<span class="skip first">首页</span><span class="skip pre">上一页</span>' +
                        '<div class="nums"></div><span class="skip next">下一页</span>' +
                        '<span class="skip last">尾页</span></div></label></div>';
                    mymoduleheader.innerHTML = header;
                    mymodulefooter.innerHTML = footer;
                    mymodule.setAttribute('style', 'width:750px;height: 448px;margin:0 auto;');
                    menuContent.setAttribute('id', $iconId + 'menuContent');
                    menuContent.setAttribute('class', 'menuContent');
                    bigmodule.setAttribute('class', 'bigmodule');
                    mymodule.setAttribute('class', 'mymodule');
                    mymodule2.setAttribute('class', 'mymodule2 mymodule2_box');
                    modal_content.setAttribute('class', 'modal-content modal_content_box');
                    mymodulebody.setAttribute('class', 'mymodulebody');
                    $(mymodulebody).css({ "height": "485px", "overflow-y": "auto" });
                    mymoduleheader.setAttribute('class', 'mymoduleheader');
                    mymodulefooter.setAttribute('class', 'mymodulefooter');
                    myinput.setAttribute('class', 'myipt');
                    divIcons.setAttribute('class', 'mytext');
                    divIcons.setAttribute('id', $iconId + 'divIcons');
                    page.setAttribute('id', $iconId + 'pageF');
                    page.setAttribute('class', 'pageF');
                    pageBox.setAttribute('id', $iconId + 'pageBox');
                    pageBox.setAttribute('class', 'pageBox');
                    buttonDiv.setAttribute("class", "buttonDiv");
                    requersTable.setAttribute("class", "requestMenu");
                    $('#' + $iconId + 'ActiveId').append(menuContent);
                    $('#' + $iconId + 'menuContent').append(bigmodule);
                    bigmodule.appendChild(mymodule);
                    mymodule.appendChild(mymodule2);
                    mymodule2.appendChild(modal_content);
                    modal_content.appendChild(mymodulebody);
                    mymodulebody.appendChild(mymoduleheader);
                    mymodulebody.appendChild(serchpage);
                    mymodulebody.appendChild(mybtn);
                    mymodulebody.appendChild(serchbox);
                    mymodulebody.appendChild(divIcons);
                    mymodulebody.appendChild(mymodulefooter);
                    mymodulebody.appendChild(myinput);
                    pageBox.appendChild(page);
                    // $('.mytext').append(sersrc);
                    //            $('.mytext').append(buttonDiv);
                    $('#' + $iconId + 'divIcons').append(requersTable);
                    $('#' + $iconId + 'divIcons').append(pageBox);
                    var lastPage = "";
                    customBase.findmay = {
                        "formId": formId,
                        "sCondition": sCondition,
                        "formhuixian": formhuixian,
                        "head": head,
                        "iconId": $iconId,
                        "addVal": addVal
                    }
                    var count = fenye("5", "1", formId, sCondition, formhuixian, head, $iconId, addVal, []);
 
                    lastPage = Math.ceil(count / 5);
                    //console.log($(".pageF"))
                    $(".pageF").paging({
                        pageNo: 1,
                        totalPage: lastPage,
                        totalSize: count,
                        callback: function (num) {
                            console.log(num);
                            fenye("5", num, formId, sCondition, formhuixian, head, $iconId, addVal, []);
                        }
                    });
                }
                //如果存在就移除
            } else {
                $('#' + $iconId + 'menuContent').remove();
            }
        } else {
            alert('未选择表单')
        }
        // 调用查询方法10/18
        findserch();
    });
    //条形码点击事件
    $('.barcodeShowClass').unbind();
    $('.barcodeShowClass').on('click', function () {
        var editable = $(this)[0].getAttribute("editable");
        //编辑设定
        if (editable == "false") {
            return;
        }
 
        $(this).addClass("cfg_contentNone");
        $("#" + $(this)[0].id + "barcode").removeClass("cfg_contentNone");
        $("#" + $(this)[0].id + "barcode").focus();
    });
    //条形码焦点离开事件
    $('.barcodeShowTextClass').unbind();
    $('.barcodeShowTextClass').on('blur', function () {
        var id = $(this)[0].id;
        //表示的控件ID取得
        var idTemp = id.replace("barcode", "");
        // //默认数值
        // var defaultSize = {
        //   width:$("#"+idTemp)[0].width,
        //   height:$("#"+idTemp)[0].height,
        //   defaultvalue:"",
        //   styleclass:""
        // };
        // var size = $("#"+idTemp)[0].getAttribute("size");
        var showCustomItem = customShow.options.customItemShow.item[idTemp];
        // var size = $("#"+idTemp)[0].getAttribute("size");
        var size = showCustomItem.tag_Attribute.size;
        // defaultSize.defaultvalue = $(this)[0].value;
        customBase.createbarcode(size, $(this)[0].value, function (text, barWidth, barHeight, sizeWidthHeight) {
            $("#canvasbarcode").remove();
            $(document.body).append('<div id="canvasbarcode" style="display: none;"></div>');
            // //设值 距离左侧距离 margin-left: -2px;
            // if(barWidth == 1){
            //    $("."+idTemp+"value").addClass("barcodeMarginleft1");
            // }else if(barWidth == 2){
 
            // }else if(barWidth == 3){
 
            // }else if(barWidth == 4){
 
            // }else if(barWidth == 5){
 
            // }else if(barWidth == 6){
 
            // }
            // $("."+idTemp+"value").addClass("barcodeMarginleft"+barWidth);
 
            jQuery('#canvasbarcode').barcode(text, "code128", { barWidth: barWidth, barHeight: barHeight, showHRI: true });
            var canvasbarcode = $("#canvasbarcode")[0].innerHTML;
            sizeWidthHeight.width = $("#canvasbarcode")[0].style.width;
 
            customBase.amount2Image(canvasbarcode, "barcode", sizeWidthHeight, function (amountHtml) {
                $("#" + idTemp + "barcode").addClass("cfg_contentNone");
                for (var i = 0; i < $("." + idTemp + "value").length; i++) {
                    $("." + idTemp + "value")[i].setAttribute("src", amountHtml);
                };
                $("#" + idTemp).removeClass("cfg_contentNone");
            });
        });
    });
    //二维码点击事件
    $('.qrcodeShowClass').unbind();
    $('.qrcodeShowClass').on('click', function () {
        var editable = $(this)[0].getAttribute("editable");
        //编辑设定
        if (editable == "false") {
            return;
        }
 
        $(this).addClass("cfg_contentNone");
        $("#" + $(this)[0].id + "qrcode").removeClass("cfg_contentNone");
        $("#" + $(this)[0].id + "qrcode").focus();
    });
 
    //二维码焦点离开事件
    $('.qrcodeShowTextClass').unbind();
    $('.qrcodeShowTextClass').on('blur', function () {
        var id = $(this)[0].id;
        //表示的控件ID取得
        var idTemp = id.replace("qrcode", "");
        var showCustomItem = customShow.options.customItemShow.item[idTemp];
        // var widthqrcode = $("#"+idTemp)[0].width;
        // var heightqrcode = $("#"+idTemp)[0].height;
        var widthqrcode = showCustomItem.tag_Attribute.width;
        var heightqrcode = showCustomItem.tag_Attribute.height;
        if (heightqrcode == 0 || heightqrcode == undefined) {
            heightqrcode = 60;
        }
        if (widthqrcode == 0 || widthqrcode == undefined) {
            widthqrcode = 60;
        }
        //默认数值
        var defaultSize = {
            width: widthqrcode,
            height: heightqrcode,
            defaultvalue: "",
            styleclass: ""
        };
        // var size = $("#"+idTemp)[0].getAttribute("size");
 
        defaultSize.defaultvalue = $(this)[0].value;
        $("#canvasqrcode").remove();
        $(document.body).append('<div id="canvasqrcode" style="display: none;"></div>');
        jQuery('#canvasqrcode').qrcode({ width: defaultSize.width, height: defaultSize.height, text: $(this)[0].value });
        var mycanvas = $("#canvasqrcode").find("canvas")[0];
        var image = mycanvas.toDataURL("image/png");
        $("#" + idTemp + "qrcode").addClass("cfg_contentNone");
        for (var i = 0; i < $("." + idTemp + "value").length; i++) {
            $("." + idTemp + "value")[i].setAttribute("src", image);
        };
 
        $("#" + idTemp).removeClass("cfg_contentNone");
    });
}
// 禁用树的父节点   12/9
customShow.setTree = {
    disableParentNode: {
        set: function (treeObj) {
            if (treeObj) {
                var nodes = treeObj.getNodes();
                var level = 0;
                //  获取最底层的层数
                treeObj.getNodesByFilter(function (node) {
                    if (level < node.level) {
                        level = node.level;
                    }
                }); // 查找不是最底层的节点集合
                var nodesFilter = treeObj.getNodesByFilter(function (node) {
                    return (node.level != level)
                });
                //父节点禁止勾选
                for (var i = 0; i < nodesFilter.length; i++) {
                    treeObj.setChkDisabled(nodesFilter[i], true);
                }
            }
        }
    }
}
 
customShow.addtree = function (itemId, item) {
    console.log(customBase.settingRadioType)
    //修改克隆树的实例化 马习同2017-11-21
    console.log(customShow.options.customItemShow.item)
    var customItem = customShow.options.customItemShow.item;
    var ztree = {};
    for (let key in customItem) {
        if (customItem[key].tag_Type == "tree") {
            ztree[key] = customItem[key];
        }
    }
    $('.zTreeDemoBackground').css("display", "none");
    $(".search_input").css("display", "none");
    var index = 0;
    var treeObj;
    // var disableparentnode = false;
    for (let key in ztree) {
        if ($(item).find("#" + key).find('.ztree').parent().attr('disableparentnode') == "true") {
            $(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id  马习同2017-11-21
            if (ztree[key].tag_Attribute.dropdowntype == "single") {
                $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
                //  12/2 树展开
                treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
                customShow.setTree.disableParentNode.set(treeObj)
                if (treeObj) {
                    treeObj.expandAll(true);
                }
            } else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
                $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
                treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
                customShow.setTree.disableParentNode.set(treeObj)
                if (treeObj) {
                    treeObj.expandAll(true);
                }
            }
        } else {
            $(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id  马习同2017-11-21
            if (ztree[key].tag_Attribute.dropdowntype == "single") {
                $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
                //  12/2 树展开
                treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
                console.log(treeObj)
                if (treeObj) {
                    treeObj.expandAll(true);
                }
            } else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
                $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
                treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
                console.log(treeObj)
                if (treeObj) {
                    treeObj.expandAll(true);
                }
            }
        }
        // 克隆后选中节点  12/7 李元杰
        if (!_.isNull(treeObj)) {
            var treeId = treeObj['setting'].treeId;
            var defaultValue = $('#' + treeId).parent().attr('defaultvalue');
            // // 12/7  默认值
            if (defaultValue != '') {
                console.log(treeObj)
                customShow.treeDefaultSet(treeObj, defaultValue);
            }
        }
 
    }
    console.log(treeObj)
    console.log($(item))
    //修改克隆树的实例化End  马习同2017-11-21
    index_i++;
 
}
 
//子表单项目追加
customShow.addsubformList = function (subformAdd, showClass) {
    console.log(i)
    var allcopy = subformAdd.getAttribute('allcopy');
    var itemId = subformAdd.getAttribute('itemId');
    //单行记录更新
    if (allcopy == "false") {
        console.log(customBase.options.customItems);
        console.log(customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv);
        var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
        // 子表单隐藏   马习同 11-13
        //      var item =$("."+showClass+" #"+itemId+"save").children()[0];
        //子表单情况为U情况
        if (item == undefined) {// 子表单回显 修改  李伟民 11-10
            var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
            tbody = tbody[0].cloneNode(true);
            console.log(tbody)
            // 清空input  12/7
            console.log($(item))
            if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
                $(item).find(".citySel").val('');
            }
            $(tbody).find(".select2").remove();
            console.log($(tbody).html());
            $(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
            $(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
            //        $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
            if ($(tbody).find(".table_title").length > 0) {
                //删除头行
                $(tbody).find(".table_title").remove();
            }
            if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr  李伟民 11-14
                $($(tbody).find(".trContentClass")[0]).siblings().remove();
            }// 去除重复的tr  李伟民 11-14
            //        $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
            tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
            console.log(tbody);
            console.log(itemId);
            console.log($(tbody).find("#" + itemId).attr("class"));
            $(tbody).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
            $(tbody).find("input").attr("checkfunarr", "");
            $(tbody).find(".select_get").attr("funarr", "");
            $(tbody).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
            $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改  李伟民 11-10
            customShow.hidesubform();
            customShow.setXhSelectList(false);//添加记录 重复问题  李伟民11-14
        } else {
            item = item[0].cloneNode(true);
            // 12/7 清空input
            var defaultvalue = $(item).find('.zTreeDemoBackground').attr('defaultvalue');
            var itemIdTree = $(item).find('.ztree').attr('id');
            var treeObj = $.fn.zTree.getZTreeObj(itemIdTree);
            console.log(treeObj)
            // 12/7  默认值
            if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
                $(item).find(".citySel").val('');
            }
            $(item).find(".select2").remove();
            $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
            $(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
            item = customShow.addsubformListInit(itemId, item);
            $(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
            $(item).find("input").attr("checkfunarr", "");
            $(item).find(".select_get").attr("funarr", "");
            $(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
            $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
            customShow.setXhSelectList(true);//添加记录 重复问题  李伟民11-14
        }
 
        customShow.addtree(itemId, item);
        //子表单事件追加
    } else {
        //全子表单复制
        //    //console.log(1);
 
        var item = $("." + showClass + " #" + itemId + "ActiveId")[0];
        // //console.log(item);
        item = item.cloneNode(true);
        //console.log(item);
        var divIcons = document.createElement("div");
        divIcons.setAttribute("class", "frm_item_icons allCopyCss");
        var divIcon = document.createElement("div");
        divIcon.setAttribute("class", "frm_item_icon remove");
        var divIconImg = document.createElement("i");
        divIconImg.setAttribute("class", "icon iconfont icon-iconfontcolor93 iconfontcolor");
        divIconImg.setAttribute("style", "text-align: left;font-size: 18px;color: red;");
        // var divIconImg = document.createElement("img");
        // divIconImg.setAttribute("src", "./../../css/img/icon/delete.png");
        divIcon.appendChild(divIconImg);
        divIcons.appendChild(divIcon);
        // $(item).find(".icon-jiahao").parent().addClass("cfg_contentNone");
        $(item).append(divIcons);
        //  清空 树的input
        console.log($(item))
        if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') != '') {
 
        } else {
            $(item).find(".citySel").val('');
        }
        $(item).find(".select2").remove();
        $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
        //console.log(item);
        item = customShow.addsubformListInit(itemId, item);
        // 10/23添加子表单记录
        var beforeitem = $("." + showClass + " #" + itemId + "ActiveId");
        //console.log(beforeitem);
        $(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
        $(item).find("input").attr("checkfunarr", "");
        $(item).find(".select_get").attr("funarr", "");
        $(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
        $("." + showClass + " #" + itemId + "ActiveId").eq(0).after(item);
        // _.each(beforeitem,function(bitem){
        if (beforeitem.length > 1) {
            for (var i = 0; i < beforeitem.length - 1; i++) {
                $(beforeitem[i]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
            }
        } else {
            $(beforeitem[0]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
        }
        customShow.setXhSelectList();//添加记录 重复问题  李伟民11-14
        // });
        customShow.addtree(itemId, item);
    }
}
//马习同修改  子表单隐藏  11/13
customShow.hidesubform = function () {
    // console.log($("[tag_type='subform']"))
    _.each($("[tag_type='subform']"), opt => {
        console.log(opt)
        $($(opt).find(".tdTitleClass")[0]).addClass("cfg_contentNone");
        $($(opt).find(".tdContentClass")[0]).addClass("cfg_contentNone");
    })
    var unvisible = customBase.options.customItems;
    var unvisibleArr = [];
    _.each(unvisible, opt => {
        if (opt.visible == false && opt.parentsubFormNum != 0) {
            unvisibleArr.push(opt)
        }
    })
    //  _.remove(unvisibleArr,n => {
    //     return n.fieldKey == "DATAROWNUM";
    // })
    // console.log(unvisibleArr)
    _.each(unvisibleArr, opt => {
        $("[id='" + opt.id + "']").parent().parent().addClass("cfg_contentNone");
        $($(".customShow #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
        $($(".customViewUEditorCss #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
    })
}
//子表单内数据初始化
customShow.addsubformListInit = function (itemId, tbodys) {
    //console.log(tbodys);
    var itemList = customShow.options.customItemShow.item;
    var item = itemList[itemId];
    var parentsubFormNum = item.columnOrderNum + "";
 
    for (itemListId in itemList) {
        if (itemList.hasOwnProperty(itemListId)) {
            if (itemList[itemListId].parentsubFormNum == parentsubFormNum) {
                //子表单内控件确认
                var type = itemList[itemListId].tag_Type;
                if (type == "text" || type == "textarea" || type == "number") {
                    $(tbodys).find("#" + itemListId)[0].value = itemList[itemListId].tag_Attribute.defaultvalue;
                } else if (type == "calendar") {
                    $(tbodys).find("#" + itemListId)[0].value = "";
                } else if (type == "radio") {
 
                } else if (type == "checkbox") {
 
                } else if (type == "dropdownlist") {
                    var itemListIdTemp = itemListId + "_" + customShow.options.dropdownlist_I;
                    var item = $(tbodys).find("#" + itemListId);
                    ////////console.log($(tbodys));
                    // var dropdowntype =  $(item.find('select'))[0].getAttribute("dropdowntype");
                    var dropdowntype = customShow.options.customItemShow.item[itemListId].tag_Attribute.dropdowntype;
                    if ($("#" + itemListId + " .select3-element")[0] == undefined) {
                        var width = $(tbodys).find("#" + itemListId)[0].style.width.replace("px", "");
                    } else {
                        var width = $("#" + itemListId + " .select3-element")[0].style.width.replace("px", "");
                    }
 
                    width = parseInt(width);
                    var listData = customBase.options.dropdownlistText[itemListId];
                    ////////console.log(customBase.options.dropdownlistText);
                    // $("#"+itemId).parent().empty();
                    var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass  dropdowntypeCss " + itemListId + "value " + itemListIdTemp;
                    var DropdownlistItem = item.parent();
                    //        DropdownlistItem.css("background-color","red");
                    // var setDiv = $('<div id="'+itemListId+'" class="selectClass '+itemIdClass+'"></div>');
                    var setDiv = $('<div id="' + itemListId + '" class="selectClass lwm' + itemIdClass + '"></div>');
                    console.log("11122211")
                    DropdownlistItem.empty();
                    setDiv.empty();
                    console.log(itemListId);
                    DropdownlistItem.append(setDiv);
                    console.log($(DropdownlistItem).html());
                    //////console.log(dropdowntype);
 
                    if (dropdowntype == "multiple") {
                        customShow.options.subformDList[itemListIdTemp] = {
                            selectId: itemListId,
                            multiple: true,
                            width: width,
                            // listData:listData,
                        }
                    } else {
                        customShow.options.subformDList[itemListIdTemp] = {
                            selectId: itemListId,
                            multiple: false,
                            width: width,
                            // listData:listData,
                        }
                    }
                    //  if(dropdowntype == "multiple"){
                    //     xhSelect.setXhSelect(
                    //         {
                    //             selectId:itemListId,
                    //             multiple:true,
                    //             width: width,
                    //             listData:listData,
                    //             setDiv:setDiv
                    //             // setDiv:itemListIdTemp
                    //         }
                    //     );
                    //  }else{
                    //     xhSelect.setXhSelect(
                    //         {
                    //             selectId:itemListId,
                    //             multiple:false,
                    //             width: width,
                    //             listData:listData,
                    //             setDiv:setDiv
                    //             // setDiv:itemListIdTemp
                    //         }
                    //     );
                    //  }
 
                }
            }
            customShow.options.dropdownlist_I++;
        }
 
    }
    //console.log(customShow);
    //console.log(customBase);
 
    ////////console.log(customShow.options.customItemShow.item);
    ////////console.log(itemId);
    ////////console.log(item);
    ////////console.log(parentsubFormNum);
    // customShow.setXhSelectList();
    return tbodys;
}
//驳回
customShow.rejectBtn = function () {
    var flag = true;//true驳回 false不驳回
    over(flag)
}
//提交
customShow.onclickSubmit = function () {
    get();
}
//查看票据
customShow.checkbill = function () {
    window.open("./../bill_img/bill.html")
}
//审批
customShow.auditableBtn = function () {
    auditableBtn();
}
function auditableBtn() {
    var processLog = JSON.parse(localStorage.getItem("processLog"));
    if (processLog != null && processLog != undefined) {
    } else {
        alert("请先创建一个流程");
        return null;
    }
    if (processLog[0].processState == 60) {
        alert("流程已结束");
        return null;
    }
    var inputs = "<h3 class='sp_title'>请输入审批语</h3><br/>" + "<textarea maxlength='200' onKeyUp='listenword()' class='stexta' type='test' id='datas'></textarea><span class='wordwrap'><var class='word'>0</var>/200</span><br/>"
        + "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn'  type='button' value='取消' onclick='zhixing(false)'/><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='zhixing(true)'/></div>";
    $("#liucheng").html(inputs);
    $("#auditableBtn")[0].setAttribute('data-toggle', "modal");
    $("#auditableBtn")[0].setAttribute('data-target', ".bs-example-modal-sm");
}
customShow.onclickSave1 = function () {
    // SC.sendanydata(function(flag){
    //     console.log(flag);
    // if(!flag){
    //     console("if")
    //     customShow.onclickSave(1);
    // }else{
 
    //    alert("错误");
    // }
    // });
    SC.sendanydata(customShow.onclickSave, 1)
 
 
}
customShow.onclickSave2 = function () {
    SC.sendanydata(customShow.onclickSave, 2)
}
 
//清空按钮按下是
customShow.onclickClear = function () {
    console.log(customBase);
    console.log(customShow);
    var itemKey = _.keys(customShow.options.customItemShow.item);
    var item = customShow.options.customItemShow.item;
    console.log(itemKey);
    _.each(itemKey, function (itemId) {
        console.log(itemId);
        console.log(item[itemId].tag_Type);
        customBase.setItemValue(itemId, item[itemId].tag_Type, "", "");
    });
}
//保存按钮按下时
customShow.onclickSave = function (clickFlag) {
    console.log(clickFlag);
    var saveReturn = customShow.initEvent.fromSaveLinkage();
 
    //画面项目取得 --------------------------画面项目取得------
    var items = customShow.getItems(true);
    console.log(items)
    // customShow.queryCost();
    try {
        if (typeof (eval(eachitem)) == "function") {
            eachitem(items);
        }
    } catch (e) {
        console.log("不存在的函数");
    }
 
    console.log("遍历数组")
    console.log(items);
    // 画面check
    var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
    if (returnfromCheck) {
        return;
    }
    // 03检证执行
    var check = customShow.initEvent.validationRuleCheck(items); //--------------------
    if (!check) {
        return;
    }
    // 检证接口函数
    var check = customShow.initEvent.validationRuleCheck3rd(items); //-----------需要对验证进行解析---------
    if (!check) {
        return;
    }
    // 提取数据 生成数据json  同customShow.getItems()
    //公式保存接口
    //  var saveReturn = customShow.initEvent.fromSaveLinkage(items);
    //  if(!saveReturn){
    //     return;
    //  }
    // 发送数据到后台服务器,保存data
    var saveReturn = customShow.initEvent.fromSave3rd(items);//--------------------
    console.log(customShow.options.customShowFlag)
    if (saveReturn) {
        console.log(1)
        if (customShow.options.customShowFlag == "1") {
            //保存
            customDataBound.fromSave(customShow.options.formid, items, function (rs) {
                if (rs.rspCode == "000000") {
                    var strMessage = customBase.getMessage("mesage_ID015");
                    customBase.alert("S", strMessage);
                    //  return;
                }
                if (rs.rspCode == "100004") {
                    var strMessage = customBase.getMessage("mesage_ID007");
                    customBase.alert("E", strMessage);
                    return;
                }
                if (customShow.options.customShowFlag == "1") {
                    window.parent.$('#myModal').modal('hide');
                    window.parent.addFormData(rs);
                    $(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
                }
                // //////console.log(rs);
            });
        } else if (customShow.options.customShowFlag == "2") {
            console.log(2)
            //保存
            customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
                if (rs.rspCode == "100004") {
                    var strMessage = customBase.getMessage("mesage_ID007");
                    customBase.alert("E", strMessage);
                    return;
                }
                customShow.options.breakFlag = true;
                //预览模式表示
                $("#customViewUEditor")[0].style.display = "none";
                //马习同  2018-1-2  布局修改
                $("#customShow")[0].style.display = "flex";
                // $(".footer")[0].style.display ="none";
 
                var btns = [
                    'printableBtn',
                    // 'exportBtn',
                    // 'rejectBtn',
                    // 'submitBtn',
                    // 'auditableBtn',
                    // 'queryBtn',
                    // 'createBtn',
                    // 'clearBtn',
                    // 'disposableBtn',
                    // 'fromSaveBtn',
                    'editableBtn'
                ];
                customShow.showCustom(items, customShow.options.customInit);
                customShow.setToolBtn(btns);
                console.log("关闭")
                customShow.onclickCancel();
 
            });
            //   customShow.onclickCancel();
        }
        else if (customShow.options.customShowFlag == "3") {
            // 保存
            console.log(3)
            if (clickFlag == 2 && customShow.options.dataRowNum != "") {
                //保存
                customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
                    ////console.log(rs);
                    if (rs.rspCode == "000000") {
                        var strMessage = customBase.getMessage("mesage_ID015");
                        customBase.alert("S", strMessage);
                        //  return;
                    }
                    if (rs.rspCode == "100004") {
                        var strMessage = customBase.getMessage("mesage_ID007");
                        customBase.alert("E", strMessage);
                        return;
                    }
                    // customShow.options.breakFlag = true;
                    // //预览模式表示
                    // $("#customViewUEditor")[0].style.display ="none";
                    // $("#customShow")[0].style.display ="block";
                    // // $(".footer")[0].style.display ="none";
                    // customShow.showCustom(items,customShow.options.customInit);
                });
                //新建
            } else {
                customDataBound.fromSave(customShow.options.formid, items, function (rs) {
                    if (rs.rspCode == "000000") {
                        var strMessage = customBase.getMessage("mesage_ID015");
                        customBase.alert("S", strMessage);
                        //  return;
                    }
                    if (rs.rspCode == "100004") {
                        var strMessage = customBase.getMessage("mesage_ID007");
                        customBase.alert("E", strMessage);
                        return;
                    }
                    // if(customShow.options.customShowFlag == "1" ){
                    //     window.parent.$('#myModal').modal('hide');
                    //     window.parent.addFormData(rs);
                    //     $(window.parent.document.body).css({"overflow-x": "auto","overflow-y": "auto"});
                    // }
                    if(customShow.options.customShowFlag != "3" ){//发布差异修改 李伟民 0120
                        customShow.options.dataRowNum = rs.data.dataRowNum;
                    }
                    //////console.log(rs);
                });
            }
        }
    }
    // customShow.onclickCancel();
    //  window.parent.$('#myModal').modal('hide');
    // console.log($('.boxOne'))
    // $('.boxOne').css("display","none");
}
 
//保存按钮按下时(项目预览表示)
customShow.showCustom = function (items, customInit) {
    console.log(items);
    console.log(customInit);
    customShow.options.customItemShow = customInit.customViewItem;
    var customItem = customShow.options.customItemShow;
    // $(".preview-edit-pane").css("display","block");
    // $(".footer")[0].style.display ="block";
    // $(".footer .fromSaveCss")[0].style.display ="none";
 
    var divHtml = customItem.formeditor;
 
    $("#customShow").empty();
    $("#customShow")[0].innerHTML = divHtml;
    var height = customShow.options.customItemShow.height;
    //  height = parseInt(height)-50;
    //////////console.log(height);
    $("#customShow")[0].style.height = height + "px";
    $("#customShow")[0].style.width = customShow.options.customItemShow.width;
    $("#customShow")[0].style.display = "flex";
    var customItems = customBase.options.customItems;
 
    //数据值变换
    for (item in customItems) {
        if (customItems.hasOwnProperty(item)) {
            if (customItems[item] == undefined) {
                delete customItems[item];
                continue;
            }
            if (customItems[item].type == 'subform') {
                var subformTemp = items[item];
                //////console.log(items);
                ////console.log(item);
                console.log(subformTemp);
                //          console.log(customItems);
                if (subformTemp == undefined) {
                    subformTemp = [{}];
                }
                for (subformItem in subformTemp[0]) {
                    if (subformTemp[0].hasOwnProperty(subformItem)) {
                        items[subformItem] = [];
                    }
                }
                for (var i = 0; i < subformTemp.length; i++) {
                    if (i != 0) {
                        //子表单项目追加
                        var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
                        customShow.addsubformList(subformAdd, "customShow");
                    }
                    for (subformItem in subformTemp[i]) {
                        if (subformTemp[i].hasOwnProperty(subformItem)) {
                            items[subformItem][i] = subformTemp[i][subformItem];
                        }
                    }
                };
            }
            //选项卡回显
            if (customItems[item].type == 'tag') {
                var subformTemp = items[item];
                ////console.log(items);
                ////console.log(item);
                ////console.log(subformTemp);
                ////console.log(customItems);
                if (subformTemp == undefined) {
                    subformTemp = [{}];
                }
                for (subformItem in subformTemp[0]) {
                    if (subformTemp[0].hasOwnProperty(subformItem)) {
                        items[subformItem] = [];
                    }
                }
                for (var i = 0; i < subformTemp.length; i++) {
                    if (i != 0) {
                        //子表单项目追加
                        var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
                        customShow.addsubformList(subformAdd, "customShow");
                    }
                    for (subformItem in subformTemp[i]) {
                        if (subformTemp[i].hasOwnProperty(subformItem)) {
                            items[subformItem][i] = subformTemp[i][subformItem];
                        }
                    }
                };
            }
        }
    }
 
    customShow.options.subformDValue = items;
    //表示项目进行变换
 
    //画面项目初期化
    customShow.controlInit("customShow");
 
    //删除项目(select2项目删除)
    $('.customShow .selection').remove();
    //console.log(customItems);
    //数据设定
    for (item in customItems) {
        console.log(items)
        if (customItems.hasOwnProperty(item)) {
            if (customItems[item] == undefined) {
                delete customItems[item];
                continue;
            }
 
            var type = customItems[item].type;
            var id = customItems[item].id;
            var value = items[item];
            // value = [{"tId":"itemId_1tree_2"},{"name":"F066008"},{"tId":"itemId_1tree_3"},{"name":"F066003"}];
            // value = [{"name":"F066008"},{"name":"F066003"}];
            // value = [{"name":"F066008"},{"name":"F066003"}];
 
            if (customItems[item].type == 'subform') {
                $(".customShow").find("#" + id + "subform").find("td").addClass("");
            } else if (customItems[item].type == 'htmlediter') {
                // var htmlediterShow = $(".customShow").find("#"+id)[0];
                var htmlediterShow = $(".customShow #" + id + "Item")[0];
                // var heightShow = $(htmlediterShow)[0].getAttribute("heightShow");
                // var widthShow = $(htmlediterShow)[0].getAttribute("widthShow");
                var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
                var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
                if (widthShow == undefined || heightShow == undefined) {
                    widthShow = 200;
                    heightShow = 200;
                }
                var oNode = '<div style="word-break:break-all;width:' + widthShow + 'px;height:' +
                    heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
                // var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
                oNode += value;
                oNode += "</div>";
                $($(".customShow #" + id + "Item")[0]).after(oNode);
                $($(".customShow #" + id + "Item")[0]).remove();
                //标签数据设定
            } else if (customItems[item].type == 'textarea') {
                var htmlediterShow = $(".customShow #" + id)[0];
                var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
                var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
                if (widthShow == undefined || heightShow == undefined) {
                    widthShow = 300;
                    heightShow = 80;
                }
                var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:' + widthShow + 'px;height:' +
                    heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
                // var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
                oNode += value;
                oNode += "</div>";
                $($(".customShow #" + id)[0]).after(oNode);
                $($(".customShow #" + id)[0]).remove();
                //标签数据设定
            } else if (customItems[item].type == 'number') {
                var numberShowItems = $(".customShow #" + id);
                for (var i = 0; i < numberShowItems.length; i++) {
                    numberShowItems[i].setAttribute("type", "text");
                }
 
                //标签数据设定
            } else if (customItems[item].type == 'link') {
                var htmlediterShow = $(".customShow").find("#" + id)[0];
                // console.log($(htmlediterShow))
                // $(htmlediterShow)[0].setAttribute("href","javascript:;");
                $(htmlediterShow).css("font-size", "16px;");
                //单选 多选按钮
            } else if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist') {
 
                var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClassTemp customShowItemClass ' + id + '_showItem edui-default">';
                oNode += "</div>";
                // $($(".customShow").find("#"+id)[0]).after(oNode);
                // $($(".customShow").find("#"+id)[0]).remove();
                var showItem = $($(".customShow").find("#" + id));
                console.log(showItem)
                for (var i = 0; i < showItem.length; i++) {
                    $($(showItem[i])[0]).after(oNode);
                    $($(showItem[i])[0]).remove();
                }
                console.log(value)
                //单选复选回显问题
                customShow.setShowItem(id, type, value, true);
            }
            else if (customItems[item].type == 'tree') {
                //普通模式树形回显  李伟民  0130
                var oNode = '<div treeitemid=' + id + ' style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClass edui-default customShowItemClassTemp">';
                // 2017 /11/7  李元杰  树的回显
                //   var   treeShow = $('#customShow').find('div[type=tree]');
 
                //   if(value !=undefined && value !=""){
                //       console.log(1);
                //     if(typeof value == "string"){
                //     //   value = $.parseJSON(value);
                //     console.log(2);
                //       value =[value];
                //     }
                //     // 2017/11/7  李元杰回显
                //     if(value.length>0){
                //        console.log(value);
                //        for(var i =0;i<value.length;i++){
                //            value[i]
                //        }
 
 
                //      console.log(value)
 
                //        if(typeof value[0] == "string"){
                //            //console.log(value[0]);
                //         //   value[0] = $.parseJSON(value[0]);
                //        }
 
                //       oNode +=value[0];
                //     }
                //     for (var i = 1; i < value.length; i++) {
                //         console.log(4);
                //       if(typeof value[i] == "string"){
                //         console.log(5);
                //         //   value[i] = $.parseJSON(value[i]);
                //        }
                //        console.log(value)
                //       oNode +=" , "+value[i];
                //       console.log(oNode)
                //     };
                //   }
                //   console.log(oNode)
 
                //   oNode +="</div>";
                "</div>";
                $($(".customShow").find("#" + id)[0]).after(oNode);
                $($(".customShow").find("#" + id)[0]).remove();
                //              customShow.setShowItem(id, type, value, true);
                console.log($($(".customShow").find("#" + id)[0]))
            }
            else if (customItems[item].type == 'amount') {
                var id = id + "amount";
                customBase.setItemValue(id, 'text', items[item], 'customShow');
                $("#" + id).blur();
 
            } else if (customItems[item].type == 'qrcode') {
                var id = id + "qrcode";
                customBase.setItemValue(id, 'text', items[item], 'customShow');
                $("#" + id).blur();
            } else if (customItems[item].type == 'barcode') {
                var id = id + "barcode";
                customBase.setItemValue(id, 'text', items[item], 'customShow');
                $("#" + id).blur()
            } else if (customItems[item].type == 'fileupload') {
                // var $wrap = $(".customShow #" + customItems[item].id);
                var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
                $uploaderItem.empty();
                var $uploadimg = $(
                    '<div >' +
                    '<div id="fileList" class="uploader-list"></div>' +
                    '</div>'
                );
                var $list = $uploadimg.find("#fileList");
                if (typeof value != "string") {
                    if (_.isArray(value)) {
                        // airport = JSON.parse(airport)
                        value = value.join(",")
                        var value = JSON.parse(value);
 
                    }
                    for (i in value) {
                        var fileDir = value[i].path;
                        var suffix = fileDir.substr(fileDir.lastIndexOf(".")+1);
                        if(suffix == "mp4"){
                            var $li = $(
                                '<div class="">' +
                                '<div><a href="' + value[i].path + '" target="_blank">' + value[i].oldName + ' </a></div>' +
                                '</div>'
                            );
                        }else{
                            var $li = $(
                                '<div class="">' +
                                // '<div class="info"><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
                                // '<div class="info info-box"><div class="info_box">' + value[i].oldName +
                                // '<span class="x_box" style="display:none;">×</span>' +
                                // '<img class="img_box" style="display:none;" src="' + value[i].path + '">' +
    
                                '<div><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
                                '</div>'
                            );
                        }
                        $li.appendTo($list);
                    };
                }
                $uploadimg.appendTo($uploaderItem);
                //2017-12-17 马习同修改 图片
                // $(".info_box").on("click", function () {
                //     $(".x_box").show();
                //     $(".img_box").show();
                //     $(".x_box").unbind();
                //     $(".x_box").on("click", function () {
                //         console.log(1);
                //         $(".x_box").hide();
                //         $(".img_box").hide();
                //     })
                // })
            } else if (customItems[item].type == 'image') {
                // var $wrap = $(".customShow #" + customItems[item].id);
                var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
                console.log($('#' + customItems[item].id));
                console.log($uploaderItem)
                $uploaderItem.empty();
 
                var $uploadimg = $(
                    '<div >' +
                    '<div id ="fileList" class="uploader-list"></div>' +
                    '</div>'
                );
                // var $list = $uploadimg.find("#"+potion.id+"fileList");
                console.log(value)
                if(customItems[item].defaultvalue != undefined){//详细显示默认值 李伟民 0131
                    var $list = $uploadimg.find("#fileList");
                        var $addLi = $(
                            '<div class="file-item thumbnail">' +
                            '<img  src="' + customItems[item].defaultvalue + '">' +
                            '</div>'
                        );
 
                        $list.prepend($addLi);
                }
                if (_.isArray(value)) {
                        // airport = JSON.parse(airport)
                    value = value.join(",")
                  var value = JSON.parse(value);
 
                }
                console.log(value)
                if (typeof value != "string") {
                    if (typeof value == "string") {
                        //   value = $.parseJSON(value);
                    }
                    for (i in value) {
                        var $list = $uploadimg.find("#fileList");
                        var $addLi = $(
                            '<div class="file-item thumbnail">' +
                            '<img style="width:100px,height:100px" src="' + value[i].path + '">' +
                            '</div>'
                        );
 
                        $list.prepend($addLi);
                    }
                }
                //  12/18 放大图片
 
                $uploaderItem.append($uploadimg);
                var particularId = $uploaderItem.attr('id') + '_1'
                $uploaderItem.children().attr('id', particularId);
                // var particularId =  $uploaderItem.find('#uploaderItem').attr('id')
                // 详情页
                var viewer = new Viewer(document.getElementById(particularId), {
                    url: 'data-original',
 
                });
                var imgId = $uploaderItem.attr('id');
                var srcUrl = $uploaderItem.find('img').attr('src');
                $uploaderItem.find('img').attr('alt', ' ');
                // itemId_32uploadimg
 
                // 编辑页
                // console.log($('#customViewUEditor').find('#'+imgId).children())
                // console.log($('#'+imgId))
                // console.log($uploaderItem)
                // var viewer = new Viewer(document.getElementById(imgId), {
                //     url: 'data-original',
                //     show:function(){
                //         console.log('显示')
                //     }
                // });
                // 12/18
 
 
            } else if (customItems[item].type == 'mytext') {
                //选择表单编辑回显
                console.log(customItems);
                console.log(customShow);
                var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
                var $mytext = $("#" + customItems[item].id);
                var item_title = [];
                var itemVal = [];
                if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
                    var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
                    var dataObj = {
                        "formID": customShow.options.formid,
                        "tenantID": "001",
                        "search": [],
                        "pageSize": "1000",
                        "pageNum": "1",
                        "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
                        "formData": {},
                        "dataRowNum": items[item]
                    };
                    var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
                    var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
                    requesTitle.done(function (res) {
                        console.log(res);
                        item_title = res.data;
                    });
                    requesData.done(function (res) {
                        console.log(res);
                        if (!_.isNull(res.data) && res.data != undefined) {
                            itemVal = res.data;
                        }
                    });
                } else {
                    var myTitle = JSON.parse(window.localStorage.getItem("title"));
                    item_title = myTitle[item];
                    itemVal = items[item];
                }
                console.log(itemVal)
                console.log(item_title);
                console.log(itemVal.list);
                createMxtTable(customItems[item].id, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
                //                            var newData = [];
                //                            _.each(itemVal.list,function(opt){
                //                                opt = _.mapKeys(opt,function(value,key){
                //                                    _.each(item_title,function(item){
                //                                        if(key == item.fieldKey){
                //                                            key = item.title;
                //                                        }
                //                                    })
                //                                    return key;
                //                                })
                //                                console.log(_.cloneDeep(opt))
                //                                newData.push(opt);
                //                            })
                //                            console.log(itemVal.list);
                //                            console.log(newData);
                var formhuixian = itemVal.list;
 
                //console.log(formhuixian);
                var huixianStr = "";
                for (let i in formhuixian) {
                    //console.log($mytext.attr("fieldkey"));
                    //console.log(i);
                    //console.log(formhuixian[i]);
                    if (i = $mytext.attr("fieldkey")) {
                        huixianStr = formhuixian[i];
                    }
                }
                //console.log(huixianStr);
                $mytext.attr("formhuixian", JSON.stringify(itemVal.list));
                //                     if(newData){
                //                         var $value = newData;
                //                         console.log($value)
                //
                //                                    var show = "";
                //                                    var divBox = $("<div></div>");
                //                                    divBox.attr('id',customItems[item].id+'divBox');
                //                                    var sdata_head = "";
                //                                    _.each($value,(opt,j)=>{
                //                                        var ulBox = $("<ul></ul>");
                //                                        for(let i in opt){
                //                                            show = "";
                //                                            sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
                //                                        show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
                //                                        ulBox.attr("class","addUl ulBox"+j);
                //                                        ulBox.attr("id","ulBox"+j);
                //                                        //console.log(show)
                //                                        ulBox.append(show);
                //                                        }
                //                                        divBox.append(ulBox);
                //                                    });
                //                                    console.log(sdata_head);
                //                          $mytext.append(divBox);
                //                      }
            }
            if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist' || type == 'tree' ||
                type == 'amount' || type == 'barcode' || type == 'qrcode' || type == 'image' ||
                type == 'button' || type == 'fileupload'
                || type == 'subform' || type == 'link'
                || type == 'splitline' || type == 'link'
                || type == 'textarea'
            ) {
 
            } else {
                //值设定
                customBase.setItemValue(id, type, value, 'customShow');
            }
 
        }
    };
}
 
//画面表示项目取得  -----------------
customShow.getItems = function (saveflag) {
    var items = customBase.options.customItems;
    console.log(items);
    var itemTempS = {};
    for (item in items) {
        if (items.hasOwnProperty(item)) {
            console.log(item);
            console.log(items[item].type);
            if (items[item].type == "button" || items[item].type == "link") {
            } else if (items[item].type == "dropdownlist") {
                // var datasourcetype = $("#"+items[item].id)[0].getAttribute("datasourcetype");
                //  //主数据源
                // if(datasourcetype == "masterdata"){
                //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
                //   //数据源
                // }else if(datasourcetype == "datasource"){
                //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
                //   //自定义
                // }else if(datasourcetype == "custom"){
                //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
                //   //API接口
                // }else if(datasourcetype == "api"){
                //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
                // }
                itemTempS[item] = customBase.getItemValue(items[item].id, "dropdownlistText");
                console.log(itemTempS[item])
                if (saveflag) {//下拉框 传值 修改  李伟民  11-09
                    console.log(itemTempS[item]);
                    _.each(itemTempS[item], function (sval, i) {
                        if (_.isArray(sval)) {
                            itemTempS[item][i] = sval.join();
                        }
                    })
                    //            if(_.isArray(itemTempS[item][0])){
                    //                  itemTempS[item][0] = itemTempS[item][0].join(",")
                    //              }
                    console.log(itemTempS[item]);
                }//下拉框 传值 修改  李伟民  11-09
            } else if (items[item].type == "tree") {
                itemTempS[item] = customBase.getItemValue(items[item].id, "tree");
                console.log(itemTempS[item])
                if (saveflag) {//树形传值 修改  李元杰  11-21
                    console.log(itemTempS[item]);
                    _.each(itemTempS[item], function (sval, i) {
                        if (_.isArray(sval)) {
                            itemTempS[item][i] = sval.join();
                        }
                    })
                    //            if(_.isArray(itemTempS[item][0])){
                    //                  itemTempS[item][0] = itemTempS[item][0].join(",")
                    //              }
                }//树形 传值 修改  李元杰  11-21
            } else if (items[item].type == "checkbox") {
                itemTempS[item] = customBase.getItemValue(items[item].id, "checkbox");
                console.log(itemTempS[item])
                console.log(saveflag)
                if (saveflag) {//复选框传值 修改  马习同  12-6
                    console.log(itemTempS[item]);
                    _.each(itemTempS[item], function (sval, i) {
                        if (_.isArray(sval)) {
                            itemTempS[item][i] = sval.join();
                        }
                    })
                    //            if(_.isArray(itemTempS[item][0])){
                    //                  itemTempS[item][0] = itemTempS[item][0].join(",")
                    //              }
                }////复选框传值 修改  马习同  12-6
            } else if (items[item].type == "radio") {
                itemTempS[item] = customBase.getItemValue(items[item].id, "radio");
                console.log(itemTempS[item])
                console.log(saveflag)
                if (saveflag) {//复选框传值 修改  马习同  12-6
                    console.log(itemTempS[item]);
                    _.each(itemTempS[item], function (sval, i) {
                        if (_.isArray(sval)) {
                            itemTempS[item][i] = sval.join();
                        }
                    })
                    //            if(_.isArray(itemTempS[item][0])){
                    //                  itemTempS[item][0] = itemTempS[item][0].join(",")
                    //              }
                }////复选框传值 修改  马习同  12-6
            } else if (items[item].type == "subform" || items[item].type == "tag" || items[item].type == "tab") {
 
            } else if (items[item].type == "auto") {
                var str = window.localStorage.getItem("customItem");
                var prefix = (str != undefined && str != "undefined") ? JSON.parse(str) : null;
                if (prefix != null && (prefix[item] != null || prefix[item] != undefined)) {
                    itemTempS[item] = prefix[item];
                } else {
                    itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
                }
            } else {
                itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
                console.log(itemTempS[item]);
            }
        }
    };
    var itemRetuen = {};
 
    //子表单数据变换
    for (item in customBase.options.customItems) {
        if (customBase.options.customItems.hasOwnProperty(item)) {
            if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
                var id = customBase.options.customItems[item].id.replace("itemId_", "");
                itemRetuen[id] = {};
            }
        }
    }
    console.log(_.cloneDeep(itemRetuen));
    console.log(_.cloneDeep(itemTempS));
    //子表单内数据保存
    for (item in itemTempS) {
        ////console.log(items);
        ////console.log(itemTempS);
        ////console.log(item);
        if (itemTempS.hasOwnProperty(item)) {
            var parentsubFormNum = customBase.options.customItems[item].parentsubFormNum;
            ////console.log(customBase.options)
            ////console.log(customBase.options.customItems[item]);
            ////console.log(parentsubFormNum);
            if (parentsubFormNum == "0") {
                if (customBase.options.customItems[item].type == "radio" ||
                    customBase.options.customItems[item].type == "checkbox" ||
                    customBase.options.customItems[item].type == "dropdownlist" ||
                    customBase.options.customItems[item].type == "tree"
                ) {
                    itemRetuen[item] = itemTempS[item][0];
                } else {
                    itemRetuen[item] = itemTempS[item];
                }
            } else {
                ////console.log(item);
                ////console.log(items);
                ////console.log(itemRetuen[parentsubFormNum]);
                ////console.log(itemTempS[item]);
                ////console.log(itemRetuen);
                ////console.log(parentsubFormNum);
                itemRetuen[parentsubFormNum][item] = itemTempS[item];
            }
        }
    }
    //子表单内最终数据变换
    console.log(_.cloneDeep(itemRetuen));
    console.log(customBase.options.customItems);
    for (item in customBase.options.customItems) {
        if (customBase.options.customItems.hasOwnProperty(item)) {
            if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
                var id = customBase.options.customItems[item].id.replace("itemId_", "");
                var tepItem = itemRetuen[id];
                var subformIten = [];
                var i = 0;
                console.log(tepItem);
                for (tem in tepItem) {
                    if (tepItem.hasOwnProperty(tem)) {
                        if (typeof tepItem[tem] == "string") {
                            if (subformIten[0] == undefined) {
                                subformIten[0] = {};
                            }
                            subformIten[0][tem] = tepItem[tem];
                        } else {
                            console.log(tepItem[tem]);
                            for (var i = 0; i < tepItem[tem].length; i++) {
                                if (subformIten[i] == undefined) {
                                    subformIten[i] = {};
                                }
                                subformIten[i][tem] = tepItem[tem][i];
                            }
                        }
                    }
                }
                delete itemRetuen[id];
                console.log(_.cloneDeep(subformIten));
                itemRetuen[customBase.options.customItems[item].fieldKey] = subformIten;
            }
        }
    }
    console.log(_.cloneDeep(itemRetuen));
    return itemRetuen;
}
 
//取消事件
customShow.onclickCancel = function () {
    // var items = customShow.getItems();
    //检证执行
    var saveReturn = customShow.initEvent.cancelEventLinkage();
    if (!saveReturn) {
        return;
    }
 
    //取消接口(第三方提供)
    var saveReturn = customShow.initEvent.cancelEvent3rd();//--------------------
    if (saveReturn) {
        // 取消接口
        customShow.initEvent.cancelEvent();//--------------------
    }
    if (customShow.options.customShowFlag == "3") {
        // window.close();
        window.location.href = "about:blank";
        window.close();
    } else if (customShow.options.customShowFlag == "0" || customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
        window.parent.$('#myModal').modal('hide');
        if (customShow.options.breakFlag) {
            window.parent.addFormData();
        }
        if (customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
            $(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
        }
        window.parent.$("#myFormDesign").css("display", "");
        window.parent.$(".htmlediterClass").css("display", "");
    }
}
 
//印刷事件  打印
customShow.onPrint = function () {
    var items = customShow.getItems();
    var interfacep = customShow.initEvent.interfaceprint3rd(items);
    if (!interfacep) {
        return;
    }
    var removePrintArea = function (id) {
        $("iframe#" + id).remove();
    };
    var customShowFlag = window.localStorage.getItem("customShowFlag");
    if (customShowFlag == "0") {
        var itemOnPrint = $("#customViewUEditor")[0].cloneNode(true);
        $(itemOnPrint).css("overflow", 'visible');
        $(itemOnPrint).printArea();
    }else{
        var itemOnPrint = $("#customShow")[0].cloneNode(true);
        $(itemOnPrint).css("overflow", 'visible');
        $(itemOnPrint).printArea();
    }
}
 
//编辑按钮按下时
customShow.onEditor = function () {
    // $(".preview-edit-pane").css("display", "none");
    window.localStorage.setItem("customShowFlag", 3);
    var formIDs = customlocalStorage.newFormID;
 
    customDataBound.formsetting(formIDs, function () { });
    //console.log("编辑存值");
    $("#customShow").empty();
    if (customShow.options.customShowFlag != "3") {
        //图片文件上传
        var uploaderImage = $(".customViewUEditorCss .uploaderImage");
        for (var i = 0; i < uploaderImage.length; i++) {
            $("#" + uploaderImage[i].id).find('.imgfileLiShow').remove();
            var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
            var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
            if (customShow.options.customShowFlag == "3") {
 
            }
            // 参数设定
            var potion = {
                id: uploaderImage[i].id,
                width: imageItem.tag_Attribute.width,
                height: imageItem.tag_Attribute.height,
                formid: customShow.options.formid,
                imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
                editable: imageItem.tag_Attribute.editable, //是否可编辑
                defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
                ItemReady: itemList,
                visible:imageItem.tag_Attribute.visible
            }
            //  12/18
            customBase.uploaderShow(potion);
 
            // customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
 
        };
 
        //文本文件上传
        var uploaderFile = $(".customViewUEditorCss .uploaderFile");
 
        for (var i = 0; i < uploaderFile.length; i++) {
            $("#" + uploaderFile[i].id + "  .filelist").empty();
 
            var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
            debugger
            var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
            // 参数设定
            var potion = {
                id: uploaderFile[i].id,
                width: imageItem.tag_Attribute.width,
                height: imageItem.tag_Attribute.height,
                formid: customShow.options.formid,
                imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
                editable: imageItem.tag_Attribute.editable, //是否可编辑
                defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
                ItemReady: itemList,
                visible:imageItem.tag_Attribute.visible
            }
            customBase.uploaderFileShow(potion);
            // customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
        };
    }
    $("#customViewUEditor")[0].style.display = "block";
    $("#customShow")[0].style.display = "none";
    $("#customShow").css("display", "none");
    $("#customShow").removeClass("fui-form");
    // $(".footer")[0].style.display ="block";
    // $(".preview-edit-pane")[0].style.display ="none";
    // $(".footer .fromSaveCss")[0].style.display ="block";
 
    var btns = [
        // 'printableBtn',
        //12/23'exportBtn',
        //12/23 'rejectBtn',
        // 12/23 'submitBtn',
        //12 /23 'auditableBtn',
        // 12/23 'queryBtn',
        // 'createBtn',
        // 'clearBtn',
        //  12/23 'disposableBtn',
        // 'fromSaveBtn',
        // 'editableBtn'
    ];
    customShow.setToolBtn(btns);
 
    customShow.setXhSelectList();
    //子表单事件调用
    customShow.clickBindSubform();
    //2017/11/18  马习同修改 隐藏预览模式下  导入数据按钮
    $(".sonImportFile").removeClass("cfg_contentNone");
    //s_savebtn
    $(".s_savebtn").show();
    // $(".preview-edit-pane").css("display", "none");
    //12/23
    // $('#disposableBtn').css('display','none');
    // $('#clearBtn').css('display','none');
    // $('#queryBtn').css('display','none');
    // $('#auditableBtn').css('display','none');
    // $('#submitBtn').css('display','none');
    // $('#rejectBtn').css('display','none');
 
}
 
//画面验证
customShow.onfromCheck = function (items) {
    if ($(".errorCheckCss").length > 0) {
        return true;
    }
    if($(".checkErr") > 0){
        return true;
    }
    $(".errorItemCss").removeClass("errorItemCss");
    $(".mesageErrDiv").remove();
    for (var id in customShow.options.showErrId) {
        $($(".customViewUEditorCss  #" + id)[customShow.options.showErrId[id]]).popover('hide');
    }
 
    //必须入力验证
    mustcheckExe = function (tag_Type, value, ItemId, N) {
        if (tag_Type == "text" || tag_Type == "textarea" ||
            tag_Type == "number" || tag_Type == "htmlediter" || tag_Type == "fileupload" ||
            tag_Type == "calendar") {
            if (tag_Type == "fileupload") {
                var count = 0;
                for (var key in value) {
                    count++;
                }
                if (count == 0) {
                    value = "";
                }
 
            }
            if (value == "") {
                customShow.showErrorItem(tag_Type, ItemId, N);
                var message = customBase.getMessage("mesage_ID004");
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            }
        } else if (tag_Type == "checkbox" || tag_Type == "dropdownlist") {
            // //////////console.log(value);
            if (value.length == 0) {
                customShow.showErrorItem(tag_Type, ItemId, N);
                var message = customBase.getMessage("mesage_ID004");
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            }
        }
    }
 
    //数值型验证
    numberFormatCheck = function (numbertype, value, ItemId, N) {
        if (numbertype == "integer") {
            if (value.indexOf(".") > -1) {
                var message = customBase.getMessage("mesage_ID019");
                customShow.showErrorItem("number", ItemId, N);
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            } else {
                var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
                numberMaxlength = parseInt(numberMaxlength);
                if (value.length > numberMaxlength && numberMaxlength != 0) {
                    customShow.showErrorItem("number", ItemId, N);
                    var message = customBase.getMessage("mesage_ID020");
                    customShow.setShowMesageErr(ItemId, message, N);
                    mustcheck = true;
                }
            }
        } else {
            var integerItem;
            integerItem = value.split(".");
            //整数长度
            // var aa = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
            var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
            numberMaxlength = parseInt(numberMaxlength);
            var numberdecimalplace = customShow.options.customItemShow.item[ItemId].tag_Attribute.decimalplace;
            numberdecimalplace = parseInt(numberdecimalplace);
            if (integerItem[0].length > numberMaxlength && numberMaxlength != 0) {
                customShow.showErrorItem("number", ItemId, N);
                var message = customBase.getMessage("mesage_ID020");
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            }
            if (integerItem[2] != undefined && integerItem[1].length > numberdecimalplace) {
                customShow.showErrorItem("number", ItemId, N);
                var message = customBase.getMessage("mesage_ID021");
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            }
            ////////console.log(customShow.options.customItemShow.item[ItemId].tag_Attribute);
        }
    }
 
    //文本格式验证
    maxlengthCheck = function (maxlength, value, ItemId, N) {
        if (value.length > maxlength && maxlength != 0) {
            customShow.showErrorItem("htmlediter", ItemId, N);
            var message = customBase.getMessage("mesage_ID023");
            customShow.setShowMesageErr(ItemId, message, N);
            mustcheck = true;
        }
    }
    //文本格式验证
    textFormatCheck = function (format, value, ItemId, N) {
        if (value == "") {
            return;
        } else if (format == "phone") {
            //手机号
            var p1 = /^1[3|4|5|7|8][0-9]{9}$/;
            var me = false;
            if (!p1.test(value)) {
                customShow.showErrorItem("text", ItemId, N);
                var message = customBase.getMessage("mesage_ID009");
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            }
        } else if (format == "url") {
            //网址 张吉男修改网址验证
            // var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
            //     + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
            //     + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
            //     + "|" // 允许IP和DOMAIN(域名)
            //     + "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
            //     + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
            //     + "[a-z]{2,6})" // first level domain- .com or .museum
            //     + "(:[0-9]{1,4})?" // 端口- :80
            //     + "((/?)|" // a slash isn't required if there is no file name
            //     + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
            var strRegex="[a-zA-z]+://[^\s]*";
            var re = new RegExp(strRegex);
            if (!re.test(value)) {
                customShow.showErrorItem("text", ItemId, N);
                var message = customBase.getMessage("mesage_ID010");
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            }
        } else if (format == "cardno") {
            //身份证
            // 2018.1.25 张吉男修改  身份证验证错误
            // var p1 = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;
            var p1=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
            // alert(1111);
            if (!p1.test(value)) {
                customShow.showErrorItem("text", ItemId, N);
                var message = customBase.getMessage("mesage_ID011");
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            }
        } else if (format == "email") {
            //邮箱
            var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            if (!myreg.test(value)) {
                customShow.showErrorItem("text", ItemId, N);
                var message = customBase.getMessage("mesage_ID012");
                customShow.setShowMesageErr(ItemId, message, N);
                mustcheck = true;
            }
        }
    }
    var customItems = customBase.options.customItems;
    //必须入力验证
    var mustcheck = false;
    for (fieldKey in customItems) {
 
        if (customItems.hasOwnProperty(fieldKey)) {
            ////console.log(customItems);
            var tag_Type = customItems[fieldKey].type;
            var ItemId = customItems[fieldKey].id;
            if (customItems[fieldKey].visible) {
                if (customItems[fieldKey].mustcheck) {
                    var value = items[fieldKey];
                    //子表单的情况
                    if (value == undefined) {
 
                        //取得对应子表单ID
                        var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
                        if (customShow.options.customItemShow.item[subformItemId] != undefined) {
                            var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
                            var subformItem = items[subformItemAlias];
                            for (var i = 0; i < subformItem.length; i++) {
                                mustcheckExe(tag_Type, subformItem[i][fieldKey], ItemId, i);
                            }
                        }
                    } else {
                        mustcheckExe(tag_Type, value, ItemId, 0);
                    }
                }
                //文本格式验证
                if (customItems[fieldKey].type == "text") {
                    var value = items[fieldKey];
                    ////console.log(fieldKey);
                    ////console.log(customItems);
                    ////console.log(value);
                    var format = customShow.options.customItemShow.item[ItemId].tag_Attribute.format;
                    //子表单的情况
                    if (value == undefined) {
                        //取得对应子表单ID
                        var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
                        var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
                        var subformItem = items[subformItemAlias];
                        ////console.log(items);
                        ////console.log(subformItemAlias);
                        ////console.log(subformItem);
                        for (var i = 0; i < subformItem.length; i++) {
                            textFormatCheck(format, subformItem[i][fieldKey], ItemId, i);
                        }
                    } else {
                        textFormatCheck(format, value, ItemId, 0);
                    }
 
                }
                //数值整数验证
                if (customItems[fieldKey].type == "number") {
                    var value = items[fieldKey];
                    //数值格式
                    var numbertype = customShow.options.customItemShow.item[ItemId].tag_Attribute.numbertype;
                    //子表单的情况
                    if (value == undefined) {
                        //取得对应子表单ID
                        var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
                        var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
                        var subformItem = items[subformItemAlias];
                        for (var i = 0; i < subformItem.length; i++) {
                            numberFormatCheck(numbertype, subformItem[i][fieldKey], ItemId, i);
                        }
                    } else {
                        numberFormatCheck(numbertype, value, ItemId, 0);
                    }
 
                }
 
                //默认长度检证
                if (customItems[fieldKey].type == "htmlediter") {
                    var value = items[fieldKey];
                    //数值格式
                    var maxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
                    // //子表单的情况
                    // if(value ==undefined){
                    //   //取得对应子表单ID
                    //   var subformItemId = "itemId_"+customItems[fieldKey].parentsubFormNum;
                    //   var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
                    //   var subformItem = items[subformItemAlias];
                    //   for(var i=0;i<subformItem.length;i++){
                    //      numberFormatCheck(numbertype,subformItem[i][fieldKey],ItemId,i);
                    //   }
                    // }else{
                    maxlengthCheck(maxlength, value, ItemId, 0);
                    // }
 
                }
            }
        }
    }
    //焦点事件
    // $(".errorItemCss").unbind('focus');
    // $(".errorItemCss").on('focus', function() {
    //     $(this).removeClass("errorItemCss");
    //     ////////////console.log($(this)[0].id);
    //     $("#"+$(this)[0].id+"mesageErrDiv").remove();
    //     $(".customViewUEditorCss  #"+$(this)[0].id).popover('hide')
    // });
    // //下拉列表点击事件
    // $(".select2-search__field").unbind("focus");
    // $(".select2-search__field").bind("focus",function(){
    //   var id = this.getAttribute("errorItemId");
    //   var N = this.getAttribute("N");
    //   $($('.customViewUEditorCss #'+id)[N].parentNode).find(".select2").removeClass("errorItemCss");
    //   $("#"+id+"mesageErrDiv").remove();
    //   $($(".customViewUEditorCss  #"+id)[N]).popover('hide')
    // });
 
    if (mustcheck) { return true; }
 
    //单选按钮长度验证
 
    //焦点事件
    // $(".errorItemCss").unbind();
    // $(".errorItemCss").on('focus', function() {
    //   $(this).removeClass("errorItemCss");
    // });
    return false;
}
 
//检证验证
customShow.interfaceCheck = function (items) {//保存前计算费用  李伟民   10 - 31
    var flag = true;
    _.each(customBase.interfaceData, function (intdata) {
        var func = intdata.customInterfacemethod + "()";
        if(intdata.interfacemethod == 'fromSave3rd'){//只执行保存接口事件
            try {//解决不上传资源文件JS报错 导致无法保存  李伟民 0129
                var thisChheck = eval(func);
                console.log(thisChheck);
                if (thisChheck == false) {
                    flag = false;
                }
            } catch (error) {
 
            }
        }
    });
    return flag;
}//保存前计算费用  李伟民   10 - 31
 
//错误信息
customShow.showErrorItem = function (errorClass, tag_Type, id, N) {
    if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar"
        || tag_Type == "checkbox") {
        $($(".customViewUEditorCss  #" + id)[N]).addClass(errorClass);
    } else if (tag_Type == "htmlediter") {
        // $(".customViewUEditorCss  #"+id+"Item").addClass(errorClass);
        UE.getEditor(id + "Item").body.setAttribute("class", errorClass);
        if (UE.getEditor(id + "Item").body.getAttribute("heightFlag") == "height") {
        } else {
            var height = UE.getEditor(id + "Item").body.style.height.replace("px", "");
            height = parseInt(height) - 12;
            UE.getEditor(id + "Item").body.style.height = height + "px";
            UE.getEditor(id + "Item").body.setAttribute("id", id);
        }
        UE.getEditor(id + "Item").body.setAttribute("heightFlag", height);
 
        // //////////console.log(UE.getEditor(id+"Item").body.style.height = );
    } else if (tag_Type == "dropdownlist") {
        //  $(".customViewUEditorCss  #"+id).p + ".selection").addClass(errorClass);
        // //////////console.log($('.customViewUEditorCss #'+id)[0].parentNode);
        $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").addClass(errorClass);
        //  $(".customViewUEditorCss  #"+id+" .select2-search__field")
        if ($($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field").length > 0) {
            $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("errorItemId", id);
            $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("N", N);
        }
    }
}
 
//画面属性设定(初始值 表示/非表示  只读 必须 审查必须)
customShow.setShowAttribute = function (aliasItem) {
    console.log(aliasItem)
    //  12/7  不可编辑 可以编辑
    id = aliasItem.id;
    //表示非表示
    if (aliasItem.visible) {
        $(".customViewUEditorCss #" + id).removeClass("cfg_contentNone");
        $(".customViewUEditorCss #" + id + "ActiveId").removeClass("cfg_contentNone");
        $(".customViewUEditorCss ." + id + "IconShow").removeClass("cfg_contentNone");
        $(".customViewUEditorCss #" + id + "Item").removeClass("cfg_contentNone");
        if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
            $($(".customViewUEditorCss #" + id)[0].parentNode).removeClass("cfg_contentNone");
        }
    } else if (!aliasItem.visible) {
        $(".customViewUEditorCss #" + id).addClass("cfg_contentNone");
        $(".customViewUEditorCss #" + id + "ActiveId").addClass("cfg_contentNone");
        $(".customViewUEditorCss ." + id + "IconShow").addClass("cfg_contentNone");
        $(".customViewUEditorCss #" + id + "Item").addClass("cfg_contentNone");
        if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
            $($(".customViewUEditorCss #" + id)[0].parentNode).addClass("cfg_contentNone");
        }
    }
    //必须
    if (aliasItem.mustcheck) {
        $(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").removeClass("cfg_contentNone");
    } else if (!aliasItem.mustcheck) {
        $(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").addClass("cfg_contentNone");
    }
    //审查必须
    if (aliasItem.approvalmustenter) {
        $(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").removeClass("cfg_contentNone");
    } else if (!aliasItem.approvalmustenter) {
        $(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").addClass("cfg_contentNone");
    }
 
    //编辑-非编辑
    var itemTemp = $($(".customViewUEditorCss #" + id)[0]);
    var tag_Type = aliasItem.type;
    if (aliasItem.editable) {
        if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
            itemTemp.removeAttr('readonly');
            //  非编辑情况移除背景颜色  12/7 李元杰
            for (var i = 0; i < itemTemp.length; i++) {
                console.log(itemTemp[i]);
                $(itemTemp[i]).removeClass('disableColor')
            }
            if (tag_Type == "calendar") {
                var calendarItem = customShow.options.customItemShow.item[id];
                // var editable = tag_Attribute['editable'];
                var textformat = calendarItem.tag_Attribute.datatype;
                if (textformat == 'Y') {
                    $(itemTemp).addClass('dateFromyyyy');
                } else if (textformat == 'Y-m') {
                    $(itemTemp).addClass('dateFromyyyymm');
                } else if (textformat == 'Y-m-d') {
                    $(itemTemp).addClass('dateFromyyyymmdd');
                } else if (textformat == 'Y-m-d H:i') {
                    $(itemTemp).addClass('dateFromhhmiss');
                }
                customShow.clickBindSubform();
 
            }
        } else if (tag_Type == "radio") {//----------------------------------------------------------
            itemTemp.find('.custom-radio').removeAttr("readonly");
        } else if (tag_Type == "radio") {//----------------------------------------------------------
            itemTemp.find('.custom-radio').removeAttr("readonly");
        } else if (tag_Type == "checkbox") {//-------------------------------------------------------
            itemTemp.find('.custom-check').removeAttr("readonly");
        } else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
            // $(itemTemp).removeClass('editableDisabled');
            // $(itemTemp).prop("disabled", false);        //设置下拉框不可用
            // $(itemTemp).find(".select-container").removeAttr("readonly");
            $(itemTemp).removeClass("disableColor");
 
            $(itemTemp).removeClass("readonly");
            //          ////console.log($(itemTemp).find(".select-container"));
        } else if (tag_Type == "button") {//---------------------------------------------------------OK
            $(itemTemp).removeClass('disabled');
        } else if (tag_Type == "link") {//-----------------------------------------------------------OK
            itemTemp.href = "javascript:void(0);";
            itemTemp.removeAttr('disabled', 'disabled');
        } else if (tag_Type == "fileupload") {//----------------------------------------------------todo
        } else if (tag_Type == "tree") {//----------------------------------------------------------todo
            $(itemTemp).parent().find('.citySel').removeClass('disableColor')
 
            //   var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
            itemTemp[0].setAttribute('editable', aliasItem.editable);
        }
        // else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
        //     //  var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
        //     itemTemp.setAttribute('editable', aliasItem.editable);
        // }
 
    } else if (!aliasItem.editable) {
        if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
            for (var i = 0; i < itemTemp.length; i++) {
                //  12/7 李元杰 添加背景颜色
                console.log(itemTemp[i]);
                itemTemp[i].setAttribute('readonly', '');
                $(itemTemp[i]).addClass('disableColor')
            }
            if (tag_Type == "calendar") {
                // $('.dateFromyyyy').unbind();
                // $('.dateFromyyyymm').unbind();
                // $('.dateFromyyyymmdd').unbind();
                // $('.dateFromhhmiss').unbind();
                itemTemp.removeClass('dateFromyyyy');
                itemTemp.removeClass('dateFromyyyymm');
                itemTemp.removeClass('dateFromyyyymmdd');
                itemTemp.removeClass('dateFromhhmiss');
                ////////console.log(itemTemp);
                var itemDateFromTemp = itemTemp[0].cloneNode(true);
                var $DateFromTemp = "<div id='itemDateFromTemp'></div>"
                itemTemp.after($DateFromTemp);
                itemTemp.remove();
                var DateFromTemp = $("#itemDateFromTemp")[0];
                DateFromTemp.after(itemDateFromTemp);
                DateFromTemp.remove();
                customShow.clickBindSubform();
            }
        } else if (tag_Type == "radio") {//----------------------------------------------------------todo
 
            // setTimeout(function(){
            itemTemp.find('.custom-radio').addClass("readonly");
            // },0)
        } else if (tag_Type == "checkbox") {//-------------------------------------------------------todo
            itemTemp.find('.custom-check').addClass("readonly");
        } else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
            // $(itemTemp).addClass('editableDisabled');
            // $(itemTemp).prop("disabled", true);        //设置下拉框不可用
            // ////console.log($(itemTemp).find(".select-container"));
            // itemTemp = $(itemTemp).find(".select-container");
            // for(var i = 0 ;i<itemTemp.length;i++){
            //   itemTemp[i].setAttribute('readonly','');
            // }
            console.log($(itemTemp))
            $(itemTemp).find('.select-container_box').addClass('disableColor')
            $(itemTemp).addClass("readonly");
            ////console.log( $(itemTemp));
        } else if (tag_Type == "button") {//---------------------------------------------------------OK
            $(itemTemp).addClass('disabled');
        } else if (tag_Type == "link") {//-----------------------------------------------------------OK
            itemTemp.href = "javascript:void(0);";
            debugger
            for (var i; i < itemTemp.length; i++) {
                itemTemp[i].setAttribute('disabled', 'disabled');
            }
        } else if (tag_Type == "fileupload") {//----------------------------------------------------todo
            console.log($(itemTemp));
            debugger
        } else if (tag_Type == "tree") {//----------------------------------------------------------todo
            // 禁用背景颜色
            console.log($(itemTemp).parents('div[name="TreeWin"]'))
            console.log($(itemTemp))
 
            itemTemp[0].setAttribute('editable', aliasItem.editable);
        }
        // else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
        //     //  var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
        //     console.log($(itemTemp))
        //     itemTemp.setAttribute('editable', aliasItem.editable);
        // }
    }
}
//错误信息显示
customShow.setShowMesageErr = function (id, message, N, type) {
    console.log("setShowMesageErr");
    console.log(message);
    ////console.log(id);
    var mesageHtml = '<div class="' + id + 'Popover"></div>';
    if (customShow.options.customInit.designMode == "1") {
        ////console.log(id);
        ////console.log(message);
        ////console.log(N);
        ////console.log($($(".customViewUEditorCss  #"+id)[N]));
        // $($(".customViewUEditorCss  #"+id)[N]).popover('hide');
        // if($($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg') != undefined){
        //    $('.' + id + 'Popover').html(message);
        // }
        $($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg','true');
        $($(".customViewUEditorCss  #" + id)[N]).popover({
            // title:"错误信息",
            html: true,
            content: mesageHtml,
            trigger: 'manual'
        });
        $($(".customViewUEditorCss  #" + id)[N]).hover(function(){// 普通模式 错误提示修改  李伟民 0125
            if($($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg') != 'false'){
                $($(".customViewUEditorCss  #" + id)[N]).popover('show');
                $('.' + id + 'Popover').html(message);
            }
        },function(){
            $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
        })
        $($(".customViewUEditorCss  #" + id)[N]).on('focus',function(){
            $($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg','false');
            $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
        })
        $($(".customViewUEditorCss  #" + id)[N]).popover('show');
        $('.' + id + 'Popover').html(message);
        setTimeout(function(){
            $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
        },2000)
        customShow.options.showErrId[id] = N;
        //////console.log($($(".customViewUEditorCss  #"+id+"Item")[N]).length);
 
        if ($($(".customViewUEditorCss  #" + id + "Item")[N]).length == 1) {
            $($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg','true');
            $($(".customViewUEditorCss  #" + id + "Item")[N]).popover({
                // title:"错误信息",
                html: true,
                content: mesageHtml,
                trigger: 'manual'
            });
            $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('show');
            $('.' + id + 'Popover').html(message);
            setTimeout(function(){
                $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
            },2000)
            customShow.options.showErrId[id + "Item"] = N;
            $($(".customViewUEditorCss  #" + id + "Item")[N]).hover(function(){
                if($($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg') != 'false'){
                    $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('show');
                    $('.' + id + 'Popover').html(message);
                }
            },function(){
                $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
            })
            $($(".customViewUEditorCss  #" + id + "Item")[N]).on('focus',function(){
                $($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg','false');
                $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
            })// 普通模式 错误提示修改  李伟民 0125
        }
 
    } else {
        var mesageErrDiv = document.createElement("div");
        mesageErrDiv.setAttribute("class", "mesageErrDiv");
        mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
        if(type){//验证消息 修改  李伟民
            $(mesageErrDiv).addClass("checkErr");
        }//验证消息 修改  李伟民
        $(mesageErrDiv).append(message);
        var tempActiveId = $($(".customViewUEditorCss  #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv");
        $($(".customViewUEditorCss  #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv").remove();
        // if(tempActiveId.length == 0){
        //          if($($(".customViewUEditorCss  #"+id+"ActiveId")[N]).length !=0){
        //2017/10/23  李元杰 必选的提示信息修改
        var requiredHint = $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]);
        if (requiredHint.find('input').val() === '') {
            if ($(".customViewUEditorCss  #" + id + "ActiveId").length == 0) {
                console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
                $(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
            } else {
                $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
            }
            $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
        } else {
            if ($(".customViewUEditorCss  #" + id + "ActiveId").length == 0) {
                console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
                if ($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").find(".mesageErrDiv").length == 0) {
                    $(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
                }
            } else {
                if ($($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).find(".mesageErrDiv").length == 0) {
                    $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
                }
            }
        }
        // $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
        //            }
        // }
 
 
    }
 
}
 
//DB数据to画面表示数据转化
customShow.dbItemToShowItem = function (itemId, type, value, showClass, dropdowntype, parentsubFormNum) {
    if (type == "radio" || type == "checkbox") {
        var itemL = $("." + showClass + " ." + itemId + "value");
        //数值变换
        //单选按钮,仅仅有一项情况(无子表单时)
        if (type == "radio" && itemL.length == 1) {
            if (parentsubFormNum != 0) {
                value = value[0];
            }
            value = [[value]];
        } else if (type == "checkbox" && itemL.length == 1) {
            //复选框时,仅仅有一项情况(无子表单时)
            //只选择一项
            if (parentsubFormNum != 0) {
                value = value[0];
            }
            if (typeof value == "string") {
                value = [[value]];
            } else {
                //复数项选择
                value = [value];
            }
        } else if (type == "radio" && itemL.length > 1) {
            //
            var valueTempRadio = [];
            for (var i = 0; i < value.length; i++) {
                valueTempRadio[i] = [value[i]];
            }
            value = valueTempRadio;
        } else if (type == "checkbox" && itemL.length > 1) {
            var valueTempRadio = [];
            for (var i = 0; i < value.length; i++) {
                if (typeof value[i] == "string") {
                    valueTempRadio[i] = [value[i]];
                } else {
                    valueTempRadio[i] = value[i];
                }
            }
            value = valueTempRadio;
        }
    } else if (type == "dropdownlistText") {
 
        //多个下拉菜单
        var itemList = $("." + showClass + " ." + itemId + "value");
        if (itemList.length == 1) {
            if (parentsubFormNum != 0) {
                value = value[0];
            }
            if (typeof value == "string" && dropdowntype == "single") {
                value = [value];
            }
            //子表单中,复选情况
            if (dropdowntype == "multiple") {
                if (typeof value == "string") {
                    value = [value];
                } else {
                    // value = value[0];
                }
            }
            // setelect2Item(itemList[0],value);
        } else {
            for (var i = 0; i < itemList.length; i++) {
                // var valueTemp;
                //单选时,多文件
                if (dropdowntype == "single") {
                    value[i] = [value[i]];
                } else {
                    // for (var i = 0; i < value[i].length; i++) {
                    if (typeof value[i] == "string") {
                        value[i] = [value[i]];
                    } else {
                        value[i] = value[i];
                    }
                    // }
                }
                // setelect2Item(itemList[i],valueTemp);
            }
        }
    }
    return value;
}
 
//表示模式下,数据设定(单选 复选 下拉菜单)
customShow.setShowItem = function (itemId, type, value, flag) {
    //被选择项目设定
    console.log(1)
    //  console.log(_.cloneDeep(itemId))
    //  console.log(_.cloneDeep(type))
    console.log(_.cloneDeep(value))
    //  console.log(_.cloneDeep(flag))
    checkboxRadioShow = function (showItem, value) {
        console.log($(showItem), value)
        var listData = customBase.options.dropdownlistText[itemId];
        if (listData == undefined) {
            return;
        }
        if (typeof value == "string") {
            value = [value];
            // value = JSON.parse(value)
        }
        var temp = [];
        var tempStr = "";
        console.log(listData);
        console.log(value)
        for (var i = 0; i < listData.length; i++) {
            for (var j = 0; j < value.length; j++) {
                if (value[j] == listData[i].value) {
                    console.log(1)
                    temp[j] = listData[i].text;
                }
            }
        }
        console.log(temp)
        for (var i = 0; i < temp.length; i++) {
            if (i == 0) {
                tempStr = temp[i];
            } else {
                tempStr += "," + temp[i];
            }
        }
        console.log(tempStr)
        $(showItem).empty();
        //console.log(tempStr);
        $(showItem).append(tempStr);
 
    }
    var showItem = $("." + itemId + "_showItem");
    console.log(showItem)
    //页面返回
    if (flag) {
        if (type == "checkbox" || type == "radio") {
            if (showItem.length == 1) {
                checkboxRadioShow(showItem[0], value);
            } else {
                for (var i = 0; i < showItem.length; i++) {
                    checkboxRadioShow(showItem[i], value[i]);
                }
            }
        } else {
            if (showItem.length == 1) {
                checkboxRadioShow(showItem[0], value);
            } else {
                for (var i = 0; i < showItem.length; i++) {
                    checkboxRadioShow(showItem[i], value[i]);
                }
            }
        }
    } else {
        if (type == "checkbox" || type == "radio") {
            for (var i = 0; i < showItem.length; i++) {
                var valueTemp = value[i];
                checkboxRadioShow(showItem[i], valueTemp);
            }
        } else {
            if (showItem.length == 1) {
                checkboxRadioShow(showItem[0], value);
            } else {
                for (var i = 0; i < showItem.length; i++) {
                    checkboxRadioShow(showItem[i], value[i]);
                }
            }
        }
    }
}
 
//工具栏设定button
customShow.setToolBtn = function (btns) {
    console.log(btns)
    $(".edit-pane").empty();
    var $editPaneBtn = $($(".edit-pane")[0]);
 
    console.log($editPaneBtn)
    //  //////console.log(btns);
    for (var i = 0; i < btns.length; i++) {
        if (customShow.button[btns[i]].functionName == "") {
            $a = '<a id="' + btns[i] + '" href="javascript:void(0);">' +
                '<i class="icon-flow-edit"></i><span style="color:#ff0000"><i class="' + customShow.button[btns[i]].cssName + '" style="text-align: left;color:#ff0000"></i>' + customShow.button[btns[i]].name + '</span></a>';
        } else {
            $a = '<a id="' + btns[i] + '" href="javascript:void(0);" onclick="' + customShow.button[btns[i]].functionName + '()">' +
                '<i class="icon-flow-edit"></i><span><i class="' + customShow.button[btns[i]].cssName + '" style="text-align: left;"></i>' + customShow.button[btns[i]].name + '</span></a>';
        }
        if (customShow.getFormSetting(btns[i]) != 0) {
            $editPaneBtn.prepend($a);
        }
 
    }
    if (btns.length > 0) {
        // $(".preview-edit-pane").css("display", "block");
    }
}
 
customShow.setTextBtn = function () {
    var item = customShow.options.customItemShow.item["itemId_1"];
    var code = item.tag_Attribute.masterData;
    var masterData = $.parseJSON(code);
    var defindCode = masterData.defindCode;
    var eleCode = masterData.eleCode;
    customLinkageAnalysis.getElement("itemId_1", eleCode, function (re) {
        ////////console.log(re);
    })
}
 
//主数据重复
customShow.setXhSelectList = function (addflag) {
    //    console.log(1)
    var subformDList = customShow.options.subformDList;
    //console.log(subformDList);
    //console.log(85244445)
    //console.log(addflag)
    var setValueItem = {};
    //
    //var subArr = [];
    //_.each(subformDList,opt=>{
    //    subArr.push(opt);
    //})
    //var subObj = {};
    //for(var key in subformDList){
    //    if(subformDList[key] == _.last(subArr)){
    //        subObj[key] = subformDList[key];
    //    }
    //}
    //console.log(_.cloneDeep(subObj));
    for (var id in subformDList) {
        console.log(id);
        if ($(".customViewUEditorCss ." + id).length == 1) {
            var xhSelectTemp = {
                selectId: customShow.options.subformDList[id].selectId,
                multiple: customShow.options.subformDList[id].multiple,
                width: customShow.options.subformDList[id].width,
                listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
                setDiv: id
            };
            console.log(xhSelectTemp);
            console.log(1)
            xhSelect.setXhSelect(xhSelectTemp);
            var item = customShow.options.customItemShow.item[customShow.options.subformDList[id].selectId];
            setValueItem[item.tag_Attribute.alias] = customShow.options.subformDList[id].selectId;
        }
    }
    console.log(setValueItem);
    console.log(customShow.options);
    if (!addflag) {
        for (var valueItem in setValueItem) {
            var setList = customShow.options.subformDValue[valueItem];
            console.log(setList);
            if (setList != undefined) {
                for (var i = 0; i < setList.length; i++) {
                    xhSelect.setValue(setValueItem[valueItem], setList[i], i);
                }
            }
        }
 
    }
}
//子表单添加记录  复制下拉框方法   2017/10/06
customShow.setXhSelectListAdd = function () {
    // //////console.log(table);
    var subformDList = customShow.options.subformDList;
    var setValueItem = {};
    //10/2/27 马习同修改  下拉框复制重复
    var xhSelectTemp = {};
    for (var id in subformDList) {
        if ($(".customViewUEditorCss ." + id).length == 1) {
            var xhSelectTemp = {
                selectId: customShow.options.subformDList[id].selectId,
                multiple: customShow.options.subformDList[id].multiple,
                width: customShow.options.subformDList[id].width,
                listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
                setDiv: id
            };
            // //////console.log($(".customViewUEditorCss ."+id).find('select > option'));
            if ($(".customViewUEditorCss ." + id).find('select > option').length == 0) {
                // //////console.log("----------------------------------------------");
                console.log(1)
                xhSelect.setXhSelect(xhSelectTemp);
            }
        }
    }
    xhSelect.setXhSelect(xhSelectTemp);
    //10/2/27 马习同修改  下拉框复制重复
}
 
 
customShow.getFormSetting = function (btnFlag) {
    var ren = 1;
    if (btnFlag == 'printableBtn') {
        ren = customShow.options.formsetting['printable'];
    } else if (btnFlag == 'exportBtn') {
        ren = customShow.options.formsetting['exportable'];
    } else if (btnFlag == 'rejectBtn') {
        ren = customShow.options.formsetting['rejectable'];
    } else if (btnFlag == 'submitBtn') {
        ren = customShow.options.formsetting['submitable'];
    } else if (btnFlag == 'auditableBtn') {
        ren = customShow.options.formsetting['auditable'];
    } else if (btnFlag == 'queryBtn') {
        ren = customShow.options.formsetting['queryable'];
    } else if (btnFlag == 'createBtn') {
        ren = customShow.options.formsetting['createable'];
    } else if (btnFlag == 'clearBtn') {
        // ren = customShow.options.formsetting['clearable'];
        ren = 1;
    } else if (btnFlag == 'disposableBtn') {
        // ren = customShow.options.formsetting['disposable'];
        ren = 1;
    //} else if (btnFlag == 'fromSaveBtn') {
    //    if(customShow.options.customShowFlag != '3'){//发布修改  李伟民 0120
    //        ren = customShow.options.formsetting['saveable'];
    //        console.log(ren)
    //    }else{
    //        ren = 1;
    //    }
        // ren = 1;
    } else if (btnFlag == 'editableBtn') {
        ren = customShow.options.formsetting['editableBtn'];//编辑按钮受权限控制  李伟民 0204
        // ren = 1;
    }
    return ren;
 
}
var customLinkageAnalysis = customLinkageAnalysis || {};
//-----------------------------------------------------仲追加内容----------------------------------------------------------
customLinkageAnalysis.options = {};
//取得表单值
/**
 * 参数:ItemId 字段ID
 * 返回值:值
 */
customLinkageAnalysis.getValue = function (itemId) {
    var item = customShow.options.customItemShow.item[itemId];
    var alias = item.tag_Attribute.alias;
    var items = customShow.getItems();
    var result = items[alias];
 
    if (item.parentsubFormNum != 0) {
        for (var ItemId in customShow.options.customItemShow.item) {
            if (customShow.options.customItemShow.item[ItemId].columnOrderNum == item.parentsubFormNum) {
                result = items[customShow.options.customItemShow.item[ItemId].tag_Attribute.alias];
            }
        }
        ////console.log(result);
        var resultTemp = "";
 
        for (var i = 0; i < result.length; i++) {
            if (i > 0) {
                resultTemp += ",";
            }
            if (typeof result[i][alias] != "string") {
                resultTemp += result[i][alias].join(',');
            } else {
                resultTemp += result[i][alias];
            }
 
        }
        ////console.log(resultTemp);
        return resultTemp;
    } else if (typeof result != "string") {
        result = result.join(',');
    }
    ////console.log(customShow);
    ////console.log(customLinkageAnalysis);
    console.log(result);
    return result;
}
 
//设定表单值--------------------
/**
 * 参数:ItemId 字段ID
 *      value:设定值
 */
customLinkageAnalysis.setValue = function (itemId, value, num) {
    console.log(itemId);
    console.log(value);
    var item = customShow.options.customItemShow.item[itemId];
    //数据类型
    var type = item.tag_Type;
    if (type == "text" || type == "textarea" ||
        type == "number" || type == "calendar") {
        customBase.setItemValue(itemId, "text", value, "", "", num);
    } else if (type == "radio" || type == "checkbox") {
        if (value.indexOf(",") != -1) {
            value = value.split(",");
            value = [value];
        }
        customBase.setItemValue(itemId, type, value, "customViewUEditorCss");
    } else if (type == "dropdownlist") {
        var dropdowntype = item.tag_Attribute.dropdowntype;
        customBase.setItemValue(itemId, "dropdownlistText", value, "customViewUEditorCss", dropdowntype);
    } else if (type == "htmlediter") {
        var id = itemId + "Item";
        UE.getEditor(id).setContent(value);
    } else if (type == "qrcode") {
        var id = itemId + "qrcode";
        customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
        $("#" + id).blur();
    } else if (type == "barcode") {
        var id = itemId + "barcode";
        customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
        $("#" + id).blur();
    } else if (type == "tree") {
 
    } else if (type == "amount") {
        var id = itemId + "amount";
        customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
        $("#" + id).blur();
    }
 
}
 
//取得属性
/**
 * 参数:ItemId 字段ID
 *      attributeName:属性名
 *                  visible  //可见                     true:可见  false:不可见
                    editable //可编辑                   true:可编辑  false:不可编辑
 */
customLinkageAnalysis.getAttribut = function (itemId, attributeName) {
    console.log(itemId);
    console.log(attributeName)
    var item = customShow.options.customItemShow.item[itemId];
    // return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
    var alias = item.tag_Attribute.alias;
    var ttn = customBase.options.customItems[alias][attributeName];
    ////console.log(ttn)
    return ttn;
}
 
//设定属性---------------需要测试-----
/**
 * 参数:ItemId 字段ID
 *      attributeName:属性名
 *                  visible  //可见                     true:可见  false:不可见
                    editable //可编辑                   true:可编辑  false:不可编辑
 */
customLinkageAnalysis.setAttribut = function (itemId, attributeName, attributeValue) {
    var item = customShow.options.customItemShow.item[itemId];
    // return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
    var alias = item.tag_Attribute.alias;
    console.log(alias)
    attributeValue = attributeValue + "";
    attributeValue = attributeValue.toLowerCase();
    if (attributeValue == "true") {
        attributeValue = true;
    } else if (attributeValue == "false") {
        attributeValue = false;
    } else {
        //默认值
        attributeValue = true;
    }
    customBase.options.customItems[alias][attributeName] = attributeValue;
    customShow.setShowAttribute(customBase.options.customItems[alias]);
}
 
//设定错误信息
/**
 * 参数:ItemId 字段ID
 *      message:信息
 */
customLinkageAnalysis.setMessage = function (mode, ItemId, message, num) {
    var item = customShow.options.customItemShow.item[ItemId];
    var type = item.tag_Type;
    if (num == undefined) {
        num = 0;
    }
    var errorClass;
    if (mode == "0") {//验证消息 修改  李伟民
        errorClass = "errorCheckCss"
    } else {
        errorClass = "errorItemCss";
    }//验证消息 修改  李伟民
    customShow.showErrorItem(errorClass, type, ItemId, num);
    //焦点事件
    // $("." + errorClass).unbind('focus');
    $("[id='" + ItemId + "']:eq(" + num + ")").unbind("focus");
    $("[id='" + ItemId + "']:eq(" + num + ")").on('focus', function () {
        console.log("focus");
        $(this).removeClass(errorClass);
        ////////console.log($(this)[0].id);
        $(this).closest("#" + $(this)[0].id + "ActiveId").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//修改错误信息删除  李伟民  2017-10-18 14:15
        $(this).closest(".tdContentClass").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//列表模式
        //        $("#"+$(this)[0].id+"mesageErrDiv").remove();
        $(".customViewUEditorCss  #" + $(this)[0].id).popover('hide')
    });
    //下拉列表点击事件
    $(".select2-search__field").unbind("focus");
    $(".select2-search__field").bind("focus", function () {
        var id = this.getAttribute("errorItemId");
        var N = this.getAttribute("N");
        $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").removeClass(errorClass);
        $("#" + id + "mesageErrDiv").remove();
        $($(".customViewUEditorCss  #" + id)[N]).popover('hide')
    });
    if (mode == "0") {//验证消息 修改  李伟民
        customShow.setShowMesageErr(ItemId, message, num, true);
    } else {
        customShow.setShowMesageErr(ItemId, message, num);
    }//验证消息 修改  李伟民
 
}
 
//设定alert信息
//参数:type类型
// E:错误信息
// I:信息
// W:警告
// S:成功
//  message:信息
customLinkageAnalysis.alert = function (type, message) {
    customBase.alert(type, message);
}
 
 
 
// 初期调用
customLinkageAnalysis.bindLinkage = function () {
    //    ////console.log(window.customBase);
    //取得公式的JSON数据
    //  ////console.log(customShow);
    //  ////console.log(customLinkageAnalysis);
    var rules = customShow.options.jsonLinkage;
    if (typeof rules == 'string') {
        rules = eval(rules);
    }
    if (rules == null || rules.length == 0) {
        return;
    }
    //初期接口 (false:不继续执行 true:继续执行)
    // customShow.initEvent.interfaceInitLinkage;
 
    //取消接口 (false:不继续执行 true:继续执行)
    // customShow.initEvent.cancelEventLinkage;
 
    //保存接口 (false:不继续执行 true:继续执行)
    // customShow.initEvent.fromSaveLinkage;
    for (var i = 0; i < rules.length; i++) {
        //console.log(rules[i]);
        var dofunction = {};
        try {
            dofunction = customLinkageAnalysis.makeLinkage(rules[i]);
        } catch (e) {
            ////console.log(e.message);
            continue;
        }
        var allFunction = customLinkageAnalysis.changeDoFunction(dofunction);
        var fieldId = rules[i].event.eventFieldId;
        if (fieldId == "_body" && rules[i].event.doEvent == "loading") {
            customShow.initEvent.interfaceInitLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
        } else if (fieldId == "_body" && rules[i].event.doEvent == "commit") {
            customShow.initEvent.fromSaveLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
        }
        var item = customShow.options.customItemShow.item[fieldId];
        if (item != undefined) {
            var doEvent = rules[i].event.doEvent;
            doEvent = doEvent.replace("selectedChange", "change");
            if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
                doEvent = doEvent.replace("change", "click");
            }
            if (item.tag_Type == "amount" || item.tag_Type == "qrcode" || item.tag_Type == "barcode") {
                fieldId = fieldId + item.tag_Type;
            }
            if (item.tag_Type == "htmlediter") {
                UE.getEditor(fieldId + "Item").onclick = function (event, ui) {
                    // eval(strFunction);
                    // ////console.log(UE.getEditor(fieldId+"Item").getContent());
                    customLinkageAnalysis.options[fieldId + "Item"] = UE.getEditor(fieldId + "Item").getContent();
                }
                UE.getEditor(fieldId + "Item").onblur = function (event, ui) {
                    //////console.log(UE.getEditor(fieldId+"Item").getContent());
                    var fieldIdItem = UE.getEditor(fieldId + "Item").getContent();
                    if (fieldIdItem != customLinkageAnalysis.options[fieldId + "Item"]) {
                        eval(allFunction.strFunction);
                    }
 
                }
                ////console.log(UE.getEditor(fieldId+"Item"));
            } else if (item.tag_Type == "tree") {
                customBase.options.zTreeOnClickItems[fieldId + "tree"] = allFunction.strFunction;
            } else if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
 
            } else {
                customLinkageAnalysis.bindEvent(fieldId, doEvent, allFunction);
            }
 
        }
        _.each(rules[i].results, function (ru) {// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09
            if ((ru.mode == "2" || ru.mode == "0") && rules[i].event.eventFieldId != ru.eventFieldId) {//判断是否为验证公式 判断触发控件与弹出消息控件是否为同一控件
                //console.log(ru);
                customLinkageAnalysis.bindEvent(ru.eventFieldId, "blur", allFunction);
            }
        });// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09 end
    }
}
 
 
// 子控件事件调用时
customLinkageAnalysis.bindLinkageSubform = function (inType) {
    //取得公式的JSON数据
    var rules = customShow.options.jsonLinkage;
    if (typeof rules == 'string') {
        rules = eval(rules);
    }
    if (rules == null || rules.length == 0) {
        return;
    }
    // if("calendar" == inType){
    //     $("#"+fieldId).unbind();
    // }
    for (var i = 0; i < rules.length; i++) {
        var dofuncion = "";
        try {
            dofuncion = customLinkageAnalysis.makeLinkage(rules[i]);
        } catch (e) {
            ////console.log(e.message);
            continue;
        }
        var fieldId = rules[i].event.eventFieldId;
        var item = customShow.options.customItemShow.item[fieldId];
        var strFunction = customLinkageAnalysis.changeDoFunction(dofuncion);
        if (item != undefined) {
            var doEvent = rules[i].event.doEvent;
            doEvent = doEvent.replace("selectedChange", "change");
            // if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
            //     // doEvent = doEvent.replace("change", "click");
            // }
            if (inType == item.tag_Type) {
                if (item.tag_Type == "radio") {
                    $("#" + fieldId + ' .custom-radio').on('click', function () {
                        // //////console.log(this.className);
                        if (this.className.indexOf("readonly") > -1) {
                            return;
                        }
                        eval(strFunction);
                    });
                } else if (item.tag_Type == "checkbox") {
                    $("#" + fieldId + ' .custom-check').on('click', function () {
                        // //////console.log(this.className);
                        if (this.className.indexOf("readonly") > -1) {
                            return;
                        }
                        eval(strFunction);
                    });
                } else {
                    customLinkageAnalysis.bindEvent(fieldId, doEvent, strFunction);
                }
 
            }
        }
    }
}
 
customLinkageAnalysis.bindFunctionEvent = function (strFunction) {
    //console.log(strFunction);
    return function () {
        try {
            eval(strFunction);
        } catch (e) {
            ////console.log(e.message);
        }
    }
}
 
customLinkageAnalysis.changeDoFunction = function (doFunction) {
    var conditionCode = doFunction.conditionCode;
    //console.log(doFunction);
    var code = "";
    var strFunction = "";
    var checkFunction = "";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
    if (conditionCode != null) {
        code = conditionCode.code
        var conditionListCode = conditionCode.listCode;
 
        for (var i = 0; i < conditionListCode.length; i++) {
            strFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";
            checkFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
            var reg = new RegExp('\\{' + i + '\\}', "g");
            code = code.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('code" + i + "'))+\"");
        }
        for (var i = 0; i < conditionListCode.length; i++) {
            var reg = new RegExp('\\{' + i + '\\}', "g");
            strFunction = strFunction.replace(reg, "code" + i);
            checkFunction = strFunction.replace(reg, "code" + i);// 单独检查校验规则代码  李伟民 2017-10-19 14:33
        }
        if (conditionCode.clearCode != undefined) {//添加清空错误信息  李伟民 2017-10-18 17:45
            _.each(conditionCode.clearCode, function (_clearCode) {
                strFunction += _clearCode;
                checkFunction += _clearCode;// 单独检查校验规则代码  李伟民 2017-10-19 14:33
            })
        }//添加清空错误信息  李伟民 2017-10-18 17:45 end
        if (code != null && code != "") {
            if (code.indexOf('Math.floor') != -1) {
                code = eval(code);
                ////console.log(code);
            }
            code = "customLinkageAnalysis.expeval(\"=" + code + "\")";
            strFunction += "if (" + code + " == 'true') { \r\n";
            checkFunction += "if (" + code + " == 'true') { \r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
        }
    }
    var results = doFunction.results;
    for (var i = 0; i < results.length; i++) {
        var resultValue = results[i].resultValue;
        var resultJsText = results[i].resultJsText;
        if (resultValue != null) {
            var listCode = resultValue.listCode;
            var resultCode = resultValue.code;
            for (var j = 0; j < listCode.length; j++) {
                strFunction += "var resultCode" + j + " = " + listCode[j] + ";\r\n";
                var reg = new RegExp('\\{' + j + '\\}', "g");
                ////console.log(resultCode);
                resultCode = resultCode.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('resultCode" + j + "'))+\"");
            }
            for (var j = 0; j < listCode.length; j++) {
                var reg = new RegExp('\\{' + j + '\\}', "g");
                strFunction = strFunction.replace(reg, "resultCode" + j);
            }
            //          if(resultCode.indexOf('Math.floor') != -1){
            ////console.log(resultCode);
            //                  resultCode = eval(resultCode);
            //              }
            //console.log(resultCode);
            resultCode = "customLinkageAnalysis.expeval(\"=" + resultCode + "\")";
            strFunction += resultJsText.replace(/\{0\}/g, resultCode);
        } else if (results[i].resultJsText.indexOf("setMessage")) {// 判断是否为 规则校验公式
            strFunction += resultJsText + "; \r\n";
            checkFunction += resultJsText + "; \r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
        } else {
            strFunction += resultJsText + "; \r\n";
        }
        //公式联动追加
        if (results[i].doEvent != undefined && results[i].resultJsText.indexOf("setValue") != -1) {
            strFunction += '$("#' + results[i].targetid + '").trigger("' + results[i].doEvent + '.value");';
        }
 
        //公式联动追加结束
 
    }
 
    if (code != null && code != "") {
        strFunction += "}";
        checkFunction += "}";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
    }
    ////console.log(strFunction);
    var allFunction = { "strFunction": strFunction, "checkFunction": checkFunction };
    return allFunction;
}
 
function funCheck(optarr, allFunction) {//判断是否重复绑定方法
    var flag = true;
    if (optarr != undefined && optarr != '') {
        optarr = JSON.parse(optarr);
        console.log(optarr);
        console.log(allFunction);
        _.each(optarr, function (fn) {
            if (fn.strFunction == allFunction.strFunction && fn.checkFunction == allFunction.checkFunction) {
                console.log("falg false");
                flag = false;
            }
        })
    }
    return flag;
}
 
customLinkageAnalysis.bindEvent = function (fieldId, doEvent, allFunction) {//aaaaaa
    console.log(allFunction);
    var evalstr = "";
    var evalchekstr = "";
    ////console.log(customShow.options.customItemShow.item[fieldId].tag_Type);
    if (customShow.options.customItemShow.item[fieldId].tag_Type == "dropdownlist") {
        ////console.log($("[id='" + fieldId+"']"));
        ////console.log($("[id='" + fieldId+"']").find(".select_get"));
        ////console.log($(".select_get"));
        ////console.log(strFunction);
        _.each($("[id='" + fieldId + "']").find(".select_get"),function(opt){
            var optarr = $(opt).attr("funarr");
            if(funCheck(optarr,allFunction)){
                $(opt).on(doEvent + ".value", function () {
            if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
                // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
                    if (allFunction.strFunction.indexOf("var i=") == -1) {
                        ////console.log(i);
                        evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
                    }
                // })
            }else{
                evalstr = allFunction.strFunction;
            }
            try {
                console.log(evalstr);
                eval(evalstr);
            } catch (e) {
                ////console.log(e.message);
            }
        });
                var funarr;
                if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
                    funarr = [allFunction];
                }else{
                    funarr = JSON.parse($(opt).attr("funarr"));
                    funarr.push(allFunction);
                }
                $(opt).attr("funarr",JSON.stringify(funarr));
            }
            var checkarr = $(opt).attr("checkfunarr");
            if(funCheck(checkarr,allFunction)){
                $(opt).on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
            if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
                // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
                    if (allFunction.checkFunction.indexOf("var i=") == -1) {
                        evalchekstr = "var i=" +  $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
                    }
                // })
            }else{
                evalchekstr = allFunction.checkFunction;
            }
            try {
                eval(evalchekstr);
            } catch (e) {
                //console.log(e.message);
            }
        });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
                var checkfunarr;
                if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
                    checkfunarr = [allFunction];
                }else{
                    checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
                    checkfunarr.push(allFunction);
                }
                $(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
            }
 
        });
        // $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".value", function () {
        //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
        //         // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
        //             if (allFunction.strFunction.indexOf("var i=") == -1) {
        //                 ////console.log(i);
        //                 evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
        //             }
        //         // })
        //     }else{
        //         evalstr = allFunction.strFunction;
        //     }
        //     try {
        //         console.log(evalstr);
        //         eval(evalstr);
        //     } catch (e) {
        //         ////console.log(e.message);
        //     }
        // });
        // $("[id='" + fieldId + "']").find(".select_get").unbind(doEvent + ".check");
        // $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
        //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
        //         // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
        //             if (allFunction.checkFunction.indexOf("var i=") == -1) {
        //                 evalchekstr = "var i=" +  $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
        //             }
        //         // })
        //     }else{
        //         evalchekstr = allFunction.checkFunction;
        //     }
        //     try {
        //         eval(evalchekstr);
        //     } catch (e) {
        //         //console.log(e.message);
        //     }
        // });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
    } else {
        // $("[id='" + fieldId + "']").unbind(doEvent + ".value");
        _.each($("[id='" + fieldId + "']"),function(opt){
            var optarr = $(opt).attr("funarr");
                if(funCheck(optarr,allFunction)){
                    $(opt).on(doEvent + ".value", function () {
            if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0 && allFunction.strFunction.indexOf("getSum") == -1) {
                console.log($("[id='" + fieldId + "']"));
                console.log($(this));
                console.log($("[id='" + fieldId + "']").index(this));
                // _.each($("[id='" + fieldId + "']"), (item, i) => {
                    // console.log($(item));
                    if (allFunction.strFunction.indexOf("var i=") == -1) {
                        ////console.log(i);
                        evalstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.strFunction;
                    }
                // })
            }else if(allFunction.strFunction.indexOf("getSum") > 0){
                console.log(allFunction.strFunction);
                console.log("replace");
                evalstr = allFunction.strFunction;
                // allFunction.strFunction = allFunction.strFunction.replace(new RegExp(".split(',')[i]") ,"");
                while(evalstr.indexOf(".split(',')[i]") != -1){
                    evalstr = evalstr.replace(".split(',')[i]","");
                }
            }else{
                evalstr = allFunction.strFunction;
            }
            // try {
                console.log(evalstr);
                eval(evalstr);
            // } catch (e) {
            //     ////console.log(e.message);
            // }
        });
                var funarr;
                if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
                    funarr = [allFunction];
                }else{
                    funarr = JSON.parse($(opt).attr("funarr"));
                    funarr.push(allFunction);
                }
                $(opt).attr("funarr",JSON.stringify(funarr));
 
            };
            var checkarr = $(opt).attr("checkfunarr");
            if(funCheck(checkarr,allFunction)){
                $(opt).on("blur.check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
            if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
                        console.log("change.check");
                _.each($("[id='" + fieldId + "']"), (item, i) => {
                    if (allFunction.checkFunction.indexOf("var i=") == -1) {
                        ////console.log(i);
                        evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
                    }
                })
            }else{
                evalchekstr = allFunction.checkFunction;
            }
            try {
                if(evalchekstr.indexOf('alert') == -1){
                    eval(evalchekstr);
                }
            } catch (e) {
                ////console.log(e.message);
            }
        });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
                var checkfunarr;
                if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
                    checkfunarr = [allFunction];
                }else{
                    checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
                    checkfunarr.push(allFunction);
    }
                $(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
            }
 
        });
        // $("[id='" + fieldId + "']").unbind(doEvent + ".check");
        // $("[id='" + fieldId + "']").on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
        //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
        //         console.log("change.check");
        //         _.each($("[id='" + fieldId + "']"), (item, i) => {
        //             if (allFunction.checkFunction.indexOf("var i=") == -1) {
        //                 ////console.log(i);
        //                 evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
        //             }
        //         })
        //     }else{
        //         evalchekstr = allFunction.checkFunction;
        //     }
        //     try {
        //         eval(evalchekstr);
        //     } catch (e) {
        //         ////console.log(e.message);
        //     }
        // });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
    }
}
 
customLinkageAnalysis.changeEvalType = function (str) {
    console.log(str);
    if (isNaN(Number(str)) && (str.substring(0, 1) != "\"" || str.substring(str.length - 1, 1) != "\"") && (str.indexOf('||') != -1) && (str.indexOf('&&') != -1)) {//|| && 修改 李伟民 公式不稳定修改 0202 
        return "'" + str + "'";
    } else {
        ////console.log(str);
        return str;
    }
}
 
//事件绑定调用
//事件绑定:字段ID:ItemId 事件名 自定义事件名
//参数
// eventItem=[{
//     ItemId:"Item_1", 控件id
//     event:"click",  事件
//     eventmethod:"XXXXXXXXXXXXXXXXXXXX"   自定义事件名
// }]
customLinkageAnalysis.setEventBind = function (eventItem) {
    customShow.setEventBindItem(eventItem);
}
//03检证执行(接口)
customLinkageAnalysis.validationEx = {
    get: function (alias) {
        var itemTempS;
        var item = customBase.options.customItems[alias];
        if (item.type == "button" || item.type == "link") {
        } else if (item.type == "dropdownlist") {
            var datasourcetype = $("#" + item.id)[0].getAttribute("datasourcetype");
            //////////console.log(datasourcetype);
            //主数据源
            if (datasourcetype == "masterdata") {
                itemTempS = customBase.getItemValue(item.id, item.type);
                //数据源
            } else if (datasourcetype == "datasource") {
                itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
                //自定义
            } else if (datasourcetype == "custom") {
                itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
                //API接口
            } else if (datasourcetype == "api") {
                itemTempS = customBase.getItemValue(item.id, item.type);
            }
        } else if (item.type == "subform") {
 
        } else {
            itemTempS = customBase.getItemValue(item.id, item.type);
        }
        item.value = itemTempS;
        ////////console.log(item);
        return item;
    }
}
//取得主数据
/*
itemId:项目ID
masterCode:执行CODE
返回值:元素的值
*/
customLinkageAnalysis.getElement = function (itemId, masterCode, num) {
    var item = customShow.options.customItemShow.item[itemId];
    var code = item.tag_Attribute.masterData;
    var masterData = $.parseJSON(code);
    var defindCode = masterData.defindCode;
    var eleCode = masterData.eleCode;
    var eleValue = customLinkageAnalysis.getValue(itemId);
    if(num != undefined && eleValue != undefined && eleValue.indexOf(',') != -1){//子表单中控件处理  李伟民  0106
        eleValue = eleValue.split(',')[num];
    }
    var opt = {
        eleCode: eleCode,
        defindCode: defindCode,
        eleValue: eleValue,
        masterCode: masterCode,
        itemId: itemId
    }
    //主数据取得
    var result = customDataBound.getElement1(opt);
    console.log(result);
    console.log(itemId)
    if (result.rspCode == "000000") {
        if (result.data[itemId].length > 0) {
            console.log(result.data[itemId][0].value)
            return result.data[itemId][0].value;
        } else {
            return "";
        }
    } else {
        return "";
    }
}
 
customLinkageAnalysis.clearMessage = function (itemId, num) {//清空错误信息方法  李伟民 2017-10-18 16:36
    if (num == undefined) {
        num = 0;
    }
    //console.log($("[id='"+itemId+"']:eq("+num+")"));
    //console.log($("[id='"+itemId+"ActiveId']:eq("+num+")"));
    $("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorItemCss");
    $("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorCheckCss");
    $("[id='" + itemId + "ActiveId']:eq(" + num + ")").find("#" + itemId + "mesageErrDiv").remove();
}//清空错误信息方法  李伟民 2017-10-18 16:36 end
 
customLinkageAnalysis.makeLinkage = function (rule) {
    ////console.log(rule);
    var result = {};
    var conditionCode = {};
    conditionCode = customLinkageAnalysis.changeCodeMirror(rule.conditionCode, rule.conditionHistory._history);
 
    if (rule.conditionCode != "" && !_.isNull(rule.conditionCode)) {//清空错误信息  李伟民 2017-10-18 16:36
        var clearCode = [];
        _.each(rule.results, function (ru) {
            if (ru.mode == "2") {
                var ruItem = customShow.options.customItemShow.item[ru.eventFieldId];
                if (ruItem.parentsubFormNum != 0) {
                    clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "',i);");
                } else {
                    clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "');");
                }
            }
        });
        conditionCode["clearCode"] = clearCode;
    }//清空错误信息  李伟民 2017-10-18 16:36 end
 
    var results = new Array();
    for (var i = 0; i < rule.results.length; i++) {
        var resultJs = {};
        var textType = rule.results[i].attribute;
        var resultJsText = "";
        var resultTargrtItem = customShow.options.customItemShow.item[rule.results[i].eventFieldId]; if ("1" == rule.results[i].mode) {
            var resultValue = customLinkageAnalysis.changeCodeMirror(rule.results[i].code, rule.results[i].eventHistory._history);
            resultJs.resultValue = resultValue;
            if (textType == 'value') {
                if (resultTargrtItem.parentsubFormNum != 0) {
                    resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0}, i);";
                } else {
                    resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0});";
                }
            } else if (textType == 'visible' || textType == 'editable') {
                resultJsText += "customLinkageAnalysis.setAttribut('" + rule.results[i].eventFieldId + "','" + textType + "', {0});";
            } else {
                // todo
            }
        } else if ("2" == rule.results[i].mode || "0" == rule.results[i].mode) {
            if (resultTargrtItem.parentsubFormNum != 0) {//自定义校验支持子表单中控件  李伟民 2017-10-18 14:34
                //              resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "',i);";
                resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "',i);";
            } else {
                //              resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "');";
                resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "');";
            }//自定义校验支持子表单中控件  李伟民 2017-10-18 14:34 end
 
        } else if ("3" == rule.results[i].mode) {
            resultJsText += "customLinkageAnalysis.alert('" + rule.results[i].messageType + "','" + rule.results[i].message + "');";
        } else {
            ;
        }
        resultJs.resultJsText = resultJsText;
        resultJs.targetid = rule.results[i].eventFieldId;// 公式联动追加 目标控件
        var targetDoEvent = '';
        //      ////console.log(customShow.options.jsonLinkage);
        var jsonLinkage_add = customShow.options.jsonLinkage;//预览公式联动修改 李伟民 0117
        if (_.isString(jsonLinkage_add)) {
            jsonLinkage_add = JSON.parse(jsonLinkage_add);
        }
        _.each(jsonLinkage_add, function (allrule) {// 公式联动追加 目标控件事件
            if (allrule.event.eventFieldId == resultJs.targetid) {
                resultJs.doEvent = allrule.event.doEvent;
            }
        });
        results.push(resultJs);
    }
    result.conditionCode = conditionCode;
    result.results = results;
    ////console.log(result);
    return result;
}
 
customLinkageAnalysis.reachLeftSpace = function (str, length) {
    var result = str;
    if (str.length < length) {
        var spaceLen = length - str.length;
        for (var i = 0; i < spaceLen; i++) {
            result = " " + result;
        }
    }
    return result;
}
 
customLinkageAnalysis.replace = function (str, stringObj, replaceText, from, to) {
    var resultBefore = str.substring(0, from);
    var text = str.substring(from, to);
    var resultAfter = str.substring(to);
    text = text.replace(stringObj, customLinkageAnalysis.reachLeftSpace(replaceText, stringObj.length));
    return resultBefore + text + resultAfter;
}
 
customLinkageAnalysis.changeCodeMirror = function (code, history) {
    if (code.trim() == "") {
        return null;
    }
    //console.log(code);
    //console.log(history);
    var result = {};
    var conditionCode = "";
    var listCode = new Array();
    var arrConditionCode = code.split('\r\n');
    ////console.log(arrConditionCode);
    var resultIndex = 0;
 
    if (history != null && history.length > 0) {
        for (var i = 0; i < history.length; i++) {
            var line = history[i].from.line;
            var fromCh = history[i].from.ch;
            var toCh = history[i].to.ch;
            var text = history[i].text;
            arrConditionCode[line] = customLinkageAnalysis.replace(arrConditionCode[line], text, '{' + resultIndex + '}', fromCh, toCh);
            var idText = history[i].idText;
            var arrInputText = idText.split('.');
            var replaceText = "";
            var id = arrInputText[0];
            var textType = arrInputText[1];
            var idItem = customShow.options.customItemShow.item[id]; if (textType == 'value') {
                if (idItem.parentsubFormNum != 0) {
                    replaceText = "customLinkageAnalysis.getValue('" + id + "').split(',')[i]";
                } else {
                    replaceText = "customLinkageAnalysis.getValue('" + id + "')";
                }                // ////console.log(replaceText);
            } else if (textType == 'visible' || textType == 'editable') {
                replaceText = "customLinkageAnalysis.getAttribut('" + id + "','" + textType + "')";
            } else {
                if (idItem.parentsubFormNum != 0) {//主数据关联也需区分子表单中控件  李伟民 0106
                    replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "',i)";
                } else {
                    replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
                }
                // replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
            }
            listCode.push(replaceText);
            resultIndex++;
        }
    }
    conditionCode = arrConditionCode.join('\r\n').replace(/\(/g, "###(###");
    conditionCode = conditionCode.replace(/\)/g, "###)###");
    arrConditionCode = conditionCode.split('\r\n');
    conditionCode = arrConditionCode.join('\r\n');
    conditionCode = conditionCode.replace(/AND/g, '&&');
    conditionCode = conditionCode.replace(/OR/g, '||');
    while (conditionCode.indexOf('  ') >= 0) {
        conditionCode = conditionCode.replace(/  /g, ' ');
    }
    var conditionCodeResult = customLinkageAnalysis.changeSign(conditionCode, listCode, resultIndex);
    conditionCode = conditionCodeResult.conditionCode;
    resultIndex = conditionCodeResult.resultIndex;
    conditionCode = conditionCode.replace(/###\(###/g, "(");
    conditionCode = conditionCode.replace(/###\)###/g, ")");
    result.code = conditionCode;
    result.listCode = listCode;
    //console.log(result);
    return result;
}
 
customLinkageAnalysis.changeCodeSign = function (sign, inner) {
    var exp = igame.Expression;
    if (sign.indexOf('MAX') >= 0) {
        sign = "Max";
    } else if (sign.indexOf('MIN') >= 0) {
        sign = "Min";
    } else if (sign.indexOf('AVG') >= 0) {
        sign = "Average";
    } else if (sign.indexOf('SUM') >= 0) {
        sign = "Sum";
    } else if (sign.indexOf('COUNT') >= 0) {
        sign = "Count";
    } else if (sign.indexOf('||') >= 0) {//|| &&修改 李伟民 0202 公式不稳定修改
        return sign + eval("[" + inner + "]").toString();
    } else {
        return "";
    }
 
    var arlInner = eval("[" + inner + "]");
    return new exp.Formula(sign + "(" + arlInner.join(',') + ")").evaluate().toString();
}
 
customLinkageAnalysis.expeval = function (str) {
    //    console.log(str);
    if (str.trim().replace(/=/, "") == "") {
        console.log("str  err");
        return " ";
    }
    console.log("str  scc");
    var exp = igame.Expression;
    //      console.log(exp);
    //      console.log(str);
    //      console.log(new exp.Formula(str));
    //      console.log(new exp.Formula(str).evaluate());
    //      console.log(new exp.Formula(str).evaluate().toString());
    return new exp.Formula(str).evaluate().toString();
}
 
customLinkageAnalysis.changeSign = function (conditionCode, listCode, resultIndex) {
    ////console.log(conditionCode);
    var index = 0;
    var indexOf = -1;
    var result = {};
    while ((indexOf = conditionCode.substring(index).indexOf('MAX')) >= 0
        || (indexOf = conditionCode.substring(index).indexOf('MIN')) >= 0
        || (indexOf = conditionCode.substring(index).indexOf('AVG')) >= 0
        || (indexOf = conditionCode.substring(index).indexOf('SUM')) >= 0
        || (indexOf = conditionCode.substring(index).indexOf('COUNT')) >= 0
        || (indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
        || (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
        || (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
        || (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数  李伟民 2017-10-17 21:49 修改公式
        var before = conditionCode.substring(0, indexOf);
        var beforeInner = 0;
        var afterIndexOf = 0;
        var sign;
        var after;
        if (history != null && history.length > 0) {
            beforeInner = conditionCode.substring(indexOf).indexOf('###(###') + 7
            // afterIndexOf = conditionCode.substring(indexOf).lastIndexOf('###)###');
            afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '###(###', '###)###');
            sign = conditionCode.substring(indexOf).substring(0, beforeInner - 7);
            after = conditionCode.substring(indexOf).substring(afterIndexOf + 7);
        } else {
            beforeInner = conditionCode.substring(indexOf).indexOf('(') + 1
            // afterIndexOf = conditionCode.substring(indexOf).lastIndexOf(')');
            afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '(', ')');
            sign = conditionCode.substring(indexOf).substring(0, beforeInner - 1);
            after = conditionCode.substring(indexOf).substring(afterIndexOf + 1);
        }
        var inner = conditionCode.substring(indexOf).substring(beforeInner, afterIndexOf);
        var innerResult = customLinkageAnalysis.changeSign(inner, listCode, resultIndex);
        inner = innerResult.conditionCode;
        resultIndex = innerResult.resultIndex;
        inner = inner.replace(/###\(###/g, "(");
        inner = inner.replace(/###\)###/g, ")");
        if ((indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
            || (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
            || (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
            || (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数  李伟民 2017-10-17 21:49 修改公式
            listCode.push(sign + "(" + inner + ")");
        } else {
            listCode.push("customLinkageAnalysis.changeCodeSign('" + sign + "',\[" + inner + "\])");
        }
 
        conditionCode = before + "{" + resultIndex + "}";
        resultIndex++;
        index = conditionCode.length - 1;
        conditionCode += after;
    }
    result.conditionCode = conditionCode;
    result.resultIndex = resultIndex;
    ////console.log(result);
    return result;
}
addtest = function (arg1, arg2) {
    return arg1 + arg2;
}
 
getDay = function (arg1, arg2) {//时间函数  李伟民 2017-10-17 21:49
    var date1 = new Date(arg1)
    var date2 = new Date(arg2)
    var s1 = date1.getTime(), s2 = date2.getTime();
    var total = (s1 - s2) / 1000;
    var day = parseInt(total / (24 * 60 * 60));//计算整数天数
    //console.log(day);
    return day;
}//时间函数  李伟民 2017-10-17 21:49 end
 
getSum = function () {
    console.log(arguments);
    var allItem = [];
    _.each(arguments, function (arg) {
        allItem.push(arg.split(","));
    });
    console.log(allItem);
    var sum = 0;
    _.each(allItem, function (item) {
        _.each(item, function (cd) {
            sum += Number(cd);
        })
    })
    return sum;
}
 
customLinkageAnalysis.getBackBracketIndex = function (str, strBracket, strBackBracket) {
    var beforeIndex = str.indexOf(strBracket);
    var backIndex = str.indexOf(strBackBracket);
    var layers = 0;
    while (beforeIndex < backIndex && beforeIndex >= 0) {
        layers++;
        beforeIndex = str.indexOf(strBracket, beforeIndex + strBracket.length)
    }
    while (layers > 1 && backIndex >= 0) {
        layers--;
        backIndex = str.indexOf(strBackBracket, backIndex + strBackBracket.length);
    }
    if (backIndex < 0) {
        throw Error("括号未闭合");
    }
    return backIndex;
}
var customDataBound = customDataBound || {};
 
//根据表单ID取得表单基本信息
customDataBound.getFormbase = function (formid, callback) {
    // if(customBase.options.formbaseInfo == ""){
    var dataObj = {};
    dataObj.formID = formid;
    var requestRight = window.commonAjax("/formbase/getFormInfoService", dataObj, "GET", true);
    requestRight.done(function (rs) {
        callback(rs);
    })
 
 
    // }else{
    //     callback(customBase.options.formbaseInfo);
    // }
}
 
//表单保存
customDataBound.savaFormbase = function (formbase, callback) {
    ////////////console.log(formbase);
    var dataObj = {};
    dataObj = formbase;
    console.log(formbase);
    var requestRight = window.commonAjax("/formbase/saveformService", dataObj, "POST", true);
    requestRight.done(function (rs) {
 
        callback(rs);
    });
}
 
//表单数据保存
customDataBound.fromSave = function (formid, formbase, callback) {
    // if(window.localStorage.getItem("bussinessSystem")){
    //     var flag = window.localStorage.getItem("bussinessSystem");
    // }
    var dataObj = {};
    dataObj.formID = formid;
    dataObj.data = formbase;
    //     dataObj.tenantID = "001";
    // dataObj.flag = flag;
    //dataObj.flag = "cloud"
    //console.log(dataObj);
    if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
        _.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
    }//保存时 传云单标号 李伟民 12-22
    //_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
    var requestRight = window.commonAjax("/datamanagement/addFormDataService", dataObj, "POST", true);
    requestRight.done(function (rs) {
        callback(rs);
    });
}
 
//表单数据编辑
customDataBound.fromEdit = function (formid, formbase, dataRowNum, callback) {
    var dataObj = {};
    // if(window.localStorage.getItem("bussinessSystem")){
    //     var flag = window.localStorage.getItem("bussinessSystem");
    // }
    // dataObj.flag = flag;
    dataObj.formID = formid;
    dataObj.dataRowNum = dataRowNum;
    dataObj.data = formbase;
    if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
        _.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
    }//保存时 传云单标号 李伟民 12-22
    //_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
    var requestRight = window.commonAjax("/datamanagement/updateFormDataService", dataObj, "POST", true);
    requestRight.done(function (rs) {
 
        callback(rs);
    });
}
 
// 获取表单设定数据源信息
 
// JSON:{"rspCode":"000000","rspDesc":"请求成功","data":[{"测试连接":["actor_id","first_name","last_name","last_update"]}]}
customDataBound.getDatasource = function (formID, callback) {
    var dataObj = {};
    dataObj.formID = formID;
    // dataObj.formID = '8888';
    // dataObj.tenantID = "001";
    var requestRight = window.commonAjax("/datasource/getDatasourceColumnsNameService", dataObj, "GET", true);
 
    requestRight.done(function (rs) {
        if (rs.rspCode == "000000") {
            callback(rs.data);
        } else {
            callback(rs.data);
        }
    });
}
 
// 获取当前表单设置字段的数据源信息  数据绑定
// 参数: formID,tenantID
// JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
customDataBound.getFieldDatasource = function (Datasource, callback) {
    url = "/datasource/getDatasourceColumnsValueService?tenantID={tenantID}&databaseName={databaseName}&datasource={datasource}&columnNames={columnNames}&callbackId={callbackId}";
    url = url.replace("{databaseName}", Datasource.databaseName);
    url = url.replace("{columnNames}", Datasource.columnNames);
    url = url.replace("{datasource}", Datasource.datasource);
    url = url.replace("{callbackId}", Datasource.callbackId);
 
    window.commonGetJson(url, callback);
 
}
 
// 获得主数据
customDataBound.getElement = function (code, callbackId, callback) {
    if (code != "") {
        var dataObj = {};
        dataObj.tenantIDForMaster = 1;
         if(_.isString(code)){
            dataObj.code = code;
        }else{
            dataObj.code = JSON.stringify(code);
        }
        dataObj.callbackId = callbackId;
        //console.log(dataObj);
        let customlocalStorage = window.localStorage.getItem("bussinessSystem");
        var reg = new RegExp('"', "g"); // service  修改  李元杰 11-16
        customlocalStorage = customlocalStorage.replace(reg, ""); // service  修改  李元杰 11-16
        console.log(customlocalStorage);
        dataObj.flag = customlocalStorage;
        var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate", dataObj, "POST", true);
 
        requestRight.done(function (rs) {
            console.log(rs)
            if (rs.rspCode == "000000") {
                console.log(rs)
                callback(rs);
                customShow.addTitle();
                SC.money_cur();
                // 12/13
 
                console.log(window.localStorage.getItem('customShowFlag'))
                if (window.localStorage.getItem('customShowFlag') == 1) {
                    // customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType');
                    SC.autoFieldKey();
                }
            } else {
                callback(rs);
                console.log(rs)
                toastr.error(rs.rspDesc.responseJSON);
            }
        });
        requestRight.error(function (rs) {
            // console.log(rs)
            // toastr.error(rs.responseJSON.rspDesc);
 
        })
    } else {
        callback([]);
    }
 
}
 
// 获得主数据
customDataBound.getElement1 = function (opt) {
    var dataObj = {};
    // dataObj.tenantIDForMaster = 1;
    // dataObj.code =opt;
    // dataObj.callbackId = callbackId;
    var result;
    var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate1", opt, "POST", true, false);
    requestRight.done(function (rs) {
        if (rs.rspCode == "000000") {
            result = rs;
        } else {
            result = rs;
        }
    });
    return result;
}
 
// 获取当前表单设置字段的数据源信息  API数据取得
// 参数: formID,tenantID
// JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
customDataBound.getApiDatasource = function (url, callbackId, callback) {
    // console.log(1);
    var urls = url;
    var url = url + "&callbackId={callbackId}";
 
    url = url.replace("{callbackId}", callbackId);
    // var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
    // xhr.open("GET", urls, true);
    // debugger
    // xhr.onreadystatechange = function () {
    //     var res = JSON.parse(xhr.responseText);
    //     console.log(res);
    // }
    $.ajax({
        type: "get",
        url: urls,
        async: true,
        success: function (rs) {
            console.log(url);
            console.log(rs);
            callback(rs, url);
        }
    });
    // // var url = url + "&callbackId={callbackId}";
    // // url = url.replace("{callbackId}", callbackId);
    // // //////////console.log(url);
    // // window.commonGetApiJson(url, callback);
    //     //////////console.log(url);
    //     //window.commonGetApiJson(url,callback);
}
 
customDataBound.bindInterface = function (formid) {//绑定接口注册方法//保存前计算费用  李伟民   10 - 31
    var dataObj = {};
    dataObj.formID = formid;
    var accessToken = JSON.parse(localStorage.getItem("token")).accessToken;
    dataObj.access_token = accessToken;
    var requestRight = window.commonAjax("/forminterface/getFormInterfaceListService", dataObj, "GET", true, false);
    requestRight.done(function (rs) {
        //console.log(rs);
        customBase.interfaceData = rs.data;
 
    })
}//保存前计算费用  李伟民   10 - 31
 
customDataBound.formsetting = function (formid, callback) {
    // 工具栏自定义10/18
    $('.edit_form').html("");
    var type = "";
    var flag = window.localStorage.getItem("customShowFlag");
    switch (flag) {
        case "1": type = "TJ"; break;
        case "3": type = "XG"; break;
        case "2": type = "XX"; break;
        case "4": type = "LB"; break;
    }
 
    //console.log(type);
    var dataObj = {};
    dataObj.formID = formid;
    dataObj.type = type;
    console.log(dataObj)
    var dataObjFlag = _.cloneDeep(dataObj);
    delete dataObjFlag.type
    var request = window.commonAjax("/formbase/getFormInfoService", dataObjFlag, "GET", true);
    request.done(function (rs) {
        if (rs.data != null) {
            window.localStorage.setItem('bussinessSystem', rs.data.bussinesssystem)
        }
    })
 
 
 
    var requestRight = window.commonAjax("/formsetting/getFormsettingInfoService", dataObj, "POST", true);
    requestRight.done(function (rs) {
        customDataBound.bindInterface(formid);
        //          ////console.log(rs);
        //console.log(type);
        if (rs.data.saveable == "0") {
            $(".sure_box").hide();
        }
        if (!rs.data.subCustomButton) {
            $("#doself").remove();
 
        }
        if (rs.data.subCustomButton) {
            // var dd=document.createElement('span');
            var formdata = [];
            //console.log("查询类型");
            //console.log(type);
            switch (type) {
                case "TJ": formdata = rs.data.subCustomButton.addCustomButton; break;
                case "XG": formdata = rs.data.subCustomButton.updateCustomButton; break;
                case "XX": formdata = rs.data.subCustomButton.detailedCustomButton; break;
                case "LB": formdata = rs.data.subCustomButton.listCustomButton; break;
            }
            //console.log("渲染结果");
            var srcd = document.createElement('script');
            // var tabledata=rs.data.customButtons;
            srcd.type = "text/javascript";
            _.each(formdata, function (obt, i) {
                var dd = document.createElement('span');
                dd.id = obt.buttonName + i;
                //btn btn-default
                dd.setAttribute("class", "btn_myself");
                dd.setAttribute("buttonId", obt.buttonId);
                dd.innerHTML = "<i class='icon iconfont icon-kongjian_danhangwenben' style='text-align: left;'></i>" + obt.buttonName;
 
                $(".edit_form").append(dd);
 
                //console.log(obt.buttonName);
                if (obt.buttonName == "驳回") {
                    //console.log("等于撤回");
                    // 定义审批流程定义的方法
                    // 撤销流程实例
 
                    $("#" + dd.id).click(function () {
                        var process = localStorage.getItem("processid");
 
                        //console.log(process);
                        var dd = JSON.parse(process);
                        var tent = JSON.parse(localStorage.getItem("tenantID")).tenantID;
 
                        //console.log(dd.data);
                        window.queryAjaxs("ubp-api-seache/process/inst/log", { "processInstId": dd.data.processInstId }, "POST", true).done(function (res) {
                            //console.log("打印回执");
                            //console.log(res);
                            if (res != undefined) {
                                //console.log("发送请求");
                                window.queryAjaxs("ubp-api-control/process/inst/drawBack", { "processInstId": res.data[0].processInstId, "activityInstId": res.data[0].activityInstId }, "POST", true).done(function (res) {
                                    //console.log("打印回执");
                                    //console.log(res);
                                    if (res.data == 1) {
                                        //console.log("撤销成功");
                                        customBase.alert('S',"撤销成功");
                                        // localStorage.removeItem('userinfo')
                                    }
                                })
                            }
 
                        })
 
                    });
 
                    // 结束流程实例
                } else if (obt.buttonName == "结束") {
                    $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
                    $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
                    $("#" + dd.id).click(function () {
                        var processLog = JSON.parse(localStorage.getItem("processLog"));
                        if (processLog != null && processLog != undefined) {
                        } else {
                            $("#liucheng").html("<h3 class='sp_title'>请先创建一个流程<h3>");
                            return null;
                        }
                        if (processLog[0].processState == 60) {
                            $("#liucheng").html("<h3 class='sp_title'>流程已结束<h3>");
                            return null;
                        } else {
                            var inputs = "<h3 class='sp_title'>是否确认结束?<h3><br/>"
                                + "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='over(true)'/>&nbsp;&nbsp;<input type='button' class='btn btn-default choosebtn' value='取消' onclick='over(false)'/></div>";
                            $("#liucheng").html(inputs);
                            $("#sssd").click();
 
                        }
                    });
 
                } else if (obt.buttonName == "退回") {
                    $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
                    $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
                    $("#" + dd.id).click(function () {
                        var processLog = JSON.parse(localStorage.getItem("processLog"));
                        if (processLog[0].processState == 60) {
                            customBase.alert('E',"流程已结束");
                            return null;
                        } else {
                            if (processLog != "null" && processLog != undefined) {
                                console.log(processLog.length);
                                if (processLog.length == 1) {
                                    customBase.alert('W',"无可退回活动");
                                    return null;
                                }
                            } else {
                                customBase.alert('W',"请先创建一个流程");
                                return;
                            }
                            //请求可退回活动项
                            var isshow = false;
                            var ss = {
                                "processInstId": processLog[0].processInstId
                            }
                            var requestSingleForm = window.commonAjax("/ubp-api-seache/process/get/back", ss, "POST", true);
                            requestSingleForm.done(function (rs) {
                                console.log(rs);
                                var res = rs.data;
                                if (res != undefined & res != null) {
 
                                    if (res.length > 0) {
 
                                        var inputs = "<h3 class='sp_title'>请选择要退回的活动</h3><br/>";
                                        for (var i = 0; i < res.length; i++) {
                                            if (i == 0) {
                                                inputs += "<input style='margin-left:-9px !important;' type='radio' onClick='choosebox(" + i + ")' class='act acts' value=" + res[i].activityDefId + " name='task'   />" + res[i].activityDefName + "</br>";
                                            } else {
                                                inputs += "<input  type='radio'  onClick='choosebox(" + i + ")' class='act acts' value=" + res[i].activityDefId + " name='task'  />" + res[i].activityDefName + "</br>";
                                            }
                                        }
                                        inputs += "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn' type='button' value='取消' onclick='tui(false)'/><input type='button' class='btn btn-default choosebtn2' value='确定' onclick='tui(true," + activeitem + ")'/>";
                                        inputs += "</div>";
                                        console.log(inputs);
                                        $("#liucheng").html(inputs);
 
 
                                        // callback();
                                    }
                                } else {
                                    $("#liucheng").html("<h3 class='sp_title'>无可退回项<h3>");
 
                                    return null;
                                }
                            });
 
                        }
                    });
                } else if (obt.buttonName == "审批") {
                    $("#" + dd.id).click(function () {
 
                        var processLog = JSON.parse(localStorage.getItem("processLog"));
                        if (processLog != null && processLog != undefined) {
                        } else {
                            customBase.alert('W',"请先创建一个流程");
                            return null;
                        }
                        if (processLog[0].processState == 60) {
                            customBase.alert('E',"流程已结束");
                            return null;
                        }
                        var inputs = "<h3 class='sp_title'>请输入审批语</h3><br/>" + "<textarea maxlength='200' onKeyUp='listenword()' class='stexta' type='test' id='datas'></textarea><span class='wordwrap'><var class='word'>0</var>/200</span><br/>"
                            + "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn'  type='button' value='取消' onclick='zhixing(false)'/><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='zhixing(true)'/></div>";
                        $("#liucheng").html(inputs);
                        $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
                        $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
                    });
 
                } else {
                    $("#" + dd.id).click(function () {
 
                        var fuc = obt.methodName + "()";
                        eval(fuc);
                        //console.log(fuc);
                        //调用自定义js中的方法
                        //console.log("调用自定义方法");
                        fuc;
 
                    });
                }
            });
 
            srcd.src = rs.data.resourceFilePath;
 
            // $("#customShow").append(srcd);
            if(rs.data.resourceFilePath != undefined && flag != 3 && rs.data.resourceFilePath != ''){//自定义JS加载修改  李伟民  0109
                document.getElementsByTagName("head")[0].appendChild(srcd); // 接口注册 初期化事件 李伟民 12-18
                srcd.onload = function () {
                    _.each(customBase.interfaceData, function (data) {
                        if (data.interfacemethod == "interfaceInit3rd") {
                            if (data.customInterfacemethod != undefined && data.customInterfacemethod != '') {
                                var funstr = data.customInterfacemethod + "()";
                                eval(funstr);
                            }
                        }
                    });
                    callback(rs);//自定义JS加载修改  李伟民  0109
                }
            }else{
                callback(rs);//自定义JS加载修改  李伟民  0109
            }
 
            //  $(".preview-edit-pane").append(dd);
            //  $("#"+dd.id).click(function(){
 
            //     var fuc=arr[1]+"()";
            //     eval(fuc);
            //     ////console.log(fuc);
 
            //     ////console.log("调用自定义方法");
            //     fuc;
 
            //  });
        }else{
            callback(rs);//自定义JS加载修改  李伟民  0109
        }
    });
    var dataObjDo = {};
    dataObjDo = dataObj;
    delete dataObjDo.type
    console.log(dataObj)
    var requestRight = window.commonAjax("/tabConfiguration/queryTabConfiguration", dataObjDo, "POST", true);
    requestRight.done(function (rs) {
        //2017/10/31 李元杰 附件 流程先洗 选项卡添加
        console.log(rs)
        $('.boxTwo').hide();
        $('.sTab').find('ul li').eq(1).hide();
        $('.boxThr').hide();
        $('.sTab').find('ul li').eq(2).hide();
        if (rs.data != '') {
            if (rs.data[0].appendix == "do") {
                console.log($('.sTab').find('ul li'))
                $('.sTab').find('ul li').eq(1).show();
            } else {
                $('.boxTwo').hide();
                $('.sTab').find('ul li').eq(1).hide();
            }
            if (rs.data[0].processInfo == "do") {
                $('.sTab').find('ul li').eq(2).show();
            } else {
                $('.boxThr').hide();
                $('.sTab').find('ul li').eq(2).hide();
            }
        }
    });
}
 
 
var xhSelect = xhSelect || {};
xhSelect.scope = {
    sel_val_lst: {
        // 'F073001':"常规出差"
    },
    rm_optionFlag: false
};
 
xhSelect.options = {
    selectId: "",
    multiple: false,
    listData: [],
    width: 200,
    setDiv: ""
}
xhSelect.setValue = function (itemId, listData) {
    xhSelect.setValue(itemId, listData, 0);
}
xhSelect.setValue = function (itemId, listData, N) {
    var selectItme = $("#" + itemId + " .selectItme");
    var listDataJson = {};
    if (_.isString(listData)) {// 下拉款填值  修改  李伟民 11-14
        listData = listData.split(",")
    }// 下拉款填值  修改  李伟民 11-14
    console.log(listData);
    for (var i = 0; i < listData.length; i++) {
        listDataJson[listData[i]] = "1";
    }
 
    var $options = $($("#" + itemId)[0]).find('select > option');
    var vals_selected = [];
    var j = 0;
    $options.each(function () {
        for (var jsonstr in listDataJson) {
            if ($(this).val() == jsonstr) {
                vals_selected[j] = {};
                vals_selected[j].value = $(this).val();
                vals_selected[j].label = $(this).text();
                j++;
            }
        }
    });
    var $el = $($("." + itemId + "value")[N]);
    var set_valueleft = function (vals_selected) {
        var $divContainer = "";
        var selectedItem = {};
        for (var i = 0; i < vals_selected.length; i++) {
            //张吉男修改 下拉框发布
            $divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
                'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
                vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
                '\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + '  <i  class="icon iconfont icon-guanbijiantou"  val="' +
                vals_selected[i].value + '" style="color:#20b4aa;"></i></li>' + ' </a>' + ' </div>';
 
            selectedItem[vals_selected[i].value] = "1";
        }
        $divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
        $el.find(".select-container").empty();
        $el.find(".select-container").append($divContainer);
        var selectedItemJson = JSON.stringify(selectedItem);
        if ($el.find(".selectItme").length != 0) {
            $el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
        }
 
    };
    set_valueleft(vals_selected);
}
xhSelect.getValue = function (itemId) {
    var returnItem = [];
    var selectItme = $("#" + itemId + " .selectItme");
    console.log(selectItme)
    for (var i = 0; i < selectItme.length; i++) {
        if (selectItme[i].getAttribute("value") == "") {
            var selectItmeJson = {};
        } else {
            ////console.log(selectItme[i].getAttribute("value"));
            var selectItmeJson = $.parseJSON(selectItme[i].getAttribute("value"));
        }
 
        var jn = 0;
        returnItem[i] = [];
        for (j in selectItmeJson) {
            returnItem[i][jn] = j;
            jn++;
        }
    }
    return returnItem;
}
// 下拉框主数据渲染
xhSelect.setXhSelect = function (options) {
    ////console.log(options);
    ////console.log(_.cloneDeep(xhSelect.options));
    //解决主数据重复
    var options_xh = _.cloneDeep(xhSelect.options);
    options_xh.listData = [];
    //解决主数据重复END
    options = $.extend(true, options_xh, options);
    var optionArr = "";
    console.log(options.selectId);
    ////console.log(options.listData);
    //        ////console.log(options.listData.length);
    for (var i = 0; i < options.listData.length; i++) {
        optionArr += '<option value="' + options.listData[i].value + '">' + options.listData[i].text + '</option>';
    }
    console.log(optionArr);
    var multiple = "";
    if (options.multiple) {
        multiple = 'multiple';
    }
 
    var $xhSelectDiv = '' +
        '<div class="selectClass">' +
        '<div ng-transclude="" style="display:none;">' +
        '<select class="select_get ng-scope" load-data="" ' + multiple + ' >' +
        optionArr +
        '</select>' +
        '</div>' +
        '<div class="selectItme" style="display:none;" value=""></div>' +
        '<div class="select3-element" style="width:100%;max-width: ' + options.width + 'px">' +
        '            <div  class="select-container select-container_box" gccolname="ex_c11">  ' +
        '                    <div class="suffix">' +
        '                            <i class="fa fa-angle-down" aria-hidden="true"></i>' +
        '                    </div>' +
        '            </div>' +
        '    </div> ' +
        '</div>';
    console.log(options);
    if (options.setDiv == '') {
        var $el = $("#" + options.selectId);
    } else {
        var $el = $("." + options.setDiv);
    }
    console.log(optionArr)
    console.log($xhSelectDiv)
    _.each($el, function (sel) {//添加记录 重复问题  李伟民11-14   主数据丢失  11-29 再次修改
        if ($(sel).find(".selectClass").length == 0) {
            $(sel).append($xhSelectDiv)
        } else {
            $(sel).find(".selectClass").find(".select_get").html(optionArr);
        }
    })//添加记录 重复问题  李伟民11-14   主数据丢失  11-29 再次修改
 
 
    //添加记录 重复问题  李伟民11-14
    //        $("#"+options.selectId).find()
 
    xhSelect.selectContainer(options);
    customLinkageAnalysis.bindLinkage();
    //行程排序初期化
    customShow.journeySort();
}
xhSelect.rm_option = function (val, vals_selected) {
    xhSelect.scope.rm_optionFlag = true;
    console.log(val);
    console.log(vals_selected)
    $('div.drop_down_sel').remove();
    var selectItmeJson = $($(val).parent().parent().parent().parent()).find(".selectItme")[0].getAttribute("value");
 
    var selectItme = $.parseJSON(selectItmeJson);
    delete selectItme[vals_selected];
    selectItmeJson = JSON.stringify(selectItme);
    $($(val).parent().parent().parent().parent()).find(".selectItme")[0].setAttribute('value', selectItmeJson);
 
    //张吉男修改 下拉框默认值不可以清空
    var cla=new RegExp("disableColor");
    //console.log(cla.test($(val).parent().parent().attr("class")));
    //判断下拉框是否是可编辑
    if(!(cla.test($(val).parent().parent().attr("class")))){
        $(val).parent().remove();
    }
    setTimeout(function () {
        xhSelect.scope.rm_optionFlag = false;
    }, 500);
}
xhSelect.selectContainer = function (options) {
    var itemId = options.selectId;
    if (options.setDiv == '') {
        var $el = $("#" + itemId);
    } else {
        var $el = $("." + options.setDiv);
    }
    $el.find('div.select-container').on('click', function (event) {
        var selectedItem = $el.find(".selectItme")[0].getAttribute("value");
        //  12/4 李元杰
        $('.zTreeDemoBackground').css("display", "none");
        $(".search_input").css("display", "none");
        console.log(selectedItem);
        console.log(event);
        console.log($(this))
        ////console.log("-------------------this-----------------------------------");
        if ($el[0].className.indexOf("readonly") > -1) {
            return;
        }
        if (selectedItem != "") {
            selectedItem = $.parseJSON(selectedItem);
        }
 
        if (xhSelect.scope.rm_optionFlag) {
            return;
        }
        console.log(2)
        $('div.drop_down_sel').remove();
        var $select = $el.find('select');
        var isMultiple = $select.attr('multiple');
        var $options = $el.find('select > option');
        ////console.log($el);
        ////console.log($options);
        var $options_str = '<ul>' + '<li class="sel_query">' + '<input type="text" name="query" >' + '</li>' + '</ul>';
 
        $options_str += '<div class="select "><ul class="line">';
 
        if ($select.attr('multiple')) {
            $options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check "' +
                ' value="All" label="全选" ><i class="label"></i>全选</span></li>';
        }
        $options.each(function () {
            var checked = '';
            if (selectedItem[$(this).val()] != undefined) {
                checked = 'cur';
            }
            $options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check ' + checked +
                '" value="' + $(this).val() + '" label="' + $(this).text() + '' + '" title="' + $(this).text() + '"><i class="label"></i>' + $(this).text() + '</span></li>'
        });
 
        $options_str += '</ul></div>';
        console.log($options_str)
        console.log(3)
        $("div.drop_down_sel").remove();
        var $select_obj = $('<div drop-down-selector="" filterlist="searchlist" class="drop_down_sel" style="position: absolute;">' + $options_str + '</div>');
        $el.find('div.select3-element').append($select_obj);
        $('body').off('click.sel').on('click.sel', function () {
            console.log(5);
            $('div.drop_down_sel').remove();
            $('.zTreeDemoBackground').css("display", "none");
            $(".search_input").css("display", "none");
        });
        $('div.drop_down_sel').off('click.sel').on('click.sel', function (event) {
 
            event.stopPropagation();
        });
        console.log(6)
        $select_obj.find('input[name="query"]').on('keyup',
            function () {
                var $el = $(this);
                var inputs = $select_obj.find('.custom-check');
                inputs.each(function () {
                    var val = $(this).attr('label');
                    var input_val = $el.val();
                    if (val.indexOf(input_val) > -1) {
                        $(this).closest('li').show();
                    } else {
                        $(this).closest('li').hide();
                    }
                });
            });
 
        $select_obj.find('.custom-check').on('click', function () {
            if (this.className.indexOf("readonly") > -1) {
                return;
            }
            $(this).toggleClass('cur');
            if ($(this)[0].getAttribute("value") == "All") {
                if (this.className.indexOf("cur") > -1) {
                    $($(this).parent().parent()).find(".custom-check").addClass("cur");
                } else {
                    $($(this).parent().parent()).find(".cur").removeClass('cur');
                }
            }
 
            var set_valueleft = function (vals_selected) {
                var $divContainer = "";
                var selectedItem = {};
                for (var i = 0; i < vals_selected.length; i++) {
                    $divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
                        'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
                        vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
                        '\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + '  <i  class="icon iconfont icon-guanbijiantou"  val="' +
                        vals_selected[i].value + '" style="color:#20b4aa;"></i>' + ' </a>' + ' </div>';
                    selectedItem[vals_selected[i].value] = "1";
                }
                $divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
                $el.find(".select-container").empty();
                $el.find(".select-container").append($divContainer);
                var selectedItemJson = JSON.stringify(selectedItem);
                $el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
                $el.find(".select_get").trigger("change.value");//下拉框 公式
            };
            var vals_selected = [];
            var vals_selected_item = [];
            var checkboxChecked = false;
            var checkboxValue = $(this)[0].getAttribute("value");
            var checkboxLabel = $(this)[0].getAttribute("label");
            if ($(this)[0].className.indexOf('cur') > -1) {
                checkboxChecked = true;
            }
            if (!isMultiple) {
                vals_selected = [{
                    'value': checkboxValue,
                    'label': checkboxLabel
                }];
                set_valueleft(vals_selected);
                console.log(7)
                $('div.drop_down_sel').remove();
            } else {
                var vls = [];
                var values = $($(this).parent().parent()).find('.cur');
                var j = 0;
                for (var i = 0; i < values.length; i++) {
                    if (values[i].getAttribute("value") != "All") {
                        vals_selected[j] = {};
                        vals_selected[j].value = values[i].getAttribute("value");
                        vals_selected[j].label = values[i].getAttribute("label");
                        j++;
                    }
                }
                set_valueleft(vals_selected);
            }
        });
        event.stopPropagation();
    });
}
 
//customBase.reCharge = function(){//重新记账  李伟民 2017-10-18 21:30
//    //console.log(customBase);
//    //console.log(customShow);
//    var rePostData = {};
//    rePostData['formID'] = customShow.options.formid;
//    rePostData['dataRowNum'] = customShow.options.dataRowNum;
//    var reCharge_request =  window.cloudAjax("epc-tenant/accounting/record",rePostData,"POST",true);
//    reCharge_request.done(function(res){
//        //console.log(res);
//    })
//}//重新记账  李伟民 2017-10-18 21:30 end
 
//customBase.checkItem = function(){//提交验证 李伟民2017-10-19 15:52
//    //console.log(customBase);
//    //console.log(customShow);
//     //画面项目取得 --------------------------画面项目取得------
//     var items = customShow.getItems();
//         ////console.log(items)
//     // 画面check
//     var returnfromCheck =  customShow.initEvent.fromCheck(items); //--------------------
//     if(returnfromCheck){
////      return;
//     }
//
//
//         var rules = customShow.options.jsonLinkage;
//        if(!_.isNull(rules) && rules != undefined){
//            rules = JSON.parse(rules);
//            //console.log(rules);
//            var checkId = [];
//            _.each(rules,function(ru){
//                _.each(ru.results,function(res){
//                    if(res.mode == "2" || res.mode == "0"){
//                        checkId.push(ru.event.eventFieldId);
//                        return false;
//                    }
//                })
//            });
//            checkId = _.uniq(checkId);
//            //console.log(checkId);
//            _.each(checkId,function(cid){
//                $("[id='" + cid + "']").trigger("change.check");
//            });
//        }
//}//提交验证 李伟民2017-10-19 15:52 end
 
// function checkSameDay(day1, day2) {//判断是否为同一天  李伟民 2017-10-20 17:00
//     var seconds;
//     seconds = day1 - day2;
//     //console.log(seconds);
//     if (seconds < 24 * 60 * 60 * 1000 && seconds >= 0) {
//         return true;
//     } else {
//         return false;
//     }
// }//判断是否为同一天  李伟民 2017-10-20 17:00 end
 
// customBase.checkTimeCross = function () {//跨行程验证时间 李伟民 2017-10-20 11:35
//     //console.log(customBase);
//     //console.log(customShow);
//     var items = customShow.getItems();
//     //console.log(items);
//     var itemKey = _.keys(customBase.options.customItems);
//     var subItem = [];
//     _.each(itemKey, function (keys) {
//         if (customBase.options.customItems[keys].type == "subform") {
//             subItem.push(customBase.options.customItems[keys].fieldKey);
//         }
//     });
//     var FromDateArr = [];
//     var LeaveDateArr = [];
//     //console.log(subItem);
//     _.each(subItem, function (sub) {
//         if (items[sub] != undefined) {
//             _.each(items[sub], function (isub, i) {
//                 if (isub.FromDate != undefined) {
//                     FromDateArr.push({ "value": new Date(isub.FromDate), "num": i, "property": customBase.options.customItems['FromDate'] });
//                 }
//                 if (isub.LeaveDate != undefined) {
//                     LeaveDateArr.push({ "value": new Date(isub.LeaveDate), "num": i, "property": customBase.options.customItems['LeaveDate'] });
//                 }
//             });
//         }
//     });
//     //console.log(FromDateArr);
//     //console.log(LeaveDateArr);
//     if (FromDateArr.length > 1 && LeaveDateArr.length > 1 && FromDateArr.length == LeaveDateArr.length) {
//         _.each(FromDateArr, function (fdate, k) {
//             if (k > 0) {
//                 //console.log(checkSameDay(fdate.value,LeaveDateArr[k-1].value));
//                 if (checkSameDay(fdate.value, LeaveDateArr[k - 1].value) == false) {
//                     var message = customShow.options.customItemShow.item[fdate.property.id].tag_Attribute.title + "与上一行程不连续";
//                     customLinkageAnalysis.setMessage(fdate.property.id, message, k);
//                 }
//             }
//         });
//     }
// }//跨行程验证时间 李伟民 2017-10-20 11:35 end
// customBase.checkLandCross = function () {//跨行程验地点 李伟民 2017-10-20 11:35
//     var items = customShow.getItems();
//     //console.log(items);
//     var itemKey = _.keys(customBase.options.customItems);
//     var subItem = [];
//     _.each(itemKey, function (keys) {
//         if (customBase.options.customItems[keys].type == "subform") {
//             subItem.push(customBase.options.customItems[keys].fieldKey);
//         }
//     });
//     var FromLandeArr = [];
//     var ToLandArr = [];
//     _.each(subItem, function (sub) {
//         if (items[sub] != undefined) {
//             _.each(items[sub], function (isub, i) {
//                 if (isub.From_site != undefined) {
//                     FromLandeArr.push({ "value": isub.From_site[0], "num": i, "property": customBase.options.customItems['From_site'] });
//                 }
//                 if (isub.To_site != undefined) {
//                     ToLandArr.push({ "value": isub.To_site[0], "num": i, "property": customBase.options.customItems['To_site'] });
//                 }
//             });
//         }
//     });
//     if (FromLandeArr.length > 1 && ToLandArr.length > 1 && FromLandeArr.length == ToLandArr.length) {
//         _.each(FromLandeArr, function (fland, k) {
//             if (k > 0) {
//                 customLinkageAnalysis.clearMessage(fland.property.id, k);
//                 //console.log(fland.value != ToLandArr[k-1].value);
//                 if (fland.value != ToLandArr[k - 1].value) {
//                     var message = customShow.options.customItemShow.item[fland.property.id].tag_Attribute.title + "与上一行程不连续";
//                     customLinkageAnalysis.setMessage(fland.property.id, message, k);
//                 }
//             }
//         });
//     }
// }//跨行程验地点 李伟民 2017-10-20 11:35 end
//自定义表单扩展函数 增加行 删除行
customShow.addRow = function (subId, data) {
    console.log(data);
    console.log(subId);
    console.log($("#" + subId));
    console.log($("#" + subId).find(".trContentClass"));
    $("#" + subId).find(".trContentClass").remove();
    // console.log(data[0].length - 1);
    for (var i = 0; i < data[0].length; i++) {
        var itemId = subId;
        var showClass = "customViewUEditorCss";
        var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
        //console.log(customShow.options)
        console.log(itemId, item)
        console.log(itemId, customBase.options.customItems)
        //子表单情况为U情况
        if (item == undefined) {// 子表单回显 修改  李伟民 11-10
            var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
            tbody = tbody[0].cloneNode(true);
            $(tbody).find(".select2").remove();
            console.log($(tbody).html());
            $(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
            $(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
            //        $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
            if ($(tbody).find(".table_title").length > 0) {
                //删除头行
                $(tbody).find(".table_title").remove();
            }
            if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr  李伟民 11-14
                $($(tbody).find(".trContentClass")[0]).siblings().remove();
            }// 去除重复的tr  李伟民 11-14
            //        $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
            tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
            console.log(tbody);
            console.log(itemId);
            console.log($(tbody).find("#" + itemId).attr("class"));
            $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改  李伟民 11-10
            customShow.hidesubform();
            customShow.setXhSelectList(false);//添加记录 重复问题  李伟民11-14
        } else {
            console.log(item);
            item = item[0].cloneNode(true);
            console.log(item);
            $(item).find(".select2").remove();
            $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
 
            $(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
            item = customShow.addsubformListInit(itemId, item);
            $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
 
        }
        customShow.setXhSelectList(true);//添加记录 重复问题  李伟民11-14
        customShow.addtree(itemId, item);
        //子表单事件追加
        customShow.clickBindSubform();
        //公式初期化
        customLinkageAnalysis.bindLinkage();
        customShow.oneTotle();
        $('.iconfontcolor').on('click', function () {
            $(this).parent().parent().parent().remove();
        });
        console.log($(item))
        customShow.addtree(itemId, item);
    }
    var customItems = customBase.options.customItems;
    console.log(customItems)
    var order = $($("#" + subId + "ActiveId .trContentClass")[0]).find(".tdContentClass");
    var orderid = [];
    var orderObj = {};
    _.each(order, opt => {
        if ($(opt).find("div").children().eq(0).attr("id")) {
            orderid.push($(opt).find("div").children().eq(0).attr("id"));
        } else {
            orderid.push($(opt).find("div").children().eq(1).attr("id"));
        }
    });
    console.log(orderid);
    orderid.splice(0, 1);
    console.log(orderid);
    var subArr = [];
    console.log(subId)
    _.each(customItems, opt => {
        if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
            subArr.push(opt);
        }
    });
    _.remove(subArr, n => {
        return n.fieldKey == "DATAROWNUM";
    })
    console.log(subArr);
    var endArr = [];
    _.each(orderid, opt => {
        var a = {};
        _.each(subArr, o => {
            if (opt == o.id) {
                a = o;
            }
        });
        endArr.push(a);
    })
    console.log(endArr);
    console.log(data);
    _.each(endArr, (opts, i) => {
        console.log(opts.id, opts.type, data[i]);
        if (opts.type == "dropdownlist") {// 不可修改  控件type  李伟民  11-17
            customBase.setItemValue(opts.id, "dropdownlistText", data[i], "", "");
        } else {
            customBase.setItemValue(opts.id, opts.type, data[i], "", "");
        }
    });
    console.log(subId)
    customShow.subTotle(subId)
};
//关联表单控件  列表渲染
createTable = function (rs, formId, formhuixian, head, $iconId, addVal) {
    var showVal = [];
    var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民  11-07
    //接收table内容请求
    var content = "";
    var counts = "";
    $(".requestMenu").empty();
    //渲染table头部变量;
    let headtr = "";
    //渲染table内容变量
    let contentdata = "";
    //表头渲染数据
    //console.log(head);
    _.remove(head, n => {
        return n.fieldKey == "DATAROWNUM";
    });
    _.each(head, opt => {
        headtr += '<td>' + opt.title + '</td>';
    });
    let head_tr = $("<tr class='headtr'></tr>");
    head_tr.append('<td class="td1">选择</td>' + headtr);
    $(".requestMenu").append(head_tr);
 
    //console.log(rs)
    if (rs.data != undefined && !_.isNull(rs.data) && rs.data.count != undefined) {
        counts = rs.data.count;
    }
    if (rs.data != undefined && !_.isNull(rs.data)) {
        content = rs.data.list;
    } else {
        content = [];
    }
    // if(iconAttr.tag_Attribute.relevancesourcetype == "fundata"){
    //     codeContent = rs.data.list;
    // }else{
    //     codeContent = rs.data.code;
    // }
    console.log(content);
    if (content.length == 0) {
        var div_empty = $("<div><i style='width:20px;height:20px;' class='fa fa-envelope-o' aria-hidden='true'></i><p>您还没有数据显示</p></div>");
        $(".requestMenu").append(div_empty);
    } else {
        _.each(content, (opt) => {
            _.each(formhuixian, n => {
                if (opt.DATAROWNUM == n.DATAROWNUM) {
                    opt.show = "cur";
                }
            });
            var contentdata = "";
            _.each(head, opts => {
                contentdata += '<td>' + opt[opts.fieldKey] + '</td>';
            });
            var tr = $("<tr class='bodytr'></tr>");
            tr.append('<td class="td1"><li class="checkLine"><span class="custom-check ' + opt.show + '"></span><i class="label"></i></li></td>' + contentdata);
            console.log(tr);
            $(".requestMenu").append(tr);
        });
    }
    //console.log(formhuixian);
 
 
    if (formhuixian != undefined) {
        addVal = formhuixian;
    }
    let show = "";
    var showObj = {};
    //选择方法
    head.push({ fieldKey: "DATAROWNUM", title: "DATAROWNUM" });
    //判断单选多选
    var selItem = customShow.options.customItemShow.item;
    console.log(selItem);
    var sel = "";
    var datarow = "";
    var tag_Id = "";
    console.log(selItem);
    for (let key in selItem) {
        if (key == $iconId) {
            sel = selItem[key].tag_Attribute.mytextSel;
            console.log(selItem[key].tag_Attribute.singleSetValue);
            if (selItem[key].tag_Attribute.singleSetValue != "itemId") {
                datarow = JSON.parse(selItem[key].tag_Attribute.singleSetValue).columnOrderNum;
                tag_Id = JSON.parse(selItem[key].tag_Attribute.singleSetValue).tag_Id;
            }
        }
    }
    console.log(sel)
    if (sel == "single") {
        $(".custom-check").on("click", function () {
            var addVals = [];
            var showVals = [];
            $(this).parent().parent().parent().siblings().find(".custom-check").removeClass('cur');
            $(this).toggleClass('cur');
            console.log($(this));
            console.log($(this).siblings());
            //            var showObj = {};
            let $index = $(this).parent().parent().parent().index() - 1;
            var check = $(".custom-check");
            console.log(check);
            _.each(check, opt => {
                console.log(opt)
                if ($(opt).hasClass('cur')) {
                    addVals.push(content[$(opt).parent().parent().parent().index() - 1]);
                    // showVals.push(content[$(opt).parent().parent().parent().index() - 1]);
                    // addVals.push(codeContent[$(opt).parent().parent().parent().index() - 1]);//填值时使用code  李伟民  12-05
                    // console.log(codeContent[$(opt).parent().parent().parent().index() - 1])
                } else {
                    _.remove(addVals, n => {
                        return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
                        // return n.DATAROWNUM == codeContent[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;//填值时使用code  李伟民  12-05
                    });
                    // _.remove(showVals, n => {
                    //     return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
                    // });
                }
            });
            addVal = addVals;
            // showVal = showVals;
            console.log(addVal);
            console.log(datarow);
            customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
        });
        console.log(addVal);
 
    } else if (sel == "multiple") {
        $(".custom-check").on("click", function () {
            $(this).toggleClass('cur');
            //                var showObj = {};
            let $index = $(this).parent().parent().parent().index() - 1;
            if ($(this).hasClass('cur')) {
                addVal.push(content[$index]);
                // showVal.push(content[$index]);
                // addVal.push(codeContent[$index]);//填值时使用code  李伟民  12-05
                //console.log(content[$index])
            } else {
                _.remove(addVal, n => {
                    return n.DATAROWNUM == content[$index].DATAROWNUM;
                    // return n.DATAROWNUM == codeContent[$index].DATAROWNUM;//填值时使用code  李伟民  12-05
                });
                // _.remove(showVal, n => {
                //     return n.DATAROWNUM == content[$index].DATAROWNUM;
                // });
            }
            customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
        });
    }
    console.log(addVal);
    //选择方法END
    return counts;
}
 
function createMxtTable($iconId, head, addVal) {// 关联数据渲染修改  李伟民 11-30
    console.log(head);
    console.log(addVal);
    if (head == "" || addVal == "" || head == undefined || addVal == undefined) {
        return false;
    }
    var tableBox = $("<table class='mxtdatatable table'></table>");
    var tableTitle = $("<tr></tr>");
    var tableBody = $("<tbody></tbody>");
    var tableHead = $("<thead></thead>");
    _.each(addVal, function (atd) {
        var tableContent = $("<tr></tr>");
        _.each(head, function (htd) {
            var td = '<td class="mxtdatatabletd">' + (atd[htd.fieldKey] ? atd[htd.fieldKey] : "") + '</td>';
            tableContent.append(td);
            var th = '<th>' + htd.title + '</th>';
            tableTitle.append(th);
        });
        tableBody.append(tableContent);
    });
    tableHead.append(tableTitle);
    tableBox.append(tableHead);
    tableBox.append(tableBody);
    $('#' + $iconId).append(tableBox);
}// 关联数据渲染修改  李伟民 11-30
 
function setValByAnother(iconAttr, addVal, formId, head, typeflag) {//遍历对比别名相同填值 typefalg为true代表关联的是函数
    var datarowNum = addVal[0].DATAROWNUM;
    var postdata = {};
    var getCodeUrl = "";
    var ajaxtype = "";
    if (typeflag) {
        getCodeUrl = "/datamanagement/getAssociateData";
        postdata = { "formID": customShow.options.formid, "search": [], "pageSize": "1000", "pageNum": "1", "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'], "dataRowNum": datarowNum, "type": "code" };
        ajaxtype = "POST";
    } else {
        postdata = {
            "datarowNum": datarowNum,
            "formID": formId.formID
        };
        getCodeUrl = "/datamanagement/getSingleFormDataService";
        ajaxtype = "GET";
    }
 
    console.log(postdata);
    var rquest = window.commonAjax(getCodeUrl, postdata, ajaxtype, true);
    rquest.done(function (res) {
        console.log(res);
        var rsdata = "";
        if (res.data && res.data.main != undefined) {
            if (typeflag) {
                rsdata = res.data.list[0];
            } else {
                rsdata = res.data.main;
            }
            console.log(iconAttr);
            console.log(rsdata);
            if (rsdata == undefined) {
                return false;
            }
            _.each(customBase.options.customItems, opt => {
                _.each(head, opts => {
                    if (opts.fieldKey == opt.fieldKey) {
                        if (opt.type == "dropdownlist") {
                            //                                if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
                            var item = customShow.options.customItemShow.item[opt.id];
                            var dropdowntype = item.tag_Attribute.dropdowntype;
                            customBase.setItemValue(opt.id, "dropdownlistText", res.data.main[opt.fieldKey], "", "");
                            //                            }
                        } else {
                            //                                if(!customBase.getItemValue(opt.id,opt.type)){
                            customBase.setItemValue(opt.id, opt.type, res.data.main[opt.fieldKey], "", "");
                            //                            }
                        }
                    };
                })
            });
        }
 
    });
 
}
 
customShow.sureonclick = function (addVal, $iconId, head, sel, iconAttr, datarow, formId) {
    console.log(datarow)
    $(".btn-primary").on("click", function () {
        var showObj = {};
        console.log(addVal);
        $('#' + $iconId).empty();
        //回显属性
        $("#" + $iconId).attr("formhuixian", JSON.stringify(addVal));
        var saveval = '';//关联数据空间 存值  李伟民  11-07
        var saveArr = [];
        _.each(addVal, function (v) {
            if (v.DATAROWNUM != undefined) {
                saveArr.push(v.DATAROWNUM);
            }
        });
        saveval = saveArr.join();
        customBase.setItemValue($iconId, customShow.options.customItemShow.item[$iconId].tag_Type, saveval);//关联数据空间 存值  李伟民  11-07 end
        if (addVal != "" && addVal != undefined) {
            $("#" + iconAttr.tag_Id).attr("checkVal", JSON.stringify(addVal));//将选中值存储起来  用于验证
            $("#" + iconAttr.tag_Id).attr("checkHead", JSON.stringify(head));
        }
        var data2 = customShow.columnToRow(head, addVal);
        //子表单自动增加行
        var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
        console.log(subId);
        if (subId == "itemId") {
            createMxtTable($iconId, head, addVal);
            console.log(addVal);
            console.log(head);
            setValByAnother(iconAttr, addVal, formId, head);
            //遍历对比别名相同填值
            // _.each(customBase.options.customItems, opt => {
            //     _.each(head, opts => {
            //         if (opts.fieldKey == opt.fieldKey) {
            //             if (opt.type == "dropdownlist") {
            //                 //                                if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
            //                 var item = customShow.options.customItemShow.item[opt.id];
            //                 var dropdowntype = item.tag_Attribute.dropdowntype;
            //                 customBase.setItemValue(opt.id, "dropdownlistText", addVal[0][opt.fieldKey], "", "");
            //                 //                            }
            //             } else {
            //                 //                                if(!customBase.getItemValue(opt.id,opt.type)){
            //                 customBase.setItemValue(opt.id, opt.type, addVal[0][opt.fieldKey], "", "");
            //                 //                            }
            //                            }
            //         };
            //     })
            // });
        } else {
            console.log(addVal)
            if (sel == "single" && iconAttr.tag_Attribute.relevancesourcetype != "fundata") {
                setValByAnother(iconAttr, addVal, formId, head)
                //                    _.each(addVal,(opt,j)=>{
                ////                        var ulBox = $("<ul></ul>");
                //                        var ulBox = $("<table></table>");
                //                        var sdata_head = "";
                //                        var sdata_boby = "";
                //                        for(var i = 0;i<head.length;i++){
                //                            show = "";
                //                            sdata_head += '<td class="data1 '+head[i].fieldKey+'">'+head[i].title+'</td>';
                //                            sdata_boby += '<td class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</td>';
                //                            show += '<li>'+'<span class="data1 '+head[i].fieldKey+'">'+head[i].title+'</span>'+'<span class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</span>'+'</li>';
                //
                //                            showObj[head[i].fieldKey] = opt[head[i].fieldKey];
                //
                //                            ulBox.attr("class","addUl ulBox"+j);
                //                            ulBox.attr("id","ulBox"+j);
                ////                            ulBox.append(show);
                //                        }
                //                        ulBox.append("<tr>"+sdata_head+"</tr><tr>"+sdata_boby+"</tr>");
                //                        console.log(sdata_head);
                //                        $('#'+$iconId).append(ulBox);
                //                    });
                createMxtTable($iconId, head, addVal);
                var subdata = {};
                console.log(datarow)
                subdata.formdataNum = datarow;
                subdata.datarowNum = addVal[0].DATAROWNUM;
                subdata.formID = formId.formID;
                var subformData = window.commonAjax("/datamanagement/getSubFormDataListService", subdata, "GET", true, false);
                subformData.done(function (rs) {
                    console.log(rs.data);
                    var c_data = SC.cur_zero(rs.data);
                    console.log(c_data)
                    var rsArr = [];
                    _.each(c_data, opt => {
                        var opts = _.omit(opt, ['DATAROWNUM']);
                        rsArr.push(opts)
                    });
                    var rslength = _.keys(rsArr[0]).length;
                    console.log(rsArr);
                    var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
                    console.log($(".myipt"))
                    var formObj = window.localStorage.getItem("netformid");
                    var globalFormID = formObj;
                    var dataObj = {};
                    dataObj.formID = globalFormID;
                    var order_id = [];
                    //   11/25 李元杰 存flag
                    console.log(dataObj)
                    var requestRight = window.commonAjax("/datamanagement/getFormFieldListService", dataObj, "GET", true, false);
                    requestRight.done(function (rs) {
                        console.log(rs)
                        order_id = rs.data;
                    })
 
                    // var tenantID =JSON.parse(window.localStorage.getItem('tenantID'))
                    // dataObj.tenantID= tenantID.tenantID;
 
                    //          var order_ids = JSON.parse($(".myipt").val());
                    console.log(order_id);
                    //         console.log(order_ids)
 
 
                    if (customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue) {
                        var message = JSON.parse(customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue);
                    }
                    console.log(message.columnOrderNum)
 
                    console.log(subId);
                    var subIds = subId.replace("itemId_", "")
                    console.log(subIds);
                    var orderArr = []; //存储关联表单内子表单的数组
                    _.each(order_id, opt => {
                        console.log(opt)
                        if (opt.parentsubFormNum == message.columnOrderNum) {
                            orderArr.push(opt);
                        }
                    });
                    _.remove(orderArr, n => {
                        return n.fieldKey == "DATAROWNUM";
                    })
                    console.log(orderArr);
                    orderArr = _.sortBy(orderArr, ['fieldOrderNum']);
                    var resArr = [];
                    for (i = 0; i < rslength; i++) {
                        resArr.push([])
                    }
                    console.log(rsArr);
                    console.log(orderArr)
                    _.each(rsArr, (opt, i) => {
                        var j = 0
                        _.each(orderArr, n => {
                            resArr[j][i] = opt[n.fieldKey]
                            j++;
                        })
                    });
                    console.log(resArr);
                    if (resArr.length == 0){
                        alert("上级预算为0");
                    } else {
                        customShow.addRow(subId, resArr);
                    }
                    $(".subformAdd").hide();
                    $(".subformAddiconShow").hide();
 
                });
            } else if (sel == "multiple" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
                console.log("fundata");
                if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//关联函数时 别名相同填值
                    setValByAnother(iconAttr, addVal, "", head, true);
                }
                createMxtTable($iconId, head, addVal);
                $("#" + subId + "subformTr").nextAll().remove();
                customShow.addRow(subId, data2);
                $(".subformAdd").hide();
                $(".subformAddiconShow").hide();
            }
        }
        console.log(customShow.customJs(subId))
        SC.setSubForm(customShow.customJs(subId), subId);
        if (addVal.length != 0) {
            SC.Superior_show()
        }
    });
}
 
customShow.customJs = function (subId) {
    var subArr = [];
    console.log(subId)
    var customItems = customBase.options.customItems;
    console.log(customItems)
    _.each(customItems, opt => {
        if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
            subArr.push(opt);
        }
    });
    _.remove(subArr, n => {
        return n.fieldKey == "DATAROWNUM";
    })
    console.log(subArr);
    var aliasArr = [];
    _.each(subArr, opt => {
        aliasArr.push(opt.fieldKey)
    })
    console.log(aliasArr);
    return aliasArr;
}
 
//表单引用 扩展 回显子表单功能
fenye = function (pageSize, pageNum, formId, sCondition, formhuixian, head, $iconId, addVal, anydata) {
    console.log($iconId);
    console.log("findmany");
    console.log(anydata);
    console.log(head);
    var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民  11-07
    console.log(iconAttr);
    var dataUrl = "";
    var dataObj;
    if (anydata) {
        //   alert('if');
    } else {
        //   alert("else");
    }
    if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
        dataUrl = "/datamanagement/getAssociateData";
        dataObj = { "formID": customShow.options.formid, "tenantID": "001", "search": [], "pageSize": pageSize, "pageNum": pageNum, "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
        _.extend(dataObj, { "formData": customShow.getItems() });
    } else {
        dataUrl = "/datamanagement/getAssociatedFormDataService";
        dataObj = { "formID": formId.formID, "tenantID": "001", "screenCondition": sCondition, "pageSize": pageSize, "pageNum": pageNum, "search": anydata };
        window.localStorage.setItem("netformid", dataObj.formID);
    }
    //关联数据 函数 数据源 李伟民  11-07
    //    var dataObj = {"formID":formId.formID,"tenantID":"001","screenCondition":sCondition,"pageSize":pageSize,"pageNum":pageNum};
    //window.localStorage.setItem("netformid",dataObj.formID);
    var requestRight = window.commonAjax(dataUrl, dataObj, "POST", true, false);
    var counts = "";
    requestRight.done(function (rs) {
        if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
            // var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
            // var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
            // requestTitle.done(function (res) {
            //     var formtitle = [];
            //     _.each(res.data, function (tdata) {
            //         formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
            //     });
            counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);
            // });
 
        } else {
            counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);//关联表单 列表回显
        }
 
    });
    $('.closeBtn').on('click', () => {
        $('#' + $iconId + 'menuContent').remove();
        console.log($('.maskLayer'))
        $('.maskLayer').css('display', 'none');
    })
    return counts;
}
customShow.journeySort = function () {//行程排序 初始化 李伟民 2017-10-23 15:56
    //console.log(customShow);
    var itemKey = _.keys(customShow.options.customItemShow.item);
    _.each(itemKey, function (keys) {
        if (customShow.options.customItemShow.item[keys].tag_Type == "subform" && customShow.options.customItemShow.item[keys].tag_Attribute.sorttype != undefined && customShow.options.customItemShow.item[keys].tag_Attribute.sorttype != "") {
            customShow.bindSort(customShow.options.customItemShow.item[keys].tag_Attribute.sorttype, keys);
        }
    });
    //    customShow.bindSort("itemId_6","itemId_3");
}//行程排序 初始化 李伟民 2017-10-23 15:56 end
 
customShow.bindSort = function (sorttype, sub) {//排序事件绑定
    if (customShow.options.customItemShow.item[sorttype] == undefined) {
        return false;
    }
    var tagType = customShow.options.customItemShow.item[sorttype].tag_Type;
    if (tagType == "text" || tagType == "number" || tagType == "calendar") { //单行文本  数字 时间
        $("[id=" + sorttype + "]").unbind("change.sort", customShow.sortEvent);
        $("[id=" + sorttype + "]").on("change.sort", { msg: { "sorttype": sorttype, "type": tagType, "sub": sub } }, customShow.sortEvent);
    } else if (tagType == "dropdownlist") { // 下拉框
 
    }
 
}
 
customShow.sortEvent = function (event) {//
    var sorttype = event.data.msg.sorttype;
    var type = event.data.msg.type;
    var sub = event.data.msg.sub;
    var subType = customShow.options.customItemShow.item[sub].tag_Attribute.allcopy;
    console.log(event);
    var allValue;
    var allItem = [];
    allValue = customBase.getItemValue(sorttype, type);
    if(_.isString(allValue)){
        allValue = [allValue];
    }
    //console.log(allValue);
    _.each(allValue, function (v, i) {
        var optValue;
        if(type == "calendar"){
            optValue = new Date(v);
        }else if(type == "number"){
            optValue = Number(v)
        }else{
            optValue = v;
        }
        if(subType){
            allItem.push({ "value": optValue, "index": i, "temp": $("[id='" + sub + "ActiveId']:eq(" + i + ")").clone(true) });
        }else{
            allItem.push({ "value": optValue, "index": i, "temp": $("[id='" + sub + "subformTr']:eq(" + i + ")").clone(true) });
        }
 
    });
    //console.log(allItem);
    var sortValue = _.sortBy(allItem, function (o) {
        return o.value;
    });
    console.log(sortValue);
    if(subType){
        _.each($("[id='" + sub + "ActiveId']"), function (subform, k) {
            $(subform).replaceWith(sortValue[k].temp);
        })
    }else{
        _.each($("[id='" + sub + "subformTr']"), function (subform, k) {
            $(subform).replaceWith(sortValue[k].temp);
        })
    }
 
    // customShow.controlInit("customShow");
    customLinkageAnalysis.bindLinkage();
    customShow.journeySort();
}
//马习同 2017/10/25
$(".sTab ul li").on('click', function () {
    $(this).css('border-bottom', '2px solid #23b7e5');
    $(this).css('box-sizing', 'border-box');
    $(this).siblings().css('border', 'none');
    //console.log($($(".tabBox>div")[$(this).index()]));
    $($(".tabBox>div")[$(this).index()]).show();
    $($(".tabBox>div")[$(this).index()]).siblings().hide();
    if($(this).index() == 0){//切换选项卡导致 保存按钮消失修改  李伟民 0201
        $(".tabBox .sure_box").show();
    }
});
$(".tag_two").on("click", function () {
    //    $(".boxTwo iframe").attr("src","http://122.114.176.216:8087/#/IframeExample?token=C3CDE94FE9CBDDDD37312D3331AC091EC737F5555007677E45A390EFEC7147996A49AA4E117EDC02F0D15984E725CA3B5B93DDAF0C989C35642B58B29360D998DDDAC06EB509BE1C22B19D555A1BB75A07A36FD6C4A7E87C9C9EA0070A213BFB44FF8D3B2AD5A33086EAF1F22E978B24951EA806054F94042533CA73EA7901C5E8B13D4DB7DC87308266E769258DEDFF&openId=3dc22baf5d484170&tenantId=13&companyId=17& appId=1&processInstId=1483")
})
//马习同  11/7  行转化列
customShow.columnToRow = function (head, addVal) {
    var data = []
    _.remove(head, n => {
        return n.fieldKey == "DATAROWNUM";
    })
    _.each(head, opt => {
        let data1 = [];
        _.each(addVal, opts => {
            data1.push(opts[opt.fieldKey]);
        });
        console.log(data1)
        data.push(data1)
    });
    return data;
}
 
function submitErrShow(item,num){//审查必须错误提示 李伟民 0119
    console.log(item,num);
    var itemId = item.tag_Id;
    if(num == undefined){
        num = 0;
    }
    var mesageErrDiv = document.createElement("div");
    mesageErrDiv.setAttribute("class", "mesageErrDiv");
    $(mesageErrDiv).addClass('submitrErr');
    var mesageErrStr = item.tag_Attribute.title + '不能为空(审查必须)';
    mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
    $(mesageErrDiv).append(mesageErrStr);
    if(customShow.options.customInit.designMode != 1){//快捷模式 李伟民 0126
        if ($(".customShow  #" + itemId + "ActiveId").length == 0) {
            console.log($(".customViewUEditorCss [id='" + itemId + "']:eq(" + num + ")").closest("td"));
            $(".customShow [id='" + itemId + "']:eq(" + num + ")").closest("td").append(mesageErrDiv);
            $(".customShow ." + itemId + "_showItem:eq(" + num + ")").append(mesageErrDiv);
        } else {
            $($($(".customShow  #" + itemId + "ActiveId")[num])[0]).append(mesageErrDiv);
        }
    }else{//普通模式 李伟民 0126
        if ($(".customShow  #" + itemId).length == 0) {
            $($(".customShow  ." + itemId + "_showItem")[num]).css({
                'height':"20px",
                'display':'inline-block'
            })
            $($(".customShow  ." + itemId + "_showItem")[num]).popover({
                // title:"错误信息",
                html: true,
                content: mesageErrStr,
                trigger: 'hover'
            });
            $($(".customShow  ." + itemId + "_showItem")[num]).popover('show');
        } else {
            $($(".customShow  #" + itemId)[num]).popover({
                // title:"错误信息",
                html: true,
                content: mesageErrStr,
                trigger: 'hover'
            });
            $($(".customShow  #" + itemId)[num]).popover('show');
        }
    }
}
 
function submitCheck(){//提交前验证审查必须 李伟民 0119
    $('.submitrErr').remove();
    var checkFlag = true;
    var item = localStorage.getItem('customItem');
    if(item != undefined && item != ''){
        item = JSON.parse(item);
    }
    console.log(customBase);
    console.log(customShow);
    console.log(item);
    var allItemKey = _.keys(customBase.options.customItems);
    var allItemId = _.keys(customShow.options.customItemShow.item);
    var allItem = _.cloneDeep(customShow.options.customItemShow.item);
    var allItemValue = [];
    var childItem = [];
    var parentNums = [];
    var parentItem = {};
    _.each(allItemId,function(id){
        if(allItem[id].parentsubFormNum == 0){
            allItemValue.push(allItem[id]);
        }else{
            childItem.push(allItem[id]);
            parentNums.push(allItem[id].parentsubFormNum);
        }
    });
    _.each(parentNums,function(num){
        _.each(allItemId,function(id){
            if(num == allItem[id].columnOrderNum){
                parentItem[num] = allItem[id];
            }
        });
    });
    _.each(childItem,function(cd){
        _.extend(cd,{'parentId':parentItem[cd.parentsubFormNum].tag_Attribute.alias});
    });
    allItemValue = _.concat(allItemValue,childItem);
    console.log(allItemValue);
    console.log(item);
    _.each(allItemValue,function(item_value){
        if(item_value.parentsubFormNum == 0){
            var value = item[item_value.tag_Attribute.alias]
            // _.extend(item_value,{'value':item[item_value.tag_Attribute.alias]});
            if(item_value.tag_Attribute.approvalmustenter){//审查必须属性
                if(_.isArray(value)){
                    if(value.length == 0){
                        submitErrShow(item_value);
                        checkFlag = false;
                    }
                }else if(value == '' || value == undefined){
                    submitErrShow(item_value);
                    checkFlag = false;
                }
            }
        }else{
            var cd_value = [];
            _.each(item[item_value.parentId],function(sub){
                cd_value.push(sub[item_value.tag_Attribute.alias]);
            });
            // _.extend(item_value,{'value':cd_value});
            _.each(cd_value,function(cval,k){
                if(_.isArray(cval)){
                    if(cval.length == 0){
                        submitErrShow(item_value,k);
                        checkFlag = false;
                    }
                }else if(cval == '' || cval == undefined){
                    submitErrShow(item_value,k);
                    checkFlag = false;
                }
            })
        }
    });
    return checkFlag;
}
 
//lym
function get() {
        var checkFlag =  submitCheck();
        if(checkFlag != true){
            return false;
        }
        console.log(localStorage.getItem("organizationId"));
        console.log(localStorage.getItem("datarowNum"));
        //从local取出log
        var processLog = localStorage.getItem("processLog");
        var tenant = JSON.parse(localStorage.getItem("tenantID"));
        var cust = JSON.parse(localStorage.getItem("customItem"));
        //暂时修改流程lym
        // var org = cust.expend_department.trim();
        //暂时修改流程lym
        console.log(processLog);
        console.log(processLog !== null);
        //12/11
        if (processLog != "null") {
            var strMessage = customBase.getMessage("mesage_ID034");
            customBase.alert("E", strMessage);
            //return null;
        } else {
            //暂时修改流程lym
            // if (org == "" || org == undefined || org == null) {
            //     //var strMessage = customBase.getMessage("mesage_ID035");
            //     customBase.alert("E", "请选择部门");
            //     return null;
            // }
            //暂时修改流程lym
            // 画面check 提交前验证 李伟民 12-26
            // var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
            // if (returnfromCheck) {
            // return;
            // }
            var ss = {
                "tenantID": tenant.tenantID,
                //"organizationId": org,
                "formID": localStorage.getItem("newFormID"),
                "dataRowNum": localStorage.getItem("datarowNum")
            }
            var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/create", ss, "POST", true);
            requestSingleForm.done(function (rs) {
                console.log(rs);
                if (rs.resCode == 00000) {
 
                        customBase.alert('S', "提交成功");
                        $("#sssd").click();
 
                } else {
                    if (rs.data == '3') {
                        customBase.alert('E', "请先配置流程定义");
                        $("#sssd").click();
                    }else if(rs.data == '2'){
                        customBase.alert('E', "请不要重复提交");
                        $("#sssd").click();
                    } else {
                    customBase.alert('E', "提交失败");
                    $("#sssd").click();
                    }
                }
            });
        }
 
    }
//lym结束后操作
function over(data) {
    if (data == true) {
        //确定提交后操作
        var processLog = JSON.parse(localStorage.getItem("processLog"));
        console.log(processLog);
        var ss = {
            "processInstId": processLog[0].processInstId
        }
        console.log(ss);
        var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/over", ss, "POST", true);
        requestSingleForm.done(function (rs) {
            console.log(rs);
            if (rs.data == 1) {
                customBase.alert('S',"结束成功");
                $("#sssd").click();
            } else {
                customBase.alert("E","结束失败");
            }
        });
 
 
 
    } else {
        $("#sssd").click();
    }
}
 
//lym退回确定后操作
function tui(data, item) {
 
    if (data == true) {
        console.log($('.actcur').val());
        if ($('.actcur').val() == undefined) {
            customBase.alert("W","请选择退回的活动");
            return null;
        }
        var processLog = JSON.parse(localStorage.getItem("processLog"));
        var ss = {
            "activityInstId": processLog[0].activityInstId,
            "activityDefId": $('.actcur').val(),
            "processInstId": processLog[0].processInstId,
            "formID": localStorage.getItem("newFormID"),
            "dataRowNum": localStorage.getItem("datarowNum")
        }
        var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/bac", ss, "POST", true);
        requestSingleForm.done(function (rs) {
            console.log(rs);
 
            if (rs.data == 1) {
                customBase.alert("S","退回成功");
                $("#sssd").click();
            } else {
                customBase.alert("E","退回失败");
            }
        });
 
 
    } else {
        $("#sssd").click();
    }
}
//lym 审批确定后方法
function zhixing(data) {
    console.log(data);
    console.log($("#datas").val());
    if (data == false) {
        $("#sssd").click();
    } else {
 
        var processLog = JSON.parse(localStorage.getItem("processLog"));
        console.log(processLog[0].processInstId);
        var ss = {
            "processInstId": processLog[0].processInstId,
            "activityInstId": processLog[0].activityInstId,
            "data": $("#datas").val(),
            "formID": localStorage.getItem("newFormID"),
            "dataRowNum": localStorage.getItem("datarowNum"),
            "token": localStorage.getItem("testToken"),//差旅token 特殊处理
            "tenantId": localStorage.getItem("testTenantId"),
            "companyId": localStorage.getItem("testCompanyId"),
 
        }
        console.log("标记token");
        var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/finish", ss, "POST", true);
        requestSingleForm.done(function (rs) {
            console.log(rs);
            if (rs.resCode == "00000") {
                customBase.alert('S',"审批成功");
                $('#editableBtn').remove();//审批成功后不能编辑 李伟民 0129
                $("#sssd").click();
            } else {
                customBase.alert('W',"审批失败");
            }
        });
    }
}
//2017.11.24  qld 追加预算
customBase.budgetAddmoney = function () {
    var id = JSON.parse(localStorage.getItem("tenantID"))
    console.log(id.tenantID);
    var sub = JSON.parse(localStorage.getItem("customItem"));
    var submit_data = {
        "formId": localStorage.getItem("newFormID"),
        "netformid": localStorage.getItem("netformid"),
        "parentDataRowNum": localStorage.getItem("datarowNum"),
        "dataRowNum": localStorage.getItem("datarowNum"),
        "tenantID": id.tenantID,
        "formType": "ZJ"
    };
 
    var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
    submit_request.done(function (res) {
        if (res.resCode == 'C0000') {
            if (res.data == '1') {
                var strMessage = customBase.getMessage("mesage_ID024");
                customBase.alert("E", strMessage);
            } else if (res.data == '2') {
                var strMessage = customBase.getMessage("mesage_ID025");
                customBase.alert("E", strMessage);
            } else if (res.data == '3') {
                var strMessage = customBase.getMessage("mesage_ID026");
                customBase.alert("E", strMessage);
            } else if (res.data == '9') {
                var strMessage = customBase.getMessage("mesage_ID027");
                customBase.alert("S", strMessage);
            } else if (res.data == '7') {
                var strMessage = customBase.getMessage("mesage_ID028");
                customBase.alert("E", strMessage);
            }
 
        }
 
    })
 
}
 
customBase.budgetBackmoney = function () {
    var id = JSON.parse(localStorage.getItem("tenantID"))
    console.log(id.tenantID);
    var sub = JSON.parse(localStorage.getItem("customItem"));
    var submit_data = {
        "formId": localStorage.getItem("newFormID"),
        "netformid": localStorage.getItem("netformid"),
        "parentDataRowNum": localStorage.getItem("datarowNum"),
        "dataRowNum": localStorage.getItem("datarowNum"),
        "formType": "TH",
        "tenantID": id.tenantID
    };
 
    var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
    submit_request.done(function (res) {
        if (res.resCode == 'C0000') {
            if (res.data == '1') {
                var strMessage = customBase.getMessage("mesage_ID024");
                customBase.alert("E", strMessage);
            } else if (res.data == '2') {
                var strMessage = customBase.getMessage("mesage_ID025");
                customBase.alert("E", strMessage);
            } else if (res.data == '3') {
                var strMessage = customBase.getMessage("mesage_ID026");
                customBase.alert("E", strMessage);
            } else if (res.data == '9') {
                var strMessage = customBase.getMessage("mesage_ID027");
                customBase.alert("S", strMessage);
            } else if (res.data == '7') {
                var strMessage = customBase.getMessage("mesage_ID028");
                customBase.alert("E", strMessage);
            }
        }
 
    })
 
}
function repayment() {
    var customBase = window.customBase;
    customBase.repayment();
    return true;
}
customBase.repayment = function () {
    var id = JSON.parse(localStorage.getItem("tenantID"))
    console.log(id.tenantID);
    var sub = JSON.parse(localStorage.getItem("customItem"));
    console.log(sub);
    var subForm = sub.DATAROWNUM;
    console.log("我是" + subForm)
    var submit_data = {
        "formId": localStorage.getItem("newFormID"),
        "netformid": localStorage.getItem("netformid"),
        "parentDataRowNum": localStorage.getItem("datarowNum"),
        "datarowNum": localStorage.getItem("datarowNum"),
        "tenantId": id.tenantID
    };
 
    var submit_request = window.commonAjax1("epc-form/repayment/money", submit_data, "POST", true);
    submit_request.done(function (res) {
        if (res.data == true) {
            //    12/7 qld
            var strMessage = customBase.getMessage("mesage_ID029");
            customBase.alert("S", strMessage);
        } else {
            var strMessage = customBase.getMessage("mesage_ID030");
            customBase.alert("E", strMessage);
        }
 
    })
 
}
//子表单合计方法   马习同   2017-12-06
customShow.subTotle = function (subId) {
    var customItems = customBase.options.customItems;
    var numArr = [];
    var subArr = [];
    var numObj = {};
    _.each(customItems, opt => {
        if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
            subArr.push(opt);
        }
    });
    _.remove(subArr, n => {
        return n.fieldKey == "DATAROWNUM";
    });
    _.each(subArr, opt => {
        if (opt.type == "number") {
            console.log(opt.id);
            numObj[opt.id] = customBase.getItemValue(opt.id, opt.type);
            numArr.push(Number(customBase.getItemValue(opt.id, opt.type)));
        }
    })
    console.log(numObj);
    for (let key in numObj) {
        var opts = [];
        if (_.isArray(numObj[key])) {
            _.each(numObj[key], n => {
                n = Number(n);
                console.log(n);
                opts.push(n);
            })
            numObj[key] = opts;
        }
        console.log(numObj[key]);
    }
    console.log(numObj);
    //_.sum   求和
    for (let key in numObj) {
        $("." + key + "totle").val(_.sum(numObj[key]));
    }
 
}
//子表单合计方法   马习同   2017-12-07
customShow.oneTotle = function () {
    var customItems = customShow.options.customItemShow.item;
    var totleArr = [];
    var numObj = {};
    var numArr = [];
    _.each(customItems, opt => {
        console.log(opt.tag_Attribute.total)
        if (opt.tag_Attribute.total == true) {
            totleArr.push(opt.tag_Id);
            console.log(opt.tag_Id)
        }
    })
    console.log(totleArr);
    _.each(totleArr, opt => {
        $("#" + opt + " [type='number']").unbind("change.totle");
        $("#" + opt + " [type='number']").on("change.totle", function () {
            console.log($(this).attr("id"));
            numObj[$(this).attr("id")] = customBase.getItemValue($(this).attr("id"), $(this).attr("type"));
            console.log(_.cloneDeep(numObj));
            console.log(numObj[key])
 
            for (let key in numObj) {
                var opts = [];
                if (_.isArray(numObj[key])) {
                    _.each(numObj[key], n => {
                        n = Number(n);
                        console.log(n);
                        opts.push(n);
                    })
                    numObj[key] = opts;
                }
                console.log(numObj[key]);
            }
 
            console.log(numObj);
            //_.sum   求和
            for (let key in numObj) {
                $("." + key + "totle").val(_.sum(numObj[key]));
            }
        })
    })
}
//子表单内的控件内容超出部分显示title
customShow.addTitle = function () {
    _.each($(".customShow .tdContentClass"), opt => {
        // $(opt).attr("title", $(opt).children().children().html());
        console.log($(opt).html())
        if ($(opt).children().children().attr("type") == "text") {
            $(opt).attr("title", $(opt).children().children().val());
        } else {
            console.log(_.cloneDeep($(opt).children().children()))
            console.log(opt.innerHTML)
            console.log($(opt).children().children()[0].innerHTML)
            $(opt).attr("title", $(opt).children().children()[0].innerHTML);
        }
    })
}
// customShow.businessTypeAutoFun = function(key,fieldKey,cookieOrlocal){
//     if(cookieOrlocal  == 'cookie'){
//         if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
//             var businessTypeAuto = getCookie(key);
//             customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
//         }
//     }else{
//         if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
//             var businessTypeAuto = window.localStorage.getItem(key);
//             customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
//         }
//     }
// }
// SC.billInfoInit = function(items){//票据信息初始化 李伟民 12-26
//     var itemKey = _.keys(items);
//     var customItems = customBase.options.customItems;
//     customShow.allbillInfo = [];
//     _.each(itemKey,function(key){
//         console.log(key);
//         if(customItems[key] != undefined && customItems[key] != '' && customItems[key].type == "subform"){
//             var billInfos = [];
//             _.each(items[key], function(journey, i){
//                 if(journey.billData != undefined){
//                     billInfos.push(JSON.parse(journey.billData));
//                     $("#" + key + "ActiveId").attr('noBillCheck',JSON.parse(journey.billData));
//                 }else{
//                     billInfos.push({});
//                 }
//             });
//             customShow.allbillInfo.push({
//                 'subFormId':customItems[key].id,
//                 'subFormKey':key,
//                 'billInfos':billInfos
//             })
//         }
//     });
//     billInfobind(customShow.allbillInfo);
//     SC.noBillCheckInit();
// }
// SC.noBillCheckInit = function(){
//     noBillCheck('journey','reimburseMan');
// }
// function noBillCheck(subFieldKey,reimburseManKey){//无票据行程及票据人员与报销人验证
//     if(customBase.options.customItems[subFieldKey] == undefined){
//         return false;
//     }
//     var subId = customBase.options.customItems[subFieldKey].id;
//     var manId = customBase.options.customItems[reimburseManKey].id;
//     var manType = customBase.options.customItems[reimburseManKey].type;
//     var manTitle = customBase.options.customItems[reimburseManKey].title;
//     var journeySub = $("#" + subId + "ActiveId");
//     _.each(journeySub,function(jour){
//         var checkData = $(jour).attr('noBillCheck');
//         if(checkData != undefined && checkData != ''){
//             checkData = JSON.parse(checkData);
//             var manVal = customBase.getItemValue(manId,manType);
//             if(manVal != undefined && manVal != checkData.PersonalVal){
//                 $(jour).children('h8').append("<span class='billCheck'>" + "票据‘" + checkData.PersonalName + "’与" + manTitle + "不同</span>");
//             }
//         }else{
//             $(jour).children('h8').append("<span class='billCheck'>无票据行程</span>");
//         }
//     });
// }
// function billInfobind(allbillInfo){//票据信息显示 及 实时验证  李伟民 12-26
//     _.each(allbillInfo,function(info,k){
//         var sub_type = customShow.options.customItemShow.item[info.subFormId].tag_Attribute.allcopy;
 
//         _.each(info.billInfos,function(binfo, i){
//             if(binfo.billCode != undefined){
//                 var itemKey = _.keys(binfo.billHeadMeaningMvCodeMap);
//                 _.each(itemKey,function(key){
//                     if(binfo.billHeadMap[key] != undefined && binfo.billHeadMap[key] != ''){
//                         var bhName = binfo.billHeadMap[key].val;
//                         var bhVal = binfo.billHeadMap[key].code;
//                         billShow(sub_type,itemKey,bhName,bhVal,i);
//                         if(sub_type && key == 'PersonalName'){//储存票据人员信息
//                             var noBillCheckData = {
//                                 "PersonalName":bhName,
//                                 "PersonalVal":bhVal
//                             };
//                             $("#" + info.subFormId + "ActiveId:ep(" + k + ")").attr("noBillCheck",JSON.stringify(noBillCheckData));
//                         }
//                     }
//                 });
//             }
//         });
//     })
// }
// function billShow(sub_type,itemKey,bhName,bhVal,num){//票据信息验证绑定 李伟民 12-26
//     var itemId = customBase.options.customItems[itemKey].id;
//     var type = customBase.options.customItems[itemKey].type;
//     if(sub_type){
//         $("[id='"+itemId+"ActiveId']:eq('" + num + "')").find("h8[name='el_title']").append("<span class='billCheck'>" + bhName + "</span>");
//     }else{
//         customBase.set_p($("[id='"+itemId+"']:eq('" + num + "')"));
//         if(type == 'dropdownlist'){
//             $("[id='"+itemId+"']:eq('" + num + "')").closet("p").append("<span class='billCheck'>" + bhName + "</span>");
//         }else{
//             $("[id='"+itemId+"']:eq('" + num + "')").prev("p").append("<span class='billCheck'>" + bhName + "</span>");
//         }
 
//     }
//     if(type == 'dropdownlist'){
//         $("[id='"+itemId+"']:eq('" + num + "')").find(".select_get").on('change.billcheck',function(){
//             if(sub_type){
//                 $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
//                 if($(this).val() != bhVal) {
//                     $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
//                 }
//             }else{
//                 $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "#333");
//                 if($(this).val() != bhVal) {
//                     $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "red");
//                 }
//             }
//         });
//     }else{
//         $("[id='"+itemId+"']:eq('" + num + "')").on('change.billcheck',function(){
//             if(sub_type){
//                 $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
//                 if($(this).val() != bhVal) {
//                     $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
//                 }
//             }else{
//                 $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "#333");
//                 if($(this).val() != bhVal) {
//                     $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "red");
//                 }
//             }
//         })
//     }
// }