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

    <div class="flex-container">
      <!-- 左侧表单区域 -->
      <div class="left-panel">
        <a-form
          ref="formRef"
          :model="formData"
          :label-col="{ span: 8 }"
          :wrapper-col="{ span: 16 }"
          class="task-form"
        >
          <!--          <a-form-item label="货架:">-->
          <!--            <a-input-->
          <!--              v-model="formData.goodsNo"-->
          <!--              placeholder="请输入货架号"-->
          <!--              @keyup.enter="handleGoodsShelfSearch"-->
          <!--              :auto-focus="true"-->
          <!--            />-->
          <!--          </a-form-item>-->
          <!-- 第一行:工位和托盘类型 -->
          <a-form-item
            label="工位:"
            class="inline-form-item"
            :rules="[{ required: true, message: '请选择或输入工位!' }]"
          >
            <a-select
              v-model="formData.workstation"
              placeholder="请选择工位"
              style="width: 100%"
              show-search
              allow-clear
              :filter-option="filterOption"
              @change="handleWorkstationChange"
            >
              <a-select-option v-for="item in workstationList" :key="item.value" :value="item.value">
                {{ item.label }}
              </a-select-option>
            </a-select>
          </a-form-item>

          <a-form-item
            label="托盘类型:"
            class="inline-form-item"
            :rules="[{ required: true, message: '请选择托盘类型!' }]"
          >
            <j-search-select-tag
              placeholder="请选择托盘类型"
              v-model="formData.containerType"
              dict="container_type,name,code,code='A' OR code='B'"
              :pageSize="5"
              :async="true"
              style="width: 100%"
            />
          </a-form-item>

          <!-- 第二行:卷号输入 -->
          <a-form-item
            label="卷号:"
            :rules="[{ required: true, message: '请输入卷号!' }]"
          >
            <div class="roll-number-input-wrapper">
              <a-input
                v-model="currentRollNumber"
                placeholder="请输入卷号,按回车确认"
                @keyup.enter="handleAddRollNumber"
                :auto-focus="true"
                style="width: 100%"
                :disabled="!formData.workstation || !formData.containerType"
              >
                <a-icon slot="prefix" type="barcode" style="color: rgba(0,0,0,.25)"/>
                <a-button
                  slot="addonAfter"
                  type="primary"
                  icon="plus"
                  @click="handleAddRollNumber"
                  :disabled="!currentRollNumber.trim()"
                  size="small"
                >
                  添加
                </a-button>
              </a-input>
            </div>
          </a-form-item>

          <!-- 第三行:卷号列表 -->
          <a-form-item label="已输入卷号:" v-if="rollNumberList.length > 0">
            <div class="roll-number-list">
              <div class="roll-number-list-header">
                <span class="list-title">卷号列表 ({{ rollNumberList.length }})</span>
                <a-button
                  type="link"
                  size="small"
                  @click="clearRollNumberList"
                  class="clear-btn"
                >
                  <a-icon type="delete"/>
                  清空
                </a-button>
              </div>

              <div class="roll-number-items">
                <div
                  v-for="(roll, index) in rollNumberList"
                  :key="index"
                  class="roll-number-item"
                  :class="{ 'last-added': index === rollNumberList.length - 1 }"
                >
                  <div class="roll-number-content">
                    <span class="roll-index" style="margin-right: 3px">{{ index + 1 }}.</span>
                    <span class="roll-value"
                          style="margin-right: 12px; font-size: 16px; font-weight: 600; color: #1890ff">{{
                        roll
                      }}</span>
                    <span class="roll-time" style="margin-right: 8px">{{ formatTime(rollTimestamp[index]) }}</span>
                    <a-icon
                      type="close-circle"
                      class="remove-icon"
                      @click="removeRollNumber(index)"
                    />
                  </div>
                </div>
              </div>

              <div class="roll-number-summary">
                <span class="summary-text">总计: {{ rollNumberList.length }} 卷</span>
                <span v-if="formData.containerType" class="pallet-type">
                  托盘类型: {{ getContainerTypeName(formData.containerType) }}
                </span>
              </div>
            </div>
          </a-form-item>
          <a-form-item :wrapper-col="{ offset: 8, span: 16 }">
            <div class="toolbox-buttons">
              <a-button type="primary" @click="handleAgvReturn" class="btn-success">
                AGV回库
              </a-button>
              <a-button type="primary" @click="handleComplete" class="btn-success">
                上下料完成
              </a-button>
              <a-button @click="handleRotation(180)" class="btn-info">
                180°旋转
              </a-button>
              <a-button type="danger" @click="handleCancel" class="btn-danger">
                AGV取消
              </a-button>
              <a-button @click="handleRotation(90)" class="btn-info">
                90°旋转
              </a-button>
            </div>
          </a-form-item>
        </a-form>
      </div>

      <!-- 右侧操作区域 -->
      <div class="right-panel">
        <div class="station-info">
          <div class="station-header">
            <span class="station-title">{{ stationInfo }}</span>
            <div class="station-controls">
              <a-select
                v-model="selectedGoodsShelf"
                style="width: 120px; margin-right: 10px"
                placeholder="货架号"
              >
                <a-select-option value="">货架号</a-select-option>
                <a-select-option
                  v-for="shelf in goodsShelfList"
                  :key="shelf.goodsShelfNo"
                  :value="shelf.goodsShelfNo"
                >
                  {{ shelf.goodsShelfNo }}
                </a-select-option>
              </a-select>
              <a-button type="primary" @click="handleManualCall" class="btn-success">
                手动叫车
              </a-button>
            </div>
          </div>

          <a-divider style="margin: 10px 0; background: white"/>

          <!-- 货架网格展示 -->
          <div class="shelf-grid-container">
            <div class="grid-table">
              <div class="grid-header">
                <div class="grid-cell">A面</div>
                <div class="grid-cell">C面</div>
              </div>

              <div v-for="row in gridRows" :key="row.level" class="grid-row">
                <div
                  v-for="cell in row.cells"
                  :key="cell.id"
                  class="grid-cell"
                  :class="getGridCellClass(cell)"
                  :style="getGridCellStyle(cell)"
                >
                  <div class="grid-content">
                    {{ cell.containerInfo }}
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 底部表格区域 -->
    <div class="bottom-tables">
      <a-tabs default-active-key="1">
        <a-tab-pane key="1" tab="当前任务">
          <!--          <j-table-->
          <!--            ref="taskTable"-->
          <!--            :columns="taskColumns"-->
          <!--            :data-source="taskData"-->
          <!--            :row-selection="{ selectedRowKeys: selectedTaskKeys, onChange: onTaskSelectChange }"-->
          <!--            :pagination="taskPagination"-->
          <!--            @change="handleTaskTableChange"-->
          <!--            @refresh="handleTaskRefresh"-->
          <!--          >-->
          <!--            <template slot="type" slot-scope="text">-->
          <!--              <j-dict-select-tag :value="text" dictCode="taskType" />-->
          <!--            </template>-->
          <!--          </j-table>-->
          <MachineAgvTask/>
        </a-tab-pane>

        <a-tab-pane key="2" tab="生产加工单">
          <!--          <j-table-->
          <!--            ref="stationTable"-->
          <!--            :columns="stationColumns"-->
          <!--            :data-source="stationData"-->
          <!--            :row-selection="{ selectedRowKeys: selectedStationKeys, onChange: onStationSelectChange }"-->
          <!--            :pagination="stationPagination"-->
          <!--            @change="handleStationTableChange"-->
          <!--          >-->
          <!--            <template slot="taskType" slot-scope="text">-->
          <!--              <j-dict-select-tag :value="text" dictCode="taskType" />-->
          <!--            </template>-->
          <!--            <template slot="uWarehouseName" slot-scope="text, record">-->
          <!--              <span class="badge-info">{{ getWarehouseName(record.uWarehouseName) }}</span>-->
          <!--            </template>-->
          <!--          </j-table>-->
          <MachineProductionOrderHeader/>
        </a-tab-pane>
      </a-tabs>
    </div>

    <!-- AGV取消确认对话框 -->
    <a-modal
      v-if="showCancelModal"
      :visible="showCancelModal"
      title="取消任务"
      @ok="handleCancelConfirm"
      @cancel="showCancelModal = false"
      width="800px"
      height="200px"
    >
      <cancel-confirm @cancel="handleCancelConfirm"/>
    </a-modal>
  </a-card>
