qx
4 小时以前 ad54cf427ee94e01e8c72a01f738615eb2b6569d
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
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"
      @submit.native.prevent>
      <el-form-item label="单位名称" prop="cnName">
        <el-input ref="inputName" v-model="queryParams.cnName" placeholder="请输入单位名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"
          style="margin: 0 15px">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
 
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:comp:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:comp:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:comp:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:comp:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single" @click="mainDepartment"
          v-hasPermi="['system:comp:edit']">维护套餐</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
 
    <el-table border v-loading="loading" :data="compList" @selection-change="handleSelectionChange" ref="tab">
      <el-table-column fixed="left" type="selection" width="40px" align="center" />
      <el-table-column label="序号" align="center" prop="newID" :show-overflow-tooltip="true" width="50px" fixed="left" />
      <el-table-column label="单位名称" align="center" prop="cnName" width="240px" />
      <el-table-column label="统一信用代码" align="center" prop="taxNumber" width="180px" />
      <el-table-column label="联系人" align="center" prop="contactPerson" :show-overflow-tooltip="true" width="90px" />
      <el-table-column label="联系电话" align="center" prop="contactPhone" :show-overflow-tooltip="true" />
      <el-table-column label="注册地址" align="center" prop="registerAddress" :show-overflow-tooltip="true" />
      <!-- <el-table-column label="企业类型" align="center" prop="typeOfEnterprise" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.dict_comp_type" :value="scope.row.typeOfEnterprise"/>
        </template>
