MachineOperation1.vue 34.9 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
<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="工位:"
            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' OR code='LS'"
              :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: 8 }">
            <div class="toolbox-buttons">
              <a-button type="primary" @click="callEmptyOut" class="btn-info">
                呼叫空托盘
              </a-button>
              <a-button type="primary" @click="stageingReceipt" class="btn-success">
                点位入库
              </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-info">-->
              <!--                呼叫空托盘-->
              <!--              </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">点 位 监 控</div>
                <!--                <div class="grid-cell"></div>-->
              </div>

              <div class="grid-container">
                <a-tooltip
                  v-for="(cell, index) in gridRows"
                  :key="cell.id || index"
                  :title="getTooltipContent(cell)"
                  placement="top"
                >
                  <!--                    @mouseenter="handleCellHover(cell)"-->
                  <!--                    @mouseleave="handleCellLeave"-->
                  <div
                    class="grid-cell"
                    :class="getGridCellClass(cell)"
                    :style="getGridCellStyle(cell)"
                    @click="handleCellClick(cell)"
                    :data-point="cell.code"
                    :data-status="cell.status"
                  >
                    <div class="grid-content">
                      {{ getCellDisplayContent(cell) }}
                    </div>
                  </div>
                </a-tooltip>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 底部表格区域 -->
    <div class="bottom-tables">
      <a-tabs default-active-key="1" @change="reloadBottom">
        <a-tab-pane key="1" tab="当前任务">
          <MachineAgvTask ref="machineAgvTask"/>
        </a-tab-pane>

        <a-tab-pane key="2" tab="生产加工单">
          <MachineProductionOrderHeader ref="machineProductionOrderHeader"/>
        </a-tab-pane>
      </a-tabs>
    </div>

    <!-- 详情提示框 -->
    <a-modal
      v-if="showDetailModal && hoveredCell"
      :visible="showDetailModal"
      :title="`点位详情 - ${hoveredCell.code}`"
      @cancel="handleModalClose"
      :footer="null"
      width="500px"
      :mask="false"
      :wrapClassName="'cell-detail-modal'"
      :style="{position: 'fixed',top: `${modalPosition.y}px`,left: `${modalPosition.x}px`}">
      <!-- modal内容保持不变 -->
      <div class="cell-detail-content">
        <div class="detail-item">
          <span class="detail-label">点位编码:</span>
          <span class="detail-value">{{ hoveredCell.code }}</span>
        </div>
        <div class="detail-item">
          <span class="detail-label">状态:</span>
          <span class="detail-value">
            <a-tag :color="getStatusColor(hoveredCell.status)">
              {{ hoveredCell.status_dictText }}
            </a-tag>
          </span>
        </div>
        <div class="detail-item">
          <span class="detail-label">任务:</span>
          <span class="detail-value">
            <a-tag :color="'orange'">
              {{ "起始位置:P0001 -> 目标位置:A1P011001" }}
            </a-tag>
          </span>
        </div>
      </div>
    </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 MachineProductionOrderHeader from "./MachineProductionOrderHeader.vue";
import MachineAgvTask from "./MachineAgvTask.vue";