</template>

<script>
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {mixinDevice} from '@/utils/mixin'
// import JTable from '@/components/jeecg/JTable'
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import StationSelect from "./StationSelect.vue";
import CancelConfirm from "./CancelConfirm.vue";
import MachineProductionOrderHeader from "./MachineProductionOrderHeader.vue";
import MachineAgvTask from "./MachineAgvTask.vue";

// 模拟任务类型字典数据
const taskTypes = [
  {value: '1', text: '入库任务'},
  {value: '2', text: '出库任务'},
  {value: '3', text: '盘点任务'},
  {value: '4', text: '移库任务'}
]

// 模拟仓库数据
const mockWarehouseData = {
  'WH001': '原材料仓库',
  'WH002': '成品仓库',
  'WH003': '半成品仓库',
  'WH004': '备件仓库'
}

// 模拟货架列表数据
const mockGoodsShelfList = [
  {goodsShelfNo: 'RACK001A'},
  {goodsShelfNo: 'RACK001C'},
  {goodsShelfNo: 'RACK002A'},
  {goodsShelfNo: 'RACK002C'},
  {goodsShelfNo: 'RACK003A'},
  {goodsShelfNo: 'RACK003C'},
  {goodsShelfNo: 'RACK004A'},
  {goodsShelfNo: 'RACK004C'}
]

// 模拟任务数据
const mockTaskData = [
  {
    id: '1',
    taskId: 'TASK001',
    lastUpdatedBy: '张三',
    materialCode: 'MAT001',
    barCode: 'BC001',
    materialName: '轴承',
    materialSpec: 'Ø50×80mm',
    containerCode: 'CTN001',
    goodsShelfNo: 'RACK001A',
    qty: 100,
    warehouseQty: 500,
    sourceCode: 'U8-2023001',
    companyName: 'ABC公司',
    uWarehouseName: 'WH001',
    type: '1',
    referenceCode: 'U8-2023001',
    remainder: 400
  },
  {
    id: '2',
    taskId: 'TASK002',
    lastUpdatedBy: '李四',
    materialCode: 'MAT002',
    barCode: 'BC002',
    materialName: '螺丝',
    materialSpec: 'M6×20mm',
    containerCode: 'CTN002',
    goodsShelfNo: 'RACK002C',
    qty: 500,
    warehouseQty: 2000,
    sourceCode: 'U8-2023002',
    companyName: 'XYZ公司',
    uWarehouseName: 'WH002',
    type: '2',
    referenceCode: 'U8-2023002',
    remainder: 1500
  },
  {
    id: '3',
    taskId: 'TASK003',
    lastUpdatedBy: '王五',
    materialCode: 'MAT003',
    barCode: 'BC003',
    materialName: '弹簧',
    materialSpec: 'Ø10×50mm',
    containerCode: 'CTN003',
    goodsShelfNo: 'RACK003A',
    qty: 200,
    warehouseQty: 800,
    sourceCode: 'U8-2023003',
    companyName: 'DEF公司',
    uWarehouseName: 'WH003',
    type: '3',
    referenceCode: 'U8-2023003',
    remainder: 600
  }
]

