14、angular1组件之pass-word密码、single-select|both-select消长、on-off开关、simple-dialog多层弹窗(含插槽ng-transclude)、3种search-select搜索下拉、input-select树结构 、dir-tree树结构(3150行)

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
一、pass-word组件(自定义密码输入框,可预览)
使用场景:修改密码时,对密码进行多方位验证,并显示验证结果。
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>passWord</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
</head>
<body>
  <div ng-controller="thisCtrl">
    <pass-word
      label-width="150"
      is-must-fill="true"
      label-text="原密码"
      this-type="password"
      placeholder="原密码"
      is-disabled="false"
      self-show='pastShow'
      is-past-input='true'
      self-data="oldPassword"
      verify="verify"
    ></pass-word>
    <pass-word
      label-width="150"
      is-must-fill="true"
      label-text="输入新密码"
      this-type="password" 
      placeholder="输入新密码"
      is-disabled="false"
      is-first-input='true'
      key-of-reg-exp="simplePassword"
      self-data="params.newPassword"
      sibling-data="newPasswordSecond"
      one-tip="oneTip"
      many-tips="manyTips"
      self-show='selfShow'
      sibling-show='siblingShow'
    ></pass-word>
    <pass-word
      label-width="150"
      is-must-fill="true"
      label-text="再次输入新密码"
      this-type="password" 
      placeholder="再次输入新密码"
      is-disabled="false"
      key-of-reg-exp="simplePassword"
      self-data="newPasswordSecond"
      sibling-data="params.newPassword"
      one-tip="oneTip"
      many-tips="manyTips"
      self-show='siblingShow'
      sibling-show='selfShow'
    ></pass-word>  
  </div>
</body>
</html>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope) {
    $scope.params = {};//发给后台
    $scope.pastShow = {
      isShowOneTip:false,
      isGreenOneTip:false,
      isShowManyTips:false,
    };
    $scope.selfShow = {
      isShowOneTip:false,
      isGreenOneTip:false,
      isShowManyTips:false,
    };
    $scope.siblingShow = {
      isShowOneTip:false,
      isGreenOneTip:false,
      isShowManyTips:false,
    };
    $scope.oneTip = {//由当前页传至本组件
      success: '自定义_输入符合要求!',
      empty: '自定义_该项不能为空!',
      different: '自定义_两次密码输入不一致!',
      formatError: '自定义_输入不符合要求,请输入以字母开头的4-24个字符!'
    };
    $scope.manyTips= [
      '密码要求:',
      '1.必须包含:数字',
      '2.必须包含:字母',
      '3.必须包含:小写字母',
      '4.必须包含:大写字母',
      '5.必须包含:下划线',
    ];
    $scope.oldPassword= '';
    $scope.params.newPassword='';
    $scope.newPasswordSecond= '';
    $scope.verify = function() {
      //把原密码告诉后台,根据后台判断结果,决定是否继续验证
      return true
    }
  });
  app.directive('passWord', function () {
    var html = `
      <div style="display:flex;align-items:center">
        <div ng-style="{width:(labelWidth||130)+'px'}" style="text-align:right;margin-right:10px;">
          <span ng-show="isMustFill" style="color:red;">*</span>
          <label ng-bind="labelText||'密码'"></label>
        </div>
        <div style="padding:10px 0; position:relative;">
          <input
            type="{{ thisType ? thisType : 'text' }}"
            ng-model="selfData" placeholder="{{placeholder||''}}"
            ng-disabled="isDisabled" ng-focus="focus()"
            ng-change="changeOrBlur()"
            ng-blur="changeOrBlur()"
            ng-trim="false"
            style="width:290px;height:30px"
          >
          <img
            src="{{servicePicture.eyeClose}}"
            ng-click="isShowEyeOpen=true;thisType='text'"
            ng-show="!isShowEyeOpen"
            style="width:14px;height:14px;position:absolute;right:10px;top:20px;cursor:pointer;padding:5px;"
          >  
          <img
            src="{{servicePicture.eyeOpen}}"
            ng-click="isShowEyeOpen=false;thisType='password'"
            ng-show="isShowEyeOpen"
            style="width:14px;height:14px;position:absolute;right:10px;top:20px;cursor:pointer;padding:5px;"
          >
        </div>
        <div style="position:relative">
          <div ng-show="selfShow.isShowOneTip">
            <img
              src="{{selfShow.isGreenOneTip ? servicePicture.correct : servicePicture.error}}"
              style="width:14px;height:14px;position:relative;left:5px;">
            <span
              ng-bind="singleTipText"
              ng-style="selfShow.isGreenOneTip?{ \'color\':\'green\'}:{\'color\':\'red\'}"
              style="position:relative;left:5px;">
            ></span>
          </div> 
          <div ng-show="selfShow.isShowManyTips && manyTips.length>0" style="position:absolute;top:0;display:flex">
            <img
              src="{{servicePicture.triangle}}"
              style="width:14px;height:14px;position:relative;z-index:3;left:5px;"
            >
            <div style="width:200px;border:1px solid #DCDCDC;position:relative;top:-5px;left:3px;padding:5px;">
              <div ng-repeat="li in manyTips" ng-bind="li"></div>
            </div>
          </div>
        </div>
      </div>
      `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        //以下是16种配置项。这是输入框组件,适用于密码输入、普通输入(isPastInput/isFirstInput:true)、旁边提示和弹窗提示。
        labelWidth: '@labelWidth',//标签宽度
        labelText: '@labelText',//标签文字
        placeholder: '@placeholder',//输入框内提示文字
        thisType: '@thisType',//输入框类型(文字或密码)
        keyOfRegExp: '@keyOfRegExp',//会用到的正则
        isMustFill: '=isMustFill',//该项是否必填
        isDisabled: '=isDisabled',//该项是否禁用
        isPastInput: '=isPastInput',//该项是不是原密码xxxxxxxxxxx
        isFirstInput: '=isFirstInput',//该项是不是第一次输入新密码xxxxxxxxxxxx
        selfData: '=selfData',//自身数据============
        siblingData: '=siblingData',//兄弟数据===============
        oneTip: '=oneTip',//单条提示
        manyTips: '=manyTips',//多条提示
        selfShow: '=selfShow',//自身的提示是否显示出来============
        siblingShow: '=siblingShow',//兄弟的提示是否显示出来=============
        verify: '=verify',//verify是函数,但按照变量传进来更好xxxxxxxxxxx
      },
      replace: true,
      controller: function ($scope, serviceRegExp, servicePicture) {
        $scope.servicePicture = servicePicture;
        $scope.inputChange = function (params, message) {
          var params = params;
          var config = {
            init: [false, false, false],
            focus: [false, false, true],
            empty: [true, false, false],
            formatError: [true, false, false],
            different: [true, false, false],
            wrong: [true, false, false],
            success: [true, true, false],
          };
          $scope.selfShow.isShowOneTip = config[params][0];
          $scope.selfShow.isGreenOneTip = config[params][1];
          $scope.selfShow.isShowManyTips = config[params][2];
          $scope.singleTipText = ($scope.oneTip && $scope.oneTip[params]) || message;
        };
        $scope.focus = function () {
          if($scope.isPastInput){
            $scope.inputChange('init');
            return
          }
          if($scope.isFirstInput){
            $scope.siblingData='';
            $scope.siblingShow = {
              isShowOneTip:false,
              isGreenOneTip:false,
              isShowManyTips:false,
            };
          }
          $scope.inputChange('focus');
        };
        $scope.changeOrBlur = function () {
          if ($scope.isMustFill && $scope.selfData=="") {//判断该项是否可以为空
            $scope.inputChange('empty', '该项不能为空!');
            return
          }
          if ($scope.keyOfRegExp && !(serviceRegExp[$scope.keyOfRegExp].test($scope.selfData))) {
            $scope.inputChange('formatError', '格式错误!');
            return
          }
          if (!$scope.isPastInput && !$scope.isFirstInput && $scope.selfData != $scope.siblingData) {
            $scope.inputChange('different', '两次密码输入不一致!');
            return
          }
          if(angular.isFunction($scope.verify) && !$scope.verify()){//验证原密码是否正确
            $scope.inputChange('wrong', '原密码输入错误!');
            return
          };
          $scope.inputChange('success', '输入符合要求!');
        };
      },
      link: function (scope, ele, attrs) {
        
      }
    };
  });
  app.factory('serviceRegExp', function () {
    return {
      simplePassword: /^[a-zA-Z][a-zA-Z0-9]{4,24}$/,//简单密码验证,以大小写字母开头,由大小写字母和数字构成的,共5-25位的密码
      complexPassword: /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*?_|~=+\-<>[{}/\'\":;,.\]*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&*?_|~=+\-<>[{}/\'\":;,.\]*]+$)(?![\d!@#$%^&*?_|~=+\-<>[{}/\'\":;,.\]*]+$)[a-zA-Z\d!@#$%^&*?_|~=+\-<>[{}/\'\":;,.\]*]{6,25}$/,//复杂密码验证,同时包含字母、数字、特殊符号如!@#$%^&*?_|~=+\-<>[{}/\'\":;,.\]
      ipFrom0To255: /^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$/,//ip地址验证,从0.0.0.0~255.255.255.255
      portFrom0To65535:/^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/,
      mac:/^[A-Fa-f\d]{2}:[A-Fa-f\d]{2}:[A-Fa-f\d]{2}:[A-Fa-f\d]{2}:[A-Fa-f\d]{2}:[A-Fa-f\d]{2}$/,
      mobilePhone: /^1[3456789]\d{9}$/,//手机号码验证,中国大陆
      numberNotLimit: /^(0|[1-9][0-9]*)$/,//0或非0开头的数字
      numberWithLimit: /^(0|[1-9][0-9]{3,4})$/,//0或非0开头的数字4-5位
      emailNotLimit: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,//邮箱验证
      emailWithLimit: /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/,//邮箱验证
      chineseCharacters: /^[\u4e00-\u9fa5]{0,}$/,//汉字验证
      blankSpace: /^\s*$/ //零到多个空格
    };
  });
  app.factory('servicePicture', function () {
    return {
      eyeClose: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAABatJREFUeAHtmX9InVUYx71Xu6bmzWorlGr90IQgiNS21qSIYX/0h+0fKYQRq/xtaAOjtZo4GMwMJSF/tNavrVEUbQtyGZXSqsHuhaA2GrElW6HmaFmk+LvPMzyX68v7nvu+i6vOzguHc87zPOd5nu/3fc655+UmJJjHMGAYMAwYBgwDhgHDgGHAMGAYMAwYBgwDhoH/GwM+AVxZ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MymYzm9/ule872SQ/Vj/tvuM5Iv2maWjab3RfGGCdDqH9jNBrtYu7yEkb1MzOWq9IsIObsHEBU/7oMctSPhVBtOubsGFbuB2AuDUj1q8I4zgTsySyM6p8VrCrUBOyyHEz181q2caZdsw39Lcuy4gj7KgntdltrNpvS5ck2sJIPEfFTRnU6Ha1er2uYDulWsg0I9he0dhWLU5YR/X7fgnqdAkdglUolB2Gz/A0J5lajsLn1VJoD5GBsvXVk9BmlnpXB3Ho83vfbx4xxAemo1WqHBoPBO0A3eW83bj1myq24V5sDcjBgfmzHbfS3ZDChPAu5Jf/XXBq0B2GBhrlc7jb657aPPReo0Who3W5Xul32QiBHADbN5/P30T+WEcja0in1uqgtLHl2IA6QewC/AMyVwKJtqgTkAzCnN1Hya5iu858vqmTy3ztfGUgoZHUF3zPvYcZ4bzd51HkCEoCT/TQ+377AzNhA9s5hLJ2qNso/jvK5q47KmKU+lmwA5HO41+vxHXTK9rH3XLIMbrVaa5DPDqCXbL9LBrZTtcdr4jfktIlrRzVGaRwy5Ef7K+h19Y92+4mAWv9W/AHAizQaNQfgsAAAAABJRU5ErkJggg=='
    };
  });
</script>
 
二、single-select和both-select
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>onlySelect</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
</head>
<body>
  <div ng-controller="thisCtrl">
    <div>一、此消彼长式</div>
    <div>使用场景:</div>
    <div>有上下两行数据,上行有很多备选项</div>
    <div>每点击上行的某项,则该项“会”消失并在下行出现</div>
    <div>每点击下行的某项,则该项“会”消失并在上行出现</div>
    <div style="margin-bottom:20px;">
      <span ng-click="getDataUp()" style="border-radius:5px;padding:2px;background:gray;">点击获取选中数据</span>
      <span ng-bind="selectedDatasUp"></span>
    </div>
    <div style="width:1000px;">
      <single-select form-datas-up="formDatasUp" current-datas-up="currentDatasUp" two-label-up="twoLabelUp"></single-select>
    </div>
    <div style="width:1000px;border:1px solid gray;margin:100px 0"></div>
    <div>二、此静彼长式</div>
    <div>使用场景:</div>
    <div>有上下两行数据,上行有很多备选项</div>
    <div>每点击上行的某项,则该项“不”消失并在下行出现,重复点击无效</div>
    <div>每点击下行的某项,则该项“会”消失,但对上行无影响</div>
    <div style="margin-bottom:20px;">
      <span ng-click="getDataDown()" style="border-radius:5px;padding:2px;background:gray;">点击获取选中数据</span>
      <span ng-bind="selectedDatasDown"></span>
    </div>
    <div style="width:1000px;">
      <both-select form-datas-down="formDatasDown" current-datas-down="currentDatasDown" two-label-down="twoLabelDown"></both-select>
    </div>
  </div>
</body>
</html>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope) {
    $scope.formDatasUp = [
      {
        value: '0',
        label: '选项一'
      },
      {
        value: '1',
        label: '选项二'
      },
      {
        value: '2',
        label: '选项三'
      },
      {
        value: '3',
        label: '选项四'
      },
      {
        value: '4',
        label: '选项五'
      }
    ];
    $scope.currentDatasUp = [];
    $scope.twoLabelUp = ['上面标签:','下面标签:'];
    $scope.getDataUp = function(){
      $scope.selectedDatasUp=angular.copy($scope.currentDatasUp);
    };
    ////////////////////////////////////////////////////////////////////////////////////////
    $scope.formDatasDown = [
      {
        value: '0',
        label: '选项一'
      },
      {
        value: '1',
        label: '选项二'
      },
      {
        value: '2',
        label: '选项三'
      },
      {
        value: '3',
        label: '选项四'
      },
      {
        value: '4',
        label: '选项五'
      }
    ];
    $scope.currentDatasDown = [];
    $scope.twoLabelDown = ['备选项:','被选项:'];
    $scope.getDataDown = function(){
      $scope.selectedDatasDown=angular.copy($scope.currentDatasDown);
    };
  });
  app.directive('singleSelect', function () {
    var html = `
        <div>
           
          <div style="width:100%;height:30px;line-height:30px;border:1px solid green;padding:5px;">
            <span ng-bind="twoLabelUp[0]"></span>
            <span ng-repeat="upData in upDatas track by $index" ng-bind="upData.label" ng-click="clickUpUp(upData.value)" style="border-radius:5px;display:inline-block;margin-right:10px;padding:2px;background:gray"></span>
          </div>
          <div style="width:100%;height:30px;line-height:30px;border:1px solid red;padding:5px;">
            <span ng-bind="twoLabelUp[1]"></span>
            <span ng-repeat="downData in downDatas track by $index" ng-bind="downData.label" ng-click="clickUPDown(downData.value)" style="border-radius:5px;display:inline-block;margin-right:10px;padding:2px;background:gray"></span>
          </div>
        </div>
      `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        formDatasUp: '=formDatasUp',
        currentDatasUp: '=currentDatasUp',
        twoLabelUp: '=twoLabelUp',
      },
      replace: true,
      controller: function ($scope) {
        $scope.upDatas = angular.copy($scope.formDatasUp);
        $scope.downDatas = [];
        
        $scope.clickUpUp = function (valueOuter) {
          angular.forEach($scope.upDatas,function(value,index){
            if(valueOuter===value.value){
              $scope.upDatas.splice(index,1);
              $scope.downDatas.push(value);
              $scope.currentDatasUp.push(value.value);
              console.log($scope.currentDatasUp)
            }
          })
        };
        $scope.clickUPDown = function (valueOuter) {
          angular.forEach($scope.downDatas,function(value,index){
            if(valueOuter===value.value){
              $scope.upDatas.push(value);
              $scope.downDatas.splice(index,1);
              var thisIndex=$scope.currentDatasUp.indexOf(value.value)
              if(thisIndex>-1){
                $scope.currentDatasUp.splice(thisIndex,1);
              }
              console.log($scope.currentDatasUp)
            }
          })
        };
      },
      link: function (scope, ele, attrs) {
 
      }
    };
  });
  app.directive('bothSelect', function () {
    var html = `
        <div>
           
          <div style="width:100%;height:30px;line-height:30px;border:1px solid green;padding:5px;">
            <span ng-bind="twoLabelDown[0]"></span>
            <span ng-repeat="upData in upDatasDown track by $index" ng-bind="upData.label" ng-click="clickDownUp(upData)" style="border-radius:5px;display:inline-block;margin-right:10px;padding:2px;background:gray"></span>
          </div>
          <div style="width:100%;height:30px;line-height:30px;border:1px solid red;padding:5px;">
            <span ng-bind="twoLabelDown[1]"></span>
            <span ng-repeat="downData in downDatasDown track by $index" ng-bind="downData.label" ng-click="clickDownDown(downData,$index)" style="border-radius:5px;display:inline-block;margin-right:10px;padding:2px;background:gray"></span>
          </div>
        </div>
      `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        formDatasDown: '=formDatasDown',
        currentDatasDown: '=currentDatasDown',
        twoLabelDown: '=twoLabelDown',
      },
      replace: true,
      controller: function ($scope) {
        $scope.upDatasDown = angular.copy($scope.formDatasDown);
        $scope.downDatasDown = [];
        $scope.clickDownUp = function (data) {
          var thisIndex=$scope.currentDatasDown.indexOf(data.value)
          if(thisIndex>-1){
            return
          }else{
            $scope.downDatasDown.push(data);
            $scope.currentDatasDown.push(data.value);
          }
        };
        $scope.clickDownDown = function (data,index) {
          $scope.downDatasDown.splice(index,1);
          var thisIndex=$scope.currentDatasDown.indexOf(data.value)
          if(thisIndex>-1){
            $scope.currentDatasDown.splice(thisIndex,1);
          }
        };
      },
      link: function (scope, ele, attrs) {
 
      }
    };
  })