export default {
  name: 'MachineOperation1',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    // JTable,
    JDictSelectTag,
    StationSelect,
    MachineProductionOrderHeader,
    MachineAgvTask
  },
  data() {
    return {
      description: '机台操作页',
      modalPosition: {
        x: 0,
        y: 0
      },
      // 表单数据
      formData: {
        workstation: '',
        containerType: '',
      },
      // 当前输入的卷号
      currentRollNumber: '',
      // 卷号列表
      rollNumberList: [],
      // 卷号时间戳
      rollTimestamp: [],
      // 工位列表
      workstationList: [
        {value: 'A1P011001', label: '工位001 - 纵切线'},
        {value: 'A1P011002', label: '工位002 - 纵切线'},
        {value: 'A1P011003', label: '工位003 - 包装线'},
        {value: 'A1P011004', label: '工位004 - 检验线'},
        {value: 'A1P011005', label: '工位005 - 纵切线'},
      ],
      // 托盘类型映射
      containerTypeMap: {
        'A': '大托盘',
        'B': '小托盘',
        'LS': '悬臂库工装托盘'
      },
      // 站台信息
      stationInfo: '纵切机台1',
      currentStation: '1',
      showStationModal: true, // 默认关闭,直接使用1号站台
      // 网格数据
      gridRows: [],
      // 详情对话框相关
      showDetailModal: false,
      hoveredCell: null,
      hoverTimer: null,
      url: {
        list: "111",
      },
      // 对话框状态
      showCancelModal: false,
    }
  },
  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
    }
  },
  methods: {
    // 初始化数据
    initData() {
      // 使用提供的网格数据
      this.loadGridData();
    },
    // 加载网格数据
    loadGridData() {
      const rawData = [
        {
          "status_dictText": "空闲",
          "haveContainer_dictText": "没有",
          "code": "A1P011001",
          "containerCode": "",
          "status": "empty"
        },
        {
          "status_dictText": "空闲",
          "haveContainer_dictText": "有",
          "code": "A1P011002",
          "containerCode": "S00012",
          "status": "empty"
        },
        {
          "status_dictText": "锁定",
          "haveContainer_dictText": "没有",
          "code": "A1P011003",
          "containerCode": "",
          "status": "lock"
        },
        {
          "status_dictText": "空闲",
          "haveContainer_dictText": "没有",
          "code": "A1P011004",
          "containerCode": "",
          "status": "empty"
        },
        {
          "status_dictText": "锁定",
          "haveContainer_dictText": "有",
          "code": "A1P011005",
          "containerCode": "S00013",
          "status": "lock"
        }

      ]

      // 转换为网格数据格式
      this.gridRows = rawData.map((item, index) => ({
        ...item,
        id: `grid-${index}`,
        level: parseInt(item.code.match(/\d+/g)[0]) || 1,
        side: item.code.charAt(0),
        x: index,
        y: 1
      }))
    },
    // 获取网格单元格样式
    getGridCellClass(cell) {
      return {
        'grid-selected': cell.status === 'empty' && cell.haveContainer_dictText === '有',
        'grid-lock': cell.status === 'lock',
        'grid-empty': cell.status === 'empty' && cell.haveContainer_dictText === '没有'
      }
    },
    getGridCellStyle(cell) {
      let backgroundColor = '#4F94CD' // 默认蓝色
      if (cell.status === 'lock') {
        backgroundColor = '#ff7875' // 浅红色 - lock状态
      } else if (cell.status === 'empty') {
        if (cell.haveContainer_dictText === '有') {
          backgroundColor = '#69c0ff' // 浅蓝色 - 有托盘的空闲状态
        } else {
          backgroundColor = '#95de64' // 浅绿色 - 无托盘的空闲状态
        }
      }
      return {backgroundColor}
    },
    // 获取状态颜色
    getStatusColor(status) {
      const colorMap = {
        'empty': 'green',
        'lock': 'orange',
        'occupied': 'blue'
      }
      return colorMap[status] || 'default'
    },
    // 获取单元格显示内容
    getCellDisplayContent(cell) {
      if (cell.containerCode) {
        return cell.containerCode
      }
      // // 解析点位编码,显示更简洁的信息
      // const code = cell.code
      // // 例如:A1P011001 -> 显示为 A1-001
      // const match = code.match(/([A-Z])(\d+)P\d+(\d{3})/)
      // if (match) {
      //   return `${match[1]}${match[2]}-${match[3]}`
      // }
      // return cell.code
    },
    // 获取工具提示内容
    getTooltipContent(cell) {
      const lines = [
        `点位编码: ${cell.code}`,
        `状态: ${cell.status_dictText}`,
        `托盘状态: ${cell.haveContainer_dictText}`
      ]

      if (cell.containerCode) {
        lines.push(`容器编码: ${cell.containerCode}`)
      }

      return lines.join('\n')
    },
    handleCellClick(cell){
      this.hoveredCell = cell;
      this.showDetailModal = true;
    },
    // 鼠标进入单元格
    handleCellHover(cell) {
      if (this.hoverTimer) {
        clearTimeout(this.hoverTimer);
      }
      // 记录鼠标位置
      if (event) {
        this.modalPosition = {
          x: event.clientX + 10, // 稍微偏移,避免遮挡
          y: event.clientY + 10
        };
      }
      this.hoverTimer = setTimeout(() => {
        this.hoveredCell = cell;
        this.showDetailModal = true;
      }, 500);
    },

    // 鼠标离开单元格
    handleCellLeave() {
      // 清除计时器,防止在离开后仍然触发显示
      if (this.hoverTimer) {
        clearTimeout(this.hoverTimer);
        this.hoverTimer = null;
      }
    },

    // 关闭modal时清理数据
    handleModalClose() {
      this.showDetailModal = false;
      this.hoveredCell = null;
    },
    //点位入库
    async stageingReceipt() {
      if (!this.formData.taskId) {
        this.$message.warning('没有找到对应的任务')
        return
      }
      console.log('入库:', {
        id: this.formData.id,
        taskId: this.formData.taskId,
        num: this.formData.num
      })
      //
      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
    },
    // 呼叫空托盘
    async callEmptyOut() {
      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('呼叫空托指令已发送')

        // 清空表单(可选)
        // this.resetForm()
      } catch (error) {
        this.$message.error('提交失败')
      }
    },
    // 机台选择
    handleStationSelect(station) {
      this.currentStation = station
      this.stationInfo = `${station}`
      //根据machineCode查询对应的AGV任务和生产加工单
      if (station) {
        this.$refs.machineAgvTask.edit(station);
      }
      this.showStationModal = false
    },
    // 切换tabs
    reloadBottom(key) {
      if (key === "1") {
        this.$refs.machineAgvTask.edit(this.currentStation);
      } else if (key === "2") {
        console.log("reloadBottom currentStation", this.currentStation)
        this.$refs.machineProductionOrderHeader.edit(this.currentStation);
      }
    },
    handleResize() {
      // 可以在这里添加响应式布局的逻辑
      console.log('窗口大小变化,当前宽度:', window.innerWidth)
    },
  }
}
</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-container {
              display: grid;
              gap: 15px; /* 减少间隙 */
              grid-template-columns: repeat(3, 1fr); /* 关键:每行3列 */
              margin-bottom: 8px;

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

              .grid-cell {
                flex: 1;
                min-width: 0; /* 允许缩小 */
                height: 60px;
                //background: linear-gradient(135deg, #4F94CD 0%, rgb(255,255,0) 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-lock {
                //  //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-lock):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-point); /* 改为显示点位号 */
                  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;
    }
  }
}

/* 详情弹窗内容样式 */
.cell-detail-content {
  padding: 20px 0;
}
.detail-item {
  display: flex;
  align-items: flex-start; /* 顶部对齐,适合多行内容 */
  margin-bottom: 5px; /* 更大的间距 */
  line-height: 2; /* 更大的行高 */
  padding: 5px 0; /* 每项内部也有间距 */
}
.detail-label {
  font-weight: 600;
  color: #595959; /* 稍微深一点的颜色 */
  min-width: 110px; /* 更宽的标签区域 */
  flex-shrink: 0;
  font-size: 15px;
  letter-spacing: 0.5px; /* 字间距 */
}
.detail-value {
  color: #262626; /* 更深的文字颜色 */
  flex: 1;
  word-break: break-all;
  font-size: 15px;
  padding-left: 4px;
}
.detail-item .ant-tag {
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 4px;
  margin: 2px 0;
}
.detail-value .ant-tag {
  display: inline-block;
  max-width: 100%;
  white-space: normal; /* 允许标签内文字换行 */
  word-break: break-word;
}
</style>