zjf
2023-02-24 2126cd24b8a0174ac0597340917c0a4595f72254
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
<template>
  <div class="employee-dep-management">
    <p class="title">员工与部门管理 </p>
    <div class="system-content">
      <!-- 左边导航栏 -->
      <div
        v-loading="depLoading"
        class="system-view-nav">
        <div class='system-nav-title'>
          企业组织架构
        </div>
        <el-tree
          ref="tree"
          :data="treeData"
          :expand-on-click-node="false"
          node-key="DepartmentId"
          :props="defaultProps"
          default-expand-all
          highlight-current
          @node-click="changeDepClick">
          <flexbox
            slot-scope="{ node, data }"
            class="node-data">
            <img
              v-if="node.expanded"
              class="node-img"
              src="@/assets/img/fold.png"
              @click="handleExpand('close',node, data)">
            <img
              v-if="!node.expanded"
              class="node-img"
              src="@/assets/img/unfold.png"
              @click="handleExpand('open',node, data)">
            <div class="node-label">{{ data.Name }}</div>
            <!-- <div class="node-label-set">
              <el-button
                v-if="strucSaveAuth"
                type="text"
                size="mini"
                @click.stop="() => append(data)">
                <i class="el-icon-plus"/>
              </el-button>
              <el-button
                v-if="strucUpdateAuth"
                type="text"
                size="mini"
                @click.stop="() => edit(node, data)">
                <i class="el-icon-edit"/>
              </el-button>
              <el-button
                v-if="strucDeleteAuth"
                type="text"
                size="mini"
                @click.stop="() => remove(node, data)">
                <i class="el-icon-close"/>
              </el-button>
            </div> -->
          </flexbox>
        </el-tree>
      </div>
      <!-- 右边内容 -->
      <div class="system-view-table flex-index">
        <div
          class="table-top">
          <div class='table-top__title'>{{tableTopName}}</div>
          <div class="icon-search lt">
            <el-input
              v-model="searchName"
              placeholder="请输入员工名称"
              @keyup.enter.native="searchClick"/>
            <i
              class="el-icon-search"
              @click="searchClick"/>
          </div>
          <div class="icon-search lt">
            <el-input
              v-model="searchPhone"
              placeholder="请输入员工手机号"
              @keyup.enter.native="searchClick"/>
            <i
              class="el-icon-search"
              @click="searchClick"/>
          </div>
          <!--<div class="status">
            <span>状态</span>
            <el-select
              v-model="selectModel"
              :clearable="true"
              placeholder="请选择"
              @change="statusChange">
              <el-option
                v-for="item in statusOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"/>
            </el-select>
          </div>
          <el-button
            v-if="selectionList.length > 0"
            type="primary"
            class="setMultiPosition"
            @click="newBtn">新建员工</el-button>-->
            <el-button
            v-if="selectionList.length > 0"
            type="primary"
            class="setMultiPosition"
            @click="isSetPosition = true">权限名称</el-button>
        </div>
        <!--<flexbox
          v-if="selectionList.length > 0"
          class="selection-bar">
          <div class="selected—title">已选中<span class="selected—count">{{ selectionList.length }}</span>项</div>
          <flexbox class="selection-items-box">
            <flexbox
              v-for="(item, index) in selectionInfo"
              :key="index"
              class="selection-item"
              @click.native="selectionBarClick(item.type)">
              <img
                :src="item.icon"
                class="selection-item-icon" >
              <div class="selection-item-name">{{ item.name }}</div>
            </flexbox>
          </flexbox>
        </flexbox>-->
        <div class="flex-box">
          <el-table
            v-loading="loading"
            id="crm-table"
            :data="tableData"
            :height="tableHeight"
            :cell-style="cellStyle"
            class="n-table--border"
            border
            highlight-current-row
            style="width: 100%; z-index: 0;"
            @header-dragend="handleHeaderDragend"
            @selection-change="handleSelectionChange"
            @row-click="rowClick">
            <el-table-column
              type="selection"
              width="55"/>
            <el-table-column
              prop="Name"
              width="200"
              show-overflow-tooltip
              label="姓名">
              <template slot-scope="scope">
                <div class="status-name">
                  <div
                    v-photo="scope.row.Avatar"
                    v-lazy:background-image="$options.filters.filterUserLazyImg(scope.row.Avatar)"
                    :key="scope.row.Avatar"
                     class="user-img div-photo"/>
 
                  <div :style="{'background-color' : getStatusColor(scope.row.Status)}"/>
                  {{ scope.row.Name }}
                </div>
              </template>
              <template
                slot="header"
                slot-scope="scope">
                <div class="table-head-name">{{ scope.column.label }}</div>
              </template>
            </el-table-column>
            <el-table-column
              v-for="(item, index) in fieldList"
              :key="index"
              :width="item.width"
              :prop="item.field"
              :label="item.value"
              :formatter="tableFormatter"
              show-overflow-tooltip>
              <template
                slot="header"
                slot-scope="scope">
                <div class="table-head-name">{{ scope.column.label }}</div>
              </template>
            </el-table-column>
            <!--<el-table-column label="排序" prop="SortNumber"></el-table-column>-->
            <el-table-column
              prop="operation"
              width='200'
              label="操作">
              <template
                slot="header"
                slot-scope="scope">
                <div class="table-head-name">操作</div>
              </template>
              <template slot-scope="scope">
                <el-button type="text" size="small"  @click='setPosition(scope.row.Id)'>权限名称</el-button>
                <el-button type="text" size="small"  @click='setArea(scope.row)'>销售区域</el-button>
              </template>
            </el-table-column>
            <el-table-column/>
          </el-table>
          <div class="p-contianer" v-if='total>0'>
            <el-pagination
              :current-page="currentPage"
              :page-sizes="pageSizes"
              :page-size.sync="pageSize"
              :total="total"
              class="p-bar"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"/>
          </div>
        </div>
      </div>
    </div>
    <!-- 配置系统职务 -->
    <el-dialog
      title="配置权限名称"
      :visible.sync="isSetPosition"
      width="24%"
      append-to-body
      :before-close="handlePosClose">
      <div class='pushBody'>
        <div class='hintSelect'>
          <span>权限名称:</span>
          <el-select v-model="pushStatus" placeholder="请选择">
            <el-option
              v-for="item in pushOptions"
              :key="item.Id"
              :label="item.Name"
              :value="item.Id">
            </el-option>
          </el-select>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handlePosClose" class='closePushBtn'>取 消</el-button>
        <el-button type="primary" @click="savePos" class='surePushBtn'>提交</el-button>
      </span>
    </el-dialog>
    <!-- 配置区域 -->
    <el-dialog
      title="销售区域"
      :visible.sync="isSetArea"
      width="24%"
      append-to-body
      :before-close="handleAreaClose">
      <div class='pushBody'>
        <div class='hintSelect'>
          <span>销售区域:</span>
          <el-select v-model="areaStatus" multiple placeholder="请选择">
            <el-option
              v-for="item in areaOptions"
              :key="item.ID"
              :label="item.ProvinceName"
              :value="item.ProvinceName">
            </el-option>
          </el-select>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleAreaClose" class='closePushBtn'>取 消</el-button>
        <el-button type="primary" @click="saveArea" class='surePushBtn'>提交</el-button>
      </span>
    </el-dialog>
    <!-- 导航新增编辑弹出框 -->
    <el-dialog
      :visible.sync="depCreateDialog"
      :title="navBtnTitle"
      :before-close="navHandleClose"
      width="30%">
      <div class="nav-dialog-div">
        <label>{{ labelName }}:</label>
        <el-input
          v-model="treeInput"
          placeholder="请输入内容"/>
      </div>
      <div
        v-if="depSelect !== 0"
        class="nav-dialog-div">
        <label>上级部门:</label>
        <el-select
          v-model="depSelect"
          :clearable="false"
          placeholder="请选择">
          <el-option
            v-for="item in dialogOptions"
            :key="item.id"
            :label="item.name"
            :value="item.id"/>
        </el-select>
      </div>
      <span
        slot="footer"
        class="dialog-footer">
        <el-button @click="depCreateDialog = false">取 消</el-button>
        <el-button
          type="primary"
          @click="submitDialog">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 详情 -->
    <employee-detail
      v-if="employeeDetailDialog"
      :data="dialogData"
      @edit="editBtn"
      @command="handleCommand"
      @hide-view="employeeDetailDialog=false"/>
    <!-- 重置密码 -->
    <el-dialog
      v-loading="loading"
      :visible.sync="resetPasswordVisible"
      :close-on-click-modal="false"
      :modal-append-to-body="false"
      :before-close="resetPasswordClose"
      title="重置密码"
      width="30%">
      <div class="el-password">
        <el-form
          ref="passForm"
          :model="passForm"
          :rules="rules">
          <el-form-item
            label="密码"
            prop="password">
            <el-input
              v-model="passForm.password"
              type="password"/>
          </el-form-item>
        </el-form>
      </div>
      <span
        slot="footer"
        class="dialog-footer">
        <el-button @click="resetPasswordClose">取 消</el-button>
        <el-button
          type="primary"
          @click="passSubmit(passForm)">确 定</el-button>
      </span>
    </el-dialog>
 
    <!-- 重置登录账号 -->
    <el-dialog
      v-loading="loading"
      :visible.sync="resetUserNameVisible"
      :close-on-click-modal="false"
      :modal-append-to-body="false"
      :before-close="()=>{resetUserNameVisible = false}"
      title="重置登录账号"
      width="30%">
      <div class="el-password">
        <el-form
          ref="resetUserNameForm"
          :model="resetUserNameForm"
          :rules="dialogRules">
          <el-form-item
            label="新账号(手机号)"
            prop="username">
            <el-input v-model="resetUserNameForm.username"/>
          </el-form-item>
          <el-form-item
            label="新密码"
            prop="password">
            <el-input
              v-model="resetUserNameForm.password"
              type="password"/>
          </el-form-item>
        </el-form>
        <div
          class="tips"
          style="margin-top: 20px;">重置登录帐号后,员工需用新账号登录。请及时告知员工,确保正常使用</div>
      </div>
      <span
        slot="footer"
        class="dialog-footer">
        <el-button @click="()=>{resetUserNameVisible = false}">取 消</el-button>
        <el-button
          type="primary"
          @click="passUserNameSubmit(resetUserNameForm)">确 定</el-button>
      </span>
    </el-dialog>
 
    <!-- 新建和编辑 -->
    <el-dialog
      v-loading="loading"
      v-if="employeeCreateDialog"
      :title="dialogTitle"
      :visible.sync="employeeCreateDialog"
      :close-on-click-modal="false"
      :modal-append-to-body="true"
      :append-to-body="true"
      :before-close="newHandleClose"
      width="60%">
      <p class="new-dialog-title">基本信息</p>
      <el-form
        ref="dialogRef"
        :inline="true"
        :model="formInline"
        :rules="dialogRules"
        class="new-dialog-form"
        label-width="80px"
        label-position="top">
        <el-form-item
          v-for="(item, index) in tableList"
          :label="item.value"
          :prop="item.field"
          :key="index">
          <span slot="label">{{ item.value }}</span>
          <el-tooltip
            v-if="item.tips"
            slot="label"
            :content="item.tips"
            effect="dark"
            placement="top">
            <i class="wukong wukong-help_tips"/>
          </el-tooltip>
          <template v-if="item.type === 'select'">
            <el-select
              v-model="formInline[item.field]"
              filterable
              placeholder="请选择"
              @change='getPositionName'>
              <el-option
                v-for="optionItem in optionsList[item.field].list"
                :key="optionItem.Id"
                :label="optionItem.PositionName"
                :value="optionItem.Id"/>
            </el-select>
          </template>
          <template v-else-if="item.type === 'radio'">
            <el-radio-group v-model="formInline[item.field]">
              <el-radio :label="1">男</el-radio>
              <el-radio :label="2">女</el-radio>
            </el-radio-group>
          </template>
          <template v-else-if="item.type === 'switch'">
            <el-switch v-model="formInline[item.field]"></el-switch>
          </template>
          <template v-else-if="item.type === 'cascader'">
             <el-cascader
              ref="refSubDepart"
              placeholder="请选择上级部门"
              :options="rightsList"
              :show-all-levels="false"
              :props="{
                children: 'Children',
                label: 'DepartmentName',
                value: 'Id'
              }"
              v-model="formInline[item.field]"
              style="width: 100%;"
              @change='getFatherOpt'
              change-on-select/>
          </template>
          <template v-else-if="item.type === 'selectCheckout'">
            <el-select
              v-model="formInline[item.field]"
              :popper-append-to-body="false"
              popper-class="select-popper-class"
              filterable
              placeholder="请选择">
              <el-option
                v-for="item in groupsList"
                :key="item.Id"
                :label="item.DepartmentName"
                :value="item.Id"/>
            </el-select>
          </template>
          <el-input
            v-else
            v-model="formInline[item.field]"
            :disabled="dialogTitle === '编辑员工' && item.field === 'username'"/>
        </el-form-item>
      </el-form>
      <span
        slot="footer"
        class="dialog-footer">
        <el-button
          type="primary"
          @click="newDialogSubmit">保 存</el-button>
        <el-button @click="newHandleClose">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { GetUserInfoDepartmentList, GetUserInfoPositionList, AddUserInfo, UpdateUserInfo, DeleteUserInfo, GetUserInfoList, UpdateUserPostion, BindUserSalesArea
} from '@/api/systemManagement/employeeManage'
import { GetProvincesList } from '@/api/common'
// GetUserInfoPageList,
import { GetDepartmentList, GetDepartmentAreaList } from '@/api/systemManagement/departmentManage'
// import { usersList, depList } from '@/api/common' // 直属上级接口
import EmployeeDetail from './components/employeeDetail'
import { GetPositionList } from '@/api/systemManagement/officalAuthority'
import { mapGetters } from 'vuex'
 