</script>
 
三、on-off组件(真实逻辑,点击后,转圈、向后台发送请求、返回数据、给开关赋值、开关展示状态。点击后,立即改成相反状态,是不对的。)
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title></title>
  <script type="text/javascript" src="https:cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  <style>
    table{
      border-collapse: collapse;
      width:1000px;
    }
    table td,table th {
      padding: 5px;
      border: 1px solid #cbcbcb;
    }
    table thead {
      background-color: #e0e0e0;
      color: #000;
      text-align: left;
    }
  </style>
</head>
<body>
  <div ng-controller="thisCtrl">
    <on-off this-switch="parentSwitch">
      <span>{{parentSwitch.state?"总开关已开启":"总开关已关闭"}}。总开关关闭时,不能操作分开关!</span>
    </on-off>
    <table>
      <thead>
        <tr>
          <th>序号</th>
          <th>数据1</th>
          <th>数据2</th>
          <th>数据3</th>
          <th>开关1</th>
          <th>开关2</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="item in tableDatas track by $index">
          <td ng-bind="$index+1"></td>
          <td ng-bind="item.value1"></td>
          <td ng-bind="item.value2"></td>
          <td ng-bind="item.value3"></td>
          <td>
            <on-off parent-switch="parentSwitch" this-switch="item.value4"></on-off>
          </td>
          <td>
            <on-off parent-switch="parentSwitch" this-switch="item.value5"></on-off>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</body>
</html>
<script>
var app = angular.module('myModel', []);
app.controller('thisCtrl', function ($scope) {
  //以下通过向后台请求,获取总开关的数据fromServerParent,经加工后为$scope.parentSwitch
  var fromServerParent={
    isOn:true
  };
  $scope.parentSwitch={
    state:fromServerParent.isOn,
    callback:function(){
      this.state=!this.state;
    }
  };
  //以下通过向后台请求,获取分开关的数据fromServerData,经加工后为$scope.tableDatas
  var fromServerData=[
    {value1:"数据1",value2:"数据2",value3:"数据3",isOn:true,isSwitch:true},
    {value1:"数据1",value2:"数据2",value3:"数据3",isOn:true,isSwitch:true},
    {value1:"数据1",value2:"数据2",value3:"数据3",isOn:true,isSwitch:true},
    {value1:"数据1",value2:"数据2",value3:"数据3",isOn:true,isSwitch:true},
    {value1:"数据1",value2:"数据2",value3:"数据3",isOn:true,isSwitch:true},
    {value1:"数据1",value2:"数据2",value3:"数据3",isOn:true,isSwitch:true},
    {value1:"数据1",value2:"数据2",value3:"数据3",isOn:true,isSwitch:true}
  ];
  var tableDatas=[];
  angular.forEach(fromServerData,function(value,key){
    var item={};
    item.value1=value.value1;
    item.value2=value.value2;
    item.value3=value.value3;
    item.value4={
      state:value.isOn,
      callback:function(){
       this.state=!this.state;
      }
    };
    item.value5={
      state:value.isSwitch,
      callback:function(){
       this.state=!this.state;
      }
    };
    tableDatas.push(item)
  })
  $scope.tableDatas=tableDatas;
});
app.directive('onOff', function () {//(含插槽)
  var html = `
  <div style="display:flex;align-content:center;padding-bottom:10px;">
    <img ng-src="{{thisSwitch.state?onOff.yes:onOff.no}}" width="65px" height="30px" ng-click="clickSwitch()"/>
    <span ng-transclude style="height:30px;line-height:30px;padding-left:10px;"></span>
  </div>
  `;
  return {
    restrict: 'E',
    template: html,
    scope: {
      thisSwitch: '=thisSwitch',
      parentSwitch: '=parentSwitch',
    },
    transclude:true,
    replace: false,
    controller: function ($scope,onOff) {
      $scope.onOff = onOff;
      $scope.clickSwitch = function(){
        //以下总开关关闭时,不能操作分开关!
        if($scope.parentSwitch && !$scope.parentSwitch.state){
          return '弹窗:父级开关阻止本级开关改变'
        }
        if($scope.thisSwitch.isForbid ){
          return '弹窗:本级数据的其它条件阻止本级开关改变'
        }
        $scope.thisSwitch.callback()
      };
    },
    link: function (scope, ele, attr) {
       
    }
  };
});
app.factory('onOff', function () {
  return {
    yes: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQQAAAB4CAYAAAAUn4wEAAAAAXNSR0IArs4c6QAADIVJREFUeAHtnQ1sFMcVx9/4fDYG22Bjm8OhUBIKqi2jNgpqoiothKZJSEqbKmqrUKSoaSJBqKI2ClKDkiIqqhYEEgkQFSlKRRspkaImipRApAIpSFEiUHHrmMiGYEj58Adg/MXZ9+HtPMNdb+/O9p09d7Oe+Y9AtzM7OzPv93b+nt2d2RWUYajf3Fx0+Up4hUPOaiJRJ4hqyaFaGS/NsAhkAwEQyDEBQaKfBF1yiC4ROadk/L25Vf4jzZvrQ5lULfv12KH6+eZA5EboJSFojeNQ+di5sRcEQMBrBGTf7ZV9943C6UVburbXt4/VvlEFYdGvThdfcwY2yYN/4zjOjLEKwT4QAAHvExBCDMhW7qwUM7aeeeVrQ+lanFYQeFQQDYbfkUJwd7qDkAYCIDB1CUhh+MRX4n803WghRRBqnm1aGolG35diMG/qmoyWgwAIjEVAisIFhwpWde9e2pSYzyUIt0YGxyEGiYiwDQJmEmBRkCOFZYkjhYKYqXzP4NZlAkYGMSj4BQGDCfAffu7z3PdjZsYFgW8g4p5BDAt+QcAOAtznbz08GDF45JLh1qXCGbkTTxPsOA9gJQjECfDTB3npsIgvHUZGCDzPAGIQ54MNELCKAPd91gA2WtycgRjqwqQjq84BGAsCLgI8eWluVVF1wch0ZMxAdMFBBARsI8ADAtaCwptrE2wzH/bqJuD3Cbp3cSk91DCTlgSKKTDTT4FZfiot9ulumtb6+4ei1H49TO09YWppH6I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Hpz28SIAFlCGDS0SG8WnRrFVhLMaYgmIGlMEyRorBDdiUOysirpX8pPtKvwAzDbxIggWgJyGcT5gywYLFTPpt3pQgck34tUgi+jCdn/wMDfqOyNlld2AAAAABJRU5ErkJggg==',
  };
})
</script>
  