</el-table-column> -->
      <el-table-column label="行政区划" align="center" prop="areaName" :show-overflow-tooltip="true" />
      <el-table-column label="通讯地址" align="center" prop="mailingAddress" :show-overflow-tooltip="true" />
      <el-table-column label="邮箱" align="center" prop="email" :show-overflow-tooltip="true" />
      <el-table-column label="开户银行" align="center" prop="bankAccount" :show-overflow-tooltip="true" />
      <el-table-column label="银行账号" align="center" prop="countNum" :show-overflow-tooltip="true" />
      <!-- <el-table-column label="GMP发证日期" align="center" prop="gmpissueDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gmpissueDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="经营许可证号" align="center" prop="businessLicenseNumber" /> -->
      <!-- <el-table-column label="GMP有效截止日期" align="center" prop="gmpDeadlineDate" width="110px" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gmpDeadlineDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="GMP延续日期" align="center" prop="gmpDelayDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gmpDelayDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="GMP证书图片(base64编码)" align="center" prop="gmpPhoto" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.gmpPhoto" :width="50" :height="50"/>
        </template>
      </el-table-column> -->
      <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
      <!-- <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="修改人" align="center" prop="updateBy" :show-overflow-tooltip="true" width="100px" />
      <el-table-column label="修改时间" align="center" prop="updateTime" width="100px" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="排序" align="center" prop="orderNum" :show-overflow-tooltip="true" width="55px" />
      <!-- <el-table-column label="数据状态(PT10.00.004)" align="center" prop="effective">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.dict_data_status" :value="scope.row.effective"/>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="有效时间" align="center" prop="validTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.validTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" width="70px">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:comp:edit']" title="修改"></el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['system:comp:remove']" title="删除"></el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <div class="pag">
      <div class="pag1">
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize" @pagination="getList" />
      </div>
    </div>
 
    <div>
      <el-dialog :title="title" :visible.sync="opens" width="1350px" append-to-body :close-on-click-modal="true">
        <el-row :gutter="20">
          <el-col :span="7" :xs="24">
            <div style="padding: 0 20px">
              <el-form ref="form" :model="form" :rules="rules" label-width="80px" :inline="true" @submit.native.prevent>
                <el-form-item label="套餐名称" prop="dwDeptName">
                  <el-input v-model="form.dwDeptName" placeholder="请输入套餐名称" />
                </el-form-item>
                <el-form-item label="签约金额" prop="signingPrice">
                  <el-input v-model="form.signingPrice" placeholder="请输入签约金额" />
                </el-form-item>
                <el-form-item label="病种" prop="bz" v-if="dwlxs == 1">
                  <el-select v-model="form.bz" placeholder="请选择病种" style="width: 130px" clearable>
                    <el-option v-for="dict in dict.type.reservation_pay_type" :key="dict.value" :label="dict.label"
                      :value="dict.value" />
                  </el-select>
                </el-form-item>
              </el-form>
              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddDept"
                    v-hasPermi="['system:comp:add']">保存套餐</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="singleg" @click="handledeleDept"
                    v-hasPermi="['system:comp:edit']">删除</el-button>
                </el-col>
              </el-row>
              <el-table ref="tb" v-loading="loading" :data="deptList" @selection-change="handleSelection" border
                style="width: 320px" height="300">
                <el-table-column type="selection" width="40px" align="center" />
                <el-table-column label="套餐名称" align="center" prop="dwDeptName" />
              </el-table>
            </div>
          </el-col>
          <el-col :span="17" :xs="24">
            <el-form ref="form" :model="forms" :rules="rules" label-width="78px" :inline="true" @submit.native.prevent>
              <el-form-item label="分组名称" prop="groupingName">
                <el-input v-model="forms.groupingName" placeholder="请输入分组名称" style="width: 130px"
                  @focus="changegroupingName" />
              </el-form-item>
              <el-form-item label="性别" prop="sex">
                <el-select v-model="forms.sex" placeholder="请选择性别" style="width: 120px" clearable
                  :disabled="isSexDisabled">
                  <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
                    :value="dict.value" />
                </el-select>
              </el-form-item>
              <!-- <el-form-item label="套餐名称" prop="pacName">
                <el-input
                  v-model="forms.pacName"
                  placeholder="请输入套餐名称"
                  @focus="changeName"
                  style="width: 130px"
                />
              </el-form-item> -->
              <el-form-item label="原价" prop="price">
                <el-input v-model="forms.price" placeholder="请输入原价" style="width: 130px" />
              </el-form-item>
              <el-form-item label="优惠价" prop="ysPrice">
                <el-input v-model="forms.ysPrice" placeholder="请输入应收" style="width: 120px" />
              </el-form-item>
              <el-form-item label="结算方式" prop="payType">
                <el-select v-model="forms.payType" placeholder="请选择结算方式" style="width: 130px" clearable>
                  <el-option v-for="dict in dict.type.reservation_pay_type" :key="dict.value" :label="dict.label"
                    :value="dict.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="是否替检" prop="tj">
                <el-select v-model="forms.tj" placeholder="请选择是否替检" style="width: 120px" clearable>
                  <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label"
                    :value="dict.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="年龄段">
                <el-col :span="7">
                  <el-input v-model="forms.ltAge" style="width: 53px" />
                </el-col>
                <el-col class="line" :span="1">-</el-col>
                <el-col :span="9">
                  <el-input v-model="forms.gtAge" style="width: 54px" />
                </el-col>
              </el-form-item>
 
            </el-form>
 
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleGroup">保存</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit" size="mini" @click="xiangmuWh">项目维护</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="singlegg"
                  @click="GroupUpdate">重置</el-button>
                <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="singlegg"
                  @click="deleteGroup">删除</el-button>
              </el-col>
            </el-row>
            <el-table border ref="tbs" v-loading="loading" :data="groupingList" @selection-change="handleChange"
              height="350">
              <el-table-column type="selection" width="40px" align="center" />
              <el-table-column label="序号" align="center" prop="newID" width="50px" />
              <el-table-column label="分组名称" align="center" prop="groupingName" />
              <el-table-column label="性别" align="center" prop="sex">
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex" />
                </template>
              </el-table-column>
              <el-table-column label="套餐名称" align="center" prop="pacName" />
              <el-table-column label="结算方式" align="center" prop="payType">
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.reservation_pay_type" :value="scope.row.payType" />
                </template>
              </el-table-column>
              <el-table-column label="折扣" align="center" prop="limits" />
              <el-table-column label="原价" align="center" prop="price" />
              <el-table-column label="应收" align="center" prop="ysPrice" />
            </el-table>
          </el-col>
        </el-row>
      </el-dialog>
    </div>
 
    <!-- 套餐 -->
    <div>
      <el-dialog :title="title" :visible.sync="openss" width="1400px" :style="{ height: 1400 + 'px' }" append-to-body
        :close-on-click-modal="false">
        <el-row :gutter="24">
          <el-col :span="8" :xs="24">
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px"
              @submit.native.prevent>
              <el-form-item label="套餐名称" prop="pacName">
                <el-input ref="inputName" v-model="queryParams.pacName" placeholder="请输入套餐名称" clearable
                  @keyup.enter.native="handleSearch" style="width: 140px" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearch">搜索</el-button>
              </el-form-item>
            </el-form>
            <el-table ref="tbone" border v-loading="loading" :data="newpacName" @selection-change="handleChangeOne"
              height="478">
              <el-table-column type="selection" width="40px" align="center" />
              <el-table-column label="序号" align="center" prop="pacId" width="50px" />
              <el-table-column label="套餐名称/价格/元" align="center" prop="pacName">
                <template slot-scope="scope">
                  {{ scope.row.pacName + "/" + scope.row.price }}
                </template>
              </el-table-column>
            </el-table>
          </el-col>
          <el-col :span="6" :xs="24">
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="46px"
              @submit.native.prevent>
              <el-form-item label="合计" prop="price">
                <el-input ref="inputName" v-model="queryParams.price" placeholder="合计" clearable style="width: 140px" />
              </el-form-item>
              <el-form-item>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuerys">重置</el-button>
              </el-form-item>
            </el-form>
            <!-- <div style="color: red; font-size: 8px">
              注释:鼠标左键双击选中行可删除
            </div> -->
            <!--       @row-dblclick="dbclick" -->
            <el-table border v-loading="loading" :data="OnenewpacName" :row-class-name="tableRowClassName" height="478">
              <el-table-column label="项目名称" align="center" prop="proName">
                <template slot-scope="scope">
                  {{ scope.row.proName }}
                </template>
              </el-table-column>
 
              <el-table-column label="操作" align="center" width="68">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" icon="el-icon-delete"
                    @click="handledbelete(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div style="font-size: 16px; margin-top: 10px">
              当前项目条数:<span style="font-weight: 700">{{
                OnenewpacName.length
              }}</span>条
            </div>
          </el-col>
          <el-col :span="2" :xs="24">
            <div style="margin: 240% 16%">
              <el-button type="primary" size="medium " icon="el-icon-back" @click="resetright">确 认</el-button>
            </div>
          </el-col>
          <el-col :span="8" :xs="24">
            <el-form :model="queryParams1" ref="queryForm" size="small" :inline="true" v-show="showSearch"
              label-width="68px" @submit.native.prevent>
              <el-form-item label="项目名称" prop="proName">
                <el-input ref="inputName" v-model="queryParams1.proName" placeholder="请输入项目名称" clearable
                  @keyup.enter.native="handleSearchFor" style="width: 140px" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchFor">搜索</el-button>
              </el-form-item>
            </el-form>
            <el-table border v-loading="loading" ref="tre" :data="Treedata" @selection-change="handleChangesingle"
              height="478">
              <el-table-column type="selection" width="40px" align="center" />
              <el-table-column label="项目名称" align="center" prop="proName" />
              <el-table-column label="项目价格/元" align="center" prop="proPrice" />
            </el-table>
          </el-col>
        </el-row>
        <div slot="footer" class="dialog-footer1">
          <el-button type="primary" @click="submitrighr">确 定</el-button>
          <el-button @click="cancell">取 消</el-button>
        </div>
      </el-dialog>
    </div>
 
    <div>
      <el-dialog :title="title" :visible.sync="openOne" width="1400px" append-to-body :close-on-click-modal="false">
        <div class="info-header" style="
            margin-bottom: 15px;
            padding: 10px;
            background-color: #f5f7fa;
            border-radius: 4px;
          ">
          <el-row :gutter="20">
            <el-col :span="8">
              <span>项目名称:{{ forms.groupingName }}</span>
            </el-col>
            <el-col :span="8">
              <span>性别:{{
                forms.sex === "1" ? "女" : forms.sex === "0" ? "男" : "未知"
              }}</span>
            </el-col>
            <el-col :span="8">
              <span>年龄范围:{{ forms.ltAge }}-{{ forms.gtAge }}岁</span>
            </el-col>
          </el-row>
        </div>
        <el-row :gutter="24" v-if="!isTableVisible">
          <el-col :span="15" :xs="24">
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="46px"
              style="height: 50px" @submit.native.prevent>
              <el-form-item label="原价">
                <el-input ref="inputName" v-model="queryParams.price" placeholder="合计" clearable style="width: 140px" />
              </el-form-item>
              <el-form-item label="折扣">
                <el-input-number ref="inputNumber" style="width: 150px" v-model="youhui" :precision="1" :step="0.1"
                  :min="0" :max="10" @change="debounceNumberChange" :debounce="3000"></el-input-number>
              </el-form-item>
              <el-form-item label="现价">
                <el-input ref="inputName" v-model="queryParams.xianprice" placeholder="合计" clearable
                  style="width: 140px" @input="changeXianjia" @blur="numberChangeXianPrice(youhui, youhui)" />
              </el-form-item>
              <el-form-item>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuerys">重置</el-button>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="Package" size="mini" style="margin-right: 20px">选择套餐</el-button>
              </el-form-item>
            </el-form>
            <el-table border v-loading="loading" :data="OnenewpacName" :row-class-name="tableRowClassName" height="478"
              :cell-style="{ padding: '5px 0' }">
              <el-table-column label="项目名称" align="center" prop="proName" width="410">
                <template slot-scope="scope">
                  {{ scope.row.proName }}
                </template>
              </el-table-column>
              <el-table-column label="原价" align="center" prop="proPrice" width="85"></el-table-column>
              <el-table-column label="折扣" width="151">
                <template slot-scope="scope">
                  <!-- 只输入纯数字折扣  @input="validateDiscount(scope.row)"-->
                  <el-input-number v-model="scope.row.limits" @change="handleManualChange(scope.row)" placeholder="输入折扣"
                    size="mini" type="number" :min="0" :step="0.1" :precision="1" :max="10">
                  </el-input-number>
                </template>
              </el-table-column>
              <el-table-column label="现价" align="center" prop="ysPrice" width="85"></el-table-column>
              <el-table-column label="操作" align="center" width="85">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" icon="el-icon-delete"
                    @click="handledbelete(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div style="font-size: 16px; margin-top: 10px">
              当前项目条数:<span style="font-weight: 700">{{
                OnenewpacName.length
              }}</span>条
            </div>
          </el-col>
          <!-- <el-col :span="2" :xs="24">
            <div style="margin: 240% 16%" class="btntoleft">
              <el-button type="primary" size="medium"
                style="writing-mode: vertical-rl; text-align: center; letter-spacing: 5px;" @click="resetright">
                确
                认
                <i class="el-icon-back"></i>
              </el-button>
            </div>
          </el-col> -->
          <el-col :span="7" :xs="24">
            <el-form :model="queryParams1" ref="queryForm" size="small" :inline="true" v-show="showSearch"
              label-width="68px" @submit.native.prevent>
              <el-form-item label="项目名称" prop="proName">
                <el-input ref="inputName" v-model="queryParams1.proName" placeholder="请输入项目名称" clearable
                  @keyup.enter.native="handleSearchFor" style="width: 140px" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchFor">搜索</el-button>
              </el-form-item>
            </el-form>
            <el-table border v-loading="loading" ref="tre" :data="Treedata" @selection-change="handleChangesingle"
              height="478" style="width: 100%">
              <el-table-column type="selection" width="40px" align="center" />
              <el-table-column label="项目名称" align="center" prop="proName" width="230px" />
              <el-table-column label="项目价格/元" align="center" prop="proPrice" width="100px" />
            </el-table>
          </el-col>
        </el-row>
        <el-row :gutter="24" v-else>
          <el-col :span="6" :xs="24">
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px"
              @submit.native.prevent>
              <el-form-item label="套餐名称" prop="pacName">
                <el-input ref="inputName" v-model="queryParams.pacName" placeholder="请输入套餐名称" clearable
                  @keyup.enter.native="handleSearch" style="width: 140px" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearch">搜索</el-button>
              </el-form-item>
            </el-form>
            <el-table ref="tbone" border v-loading="loading" :data="newpacName" @selection-change="handleChangeOne"
              height="483">
              <!-- <el-table-column type="selection" width="40px" align="center" /> -->
 
              <el-table-column label="序号" align="center" prop="newID" width="50px">
                <template slot-scope="scope">
                  {{ scope.row.newID }}
                </template>
              </el-table-column>
 
              <el-table-column label="套餐名称/价格/元" align="center" prop="pacName">
                <template slot-scope="scope">
                  {{ scope.row.pacName + "/" + scope.row.price }}
                </template>
              </el-table-column>
            </el-table>
            <div style="font-size: 16px; margin-top: 10px">
              项目总条数:<span style="font-weight: 700; margin-right: 5px">{{
                newpacName.length
              }}</span>条
            </div>
          </el-col>
          <el-col :span="8" :xs="24">
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="46px"
              style="height: 51px" @submit.native.prevent>
              <el-form-item label="合计" prop="price">
                <el-input ref="inputName" v-model="queryParams.price" placeholder="合计" clearable style="width: 140px" />
              </el-form-item>
              <el-form-item>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuerys">重置</el-button>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="Package" size="mini" style="margin-right: 20px">选择套餐</el-button>
              </el-form-item>
            </el-form>
            <el-table border v-loading="loading" :data="OnenewpacName" :row-class-name="tableRowClassName" height="478"
              :cell-style="{ padding: '5px 0' }">
              <el-table-column label="项目名称" align="center" prop="proName" width="170">
                <template slot-scope="scope">
                  {{ scope.row.proName }}
                </template>
              </el-table-column>
              <el-table-column label="原价" align="center" prop="proPrice"></el-table-column>
              <el-table-column label="操作" align="center" width="68">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" icon="el-icon-delete"
                    @click="handledbelete(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div style="font-size: 16px; margin-top: 10px">
              当前项目条数:<span style="font-weight: 700">{{
                OnenewpacName.length
              }}</span>条
            </div>
          </el-col>
          <!-- <el-col :span="2" :xs="24">
            <div style="margin: 240% 16%">
              <el-button type="primary" size="medium " icon="el-icon-back"
                style="writing-mode: vertical-rl; text-align: center;letter-spacing: 10px;" @click="resetright">确
                认</el-button>
            </div>
          </el-col> -->
          <el-col :span="8" :xs="24">
            <el-form :model="queryParams1" ref="queryForm" size="small" :inline="true" v-show="showSearch"
              label-width="68px" @submit.native.prevent>
              <el-form-item label="项目名称" prop="proName">
                <el-input ref="inputName" v-model="queryParams1.proName" placeholder="请输入项目名称" clearable
                  @keyup.enter.native="handleSearchFor" style="width: 140px" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchFor">搜索</el-button>
              </el-form-item>
            </el-form>
            <el-table border v-loading="loading" ref="tre" :data="Treedata" @selection-change="handleChangesingle"
              height="478">
              <el-table-column type="selection" width="40px" align="center" />
              <el-table-column label="项目名称" align="center" prop="proName" width="288" />
              <el-table-column label="项目价格/元" align="center" prop="proPrice" width="100" />
            </el-table>
          </el-col>
        </el-row>
        <div slot="footer" class="dialog-footer1">
          <el-button type="primary" @click="submitrighr">确认并保存</el-button>
          <el-button @click="cancell">取 消</el-button>
        </div>
      </el-dialog>
    </div>
 
    <el-dialog :visible.sync="taocan" width="70%" height="700px" :close-on-click-modal="false">
      <!-- <el-form :model="queryParam" ref="queryForm" size="small" :inline="true" label-width="auto">
        <el-form-item label="套餐名称" prop="pacName">
          <el-input v-model="queryParam.pacName" placeholder="请输入套餐名称" clearable @keyup.enter.native="handle"
            style="width: 200px" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handle">搜索</el-button>
        </el-form-item>
      </el-form> -->
 
      <el-radio-group v-model="taocanStatus" @input="radioChangetaocan" style="margin-left: 10px;margin-bottom: 20px;">
        <el-radio-button label="0">基础套餐</el-radio-button>
        <el-radio-button label="1">单位套餐</el-radio-button>
      </el-radio-group>
      <div>
        <el-form :model="formdanwen" ref="queryForm" size="small" :inline="true" label-width="68px"
          @submit.native.prevent v-if="taocanStatus == 1">
          <el-form-item label="单位名称" prop="drugManufacturerId">
            <el-select v-model="formdanwen.drugManufacturerId" remote filterable style="width: 200px"
              placeholder="请选择单位名称" clearable>
              <el-option v-for="dict in compList" :key="dict.cnName" :label="dict.cnName"
                :value="dict.drugManufacturerId" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuerydanwen"
              style="margin: 0 15px">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="loading" element-loading-text="正在加载中..." element-loading-spinner="el-icon-loading" border
          :data="newpacName1" @selection-change="handleSelectionChange1" height="450px" ref="tb">
          <el-table-column type="selection" width="40px" align="center" label="选择" />
          <el-table-column label="套餐名称" align="center" prop="pacName" width="120px" />
          <el-table-column label="套餐价格" align="center" prop="price" width="120px" />
          <el-table-column label="套餐明细" align="center" prop="allProName" :show-overflow-tooltip="true" />
        </el-table>
      </div>
      <!-- <div v-else>
 
      </div> -->
 
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel1">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
 
    <!-- 添加或修改体检单位信息维护对话框 -->
    <div class="dia">
      <el-dialog :title="title" :visible.sync="open" width="1330px" append-to-body>
        <el-form ref="form" :model="form" :rules="rules" label-width="98px" :inline="true" @submit.native.prevent>
          <el-form-item label="单位类型" prop="dwlx">
            <el-radio-group v-model="form.dwlx" @input="radioChange">
              <el-radio :label="0">普通单位</el-radio>
              <el-radio :label="1">职业病单位</el-radio>
            </el-radio-group>
          </el-form-item>
          <br />
          <el-form-item label="单位名称" prop="cnName">
            <el-input v-model="form.cnName" placeholder="请输入中文名称" style="width:510px" />
          </el-form-item>
          <el-form-item label="统一信用代码" prop="taxNumber">
            <el-input v-model="form.taxNumber" placeholder="请输入统一信用代码" style="width: 510px" />
          </el-form-item>
          <el-form-item label="法人代表" prop="legalPerson">
            <el-input v-model="form.legalPerson" placeholder="请输入法人" />
          </el-form-item>
          <el-form-item label="联系人" prop="contactPerson">
            <el-input v-model="form.contactPerson" placeholder="请输入联系人" />
          </el-form-item>
          <el-form-item label="联系电话" prop="contactPhone">
            <el-input v-model="form.contactPhone" placeholder="请输入联系电话" />
          </el-form-item>
          <el-form-item label="传真" prop="faxNumber">
            <el-input v-model="form.faxNumber" placeholder="请输入传真" />
          </el-form-item>
 
          <!-- <el-form-item label="编码" prop="code">
          <el-input v-model="form.code" placeholder="请输入编码" />
        </el-form-item> -->
 
          <el-form-item label="注册地址" prop="registerAddress">
            <el-input v-model="form.registerAddress" placeholder="请输入注册地址" style="width: 1128px" />
          </el-form-item>
          <el-form-item label="通讯地址" prop="mailingAddress">
            <el-input v-model="form.mailingAddress" placeholder="请输入通讯地址" style="width: 1128px" />
          </el-form-item>
          <el-form-item label="所属地区" prop="ssdq" v-if="form.dwlx == 1">
            <el-input v-model="form.ssdq" placeholder="请输入所属地区" />
          </el-form-item>
          <el-form-item label="隶属关系" prop="lsgx" v-if="form.dwlx == 1">
            <!-- <el-input
              v-model="form.industryType"
              placeholder="请输入隶属关系"
            /> -->
            <el-select filterable v-model="form.lsgx" placeholder="请选择隶属关系" clearable style="width: 198px">
              <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="经济类型" prop="jjlx" v-if="form.dwlx == 1">
            <el-select filterable v-model="form.jjlx" placeholder="请选择经济类型" clearable style="width: 199px">
              <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="企业规模" prop="qygm" v-if="form.dwlx == 1">
            <el-input v-model="form.qygm" placeholder="请输入企业规模" />
          </el-form-item>
          <el-form-item label="行业分类" prop="hyfl" v-if="form.dwlx == 1">
            <el-select filterable v-model="form.hyfl" placeholder="请选择行业分类" clearable style="width: 199px">
              <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="风险评估" prop="fxpg" v-if="form.dwlx == 1">
            <el-select filterable v-model="form.fxpg" placeholder="请选择风险评估" clearable style="width: 198px">
              <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
          <br />
          <el-form-item label="开户银行" prop="bankAccount">
            <el-input v-model="form.bankAccount" placeholder="请输入开户银行" style="width: 510px" />
          </el-form-item>
          <el-form-item label="银行账户" prop="countNum">
            <el-input v-model="form.countNum" placeholder="请输入银行账户" style="width: 510px" />
          </el-form-item>
          <el-form-item label="联系邮箱" prop="email">
            <el-input v-model="form.email" placeholder="请输入邮箱" />
          </el-form-item>
          <el-form-item label="负责人" prop="principal">
            <el-input v-model="form.principal" placeholder="请输入负责人" />
          </el-form-item>
          <el-form-item label="网址" prop="url">
            <el-input v-model="form.url" placeholder="请输入网址" />
          </el-form-item>
 
          <el-form-item label="行政区划名称" prop="areaName">
            <el-select filterable v-model="form.areaName" placeholder="请选择行政区划名称" clearable style="width: 198px">
              <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
 
          <el-form-item label="备注" prop="remark">
            <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" :rows="2" label-width="400px"
              style="width: 830px" resize="none"></el-input>
          </el-form-item>
          <!-- <el-form-item label="五笔简码" prop="wbm">
          <el-input v-model="form.wbm" placeholder="请输入五笔简码" />
        </el-form-item> -->
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
 