var validateUsername = (rule, value, callback) => {
  if (value && value === 'admin') {
    callback()
  } else if (value && /^1\d{10}$/.test(value)) {
    callback()
  } else {
    callback(new Error('目前只支持中国大陆的手机号码或座机号'))
  }
}
 
export default {
  /** 系统管理 的 员工部门管理 */
  name: 'EmployeeManage',
  components: {
    EmployeeDetail
  },
  data () {
    return {
      // 右边导航
      navBtnTitle: '新建',
      depCreateDialog: false, // 控制部门新增 编辑 数据
      depSelect: '',
      dialogOptions: [],
      labelName: '',
      treeData: [],
      depLoading: false, // 左侧部门loading效果
      // 列表
      loading: false, // 表的加载动画
      searchName: '', // 搜索
      searchPhone: '',
      statusOptions: [
        { value: '1', label: '已激活' },
        { value: '2', label: '已禁用' },
        { value: '4', label: '未激活' },
        { value: '5', label: '退出企业' }
      ],
      selectModel: '', // 状态值 用于筛选
      /** 列表 */
      fieldList: [
        { field: 'IsLeader', value: '是否为上级' },
        { field: 'MobilePhone', value: '手机号(登录名)' },
        { field: 'Gender', value: '性别' },
        { field: 'Email', value: '邮箱' },
        { field: 'MainDepartmentName', value: '部门' },
        { field: 'MasterSalesArea', value: '销售区域' },
        { field: 'Status', value: '状态' },
        { field: 'Position', value: '公司职务' },
        { field: 'JobPosition', value: '权限名称' }
      ],
      selectionList: [], // 批量勾选数据
      tableData: [],
      tableHeight: document.documentElement.clientHeight - 360, // 表的高度
      /** 分页逻辑 */
      structureValue: '', // 左侧列表选中的值 用于筛选
      currentPage: 1,
      pageSize: 10,
      pageSizes: [10, 20, 45, 60],
      total: 0,
      /** ** */
      employeeDetailDialog: false,
      dialogData: {},
      // 新建和编辑
      employeeCreateDialog: false,
      dialogTitle: '新建员工',
      formInline: {},
      treeInput: '',
      // 编辑部门时id
      treeEditId: '',
      optionsList: {
        DepartmentId: {
          field: 'DepartmentId',
          list: []
        },
        PositionId: {
          field: 'PositionId',
          list: [{ Id: 0, PositionName: '请选择' }]
        },
        Sex: {
          field: 'Sex',
          list: [
            { id: 0, name: '请选择' },
            { id: 1, name: '男' },
            { id: 2, name: '女' }
          ]
        }
      },
      groupsList: [{DepartmentName: '', Id: 0}],
      // 重置密码
      resetPasswordVisible: false,
      rules: {
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { min: 6, max: 12, message: '长度在 6 到 12 个字符', trigger: 'blur' }
        ],
        username: [
          { required: true, message: '手机号不能为空', trigger: 'blur' }
        ]
      },
      passForm: {},
      dialogRules: {
        UserName: [
          { required: true, message: '用户名不能为空', trigger: 'blur' }
        ],
        RealName: [
          { required: true, message: '姓名不能为空', trigger: 'blur' }
        ],
        LoginPassword: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { min: 6, max: 12, message: '长度在 6 到 12 个字符', trigger: 'blur' }
        ],
        ConfirmPassword: [
          { required: true, message: '请再次输入密码', trigger: 'blur' },
          { min: 6, max: 12, message: '长度在 6 到 12 个字符', trigger: 'blur' }
        ],
        MobilePhone: [
          { required: true, message: '手机号码不能为空', trigger: 'blur' },
          {
            validator: validateUsername,
            trigger: 'blur'
          }
        ],
        Email: [
          {
            // eslint-disable-next-line no-useless-escape
            pattern: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
            message: '请输入正确的邮箱格式',
            trigger: 'blur',
            required: true
          }
        ],
        DepartmentId: [
          { required: true, message: '部门不能为空', trigger: 'change' }
        ],
        PositionId: [{ required: true, message: '职务不能为空', trigger: 'change' }]
      },
      // 重置登录账号
      resetUserNameVisible: false,
      resetUserNameForm: {
        username: '',
        password: ''
      },
      defaultProps: {
        children: 'Children',
        label: 'Name'
      },
      rightsList: [],
      parentId: '',
      positionName: '',
      tableTopName: '全公司',
      isSetPosition: false, // 职务配置
      pushStatus: '',
      pushOptions: [],
      isSetArea: false, // 区域配置
      areaId: '',
      areaStatus: [],
      areaOptions: []
    }
  },
  computed: {
    ...mapGetters(['manage']),
    // 员工创建权限
    userSaveAuth () {
      // return this.manage && this.manage.users && this.manage.users.userSave
      return true
    },
    // 员工编辑操作权限
    userUpdateAuth () {
      // return this.manage && this.manage.users && this.manage.users.userUpdate
      return true
    },
    // 员工禁用启用权限
    userEnablesAuth () {
      // return this.manage && this.manage.users && this.manage.users.userEnables
      return true
    },
    // 员工列表的勾选编辑
    tableUpdateAuth () {
      return this.userEnablesAuth && this.userUpdateAuth
    },
    // // 部门编辑权限
    strucSaveAuth () {
      // return this.manage && this.manage.users && this.manage.users.deptSave
      return true
    },
    // 部门编辑权限
    strucUpdateAuth () {
      // return this.manage && this.manage.users && this.manage.users.deptUpdate
      return true
    },
    // 部门编辑权限
    strucDeleteAuth () {
      // return this.manage && this.manage.users && this.manage.users.deptDelete
      return true
    },
    selectionInfo: function () {
      let temps = []
      // if (this.userEnablesAuth) {
      //   temps = [
      //     {
      //       name: '禁用',
      //       type: 'lock',
      //       icon: require('@/assets/img/selection_disable.png')
      //     },
      //     {
      //       name: '激活',
      //       type: 'unlock',
      //       icon: require('@/assets/img/selection_start.png')
      //     }
      //   ]
      // }
      if (this.userUpdateAuth) {
        if (this.selectionList.length === 1) {
          temps = temps.concat([
            {
              name: '编辑',
              type: 'edit',
              icon: require('@/assets/img/selection_edit.png')
            }
            // ,
            // {
            //   name: '重置密码',
            //   type: 'reset',
            //   icon: require('@/assets/img/selection_reset.png')
            // },
            // {
            //   name: '重置登录账号',
            //   type: 'resetName',
            //   icon: require('@/assets/img/section_reset_name.png')
            // }
          ])
        } else {
          // temps = temps.concat([
          //   {
          //     name: '重置密码',
          //     type: 'reset',
          //     icon: require('@/assets/img/selection_reset.png')
          //   }
          // ])
        }
      }
 
      return temps
    },
    /** 添加列表 */
    tableList: function () {
      if (this.dialogTitle === '新建员工') {
        return [
          { field: 'UserName', value: '用户名(登录名)' },
          { field: 'RealName', value: '姓名' },
          { field: 'Sex', value: '性别', type: 'radio' },
          { field: 'MobilePhone', value: '手机号' },
          { field: 'Email', value: '邮箱' },
          { field: 'OfficePhone', value: '办公电话' },
          { field: 'QQNumber', value: 'QQ' },
          { field: 'WeixinNumber', value: '微信' },
          { field: 'IsEnabled', value: '状态', type: 'switch' },
          { field: 'DepartmentId', value: '部门', type: 'cascader' },
          { field: 'LoginPassword', value: '登录密码' },
          { field: 'PositionId', value: '职务', type: 'select' },
          { field: 'ConfirmPassword', value: '确认登录密码' }
        ]
      } else {
        return [
          { field: 'UserName', value: '用户名(登录名)' },
          { field: 'RealName', value: '姓名' },
          { field: 'Sex', value: '性别', type: 'radio' },
          { field: 'MobilePhone', value: '手机号' },
          { field: 'Email', value: '邮箱' },
          { field: 'OfficePhone', value: '办公电话' },
          { field: 'QQNumber', value: 'QQ' },
          { field: 'WeixinNumber', value: '微信' },
          { field: 'IsEnabled', value: '状态', type: 'switch' },
          { field: 'DepartmentId', value: '部门', type: 'cascader' },
          { field: 'PositionId', value: '职务', type: 'select' },
          { field: 'LoginPassword', value: '登录密码' },
          { field: 'ConfirmPassword', value: '确认登陆密码' }
        ]
      }
    }
  },
  mounted () {
    var self = this
    /** 控制table的高度 */
    window.onresize = function () {
      self.tableHeight = document.documentElement.clientHeight - 260
    }
 
    // 部门树形列表
    this.treeListFun()
    this.getSelectUserList() // 直属上级列表
    this.getDepList()
    // 系统职务
    this.getPositionList()
    // 配置区域
    this.getAreaList()
    // 新增编辑下拉选项
    // this.departListFun()
    // this.positionListFun()
    // this.departAreaFunc()
    // document.getElementsByClassName('el-select-dropdown')[0].style.color = 'red'
  },
  methods: {
    handleHeaderDragend (newWidth, oldWidth, column, event) {
      if (column.property) {
      }
    },
    /** 通过回调控制style */
    cellStyle ({ row, column, rowIndex, columnIndex }) {
    },
    getArea (val) {
      console.log(val)
    },
    // 改变部门
    changeDepClick (data) {
      console.log(data)
      this.currentPage = 1
      this.structureValue = data.DepartmentId
      this.usersListFun()
    },
    /**
     * 展开闭合操作
     */
    handleExpand (type, node, data) {
      console.log(type, node, data)
      if (type === 'close') {
        if (data.Children) {
          node.expanded = false
        }
      } else if (type === 'open') {
        node.expanded = true
      }
    },
    getPositionName (val) {
      this.positionName = val ? this.optionsList['PositionId'].list.find(ele => ele.Id === val).PositionName : ''
    },
    getFatherOpt (val) {
      console.log(this.$refs['refSubDepart'][0].getCheckedNodes()[0].label)
      const flag = Array.isArray(this.formInline['DepartmentId'])
      if (flag) {
        this.parentId = this.formInline['DepartmentId'].length > 1 ? this.formInline['DepartmentId'][0] : ''
      }
      for (let j = 0; j < this.rightsList.length; j++) {
        if (this.rightsList[j].Id === val[0]) {
          if (this.rightsList[j].DepartmentType === 6) {
            this.tableList.splice(11, 0, { field: 'UserDepartment', value: '区域部门关联', type: 'selectCheckout' })
          } else {
            if (this.tableList[11].field === 'UserDepartment') {
              this.tableList.splice(11, 1)
            }
          }
        }
      }
    },
    handleClose () {
      this.employeeDetailDialog = false
    },
    // 第一列点击事件
    rowClick (row, column, event) {
      this.dialogData = row
      if (column.property === 'Name') {
        this.employeeDetailDialog = true
      }
    },
    // 新建和编辑
    newHandleClose () {
      this.employeeCreateDialog = false
      this.$refs.dialogRef.resetFields()
      if (this.tableList[11].field === 'UserDepartment') {
        this.tableList.splice(11, 1)
      }
    },
    // 新建用户
    newBtn () {
      this.employeeCreateDialog = true
      this.dialogTitle = '新建员工'
      this.formInline = {
        Sex: 1,
        IsEnabled: true
      }
    },
    // 详情 -- 编辑用户
    editBtn () {
      this.dialogTitle = '编辑员工'
      var detail = {}
      for (let index = 0; index < this.tableList.length; index++) {
        const element = this.tableList[index]
        if (element.field !== 'LoginPassword') {
          // if (element.field === 'PositionId') {
          //   detail[element.field] = this.dialogData.PositionId
          //     ? this.dialogData.PositionId
          //       .split(',')
          //       .map(function (item, index, array) {
          //         return parseInt(item)
          //       })
          //     : []
          // }
          if (element.field === 'DepartmentId') {
            detail.DepartmentId = this.dialogData.DepartmentId
          } else {
            detail[element.field] = this.dialogData[element.field]
          }
        }
      }
      detail['Id'] = this.dialogData.Id
      this.formInline = detail
      this.employeeCreateDialog = true
    },
    // 增加组织架构
    // 部门非树形结构列表 用于部门添加
    getDepList () {
      // depList().then(response => {
      //   this.optionsList['deptId'].list = response.data
      // })
    },
    append (data) {
      this.treeInput = ''
      this.labelName = '新增部门'
      this.navBtnTitle = '新增部门'
      this.depSelect = data.id
      this.getStructuresListBySuperior({ id: data.id, type: 'save' })
      this.depCreateDialog = true
    },
    // 获取新增部门 上级部门信息
    getStructuresListBySuperior (data) {
      this.dialogOptions = []
      // depList(data).then(response => {
      //   this.dialogOptions = response.data
      // })
    },
    // 配置系统职务
    setPosition (id) {
      this.selectionList = [{'Id': id}]
      this.isSetPosition = true
    },
    handlePosClose () {
      this.pushStatus = ''
      this.isSetPosition = false
    },
    savePos () {
      let params = {
        'PositionId': this.pushStatus,
        'UserInfos': this.selectionList
      }
      console.log(params)
      UpdateUserPostion(params).then(res => {
        console.log(res)
        if (res.data.ErrorCode === 200) {
          this.$message.success(res.data.Message)
          this.isSetPosition = false
          this.pushStatus = ''
          this.usersListFun()
        } else {
          this.$message.error(res.data.Message)
        }
      })
    },
    // 勾选
    handleSelectionChange (val) {
      let Ids = []
      for (let j in val) {
        Ids.push({'Id': val[j].Id})
      }
      this.selectionList = Ids // 勾选的行
      console.log(this.selectionList)
    },
    getPositionList () {
      GetPositionList().then(res => {
        console.log(res)
        if (res.data.ErrorCode === 200 && res.data.Result) {
          this.pushOptions = res.data.Result
        } else {
          this.$message.error(res.data.Message)
        }
      })
    },
    getAreaList () {
      GetProvincesList().then(res => {
        console.log(res)
        if (res.data.ErrorCode === 200 && res.data.Result) {
          this.areaOptions = res.data.Result
        } else {
          this.$message.error(res.data.Message)
        }
      })
    },
    // 区域配置
    handleAreaClose () {
      this.areaStatus = []
      this.isSetArea = false
    },
    // 配置系统区域
    setArea (row) {
      this.areaId = [row.Id]
      this.areaStatus = row.MasterSalesArea && row.MasterSalesArea.length > 0 ? row.MasterSalesArea.split(',') : []
      this.isSetArea = true
    },
    saveArea () {
      console.log(this.areaStatus)
      let params = {
        'Users': this.areaId,
        'Areas': this.areaStatus
      }
      console.log(params)
      BindUserSalesArea(params).then(res => {
        console.log(res)
        if (res.data.ErrorCode === 200) {
          this.$message.success(res.data.Message)
          this.isSetArea = false
          this.areaStatus = []
          this.usersListFun()
        } else {
          this.$message.error(res.data.Message)
        }
      })
    },
    // 编辑组织架构
    edit (node, data) {
      this.treeInput = data.label
      this.treeEditId = data.id
      this.depSelect = data.pid
      this.navBtnTitle = '编辑部门'
      this.labelName = '编辑部门'
      this.getStructuresListBySuperior({ id: data.id, type: 'update' })
      this.depCreateDialog = true
    },
    // 删除组织架构
    remove (node, data) {
      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.loading = true
          // depDelete({ id: data.id })
          //   .then(res => {
          //     this.treeListFun()
          //     this.$message.success('删除成功')
          //     this.loading = false
          //   })
          //   .catch(() => {
          //     this.loading = false
          //   })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 关闭新增或编辑
    navHandleClose () {
      this.depCreateDialog = false
    },
    // 新增或编辑确定按钮
    submitDialog () {
      if (this.labelName === '新增部门') {
        // depSave({ name: this.treeInput, pid: this.depSelect }).then(res => {
        //   this.getDepList() // 增加了新部门 刷新数据
        //   this.treeListFun()
        //   this.navHandleClose()
        // })
      } else {
        // depEdit({
        //   name: this.treeInput,
        //   deptId: this.treeEditId,
        //   pid: this.depSelect
        // }).then(res => {
        //   this.$message.success('操作成功')
        //   this.treeListFun()
        //   this.navHandleClose()
        // })
      }
    },
    // 获取树形列表
    treeListFun () {
      this.depLoading = true
      GetDepartmentList()
        .then(response => {
          this.treeData = response.data.Result
          this.structureValue = response.data.Result[0].DepartmentId
          this.tableTopName = response.data.Result[0].Name
          this.usersListFun()
          this.depLoading = false
        })
        .catch(() => {
          this.depLoading = false
        })
    },
    departListFun () {
      GetUserInfoDepartmentList().then(response => {
        if (response.data.Result) {
          this.rightsList = response.data.Result
        } else {
          this.$message.error(response.data.Message)
        }
      })
        .catch((err) => {
          console.log(err)
        })
    },
    positionListFun () {
      GetUserInfoPositionList().then(response => {
        if (response.data.Result) {
          this.optionsList['PositionId'].list = response.data.Result
        } else {
          this.$message.error(response.data.Message)
        }
      })
        .catch((err) => {
          console.log(err)
        })
    },
    departAreaFunc () {
      GetDepartmentAreaList().then(response => {
        if (response.data.Result) {
          this.groupsList = response.data.Result
        } else {
          this.$message.error(response.data.Message)
        }
      })
        .catch((err) => {
          console.log(err)
        })
    },
    // 搜索框
    searchClick () {
      this.currentPage = 1
      this.structureValue = 0
      this.usersListFun()
    },
    // 状态筛选
    statusChange () {
      this.currentPage = 1
      this.usersListFun()
    },
    deleteSingleModule (id) {
      this.$confirm('确定删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          DeleteUserInfo({'Id': id}).then(res => {
            if (res.data.ErrorCode === 200) {
              this.$message.success(res.data.Message)
              this.usersListFun()
              this.getSelectUserList()
            } else {
              this.$message.error(res.data.Message)
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 用户新建
    newDialogSubmit () {
      this.$refs.dialogRef.validate(valid => {
        if (valid) {
          const isIntro = Array.isArray(this.formInline.DepartmentId)
          this.formInline.DepartmentId = isIntro ? (this.formInline.DepartmentId.length > 1 ? this.formInline.DepartmentId[this.formInline.DepartmentId.length - 1] : (this.formInline.DepartmentId[0] === 0 ? '' : this.formInline.DepartmentId[0])) : this.formInline.DepartmentId
          this.formInline.DepartmentName = this.$refs['refSubDepart'][0].getCheckedNodes()[0].label
          this.formInline.PositionName = this.positionName
          console.log(this.formInline)
          if (this.dialogTitle === '新建员工') {
            this.loading = true
            // this.formInline.roleIds = this.formInline.roleId.join(',')
            AddUserInfo(this.formInline)
              .then(res => {
                if (res.data.ErrorCode === 200 && res.data.Result !== 0) {
                  this.$message.success('新增成功')
                  this.employeeCreateDialog = false
                  this.usersListFun()
                  this.getSelectUserList()
                  this.loading = false
                } else {
                  this.$message.error(res.data.Message)
                  this.loading = false
                }
              })
              .catch(() => {
                this.loading = false
              })
          } else {
            this.loading = true
            // this.formInline.roleIds = this.formInline.roleId.join(',')
            UpdateUserInfo(this.formInline)
              .then(res => {
                if (res.data.ErrorCode === 200 && res.data.Result !== 0) {
                  if (this.employeeDetailDialog) {
                    this.employeeDetailDialog = false
                  }
                  this.employeeCreateDialog = false
                  this.$message.success('编辑成功')
                  this.usersListFun()
                  this.getSelectUserList()
                  this.loading = false
                } else {
                  this.$message.error(res.data.Message)
                  this.loading = false
                }
              })
              .catch(() => {
                this.loading = false
              })
          }
        } else {
          return false
        }
      })
    },
    // 详情里面点击事件
    handleCommand (command) {
      switch (command) {
        case 'reset':
          // 当前登录用户ID
          this.passForm = {
            password: ''
          }
          this.resetPasswordVisible = true
          break
        case 'status':
          // usersEditStatus({
          //   userIds: this.dialogData.userId,
          //   status: this.dialogData.status === 0 ? 1 : 0
          // }).then(res => {
          //   this.employeeDetailDialog = false
          //   this.$message.success('修改成功')
          //   this.usersListFun()
          // })
          break
      }
    },
    /** 操作 */
    selectionBarClick (type) {
      // var ids = this.selectionList
      //   .map(function (item, index, array) {
      //     return item.userId
      //   })
      // .join(',')
      if (type === 'lock' || type === 'unlock') {
        var message = type === 'lock' ? '禁用' : '激活'
        this.$confirm('这些员工账号将被' + message + ', 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.loading = true
            // usersEditStatus({
            //   userIds: ids,
            //   status: type === 'unlock' ? 1 : 0
            // })
            //   .then(res => {
            //     this.loading = false
            //     this.$message.success('修改成功')
            //     this.usersListFun()
            //   })
            //   .catch(() => {
            //     this.loading = false
            //   })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
      } else if (type === 'reset') {
        this.resetPasswordVisible = true
      } else if (type === 'resetName') {
        this.resetUserNameVisible = true
      } else if (type === 'edit') {
        this.dialogData = this.selectionList[0]
 
        this.dialogTitle = '编辑员工'
        var detail = {}
        for (let index = 0; index < this.tableList.length; index++) {
          const element = this.tableList[index]
          if (element.field !== 'LoginPassword') {
          // if (element.field === 'PositionId') {
          //   detail[element.field] = this.dialogData.PositionId
          //     ? this.dialogData.PositionId
          //       .split(',')
          //       .map(function (item, index, array) {
          //         return parseInt(item)
          //       })
          //     : []
          // }
            if (element.field === 'DepartmentId') {
              detail.DepartmentId = this.dialogData.DepartmentId
            } else {
              detail[element.field] = this.dialogData[element.field]
            }
          }
        }
        detail['Id'] = this.dialogData.Id
        this.formInline = detail
        this.employeeCreateDialog = true
      }
    },
    // 重置密码 -- 关闭按钮
    resetPasswordClose () {
      this.resetPasswordVisible = false
    },
    // 重置密码 -- 确定按钮
    passSubmit (val) {
      this.$refs.passForm.validate(valid => {
        if (valid) {
          var ids = []
          if (this.selectionList.length > 0) {
            ids = this.selectionList
              .map(function (item, index, array) {
                return item.userId
              })
              .join(',')
          } else {
            ids = this.dialogData.userId
          }
          val.userIds = ids
          this.loading = true
          // adminUsersUpdatePwd(val)
          //   .then(res => {
          //     this.$message.success('重置成功')
          //     this.resetPasswordClose()
          //     this.loading = false
          //   })
          //   .catch(() => {
          //     this.loading = false
          //   })
        } else {
          return false
        }
      })
    },
    /**
     * 重置登录账号
     */
    passUserNameSubmit (val) {
      this.$refs.resetUserNameForm.validate(valid => {
        if (valid) {
          if (this.selectionList.length > 0) {
            val.id = this.selectionList[0].userId
            this.loading = true
            // adminUsersUsernameEditAPI(val)
            //   .then(res => {
            //     this.$message.success('重置成功')
            //     this.searchClick()
            //     this.resetUserNameVisible = false
            //     this.loading = false
            //   })
            //   .catch(() => {
            //     this.loading = false
            //   })
          }
        } else {
          return false
        }
      })
    },
 
    // 更改每页展示数量
    handleSizeChange (val) {
      this.pageSize = val
      this.usersListFun()
    },
    // 更改当前页数
    handleCurrentChange (val) {
      this.currentPage = val
      this.usersListFun()
    },
    // 用户列表
    usersListFun () {
      this.loading = true
      GetUserInfoList({
        PageIndex: this.currentPage,
        PageSize: this.pageSize,
        RealName: this.searchName,
        DepartmentId: this.structureValue,
        MobilePhone: this.searchPhone
      })
        .then(res => {
          this.tableData = res.data.Result.List
          this.total = res.data.Result.Count
          this.loading = false
        })
        .catch(() => {
          this.loading = false
        })
    },
    /** 获取选择直属上级列表 */
    getSelectUserList () {
      this.loading = true
      // usersList({ pageType: 0 })
      //   .then(res => {
      //     this.optionsList['parentId'].list = []
      //     for (const i of res.data) {
      //       this.optionsList['parentId'].list.push({
      //         id: i.userId,
      //         name: i.realname
      //       })
      //     }
      //     this.loading = false
      //   })
      //   .catch(() => {
      //     this.loading = false
      //   })
    },
    // 获取状态颜色 0 禁用 1 启用 2未激活
    getStatusColor (status) {
      if (status === 0) {
        return '#FF6767'
      } else if (status === 1) {
        return '#4D88FF'
      } else if (status === 2) {
        return '#CCCCCC'
      }
    },
    // 列表信息格式化
    tableFormatter (row, column) {
      if (column.property === 'IsLeader') {
        return { true: '是', false: '否' }[row.IsLeader]
      } else if (column.property === 'Gender') {
        return { 1: '男', 2: '女' }[row.Gender]
      } else if (column.property === 'Status') {
        return { 1: '已激活',
          2: '已禁用',
          4: '未激活',
          5: '退出企业'}[row.Status]
      }
      return row[column.property] || '--'
    }
  }
}
</script>
 
<style lang="scss" scoped>
.el-table /deep/ thead th:first-child, thead td {
  border-right: 1px solid #F7FAFF !important;
}
.setMultiPosition{
  margin-left: 30px;
}
.pushBody{
  margin: 0 60px;
  .hintWord{
    margin-top: 10px;
  }
  .hintSelect{
    margin-top: 20px;
    .el-select{
      width: 224px;
    }
  }
}
.closePushBtn{
  margin-right: 16px;
}
.employee-dep-management {
  /* padding: 0 20px 20px; */
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.system-content {
  position: relative;
  height: 100%;
  flex: 1;
  display: flex;
  overflow: hidden;
}
.system-view-nav {
  width: 240px;
  height: 100%;
  overflow: auto;
  margin-right: 10px;
  background: #fff;
  border: 1px solid #e6e6e6;
  .system-nav-title{
      padding: 15px;
      font-size: 16px;
      font-weight: 600;
      border-bottom: 1px solid #e6e6e6;
    }
}
.title {
  font-size: 18px;
  height: 40px;
  line-height: 40px;
  margin: 10px 0;
  color: #333;
  padding: 0 20px;
}
.system-view-table {
  background: #fff;
  border: 1px solid #e6e6e6;
  /* flex: 1; */
  position: absolute;
  top: 0;
  left: 250px;
  bottom: 0;
  right: 0;
}
 
.table-top {
    padding: 0 30px;
    height: 50px;
    display: flex;
    align-items: center;
  .table-top__title{
    font-size: 16px;
    color: #333;
  }
}
 
.status {
  display: inline-block;
  margin-left: 50px;
}
.status > span {
  margin-right: 10px;
}
 
.status-name {
  .user-img {
    width: 32px;
    min-width: 32px;
    min-height: 32px;
    height: 32px;
    margin-right: 8px;
    border-radius: 50%;
  }
  div {
    width: 6px;
    height: 6px;
    border-radius: 3px;
  }
  color:  #ff6a00;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: left;
}
/* 详情 */
.employee-dep-management /deep/ .el-dialog__wrapper {
  margin-top: 60px !important;
}
// .employee-dep-management /deep/ .position-flxed-animation {
//   left: 70%;
//   height: 100%;
//   color: red;
//   margin: 0 !important;
// }
.dialog-top > img {
  vertical-align: middle;
  margin-right: 10px;
  height: 36px;
}
.dialog-btn-group {
  float: right;
}
.dialog-remark {
  font-size: 14px;
  color: #999;
  margin-top: 10px;
}
.dialog-content {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e6e6e6;
}
.dialog-content > div {
  padding: 10px 0;
}
.dialog-content > div > label {
  color: #777;
  width: 30%;
  display: inline-block;
}
/* 新建和编辑 */
.new-dialog-title {
  padding-left: 10px;
  margin-bottom: 3px;
  border-left: 2px solid #4D88FF;
}
.new-dialog-form {
  height: 47vh;
  overflow-y: auto;
  padding: 20px;
}
.new-dialog-form /deep/ .el-form-item {
  width: 50%;
  margin: 0;
  padding-bottom: 10px;
}
.new-dialog-form /deep/ .el-form-item .el-form-item__label {
  padding: 0;
}
.new-dialog-form /deep/ .el-form-item .el-form-item__content {
  width: 70%;
}
.nav-dialog-div {
  margin-bottom: 20px;
}
.nav-dialog-div /deep/ .el-input {
  width: auto;
}
/** 树形结构 */
.el-tree /deep/ .el-tree-node__expand-icon {
  display: none;
}
.el-tree /deep/ .el-tree-node__content {
  height: 30px;
 
  .node-data {
    .node-img {
      width: 15px;
      height: 15px;
      display: block;
      margin-right: 8px;
      margin-left: 24px;
    }
    .node-label {
      margin-right: 8px;
    }
    .node-label-set {
      display: none;
    }
  }
 
  .node-data:hover .node-label-set {
    display: block;
  }
}
.el-tree /deep/ .el-tree-node.is-current > .el-tree-node__content {
  background-color: #ebf3ff;
  border-right: 2px solid #4D88FF;
  .node-label-set {
    display: block;
  }
}
.system-view-nav /deep/ .el-tree-node > .el-tree-node__children {
  overflow: visible;
}
.system-view-nav /deep/ .el-tree > .el-tree-node {
  min-width: 100%;
  display: inline-block !important;
}
/* 搜索框图标按钮 */
.icon-search .el-icon-search {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  font-size: 20px;
  color: #ccc;
}
/* 设置flex布局 */
.flex-index {
  display: flex;
  flex-direction: column;
}
/* 设置占位 */
.flex-box {
  flex: 1;
  border-bottom: 1px solid #e6e6e6;
  padding: 24px 20px;
}
/* 搜索框 */
.icon-search {
  width: 280px;
  position: relative;
}
.new-dialog-form /deep/ .el-select {
  display: block;
}
 
/** 分页布局 */
.p-contianer {
  position: relative;
  background-color: white;
  height: 44px;
  .p-bar {
    float: right;
    margin: 5px 0 0 0;
    font-size: 14px !important;
  }
}
 
/** 勾选操作 */
.selection-bar {
  font-size: 12px;
  height: 54px;
  min-height: 54px;
  padding: 0 20px;
  color: #777;
 
  .selected—title {
    flex-shrink: 0;
    padding-right: 20px;
    border-right: 1px solid #e6e6e6;
    .selected—count {
      color:  #ff6a00;
    }
  }
}
 
.selection-items-box {
  .selection-item {
    width: auto;
    padding: 15px;
    .selection-item-icon {
      display: block;
      margin-right: 5px;
      width: 15px;
      height: 15px;
    }
    .selection-item-name {
      cursor: pointer;
      color: #777;
    }
    .selection-item-name:hover {
      color:  #ff6a00;
    }
  }
}
.new-dialog-form
  /deep/
  .el-form-item
  .el-form-item__content
  .el-select-group__wrap:not(:last-of-type)::after {
  display: none;
}
.new-dialog-form /deep/ .el-form-item .el-form-item__content .el-select-group {
  padding-left: 10px;
}
.new-dialog-form
  /deep/
  .el-form-item
  .el-form-item__content
  .el-select-group__title {
  border-bottom: 1px solid #e4e7ed;
  padding: 0 0 7px;
  margin: 0 20px 5px;
}
 
.status-des {
  font-size: 12px;
  color: #777777;
  margin: 0 5px;
  position: absolute;
  left: 0;
  top: 7px;
  .status-des-item {
    margin: 8px;
    display: inline-block;
    div {
      display: inline-block;
      width: 6px;
      height: 6px;
      border-radius: 3px;
      margin-right: 5px;
    }
  }
}
 
// 提示
// 提示标志
.wukong-help_tips {
  color: #999;
  font-size: 14px;
  margin-left: 3px;
  cursor: pointer;
}
 
.wukong-help_tips:hover {
  color:  #ff6a00;
}
 
// 修改密码和修改登录名的样式
.el-password {
  .el-form-item {
    margin-bottom: 5px;
  }
}
 
.el-dialog__wrapper /deep/.el-dialog__body {
  padding: 20px;
}
 
.tips {
  font-size: 13px;
  color: #999;
}
 
@import '../../clients/styles/table.scss';
</style>