四、simple-dialog
1、不可拖拽(含插槽)
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>三层不可拖拽弹窗之angular1.6.2版</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  <style>
    .simpleDialog {
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .simpleDialog .mask {
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      background: black;
      opacity: 0.5;
    }
    .simpleDialog .content {
      position: fixed;
      background: white;
      opacity: 1;
      display: flex;
      flex-direction: column;
    }
    .simpleDialog .content .title {
      display: flex;
      background: blue;
      color: white;
      padding: 10px;
      cursor: pointer;
      user-select: none;
    }
    .simpleDialog .content .conform {
      display: flex;
      justify-content: center;
      padding: 10px;
      background: blue;
    }
  </style>
</head>
<body>
  <div ng-controller="thisCtrl">
    <button ng-click="clickButton()" style="margin-top: 30px; z-index: 250">
      点击-出现-弹窗
    </button>
    <simple-dialog required-data="requiredDataOut">
      1111111
      <simple-dialog required-data="requiredDataMid">
        2222222
        <simple-dialog required-data="requiredDataIn">
          33333333
        </simple-dialog>
      </simple-dialog>
    </simple-dialog>
  </div>
</body>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope) {
    $scope.clickButton = function () {
      $scope.requiredDataOut.isShow = true;
    };
    $scope.requiredDataOut = {
      isShow : false,
      width : '900px',
      height : '600px',
      openFn : function () {
        $scope.requiredDataMid.isShow = true;
      }
    };
    $scope.requiredDataMid = {
      isShow : false,
      width : '600px',
      height : '400px',
      openFn : function () {
        $scope.requiredDataIn.isShow = true;
      },
    };
    $scope.requiredDataIn = {
      isShow : false,
      width : '300px',
      height : '200px',
    };
    // 一层弹窗可以如下使用
    // $scope.requiredDataOut = {
    //   isShow : false,
    // };
    // $scope.clickButton = function () {
    //   $scope.requiredDataOut.isShow = true;
    // };
  });
  app.directive('simpleDialog', function () {
    var html = `
      <div class="simpleDialog" ng-show="requiredData.isShow">
        <div class="mask" ng-show="requiredData.isShow"></div>
        <div class="content" ng-show="requiredData.isShow">
          <div class="title">
            <span>系统消息</span>
          </div>
          <div ng-transclude ng-style="{width:requiredData.width||'800px',height:requiredData.height||'400px'}"></div>
          <div class="conform">
            <button ng-click="close()">关闭</button>
            <button ng-click="open()">打开</button>
          </div>
        <div>
      </div>
    `;
    return {
      restrict: 'E',
      template: html,
      transclude: true,
      scope: {
        requiredData: '='
      },
      controller: function ($scope) {
        $scope.close = function () {
          $scope.requiredData.isShow = false;
          if($scope.requiredData.closeFn)$scope.requiredData.closeFn();
        };
        $scope.open = function () {
          if($scope.requiredData.openFn)$scope.requiredData.openFn();
        };
      }
    };
  });
  </script>
</html>
2、可拖拽(含插槽)
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>三层可拖拽弹窗之angular1.6.2版</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  <style>
    .simpleDialog {
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .simpleDialog .mask {
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      background: black;
      opacity: 0.5;
    }
    .simpleDialog .content {
      position: fixed;
      background: white;
      opacity: 1;
      display: flex;
      flex-direction: column;
    }
    .simpleDialog .content .title {
      display: flex;
      background: blue;
      color: white;
      padding: 10px;
      cursor: pointer;
      user-select: none;
    }
    .simpleDialog .content .conform {
      display: flex;
      justify-content: center;
      padding: 10px;
      background: blue;
    }
  </style>
</head>
<body>
  <div ng-controller="thisCtrl">
    <button ng-click="clickButton()" style="margin-top: 30px; z-index: 250">
      点击-出现-弹窗
    </button>
    <simple-dialog required-data="requiredDataOut">
      1111111
      <simple-dialog required-data="requiredDataMid">
        2222222
        <simple-dialog required-data="requiredDataIn">
        </simple-dialog>
      </simple-dialog>
    </simple-dialog>
  </div>
</body>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope, drag) {
    $scope.clickButton = function () {
      $scope.requiredDataOut.isShow = true;
      drag($scope.requiredDataOut.titleId,$scope.requiredDataOut.contentId);
    };
    $scope.requiredDataOut = {
      isShow : false,
      width : '900px',
      height : '600px',
      titleId : "titleId1",
      contentId : "contentId1",
      openFn : function () {
        $scope.requiredDataMid.isShow = true;
        drag($scope.requiredDataMid.titleId,$scope.requiredDataMid.contentId);
      }
    };
    $scope.requiredDataMid = {
      isShow : false,
      width : '600px',
      height : '400px',
      titleId : "titleId2",
      contentId : "contentId2",
      openFn : function () {
        $scope.requiredDataIn.isShow = true;
        drag($scope.requiredDataIn.titleId,$scope.requiredDataIn.contentId);
      },
    };
    $scope.requiredDataIn = {
      isShow : false,
      width : '300px',
      height : '200px',
      titleId : "titleId3",
      contentId : "contentId3",
    };
    // 一层弹窗可以如下使用
    // $scope.requiredDataOut = {
    //   isShow : false,
    // };
    // $scope.clickButton = function () {
    //   $scope.requiredDataOut.isShow = true,
    //   drag();
    // };
  });
  app.directive('simpleDialog', function () {
    var html = `
      <div class="simpleDialog" ng-show="requiredData.isShow">
        <div class="mask" ng-show="requiredData.isShow"></div>
        <div class="content" ng-show="requiredData.isShow" id="{{requiredData.contentId||'contentId'}}">
          <div class="title" id="{{requiredData.titleId||'titleId'}}">
            <span>系统消息</span>
          </div>
          <div ng-transclude ng-style="{width:requiredData.width||'800px',height:requiredData.height||'400px'}">后备内容</div>
          <div class="conform">
            <button ng-click="close()">关闭</button>
            <button ng-click="open()">打开</button>
          </div>
        <div>
      </div>
    `;
    return {
      restrict: 'E',
      template: html,
      transclude: true,
      scope: {
        requiredData: '='
      },
      controller: function ($scope) {
        $scope.close = function () {
          $scope.requiredData.isShow = false;
          angular
            .element(
              document.getElementById($scope.requiredData.contentId||'contentId')
            )
            .css({
              top: '50%',
              left: '50%',
              transform: 'translate(-50%, -50%)'
            });
          if($scope.requiredData.closeFn)$scope.requiredData.closeFn();
        };
        $scope.open = function () {
          if($scope.requiredData.openFn)$scope.requiredData.openFn();
        };
      }
    };
  });
  app.factory('drag', function () {
    return function (wholeTitleId, wholeContentId) {
      var wholeTitleId = wholeTitleId||'titleId';
      var wholeContentId = wholeContentId||'contentId';
      var oDiv = document.getElementById(wholeContentId);
      oDiv.onmousedown = down;
      function processThis(fn, nowThis) {
        return function (event) {
          fn.call(nowThis, event);
        };
      }
      function down(event) {
        event = event || window.event;
        if (event.target.id != wholeTitleId) return;
        this.initOffsetLeft = this.offsetLeft;
        this.initOffsetTop = this.offsetTop;
        this.initClientX = event.clientX;
        this.initClientY = event.clientY;
        this.maxOffsetWidth =
          (document.documentElement.clientWidth || document.body.clientWidth) -
          this.offsetWidth;
        this.maxOffsetHeight =
          (document.documentElement.clientHeight ||
            document.body.clientHeight) - this.offsetHeight;
        if (this.setCapture) {
          this.setCapture();
          this.onmousemove = processThis(move, this);
          this.onmouseup = processThis(up, this);
        } else {
          document.onmousemove = processThis(move, this);
          document.onmouseup = processThis(up, this);
        }
      }
      function move(event) {
        var nowLeft = this.initOffsetLeft + (event.clientX - this.initClientX);
        var nowTop = this.initOffsetTop + (event.clientY - this.initClientY);
        //此处可以根据实际需要,限制拖动边界
        this.style.left = nowLeft + 'px';
        this.style.top = nowTop + 'px';
      }
      function up() {
        if (this.releaseCapture) {
          this.releaseCapture();
          this.onmousemove = null;
          this.onmouseup = null;
        } else {
          document.onmousemove = null;
          document.onmouseup = null;
        }
      }
    };
  });
  </script>
</html>
 
五、3种searchSelect搜索下拉
1、searchSelectFull
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>searchSelectFull</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  <style>
    .outer-div{
      display: flex;
      flex-direction: column;
      flex-wrap: wrap;
      align-items: top;
      border: 1px solid #7b8ea5;
      border-radius: 6px;
      cursor: pointer;
      width: 70%;
      user-select: none;
    }
    .select-div{
      height: 120px;
      padding: 5px 0 0 5px;
      display: flex;
      justify-content: flex-start;
      flex-wrap: wrap;
      overflow-y: auto;
    }
    .item-summary{
      border: 1px solid #dddddd;
      padding: 5px 10px;
      background: #fafafa;
      margin-right: 5px;
      margin-bottom: 5px;
      border-radius: 4px;
      height:24px;
      color:#000;
    }
    .option-all{
      position: absolute;
      border: 2px solid #dddddd;
      width:444px;
      background:#ffffff;
      z-index: 10;
      padding:6px
    }
    .option-div{
      padding: 5px 10px;
      background: #fafafa;
      margin-right: 5px;
      margin-bottom: 5px;
      border-radius: 4px;
      text-align: left;
    }
    .option-div:hover {
      background: #cccccc !important;
    }
    .yes-selected{
      background:#237eff;
      border-radius:4px;
      color:#ffffff
    }
    .no-selected{
      background:#ffffff;
      border-radius:0;
      border-bottom:1px solid #e7e7e7;
      color:#000000
    }
  </style>
</head>
<body>
  <div ng-controller="thisCtrl">
    <button ng-click="getAllSelectedOptions()">点击获取被选中项</button>
    <duv>{{result}}</duv>
    <search-select-full protocol-type="protocolType"></search-select-full>
  </div>
