cienceTeacher.vue 54.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690
<template>
  <div class="app-container">
    <!-- 页面头部 -->
    <div class="page-header">
      <div class="header-left">
        <h2>科技老师工资</h2>
        <p class="page-desc">管理科技老师工资数据,包括业绩、提成、补贴、扣款等信息</p>
      </div>
      <div class="header-right">
        <el-button 
          type="warning" 
          icon="el-icon-upload2"
          @click="showImportDialog"
          :loading="importLoading"
        >
          导入
        </el-button>
        <el-button 
          type="success" 
          icon="el-icon-download"
          @click="handleExport"
          :loading="exportLoading"
          :disabled="!list || list.length === 0"
        >
          导出
        </el-button>
        <el-button 
          type="primary" 
          icon="el-icon-cpu"
          @click="showCalculateDialog"
          :loading="calculateLoading"
        >
          计算工资
        </el-button>
        <el-button 
          icon="el-icon-refresh" 
          @click="getList"
          :loading="loading"
        >
          刷新
        </el-button>
      </div>
    </div>

    <!-- 搜索区域 -->
    <div class="search-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="50px">
        <el-form-item label="月份" prop="month">
          <el-date-picker
            v-model="queryParams.month"
            type="month"
            placeholder="选择月份"
            format="yyyyMM"
            value-format="yyyyMM"
            style="width: 200px"
          />
        </el-form-item>
        <el-form-item label="门店" prop="storeId">
          <el-select 
            v-model="queryParams.storeId" 
            placeholder="请选择门店"
            clearable
            filterable
            style="width: 200px"
          >
            <el-option
              v-for="store in storeList"
              :key="store.id"
              :label="store.fullName"
              :value="store.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <!-- 批量操作区域 -->
      <div class="batch-action-container" v-if="selectedRows.length > 0">
        <span class="selected-count">已选择 {{ selectedRows.length }} 条记录</span>
        <el-button 
          type="warning" 
          icon="el-icon-lock"
          size="small"
          @click="handleBatchLock"
          :loading="lockLoading"
        >
          批量锁定
        </el-button>
        <el-button 
          type="success" 
          icon="el-icon-unlock"
          size="small"
          @click="handleBatchUnlock"
          :loading="lockLoading"
        >
          批量解锁
        </el-button>
        <el-button 
          type="info" 
          icon="el-icon-close"
          size="small"
          @click="handleClearSelection"
        >
          取消选择
        </el-button>
      </div>
    </div>

    <!-- 数据表格 -->
    <div class="table-container">
      <NCC-table 
        ref="table"
        v-loading="loading" 
        :data="list" 
        border 
        stripe
        height="calc(100vh - 480px)"
        :header-cell-style="{ background: '#f5f7fa', color: '#606266' }"
        @selection-change="handleSelectionChange"
      >
        <!-- 多选列 -->
        <el-table-column type="selection" width="55" align="center" fixed="left" />
        <!-- 基本信息 -->
        <el-table-column prop="StoreName" label="门店名称" width="140" align="center" fixed="left">
          <template slot-scope="scope">
            <div class="store-name">
              <i class="el-icon-shop store-icon"></i>
              <span>{{ scope.row.StoreName || '无' }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="EmployeeName" label="员工姓名" width="130" align="center" fixed="left">
          <template slot-scope="scope">
            <div class="employee-name">
              <i class="el-icon-user employee-icon"></i>
              <span>{{ scope.row.EmployeeName || '无' }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="Position" label="岗位" width="100" align="center" fixed="left">
          <template slot-scope="scope">
            <span>{{ scope.row.Position || '无' }}</span>
          </template>
        </el-table-column>

        <!-- 业绩信息 -->
        <el-table-column label="业绩信息" align="center">
          <el-table-column prop="OrderAchievement" label="开单业绩" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.OrderAchievement) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="ConsumeAchievement" label="消耗业绩" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.ConsumeAchievement) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="RefundAchievement" label="退卡业绩" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.RefundAchievement) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="TotalPerformance" label="总业绩" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.TotalPerformance) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="ProjectCount" label="项目数" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.ProjectCount || '0' }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <!-- 提成信息 -->
        <el-table-column label="提成信息" align="center">
          <el-table-column prop="PerformanceCommissionRate" label="业绩提成比例" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatPercent(scope.row.PerformanceCommissionRate) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="PerformanceCommissionAmount" label="业绩提成金额" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.PerformanceCommissionAmount) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="ConsumeCommissionRate" label="消耗提成比例" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatPercent(scope.row.ConsumeCommissionRate) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="ConsumeCommissionAmount" label="消耗提成金额" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.ConsumeCommissionAmount) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="HandworkFee" label="手工费" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.HandworkFee) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="TotalCommission" label="提成合计" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.TotalCommission) }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <!-- 工资信息 -->
        <el-table-column label="工资信息" align="center">
          <el-table-column prop="BaseSalaryLevel" label="底薪档位" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.BaseSalaryLevel || '0' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="BaseSalary" label="底薪" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.BaseSalary) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="CalculatedGrossSalary" label="核算应发工资" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.CalculatedGrossSalary) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="GuaranteedSalary" label="保底工资" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.GuaranteedSalary) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="GuaranteedLeaveDeduction" label="保底请假扣款" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.GuaranteedLeaveDeduction) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="GuaranteedBaseSalary" label="保底底薪" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.GuaranteedBaseSalary) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="GuaranteedSupplement" label="保底补差" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.GuaranteedSupplement) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="FinalGrossSalary" label="最终应发工资" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.FinalGrossSalary) }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <!-- 考勤信息 -->
        <el-table-column label="考勤信息" align="center">
          <el-table-column prop="WorkingDays" label="在店天数" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.WorkingDays || '0' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="LeaveDays" label="请假天数" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.LeaveDays || '0' }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <!-- 补贴信息 -->
        <el-table-column label="补贴信息" align="center">
          <el-table-column prop="TransportationAllowance" label="车补" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.TransportationAllowance) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="LessRest" label="少休费" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.LessRest) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="FullAttendance" label="全勤奖" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.FullAttendance) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="MonthlyTrainingSubsidy" label="当月培训补贴" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.MonthlyTrainingSubsidy) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="MonthlyTransportSubsidy" label="当月交通补贴" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.MonthlyTransportSubsidy) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="LastMonthTrainingSubsidy" label="上月培训补贴" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.LastMonthTrainingSubsidy) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="LastMonthTransportSubsidy" label="上月交通补贴" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.LastMonthTransportSubsidy) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="TotalSubsidy" label="补贴合计" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.TotalSubsidy) }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <!-- 扣款信息 -->
        <el-table-column label="扣款信息" align="center">
          <el-table-column prop="MissingCard" label="缺卡扣款" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.MissingCard) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="LateArrival" label="迟到扣款" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.LateArrival) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="LeaveDeduction" label="请假扣款" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.LeaveDeduction) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="SocialInsuranceDeduction" label="扣社保" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.SocialInsuranceDeduction) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="RewardDeduction" label="扣除奖励" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.RewardDeduction) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="AccommodationDeduction" label="扣住宿费" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.AccommodationDeduction) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="StudyPeriodDeduction" label="扣学习期费用" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.StudyPeriodDeduction) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="WorkClothesDeduction" label="扣工作服费用" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.WorkClothesDeduction) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="TotalDeduction" label="扣款合计" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.TotalDeduction) }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <!-- 其他信息 -->
        <el-table-column label="其他信息" align="center">
          <el-table-column prop="Bonus" label="发奖金" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.Bonus) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="ReturnPhoneDeposit" label="退手机押金" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.ReturnPhoneDeposit) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="ReturnAccommodationDeposit" label="退住宿押金" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.ReturnAccommodationDeposit) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="LastMonthSupplement" label="补发上月" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.LastMonthSupplement) }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <!-- 支付信息 -->
        <el-table-column label="支付信息" align="center">
          <el-table-column prop="ActualSalary" label="实发工资" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.ActualSalary) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="MonthlyPaymentStatus" label="当月是否发放" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.MonthlyPaymentStatus || '无' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="PaidAmount" label="支付金额" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.PaidAmount) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="PendingAmount" label="待支付金额" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.PendingAmount) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="MonthlyTotalPayment" label="当月支付总额" width="140" align="center">
            <template slot-scope="scope">
              <span>{{ formatMoney(scope.row.MonthlyTotalPayment) }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <!-- 其他字段 -->
        <el-table-column prop="IsNewStore" label="是否新店" width="100" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.IsNewStore || '无' }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="NewStoreProtectionStage" label="新店保护阶段" width="120" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.NewStoreProtectionStage || '0' }}</span>
          </template>
        </el-table-column>
        <!-- 锁定状态列 -->
        <el-table-column prop="IsLocked" label="锁定状态" width="100" align="center" fixed="right">
          <template slot-scope="scope">
            <el-tag :type="scope.row.IsLocked === 1 ? 'danger' : 'success'" size="mini">
              {{ scope.row.IsLocked === 1 ? '已锁定' : '未锁定' }}
            </el-tag>
          </template>
        </el-table-column>
        <!-- 确认状态列 -->
        <el-table-column prop="EmployeeConfirmStatus" label="确认状态" width="100" align="center" fixed="right">
          <template slot-scope="scope">
            <el-tag :type="scope.row.EmployeeConfirmStatus === 1 ? 'success' : 'info'" size="mini">
              {{ scope.row.EmployeeConfirmStatus === 1 ? '已确认' : '未确认' }}
            </el-tag>
          </template>
        </el-table-column>
        <!-- 操作列 -->
        <el-table-column label="操作" width="250" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              icon="el-icon-view"
              @click="handleViewDetail(scope.row)"
            >
              详情
            </el-button>
            <el-button
              v-if="scope.row.IsLocked === 1"
              type="success"
              size="mini"
              icon="el-icon-unlock"
              @click="handleUnlock(scope.row)"
              :loading="lockLoading"
            >
              解锁
            </el-button>
            <el-button
              v-else
              type="warning"
              size="mini"
              icon="el-icon-lock"
              @click="handleLock(scope.row)"
              :loading="lockLoading"
            >
              锁定
            </el-button>
          </template>
        </el-table-column>
        <!-- <el-table-column prop="IsTerminated" label="离职状态" width="100" align="center" fixed="right">
          <template slot-scope="scope">
            <el-tag :type="scope.row.IsTerminated === 1 ? 'warning' : 'success'" size="mini">
              {{ scope.row.IsTerminated === 1 ? '已离职' : '在职' }}
            </el-tag>
          </template>
        </el-table-column> -->
      </NCC-table>
    </div>

    <!-- 计算工资弹窗 -->
    <el-dialog
      title="计算科技老师工资"
      :visible="calculateDialogVisible"
      width="500px"
      :close-on-click-modal="false"
      @close="handleCalculateDialogClose"
    >
      <el-form label-width="100px" label-position="right">
        <el-form-item label="选择月份" required>
          <el-date-picker
            v-model="calculateMonth"
            type="month"
            placeholder="请选择月份"
            format="yyyyMM"
            value-format="yyyyMM"
            style="width: 100%"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCalculateDialogClose">取消</el-button>
        <el-button 
          type="primary" 
          @click="handleCalculateConfirm"
          :loading="calculateLoading"
        >
          确定
        </el-button>
      </div>
    </el-dialog>

    <!-- 详情弹窗 -->
    <tech-teacher-detail-dialog
      :visible.sync="detailDialogVisible"
      :detail-data="currentDetailData"
      @close="handleDetailDialogClose"
    />

    <!-- 导入弹窗 -->
    <el-dialog
      title="导入科技老师工资数据"
      :visible="importDialogVisible"
      width="500px"
      :close-on-click-modal="false"
      @close="handleImportDialogClose"
    >
      <el-upload
        ref="upload"
        action=""
        :auto-upload="false"
        :on-change="handleFileChange"
        :file-list="fileList"
        :limit="1"
        accept=".xlsx,.xls"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">只能上传.xlsx/.xls文件,且不超过10MB</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleImportDialogClose">取消</el-button>
        <el-button 
          type="primary" 
          @click="handleImportConfirm"
          :loading="importLoading"
          :disabled="!importFile"
        >
          确定
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getTechTeacherSalaryList, calculateTechTeacherSalary, lockTechTeacherSalary, importTechTeacherSalaryFromExcel } from '@/api/extend/techTeacherSalary'
import { getStoreSelector } from '@/api/extend/store'
import TechTeacherDetailDialog from './tech-teacher-detail-dialog.vue'