// 模拟站台任务数据
const mockStationData = [
  {
    id: '1',
    lastUpdatedBy: '赵六',
    materialCode: 'MAT004',
    materialOldCode: 'BC004',
    materialName: '垫片',
    specification: 'Ø20×3mm',
    containerCode: 'CTN004',
    goodsShelfNo: 'RACK004C',
    qty: 300,
    referenceCode: 'U8-2023004',
    companyName: 'GHI公司',
    uWarehouseName: 'WH004',
    taskType: '4',
    warehouseQty: 1000
  },
  {
    id: '2',
    lastUpdatedBy: '孙七',
    materialCode: 'MAT005',
    materialOldCode: 'BC005',
    materialName: '螺母',
    specification: 'M8',
    containerCode: 'CTN005',
    goodsShelfNo: 'RACK001A',
    qty: 1000,
    referenceCode: 'U8-2023005',
    companyName: 'JKL公司',
    uWarehouseName: 'WH001',
    taskType: '1',
    warehouseQty: 5000
  }
]

// 模拟货架详情数据
const mockShelfDetailData = [
  {
    id: '1',
    taskId: 'TASK001',
    uWarehouseName: 'WH001',
    referenceCode: 'U8-2023001',
    materialCode: 'MAT001',
    materialOldCode: 'BC001',
    materialName: '轴承',
    materialSpec: 'Ø50×80mm',
    containerCode: 'CTN001-A5-1', // A面第5层
    warehouseQty: 500,
    qty: 100,
    remainder: 400,
    goodsShelfNo: 'RACK001A'
  },
  {
    id: '2',
    taskId: 'TASK006',
    uWarehouseName: 'WH002',
    referenceCode: 'U8-2023006',
    materialCode: 'MAT006',
    materialOldCode: 'BC006',
    materialName: '螺栓',
    materialSpec: 'M10×40mm',
    containerCode: 'CTN006-A4-1', // A面第4层
    warehouseQty: 300,
    qty: 50,
    remainder: 250,
    goodsShelfNo: 'RACK001A'
  },
  {
    id: '3',
    taskId: 'TASK007',
    uWarehouseName: 'WH003',
    referenceCode: 'U8-2023007',
    materialCode: 'MAT007',
    materialOldCode: 'BC007',
    materialName: '齿轮',
    materialSpec: 'Ø100×20mm',
    containerCode: 'CTN007-C5-3', // C面第5层
    warehouseQty: 200,
    qty: 30,
    remainder: 170,
    goodsShelfNo: 'RACK001A'
  }
]