</body>
</html>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope) {
    $scope.protocolType = {
      "yesOptions": [
          "c1222",
          "cnip",
          "dnp3",
          "dns",
          "doip",
          "egd",
          "enip",
          "enip-io",
          "fins",
          "ftp",
          "ftp-data",
          "ge-srtp",
          "goose",
          "hartip",
          "http",
          "iec104",
          "knxip",
          "mms",
          "modbus",
          "opcda",
          "opcua",
          "pn-dcp",
          "pn-mrrt",
          "pn-ptcp",
          "pop3",
          "rdp",
          "s7",
          "s7-plus",
          "sercos",
          "smb",
          "smb2",
          "smtp",
          "sv",
          "telnet"
      ],
      "allOptions": [
          {
              "server": "c1222",
              "client": "c1222"
          },
          {
              "server": "cnip",
              "client": "cnip"
          },
          {
              "server": "dnp3",
              "client": "dnp3"
          },
          {
              "server": "dns",
              "client": "dns"
          },
          {
              "server": "doip",
              "client": "doip"
          },
          {
              "server": "egd",
              "client": "egd"
          },
          {
              "server": "enip",
              "client": "enip"
          },
          {
              "server": "enip-io",
              "client": "enip-io"
          },
          {
              "server": "fins",
              "client": "fins"
          },
          {
              "server": "ftp",
              "client": "ftp"
          },
          {
              "server": "ftp-data",
              "client": "ftp-data"
          },
          {
              "server": "ge-srtp",
              "client": "ge-srtp"
          },
          {
              "server": "goose",
              "client": "goose"
          },
          {
              "server": "hartip",
              "client": "hartip"
          },
          {
              "server": "http",
              "client": "http"
          },
          {
              "server": "iec104",
              "client": "iec104"
          },
          {
              "server": "knxip",
              "client": "knxip"
          },
          {
              "server": "mms",
              "client": "mms"
          },
          {
              "server": "modbus",
              "client": "modbus"
          },
          {
              "server": "opcda",
              "client": "opcda"
          },
          {
              "server": "opcua",
              "client": "opcua"
          },
          {
              "server": "pn-dcp",
              "client": "pn-dcp"
          },
          {
              "server": "pn-mrrt",
              "client": "pn-mrrt"
          },
          {
              "server": "pn-ptcp",
              "client": "pn-ptcp"
          },
          {
              "server": "pop3",
              "client": "pop3"
          },
          {
              "server": "rdp",
              "client": "rdp"
          },
          {
              "server": "s7",
              "client": "s7"
          },
          {
              "server": "s7-plus",
              "client": "s7-plus"
          },
          {
              "server": "sercos",
              "client": "sercos"
          },
          {
              "server": "smb",
              "client": "smb"
          },
          {
              "server": "smb2",
              "client": "smb2"
          },
          {
              "server": "smtp",
              "client": "smtp"
          },
          {
              "server": "sv",
              "client": "sv"
          },
          {
              "server": "telnet",
              "client": "telnet"
          }
      ],
      "isFull": true
    }
    $scope.getAllSelectedOptions = function(){
      var values = $scope.protocolType.getValues();
      $scope.result = JSON.stringify(values)
    };
  });
  app.directive('searchSelectFull', function () {
    var html = `
    <div class="outer-div"
      tabindex="-1"
      ng-blur="getBlurOut()">
      <!-- 以下是select -->
      <div style="display: flex;"
        ng-click="getOptions($event)">
        <div class="select-div">
          <div class="item-summary">已选择{{yesOptions.length}}条</div>
          <div ng-repeat="client in yesOptions track by $index" class="item-summary">
            <span ng-bind="client" style="position:relative;top:-7px"></span>
            <img ng-click="clickFork(yesOptions,client)" class="onlyQC" src="{{checkImg.fork}}" width="24px" height="24px" /> 
          </div>
          <div class="item-summary" ng-show="yesOptions.length>20">已选择{{yesOptions.length}}条</div>
        </div>
      </div>
      <!-- 以下是option -->
      <div style="position: relative" ng-show="isShowOptions">
        <div class="option-all">
          <div>
            <input type="text"
              class="form-control"
              style="width:300px;height:44px;border-radius:4px;margin:4px 0"
              ng-focus="getFocusInput()"
              ng-blur="getBlurInput()"
              ng-change="changeInputValue()"
              ng-model="selectedOption"/>
            <span style="padding-bottom: 5px;display:inline-block;width:112px;" ng-style="{'visibility': isShowSelectAll? 'visible':'hidden'}">
              <img ng-click="selectAll()" src="{{isSelectAll?checkImg.yes:checkImg.no}}" width="16px" height="16px"/>
              <span>{{textSelectAll}}</span>
            </span>
          </div>
          <div style="max-height: 360px;overflow: auto;padding-left: 6px;">
            <div ng-repeat="option in filterOptions track by $index" class="option-div"
              ng-click="clickOptions(option)"
              ng-class="yesOptions.indexOf(option.client)>-1?'yes-selected':'no-selected'">
              <span ng-bind="option.client"
                style="height:34px;line-height:34px;display: inline-block;"></span>
            </div>
          </div>
        </div>
      </div>
    </div>
      `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        protocolType: '=protocolType',//所有选项
      },
      replace: true,
      controller: function ($scope,$timeout,checkImg) {
        $scope.checkImg = checkImg;
        $scope.isSelectAll = true;
        $scope.isShowSelectAll = true;
        $scope.isFocusInput = false;
        $scope.isShowOptions = false;
        $scope.isClickOptions = false;
        $scope.isClickSelectAll = false;
        $scope.yesOptions = $scope.protocolType.yesOptions;
        $scope.allOptions = $scope.protocolType.allOptions;
        $scope.filterOptions = angular.copy($scope.allOptions);
        $scope.textSelectAll = "全部选择";
        if($scope.isSelectAll){
          $scope.textSelectAll = "已选择"+$scope.yesOptions.length+"条";
        }
        $scope.clickFork = function (yesOptions,client) {
          angular.forEach(yesOptions,function(option,index){
            if(client===option){
              yesOptions.splice(index,1);
              $scope.textSelectAll = "已选择"+$scope.yesOptions.length+"条";
            }
          })
        };
        $scope.selectAll = function () {
          $scope.isClickSelectAll = true;
          $scope.yesOptions = [];
          $scope.isSelectAll = !$scope.isSelectAll;
          if($scope.isSelectAll){
            angular.forEach($scope.allOptions,function(option){
              $scope.yesOptions.push(option.client)
            })
            $scope.textSelectAll = "已选择"+$scope.yesOptions.length+"条";
          }else{
            $scope.textSelectAll = "全部选择";
          }
          $timeout(function(){
            $scope.isClickSelectAll = false;
          },300)
        };
        $scope.getOptions = function (event) {
          if(event.target.className === "onlyQC")return;
          $scope.isShowOptions = !$scope.isShowOptions;
        };
        //组件失焦时,执行下面函数。想一想,什么时候组件聚焦?
        $scope.getBlurOut = function () {
          $timeout(function(){
            if(!$scope.isFocusInput){
              $scope.isShowOptions = false;
            }
          })
        };
        $scope.getFocusInput = function () {
          $scope.isFocusInput = true;
        };
        //输入框失焦时,执行下面函数
        $scope.getBlurInput = function () {
          $scope.isFocusInput = false;
          $timeout(function(){
            if(!$scope.isClickOptions && !$scope.isClickSelectAll){
              $scope.isShowOptions = false;
            }
          },200)
        };
        $scope.clickOptions = function (option) {
          var flag = true;
          $scope.isClickOptions = true;
          angular.forEach($scope.yesOptions,function(client){
            if(option.client===client){
              flag = false;
              $scope.yesOptions.splice($scope.yesOptions.indexOf(client),1);
            }
          });
          if(flag){
            $scope.yesOptions.push(option.client);
          }
          $scope.textSelectAll = "已选择"+$scope.yesOptions.length+"条";
          $timeout(function(){
            $scope.isClickOptions = false;
          },300)
        };
        $scope.changeInputValue = function () {
          if($scope.selectedOption){
            $scope.isShowSelectAll = false;
            $scope.filterOptions = [];
            angular.forEach($scope.allOptions,function(option){
              if(option.client.indexOf($scope.selectedOption) != -1){
                $scope.filterOptions.push(option);
              }
            });
          }else{
            $scope.isShowSelectAll = true;
            $scope.filterOptions = angular.copy($scope.allOptions);
          }
        };
        $scope.protocolType.getValues = function () {
          var client = [];
          var server = [];
          var clientNo = [];
          var serverNo = [];
          var obj;
          angular.forEach($scope.allOptions,function(option){
            if($scope.yesOptions.indexOf(option.client) != -1){
              client.push(option.client)
              server.push(option.server)
            }else{
              clientNo.push(option.client)
              serverNo.push(option.server)
            }
          });
          if($scope.isSelectAll){
            obj = {
              is_all:1,
              client:clientNo,
              server:serverNo,
            }
          }else{
            obj = {
              is_all:0,
              client:client,
              server:server,
            }
          }
          return obj
        };
      },
      link: function (scope, ele, attrs) {
 
      }
    };
  });
  app.factory('checkImg', function () {
    return {
      fork:
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAWCAYAAAArdgcFAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEBSURBVEhL7ZKxSwMxFMb9/5dwS0T0DocbhBbhhg4Hwg0OglC5QpGDDsJZSgsKD26oZPlsaCPpu5dUaF2kw2954f2+kC8Xxhj8FWe5yD+Vr5oxmsW6f0Yt6kkL4nNGUN4+5tBKQSUpHt68AKpxf7mZb870sI4GyPJlhdSKHS7AEzvyJ+rv7wjcnFAP9Z5EJRpXTKyyEjOS9rdE3lwI8DkgtkQLDQbcjA6KLXE5TVFcM7GFlxwgLA+JHb8IkOVdgxEXZwXKO15yimou7O+Q5Z/PyBNP8lMe70CjeGW7HuFnea9wawN6v8IFaAxePrx5n3ihHaH7EuZmDaJjCj0BZ7mAwTfR6GSuYmrILwAAAABJRU5ErkJggg==',
      yes:
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAC98Dn6AAAA+UlEQVQoFZWSMU4DMRBF/584G7QSRcIxuAZKEykNEiUVHVTQRaKh4AIcgAvQpkukVDlBOAYNSGSlXXuwpViyYYFdS9aMZ/6bsezh5HZ3T2KhqkfosEhWqnjkyd1u3xWKdQMsfaEAB0Zilf8swfdU0w0klmpGpz1BvpbHcklbPf8Okts0CfJtWBTz/Yc++Jc8S3PZVQfKGwiuvMD6XYsMzm1dT/1jXKdQ8E0asHRrAzOzbC6UGINWHPQp1UQ/6wjF2LpmJSKfhti4Bi8+lhWP4I+gAqV1uqSi8j9WRuF3m3eMWVUJBeKxzUoYn7bEX7HDyPmB7QEHbRjyL+/+VnuXDUFOAAAAAElFTkSuQmCC',
      no:
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAC98Dn6AAAAbklEQVQoFWM8c+ZMLQMDQxUQcwAxMeAHUFEbC5CoYmNj02ZmZn5FjK6/f/+K/fr16ypIIwdIk7a29hdiNF69ehWkjIOJGMXY1IxqxBYqULEhFDiglPMDlIygKQKPryBSILUgPSCNbaC0B6RJSuQAbowizhJuOsAAAAAASUVORK5CYII='
    };
  });
</script>
2、searchSelectMid
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>searchSelectMid</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  <style>
    .outer-div{
      width:210px;
      height:36px;
      cursor: pointer;
    }
    .select-div{
      border: 1px solid #dddddd;
      padding: 5px 10px;
      background: #fafafa;
      margin-right: 5px;
      border-radius: 4px;
      height:24px;
      color:#000;
    }
    .option-both{
      position: absolute;
      border: 2px solid #dddddd;
      width:444px;
      background:#ffffff;
      z-index: 10;
      padding:6px
    }
    .option-filter{
      padding: 5px 10px;
      background: #fafafa;
      margin-right: 5px;
      margin-bottom: 5px;
      border-radius: 4px;
      text-align: left;
    }
    .option-filter:hover {
      background: #cccccc !important;
    }
    .option-summary{
      max-height: 360px;
      padding: 4px;
      display: flex;
      justify-content: flex-start;
      flex-wrap: wrap;
      overflow-y: auto;
    }
    .yes-selected{
      background:#237eff;
      border-radius:4px;
      color:#ffffff
    }
    .no-selected{
      background:#ffffff;
      border-radius:0;
      border-bottom:1px solid #e7e7e7;
      color:#000000
    }
  </style>
</head>
<body>
  <div ng-controller="thisCtrl">
    <button ng-click="getAllSelectedOptions()">点击获取被选中项</button>
    <duv>{{result}}</duv>
    <search-select-mid protocol-type="protocolType"></search-select-mid>
  </div>