export default {
  name: 'TechTeacherSalary',
  components: {
    TechTeacherDetailDialog
  },
  data() {
    // 获取当前年月
    const getCurrentYear = () => {
      return new Date().getFullYear().toString()
    }
    const getCurrentMonth = () => {
      const now = new Date()
      const year = now.getFullYear()
      const month = String(now.getMonth() + 1).padStart(2, '0')
      return `${year}${month}`
    }

    return {
      loading: false,
      calculateLoading: false,
      exportLoading: false,
      importLoading: false,
      lockLoading: false,
      list: [],
      total: 0,
      storeList: [],
      calculateDialogVisible: false,
      calculateMonth: getCurrentMonth(),
      detailDialogVisible: false,
      currentDetailData: null,
      importDialogVisible: false,
      importFile: null,
      fileList: [],
      selectedRows: [],
      queryParams: {
        currentPage: 1,
        pageSize: 300, // 写死为300
        year: getCurrentYear(),
        month: getCurrentMonth(), // yyyyMM 格式
        storeId: ''
      }
    }
  },
  created() {
    this.getStoreList()
    this.getList()
  },
  methods: {
    // 获取门店列表
    async getStoreList() {
      try {
        const response = await getStoreSelector()
        this.storeList = response.data.list || []
      } catch (error) {
        console.error('获取门店列表失败:', error)
        this.storeList = []
      }
    },

    // 获取列表数据
    async getList() {
      this.loading = true
      try {
        // 处理年月:从month选择器中提取年份和月份
        let year = ''
        let month = ''
        
        if (this.queryParams.month && this.queryParams.month.length === 6) {
          // yyyyMM 格式,如 202512
          year = this.queryParams.month.substring(0, 4)
          month = this.queryParams.month.substring(4, 6)
        } else if (this.queryParams.year && this.queryParams.month) {
          // 分别选择年份和月份
          year = this.queryParams.year
          month = this.queryParams.month.length === 6 
            ? this.queryParams.month.substring(4, 6) 
            : this.queryParams.month
        } else {
          // 使用默认值(当前年月)
          const now = new Date()
          year = now.getFullYear().toString()
          month = String(now.getMonth() + 1).padStart(2, '0')
        }

        const params = {
          currentPage: this.queryParams.currentPage,
          pageSize: this.queryParams.pageSize,
          Year: year,
          Month: month,
          StoreId: this.queryParams.storeId || ''
        }

        const response = await getTechTeacherSalaryList(params)

        if (response.code === 200) {
          this.list = response.data.list || []
          this.total = (response.data.pagination && response.data.pagination.total) || 0
          // 刷新后清除选择
          this.handleClearSelection()
        } else {
          this.$message.error(response.msg || '获取数据失败')
        }
      } catch (error) {
        console.error('获取科技老师工资列表失败:', error)
        this.$message.error('获取数据失败')
      } finally {
        this.loading = false
      }
    },

    // 搜索
    handleQuery() {
      this.queryParams.currentPage = 1
      this.getList()
    },

    // 重置搜索
    resetQuery() {
      const getCurrentYear = () => {
        return new Date().getFullYear().toString()
      }
      const getCurrentMonth = () => {
        const now = new Date()
        const year = now.getFullYear()
        const month = String(now.getMonth() + 1).padStart(2, '0')
        return `${year}${month}`
      }

      this.queryParams = {
        currentPage: 1,
        pageSize: 300, // 写死为300
        year: getCurrentYear(),
        month: getCurrentMonth(),
        storeId: ''
      }
      this.getList()
    },

    // 显示计算工资弹窗
    showCalculateDialog() {
      const getCurrentMonth = () => {
        const now = new Date()
        const year = now.getFullYear()
        const month = String(now.getMonth() + 1).padStart(2, '0')
        return `${year}${month}`
      }
      this.calculateMonth = getCurrentMonth()
      this.calculateDialogVisible = true
    },

    // 关闭计算工资弹窗
    handleCalculateDialogClose() {
      this.calculateDialogVisible = false
    },

    // 确认计算工资
    async handleCalculateConfirm() {
      if (!this.calculateMonth) {
        this.$message.warning('请选择月份')
        return
      }

      // 从calculateMonth中提取年份和月份(yyyyMM格式,如202512)
      let year = ''
      let month = ''
      if (this.calculateMonth && this.calculateMonth.length === 6) {
        year = this.calculateMonth.substring(0, 4)
        month = this.calculateMonth.substring(4, 6)
      } else {
        this.$message.warning('月份格式不正确')
        return
      }

      this.calculateLoading = true
      try {
        const response = await calculateTechTeacherSalary(year, month)
        if (response.code === 200) {
          this.$message.success('计算工资成功')
          this.calculateDialogVisible = false
          this.getList()
        } else {
          this.$message.error(response.msg || '计算工资失败')
        }
      } catch (error) {
        console.error('计算工资失败:', error)
        this.$message.error(error.message || '计算工资失败')
      } finally {
        this.calculateLoading = false
      }
    },

    // 导出功能
    async handleExport() {
      if (!this.list || this.list.length === 0) {
        this.$message.warning('暂无数据可导出')
        return
      }

      this.exportLoading = true
      try {
        // 动态导入 xlsx 库
        const XLSX = await import('xlsx')

        // 构建表头
        const headers = [
          'ID',
          '门店名称',
          '员工姓名',
          '岗位',
          '开单业绩',
          '消耗业绩',
          '退卡业绩',
          '总业绩',
          '项目数',
          '底薪档位',
          '底薪',
          '业绩提成比例',
          '业绩提成金额',
          '消耗提成比例',
          '消耗提成金额',
          '手工费',
          '提成合计',
          '在店天数',
          '请假天数',
          '车补',
          '少休费',
          '全勤奖',
          '当月培训补贴',
          '当月交通补贴',
          '上月培训补贴',
          '上月交通补贴',
          '补贴合计',
          '核算应发工资',
          '保底工资',
          '保底请假扣款',
          '保底底薪',
          '保底补差',
          '最终应发工资',
          '缺卡扣款',
          '迟到扣款',
          '请假扣款',
          '扣社保',
          '扣除奖励',
          '扣住宿费',
          '扣学习期费用',
          '扣工作服费用',
          '扣款合计',
          '发奖金',
          '退手机押金',
          '退住宿押金',
          '补发上月',
          '实发工资',
          '当月是否发放',
          '支付金额',
          '待支付金额',
          '当月支付总额',
          '是否新店',
          '新店保护阶段',
          '锁定状态',
          '离职状态'
        ]

        // 构建数据行
        const dataRows = this.list.map(item => [
          item.Id || '无',
          item.StoreName || '无',
          item.EmployeeName || '无',
          item.Position || '无',
          this.formatMoney(item.OrderAchievement),
          this.formatMoney(item.ConsumeAchievement),
          this.formatMoney(item.RefundAchievement),
          this.formatMoney(item.TotalPerformance),
          item.ProjectCount || '0',
          item.BaseSalaryLevel || '0',
          this.formatMoney(item.BaseSalary),
          this.formatPercent(item.PerformanceCommissionRate),
          this.formatMoney(item.PerformanceCommissionAmount),
          this.formatPercent(item.ConsumeCommissionRate),
          this.formatMoney(item.ConsumeCommissionAmount),
          this.formatMoney(item.HandworkFee),
          this.formatMoney(item.TotalCommission),
          item.WorkingDays || '0',
          item.LeaveDays || '0',
          this.formatMoney(item.TransportationAllowance),
          this.formatMoney(item.LessRest),
          this.formatMoney(item.FullAttendance),
          this.formatMoney(item.MonthlyTrainingSubsidy),
          this.formatMoney(item.MonthlyTransportSubsidy),
          this.formatMoney(item.LastMonthTrainingSubsidy),
          this.formatMoney(item.LastMonthTransportSubsidy),
          this.formatMoney(item.TotalSubsidy),
          this.formatMoney(item.CalculatedGrossSalary),
          this.formatMoney(item.GuaranteedSalary),
          this.formatMoney(item.GuaranteedLeaveDeduction),
          this.formatMoney(item.GuaranteedBaseSalary),
          this.formatMoney(item.GuaranteedSupplement),
          this.formatMoney(item.FinalGrossSalary),
          this.formatMoney(item.MissingCard),
          this.formatMoney(item.LateArrival),
          this.formatMoney(item.LeaveDeduction),
          this.formatMoney(item.SocialInsuranceDeduction),
          this.formatMoney(item.RewardDeduction),
          this.formatMoney(item.AccommodationDeduction),
          this.formatMoney(item.StudyPeriodDeduction),
          this.formatMoney(item.WorkClothesDeduction),
          this.formatMoney(item.TotalDeduction),
          this.formatMoney(item.Bonus),
          this.formatMoney(item.ReturnPhoneDeposit),
          this.formatMoney(item.ReturnAccommodationDeposit),
          this.formatMoney(item.LastMonthSupplement),
          this.formatMoney(item.ActualSalary),
          item.MonthlyPaymentStatus || '无',
          this.formatMoney(item.PaidAmount),
          this.formatMoney(item.PendingAmount),
          this.formatMoney(item.MonthlyTotalPayment),
          item.IsNewStore || '无',
          item.NewStoreProtectionStage || '0',
          item.IsLocked === 1 ? '已锁定' : '未锁定',
          item.IsTerminated === 1 ? '已离职' : '在职'
        ])

        // 合并表头和数据
        const excelData = [headers, ...dataRows]

        // 创建工作表
        const ws = XLSX.utils.aoa_to_sheet(excelData)

        // 设置列宽
        const colWidths = headers.map(() => ({ wch: 15 }))
        ws['!cols'] = colWidths

        // 创建工作簿
        const wb = XLSX.utils.book_new()
        XLSX.utils.book_append_sheet(wb, ws, '科技老师工资')

        // 生成文件名
        const now = new Date()
        const timestamp = now.getFullYear() + 
          String(now.getMonth() + 1).padStart(2, '0') + 
          String(now.getDate()).padStart(2, '0') + 
          String(now.getHours()).padStart(2, '0') + 
          String(now.getMinutes()).padStart(2, '0') + 
          String(now.getSeconds()).padStart(2, '0')
        const fileName = `科技老师工资_${timestamp}.xlsx`

        // 导出文件
        XLSX.writeFile(wb, fileName)

        this.$message.success('导出成功')
      } catch (error) {
        console.error('导出失败:', error)
        this.$message.error('导出失败,请重试')
      } finally {
        this.exportLoading = false
      }
    },

    // 格式化金额
    formatMoney(value) {
      if (value === null || value === undefined || value === '') {
        return '0.00'
      }
      return Number(value).toFixed(2)
    },

    // 格式化百分比
    formatPercent(value) {
      if (value === null || value === undefined || value === '') {
        return '0.00%'
      }
      return (Number(value) * 100).toFixed(2) + '%'
    },

    // 查看详情
    handleViewDetail(row) {
      this.currentDetailData = row
      this.detailDialogVisible = true
    },

    // 关闭详情弹窗
    handleDetailDialogClose() {
      this.detailDialogVisible = false
      this.currentDetailData = null
    },

    // 显示导入弹窗
    showImportDialog() {
      this.importDialogVisible = true
      this.importFile = null
      this.fileList = []
    },

    // 关闭导入弹窗
    handleImportDialogClose() {
      this.importDialogVisible = false
      this.importFile = null
      this.fileList = []
      if (this.$refs.upload) {
        this.$refs.upload.clearFiles()
      }
    },

    // 文件选择变化
    handleFileChange(file, fileList) {
      this.importFile = file.raw
      this.fileList = fileList
    },

    // 确认导入
    async handleImportConfirm() {
      if (!this.importFile) {
        this.$message.warning('请选择要导入的Excel文件')
        return
      }

      // 检查文件大小(10MB)
      const maxSize = 10 * 1024 * 1024
      if (this.importFile.size > maxSize) {
        this.$message.warning('文件大小不能超过10MB')
        return
      }

      // 检查文件格式
      const allowedExtensions = ['.xlsx', '.xls']
      const fileName = this.importFile.name.toLowerCase()
      const isValidFormat = allowedExtensions.some(ext => fileName.endsWith(ext))
      if (!isValidFormat) {
        this.$message.warning('只支持.xlsx和.xls格式的Excel文件')
        return
      }

      this.importLoading = true
      try {
        const response = await importTechTeacherSalaryFromExcel(this.importFile)
        if (response.code === 200) {
          const result = response.data || response
          this.$message.success( result.message || '导入成功')
          this.handleImportDialogClose()
          this.getList()
        } else {
          this.$message.error(response.message || '导入失败')
        }
      } catch (error) {
        console.error('导入失败:', error)
        this.$message.error(error.message || '导入失败,请重试')
      } finally {
        this.importLoading = false
      }
    },

    // 锁定工资
    async handleLock(row) {
      // 检查是否已确认
      if (row.EmployeeConfirmStatus === 1) {
        this.$message.warning('该记录已确认,无法锁定或解锁')
        return
      }

      await this.$confirm('确定要锁定该工资记录吗?锁定后将无法修改。', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        this.lockLoading = true
        try {
          const response = await lockTechTeacherSalary([row.Id], true)
          if (response.code === 200) {
            this.$message.success('锁定成功')
            this.getList()
          } else {
            this.$message.error(response.msg || '锁定失败')
          }
        } catch (error) {
          console.error('锁定失败:', error)
          this.$message.error(error.message || '锁定失败,请重试')
        } finally {
          this.lockLoading = false
        }
      }).catch(() => {
        // 用户取消
      })
    },

    // 解锁工资
    async handleUnlock(row) {
      // 检查是否已确认
      if (row.EmployeeConfirmStatus === 1) {
        this.$message.warning('该记录已确认,无法锁定或解锁')
        return
      }

      await this.$confirm('确定要解锁该工资记录吗?解锁后可以修改。', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        this.lockLoading = true
        try {
          const response = await lockTechTeacherSalary([row.Id], false)
          if (response.code === 200) {
            this.$message.success('解锁成功')
            this.getList()
          } else {
            this.$message.error(response.msg || '解锁失败')
          }
        } catch (error) {
          console.error('解锁失败:', error)
          this.$message.error(error.message || '解锁失败,请重试')
        } finally {
          this.lockLoading = false
        }
      }).catch(() => {
        // 用户取消
      })
    },

    // 选择变化
    handleSelectionChange(selection) {
      this.selectedRows = selection
    },

    // 清除选择
    handleClearSelection() {
      // NCC-table 组件内部 el-table 的 ref 是 NCCTable
      if (this.$refs.table && this.$refs.table.$refs && this.$refs.table.$refs.NCCTable) {
        this.$refs.table.$refs.NCCTable.clearSelection()
      }
      this.selectedRows = []
    },

    // 批量锁定
    async handleBatchLock() {
      if (!this.selectedRows || this.selectedRows.length === 0) {
        this.$message.warning('请先选择要锁定的记录')
        return
      }

      // 过滤出未锁定且未确认的记录
      const unlockedRows = this.selectedRows.filter(row => row.IsLocked !== 1 && row.EmployeeConfirmStatus !== 1)
      if (unlockedRows.length === 0) {
        // 检查是否有已确认的记录
        const confirmedRows = this.selectedRows.filter(row => row.EmployeeConfirmStatus === 1)
        if (confirmedRows.length > 0) {
          this.$message.warning('所选记录中包含已确认的记录,已确认的记录无法锁定或解锁')
        } else {
          this.$message.warning('所选记录已全部锁定')
        }
        return
      }

      await this.$confirm(`确定要锁定选中的 ${unlockedRows.length} 条记录吗?锁定后将无法修改。`, '批量锁定', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        this.lockLoading = true
        try {
          const ids = unlockedRows.map(row => row.Id)
          const response = await lockTechTeacherSalary(ids, true)
          if (response.code === 200) {
            this.$message.success(`锁定成功:${unlockedRows.length}条`)
            this.handleClearSelection()
            this.getList()
          } else {
            this.$message.error(response.msg || '批量锁定失败')
          }
        } catch (error) {
          console.error('批量锁定失败:', error)
          this.$message.error(error.message || '批量锁定失败,请重试')
        } finally {
          this.lockLoading = false
        }
      }).catch(() => {
        // 用户取消
      })
    },

    // 批量解锁
    async handleBatchUnlock() {
      if (!this.selectedRows || this.selectedRows.length === 0) {
        this.$message.warning('请先选择要解锁的记录')
        return
      }

      // 过滤出已锁定且未确认的记录
      const lockedRows = this.selectedRows.filter(row => row.IsLocked === 1 && row.EmployeeConfirmStatus !== 1)
      if (lockedRows.length === 0) {
        // 检查是否有已确认的记录
        const confirmedRows = this.selectedRows.filter(row => row.EmployeeConfirmStatus === 1)
        if (confirmedRows.length > 0) {
          this.$message.warning('所选记录中包含已确认的记录,已确认的记录无法锁定或解锁')
        } else {
          this.$message.warning('所选记录已全部解锁')
        }
        return
      }

      await this.$confirm(`确定要解锁选中的 ${lockedRows.length} 条记录吗?解锁后可以修改。`, '批量解锁', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        this.lockLoading = true
        try {
          const ids = lockedRows.map(row => row.Id)
          const response = await lockTechTeacherSalary(ids, false)
          if (response.code === 200) {
            this.$message.success(`解锁成功:${lockedRows.length}条`)
            this.handleClearSelection()
            this.getList()
          } else {
            this.$message.error(response.msg || '批量解锁失败')
          }
        } catch (error) {
          console.error('批量解锁失败:', error)
          this.$message.error(error.message || '批量解锁失败,请重试')
        } finally {
          this.lockLoading = false
        }
      }).catch(() => {
        // 用户取消
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  padding: 16px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 50%, #f0f4f8 100%);
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 18px 24px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(144, 147, 153, 0.2);
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #606266 0%, #909399 50%, #606266 100%);
  }

  .header-left {
    h2 {
      margin: 0 0 8px 0;
      color: #303133;
      font-size: 22px;
      font-weight: 600;
      background: linear-gradient(135deg, #303133 0%, #606266 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .page-desc {
      margin: 0;
      color: #909399;
      font-size: 14px;
    }
  }

  .header-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;

    .el-button {
      border-radius: 8px;
      padding: 10px 18px;
      font-weight: 500;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
      }

      &.el-button--primary {
        background: linear-gradient(135deg, #606266 0%, #909399 100%);
        border: none;

        &:hover {
          background: linear-gradient(135deg, #909399 0%, #606266 100%);
        }
      }

      &.el-button--success {
        background: linear-gradient(135deg, #67C23A 0%, #85ce61 100%);
        border: none;

        &:hover {
          background: linear-gradient(135deg, #85ce61 0%, #67C23A 100%);
        }
      }

      &.el-button--warning {
        background: linear-gradient(135deg, #E6A23C 0%, #f0b45a 100%);
        border: none;

        &:hover {
          background: linear-gradient(135deg, #f0b45a 0%, #E6A23C 100%);
        }
      }

      &.el-button--info {
        background: linear-gradient(135deg, #909399 0%, #a6a9ad 100%);
        border: none;

        &:hover {
          background: linear-gradient(135deg, #a6a9ad 0%, #909399 100%);
        }
      }
    }
  }
}

.search-container {
  margin-bottom: 16px;
  padding: 18px 24px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(144, 147, 153, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  &:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.06);
  }

  &::v-deep .el-form {
    .el-form-item {
      margin-bottom: 16px;
    }

    .el-button {
      border-radius: 8px;
      padding: 10px 20px;
      font-weight: 500;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
      }

      &.el-button--primary {
        background: linear-gradient(135deg, #606266 0%, #909399 100%);
        border: none;

        &:hover {
          background: linear-gradient(135deg, #909399 0%, #606266 100%);
        }
      }
    }

    .el-input__inner,
    .el-select .el-input__inner {
      border-radius: 8px;
      border: 1px solid rgba(144, 147, 153, 0.3);
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

      &:focus {
        border-color: #909399;
        box-shadow: 0 0 0 2px rgba(144, 147, 153, 0.15);
      }
    }
  }
}

.batch-action-container {
  margin-top: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(144, 147, 153, 0.08) 0%, rgba(144, 147, 153, 0.05) 100%);
  border-radius: 10px;
  border: 1px solid rgba(144, 147, 153, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(144, 147, 153, 0.1);

  .selected-count {
    color: #606266;
    font-weight: 600;
    margin-right: 8px;
    font-size: 14px;
  }

  .el-button {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    }
  }
}

.table-container {
  margin-bottom: 20px;
  padding: 18px 24px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(144, 147, 153, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  z-index: 1;

  &:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.06);
  }

  &::v-deep .el-table {
    background-color: #ffffff;

    .el-table__body-wrapper {
      background-color: #ffffff;
    }
  }
}

.store-name,
.employee-name {
  display: flex;
  align-items: center;
  gap: 6px;

  .store-icon,
  .employee-icon {
    color: #606266;
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  &:hover .store-icon,
  &:hover .employee-icon {
    transform: scale(1.1) rotate(5deg);
  }
}

// 表格样式优化
::v-deep .el-table {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(144, 147, 153, 0.2);

  // 确保多选框列可以点击 - 全局设置,最高优先级
  .el-table__column--selection {
    z-index: 1000 !important;
    pointer-events: auto !important;
    position: relative;
  }

  .el-checkbox {
    z-index: 1001 !important;
    pointer-events: auto !important;
    position: relative;
    cursor: pointer;
  }

  .el-checkbox__input {
    z-index: 1001 !important;
    pointer-events: auto !important;
    cursor: pointer;
  }

  .el-checkbox__inner {
    z-index: 1001 !important;
    pointer-events: auto !important;
    cursor: pointer;
  }

  td.el-table__cell--selection,
  th.el-table__cell--selection {
    z-index: 1000 !important;
    pointer-events: auto !important;
    position: relative;
    background-color: #ffffff !important;
    cursor: pointer;

    .cell {
      pointer-events: auto !important;
      z-index: 1001 !important;
      position: relative;
    }
  }

  .el-table__header-wrapper {
    th {
      background: linear-gradient(135deg, rgba(144, 147, 153, 0.08) 0%, rgba(144, 147, 153, 0.05) 100%);
      color: #303133;
      font-weight: 600;
      border-bottom: 2px solid rgba(144, 147, 153, 0.2);
      padding: 14px 0 !important;
      height: auto !important;
      line-height: normal !important;
      box-sizing: border-box;
    }
  }

  .el-table__body-wrapper {
    background-color: #ffffff;
    z-index: 1;

    .el-table__row {
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      background-color: #ffffff;

      &:hover {
        background: linear-gradient(90deg, rgba(144, 147, 153, 0.05) 0%, rgba(144, 147, 153, 0.02) 100%) !important;
        transform: translateX(2px);
      }

      td {
        border-bottom: 1px solid rgba(144, 147, 153, 0.15);
        background-color: #ffffff !important;
        padding: 12px 0 !important;
        height: auto !important;
        line-height: normal !important;
        box-sizing: border-box;
      }

      &.el-table__row--striped {
        td {
          background-color: #fafafa !important;
        }

        &:hover td {
          background: linear-gradient(90deg, rgba(144, 147, 153, 0.05) 0%, rgba(144, 147, 153, 0.02) 100%) !important;
        }
      }
    }
  }

  .el-table__header-wrapper {
    background-color: #ffffff;
    z-index: 2;
  }

  // 固定列样式修复
  .el-table__fixed,
  .el-table__fixed-right {
    z-index: 5 !important;
    background-color: #ffffff;
    height: 100% !important;

    // 确保多选框可以点击 - 选择列需要最高的z-index
    .el-table__column--selection {
      z-index: 1000 !important;
      pointer-events: auto !important;
      position: relative;
    }

    // 确保选择列单元格可以点击
    td.el-table__cell--selection,
    th.el-table__cell--selection {
      z-index: 1000 !important;
      pointer-events: auto !important;
      position: relative;
      background-color: #ffffff !important;
      cursor: pointer;

      .cell {
        pointer-events: auto !important;
        z-index: 1001 !important;
        position: relative;
      }
    }

    // 确保多选框本身可以点击
    .el-checkbox {
      z-index: 1001 !important;
      position: relative;
      pointer-events: auto !important;
      cursor: pointer;
    }

    .el-checkbox__input {
      z-index: 1001 !important;
      pointer-events: auto !important;
      cursor: pointer;
    }

    .el-checkbox__inner {
      z-index: 1001 !important;
      pointer-events: auto !important;
      cursor: pointer;
    }

    &::before {
      background: linear-gradient(135deg, rgba(144, 147, 153, 0.08) 0%, rgba(144, 147, 153, 0.05) 100%);
      z-index: 4 !important;
      height: 100% !important;
      pointer-events: none !important;
    }

    .el-table__fixed-header-wrapper {
      height: auto !important;
      background-color: #ffffff;

      th {
        background: linear-gradient(135deg, rgba(144, 147, 153, 0.08) 0%, rgba(144, 147, 153, 0.05) 100%) !important;
        z-index: 6 !important;
        padding: 14px 0 !important;
        height: auto !important;
        line-height: normal !important;

        // 选择列header需要最高z-index
        &.el-table__cell--selection {
          z-index: 1000 !important;
          pointer-events: auto !important;
        }
      }
    }

    .el-table__fixed-body-wrapper {
      background-color: #ffffff;
      height: auto !important;
      max-height: 100% !important;
      overflow-y: auto !important;

      td {
        background-color: #ffffff !important;
        z-index: 6 !important;
        padding: 12px 0 !important;
        height: auto !important;
        line-height: normal !important;

        // 选择列cell需要最高z-index
        &.el-table__cell--selection {
          z-index: 1000 !important;
          pointer-events: auto !important;
        }
      }

      .el-table__row {
        height: auto !important;

        &.el-table__row--striped {
          td {
            background-color: #fafafa !important;
          }
        }
      }
    }

    th {
      background: linear-gradient(135deg, rgba(144, 147, 153, 0.08) 0%, rgba(144, 147, 153, 0.05) 100%) !important;
      z-index: 6 !important;
      padding: 14px 0 !important;
      height: auto !important;
      line-height: normal !important;

      // 选择列header需要最高z-index
      &.el-table__cell--selection {
        z-index: 1000 !important;
        pointer-events: auto !important;
      }
    }

    td {
      background-color: #ffffff !important;
      z-index: 6 !important;
      padding: 12px 0 !important;
      height: auto !important;
      line-height: normal !important;

      // 选择列cell需要最高z-index
      &.el-table__cell--selection {
        z-index: 1000 !important;
        pointer-events: auto !important;
      }
    }
  }

  // 固定列补丁
  .el-table__fixed-right-patch {
    background-color: #ffffff;
    z-index: 4 !important;
    height: 100% !important;
    pointer-events: none !important;
  }

  // 确保固定列和主表格的header高度一致
  .el-table__header-wrapper th,
  .el-table__fixed-header-wrapper th,
  .el-table__fixed-right-header-wrapper th {
    padding: 14px 0 !important;
    height: auto !important;
    line-height: normal !important;
  }

  // 确保固定列和主表格的body行高一致
  .el-table__body-wrapper td,
  .el-table__fixed-body-wrapper td,
  .el-table__fixed-right-body-wrapper td {
    padding: 12px 0 !important;
    height: auto !important;
    line-height: normal !important;
  }
}
</style>