export default {
  name: 'MachineOperation1',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    // JTable,
    JDictSelectTag,
    StationSelect,
    CancelConfirm,
    MachineProductionOrderHeader,
    MachineAgvTask
  },
  data() {
    return {
      description: 'AGV任务操作页面',

      // 表单数据
      formData: {
        id: '',
        taskId: '',
        goodsNo: '',
        uWarehouseName: '',
        sourceCode: '',
        materialCode: '',
        barCode: '',
        materialName: '',
        specification: '',
        num: '',
        remainder: '',
        workstation: '',
        containerType: '',
      },

      // 当前输入的卷号
      currentRollNumber: '',

      // 卷号列表
      rollNumberList: [],

      // 卷号时间戳
      rollTimestamp: [],

      // 工位列表
      workstationList: [
        {value: 'WS001', label: '工位001 - 装配线'},
        {value: 'WS002', label: '工位002 - 测试线'},
        {value: 'WS003', label: '工位003 - 包装线'},
        {value: 'WS004', label: '工位004 - 检验线'},
        {value: 'WS005', label: '工位005 - 返修线'},
      ],

      // 托盘类型映射
      containerTypeMap: {
        'A': 'A型托盘',
        'B': 'B型托盘',
        'C': 'C型托盘',
        'D': 'D型托盘',
      },

      // 站台信息
      stationInfo: '1号站台',
      currentStation: '1',
      showStationModal: true, // 默认关闭,直接使用1号站台

      // 货架列表
      selectedGoodsShelf: '',
      goodsShelfList: [...mockGoodsShelfList],

      // 网格数据
      gridRows: this.generateGridData(),

      // 表格数据
      taskData: [...mockTaskData],
      stationData: [...mockStationData],
      selectedTaskKeys: [],
      selectedStationKeys: [],

      // 表格配置
      taskColumns: [
        {
          title: '操作人',
          dataIndex: 'lastUpdatedBy',
          align: 'center'
        },
        {
          title: '存货编码',
          dataIndex: 'materialCode',
          align: 'center'
        },
        {
          title: '存货代码',
          dataIndex: 'barCode',
          align: 'center'
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
          align: 'center'
        },
        {
          title: '规格',
          dataIndex: 'materialSpec',
          align: 'center'
        },
        {
          title: '容器编码',
          dataIndex: 'containerCode',
          align: 'center'
        },
        {
          title: '货架',
          dataIndex: 'goodsShelfNo',
          align: 'center'
        },
        {
          title: '数量',
          dataIndex: 'qty',
          align: 'center'
        },
        {
          title: '库存',
          dataIndex: 'warehouseQty',
          align: 'center'
        },
        {
          title: 'U8单据',
          dataIndex: 'sourceCode',
          align: 'center'
        },
        {
          title: '货主',
          dataIndex: 'companyName',
          align: 'center'
        },
        {
          title: 'u8仓库',
          dataIndex: 'uWarehouseName',
          align: 'center'
        },
        {
          title: '任务类型',
          dataIndex: 'type',
          align: 'center',
          scopedSlots: {customRender: 'type'}
        }
      ],

      stationColumns: [
        {
          title: '操作人',
          dataIndex: 'lastUpdatedBy',
          align: 'center'
        },
        {
          title: '存货编码',
          dataIndex: 'materialCode',
          align: 'center'
        },
        {
          title: '存货代码',
          dataIndex: 'materialOldCode',
          align: 'center'
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
          align: 'center'
        },
        {
          title: '规格',
          dataIndex: 'specification',
          align: 'center'
        },
        {
          title: '容器编码',
          dataIndex: 'containerCode',
          align: 'center'
        },
        {
          title: '货架',
          dataIndex: 'goodsShelfNo',
          align: 'center'
        },
        {
          title: '数量',
          dataIndex: 'qty',
          align: 'center'
        },
        {
          title: 'U8单据',
          dataIndex: 'referenceCode',
          align: 'center'
        },
        {
          title: '货主',
          dataIndex: 'companyName',
          align: 'center'
        },
        {
          title: 'u8仓库',
          dataIndex: 'uWarehouseName',
          align: 'center',
          scopedSlots: {customRender: 'uWarehouseName'}
        },
        {
          title: '任务类型',
          dataIndex: 'taskType',
          align: 'center',
          scopedSlots: {customRender: 'taskType'}
        },
        {
          title: '库存',
          dataIndex: 'warehouseQty',
          align: 'center'
        }
      ],

      // 分页配置
      taskPagination: {
        current: 1,
        pageSize: 50,
        pageSizeOptions: ['10', '25', '50', '100'],
        showTotal: (total) => `共 ${total} 条`,
        showSizeChanger: true,
        showQuickJumper: true,
        total: mockTaskData.length
      },

      stationPagination: {
        current: 1,
        pageSize: 50,
        pageSizeOptions: ['10', '25', '50', '100'],
        showTotal: (total) => `共 ${total} 条`,
        showSizeChanger: true,
        showQuickJumper: true,
        total: mockStationData.length
      },

      // 对话框状态
      showCancelModal: false,

      // 仓库映射数据
      warehouseMap: mockWarehouseData,

      // 当前选中的任务ID
      currentTaskId: null,

      // 任务类型字典(用于表格显示)
      taskTypeDict: taskTypes.reduce((map, item) => {
        map[item.value] = item.text
        return map
      }, {})
    }
  },
  created() {
    this.initData()
  },
  mounted() {
    this.$nextTick(() => {
      window.addEventListener('resize', this.handleResize)
      this.handleResize()
    })
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.handleResize)
  },
  computed: {
    // 是否可以提交
    canSubmit() {
      return this.formData.workstation &&
        this.formData.containerType &&
        this.rollNumberList.length > 0
    }
  },
  methods: {
    // 初始化数据
    initData() {
      // 使用模拟数据,不请求后端
      this.loadMockData()
    },

    // 加载模拟数据
    loadMockData() {
      // 这里使用模拟数据替代后端请求
      console.log('使用模拟数据,不请求后端')
    },

    // 生成网格数据
    generateGridData() {
      const rows = []
      const levels = [5, 4, 3, 2, 1]

      levels.forEach(level => {
        const cells = [
          {
            id: `grid-A-${level}`,
            level,
            side: 'A',
            x: level,
            y: 1,
            containerInfo: '',
            status: 'empty',
            containerCode: ''
          },
          {
            id: `grid-C-${level}`,
            level,
            side: 'C',
            x: level,
            y: 3,
            containerInfo: '',
            status: 'empty',
            containerCode: ''
          }
        ]
        rows.push({level, cells})
      })

      return rows
    },

    // 获取网格单元格样式
    getGridCellClass(cell) {
      return {
        'grid-selected': cell.status === 'selected',
        'grid-occupied': cell.status === 'occupied',
        'grid-empty': cell.status === 'empty'
      }
    },

    getGridCellStyle(cell) {
      let backgroundColor = '#4F94CD' // 默认蓝色

      if (cell.status === 'selected') {
        backgroundColor = 'rgb(236,71,88)' // 红色
      } else if (cell.status === 'occupied') {
        backgroundColor = 'rgb(255,255,0)' // 黄色
      }

      return {backgroundColor}
    },

    // 货架搜索(使用模拟数据)
    async handleGoodsShelfSearch() {
      if (!this.formData.goodsNo) {
        this.$message.warning('请输入货架号!')
        return
      }

      // 清空网格状态
      this.resetGridStatus()

      // 使用模拟数据
      console.log('搜索货架号:', this.formData.goodsNo)

      // 模拟数据处理逻辑
      const shelfNo = this.formData.goodsNo.toUpperCase()

      if (shelfNo === 'RACK001A') {
        // 模拟货架001A的数据
        const shelfData = [...mockShelfDetailData]

        // 更新网格状态
        shelfData.forEach((item, index) => {
          if (item.containerCode) {
            // 解析容器编码中的层和面信息
            const parts = item.containerCode.split('-')
            if (parts.length >= 3) {
              const sideChar = parts[1].charAt(0) // A或C
              const level = parseInt(parts[1].substring(1)) // 数字部分
              const side = sideChar === 'A' ? 1 : 3

              // 找到对应的网格单元格
              this.gridRows.forEach(row => {
                if (row.level === level) {
                  row.cells.forEach(cell => {
                    if (cell.y === side) {
                      cell.containerInfo = item.containerCode
                      cell.containerCode = item.containerCode
                      cell.status = index === 0 ? 'selected' : 'occupied'
                    }
                  })
                }
              })
            }
          }
        })

        // 更新表单数据(使用第一条数据)
        if (shelfData[0]) {
          const firstItem = shelfData[0]
          this.formData = {
            ...this.formData,
            id: firstItem.id,
            taskId: firstItem.taskId,
            uWarehouseName: mockWarehouseData[firstItem.uWarehouseName] || firstItem.uWarehouseName,
            sourceCode: firstItem.referenceCode,
            materialCode: firstItem.materialCode,
            barCode: firstItem.materialOldCode,
            materialName: firstItem.materialName,
            specification: firstItem.materialSpec,
            num: firstItem.qty,
            remainder: firstItem.remainder
          }
          this.currentTaskId = firstItem.id
        }

        // 更新任务表格
        this.taskData = shelfData.map(item => ({
          ...item,
          type: '1', // 入库任务
          lastUpdatedBy: '系统',
          companyName: '测试公司'
        }))

        this.$message.success('货架信息加载成功')
      } else if (shelfNo === 'RACK001C') {
        // 模拟货架001C的数据
        this.formData = {
          ...this.formData,
          id: '4',
          taskId: 'TASK008',
          uWarehouseName: '成品仓库',
          sourceCode: 'U8-2023008',
          materialCode: 'MAT008',
          barCode: 'BC008',
          materialName: '电机',
          specification: '1.5KW',
          num: '10',
          remainder: '90'
        }

        // 设置C面第3层为选中状态
        this.gridRows.forEach(row => {
          if (row.level === 3) {
            row.cells.forEach(cell => {
              if (cell.side === 'C') {
                cell.containerInfo = 'CTN008-C3-3'
                cell.containerCode = 'CTN008-C3-3'
                cell.status = 'selected'
              }
            })
          }
        })

        this.taskData = [
          {
            id: '4',
            taskId: 'TASK008',
            lastUpdatedBy: '系统',
            materialCode: 'MAT008',
            barCode: 'BC008',
            materialName: '电机',
            materialSpec: '1.5KW',
            containerCode: 'CTN008-C3-3',
            goodsShelfNo: 'RACK001C',
            qty: 10,
            warehouseQty: 100,
            sourceCode: 'U8-2023008',
            companyName: '测试公司',
            uWarehouseName: '成品仓库',
            type: '2'
          }
        ]

        this.$message.success('货架信息加载成功')
      } else {
        this.$message.warning('未找到对应的货架信息,请尝试 RACK001A 或 RACK001C')
        this.resetFormData()
      }
    },

    // 重置网格状态
    resetGridStatus() {
      this.gridRows.forEach(row => {
        row.cells.forEach(cell => {
          cell.containerInfo = ''
          cell.containerCode = ''
          cell.status = 'empty'
        })
      })
    },

    // 重置表单数据
    resetFormData() {
      this.formData = {
        id: '',
        taskId: '',
        goodsNo: this.formData.goodsNo,
        uWarehouseName: '',
        sourceCode: '',
        materialCode: '',
        barCode: '',
        materialName: '',
        specification: '',
        num: '',
        remainder: ''
      }
      this.taskData = []
    },

    // 完成操作(模拟)
    async handleComplete() {
      if (!this.formData.taskId) {
        this.$message.warning('没有找到对应的任务')
        return
      }

      // 模拟操作成功
      console.log('完成操作:', {
        id: this.formData.id,
        taskId: this.formData.taskId,
        num: this.formData.num
      })

      // 模拟API响应
      const mockResponse = {
        success: true,
        message: '操作成功'
      }

      if (mockResponse.success) {
        this.$message.success(mockResponse.message)
        // 模拟重新加载数据
        this.handleGoodsShelfSearch()
        this.formData.goodsNo = ''
        this.$nextTick(() => {
          // const input = this.$refs.formRef?.$el?.querySelector('input[placeholder="请输入货架号"]')
          // if (input) input.focus()
        })
      } else {
        this.$message.error(mockResponse.message || '操作失败')
      }
    },
    // 添加工位搜索过滤
    filterOption(input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    },

    // 工位选择变化
    handleWorkstationChange(value) {
      console.log('工位选择:', value)
      // 可以根据选择的工位加载相关数据
    },

    // 添加卷号
    handleAddRollNumber() {
      const rollNumber = this.currentRollNumber.trim()

      if (!rollNumber) {
        this.$message.warning('请输入卷号')
        return
      }

      if (!this.formData.workstation) {
        this.$message.warning('请先选择工位')
        return
      }

      if (!this.formData.containerType) {
        this.$message.warning('请先选择托盘类型')
        return
      }

      // 检查是否重复
      if (this.rollNumberList.includes(rollNumber)) {
        this.$message.warning('卷号已存在,请勿重复输入')
        this.currentRollNumber = ''
        return
      }

      // 添加到列表
      this.rollNumberList.push(rollNumber)
      this.rollTimestamp.push(new Date())

      // 清空输入框并重新聚焦
      this.currentRollNumber = ''
      // this.$nextTick(() => {
      //   const input = this.$refs.formRef?.$el?.querySelector('input[placeholder="请输入卷号,按回车确认"]')
      //   if (input) input.focus()
      // })

      // 显示成功消息
      this.$message.success(`卷号 "${rollNumber}" 已添加`)
    },

    // 移除卷号
    removeRollNumber(index) {
      this.rollNumberList.splice(index, 1)
      this.rollTimestamp.splice(index, 1)
      this.$message.info('卷号已移除')
    },

    // 清空卷号列表
    clearRollNumberList() {
      if (this.rollNumberList.length === 0) return

      this.$confirm({
        title: '确认清空',
        content: '确定要清空所有卷号吗?',
        onOk: () => {
          this.rollNumberList = []
          this.rollTimestamp = []
          this.$message.info('卷号列表已清空')
        }
      })
    },

    // 格式化时间
    formatTime(timestamp) {
      if (!timestamp) return ''
      const date = new Date(timestamp)
      return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`
    },

    // 获取托盘类型名称
    getContainerTypeName(code) {
      return this.containerTypeMap[code] || code
    },

    // AGV回库 - 提交所有数据
    async handleAgvReturn() {
      if (!this.canSubmit) {
        this.$message.warning('请先完成工位、托盘类型选择和卷号输入')
        return
      }

      const submitData = {
        workstation: this.formData.workstation,
        containerType: this.formData.containerType,
        rollNumbers: this.rollNumberList,
        timestamp: new Date(),
        // 可以添加其他需要的数据
      }

      console.log('提交数据:', submitData)

      try {
        // 这里调用实际的API
        // const res = await this.$http.post('/api/agv/return', submitData)

        // 模拟成功
        this.$message.success('AGV回库指令已发送')

        // 清空表单(可选)
        // this.resetForm()
      } catch (error) {
        this.$message.error('提交失败')
      }
    },

    // 旋转操作(模拟)
    async handleRotation(angle) {
      if (!this.formData.goodsNo) {
        this.$message.warning('请输入货架号!')
        return
      }

      console.log('旋转操作:', {
        carNo: this.formData.goodsNo,
        orientation: angle
      })

      // 模拟API响应
      const mockResponse = {
        code: 200,
        msg: `AGV旋转${angle}°指令已发送`
      }

      if (mockResponse.code === 200) {
        this.$message.success(mockResponse.msg)
        this.formData.goodsNo = ''
        this.$nextTick(() => {
          // const input = this.$refs.formRef?.$el?.querySelector('input[placeholder="请输入货架号"]')
          // if (input) input.focus()
        })
      } else {
        this.$message.warning(mockResponse.msg)
      }
    },

    // 取消操作
    handleCancel() {
      this.showCancelModal = true
    },

    // 确认取消(模拟)
    async handleCancelConfirm() {
      console.log('取消任务操作')

      // 模拟操作
      setTimeout(() => {
        this.showCancelModal = false
        this.$message.success('任务取消成功')
      }, 500)
    },

    // 手动叫车(模拟)
    async handleManualCall() {
      if (!this.selectedGoodsShelf) {
        this.$message.warning('请选择货架号!')
        return
      }

      console.log('手动叫车操作:', {
        shelfNo: this.selectedGoodsShelf,
        station: this.currentStation
      })

      // 模拟API响应
      const mockResponse = {
        code: 200,
        msg: `已向货架${this.selectedGoodsShelf}发送叫车指令`
      }

      if (mockResponse.code === 200) {
        this.$message.success(mockResponse.msg)
      } else {
        this.$message.error(mockResponse.msg)
      }

      this.formData.goodsNo = ''
      this.$nextTick(() => {
        // const input = this.$refs.formRef?.$el?.querySelector('input[placeholder="请输入货架号"]')
        // if (input) input.focus()
      })
    },

    // 站台选择
    handleStationSelect(station) {
      this.currentStation = station
      this.stationInfo = `${station}号站台`
      this.showStationModal = false

      // 模拟根据站台加载不同数据
      console.log('切换到站台:', station)

      // 可以根据不同站台显示不同数据
      if (station === '1') {
        this.taskData = [...mockTaskData]
        this.stationData = [...mockStationData]
      } else if (station === '2') {
        // 模拟2号站台数据
        this.taskData = [
          {
            id: '10',
            taskId: 'TASK010',
            lastUpdatedBy: '站台2操作员',
            materialCode: 'MAT010',
            barCode: 'BC010',
            materialName: '阀门',
            materialSpec: 'DN50',
            containerCode: 'CTN010',
            goodsShelfNo: 'RACK010A',
            qty: 5,
            warehouseQty: 20,
            sourceCode: 'U8-2023010',
            companyName: '站台2公司',
            uWarehouseName: 'WH002',
            type: '1'
          }
        ]
        this.stationData = [
          {
            id: '11',
            lastUpdatedBy: '站台2系统',
            materialCode: 'MAT011',
            materialOldCode: 'BC011',
            materialName: '泵体',
            specification: '50m³/h',
            containerCode: 'CTN011',
            goodsShelfNo: 'RACK010C',
            qty: 3,
            referenceCode: 'U8-2023011',
            companyName: '站台2测试',
            uWarehouseName: 'WH003',
            taskType: '2',
            warehouseQty: 15
          }
        ]
      }

      this.taskPagination.total = this.taskData.length
      this.stationPagination.total = this.stationData.length
    },

    // 获取仓库名称
    getWarehouseName(warehouseCode) {
      return this.warehouseMap[warehouseCode] || warehouseCode
    },

    // 表格选择变化
    onTaskSelectChange(selectedRowKeys) {
      this.selectedTaskKeys = selectedRowKeys
    },

    onStationSelectChange(selectedRowKeys) {
      this.selectedStationKeys = selectedRowKeys
    },

    // 表格变化
    handleTaskTableChange(pagination, filters, sorter) {
      this.taskPagination = pagination
      // 模拟分页,这里简单处理
      console.log('任务表格变化:', {pagination, filters, sorter})
    },

    handleStationTableChange(pagination, filters, sorter) {
      this.stationPagination = pagination
      // 模拟分页,这里简单处理
      console.log('站台表格变化:', {pagination, filters, sorter})
    },

    // 刷新任务表格
    handleTaskRefresh() {
      // 模拟刷新数据
      console.log('刷新表格数据')
      this.$message.info('已刷新数据')
    },

    // 窗口大小变化
    handleResize() {
      // 可以在这里添加响应式布局的逻辑
      console.log('窗口大小变化,当前宽度:', window.innerWidth)
    },

    // 重置表单
    resetForm() {
      this.formData = {
        workstation: '',
        containerType: ''
      }
      this.currentRollNumber = ''
      this.rollNumberList = []
      this.rollTimestamp = []
    }
  }
}
</script>

<style scoped lang="less">
.agv-task-container {
  .flex-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;

    /* 左侧面板容器 */

    .left-panel {
      flex: 2;
      margin-right: 10px; /* 减少右边距,让左右更靠近 */

      .task-form {
        padding: 24px; /* 稍微减少内边距 */
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), /* 减少阴影强度 */ 0 1px 3px rgba(0, 0, 0, 0.05);
        transition: all 0.2s ease;
        height: 100%; /* 确保高度充满 */
        box-sizing: border-box;

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

        /deep/ .ant-form-item {
          margin-bottom: 18px; /* 适当减少间距 */

          &:last-child {
            margin-bottom: 0;
          }
        }

        /deep/ .ant-form-item-label {
          label {
            font-size: 15px; /* 稍小一点 */
            font-weight: 600;
            color: #1a1a1a;
            display: flex;
            align-items: center;
            height: 36px; /* 固定高度对齐 */

            &::before {
              content: "▸"; /* 使用箭头符号,更简洁 */
              color: #1890ff;
              margin-right: 6px;
              font-size: 14px;
              transform: translateY(-1px);
            }
          }
        }

        /deep/ .ant-form-item-control-input {
          input {
            font-size: 15px;
            height: 36px; /* 降低高度 */
            border-radius: 6px;
            border: 1px solid #e8e8e8;
            transition: all 0.2s;

            &:hover {
              border-color: #40a9ff;
            }

            &:focus {
              border-color: #1890ff;
              box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
            }

            &.ant-input[readonly] {
              background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
              border-color: #f0f0f0;
              color: #595959;
              cursor: default;
            }
          }

          /* 数量输入框特殊样式 */

          .ant-input-group-wrapper {
            display: flex;
            align-items: center;

            .ant-input {
              flex: 1;
            }

            .ant-input-group-addon {
              background: transparent;
              border: none;
              padding: 0 10px;
              color: #666;
              font-size: 14px;
            }
          }
        }

        /* 按钮区域样式 */

        /deep/ .ant-form-item:last-child {
          margin-top: 20px;
          padding-top: 15px;
          border-top: 1px solid #f0f0f0;

          .toolbox-buttons {
            display: flex;
            gap: 8px; /* 减少按钮间距 */
            justify-content: space-between;
            flex-wrap: wrap;

            .ant-btn {
              flex: 1;
              min-width: 90px; /* 最小宽度 */
              height: 36px;
              border-radius: 6px;
              font-size: 14px;
              font-weight: 500;
              transition: all 0.2s;

              &.btn-success {
                background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%);
                border: none;
                color: white;

                &:hover {
                  transform: translateY(-1px);
                  box-shadow: 0 3px 8px rgba(82, 196, 26, 0.3);
                }
              }

              &.btn-info {
                background: linear-gradient(135deg, #1890ff 0%, #40a9ff 100%);
                border: none;
                color: white;

                &:hover {
                  transform: translateY(-1px);
                  box-shadow: 0 3px 8px rgba(24, 144, 255, 0.3);
                }
              }

              &.btn-danger {
                background: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%);
                border: none;
                color: white;

                &:hover {
                  transform: translateY(-1px);
                  box-shadow: 0 3px 8px rgba(255, 77, 79, 0.3);
                }
              }
            }
          }
        }
      }
    }

    /* 右侧面板容器 */

    .right-panel {
      flex: 1;
      margin-left: 10px; /* 与左侧保持一致的间距 */

      .station-info {
        background: #fff;
        border-radius: 12px; /* 圆角与左侧一致 */
        padding: 20px;
        height: 100%; /* 使用100%高度,让父容器控制 */
        box-sizing: border-box;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
        0 1px 3px rgba(0, 0, 0, 0.05);
        transition: all 0.2s ease;

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

        .station-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 16px;
          padding-bottom: 12px;
          border-bottom: 1px solid #f0f0f0; /* 添加分割线 */

          .station-title {
            font-size: 18px; /* 稍小一点 */
            line-height: 1.4;
            color: #1890ff; /* 使用主题色 */
            font-weight: 700;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif; /* 现代字体 */
            display: flex;
            align-items: center;

            &::before {
              content: "📍"; /* 添加图标 */
              margin-right: 8px;
              font-size: 16px;
            }
          }

          .station-controls {
            display: flex;
            align-items: center;
            gap: 10px; /* 使用gap间距 */

            .ant-select {
              width: 130px; /* 固定宽度 */
              height: 36px;

              .ant-select-selector {
                border-radius: 6px;
                border: 1px solid #e8e8e8;
                transition: all 0.2s;

                &:hover {
                  border-color: #40a9ff;
                }
              }
            }

            .ant-btn {
              height: 36px;
              border-radius: 6px;
              font-size: 14px;
              font-weight: 500;
              background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%);
              border: none;
              color: white;
              padding: 0 16px;
              transition: all 0.2s;

              &:hover {
                transform: translateY(-1px);
                box-shadow: 0 3px 8px rgba(82, 196, 26, 0.3);
              }

              &:active {
                transform: translateY(0);
              }
            }
          }
        }

        /* 分割线样式 */

        .ant-divider {
          margin: 12px 0;
          background: #f0f0f0;
        }

        .shelf-grid-container {
          margin-top: 30px; /* 减少上边距 */

          .grid-table {
            display: inline-block;
            width: 100%;

            /* 添加容器阴影和背景 */
            padding: 15px;
            background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
            border-radius: 10px;
            border: 1px solid #f0f0f0;

            .grid-header {
              display: flex;
              gap: 15px; /* 减少间隙 */
              margin-bottom: 10px;
              padding: 0 5px;

              .grid-cell {
                flex: 1;
                min-width: 0; /* 允许缩小 */
                text-align: center;
                font-size: 16px;
                color: #1890ff;
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
                font-weight: 600;
                padding: 8px 0;
                background: rgba(24, 144, 255, 0.1);
                border-radius: 6px;
                letter-spacing: 1px;
              }
            }

            .grid-row {
              display: flex;
              gap: 15px; /* 减少间隙 */
              margin-bottom: 8px;

              &:last-child {
                margin-bottom: 0;
              }

              .grid-cell {
                flex: 1;
                min-width: 0; /* 允许缩小 */
                height: 60px;
                background: linear-gradient(135deg, #4F94CD 0%, #6ba8e0 100%);
                border-radius: 8px; /* 更大的圆角 */
                display: flex;
                align-items: center;
                justify-content: center;
                overflow: hidden;
                position: relative;
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                cursor: pointer;
                border: 2px solid transparent;

                /* 添加3D效果 */
                box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);

                &:hover {
                  transform: translateY(-2px);
                  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15),
                  inset 0 1px 0 rgba(255, 255, 255, 0.2);
                  border-color: rgba(24, 144, 255, 0.5);
                }

                &:active {
                  transform: translateY(0);
                }

                /* 选中状态 */

                &.grid-selected {
                  background: linear-gradient(135deg, rgb(236, 71, 88) 0%, rgb(255, 120, 117) 100%);
                  border-color: #ff4d4f;
                  animation: pulse 2s infinite;

                  &::before {
                    content: "✓";
                    position: absolute;
                    top: 4px;
                    right: 4px;
                    color: white;
                    font-size: 12px;
                    font-weight: bold;
                    background: rgba(255, 255, 255, 0.3);
                    width: 16px;
                    height: 16px;
                    border-radius: 50%;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                  }
                }

                /* 占用状态 */

                &.grid-occupied {
                  background: linear-gradient(135deg, rgb(255, 255, 0) 0%, rgb(255, 255, 150) 100%);
                  border-color: #ffc53d;

                  &::before {
                    content: "●";
                    position: absolute;
                    top: 4px;
                    right: 4px;
                    color: #faad14;
                    font-size: 12px;
                  }
                }

                /* 空闲状态hover效果 */

                &:not(.grid-selected):not(.grid-occupied):hover {
                  background: linear-gradient(135deg, #6ba8e0 0%, #8bc1f7 100%);
                }

                .grid-content {
                  font-size: 14px; /* 使用固定px,避免vh单位问题 */
                  text-overflow: ellipsis;
                  overflow: hidden;
                  white-space: nowrap;
                  width: 90%;
                  color: white;
                  font-weight: 500;
                  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
                  padding: 0 8px;

                  /* 为空时显示占位符 */

                  &:empty::before {
                    content: "空闲";
                    color: rgba(255, 255, 255, 0.7);
                    font-size: 12px;
                  }
                }

                /* 添加网格坐标提示 */

                &::after {
                  content: attr(data-layer) "层";
                  position: absolute;
                  bottom: 4px;
                  left: 8px;
                  font-size: 10px;
                  color: rgba(255, 255, 255, 0.6);
                  font-weight: 500;
                }
              }
            }
          }
        }
      }
    }

    /* 脉冲动画 */
    @keyframes pulse {
      0% {
        box-shadow: 0 0 0 0 rgba(236, 71, 88, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.1);
      }
      70% {
        box-shadow: 0 0 0 6px rgba(236, 71, 88, 0),
        0 2px 4px rgba(0, 0, 0, 0.1);
      }
      100% {
        box-shadow: 0 0 0 0 rgba(236, 71, 88, 0),
        0 2px 4px rgba(0, 0, 0, 0.1);
      }
    }

    /* 响应式设计 */
    @media (max-width: 1200px) {
      .right-panel {
        .station-info {
          .shelf-grid-container {
            .grid-table {
              .grid-header,
              .grid-row {
                gap: 10px;
              }

              .grid-cell {
                height: 55px;

                .grid-content {
                  font-size: 13px;
                }
              }
            }
          }
        }
      }
    }
  }

  .bottom-tables {
    background: #fff;
    border-radius: 4px;
    padding: 20px;

    /deep/ .ant-tabs-bar {
      margin-bottom: 16px;
    }
  }

  .toolbox-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;

    .btn-success {
      background-color: #52c41a;
      border-color: #52c41a;
    }

    .btn-info {
      background-color: #1890ff;
      border-color: #1890ff;
    }

    .btn-danger {
      background-color: #f5222d;
      border-color: #f5222d;
    }
  }
}

.badge-info {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #fff;
  background-color: #1890ff;
  border-radius: 10px;
}
</style>