</body>
</html>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope) {
    $scope.protocolType = {
      "yesOptions": [
          "c1222",
          "cnip",
          "dnp3",
          "dns",
          "doip",
          "egd",
          "enip",
          "enip-io",
          "fins",
          "ftp",
          "ftp-data",
          "ge-srtp",
          "goose",
          "hartip",
          "http",
          "iec104",
          "knxip",
          "mms",
          "modbus",
          "opcda",
          "opcua",
          "pn-dcp",
          "pn-mrrt",
          "pn-ptcp",
          "pop3",
          "rdp",
          "s7",
          "s7-plus",
          "sercos",
          "smb",
          "smb2",
          "smtp",
          "sv",
          "telnet"
      ],
      "allOptions": [
          {
              "server": "c1222",
              "client": "c1222"
          },
          {
              "server": "cnip",
              "client": "cnip"
          },
          {
              "server": "dnp3",
              "client": "dnp3"
          },
          {
              "server": "dns",
              "client": "dns"
          },
          {
              "server": "doip",
              "client": "doip"
          },
          {
              "server": "egd",
              "client": "egd"
          },
          {
              "server": "enip",
              "client": "enip"
          },
          {
              "server": "enip-io",
              "client": "enip-io"
          },
          {
              "server": "fins",
              "client": "fins"
          },
          {
              "server": "ftp",
              "client": "ftp"
          },
          {
              "server": "ftp-data",
              "client": "ftp-data"
          },
          {
              "server": "ge-srtp",
              "client": "ge-srtp"
          },
          {
              "server": "goose",
              "client": "goose"
          },
          {
              "server": "hartip",
              "client": "hartip"
          },
          {
              "server": "http",
              "client": "http"
          },
          {
              "server": "iec104",
              "client": "iec104"
          },
          {
              "server": "knxip",
              "client": "knxip"
          },
          {
              "server": "mms",
              "client": "mms"
          },
          {
              "server": "modbus",
              "client": "modbus"
          },
          {
              "server": "opcda",
              "client": "opcda"
          },
          {
              "server": "opcua",
              "client": "opcua"
          },
          {
              "server": "pn-dcp",
              "client": "pn-dcp"
          },
          {
              "server": "pn-mrrt",
              "client": "pn-mrrt"
          },
          {
              "server": "pn-ptcp",
              "client": "pn-ptcp"
          },
          {
              "server": "pop3",
              "client": "pop3"
          },
          {
              "server": "rdp",
              "client": "rdp"
          },
          {
              "server": "s7",
              "client": "s7"
          },
          {
              "server": "s7-plus",
              "client": "s7-plus"
          },
          {
              "server": "sercos",
              "client": "sercos"
          },
          {
              "server": "smb",
              "client": "smb"
          },
          {
              "server": "smb2",
              "client": "smb2"
          },
          {
              "server": "smtp",
              "client": "smtp"
          },
          {
              "server": "sv",
              "client": "sv"
          },
          {
              "server": "telnet",
              "client": "telnet"
          }
      ],
      "isFull": true
    }
    $scope.getAllSelectedOptions = function(){
      var values = $scope.protocolType.getValues();
      $scope.result = JSON.stringify(values)
    };
  });
  app.directive('searchSelectMid', function () {
    var html = `
    <div
      tabindex="-1"
      class="outer-div"
      ng-blur="outerBlur()"
      ng-click="outerFocus()"
      ng-mouseleave="outerLeave()"
      style="
        width:210px;
        height:36px;
        cursor: pointer;padding:0">
      <!-- 以下是select -->
      <div ng-mouseenter="enterSelect()" ng-click="clickSelect()" style="padding:4px 0 0 10px;height:34px;" class="select-div">
        <span ng-show="yesOptions[0]" ng-bind="yesOptions[0]"></span>
        <span ng-show="yesOptions.length>1" ng-bind="' ......'"></span>
        <span ng-show="yesOptions.length==0">
          <span style="color:#87a6c9;">请单选或多选或滤选</span>
        </span>
      </div>
      <!-- 以下是option -->
      <div style="position: relative;" ng-show="isShowOptions||isShowSummary">
        <div style="position: absolute;border: 1px solid #818080;width:300px;background:#ffffff;z-index: 10;padding:6px" ng-show="!isShowSummary">
          <div>
            <input type="text"
              style="width:156px;height:32px;border-radius:4px;margin:4px 0;padding-left: 8px;"
              placeholder="请输入过滤条件"
              ng-change="changeInputValue()"
              ng-model="selectedOption" />
            <span style="padding-bottom: 5px;display:inline-block;width:112px;" ng-style="{'visibility': isShowSelectAll? 'visible':'hidden'}">
              <img ng-click="selectAll()" src="{{isSelectAll?checkImg.yes:checkImg.no}}" width="16px" height="16px"/>
              <span>{{textSelectAll}}</span>
            </span>
          </div>
          <div style="max-height: 360px;overflow: auto;" class="youSelect-option">
            <div ng-repeat="option in filterOptions track by $index" style="
                padding: 2px 8px;
                background: #fafafa;
                margin-right: 5px;
                margin-bottom: 1px;
                text-align: left;
              "
              ng-click="clickOptions(option)"
              ng-style="yesOptions.indexOf(option.client)>-1?{'background':'#237eff','color':'#ffffff'}:{'background':'#ffffff','color':'#495057'}">
              <span ng-bind="option.client"
                style="height:24px;line-height:24px;display: inline-block;"></span>
              <i class="fa"
                style="float:right;position: relative;top:5px"
                ng-show="yesOptions.indexOf(option.client)>-1"></i>
            </div>
          </div>
        </div>
        <div style="position: absolute;border: 1px solid #818080;width:300px;background:#ffffff;z-index: 10;padding:6px;box-shadow: 10px 10px 5px #888888;" ng-show="isShowSummary && yesOptions.length>0">
          <div style="
              max-height: 360px;
              padding: 4px;
              display: flex;
              justify-content: flex-start;
              flex-wrap: wrap;
              overflow-y: auto;
            ">
            <span style="position:relative;top:4px;">{{'已选'+yesOptions.length+'条&nbsp'}}</span>
            <span ng-repeat="client in yesOptions track by $index"
              style="
                padding: 4px;
                background: #fafafa;
                margin-right: 5px;
              
              ng-bind="client" style="color: #000"
            ></span>
          </div>
        </div>
      </div>
    </div>
      `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        protocolType: '=protocolType',//所有选项
      },
      replace: true,
      controller: function ($scope,$timeout,checkImg) {
        $scope.checkImg = checkImg;
        $scope.isShowSummary = false; //是否显示已选项汇总
        $scope.isShowSelectAll = true; //是否显示全选
        $scope.isShowOptions = false; //是否显示下拉项
        $scope.isFocus = false
        $scope.isSelectAll = $scope.protocolType.isFull||false; //是否全选
        $scope.yesOptions = angular.copy($scope.protocolType.yesOptions);
        $scope.allOptions = angular.copy($scope.protocolType.allOptions);
        $scope.filterOptions = angular.copy($scope.allOptions);
        $scope.textSelectAll = "全部选择";
        if($scope.isSelectAll){
          $scope.textSelectAll = "已选择"+$scope.yesOptions.length+"条";
        }
        $scope.selectAll = function () {
          $scope.yesOptions = [];
          $scope.isSelectAll = !$scope.isSelectAll;
          if($scope.isSelectAll){
            angular.forEach($scope.allOptions,function(option){
              $scope.yesOptions.push(option.client)
            })
            $scope.textSelectAll = "已选择"+$scope.yesOptions.length+"条";
          }else{
            $scope.textSelectAll = "全部选择";
          }
        };
        $scope.enterSelect = function () {
          if($scope.isShowOptions){
            $scope.isShowSummary = false;
          }else{
            $scope.isShowSummary = true;
          }
        };
        $scope.clickSelect = function () {
          $scope.isShowSummary = false;
          $scope.isShowOptions = !$scope.isShowOptions;
        };
        $scope.outerLeave = function () {
          $scope.isShowSummary = false;
        };
        $scope.outerFocus = function () {
          $scope.isFocus = true;
          $timeout(function(){
            $scope.isFocus = false;
          },200)
        };
        $scope.outerBlur = function () {
          $timeout(function(){
            if(!$scope.isFocus){//域外失焦
              $scope.isShowSummary = false;
              $scope.isShowOptions = false;
            }
          },150)
        };
        $scope.clickOptions = function (option) {
          var flag = true;
          angular.forEach($scope.yesOptions,function(client){
            if(option.client===client){
              flag = false;
              $scope.yesOptions.splice($scope.yesOptions.indexOf(client),1);
            }
          });
          if(flag){
            $scope.yesOptions.push(option.client);
          }
          $scope.textSelectAll = "已选择"+$scope.yesOptions.length+"条";
        };
        $scope.changeInputValue = function () {
          if($scope.selectedOption){
            $scope.isShowSelectAll = false;
            $scope.filterOptions = [];
            angular.forEach($scope.allOptions,function(option){
              if(option.client.indexOf($scope.selectedOption) != -1){
                $scope.filterOptions.push(option);
              }
            });
          }else{
            $scope.isShowSelectAll = true;
            $scope.filterOptions = angular.copy($scope.allOptions);
          }
        };
        $scope.protocolType.getValues = function () {
          var client = [];
          var server = [];
          var clientNo = [];
          var serverNo = [];
          var obj;
          angular.forEach($scope.allOptions,function(option){
            if($scope.yesOptions.indexOf(option.client) != -1){
              client.push(option.client)
              server.push(option.server)
            }else{
              clientNo.push(option.client)
              serverNo.push(option.server)
            }
          });
          if($scope.isSelectAll){
            obj = {
              is_all:1,
              client:clientNo,
              server:serverNo,
            }
          }else{
            obj = {
              is_all:0,
              client:client,
              server:server,
            }
          }
          return obj
        };
        $scope.protocolType.empty = function (array) {
          $scope.yesOptions = array||[];
          $scope.textSelectAll = "全部选择";
          $scope.isSelectAll = false;
        };
        $scope.protocolType.full = function () {
          $scope.isSelectAll = true;
          $scope.selectedOption = '';
          $scope.changeInputValue();
          $scope.yesOptions = angular.copy($scope.protocolType.yesOptions);
          $scope.textSelectAll = "已选择"+$scope.yesOptions.length+"条";
        };
      },
      link: function (scope, ele, attrs) {
 
      }
    };
  });
  app.factory('checkImg', function () {
    return {
      yes:
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAC98Dn6AAAA+UlEQVQoFZWSMU4DMRBF/584G7QSRcIxuAZKEykNEiUVHVTQRaKh4AIcgAvQpkukVDlBOAYNSGSlXXuwpViyYYFdS9aMZ/6bsezh5HZ3T2KhqkfosEhWqnjkyd1u3xWKdQMsfaEAB0Zilf8swfdU0w0klmpGpz1BvpbHcklbPf8Okts0CfJtWBTz/Yc++Jc8S3PZVQfKGwiuvMD6XYsMzm1dT/1jXKdQ8E0asHRrAzOzbC6UGINWHPQp1UQ/6wjF2LpmJSKfhti4Bi8+lhWP4I+gAqV1uqSi8j9WRuF3m3eMWVUJBeKxzUoYn7bEX7HDyPmB7QEHbRjyL+/+VnuXDUFOAAAAAElFTkSuQmCC',
      no:
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAC98Dn6AAAAbklEQVQoFWM8c+ZMLQMDQxUQcwAxMeAHUFEbC5CoYmNj02ZmZn5FjK6/f/+K/fr16ypIIwdIk7a29hdiNF69ehWkjIOJGMXY1IxqxBYqULEhFDiglPMDlIygKQKPryBSILUgPSCNbaC0B6RJSuQAbowizhJuOsAAAAAASUVORK5CYII='
    };
  });
</script>
3、searchSelectEmpty
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>searchSelectEmpty</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  <style>
    .outer-div{
      width:300px;
      height:36px;
      cursor: pointer;
    }
    .select-div{
      border:1px solid #cccccc;
      border-radius: 6px;
    }
    .option-outer{
      position: absolute;
      border: 2px solid #dddddd;
      width:444px;
      background:#ffffff;
      z-index: 10;
      padding:6px
    }
    .option-inner{
      padding: 5px 10px;
      background: #fafafa;
      margin-right: 5px;
      margin-bottom: 5px;
      border-radius: 4px;
      text-align: left;
      border-bottom: 1px solid #e7e7e7;
    }
    .option-inner:hover {
      background: #cccccc !important;
    }
    .form-input{
      width:180px;
      height:34px;
      border-radius: 16px;
      border:1px solid #ffffff;
      font-size: 16px;
      padding-left: 20px;
    }
    .form-input:focus {
      outline:none
    }
  </style>
</head>
<body>
  <div ng-controller="thisCtrl">
    <button ng-click="getAllSelectedOptions()">点击获取被选中项</button>
    <duv>{{result}}</duv>
    <search-select-empty server-value="serverValue" protocol-type="protocolType"></search-select-empty>
  </div>