<script>
import Big from "big.js";
import {
  listComp,
  getComp,
  delComp,
  addComp,
  updateComp,
  addDept,
  Deptlist,
  deldwdept,
  getDwAndDwDept,
  dwgrouping,
  getProjectList,
  getPackageList,
  delegrouping,
  getDetails,
  huoqutuantitaocanxiangmuList
} from "@/api/system/comp";
import {
  deptTreeSelect,
  projectGetList,
  getconfigKey,
} from "@/api/system/tijian";
import { getInfo } from "@/api/login";
export default {
  name: "Comp",
  dicts: [
    "dict_comp_type",
    "dict_data_status",
    "sys_user_sex",
    "reservation_pay_type",
    "sys_yes_no", "sys_normal_disable"
  ],
  data() {
    let checkPhoneNum = (rule, value, callback) => {
      let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
      if (value == "" && value == undefined && !value) {
        return callback("");
      } else if (value != undefined && value != "") {
        return callback();
      } else if (!patter.test(value)) {
        return callback("");
      }
    };
    return {
      // 遮罩层
      loading: true,
      taocanStatus: 0,
      Treedata: [],
      id: "",
      // 选中数组
      ids: [],
      newpacName1: [],
      taocan: false,
      // 控制性别选择框是否禁用
      isSexDisabled: false,
      dwIds: [],
      groupIds: [],
      deptList: [],
      selectionList: [],
      newpacName: [],
      OnenewpacName: [],
      pacList: [],
      dataList: [],
      groupList: [],
      dataLists: [],
      // 非单个禁用
      single: true,
      singleg: true,
      singlegg: true,
      isfalse: false,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      dwlxs: null,
      // 总条数
      total: 0,
      // 体检单位信息维护表格数据
      compList: [],
      groupingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      opens: false,
      openss: false,
      openOne: false,
      queryParams1: {
        proName: null,
        pym: null,
      },
      formdanwen: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cnName: null,
        enName: null,
        code: null,
        price: null,
        xianprice: null,
        limits: null,
      },
 
      id: "",
      // 表单参数
      form: {
        isZybUnit: 0,
      },
      lastXianPrice: 0,
      forms: {
        limits: 10,
        ltAge: 0,
        gtAge: 100,
        groupingName: "",
        pacName: "",
        payType: "1",
        sex: "2",
      },
      sfzs: "",
      youhui: "",
      // 表单校验
      rules: {
        cnName: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
        dwDeptName: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        groupingName: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        gtAge: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
        limits: [
          { required: false, validator: checkPhoneNum, trigger: "blur" },
        ],
        ltAge: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
        /*  pacName: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ], */
        payType: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        sex: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
 
        deleted: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        contactPerson: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        contactPhone: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        // taxNumber: [
        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
        // ],
        // legalPerson: [
        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
        // ],
        // registerAddress: [
        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
        // ],
        // bankAccount: [
        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
        // ],
        // countNum: [
        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
        // ],
        // principal: [
        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
        // ],
        // faxNumber: [
        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
        // ],
        // mailingAddress: [
        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
        // ],
        // email: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
      },
    };
  },
  computed: {
    // 根据 sfzs 字段的值来控制表格是否显示
    isTableVisible() {
      return this.sfzs === "Y";
    },
  },
 
  created() {
    this.getList();
  },
  methods: {
    handleManualChange(row) {
      console.log("这是主动出发的");
      this.updateProPrice(row);
    },
    validateDiscount(row) {
      if (
        this.queryParams.xianprice !== undefined &&
        !isNaN(this.queryParams.xianprice) &&
        this.queryParams.xianprice !== this.lastXianPrice
      ) {
        // 只有在现价实际由用户输入修改时才更新
        this.updateProPrice1(row);
        this.lastXianPrice = this.queryParams.xianprice;
      }
    },
    updateProPrice(row) {
      const proPrice = new Big(row.proPrice);
      const limits = new Big(row.limits);
      const result = proPrice.times(limits.div(10)).toNumber(); // ordPrice * (discount / 10)
      row.ysPrice = result.toFixed(2);
      this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => {
        return sum.plus(new Big(item.ysPrice || "0"));
      }, new Big(0)).toNumber();
      this.youhui =
        (Math.floor(
          (this.queryParams.xianprice / this.queryParams.price) * 100
        ) /
          100) *
        10;
    },
    updateProPrice1(row) {
      const proPrice = new Big(row.proPrice);
      const limits = new Big(row.limits);
      const result = proPrice.times(limits.div(10)).toNumber(); // ordPrice * (discount / 10)
      row.ysPrice = result.toFixed(2);
      const totalYsPrice = this.OnenewpacName.reduce((sum, item) => {
        return sum.plus(new Big(item.ysPrice || "0"));
      }, new Big(0));
      const totalYsPriceNum = totalYsPrice.toNumber();
      if (
        this.queryParams.xianprice !== undefined &&
        !isNaN(this.queryParams.xianprice)
      ) {
        const xianPrice = new Big(this.queryParams.xianprice);
        const diff = xianPrice.minus(totalYsPriceNum);
        if (!diff.eq(0) && this.OnenewpacName.length > 0) {
          const lastItem = this.OnenewpacName[this.OnenewpacName.length - 1];
          const newYsPrice = new Big(lastItem.ysPrice).plus(diff).toNumber();
          this.$set(
            this.OnenewpacName[this.OnenewpacName.length - 1],
            "ysPrice",
            newYsPrice
          );
        }
      }
 
      // Update youhui calculation
 
      if (this.queryParams.price !== 0 && this.queryParams.xianprice !== 0) {
        this.youhui =
          (Math.floor(
            (this.queryParams.xianprice / this.queryParams.price) * 100
          ) /
            100) *
          10;
      } else {
        this.youhui = 10;
      }
    },
    debounceNumberChange(currentValue, oldValue) {
      clearTimeout(this.debounceTimer);
      this.debounceTimer = setTimeout(() => {
        this.numberChange(currentValue, oldValue);
      }, 300);
    },
    changeXianjia() {
      // 原始折扣率计算
      if (this.queryParams.price !== 0) {
        this.youhui =
          (Math.floor(
            (this.queryParams.xianprice / this.queryParams.price) * 100
          ) /
            100) *
          10;
      }
    },
 
    getList() {
      this.$nextTick(() => {
        this.$refs.inputName.focus();
      }),
        (this.loading = true);
      listComp(this.queryParams).then((response) => {
        this.compList = response.rows;
 
        response.rows.forEach((item, index) => {
          item.newID =
            (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
            index +
            1;
        });
        this.total = response.total;
        this.loading = false;
      });
    },
 
    cancel() {
      this.open = false;
      this.opens = false;
      // this.$router.go(0);
    },
 
    // 取消套餐
    cancell() {
      this.openss = false;
      this.openOne = false;
      this.youhui = 10;
      // this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        drugManufacturerId: null,
        cnName: null,
        enName: null,
        taxNumber: null,
        legalPerson: null,
        code: null,
        contactPerson: null,
        contactPhone: null,
        typeOfEnterprise: null,
        areaid: null,
        areaName: null,
        principal: null,
        mailingAddress: null,
        url: null,
        email: null,
        bankAccount: null,
        faxNumber: null,
        registerAddress: null,
        gmpNo: null,
        gmpissueDate: null,
        businessLicenseNumber: null,
        gmpDeadlineDate: null,
        gmpRange: null,
        gmpDelayRange: null,
        gmpDelayDate: null,
        gmpPhoto: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        orderNum: null,
        effective: null,
        spell: null,
        validTime: null,
        wbm: null,
        deleted: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    resetQuerys() {
      (this.OnenewpacName = []),
        (this.queryParams.price = 0),
        (this.queryParams.xianprice = 0),
        (this.youhui = 0);
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      selection.forEach((item) => {
        this.form = item;
      });
      this.ids = selection.map((item) => item.drugManufacturerId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
      if (selection.length > 1) {
        // 如果选择了多行,保留最后一行
        this.$refs.tab.clearSelection(); // 清空所有选择
        this.$refs.tab.toggleRowSelection(selection[selection.length - 1]); // 重新选择最后一项
      }
    },
    // 部门表格单行获取
    handleSelection(selection) {
      this.selectionList = selection;
      if (selection.length > 1) {
        let del_row = selection.shift();
        this.$refs.tb.toggleRowSelection(del_row, false); //设置这一行取消选中
      }
      this.dwIds = selection.map((item) => item.id);
      this.singleg = !selection.length;
      if (this.selectionList.length && this.selectionList[0].id) {
        this.beCurrent();
      } else {
        this.GroupUpdate();
      }
 
      /* if (this.selectionList.length) {
        // 如果第一个表格有选中项,选中第二个表格对应的数据
        const selectedDeptId = this.selectionList[0].id; // 假设每个项有一个唯一的 id
        const correspondingGroups = this.groupingList.filter(
          (group) => group.deptId === selectedDeptId
        );
        this.groupList = correspondingGroups;
      } else {
        // 如果没有选中任何项,清空第二个表格的选中项
        this.groupList = [];
        this.$refs.tbs.clearSelection();
      } */
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.form.isZybUnit = 0;
      this.open = true;
      this.title = "添加体检单位信息维护";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const drugManufacturerId = row.drugManufacturerId || this.ids;
      getComp(drugManufacturerId).then((response) => {
        // 不要直接赋值整个 response.data,而是逐个属性赋值
        Object.assign(this.form, response.data);
        this.form.isZybUnit = response.data.isZybUnit === true ? 1 : 0;
        this.form.dwlx = Number(response.data.dwlx)
        console.log("修改时的 isZybUnit 值:", this.form.isZybUnit);
        this.open = true;
        this.title = "修改体检单位信息维护";
      });
    },
    // 维护部门
    mainDepartment() {
      this.opens = true;
 
      this.groupingList = [];
      this.dwlxs = this.form.dwlx
      if (this.form.drugManufacturerId) {
        this.beCurrentDept();
      }
      this.title = "套餐分组维护" + "( " + this.form.cnName + ")";
    },
    numberChange(currentValue, oldValue) {
      this.$confirm("确定修改所有子项的折扣吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.youhui = currentValue;
 
          this.OnenewpacName.forEach((item) => {
            item.limits = this.youhui;
            const proPrice = new Big(item.proPrice);
            const limits = new Big(item.limits);
            const result = proPrice.times(limits.div(10)); // ordPrice * (discount / 10)
            item.ysPrice = result.toNumber();
            this.queryParams.xianprice = this.OnenewpacName.reduce(
              (sum, item) => {
                return sum.plus(new Big(item.ysPrice || "0"));
              },
              new Big(0)
            ).toNumber();
          });
        })
        .catch(() => {
          this.youhui = oldValue;
        });
    },
    numberChangeXianPrice(currentValue, oldValue) {
      // 如果现价没有变化,直接返回
      if (
        this.queryParams.xianprice === this.lastXianPrice ||
        !this.queryParams.xianprice
      ) {
        return;
      }
 
      this.$confirm("确定修改所有子项的折扣吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          // 确保修改折扣的值
          this.youhui = currentValue;
 
          let totalYsprice = new Big(0); // 初始化总 ysprice
          // 遍历每个项目,更新每个子项的价格
          this.OnenewpacName.forEach((item) => {
            item.limits = this.youhui;
            const proPrice = new Big(item.proPrice);
            const limits = new Big(item.limits);
            const result = proPrice.times(limits.div(10)); // ordPrice * (discount / 10)
            item.ysPrice = result.toNumber();
            totalYsprice = totalYsprice.plus(new Big(item.ysPrice));
          });
          // 如果总的 ysPrice 和查询参数中的 xianprice 不一致,进行调整
          if (!totalYsprice.eq(this.queryParams.xianprice)) {
            const diff = new Big(this.queryParams.xianprice).minus(
              totalYsprice
            );
            // 如果 OnenewpacName 数组不为空,调整最后一项的 ysPrice
            if (this.OnenewpacName.length > 0) {
              const lastItem =
                this.OnenewpacName[this.OnenewpacName.length - 1];
              const newYsPrice = new Big(lastItem.ysPrice)
                .plus(diff)
                .toNumber();
              // 使用 $set 确保响应性更新
              this.$set(
                this.OnenewpacName[this.OnenewpacName.length - 1],
                "ysPrice",
                newYsPrice
              );
            }
          }
          // 更新 lastXianPrice 以便下次比较
          this.lastXianPrice = this.queryParams.xianprice;
        })
        .catch(() => {
          // 如果取消修改,恢复原有的优惠值
          this.youhui = oldValue;
        });
    },
 
    changegroupingName() {
      if (this.selectionList.length <= 0) {
        this.$modal.msgError("请先选中部门或添加新的部门");
      }
    },
    // 套餐获取
    changeName() {
      this.openss = true;
      this.title = "分组项目维护";
      this.OnenewpacName = [];
      this.queryParams.price = 0;
      this.loading = true;
      if (this.forms.sex) {
        deptTreeSelect(this.forms.sex).then((response) => {
          this.newpacName = response.rows;
          this.loading = false;
          response.rows.forEach((item, index) => {
            item.newID =
              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
              index +
              1;
          });
        });
      } else {
        deptTreeSelect().then((response) => {
          this.newpacName = response.rows;
          this.loading = false;
          response.rows.forEach((item, index) => {
            item.newID =
              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
              index +
              1;
          });
        });
      }
      getProjectList().then((response) => {
        this.Treedata = response.data;
      });
    },
    getpro() {
      getProjectList().then((response) => {
        this.Treedata = response.data;
      });
    },
    handleSearch() {
      if (this.queryParams.pacName) {
        getPackageList(this.queryParams.pacName).then((response) => {
          this.newpacName = response.data;
          response.data.forEach((item, index) => {
            item.newID =
              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
              index +
              1;
          });
        });
      } else {
        deptTreeSelect().then((response) => {
          this.newpacName = response.rows;
          response.rows.forEach((item, index) => {
            item.newID =
              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
              index +
              1;
          });
          if (this.newpacName.length != 0) {
            this.$nextTick(() => {
              this.$refs.tbone.toggleRowSelection(this.newpacName[0], true);
            });
          } else {
            this.$refs.tbone.clearSelection();
          }
        });
      }
    },
    handleSearchFor() {
      // 判断是否为汉字
      const isChineseChar = (char) => /[\u4E00-\u9FA5]/.test(char);
      if (isChineseChar(this.queryParams1.proName)) {
        this.queryParams1.pym = null;
        getProjectList(this.queryParams1).then((response) => {
          this.Treedata = response.data;
        });
      } else {
        this.queryParams1.pym = this.queryParams1.proName;
        this.queryParams1.proName = null;
        getProjectList(this.queryParams1).then((response) => {
          this.Treedata = response.data;
        });
      }
    },
    // 单项数据获取
    handleChangesingle(selection) {
      if (selection) {
        this.dataList = selection;
        this.resetright();
      }
    },
    resetright() {
      if (this.dataList.length == 0) {
        return; // 如果数据列表为空,直接返回
      } else {
        this.queryParams.price = 0; // 初始化总价
        this.queryParams.xianprice = 0; // 初始化现价
        this.youhui = 0; // 初始化优惠
 
        const newItemsToAdd = []; // 用于存储新需要添加的项目
 
        this.dataList.forEach((item) => {
          this.$refs.tre.toggleRowSelection(item, false); // 取消选中状态
          // 使用 $set 确保响应性
          this.$set(item, "limits", 10); // 设置限制数量
          this.$set(item, "ysPrice", item.proPrice); // 设置现价为原价
 
          // 检查是否已经存在相同的项目
          const existingItem = this.OnenewpacName.find(
            (existing) => existing.proId === item.proId
          );
          if (!existingItem) {
            newItemsToAdd.push(item); // 如果不存在相同项目,则添加到新数组
            this.updateProPrice(item);
          }
        });
 
        // 添加新项目到 OnenewpacName
        this.OnenewpacName.push(...newItemsToAdd);
 
        // 删除重复项目,这里我们只需处理新添加的项目和原有项目之间的重复
        for (
          let i = this.OnenewpacName.length - newItemsToAdd.length;
          i < this.OnenewpacName.length - 1;
          i++
        ) {
          for (let j = i + 1; j < this.OnenewpacName.length; j++) {
            if (this.OnenewpacName[i].proId === this.OnenewpacName[j].proId) {
              this.OnenewpacName.splice(j, 1); // 删除重复的项目
              j--; // 因为删除了一个元素,当前的j要减1
            }
          }
        }
        this.queryParams.price = 0;
        this.queryParams.xianprice = 0;
        // 重新计算总价和现价
        this.OnenewpacName.forEach((item) => {
          this.queryParams.price += item.proPrice; // 累加原价
          //this.queryParams.xianprice += item.ysPrice || 0;  累加现价,如果ysPrice为undefined则累加0
        });
        this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => {
          return sum.plus(new Big(item.ysPrice || "0"));
        }, new Big(0)).toNumber();
        this.youhui =
          (Math.floor(
            (this.queryParams.xianprice / this.queryParams.price) * 100
          ) /
            100) *
          10;
      }
    },
    handledbelete(row) {
      this.queryParams.price = 0;
      this.queryParams.xianprice = 0; // 初始化现价
      this.youhui = 0; // 初始化优惠
 
      // 先找到并删除项目
      this.OnenewpacName = this.OnenewpacName.filter(
        (item) => item.proId !== row.proId
      );
 
      // 然后更新总价和现价
      this.OnenewpacName.forEach((item) => {
        this.queryParams.price += item.proPrice;
        this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => {
          return sum.plus(new Big(item.ysPrice || "0"));
        }, new Big(0)).toNumber();
      });
 
      // 计算优惠
      if (this.queryParams.price > 0) {
        this.youhui =
          (Math.floor(
            (this.queryParams.xianprice / this.queryParams.price) * 100
          ) /
            100) *
          10;
      } else {
        this.youhui = 10;
      }
    },
 
    submitrighr() {
      this.openOne = false;
      this.forms.price = this.queryParams.price;
      this.forms.ysPrice = this.queryParams.xianprice;
      this.forms.limits = this.youhui;
      let mapList = [];
      this.OnenewpacName.forEach((item) => {
        mapList.push({
          proName: item.proName,
          proId: item.proId,
          proPrice: item.proPrice,
          limits: item.limits,
          ysPrice: item.ysPrice,
        });
      });
 
      // 如果 selectionList 为空,使用 mapList 继续保存
      if (this.OnenewpacName.length === 0) {
        this.$modal.msgError("请先选中项目");
        return; // 提示用户选中项目
      }
 
      let data = {
        groupingName: this.forms.groupingName,
        gtAge: this.forms.gtAge,
        limits: this.forms.limits,
        ltAge: this.forms.ltAge,
        pacName: this.forms.pacName,
        payType: this.forms.payType,
        sex: this.forms.sex,
        dwDeptId: this.selectionList.length > 0 ? this.selectionList[0].id : "", // 如果没有选中部门,设置为空
        dwId: this.selectionList.length > 0 ? this.selectionList[0].dwId : "",
        mapList: mapList,
        price: this.forms.price,
        ysPrice: this.forms.ysPrice,
        id: this.groupList[0] ? this.groupList[0].id : "",
      };
 
      // 发送请求保存数据
      dwgrouping(data).then((res) => {
        if (res.code == 200) {
          this.beCurrent();
          this.forms.groupingName = "";
          this.forms.sex = "2";
          this.forms.pacName = "";
          this.forms.price = "";
          this.forms.ysPrice = "";
          this.forms.payType = "1";
        }
      });
 
      // this.handleGroup();
    },
    // 套餐单项获取
    handleChangeOne(selection) {
      if (selection.length > 1) {
        let del_row = selection.shift();
        this.$refs.tbone.toggleRowSelection(del_row, false); //设置这一行取消选中
      }
      this.pacList = selection;
 
      this.dataLists = [];
      this.queryParams.price = 0;
      this.pacList.forEach((item) => {
        this.OnenewpacName = item.tjProjectList;
      });
      this.OnenewpacName.forEach((item) => {
        this.queryParams.price += item.proPrice;
      });
    },
    beCurrentDept() {
      Deptlist(this.form.drugManufacturerId).then((response) => {
        this.deptList = response.data;
        if (this.deptList.length != 0) {
          this.$nextTick(() => {
            this.$refs.tb.toggleRowSelection(this.deptList[0], true);
          });
        } else {
          this.$refs.tb.clearSelection();
        }
      });
    },
 
    // 保存部门
    handleAddDept() {
      let data = {
        dwName: this.form.cnName,
        dwId: this.form.drugManufacturerId,
        dwDeptName: this.form.dwDeptName,
        signingPrice: this.form.signingPrice,
      };
      addDept(data).then((response) => {
        if (response.code == 200) {
          this.beCurrentDept();
        }
      });
    },
    // 删除部门
    handledeleDept() {
      deldwdept(this.dwIds).then((response) => {
        if (response.code == 200) {
          this.beCurrentDept();
        }
      });
    },
 
    handleChange(selection) {
      this.groupList = selection;
      if (selection.length > 0) {
        this.groupList.forEach((item) => {
          this.forms.groupingName = item.groupingName;
          this.forms.gtAge = item.gtAge;
          this.forms.limits = item.limits;
          this.youhui = item.limits;
          this.forms.ltAge = item.ltAge;
          this.forms.pacName = item.pacName;
          this.forms.payType = item.payType;
          this.forms.sex = item.sex;
          this.forms.price = item.price;
          this.forms.ysPrice = item.ysPrice;
        });
        this.isSexDisabled = true; // 禁用性别选择
      } else {
        // 如果没有选中行,清空表单并取消禁用
        this.GroupUpdate();
        this.isSexDisabled = false; // 恢复性别选择框为可用
      }
      this.groupIds = selection.map((item) => item.id);
      this.singlegg = !selection.length;
    },
    handleBeforeClose(done) {
      this.$confirm("确认关闭?")
        .then(() => done())
        .catch(() => {
          /* 取消关闭 */
        });
    },
    xiangmuWh() {
      if (!this.forms.groupingName || !this.forms.sex || !this.forms.payType) {
        this.$modal.msgError("请先填写所有必填项!");
        return; // Stop execution if any required field is empty
      }
      this.openOne = true;
      this.title = "分组项目维护";
      this.OnenewpacName = [];
      this.queryParams.price = 0;
      this.loading = true;
      if (this.groupList[0]) {
        let id = this.groupList[0].id || "";
        getDetails(id).then((res) => {
          this.OnenewpacName = res.data.groupingProList;
          // this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => {
          //   return sum.plus(new Big(item.ysPrice || '0'));
          // }, new Big(0)).toNumber();
 
          // this.OnenewpacName.forEach((item, index) => {
          //   this.queryParams.price += item.proPrice;
          // });
          //
 
          // this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10
          this.queryParams.xianprice = res.data.ysPrice;
          this.queryParams.price = res.data.price;
          this.youhui = res.data.limits;
        });
      }
      // console.log(this.groupList[0].id, 9966);
      getconfigKey("sfzstc").then((res) => {
        this.sfzs = res.msg;
      });
 
      if (this.forms.sex) {
        console.log("进来了if");
 
        deptTreeSelect(this.forms.sex).then((response) => {
          // 套餐名称
          this.newpacName = response.rows;
          this.loading = false;
          response.rows.forEach((item, index) => {
            item.newID =
              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
              index +
              1;
          });
        });
      } else {
        console.log("进来了else");
 
        deptTreeSelect().then((response) => {
          this.newpacName = response.rows;
          this.loading = false;
          response.rows.forEach((item, index) => {
            item.newID =
              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
              index +
              1;
          });
        });
      }
      getProjectList().then((response) => {
        this.Treedata = response.data;
      });
    },
 
    handleGroup() {
      // 如果没有选中任何部门(即没有 selectionList),可以直接从 OnenewpacName 获取数据
      let mapList = [];
      this.OnenewpacName.forEach((item) => {
        mapList.push({
          proName: item.proName,
          proId: item.proId,
          proPrice: item.proPrice,
        });
      });
 
      let data = {
        groupingName: this.forms.groupingName,
        gtAge: this.forms.gtAge,
        limits: this.forms.limits,
        ltAge: this.forms.ltAge,
        pacName: this.forms.pacName,
        payType: this.forms.payType,
        sex: this.forms.sex,
        dwDeptId: this.selectionList.length > 0 ? this.selectionList[0].id : "", // 如果没有选中部门,设置为空
        dwId: this.selectionList.length > 0 ? this.selectionList[0].dwId : "",
        mapList: mapList,
        price: this.forms.price,
        ysPrice: this.forms.ysPrice,
        id: this.groupList[0].id,
      };
 
      // 发送请求保存数据
      dwgrouping(data).then((res) => {
        if (res.code == 200) {
          this.beCurrent();
          this.forms.groupingName = "";
          this.forms.sex = "2";
          this.forms.pacName = "";
          this.forms.price = "";
          this.forms.ysPrice = "";
          this.forms.payType = "1";
        }
      });
    },
    // 修改分组
    GroupUpdate() {
      this.$refs.tbs.clearSelection();
      this.forms = {
        groupingName: "",
        gtAge: "",
        limits: "",
        ltAge: "",
        pacName: "",
        payType: "1",
        sex: "2",
        price: "",
        ysPrice: "",
      };
    },
    beCurrent() {
      let data = {
        deptId: this.selectionList[0].id,
        dwId: this.selectionList[0].dwId,
      };
      getDwAndDwDept(data).then((response) => {
        // 部门名称
        this.groupingList = response.data;
        response.data.forEach((item, index) => {
          item.newID =
            (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
            index +
            1;
        });
      });
    },
    // 删除分组
    deleteGroup() {
      delegrouping(this.groupIds).then((res) => {
        if (res.code == 200) {
          this.beCurrent();
        }
      });
    },
    // 双击
    dbclick(row, column, event) {
      row.isOK = !row.isOK;
 
      this.OnenewpacName[row.index] = JSON.parse(JSON.stringify(row)); // 复制旧的数据,取消时用到
      // 判断是否为双击第二次修改,第二次双击则提交数据进行修改,或者可点击按钮取消
      if (row.isOK == true) {
        this.$confirm("是否需要删除" + row.proName, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.OnenewpacName.splice(row.index, 1); //删除对应的表头
            this.queryParams.price = 0;
            if (this.OnenewpacName.length >= 1) {
              this.OnenewpacName.forEach((item) => {
                this.queryParams.price += item.proPrice;
              });
            } else {
              this.queryParams.price = 0;
            }
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      }
    },
 
    tableRowClassName({ row, rowIndex }) {
      row.index = rowIndex;
    },
 
    Package() {
      this.taocan = true;
      deptTreeSelect(this.forms.sex).then((res) => {
        if (res.rows) {
          this.newpacName1 = res.rows;
        }
      });
    },
 
    handle() {
      this.loading = true;
      deptTreeSelect(this.forms.sex, this.queryParam)
        .then((res) => {
          if (res.rows) {
            this.newpacName1 = res.rows; // 更新套餐列表
          } else {
            this.newpacName1 = [];
          }
          this.loading = false;
        })
        .catch(() => {
          this.loading = false;
          this.$modal.msgError("搜索失败,请稍后重试");
        });
    },
 
 
    radioChange(val) {
      this.reset();
      this.form.dwlx = val
    },
 
    radioChangetaocan(val) {
      if (val == 0) {
        this.getList()
      } else {
        this.handleQuerydanwen()
      }
    },
 
    handleQuerydanwen() {
      let dwId = this.formdanwen.drugManufacturerId
      huoqutuantitaocanxiangmuList(dwId).then(res => {
        this.newpacName1 = res.data
      })
    },
 
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.drugManufacturerId != null) {
            updateComp(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            if (
              this.form.cnName &&
              this.form.contactPerson &&
              this.form.contactPhone
            ) {
              addComp(this.form).then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            } else {
              this.$modal.msgError("请填写必传项");
            }
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const drugManufacturerIds = row.drugManufacturerId || this.ids;
      this.$modal
        .confirm(
          '是否确认删除体检单位信息维护编号为"' +
          drugManufacturerIds +
          '"的数据项?'
        )
        .then(function () {
          return delComp(drugManufacturerIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => { });
    },
 
    submit() {
      if (!this.selectedPackage) {
        this.$modal.msgError("请先选择一个套餐");
        return;
      }
 
      // 清空左侧表格
      this.OnenewpacName = [];
 
      // 获取选中的套餐项目列表
      const newProjects = this.selectedPackage.tjProjectList || [];
      console.log(newProjects, 22222)
      // 将选中的套餐项目添加到左侧表格
      this.loading = true;
      newProjects.forEach((project) => {
        // 为每个项目设置默认折扣和现价
        this.$set(project, "limits", 10); // 默认折扣 10(即原价)
        this.$set(project, "ysPrice", project.proPrice); // 现价初始化为原价
        this.OnenewpacName.push(project);
      });
 
      // 更新总价和现价
      this.queryParams.price = this.OnenewpacName.reduce((sum, item) => {
        return sum + (item.proPrice || 0);
      }, 0);
 
      this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => {
        return sum + (item.ysPrice || 0);
      }, 0);
 
      // 更新优惠值
      this.youhui =
        this.queryParams.price > 0
          ? (Math.floor(
            (this.queryParams.xianprice / this.queryParams.price) * 100
          ) /
            100) *
          10
          : 0;
 
      // 关闭对话框
      this.taocan = false;
      this.loading = false;
      this.$modal.msgSuccess("添加成功");
    },
    cancel1() {
      this.taocan = false;
    },
 
    handleSelectionChange1(selection) {
      console.log(selection, 11111)
      // 实现单选逻辑
      if (selection.length > 1) {
        const lastSelected = selection[selection.length - 1];
        this.$refs.tb.clearSelection();
        this.$refs.tb.toggleRowSelection(lastSelected, true);
        this.selectedPackage = lastSelected;
      } else if (selection.length === 1) {
        this.selectedPackage = selection[0];
      } else {
        this.selectedPackage = null;
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/comp/export",
        {
          ...this.queryParams,
        },
        `comp_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss" scoped>
.pag {
  width: 100%;
  display: flex;
  justify-content: center;
}
 
.pag1 {
  width: 30%;
}
 
.dia {
  display: flex;
}
 
.dialog-footer {
  width: 1300px;
  height: 36px;
  display: flex;
  justify-content: center;
}
 
.dialog-footer1 {
  width: 960px;
  height: 36px;
  display: flex;
  justify-content: center;
  margin: auto;
}
 
.btnback {
  width: 50px;
  height: 100px;
}
 
::v-deep .el-dialog__body {
  padding: 5px 30px;
}
 
::v-deep .el-dialog {
  // height: 750px;
  overflow-y: auto;
}
 
::v-deep .btntoleft .el-button--medium {
  padding: 20px 20px 10px;
  font-size: 14px;
  border-radius: 4px;
}
</style>