addSubMerchant.html
87.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="广联帐户管理中心-员工管理" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<style>
/* body {
height:auto;
} */
.marCheckbox{
display: flex;
}
.marCheckbox div:nth-child(4){
margin-left: 80px;
}
.clearfix {
zoom: 1;
}
.clearfix::after {
content: '';
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.edit-box {
/* width: 1046px; */
padding: 20px 20px;
color: #333333;
background-color: #ffffff;
margin: 15px auto;
position: relative;
}
.edit-box .grayLine {
position: absolute;
left: 0;
top: 68px;
background-color: #d8d8d8;
width: 100%;
height: 1px;
}
.edit-title {
height: 48px;
line-height: 48px;
padding: 0 10px;
margin-bottom: 15px;
font-size: 16px;
font-weight: 600;
/* background: #f7f7f7; */
}
.edit-box .layui-form-label {
width: 130px;
}
.edit-box .layui-form-item .layui-input-inline {
width: 320px;
}
.edit-box .layui-form-item .layui-input-inline.w-70 {
width: 70%;
}
.edit-box .layui-form-item .layui-input-inline.w-70 #addrEl {
width: calc(100% - 200px);
display: inline-block;
}
.edit-box .btn-no-border {
border: none;
}
.edit-box .upload-img-box {
position: relative;
color: #999999;
border: 1px dashed #d9d9d9;
cursor: pointer;
}
.edit-box .upload-img-box .upload-img {
position: absolute;
top: 0;
left: 0;
}
.edit-box .icon-add {
position: absolute;
top: 45%;
font-size: 40px;
left: 50%;
transform: translate3d(-50%, -50%, 0);
}
.edit-box .m-t-10 {
margin-top: 10px;
}
.edit-box .label-text {
line-height: 32px;
}
.edit-box .upload-img-wh {
width: 120px !important;
height: 80px;
}
.show {
display: inline-block;
}
.hide {
display: none !important;
}
.option-btns {
height: 38px;
margin-left: 20px;
}
.wrap-add-signal {
margin-top: 11px;
background-color: #1989fa;
color: #fff;
height: 16px;
line-height: 16px;
text-align: center;
width: 16px;
border-radius: 50%;
}
.tips {
display: inline-block;
font-size: 14px;
color: #999;
margin-left: 160px;
margin-top: 8px;
}
.form-right {
position: absolute;
right: 0;
top: 0;
transform: translateX(110%);
}
.edit-box #accountTypeEl .layui-form-checked span,
#accountTypeEl .layui-form-checked:hover span {
background-color: #2A58AD !important;
}
.edit-box #accountTypeEl .layui-form-checked i,
#accountTypeEl .layui-form-checked:hover i {
color: #2A58AD !important;
}
.layui-form-radio:hover *,
.layui-form-radioed,
.layui-form-radioed > i {
color: #2A58AD !important;
}
.pageTitle {
background-color: #fff;
height: 78px;
font-size: 20px;
font-weight: bold;
color: #333333;
line-height: 78px;
padding: 0 20px;
width: 100%;
}
/* .Wrap {
margin: 8px auto 0;
width: 1046px;
} */
.layui-tab-content {
position: relative;
}
.layui-no-data {
width: 100%;
height: 500px;
}
.layui-no-data .no-data {
position: absolute;
top: 50%;
height: 50%;
width: 100%;
text-align: center;
font-size: 14px;
line-height: 22px;
}
.layui-no-data .no-data div {
margin-top: 12px;
}
.layuui-radio {
display: inline-flex;
align-items: center;
margin-right: 20px;
}
.layuui-radio .layui-form-radio {
margin: 0;
}
.layuui-radio span {
line-height: 28px;
}
#basicForm {
margin-bottom: 87px;
}
.no-car {
display: flex;
height: 100px;
align-items: center;
justify-content: center;
}
.check-carbrand {
position: absolute;
left: 340px;
top: 0;
}
.w-70 {
width: 150px !important;
}
.address {
display: inline-block;
width: calc(100% - 120px);
}
.select-address {
width: calc(100% - 600px) !important;
margin-left: 20px;
}
</style>
<title>商户编辑</title>
</head>
<body>
<div id="app">
<main>
<div class="Wrap">
<div class="pageTitle">
<span id="addUpdateTitle">创建子商户</span>
</div>
<!-- <div class="edit-box"> -->
<!-- 基本信息 -->
<div id="basicForm">
<form class="layui-form layui-row" autocomplete="off" lay-filter="merchantForm">
<div class="edit-box clearfix">
<div class="grayLine"></div>
<div class="layui-form-item edit-title" style="position: relative">
<div id="basic" class="layui-input-inline">企业基本信息</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">商户名称:</label>
<div class="layui-input-inline">
<input class="layui-input" maxlength="50" name="merchantName" required lay-verify="required" placeholder="请输入商户名称" />
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">商户简称:</label>
<div class="layui-input-inline">
<input class="layui-input" maxlength="15" name="merchantAbbreviation" placeholder="请输入商户简称" />
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">联系电话:</label>
<div class="layui-input-inline">
<input class="layui-input" name="merchantLegalPersonPhone" maxlength="11" required lay-verify="required|phone" placeholder="请输入联系电话" />
<div class="marCheckbox">
<input type="checkbox" name="isloginName" lay-filter="encrypt" lay-skin="primary" title="联系电话同时作为登录账户名" />
<input type="checkbox" name="mesVerifyFlag" lay-filter="encrypt" lay-skin="primary" title="开启短信验证登录" />
</div>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">联系人:</label>
<div class="layui-input-inline">
<input class="layui-input" maxlength="15" name="merchantLegalPerson" placeholder="请输入联系人姓名" />
<div style="width: 100%; height: 28px"></div>
</div>
</div>
</div>
<div class="layui-col-md6 hide" id="sapCode">
<div class="layui-form-item">
<label class="layui-form-label">商户SAP编码:</label>
<div class="layui-input-inline">
<input class="layui-input" maxlength="15" name="sapCode" placeholder="请输入商户SAP编码" />
</div>
</div>
</div>
<!-- <div class="layui-form-item">
<label class="layui-form-label">商户类型:</label>
<div class="layui-input-inline" style="width: 100px; margin: 0">
<select name="merchantType" id="merchantTypeEl" lay-filter="merchantTypeFilter">
<option value="1">个人</option>
<option value="2">企业</option>
</select>
</div>
<div class="layui-input-inline" style="width: 220px">
<input class="layui-input" maxlength="50" lay-verify="merchantOrgcode" name="merchantOrgcode"
id="merchantOrgcodeEl" placeholder="请输入身份证号码" />
</div>
</div> -->
<div class="layui-form-item">
<label class="layui-form-label required">商户地址:</label>
<div class="layui-input-inline">
<div class="layui-bg-white padding10 padding-l20 layui-form">
<div class="layui-input-inline margin-l10 w-70">
<div class="searchBtn">
<select name="select4" id="startp" lay-search></select>
</div>
</div>
<div class="layui-input-inline w-70" style="margin-left: 20px">
<div class="searchBtn">
<select name="select4" id="startc" lay-search></select>
</div>
</div>
</div>
<div id="addMap"></div>
</div>
<div class="layui-input-inline select-address">
<input style="color: #333333 !important" name="merchantAddress" disabled required lay-verify="required" class="layui-input layui-btn-disabled address" id="addrEl" placeholder="请选择商户地址" />
<!-- <div class="m-t-10" id="addrEl">请选择商户地址</div> -->
<button type="button" class="layui-btn" data-type="handleSelectAddr" style="margin-left: 20px">选择地址</button>
</div>
</div>
<!-- <div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-inline">
<button type="button" class="layui-btn" data-type="handleSelectAddr">选择地址</button>
</div>
</div> -->
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">驻店联系人:</label>
<div class="layui-input-inline">
<input class="layui-input" name="residentContact" maxlength="15" placeholder="请输入驻店联系人" />
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">驻店电话:</label>
<div class="layui-input-inline">
<input class="layui-input" name="residentPhone" maxlength="13" placeholder="请输入驻店电话" lay-verify="residentPhone" />
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">营业时间:</label>
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" id="startDate" class="layui-input" name="bussinessBegintime" placeholder="开始时间" />
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" id="endDate" class="layui-input" name="bussinessEndtime" placeholder="结束时间" />
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">经营业务类型:</label>
<div id="busiScopeEl"></div>
</div>
<!-- <div class="layui-form-item" id="custom-scope">
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div>
<div class="layui-input-inline">
<input id="scopeCus" class="layui-input business-scope-cust" maxlength="15"
placeholder="请自定义营业范围,建议不超过10个" />
</div>
<div class="layui-input-inline option-btns">
<button type="button" class="layui-btn btn-no-border" data-type="handleAddScope">
<i class="layui-icon layui-icon-add-circle scope-btn"></i>
</button>
</div>
</div>
</div>
</div> -->
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">主营品牌:</label>
<div class="layui-input-inline" style="position: relative">
<input class="layui-input" placeholder="请输入品牌/子品牌名称搜索" id="brand" />
<button id="checkCarBrand" type="button" class="layui-btn btn-no-border check-carbrand">全选</button>
<div id="carBrandTree" class="hide" style="height: 200px; overflow-y: scroll"></div>
<div id="noCarbrand" class="no-car hide">暂无数据</div>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">门店照片:</label>
<div class="layui-input-inline upload-img-wh">
<div class="upload-img-box">
<div class="icon-add img-add0 show">+</div>
<img class="upload-img upload-img-wh hide" id="img0" src="" />
<input
type="file"
id="upload0"
name="merhcnatImg0"
ref="file"
class="upload upload-img-box upload-img-wh"
accept="image/png, image/jpeg, image/gif, image/jpg"
data-idx="0"
style="opacity: 0"
/>
</div>
</div>
<div class="layui-input-inline upload-img-wh">
<div class="upload-img-box">
<div class="icon-add img-add1 show">+</div>
<img class="upload-img upload-img-wh hide" id="img1" src="" />
<input
type="file"
id="upload1"
name="merhcnatImg1"
ref="file"
class="upload upload-img-box upload-img-wh"
accept="image/png, image/jpeg, image/gif, image/jpg"
data-idx="1"
style="opacity: 0"
/>
</div>
</div>
<div class="layui-input-inline upload-img-wh">
<div class="upload-img-box">
<div class="icon-add img-add2 show">+</div>
<img class="upload-img upload-img-wh hide" id="img2" src="" />
<input
type="file"
id="upload2"
name="merhcnatImg2"
ref="file"
class="upload upload-img-box upload-img-wh"
accept="image/png, image/jpeg, image/gif, image/jpg"
data-idx="2"
style="opacity: 0"
/>
</div>
</div>
<span class="tips">图片格式仅支持JPG,PNG格式,大小1M以内</span>
</div>
</div>
</div>
<div class="edit-box">
<p class="edit-title">账户基本信息</p>
<div class="grayLine"></div>
<div id="subMerchantEl" class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">上级商户:</label>
<div class="layui-input-inline">
<!-- <input class="layui-input layui-btn-disabled" name="parentName" placeholder="请输入上级商户" disabled> -->
<div class="label-text" id="parentName"></div>
</div>
</div>
</div>
<div id="subMerchantModel" class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">上级商户模式:</label>
<div class="layui-input-inline">
<!-- <input class="layui-input layui-btn-disabled" name="parentName" placeholder="请输入上级商户" disabled> -->
<div class="label-text" id="merchantModelName"></div>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">登录账户名:</label>
<div class="layui-input-inline">
<input
class="layui-input"
id="merchantLoginAccountEl"
name="merchantLoginAccount"
maxlength="15"
placeholder="请输入登录账户名"
required
autocomplete="off"
lay-verify="required|merchantLoginAccount"
/>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">登录密码:</label>
<div class="layui-input-inline">
<input
class="layui-input"
type="password"
id="password"
name="merchantLoginPassword"
maxlength="20"
placeholder="请输入密码(必须包含6-20个字母+数字)"
required
autocomplete="off"
lay-verify="required|merchantLoginPassword"
/>
<!-- <button type="button" class="layui-btn form-right hide" id="resetpsw">重置密码</button> -->
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">账户等级:</label>
<div class="layui-input-inline">
<select id="accountLevelEl" name="merchantAccountLevel" lay-filter="accountLevel" required lay-vertify="required" lay-search></select>
</div>
</div>
<div class="layui-form-item hide" id="effectiveShowEl">
<label class="layui-form-label required">账户有效期:</label>
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" id="effectiveStarttime" class="layui-input" name="effectiveStarttime" placeholder="开始时间" />
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" id="expireDate" disabled class="layui-input" name="expireDate" placeholder="结束时间" />
</div>
<button id="sevenday" type="button" class="layui-btn btn-no-border">续7天</button>
<button id="oneyear" type="button" class="layui-btn btn-no-border">续1年</button>
<button id="twoyears" type="button" class="layui-btn btn-no-border">续2年</button>
<button id="fiveyears" type="button" class="layui-btn btn-no-border">续5年</button>
<button id="tenyears" type="button" class="layui-btn btn-no-border">续10年</button>
</div>
</div>
<!-- <div class="layui-form-item" id="effectiveShowEl">
<label class="layui-form-label required">账户有效期:</label>
<div class="layui-input-inline">
<select id="validPeriodEl" name="effectiveTime" required lay-vertify="required" lay-search></select>
</div>
</div> -->
<div class="layui-form-item">
<label class="layui-form-label required">账户类型:</label>
<div class="layui-input-inline w-70" id="accountTypeEl"></div>
</div>
<div class="footer-close">
<button id="firstBtn" class="layui-btn" lay-submit lay-filter="handleFirstSubmit">下一步</button>
<button type="reset" class="layui-btn" data-type="handleCancel">取消</button>
</div>
</div>
</form>
</div>
</div>
<!-- 权限树 -->
<div id="authorityTree">
<div class="edit-box">
<div class="layui-form-item edit-title" style="position: relative">
<div class="layui-input-inline">功能权限</div>
</div>
<!-- 树 -->
<!-- <div class="layui-form-item">
<label class="layui-form-label required">角色权限:</label>
<div class="layui-input-block" id="accountType"> -->
<!-- <input lay-filter="switch" type="checkbox" name="merchantId" value="1" title="引流渠道商" />
<input lay-filter="switch" type="checkbox" name="merchantId" value="2" title="服务商/合作商" /> -->
<!-- </div>
</div> -->
<div class="layui-tab" lay-filter="roleAuth">
<ul class="layui-tab-title"></ul>
<div class="layui-tab-content"></div>
</div>
<div class="footer-close">
<button id="draft" class="layui-btn">存草稿</button>
<button id="preStep" class="layui-btn">上一步</button>
<button id="confirm" class="layui-btn">确定</button>
<button class="layui-btn" data-type="handleCancel">取消</button>
</div>
</div>
</div>
</main>
</div>
<script src="https://img02.glsx.com.cn/layui/layui.js"></script>
<script src="/js/load.js"></script>
<!-- <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=44cc16e43ad7ed3358df507bd0618181&plugin=AMap.Geocoder&plugin=AMap.PlaceSearch&plugin=AMap.Geolocation"></script> -->
<script src="/js/validator.js"></script>
<script>
layui.use(['gtree', 'request', 'helper', 'layer', 'laydate', 'element', 'xmSelect', 'laytpl', 'validator', 'util', 'common'], function () {
var com = layui.common
var tree = layui.gtree
var request = layui.request
var form = layui.form
var laydate = layui.laydate
var $ = layui.$
var validator = layui.validator
var helper = layui.helper
var util = layui.util
var element = layui.element
var editData = {}
var treeObj = null
var all_nodes = []
// 1-创建新商户;2-创建子商户;3-修改
var editLevel = 1
// 1-基本信息;2-权限树
var step = 1
var merchantId = null
var parentMerchantId = null
var accountTypeVisible = false
// 是否工厂
var isFactory = true
var accountInfo = helper.store.get('accountInfo')
var merchantAccountLevel = qs('merchantAccountLevel')
if (merchantAccountLevel == 3 && !accountInfo) {
// 上级是市代,子商户为门店,显示 有效期
$('#effectiveShowEl').removeClass('hide')
$('#effectiveShowEl').addClass('show')
$('#effectiveStarttime').attr('lay-verify', 'required')
$('#expireDate').attr('lay-verify', 'required')
}
var parentInfo = {}
var isFreshSecond = true
var scopeNum = 1
var merchantForm = {
channelId: '',
merchantName: '',
merchantAbbreviation: '',
merchantType: '',
merchantOrgcode: '',
merchantLegalPerson: '',
merchantLegalPersonPhone: '',
isloginName: 0,
mesVerifyFlag:0,
residentContact: '',
residentPhone: '',
bussinessBegintime: '',
bussinessEndtime: '',
lat: '',
lng: '',
merchantAddress: '',
businessType: '',
merchantFiles: []
}
var baseData = {
channelList: [],
carBrandTreeList: [],
accountLevelList: [],
validPeriodList: [],
busiScopeList: [],
accountTypeList: []
}
var provinceInfoList = []
var cityInfo = []
var addressData = {}
const external_data = helper.store.get('external').val
// 省市区
getProvinceList()
// 禁用所有input框的回车事件
var inputs = document.getElementsByTagName('input')
for (let i = 0; i < inputs.length; i++) {
var input = inputs[i]
input.onkeydown = function (event) {
if (event.keyCode == 13) {
event.keyCode = 0
event.returnValue = false
}
}
}
var startDate = laydate.render({
elem: '#startDate', //指定元素
type: 'time',
format: 'HH:mm:ss',
done: function (value, date) {
//监听日期被切换
if (value != '') {
date.month = date.month - 1
endDate.config.min = date
} else {
endDate.config.min = startDate.config.min
}
lay('#startDate').html(value)
}
})
var endDate = laydate.render({
elem: '#endDate', //指定元素
type: 'time',
format: 'HH:mm:ss',
done: function (value, date) {
//监听日期被切换
if (value != '') {
date.month = date.month - 1
startDate.config.max = date
} else {
startDate.config.max = endDate.config.max
}
lay('#endDate').html(value)
}
})
var effectiveStarttime = laydate.render({
elem: '#effectiveStarttime',
format: 'yyyy-MM-dd',
min: helper.dateFormat(new Date()),
done: function (value, date) {
date.month = date.month - 1
date.date = date.date + 1
$('#expireDate').val('')
expireDate.config.min = date
$('#expireDate').removeAttr('disabled')
}
})
var expireDate = laydate.render({
elem: '#expireDate',
format: 'yyyy-MM-dd',
btns: ['clear', 'confirm'],
min: `${new Date().getFullYear()}-${new Date().getMonth() + 1}-${new Date().getDate() + 1}`
})
editLevel = qs('editLevel')
isFactory = qs('isFactory') == 'true'
step = qs('step')
var pwd = $('#password') // 密码输入框
// var resetpsw = $('#resetpsw')
// pwd.attr('readonly', false)
// 重置密码
// resetpsw.on('click', function () {
// pwd.attr('readonly', false)
// pwd.val('')
// })
init()
// 校验
form.verify({
channelId: function (value) {
if (editLevel == 1 && !value) {
return '必填项不能为空'
}
},
merchantOrgcode: function (value) {
var merchantType = $('#merchantTypeEl option:selected').val()
if (value) {
if (merchantType == 1 && !validator.checkIdCard(value)) {
return '请填入正确的身份证'
}
if (value && validator.ISCHINESE2.test(value)) {
return '只能输入数字、字母和符号'
}
}
},
merchantLoginAccount: function (value) {
if (value && value.length < 3) {
return '登录账户名请填入3-15位字符'
}
if (value.length == 11 && !isNaN(value)) {
return '登录账户名不可为 11 位纯数字'
}
},
merchantLoginPassword: function (value) {
if (value) {
if (value.length < 6 || value.length > 20) {
return '登录密码请填入6-20位字符'
}
if (!/^(?=.*\d)(?=.*[a-zA-Z])[\s\S]{6,20}$/.test(value)) {
return '您输入的密码格式不正确,必须同时包含字母、数字。'
}
}
},
residentPhone: function (value) {
if (value && !validator.checkPhoneNumberTwo(value)) {
return '请填入正确的驻店电话'
}
},
otherReq: function (value, item) {
var verifyName = $(item).attr('name'),
verifyType = $(item).attr('type'),
formElem = $(item).parents('.layui-form'), //获取当前所在的form元素,如果存在的话
verifyElem = formElem.find('input[name=' + verifyName + ']'), //获取需要校验的元素
isTrue = verifyElem.is(':checked'), //是否命中校验
focusElem = verifyElem.next().find('i.layui-icon') //焦点元素
if (!isTrue || !value) {
//定位焦点
focusElem.css(verifyType == 'radio' ? { color: '#FF5722' } : { 'border-color': '#FF5722' })
//对非输入框设置焦点
focusElem
.first()
.attr('tabIndex', '1')
.css('outline', '0')
.blur(function () {
focusElem.css(verifyType == 'radio' ? { color: '' } : { 'border-color': '' })
})
.focus()
return '必填项不能为空'
}
}
})
form.on('select(merchantTypeFilter)', function (data) {
if (data.value == 1) {
$('#merchantOrgcodeEl').attr('placeholder', '请输入身份证号码')
} else {
$('#merchantOrgcodeEl').attr('placeholder', '请输入组织机构号码')
}
})
// select 选择触发
form.on('select(accountLevel)', function (data) {
if (!accountInfo) {
if (data.value == 4) {
$('#effectiveShowEl').removeClass('hide')
$('#effectiveShowEl').addClass('show')
$('#effectiveStarttime').attr('lay-verify', 'required')
$('#expireDate').attr('lay-verify', 'required')
} else {
$('#effectiveShowEl').removeClass('show')
$('#effectiveShowEl').addClass('hide')
$('#effectiveStarttime').removeAttr('lay-verify')
$('#expireDate').removeAttr('lay-verify', 'required')
}
}
})
form.on('submit(handleFirstSubmit)', function (data) {
// document.querySelector('#basic').scrollIntoView(true)
var loading = layer.load('Loading...', {
shade: [0.1, '#fff'] //0.1透明度的白色背景
})
var formData = data.field
var params = {
isloginName: 0,
mesVerifyFlag:0
}
var fieldToFormNameList = [
'merchantName',
'merchantAbbreviation',
'merchantType',
'merchantOrgcode',
'merchantLegalPerson',
'merchantLegalPersonPhone',
'residentContact',
'residentPhone',
'merchantLoginAccount',
'merchantLoginPassword',
'merchantAccountLevel'
// 'effectiveStarttime',
// 'expireDate'
]
if (formData.isloginName == 'on') {
params.isloginName = 1
}
if (formData.mesVerifyFlag == 'on') {
params.mesVerifyFlag = 1
}
if (formData.bussinessBegintime) {
merchantForm.bussinessBegintime = formData.bussinessBegintime
params.bussinessBegintime = formData.bussinessBegintime
} else {
params.bussinessBegintime = ''
}
if (formData.bussinessEndtime) {
merchantForm.bussinessEndtime = formData.bussinessEndtime
params.bussinessEndtime = formData.bussinessEndtime
} else {
params.bussinessEndtime = ''
}
if (merchantForm.lat) {
params.lat = merchantForm.lat
params.lng = merchantForm.lng
params.merchantAddress = merchantForm.merchantAddress
}
if (merchantForm.provinceName) {
params.provinceName = merchantForm.provinceName
params.provinceCode = merchantForm.provinceCode
params.cityName = merchantForm.cityName
params.cityCode = merchantForm.cityCode
}
$.each(fieldToFormNameList, function (index, item) {
merchantForm[item] = formData[item] || ''
params[item] = formData[item] || ''
})
if (formData.effectiveStarttime) params.effectiveStarttime = new Date(formData.effectiveStarttime)
if (formData.expireDate) params.expireDate = new Date(formData.expireDate)
// if (merchantId) {
// params.effectiveTime = merchantForm.effectiveTime
// }
if (editLevel == 1) {
merchantForm.channelId = formData.channelId
params.channelId = formData.channelId
} else {
params.channelId = merchantForm.channelId
}
if (parentInfo.channelId == 2) {
params.sapCode = formData.sapCode
}
var checkClassNameList = [
{
attr: 'businessType',
toString: ','
},
{
attr: 'accounttypeId',
toString: ','
}
]
$.each(checkClassNameList, function (index, item) {
var checkedArr = []
$('input[class=' + item.attr + ']:checked').each(function () {
checkedArr.push($(this).val())
})
if (checkedArr.length) {
if (item.toString) {
merchantForm[item.attr] = checkedArr.join(item.toString)
params[item.attr] = checkedArr.join(item.toString)
}
} else {
merchantForm[item.attr] = ''
params[item.attr] = ''
}
})
if (!params.accounttypeId) {
layer.msg('账户类型不能为空', {
icon: 5,
anim: 6
})
layer.close(loading)
return false
}
var elList = $('.business-scope-cust')
var tempList = []
$.each(elList, function (index, item) {
if (item.value) {
tempList.push(item.value)
}
})
// merchantForm.businessScopeCustomize = tempList.join(',')
// params.businessScopeCustomize = tempList.join(',')
// if (treeObj) merchantForm.merchantBrandMain = treeObj.getCheckedNodes(true)
// params.merchantBrandMain = findId(merchantForm.merchantBrandMain).join(',')
if (treeObj) {
let getCheckedNodes = treeObj.getCheckedNodes(true)
const getCheckedKeys = treeObj.getCheckedNodes(true).map(item => item.id)
if(!getCheckedKeys?.length){
layer.msg('主营品牌不能为空', {
icon: 5,
anim: 6
})
}
getCheckedNodes = getCheckedNodes.filter(item => item.children)
merchantForm.merchantBrandList = getCheckedNodes.map(car => {
let merchantBrandId = []
car.children.forEach(item => {
if (getCheckedKeys.includes(item.id)) {
merchantBrandId.push(item.id)
}
})
return {
cars: car.id,
merchantBrandId
}
})
params.merchantBrandListJson = JSON.stringify(merchantForm.merchantBrandList)
}
if (merchantForm.merchantFiles.length) {
params.merchantFiles = JSON.stringify(merchantForm.merchantFiles)
}
if (merchantId) {
params.id = merchantId
if (!isFactory) {
params.parentId = parentInfo.parentId
params.merchantModel = parentInfo.merchantModel
}
params.method = 'merchants.api.merchant.updateMerchant'
} else if (editLevel == 1) {
params.method = 'merchants.api.merchant.saveMerchant'
} else if (editLevel == 2) {
if (!isFactory) {
params.parentId = parentInfo.parentId
params.merchantModel = parentInfo.merchantModel
}
params.method = 'merchants.api.merchant.saveMerchant'
}
// 保存状态 1.草稿 2.发布 3.注销 4.过期
if (merchantForm.status) {
params.status = merchantForm.status
} else {
params.status = 1
}
verifyMerchantName(params.merchantName,params,loading)
layer.close(loading)
return false
})
function nextStepRequest(params,loading){
params.createdSource = 1
request(params, function (res) {
if (res.code == '0') {
layer.close(loading)
if (editLevel == 3) {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
} else {
if (!merchantId) {
merchantId = res.data
}
merchantForm.merchantAccountLevel = parseInt(merchantForm.merchantAccountLevel)
getMerchantApi(merchantId, function (respone) {
form.val('merchantForm', respone.data)
merchantForm = respone.data
if (merchantForm.merchantAddress) {
$('#addrEl').text(merchantForm.merchantAddress)
}
accountTypeVisible = true
var el = $('#accountTypeEl')
el.empty()
recoveryFile()
getAccountType()
baseIsShow(false)
treeIsShow(true)
if (isFreshSecond) {
getById()
isFreshSecond = false
}
})
}
}
})
layer.close(loading)
}
function verifyMerchantName(name,paramsM,loading){
var params = {
method: 'merchants.api.merchant.checkMerchantNameRepeat',
merchantName: paramsM.merchantName
}
request(params, function (res) {
if(res && res.data == true){
return nextStepRequest(paramsM,loading)
}else if(res && res.data ==false){
return verifyDialog(paramsM,loading)
}
})
}
function verifyDialog(params,loading){
// 验证商户名是否重复
layer.confirm('商户名称已经被使用,是否确定继续使用', {
title: "提示",
btn: ['确定','取消'] //可以无限个按钮
,btn2: function(index, layero){
//按钮【按钮二】的回调
layer.close(index);
layer.close(loading)
}
}, function(index, layero){
//按钮【按钮一】的回调
nextStepRequest(params,loading)
})
}
function findId(nodeList) {
var idList = []
$.each(nodeList, function (index, item) {
idList.push(item.id)
})
return idList
}
// 按钮事件绑定
var btnHandle = {
// 选择地址
handleSelectAddr: function () {
helper.store.set('merchantMapObj', merchantForm)
layer.open({
type: 2,
title: '选择地址',
area: ['900px', '600px'],
btn: ['确定', '取消'],
content: 'map.html',
yes: function (index, layero) {
var body = layer.getChildFrame('body', index)
body.find('#mapBtn').click()
var res = helper.store.get('merchantMapObj')
if (res.lat && res.merchantAddress) {
merchantForm.lat = res.lat
merchantForm.lng = res.lng
merchantForm.merchantAddress = res.merchantAddress
var fullAddress = ''
var provincecode = ''
// if (res.geocoderAddress) {
// fullAddress = res.geocoderAddress.addressComponent
// provincecode = res.geocoderAddress.adcode
// addressData.fullAddress = res.geocoderAddress.addressComponent
// addressData.provincecode = res.geocoderAddress.adcode
// } else {
fullAddress = res.geocoderAddress.addressComponents
provincecode = res.geocoderAddress.content.address_detail.adcode
// }
// 获取省市
var provinceIdx = fullAddress.province
var cityIdx = fullAddress.city ? fullAddress.city : fullAddress.district
// const municipalities = ['北京市', '天津市', '上海市', '重庆市']
// var municipality = municipalities.find(item => item == provinceIdx)
// if (municipality) {
// cityIdx = cityIdx.slice(0, 2) + '城区'
// if (municipality === '重庆市') {
// provincecode = provincecode.slice(0, 4)
// provincecode == 5001 ? (cityIdx = cityIdx.slice(0, 2) + '城区') : (cityIdx = cityIdx.slice(0, 2) + '郊县')
// }
// }
// 判断省市是否匹配
// if (merchantForm.provinceName) {
// if (merchantForm.provinceName !== provinceIdx || merchantForm.cityName !== cityIdx) {
// layer.open({
// title: '提示',
// content: '您选择的地址错误,请重新选择'
// })
// return
// }
// }
$('#addrEl').val(merchantForm.merchantAddress)
var province = provinceInfoList.find(item => item.name == provinceIdx)
$('#startp').val(province.name)
cityInfo = province.districts
merchantForm.provinceName = province.name
merchantForm.provinceCode = province.code
com.getSelect({
id: 'startc',
value: 'name',
text: 'name',
data: cityInfo,
link: 'startp',
// isFirst: false,
select: function (data) {
const { value } = data
if (value) {
merchantForm.cityName = value
var cityChange = cityInfo.find(item => item.cityName == value)
merchantForm.cityCode = cityChange.code
$('#addrEl').val('')
}
}
})
var city = cityInfo.find(item => item.name == cityIdx)
merchantForm.cityCode = city.code
merchantForm.cityName = city.name
$('#startc').val(merchantForm.cityName)
form.render('select')
layer.close(index)
} else {
layer.msg('请选择地址', {
icon: 5
})
}
},
end: function () {
helper.store.remove('merchantMapObj')
}
})
},
// 添加范围
handleAddScope: function (txt) {
if (scopeNum < 10) {
scopeNum = scopeNum + 1
var parent = $('#custom-scope')
var subParent = $('<div class="layui-form-item"><label class="layui-form-label"></label></div>')
var child1 = $('<div class="layui-input-inline"></div>')
var inputEl = $('<input class="layui-input business-scope-cust" maxlength="15" placeholder="请自定义营业范围,建议不超过10个">')
var child2 = $('<div class="layui-input-inline"></div>')
var addBtn = $('<button type="button" class="layui-btn btn-no-border"><i class="layui-icon layui-icon-add-circle"></i></button>')
var deleteBtn = $('<button type="button" class="layui-btn btn-no-border"><i class="layui-icon layui-icon-reduce-circle"></i></button>')
if (txt) {
inputEl.val(txt)
}
addBtn.bind('click', function (e) {
btnHandle.handleAddScope()
})
deleteBtn.bind('click', function (e) {
scopeNum = scopeNum - 1
var el = $(this).parent().parent()
el.remove()
})
child1.append(inputEl)
child2.append(addBtn)
child2.append(deleteBtn)
subParent.append(child1)
subParent.append(child2)
parent.append(subParent)
}
},
handleCancel: function () {
go('merchant', 'index')
return false
}
}
var checkAll = false
var checkCarBrand = $('#checkCarBrand')
// 主营品牌全选
checkCarBrand.on('click', function () {
checkAll = !checkAll
treeObj.checkAllNodes(checkAll)
if (checkAll) {
checkCarBrand.html('全不选')
} else {
checkCarBrand.html('全选')
}
})
$('.layui-btn').on('click', function () {
var type = $(this).data('type')
if (btnHandle[type]) {
btnHandle[type]()
}
})
$('.upload').on('change', function (e) {
var idx = $(this).data('idx')
var imgEl = $('#img' + idx)
var el = $('#upload' + idx)
var addEl = $('.img-add' + idx)
var reader = new FileReader()
var fileInfo = el[0].files[0]
reader.readAsDataURL(fileInfo)
reader.onload = function (e) {
if (e) {
var imgFile = e.target.result
var base64 = fileInfo.name.split('.')[1] + '@' + imgFile.split(',')[1]
var params = {
method: 'glsx.accounts.biz.common.pictureUpload',
file: base64
}
request(
params,
function (result) {
merchantForm.merchantFiles[idx] = {
fileUrl: result.data,
fileName: ''
}
imgEl.attr('src', result.data)
imgEl.removeClass('hide')
imgEl.addClass('show')
addEl.removeClass('show')
addEl.addClass('hide')
},
{},
['file'],
true
)
}
}
reader.onload()
})
$('#sevenday').on('click', function () {
var startTime = new Date(new Date().setHours(0, 0, 0, 0))
var endTime = startTime * 1 + 86400 * 7 * 1000
$('#effectiveStarttime').val(helper.dateFormat(startTime))
$('#expireDate').val(helper.dateFormat(endTime))
$('#expireDate').removeAttr('disabled')
})
$('#oneyear').on('click', function () {
var startTime = new Date(new Date().setHours(0, 0, 0, 0))
var endTime = startTime.setFullYear(startTime.getFullYear() + 1)
$('#effectiveStarttime').val(helper.dateFormat(new Date(new Date().setHours(0, 0, 0, 0))))
$('#expireDate').val(helper.dateFormat(endTime))
$('#expireDate').removeAttr('disabled')
})
$('#twoyears').on('click', function () {
var startTime = new Date(new Date().setHours(0, 0, 0, 0))
var endTime = startTime.setFullYear(startTime.getFullYear() + 2)
$('#effectiveStarttime').val(helper.dateFormat(new Date(new Date().setHours(0, 0, 0, 0))))
$('#expireDate').val(helper.dateFormat(endTime))
$('#expireDate').removeAttr('disabled')
})
$('#fiveyears').on('click', function () {
var startTime = new Date(new Date().setHours(0, 0, 0, 0))
var endTime = startTime.setFullYear(startTime.getFullYear() + 5)
$('#effectiveStarttime').val(helper.dateFormat(new Date(new Date().setHours(0, 0, 0, 0))))
$('#expireDate').val(helper.dateFormat(endTime))
})
$('#tenyears').on('click', function () {
var startTime = new Date(new Date().setHours(0, 0, 0, 0))
var endTime = startTime.setFullYear(startTime.getFullYear() + 10)
$('#effectiveStarttime').val(helper.dateFormat(new Date(new Date().setHours(0, 0, 0, 0))))
$('#expireDate').val(helper.dateFormat(endTime))
})
function baseIsShow(isShow) {
if (isShow) {
$('#basicForm').show()
} else {
$('#basicForm').hide()
}
}
function treeIsShow(isShow) {
if (isShow) {
$('#authorityTree').show()
} else {
$('#authorityTree').hide()
}
}
function init() {
// var index = layer.load(2, {
// shade: true,
// time: 10 * 1000
// }); //又换了种风格,并且设定最长等待10秒
//关闭
// layer.close(index);
if (step == 1) {
getPeriod()
baseIsShow(true)
treeIsShow(false)
// if (merchantId) {
// resetpsw.removeClass('hide')
// resetpsw.addClass('show')
// }
if (isFactory) {
$('#subMerchantEl').hide()
$('#subMerchantModel').hide()
}
} else {
baseIsShow(false)
treeIsShow(true)
}
// 创建商户
if (editLevel == 1) {
if (!merchantId) {
getChannel()
$('#accountLevelEl').attr('disabled', true)
getBusiScope()
getCarBrandTree()
getAccountLevel()
getAccountType()
} else {
$('#validPeriodEl').attr('disabled', true)
$('#merchantLoginAccountEl').attr('disabled', true)
$('#channelEl').attr('required')
// $('#channelEl').attr('disabled', true)
}
} else {
if (!merchantId) {
merchantId = qs('id')
}
// if (merchantId) {
// resetpsw.removeClass('hide')
// resetpsw.addClass('show')
// }
if (editLevel == 3) {
$('#firstBtn').text('确定')
$('#preStep').remove()
if (step == 1) {
$('#validPeriodEl').attr('disabled', true)
$('#merchantLoginAccountEl').attr('disabled', true)
accountTypeVisible = true
$('#accountLevelEl').attr('disabled', true)
}
} else {
if (!merchantId && step == 1) {
getBusiScope()
getCarBrandTree()
}
}
if (isFactory) {
getAccountLevel()
getMerchantInfo()
} else {
// 创建/编辑子商户
if (!parentMerchantId) {
parentMerchantId = qs('parentId')
}
$('#validPeriodEl').attr('disabled', true)
// $('#channelEl').attr('disabled', true)
if (editLevel == 3 || (editLevel == 2 && !merchantId)) {
getParentInfo()
} else {
$('#merchantLoginAccountEl').attr('disabled', true)
$('#accountLevelEl').attr('disabled', true)
}
}
}
}
// function bindEvent() {
// $('#brand').on(
// 'input',
// helper.debounce(function () {
// var txt = $(this).val()
// if (!txt) {
// treeObj.showNodes(all_nodes)
// } else {
// var nodesList = treeObj.getNodesByParamFuzzy('label', txt)
// show_nodes = helper.findShowNode(nodesList, all_nodes)
// treeObj.hideNodes(all_nodes)
// treeObj.showNodes(show_nodes)
// }
// }, 500)
// )
// }
function bindEvent() {
$('#brand').on(
'input',
helper.debounce(function () {
var txt = $(this).val();
if (!txt) {
treeObj.showNodes(all_nodes);
} else {
var nodesList = treeObj.getNodesByParamFuzzy('label', txt);
var showNodes = [];
nodesList.forEach(function(node) {
showNodes.push(node); // 把当前匹配的节点加入显示列表
// 如果匹配的节点有父节点,也将其父节点加入显示列表
var parentNode = node.getParentNode();
if (parentNode && showNodes.indexOf(parentNode) === -1) {
showNodes.push(parentNode);
}
// 如果匹配的是一级菜单节点,同时把它的所有子节点加入显示列表
if (!parentNode && node.children) {
showNodes = showNodes.concat(node.children);
}
});
// 去除重复节点
showNodes = uniqueNodes(showNodes);
// 先隐藏所有节点,再显示匹配的节点及其相关的父或子节点
treeObj.hideNodes(all_nodes);
treeObj.showNodes(showNodes);
}
}, 500)
);
}
// unique 方法用于确保没有重复的节点
function uniqueNodes(nodes) {
var uniqueNodes = [];
var uniqueKeys = {};
nodes.forEach(function(node) {
if (!uniqueKeys[node.tId]) {
uniqueKeys[node.tId] = true;
uniqueNodes.push(node);
}
});
return uniqueNodes;
};
function setCheckbox(checkedStr, attr) {
if (!checkedStr || !checkedStr.length) {
return false
}
var list = []
if (layui._isArray(checkedStr)) {
list = checkedStr
} else {
list = checkedStr.split(',')
}
$.each(list, function (index, item) {
$('input[class=' + attr + ']').attr('checked', true)
})
}
function getMerchantApi(id, fn) {
var params = {
method: 'merchants.api.merchant.findMerchantDetail',
id: id
}
request(params, function (res) {
fn && fn(res)
})
}
// 子商户 - 获取父商户信息
function getParentInfo() {
getMerchantApi(parentMerchantId, function (res) {
var data = res.data
parentInfo = {
parentId: data.id,
parentName: data.merchantName + '(' + data.merchantNo + ')',
parentAccountType: data.accountType,
parentMerchantAccountLevel: data.merchantAccountLevel,
channelId: data.channelId,
// effectiveTime: data.effectiveTime,
merchantModelName: data.merchantModelName ? data.merchantModelName : '无',
merchantModel: data.merchantModel
}
merchantForm.channelId = parentInfo.channelId
if (parentInfo.channelId == 2) {
$('#sapCode').removeClass('hide')
}
var attrList = ['parentName', 'merchantModelName']
$.each(attrList, function (index, item) {
$('#' + item).text(parentInfo[item])
})
form.val('merchantForm', parentInfo)
if (editLevel == 3) {
getMerchantInfo()
$('#accountLevelEl').attr('disabled', true)
} else {
if (step == 1) {
getAccountType()
}
}
if (step == 1) {
getAccountLevel()
}
})
}
// 获取商户信息
function getMerchantInfo() {
getMerchantApi(merchantId, function (res) {
form.val('merchantForm', res.data)
merchantForm = res.data
if (!isFactory) {
merchantForm.channelId = parentInfo.channelId
}
if (merchantForm.merchantAddress) {
$('#addrEl').text(merchantForm.merchantAddress)
}
if (merchantForm.status != 1) {
$('#draft').remove()
}
if (merchantForm.merchantType == 2) {
$('#merchantOrgcodeEl').attr('placeholder', '请输入组织机构号码')
}
if (step == 1) {
getBusiScope()
getCarBrandTree()
getAccountType()
recoveryBusiScopeCus()
recoveryFile()
} else {
getById()
}
})
}
// 渠道
function getChannel() {
getDictData('channel', function (res) {
baseData.channelList = res.data
setSelectOption('#channelEl', 'channelList', 'dictValue', 'dictLabel')
})
}
// 品牌
function getCarBrandTree() {
var params = {
method: 'merchants.api.merchantCommon.getCarbrandTree'
}
request(params, function (res) {
baseData.carBrandTreeList = res.data
if (res.data && res.data.length) {
$('#carBrandTree').removeClass('hide')
var checkedList = []
if (editLevel == 3 && merchantForm.merchantBrandMain) {
// checkedList = merchantForm.merchantBrandMain.split(',')
checkedList = merchantForm.merchantBrandMain.replaceAll(';', ',').split(',')
$.each(checkedList, function (index, item) {
checkedList[index] = parseInt(item)
})
}
treeObj = tree.create('carBrandTree', res.data, {
checkedList: checkedList
})
if (checkedList) {
treeObj.checkNodes(checkedList)
}
all_nodes = treeObj.transformToArray(treeObj.getNodes())
bindEvent()
} else {
$('#noCarbrand').removeClass('hide')
}
})
}
// 获取字典数据
function getDictData(dictType, fn) {
var params = {
method: 'merchants.api.menu.findAllDictData',
dictType: dictType
}
request(params, function (res) {
fn && fn(res)
})
}
// 设置option
function setSelectOption(elName, listName, optionId, optionLabel) {
var el = $(elName)
$.each(baseData[listName], function (index, item) {
el.append(new Option(item[optionLabel], item[optionId]))
})
form.render('select')
}
// 设置input值
function setInput(elName, value) {
$(elName).val(value)
}
// 账户等级
function getAccountLevel() {
getDictData('account_level', function (res) {
baseData.accountLevelList = res.data
if (!isFactory) {
var tempList = []
$.each(baseData.accountLevelList, function (index, item) {
if (item.dictValue > parentInfo.parentMerchantAccountLevel) {
if (parentInfo.parentMerchantAccountLevel == 1 && item.dictValue == 3) {
} else {
tempList.push(baseData.accountLevelList[index])
}
}
})
baseData.accountLevelList = tempList
}
setSelectOption('#accountLevelEl', 'accountLevelList', 'dictValue', 'dictLabel')
})
}
// 有效期
function getPeriod() {
getDictData('account_validity_period', function (res) {
baseData.validPeriodList = res.data
setSelectOption('#validPeriodEl', 'validPeriodList', 'dictValue', 'dictLabel')
})
}
// 营业范围
function getBusiScope() {
getDictData('business_type', function (res) {
baseData.busiScopeList = res.data
var checkedList = []
if (editLevel == 3 && merchantForm.businessType) {
checkedList = merchantForm.businessType.split(',')
}
var el = $('#busiScopeEl')
$.each(baseData.busiScopeList, function (index, item) {
var optionEl = $(
'<input type="checkbox" class="businessType" name="businessType[' + item.dictValue + ']" title=' + item.dictLabel + ' value="' + item.dictValue + '" lay-skin="primary">'
)
if (item.dictValue <= 6) {
optionEl.attr('checked', true)
optionEl.attr('disabled', true)
}
el.append(optionEl)
form.render('checkbox')
})
})
}
// 恢复自定义营业范围
function recoveryBusiScopeCus() {
if (merchantForm.businessScopeCustomize) {
var scopeCusList = merchantForm.businessScopeCustomize.split(',')
$.each(scopeCusList, function (index, item) {
if (index != 0) {
btnHandle.handleAddScope(item)
} else {
$('#scopeCus').val(item)
}
})
scopeNum = scopeCusList.length
}
}
// 恢复图片
function recoveryFile() {
merchantForm.merchantFiles = []
$.each(merchantForm.merchantFileResponses, function (index, item) {
var imgEl = $('#img' + index)
var el = $('#upload' + index)
var addEl = $('.img-add' + index)
merchantForm.merchantFiles[index] = {
fileUrl: item.fileUrl,
fileName: item.fileName
}
imgEl.attr('src', item.fileUrl)
imgEl.removeClass('hide')
imgEl.addClass('show')
addEl.removeClass('show')
addEl.addClass('hide')
})
}
// 账户类型
function getAccountType() {
getDictData('account_type', function (res) {
baseData.accountTypeList = res.data
var checkedList = []
if (merchantId && merchantForm.accountType) {
checkedList = merchantForm.accountType.split(',')
}
var el = $('#accountTypeEl')
$.each(baseData.accountTypeList, function (index, item) {
if (parentMerchantId) {
var parentLevelList = parentInfo.parentAccountType.split(',')
for (var k = 0; k <= parentLevelList.length; k++) {
if (item.dictValue == parseInt(parentLevelList[k])) {
var optionEl = $('<input type="checkbox" class="accounttypeId" name="accountType[' + item.dictValue + ']" title=' + item.dictLabel + ' value="' + item.dictValue + '">')
if (accountTypeVisible) {
optionEl.attr('disabled', true)
}
// 修改-回显
if (merchantId) {
for (var i = 0; i <= checkedList.length; i++) {
if (checkedList[i] == item.dictValue) {
optionEl.attr('checked', true)
break
}
}
}
el.append(optionEl)
form.render('checkbox')
break
}
}
} else {
var optionEl = $('<input type="checkbox" class="accounttypeId" name="accountType[' + item.dictValue + ']" title=' + item.dictLabel + ' value="' + item.dictValue + '">')
if (accountTypeVisible) {
optionEl.attr('disabled', true)
}
// 修改-回显
if (merchantId) {
for (var i = 0; i <= checkedList.length; i++) {
if (checkedList[i] == item.dictValue) {
optionEl.attr('checked', true)
break
}
}
}
el.append(optionEl)
form.render('checkbox')
}
})
})
}
// 省市区
function getProvinceList() {
var params = {
keyword: '中国',
extensions_code: 1,
sub_admin: 2
}
let data = ''
for (let key in params) {
data += '&' + key + '=' + params[key]
}
// let path = 'http://eshield.dev.glsx.com.cn/nesi/apiRegion/search?'
let path = external_data.provinceUrl
path = path + data
const pro = fetch(path).then(res => {
console.log(res, 'res')
return res.json()
})
pro.then(r => {
provinceInfoList = JSON.parse(r.data).districts[0].districts
com.getSelect({
id: 'startp',
name: 'provinceName',
url: '/area/list',
// value: 'provinceId',
data: provinceInfoList,
value: 'name',
text: 'name',
param: {},
select: function (data) {
const { value } = data
if (value) {
// var province = provinceInfoList.find(item => item.provinceId == value)
var province = provinceInfoList.find(item => item.name == value)
cityInfo = province.districts
merchantForm.provinceCode = province.code
merchantForm.provinceName = province.name
$('#addrEl').val('')
} else {
cityInfo = []
merchantForm.provinceCode = ''
merchantForm.provinceName = ''
}
merchantForm.cityCode = ''
merchantForm.cityName = ''
com.getSelect({
id: 'startc',
name: 'cityName',
url: '/area/list',
value: 'name',
text: 'name',
data: cityInfo,
link: 'startp',
select: function (data) {
const { value } = data
if (value) {
// var city = cityInfo.find(item => item.cityId == value)
var city = cityInfo.find(item => item.name == value)
merchantForm.cityCode = city.code
merchantForm.cityName = city.name
} else {
merchantForm.cityCode = ''
merchantForm.cityName = ''
}
}
})
}
})
})
// var map = new AMap.Map('district', {
// resizeEnable: true
// })
// AMap.plugin(['AMap.DistrictSearch'], () => {
// var opts = {
// subdistrict: 2, //返回下一级行政区
// level: 'city', //查询的范围
// showbiz: true //查询行政级别为 市
// }
// var districtSearch = new AMap.DistrictSearch(opts)
// districtSearch.search('中国', (status, result) => {
// provinceInfoList = result.districtList[0].districtList
// com.getSelect({
// id: 'startp',
// name: 'provinceName',
// url: '/area/list',
// // value: 'provinceId',
// data: provinceInfoList,
// value: 'name',
// text: 'name',
// param: {},
// select: function (data) {
// const { value } = data
// if (value) {
// // var province = provinceInfoList.find(item => item.provinceId == value)
// var province = provinceInfoList.find(item => item.name == value)
// cityInfo = province.districtList
// merchantForm.provinceCode = province.adcode
// merchantForm.provinceName = province.name
// $('#addrEl').val('')
// } else {
// cityInfo = []
// merchantForm.provinceCode = ''
// merchantForm.provinceName = ''
// }
// merchantForm.cityCode = ''
// merchantForm.cityName = ''
// com.getSelect({
// id: 'startc',
// name: 'cityName',
// url: '/area/list',
// value: 'name',
// text: 'name',
// data: cityInfo,
// link: 'startp',
// select: function (data) {
// const { value } = data
// if (value) {
// // var city = cityInfo.find(item => item.cityId == value)
// var city = cityInfo.find(item => item.name == value)
// merchantForm.cityCode = city.adcode
// merchantForm.cityName = city.name
// } else {
// merchantForm.cityCode = ''
// merchantForm.cityName = ''
// }
// }
// })
// }
// })
// })
// })
}
// 数 - start
var laytpl = layui.laytpl
var xmSelect = layui.xmSelect
var check_arr = []
var requestList = []
var templateData = {}
var selectEl = {}
var treeData = {}
var menuFunTreeData = [] // 商户的菜单权限树数据
var active = {
/**
* 第一级tab添加
* item: {name: 选项卡名称, value: 选项卡值}
* roleAuth: 选项卡过滤器的名称 lay-filter绑定的名字
* content: 一个放置模板的视图容器,用于呈现渲染结果 带有id的div
* id:选项卡标题的lay-id属性值
* 需要引入laytpl 模块
* rolesAuth:模板的id
* view 放置模板的视图容器的dom
* templateData:用于渲染模板的数据
* productList:复选下拉框的list,修改过的数据{name: '', value: ''}
* products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用
*/
tabAdd: function (item, productList) {
// 渠道的id,一层选项卡的id
var id = item.value
// roleAuth 一层选项卡过滤器的名称
element.tabAdd('roleAuth', {
title: item.title,
// 放置模板视图的上一级div
content: '<div id="role' + id + '"></div>',
// 选项卡标题的lay-id属性值
id: id
})
var getTpl = `<form class="layui-form layui-form-pane layui-tab-form" action="">
<div class="layui-form-item" pane>
<label class="layui-form-label">选择产品:</label>
<div class="layui-input-block" id="project${id}">
</div>
</div>
</form>
<div style="margin-left: 30px;">请选择产品权限</div>
<div class="layui-tab layui-tree-box" lay-filter="treeTab{{d.id}}">
<ul class="layui-tab-title"></ul>
<div class="layui-tab-content">
<div class="layui-no-data show" id="nodata${id}">
<div class="no-data">
<img src="../../css/img/no-data.png" />
<div>请先选择产品</div>
</div>
</div>
</div>
</div>`
view = document.getElementById('role' + id)
templateData.id = id // 渲染模版的数据
laytpl(getTpl).render(templateData, function (html) {
view.innerHTML = html
})
var products = menuFunTreeData.find(item => item.accounttypeId == id).products
products.forEach(i => {
var str = $('<input lay-filter="filter" data-id="' + id + '" type="checkbox" name="check[' + id + ']" value="' + i.productId + '" title="' + i.productName + '" lay-skin="primary" />')
$('#project' + id).append(str)
if (productList) {
productList.forEach(j => {
if (j.productId == i.productId) {
str.attr('checked', true)
}
})
}
form.render()
})
},
// tab删除
tabDelete: function (name, id) {
element.tabDelete(name, id)
},
// tab Change
tabChange: function (name, id) {
element.tabChange(name, id)
if (name == 'roleAuth') {
$(`#nomenu${id}`).html('请选择产品')
}
},
/**
* 第二级选项卡
* treeTabAdd 产品的权限添加
* item: {name: 选项卡名称, value: 选项卡值}
* id 第一级选项卡的item.value
* filterName: 过滤器的名称 lay-filter绑定的值
* treeData:渲染模板的数据,和用来存放对应树实例的对象,
* products:产品list数组
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/
treeTabAdd: function (item, id, treeListData, defaultList) {
var productId = 'tab_' + id + '_' + item.value
var filterName = 'treeTab' + id // 过滤器的名称 lay-filter
element.tabAdd(filterName, {
title: item.name,
content: '<div id="treeTab' + productId + '"></div>', // 放置模板视图的div
id: productId
})
var getTreeTpl = treeAuth.innerHTML, // 获取的模板的id的内容
treeView = document.getElementById('treeTab' + productId) // 放置模板视图的div
treeData[id] = treeData[id] || {}
treeData[id][item.value] = treeData[id][item.value] || {}
treeData[id][item.value].id = productId // 渲染模版的数据
treeData[id][item.value].productId = item.value
laytpl(getTreeTpl).render(treeData[id][item.value], function (html) {
treeView.innerHTML = html
})
var treedom = 'tree_' + productId
if (treeListData && treeListData.length != 0) {
treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
treeData[id][item.value].treeObj.checkAllNodes(true)
}
}
}
// 产品复选框change事件
form.on('checkbox(filter)', function (data) {
var roleId = +data.elem.dataset.id
var projectId = data.value
var isAdd = data.elem.checked
var filterName = 'treeTab' + roleId
// merchantProTreeResponses
var changeObj = menuFunTreeData.find(item => item.accounttypeId == roleId).products.find(i => i.productId == projectId)
var products = menuFunTreeData.find(item => item.accounttypeId == roleId).products
if (isAdd) {
// 新增
active.treeTabAdd(
{
name: changeObj.productName,
value: changeObj.productId
},
roleId,
changeObj.merchantProTreeResponses
)
$(`#nodata${roleId}`).removeClass('show')
$(`#nodata${roleId}`).addClass('hide')
menuFunTreeData.forEach(item => {
if (item.accounttypeId == roleId) {
item.products.forEach(i => {
if (i.productId == projectId) {
if (i.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${roleId}_${projectId}`).removeClass('hide')
$(`#nomenutab_${roleId}_${projectId}`).addClass('show')
} else {
$(`#nomenutab_${roleId}_${projectId}`).removeClass('show')
$(`#nomenutab_${roleId}_${projectId}`).addClass('hide')
}
}
})
}
})
} else {
// 删除
var productId = 'tab_' + roleId + '_' + changeObj.productId
active.tabDelete(filterName, productId)
if (Object.keys(treeData).length != 0) {
delete treeData[roleId][changeObj.productId]
}
if (Object.keys(treeData).length == 0 || Object.keys(treeData[roleId]).length == 0) {
$(`#nodata${roleId}`).removeClass('hide')
$(`#nodata${roleId}`).addClass('show')
}
}
if (Object.keys(treeData).length != 0) {
var productId = 'tab_' + roleId + '_' + changeObj.productId
active.tabChange(filterName, productId)
}
})
// 查询商户的菜单权限树
function findMenuFunTreeByMerId() {
var params = {}
if (parentMerchantId) {
params = {
method: 'merchants.api.merchant.findMenuFunTreeByMerId',
id: merchantId,
parentId: parentMerchantId,
accountlevel: merchantForm.merchantAccountLevel
}
} else {
params = {
method: 'merchants.api.merchant.accountTypeSearchRequest',
ids: merchantForm.accountType,
merchantId: merchantId,
accountLevel: merchantForm.merchantAccountLevel
}
}
request(params, function (res) {
if (res.code == '0') {
menuFunTreeData = res.data
var accountType = $('#accountType')
accountType.empty()
menuFunTreeData.forEach((item, index) => {
var str = $('<input lay-filter="switch" type="checkbox" name="accounttypeId" value="' + item.accounttypeId + '" title="' + item.accounttypeName + '" />')
accountType.append(str)
if (merchantId) {
check_arr.forEach(i => {
if (i.accounttypeId == item.accounttypeId) {
var productData = i
var id = item.accounttypeId
str.attr('checked', true)
var obj = { title: item.accounttypeName, value: item.accounttypeId }
active.tabAdd(obj, productData.products)
}
})
}
})
if (check_arr.length != 0) {
active.tabChange('roleAuth', check_arr[0].accounttypeId)
}
form.render('checkbox')
$(window).resize()
}
})
}
// 根据id获取角色详情
function getById() {
var params = {
method: 'merchants.api.merchant.findPermissionsByMerId',
id: merchantId
}
request(params, function (res) {
if (res.code == '0') {
var accounttypeId = ''
if (res.data) {
check_arr = res.data
}
findMenuFunTreeByMerId()
form.val('roleForm', {
roleName: res.data.roleName,
roleDescription: res.data.roleDescription
})
}
})
}
// 获取角色权限数据requestList
function getAuthList() {
requestList = []
for (var key in treeData) {
var accountObj = treeData[key]
var productList = []
if (Object.keys(accountObj).length != 0) {
for (var i in accountObj) {
var productObj = accountObj[i]
var menuIds = []
var functionIds = []
var functionIdLists = []
var functionValueIdLists = []
if (productObj.treeObj) {
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIds.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
var findIdx = -1
$.each(functionIds, function (idn, n) {
if (n.functionId == m.parentId) {
findIdx = idn
}
})
if (findIdx != -1) {
functionIds[findIdx].functionValue += ';' + m.id + ':' + m.label
} else {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId,
functionValue: m.id + ':' + m.label
})
}
})
$.each(functionIdLists, function (idx, m) {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIds: functionIds,
menuIds: menuIds
})
} else {
productList.push({
productId: productObj.productId,
functionIdList: [],
menuIdList: []
})
}
}
requestList.push({
accountTypeId: key,
products: productList
})
}
}
}
$('#draft').on('click', function () {
getAuthList()
var params = {
merchantId: merchantId,
// accountTypes: JSON.stringify(requestList),
method: 'merchants.api.merchant.updatePermissions',
status: merchantForm.status
}
if (requestList.length != 0) {
params.accountTypes = JSON.stringify(requestList)
} else {
params.accountTypes = JSON.stringify([])
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
return false
})
$('#preStep').on('click', function () {
step = 1
init()
// document.querySelector('#basic').scrollIntoView(true)
})
$('#confirm').on('click', function () {
getAuthList()
if (requestList.length != 0) {
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList)
}
params.method = 'merchants.api.merchant.updatePermissions'
// 草稿
if (merchantForm.status == 1) {
params.status = 2
} else {
params.status = merchantForm.status
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
} else {
layer.msg('请选择产品', {
icon: 5
})
}
return false
})
util.event('lay-active', {
checkAll: function (othis) {
const id = othis.context.dataset.id
const accounttypeId = id.split('_')[1]
const productId = id.split('_')[2]
treeData[accounttypeId][productId].treeObj.checkAllNodes(true)
},
cancelCheckedAll: function (othis) {
const id = othis.context.dataset.id
const accounttypeId = id.split('_')[1]
const productId = id.split('_')[2]
treeData[accounttypeId][productId].treeObj.checkAllNodes(false)
}
})
})
</script>
<script type="text/html" id="treeAuth">
<div style="float: right; margin: 10px;">
<button class="layui-btn layui-btn-sm" data-id="{{d.id}}" lay-active="checkAll">全选</button>
<button class="layui-btn layui-btn-sm" data-id="{{d.id}}" lay-active="cancelCheckedAll">取消全选</button>
</div>
<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>
<div class="layui-no-data show" id="nomenu{{d.id}}">
<div class="no-data">
<img src="../../css/img/no-data.png" />
<div>暂无可选择的菜单功能</div>
</div>
</div>
</script>
</body>
</html>