</body>
</html>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope) {
    $scope.serverValue = '';
    $scope.protocolType =  [
      {
          "server": "c1222",
          "client": "c1222"
      },
      {
          "server": "cnip",
          "client": "cnip"
      },
      {
          "server": "dnp3",
          "client": "dnp3"
      },
      {
          "server": "dns",
          "client": "dns"
      },
      {
          "server": "doip",
          "client": "doip"
      },
      {
          "server": "egd",
          "client": "egd"
      },
      {
          "server": "enip",
          "client": "enip"
      },
      {
          "server": "enip-io",
          "client": "enip-io"
      },
      {
          "server": "fins",
          "client": "fins"
      },
      {
          "server": "ftp",
          "client": "ftp"
      },
      {
          "server": "ftp-data",
          "client": "ftp-data"
      },
      {
          "server": "ge-srtp",
          "client": "ge-srtp"
      },
      {
          "server": "goose",
          "client": "goose"
      },
      {
          "server": "hartip",
          "client": "hartip"
      },
      {
          "server": "http",
          "client": "http"
      },
      {
          "server": "iec104",
          "client": "iec104"
      },
      {
          "server": "knxip",
          "client": "knxip"
      },
      {
          "server": "mms",
          "client": "mms"
      },
      {
          "server": "modbus",
          "client": "modbus"
      },
      {
          "server": "opcda",
          "client": "opcda"
      },
      {
          "server": "opcua",
          "client": "opcua"
      },
      {
          "server": "pn-dcp",
          "client": "pn-dcp"
      },
      {
          "server": "pn-mrrt",
          "client": "pn-mrrt"
      },
      {
          "server": "pn-ptcp",
          "client": "pn-ptcp"
      },
      {
          "server": "pop3",
          "client": "pop3"
      },
      {
          "server": "rdp",
          "client": "rdp"
      },
      {
          "server": "s7",
          "client": "s7"
      },
      {
          "server": "s7-plus",
          "client": "s7-plus"
      },
      {
          "server": "sercos",
          "client": "sercos"
      },
      {
          "server": "smb",
          "client": "smb"
      },
      {
          "server": "smb2",
          "client": "smb2"
      },
      {
          "server": "smtp",
          "client": "smtp"
      },
      {
          "server": "sv",
          "client": "sv"
      },
      {
          "server": "telnet",
          "client": "telnet"
      }
    ];
    $scope.getAllSelectedOptions = function(){
      $scope.result = $scope.serverValue
    };
  });
  app.directive('searchSelectEmpty', function () {
    var html = `
      <div class="outer-div" >
        <!-- 以下是select -->
        <div ng-click="clickSelect()" class="select-div">
          <input type="text" class="form-input"
            ng-blur="getInputBlur()"
            ng-change="changeInputValue()"
            ng-model="clientValue" />
          <img src="{{checkImg.triangle}}"
            width="12px" height="6px"
            style="float:right;position: relative;top:16px;left:-6px" />
        </div>
        <!-- 以下是option -->
        <div style="position: relative;" ng-show="isShowOptions && filterOptions.length">
          <div class="option-outer" >
            <div style="max-height: 360px;overflow: auto;padding-left: 6px;">
              <div ng-repeat="option in filterOptions track by $index" class="option-inner" ng-click="clickOptions(option)">
                <span ng-bind="option.client" style="height:34px;line-height:34px;display: inline-block;"></span>
              </div>
            </div>
          </div>
        </div>
      </div>
      `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        protocolType: '=protocolType',//所有选项
        serverValue: '=serverValue',
      },
      replace: true,
      controller: function ($scope,$timeout,checkImg) {
        $scope.checkImg = checkImg;
        $scope.isShowOptions = false;
        $scope.filterOptions = angular.copy($scope.protocolType);
        $scope.copyOptions = angular.copy($scope.protocolType);
        $scope.clickSelect = function () {
          $scope.isShowOptions = true;
        };
        $scope.getInputBlur = function () {
          $timeout(function(){
            $scope.isShowOptions = false;
          },150)
        };
        $scope.clickOptions = function (option) {
          $scope.serverValue = option.server;
          $scope.clientValue = option.client;
        };
        $scope.changeInputValue = function () {
          if($scope.clientValue){
            $scope.filterOptions = [];
            angular.forEach($scope.copyOptions,function(option){
              if(option.client.indexOf($scope.clientValue) != -1){
                $scope.filterOptions.push(option);
              }
            });
          }else{
            $scope.filterOptions = angular.copy($scope.copyOptions);
          }
        };
      },
      link: function (scope, ele, attrs) {
 
      }
    };
  });
  app.factory('checkImg', function () {
    return {
      triangle:
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAYCAYAAAC8/X7cAAAAAXNSR0IArs4c6QAAAM9JREFUWAnV2MsNwyAMgGFKRmKBToPYImQLGKcDsFNKlUp9BIKNnWBLPvnyf1ffrLWzUso/V9xorZcppfQwxuT4uyRBjg8h+ClHS0O843P7CyAJ8Rn/BZCA+I3/A4yM2IvfBYyIKMUXASMhavFVwAiIo/hDwJWIlvgmwBWI1vhmwJkISDwIcAYCGg8GcCIw8SgABwIbjwZQInriuwAUiN74bkAPgiKeBIBBUMWTASAIynhSQAuCOp4cUENwxLMACggfY1zyTdQ45/z2tmHrXgHsbZxC2VHomgAAAABJRU5ErkJggg==',
    };
  });
</script>
 
六、input-select树结构(嵌套结构,不可以拖拽,左侧没有竖线)
1、主要需求描述
(1)页面初始时,前端自己显示一个空下拉框
(2)点击下拉框,前端向后台发送请求,将返回的数据,既渲染成下拉项,又存为备份
(3)点击其中一个下拉项,该下拉项如果没有下一级或下一级只有输入框,那么直接渲染,如果有下一级且下一级有下拉框,那么带上该下拉项数据,向后台发送请求,将返回的数据分别渲染成多个下拉框和输入框,作为下拉框的子级并缩进
(4)下拉框有的可以多选,有的只能单选,有的0选中时可以输入,叉掉选中项时,对应的子级也一起删掉
(5)以后重复(2)(3)(4),只是要携带自身至树根所有层级的label和value...
(6)点击“保存”,将整个树图和层级关系发给后台,后台生成一条数据,前端刷新页面,该条数据出现在表格中
(7)点击该条数据后面的“详情”,前端将该条数据展示成“保存”前的树图,可以继续编辑
(8)另外,点击域内下拉框,下拉框隐现交替,点击域外,域内下拉框隐藏
2、主要需求实现思路
(1)弃用select标签,使用div标签模拟select标签的效果,给div标签添加tabindex属性,使其能够获取和失去焦点
(2)数据和组件都用嵌套结构,见下面“数据示例”和“组件html代码”,以便实现各种展示效果,
(3)点击“保存”时,用递归遍历整个嵌套树,提取出后台所需数据
(4)点击“详情”时,用递归遍历本条详情,逐级逐条生成数据,每条数据的生成,都包含:A、本条数据加工getThisChildren(children,detail1),B、本条选项获取并加工getThisOptions(thisChild,detail2),C、下级数据获取getNextChildren(thisChild,detail3);getNextChildren最后将thisChild.children和detail3传给getThisChildren,开启下一级数据的生成;这样纵使后发出的请求先返回数据,也不会出现混乱。
附、数据示例
  var childrenTemp = {//下拉框示例
    type: type,//决定渲染成下拉框还是输入框
    parentOption: formData.selectFront,//本条父级的前端文字,
    selectLabel: key,//标签内容
    selectFront: '',//本条的前端文字,传给本条的子级
    selectBack: '',//本条的后台数据,传给本条的子级
    selectModel: '',//0选中时输入的数据
    type_detail: type_detail,//0选中时,是否禁止输入
    protocol_type: parentProtocolType,//是否把本条后代的根定在此处
    allOptions: [],//本条所有的下拉项,每项包含前后端数据
    yesOptions: [],//本条所有的选中项,每项只包含前端数据
    selectChainThis: parentProtocolType? [thisParams] : selectChainThis,//自身父级至树根所有层级的{label:value}对象组成的数组
    isFinal: isFinal,//本条是否有子级
    isArray: isArray,//本条是否可以多选
    isShowOptions: false,//是否显示本条的下拉项
    children: [],//本条的所有子级
  };
  var childrenTemp = {//输入框示例
    type: type,//决定渲染成下拉框还是输入框
    parentOption: formData.selectFront,//本数据与父级select的哪个选中项关联,
    inputLabel: key,//标签内容
    inputValue: '',//输入的数据
    type_detail: type_detail,//是否禁止输入
  };
3、实例1,不可预览,供实用参考
(1)组件html代码
<div style="margin-left: 20px"><!-- 子级缩进 -->
  <div ng-show="requestParams.which==='addOrEdit'">
    <div ng-repeat="formData in formDatas track by $index">
      <div ng-if="formData.type==='input'" style="margin: 10px 0">
      </div>
      <div ng-if="formData.type==='select'">
        <input-select
          ng-if="formData.children.length>0"
          form-datas="formData.children"
          request-params="requestParams"
        ></input-select>
      </div>
    </div>
  </div>
  <div ng-show="requestParams.which==='detail'">
    <div ng-repeat="formData in formDatas track by $index">
      <div ng-if="formData.type==='input'" style="margin: 10px 0">
      </div>
      <div ng-if="formData.type==='select'">
        <input-select
          ng-if="formData.children.length>0"
        ></input-select>
      </div>
    </div>
  </div>
</div>
(2)页面html代码
<input-select
  ng-if="formDatas.length>0"
  form-datas="formDatas"
  request-params="requestParamsAddOrEdit"
>
</input-select>
(3)组件js代码
(function () {
  angular.module('common-dir').directive('inputSelect', function () {
    return {
      restrict: 'E',
      templateUrl: 'vendor/common-directive/input-select.html',
      scope: {
        formDatas: '=formDatas',
        requestParams: '=requestParams'
      },
      replace: true,
      controller: function ($scope, auditApi, $timeout) {
        $scope.getBlur = function (formData, event) {
          $timeout(function () {
            formData.isShowOptions = false;
          }, 200);
        };
        //这个函数用于:向后台发送请求,获取select的option
        $scope.getOptions = function (formData, event) {
          //点击select框,获取下拉项
          if (event.target.tagName === 'INPUT') return; //当点击select框内部的input框时,阻止
          if (event.target.className === 'onlyQC') return; //当点击select框内部的备选项时,阻止
          if (formData.allOptions && formData.allOptions.length > 0) {
            if (event.target.parentElement.className === 'isShowOptions') {
              formData.isShowOptions = !formData.isShowOptions;
            }
            return; //当下拉项已存在时,阻止
          }
          ................................
        };
        //这个函数用于:叉掉已选中项时,除了删掉自身,还删掉下面对应的所有子项
        $scope.optionDelete = function (formData, front) {
          formData.yesOptions.splice(formData.yesOptions.indexOf(front), 1);
          for (var i = 0; i < formData.children.length; i++) {
            if (formData.children[i].parentOption == front) {
              formData.children.splice(
                formData.children.indexOf(formData.children[i]),
                1
              );
              i--;
            }
          }
        };
        //这个函数用于:点击下拉项中的某项时
        $scope.optionClick = function (formData, option) {
          var isTrue =
            formData.type_detail === 'protogo' ||
            formData.type_detail === 'object' ||
            formData.isArray;
          if (!isTrue) {
            formData.children = [];
          }
          ................................
        };
      },
      link: function (scope, ele, attrs) {}
    };
  }).factory('inputSelect', function (auditApi) {
    return {
      /*方法说明
        *@method getThisChildren 生成本条的全部子级
        *@param{Array}selectChainThis 参数链,向后台发送请求前,应当拼接成字符串
        *@param{String}label label标签文字
        *@param{String}parent 本条来自于父级的被选中项parent
        *@param{Object}valueOut 所有子级的原始数据
        *@param{Array}children 所有子级的最终数据
        *@param{Object,Array,String}thisDetail 本条数据的详情,随着递归的深入,越来越短
        *@param{Boolean}isLeap 是否需要跳转,有时随着递归的深入,下一级回到了第一级(协议名称),这种情况叫跳转
        *@return {undefined} undefined,没有返回值
        */
      getThisChildren:function (
        selectChainThis,
        label,
        parent,
        valueOut,
        children,
        thisDetail,
        isLeap,
        request
      ) {
        if (type === 'input') {
          thisChild = {};
        } else if (type === 'select') {
          thisChild = {};
          if (isFinal === 1) {
            //没有子级
          } else if (isFinal === 0) {
            //有子级 
            if (thisDetail.constructor === Object) {
              var detailKeysArray = Object.keys(thisDetail);
              for (var i = 0; i < detailKeysArray.length; i++) {
                var detailKey = detailKeysArray[i];
                if (detailKey == label) {
                  var nextDetail = thisDetail[detailKey];
                  that.getThisOptions(...);
                }
              }
            } else {
              //点击下拉框时,组件向后台发送请求,然后才出现下拉项,不用在这里获取下拉项。
            }
          }
        }
        children.push(thisChild);
      },
      /*方法说明
        *@method getThisOptions 生成本子级的所有下拉项
        *@param{Object}thisChild 一个子级
        *@param{Object,Array,String}nextDetail 本条数据的详情,随着递归的深入,越来越短
        *@param{Array}selectChainThis 参数链,向后台发送请求前,应当拼接成字符串
        *@param{String}label label标签文字
        *@param{Boolean}isLeap 是否需要跳转,有时随着递归的深入,下一级回到了第一级(协议名称),这种情况叫跳转
        *@return {undefined} undefined,没有返回值
        */
      getThisOptions:function (
        thisChild,
        nextDetail,
        selectChainThis,
        label,
        isLeap,
        request
      ) {
        $http({
            method: request.method,
            root: request.root,
            url: request.url,
            params: params
          })
          .then(function (result) {
            allOptions.push(oneOption);
            for (var j = 0; j < allOptions.length; j++) {
              var optionOne = allOptions[j];
              that.getNextChildren(...);
            }
          });
      },
      /*方法说明
        *@method getNextChildren 获取子级的子级
        *@param{Object}optionOne 子级的一个下拉项
        *@param{Object,Array,String}nextDetail 本条数据的详情,随着递归的深入,越来越短
        *@param{Array}selectChainThis 参数链,向后台发送请求前,应当拼接成字符串
        *@param{Object}thisChild 一个子级
        *@param{Object}params 请求参数
        *@param{Boolean}isLeap 是否需要跳转,有时随着递归的深入,下一级回到了第一级(协议名称),这种情况叫跳转
        *@return {undefined} undefined,没有返回值
        */
      getNextChildren:function (
        optionOne,
        nextDetail,
        selectChainThis,
        thisChild,
        params,
        isLeap,
        request
      ) {
        var that = this;
        var isFinal = optionOne.isFinal;
        var parent = optionOne.front;
        if (that.wholeKeysArray.indexOf(parent) > -1) {//以下是跳转逻辑
          $http({
              method: request.method,
              root: request.root,
              url: request.url,
              params: {
              protocol_type: parent
              }
          })
          .then(function (result) {
              var selectChainThis = [{ 协议名称: parent }]; //遇到跳转逻辑时,给选择链重新赋值
              for (var label in valueOut) {
                that.getThisChildren(...);
              }
          });
          }
        } else {//以下是正常逻辑
          if (isFinal === 1) {
            var resultKey = Object.keys(thisChild.copyOptions)[0];
            var valueOut = thisChild.copyOptions[resultKey];
            var isObject = nextDetail.constructor === Object;
            var detailKeysArray;
            if (isObject) {
              detailKeysArray = Object.keys(nextDetail);
              if (detailKeysArray.indexOf(parent) > -1) {
                for (var label in valueOut) {
                  if (label === parent) {
                    that.getThisChildren(...);
                    thisChild.yesOptions.push(parent);
                  }
                }
              }
            }
          } else if (isFinal === 0) {
            var isObject = nextDetail.constructor === Object;
            if (isObject) {
              var detailKeysArray = Object.keys(nextDetail);
              if (detailKeysArray.indexOf(parent) > -1) {
                  $http({
                    method: request.method,
                    root: request.root,
                    url: request.url,
                    params: thisParams
                  })
                  .then(function (result) {
                    if (detailKeysArray.indexOf(resultKeysArray[0]) > -1) {//父级的parentOption和子级的label一样
                      for (var label in valueOut) {
                        that.getThisChildren(...);
                      }
                    } else {//如果出现parentOption和它子级的label不一样,那么根据数据结构,逻辑写在此处。
                      for (var label in valueOut) {
                        that.getThisChildren(...);
                      }
                    }
                  });
              }
            }
          }
        }
      },
    };
  });
})();
(4)页面js代码
$scope.formDatas = [
  {
    type: 'select',
    selectLabel: '协议名称',
    selectFront: '',
    selectBack: '',
    allOptions: [],
    yesOptions: [],
    selectChainThis: [],
    children: [],
    isFinal: 0
  }
];
4、实例2,可预览,供演示
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>input和select</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
</head>
 
<body>
  <div ng-controller="thisCtrl">
    <div>
      <p>=====可预览=====</p>
      <p>1、向后台发送请求,获取返回数据,填充$scope.formDatas</p>
      <p>2、向后台发送请求,获取返回数据,填充$scope.formDatas</p>
    </div>
    <input-select ng-if="formDatas.length>0" form-datas="formDatas">
    </input-select>
  </div>
</body>
 
</html>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope/*,cyRequest*/) {
    //此处,向后台发送请求,获取返回数据,填充$scope.formDatas
    $scope.formDatas = [
      {
        type: 'input',
        inputLabel: '输入框',
        inputValue: '',
      },{
        type: 'select',
        selectLabel: '选择框标签',
        selectValue: '后台1',
        selectOptions: [
          { back: '后台0', front: '前端0' },
          { back: '后台1', front: '前端1' },
          { back: '后台2', front: '前端2' },
          { back: '后台3', front: '前端3' },
          { back: '后台4', front: '前端4' },
          { back: '后台5', front: '前端5' },
        ],
        selectChainThis: [],//默认值。
        selectChainNext: null,
        children: [],//子级。
      },{
        type: 'select',
        selectLabel: '选择框标签2222',
        selectValue: '后台1',
        selectOptions: [
          { back: '后台0', front: '前端0' },
          { back: '后台1', front: '前端1' },
          { back: '后台2', front: '前端2' },
          { back: '后台3', front: '前端3' },
          { back: '后台4', front: '前端4' },
          { back: '后台5', front: '前端5' },
        ],
        selectChainThis: [],//默认值。
        selectChainNext: null,
        children: [],//子级。
      }
    ];
  });
  app.directive('inputSelect', function () {
    var html = `
        <div style="margin-left:10px;">
          <div ng-repeat="formData in formDatas track by $index">
            <div ng-if="formData.type==='input'" style="margin:10px 0">
              <label ng-bind="formData.inputLabel+':'" style="width:200px;text-align:right;display:inline-block"></label>
              <input ng-model="formData.inputValue" type="text" style="width:300px;border:1px solid gray;height:26px;border-radius:4px;"/>  
            </div>
            <div ng-if="formData.type==='select'" style="margin:10px 0">
              <label ng-bind="formData.selectLabel+':'" style="width:200px;text-align:right;display:inline-block"></label>
              <select 
              ng-model="formData.selectValue"
              ng-options="option.back as option.front for option in formData.selectOptions"
              ng-change="clickOption(formData)"
              style="width:306px;border:1px solid gray;height:26px;border-radius:4px;"
              ></select>
              <input-select ng-if="formData.children.length>0" form-datas="formData.children"></input-select>
            </div>
          </div>
        </div>
      `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        formDatas: '=formDatas'
      },
      replace: true,
      controller: function ($scope) {//此处注入“公共请求服务”
        $scope.clickOption = function (formData) {
          var objOuter={};
          objOuter[formData.selectLabel] = formData.selectValue;
          formData.selectChainNext = angular.copy(formData.selectChainThis);
          formData.selectChainNext.push(objOuter);
          //此处,把formData.selectChainNext作为“公共请求服务”的参数,向后台发送请求,获取返回数据result并加工,然后填充formData.children
          var result=[
            {
              type:'input',
              label:'输入框'
            },{
              type:'select',
              label:'选择框标签'
            },{
              type:'select',
              label:'选择框标签2'
            }
          ];
          angular.forEach(result,function(value,index){
            var objInner = { };
            if(value.type==='input'){
              objInner.type = value.type;
              objInner.inputLabel = value.label;
              objInner.inputValue = '';
            }else if(value.type==='select'){
              objInner.type = value.type;
              objInner.selectLabel = value.label;
              objInner.selectValue = '后台1';
              objInner.selectOptions = [
                { back: '后台0', front: '前端0' },
                { back: '后台1', front: '前端1' },
                { back: '后台2', front: '前端2' },
                { back: '后台3', front: '前端3' },
                { back: '后台4', front: '前端4' },
                { back: '后台5', front: '前端5' },
              ];
              objInner.selectChainThis = angular.copy(formData.selectChainNext);
              objInner.selectChainNext = null;
              objInner.children = [];
              if(index===1){
                console.log(objInner.selectChainThis)
              }
            }
            formData.children.push(objInner)
          })
        };
      },
      link: function (scope, ele, attrs) {
 
      }
    };
  })
</script>
 
七、dir-tree树结构(平行结构,可以拖拽,左侧有竖线)
1、主要需求描述
(1)页面初始时,初始化组件,向后台发送请求,获取嵌套数据,改成平级数据,计算并添加缩进和左侧线,渲染组件
(2)可以编辑本条数据
(3)可以拖拽本条数据至目标数据上,将自身和目标数据发给后台,最后刷新页面,获取新嵌套数据(被拖拽数据及其后代成为目标数据的后代)
2、主要需求实现思路
(1)拖拽效果用插件
(2)递归实现嵌套数据改成平级数据,非如此则拖拽出错
(3)递归实现左侧竖线
附、数据示例
var obj={
  id: item.id,//本级id
  name: item.name,
  puuid: item.puuid,
  uuid: item.uuid,
  idsArray: item.idsArray,//供判断层级关系时用
  isShowSelf: item.collapsed||true,//是否显示自身
  //以上为后台返回,以下为前端添加
  isShowChild: true,//是否显示后代
  leftTime: leftTime,//竖线从左缩进次数
  downTime: 0,//竖线向下延伸次数
}
(5)给div标签添加tabindex属性,使其能够获取和失去焦点
3、实例1,不可预览,供实用参考
(1)组件html代码
<div>
  <div
    style="display:flex; flex-direction: row" 
    ng-repeat="formData in formDatas track by $index"
  >
    <div
      class="dir-tree-line"
      ng-drag="true" 
      ng-drop="true"
      ng-show="formData.isShowSelf"
      ng-style="{'margin-left':formData.leftTime*28+'px'}"
      ng-drop-success="dropSuccess($index, $data, $event)"
      ng-drag-data="formData"
      ng-click="clickItem(formData)"
      style="position:relative"
    >
      <div>
        <span ng-style="{'background': $index===0? '#ffffff':'rgb(162, 142, 142)'}" style="height:1px;width:16px;display: inline-block;position: relative;top:-4px"></span>
        <span
          class="dir-tree-label"
          ng-class="formData.isHasChild?((selectedItem.showId && selectedItem.showId === formData.uuid)?'dir-tree-haschild-blue':'dir-tree-haschild-black'):((selectedItem.showId && selectedItem.showId === formData.uuid)?'dir-tree-nochild-blue':'dir-tree-nochild-black')"
        ></span>
        <span
          ng-bind="formData.name"
          ng-class="(selectedItem.showId && selectedItem.showId === formData.uuid)?'dir-tree-label-text-blue':'dir-tree-label-text-black'"
          ng-drag="true"
          ng-drag-data="formData"
        ></span>
        <span
          class="dir-tree-label"
          ng-show="formData.isHasChild && !formData.isShowChild"
          ng-class="(selectedItem.showId && selectedItem.showId === formData.uuid)?'dir-tree-haschild-tianjia-blue':'dir-tree-haschild-tianjia-black'"
        ></span>
      </div>
      <div
        style="position:relative;width:1px;background: rgb(162, 142, 142);left:27px;top:-7px;"
        ng-style="{'height':((formData.downTime+0.5)*36+8)+'px'}"
        ng-show="formData.isShowChild && formData.isHasChild"
      ></div>
    </div>
    <div style="flex:1;"></div>
  </div>
</div>
(2)页面html代码
<dir-tree request-datas='requestDatas' selected-item='selectedAdd' ng-if="decideOther.isIf"></dir-tree>
(3)组件js代码
(function () {
  angular.module('common-dir').directive('dirTree', function () {
    return {
      restrict: 'E',
      templateUrl: 'vendor/common-directive/dir-tree.html',
      scope: {
        requestDatas: '=requestDatas',//与前后台交互相关的内容
        selectedItem: '=selectedItem',//树图的被选中项
        decideOther: '=decideOther'//本树是否决定“其它树”的隐现
      },
      replace: true,
      controller: function ($scope, $timeout, auditApi) {
        if(!$scope.selectedItem.isAbandonDrag){
          $scope.selectedItem.callback = function(name,uuid,puuid){
            auditApi
              .query({
                method: $scope.requestDatas.method||'put',
                root: $scope.requestDatas.root||'organization',
                url: $scope.requestDatas.url||'/info',
                data: {
                  name:name,//被修改节点的名称
                  uuid:uuid,//被修改节点的uuid
                  puuid:puuid,//被修改的节点,应移到哪个节点之下
                },
                pageLoad: true,
              })
              .then(function () {
                layer.msg('拖拽成功!');
                $scope.getDatas();
              }).catch(function(){
                $scope.getDatas();
 
              });
          }
        }else{
          delete $scope.selectedItem.callback
        }
        $scope.clickItem = function(formData){
          $scope.selectedItem.name = formData.name;
          $scope.selectedItem.puuid = formData.puuid;
          $scope.selectedItem.uuid = formData.uuid;
          $scope.selectedItem.showId = formData.uuid;
          var id = formData.id;
          formData.isShowChild = !formData.isShowChild
          $scope.formDatas.forEach(function(item){
            if(item.idsArray.indexOf(id) > -1 && item.idsArray.length > formData.idsArray.length){
              item.isShowChild = formData.isShowChild;
              item.isShowSelf = formData.isShowChild;
            }
          })
          $scope.addDownTime($scope.formDatas);
        }
        $scope.dropSuccess = function(index,data,event){
          var toItem = $scope.formDatas[index];
          if(angular.isFunction($scope.selectedItem.callback)){
            $scope.selectedItem.callback(data.name,data.uuid,toItem.uuid);
          }
        }
        $scope.getDatas = $scope.requestDatas.getDatas = function(isNewAdd){
          auditApi
            .query({
              method: $scope.requestDatas.method||'get',
              root: $scope.requestDatas.root||'organization',
              url: $scope.requestDatas.url||'/info',
              pageLoad: true,
            })
            .then(function (res) {
              var list = angular.copy(res.rows);
              var lastList = [];
              //以下给每条数据添加idsArray属性,供判断层级关系时用
              function addEachRowIdsArray(list,fatherId){
                list.forEach(function(item) {
                  item.idsArray = fatherId.concat(item.id);
                  if(item.children){
                    addEachRowIdsArray(item.children,item.idsArray)
                  }
                });
              }
              addEachRowIdsArray(list,[])
              //以下把父子嵌套数据改造成兄弟并列数据,不如此则拖拽出错
              function getList(list,leftTime){
                angular.forEach(list,function(item){
                  var obj={
                    id: item.id,
                    name: item.name,
                    puuid: item.puuid,
                    uuid: item.uuid,
                    idsArray: item.idsArray,
                    isShowSelf: item.collapsed||true,//是否显示自身
                    //以上为后台返回,以下为前端添加
                    isShowChild: true,//是否显示后代
                    leftTime: leftTime,//竖线从左缩进次数
                    downTime: 0,//竖线向下延伸次数
                  }
                  lastList.push(obj)
                  if(item.children.length){
                    obj.isHasChild = true;
                    getList(item.children,leftTime+1)
                  }
                })
              }
              getList(list,1);
              if(isNewAdd){
                $scope.selectedItem.showId = lastList[0].uuid;
                $scope.selectedItem.uuid = lastList[0].uuid;
              }
              $scope.selectedItem.isInit = Boolean(lastList.length);
              if($scope.decideOther){//不如此,修改后“其它树”不刷新
                $scope.decideOther.isIf = false;
                $timeout(function(){
                  $scope.decideOther.isIf = true;
                  $scope.formDatas = lastList;
                  $scope.addDownTime($scope.formDatas)
                })
              }
              $scope.formDatas = lastList;//已经完成加工的树图总数据!
              $scope.addDownTime($scope.formDatas)//给总数据的每条数据添加向下延伸次数
            });
        }
        $scope.addDownTime = function(formDatas){
          //以下给formDatas的每一项添加downTime
          formDatas.forEach(function(item1){
            item1.downTime = 0 ;
            if(!item1.isShowChild)return;
            //以下添加item1的downTime
            var id1 = item1.id;
            var idsArray = [];
            //以下获取本级的所有子代的id,并存储在idsArray中
            formDatas.forEach(function(item2){
              if(item2.idsArray.indexOf(id1) > -1 && item2.idsArray.length == item1.idsArray.length+1){
                idsArray.push(item2.id)
              }
            })
            //以下删除idsArray的最后一项
            idsArray.pop();
            //以下计算本项的downTime
            for(var i = 0; i<idsArray.length; i++){
              var id2 = idsArray[i];//第i个子代的id
              for(var ii = 0; ii<formDatas.length; ii++){
                var item3 = formDatas[ii];
                if(item3.idsArray.indexOf(id2)>-1){//从所有数据中,找到第i个子代
                  item1.downTime++;
                  if(item3.isHasChild && !item3.isShowChild){//第i个子代有子代且没有展开
                    var id3 = item3.id;
                    formDatas.forEach(function(item4){
                      if(item4.idsArray.indexOf(id3) > -1 && item4.idsArray.length > item3.idsArray.length){
                        ii++//跳过没展开的子代
                      }
                    }) 
                  }
                }
              }
            }
          })
        }
        $scope.getDatas()
      },
      link: function (scope, ele, attrs) {}
    };
  });
})();
(4)页面js代码
//以下是树图属性传参的数据
$scope.decideOther = {//本树是否决定“其它树”的隐现
  isIf: true
};
$scope.requestDatas = { };//与前后台交互相关的内容
$scope.selectedDatas = {//树图的被选中项
  name: '',
  uuid: '',
  puuid: '',
  showId: '',
};
4、实例2,可预览,供演示用
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>passWord</title>
  <style>
    .dir-tree-label{
      padding-left: 20px;
      margin-right: 4px;
      height: 36px;
      line-height: 36px;
      background-position: left 4px;
      background-repeat: no-repeat;
      cursor:pointer;
      user-select:none;
    }
    .dir-tree-label-text{
      cursor: pointer;
      user-select: none;
    }
    .dir-tree-label-black{
      color:black
    }
    .dir-tree-label-red{
      color:red
    }
  </style>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  <script src="https://cdn.bootcss.com/ngDraggable/0.1.11/ngDraggable.js"></script>
</head>
<body>
  <div ng-controller="thisCtrl">
    <dir-tree form-datas="lastList" other-datas='otherDatas'></dir-tree>
  </div>
</body>
</html>
<script>
  var app = angular.module('myModel', ['ngDraggable']);
  app.controller('thisCtrl', function ($scope) {
    var res = {
      "rows": [{
        "children": [{
            "children": [{
                "children": [{
                    "children": [],
                    "isShowSelf": true,
                    "id": "12",
                    "name": "裁员部一",
                    "puuid": "1ec9f238-9aba-484c-b857-d4183200053c",
                    "uuid": "1e8ae51d-8d2f-486e-b1d1-ff1009f8461e"
                  },
                  {
                    "children": [],
                    "isShowSelf": true,
                    "id": "13",
                    "name": "裁员部二",
                    "puuid": "1ec9f238-9aba-484c-b857-d4183200053c",
                    "uuid": "be521aa9-1e8c-4262-a156-2d02e3cb9c51"
                  }
                ],
                "isShowSelf": true,
                "id": "4",
                "name": "人力部一",
                "puuid": "bcb3e97f-d8ef-4e33-a234-09a3fef8533d",
                "uuid": "1ec9f238-9aba-484c-b857-d4183200053c"
              },
              {
                "children": [],
                "isShowSelf": true,
                "id": "5",
                "name": "人力部二",
                "puuid": "bcb3e97f-d8ef-4e33-a234-09a3fef8533d",
                "uuid": "ba10a598-9af7-47ba-9c34-ee41d85f0525"
              },
              {
                "children": [],
                "isShowSelf": true,
                "id": "6",
                "name": "人力部三",
                "puuid": "bcb3e97f-d8ef-4e33-a234-09a3fef8533d",
                "uuid": "a880024f-e906-4558-833c-4ec7a20927e3"
              },
              {
                "children": [],
                "isShowSelf": true,
                "id": "7",
                "name": "人力部四",
                "puuid": "bcb3e97f-d8ef-4e33-a234-09a3fef8533d",
                "uuid": "25de3bf5-4848-48e5-a161-04d1492a4edb"
              }
            ],
            "isShowSelf": true,
            "id": "2",
            "name": "人力部",
            "puuid": "f2a8c4ea-e270-44d0-a7bd-18c62fb55358",
            "uuid": "bcb3e97f-d8ef-4e33-a234-09a3fef8533d"
          },
          {
            "children": [{
                "children": [],
                "isShowSelf": true,
                "id": "8",
                "name": "财务部一",
                "puuid": "44667cbb-a1d5-4187-84aa-c3ee347d873e",
                "uuid": "c036eab1-0f4d-4732-be3c-8e2da46cb60e"
              },
              {
                "children": [],
                "isShowSelf": true,
                "id": "9",
                "name": "财务部二",
                "puuid": "44667cbb-a1d5-4187-84aa-c3ee347d873e",
                "uuid": "ee22c501-e797-4190-84d7-41c0523ac784"
              },
              {
                "children": [],
                "isShowSelf": true,
                "id": "10",
                "name": "财务部三",
                "puuid": "44667cbb-a1d5-4187-84aa-c3ee347d873e",
                "uuid": "60dd79cf-20b7-4d04-92c0-968eb85620c1"
              },
              {
                "children": [],
                "isShowSelf": true,
                "id": "11",
                "name": "财务部四",
                "puuid": "44667cbb-a1d5-4187-84aa-c3ee347d873e",
                "uuid": "f7a76408-c3ba-4c4b-8f77-d520407beb31"
              }
            ],
            "isShowSelf": true,
            "id": "3",
            "name": "财务部",
            "puuid": "f2a8c4ea-e270-44d0-a7bd-18c62fb55358",
            "uuid": "44667cbb-a1d5-4187-84aa-c3ee347d873e"
          }
        ],
        "isShowSelf": true,
        "id": "1",
        "name": "中国石油",
        "puuid": "",
        "uuid": "f2a8c4ea-e270-44d0-a7bd-18c62fb55358"
      }]
    };
    var list = angular.copy(res.rows);
    var lastList = [];
    //以下解决隐藏和显示问题
    function addEachRowIds(list,fatherId){
      list.forEach(function(item) {
        item.idsArray = fatherId.concat(item.id);
        if(item.children){
          addEachRowIds(item.children,item.idsArray)
        }
      });
    }
    addEachRowIds(list,[])
    //以下把父子嵌套数据改造成兄弟并列数据,不如此则拖拽出错,极端重要!!!
    function getList(list,left){
      angular.forEach(list,function(item){
        var obj={
          id: item.id,
          name: item.name,
          puuid: item.puuid,
          uuid: item.uuid,
          idsArray: item.idsArray,
          isShowSelf: item.isShowSelf,
          left: left,
        }
        lastList.push(obj)
        if(item.children.length){
          obj.isHasChild = true;
          getList(item.children,left+1)
        }
      })
    }
    getList(list,1);
    $scope.lastList = lastList;
    $scope.otherDatas = {//页面树图的被选中项
      name: '',//被选中项的name
      uuid: '',//被选中项的uuid
      puuid: '',//被选中项的puuid,即该数据父级的uuid
      showId: '',//被选中项的showId,取值为“该条数据”的uuid,在<dir-tree>组件中,showId与每条数据的uuid进行比较,相等的展示为红色,为被选中项本身
      callback: function(name,uuid,puuid){//拖动结束后,触发的函数
         
      }
    };
  });
  app.directive('dirTree', function () {
    var html = `
    <div>
      <div
        class="dir-tree-label"
        ng-drag="true" 
        ng-drop="true"
        ng-show="formData.isShowSelf"
        ng-style="{'margin-left':formData.left*20+'px'}"
        ng-repeat="formData in formDatas track by $index"
        ng-drop-success="dropSuccess($index, $data, $event)"
        ng-drag-data="formData"
      >
        <img ng-src="{{formData.isHasChild? fileImg.havechild : fileImg.nochild}}" ng-click="clickImg(formData)">
        <span
          class="dir-tree-label-text"
          ng-bind="formData.name"
          ng-class="(otherDatas.showId && otherDatas.showId === formData.uuid)?'dir-tree-label-red':'dir-tree-label-black'"
          ng-click="clickText(formData)"
          ng-drag="true"
          ng-drag-data="formData"
        ></span>
      </div>
    </div>
      `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        formDatas: '=formDatas',
        otherDatas: '=otherDatas'//页面树图的被选中项
      },
      replace: true,
      controller: function ($scope,fileImg) {
        $scope.fileImg = fileImg;
        $scope.clickImg = function(formData){
          $scope.clickText(formData);
          var thisArrayIds = formData.idsArray;
          $scope.formDatas.forEach(function(item){
            var flag = true;
            var itemArrayIds = item.idsArray;
            thisArrayIds.forEach(function(id,index){
              if(itemArrayIds.indexOf(id) === -1){
                flag = false;
              }
            })
            if(flag){
             item.isShowSelf = !item.isShowSelf
            }
          })
          formData.isShowSelf = true
        }
        $scope.clickText = function(formData){
          $scope.otherDatas.name = formData.name;
          $scope.otherDatas.puuid = formData.puuid;
          $scope.otherDatas.uuid = formData.uuid;
          $scope.otherDatas.showId = formData.uuid;
        }
        $scope.dropSuccess = function(index,data,event){
          /**
          * 函数说明:拖拽结束时触发的函数
          * @index:目标所在位置的序号
          * @data:初始位置的数据
          * @event:初始位置的鼠标事件
          *
          */
          var toItem = $scope.formDatas[index];
          var fromIndex = $scope.formDatas.findIndex(function(item){
            return  Object.is(data.uuid ,item.uuid)
          })
          $scope.formDatas[index] = data;
          $scope.formDatas[fromIndex] = toItem;
          $scope.otherDatas.callback(data.name,data.uuid,toItem.uuid);
        }
      },
      link: function (scope, ele, attrs) {}
    };
  });
   
  app.factory('fileImg', function () {
    return {
      nochild: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAOCAYAAADwikbvAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAOw4AAA7DAZBCL/sAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAHZJREFUOE9j+P//Pxiv7HH8jw/D1CFjOAOqACu4srcGqwFEa8ZmAEma0Q3A1JxbgIrRAH7NBABezT3bF8JxfU08WCwrJwlMgwD1bYbZguxXkBjIVmSboepwaCYA8GoGRQeyvy07S8AYBmhnMyGAUzOxGKLnPwMABE2jDc+cnOsAAAAASUVORK5CYII=',
      havechild: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAIhJREFUOE9j+P//P0UYqyApGIVzuN3kPzJGlsOF4Yy1xbpAChVAxVA0oGMwAbbt0TwEvtT8/8GuCjBGdxVYLVYDiAS4DUB2AR48PUoe0wCwX7EoxobRw4U6BszPUAEHHDEYrBbdALC/sCjGhrGGAUgQ7DQsGtAxVgNAGOQ0YjBMPQyjcEjH/xkAhEKsbVNNI1sAAAAASUVORK5CYII=',
    };
  });
</script>
  
  
  

  

posted @   WEB前端工程师_钱成  阅读(10443)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示