location.vue 27.4 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
<template>
  <el-container style="padding: 20px">
    <el-aside>
      <el-card :style="{ height: asideHeight }">
        <el-form label-width="80px">
          <el-form-item label="库位编号">
            <el-input
              v-model="locationCode"
              placeholder="请输入库位编号"
            ></el-input>
          </el-form-item>
          <el-form-item label="关联库位">
            <el-input
              v-model="associatedLocation"
              placeholder="请输入关联库位"
            ></el-input>
          </el-form-item>
          <el-form-item label="容器编码">
            <el-input
              v-model="containerCode"
              placeholder="请输入容器编码"
            ></el-input>
          </el-form-item>
          <el-form-item label="区域">
            <el-input v-model="area" placeholder="请输入区域"></el-input>
          </el-form-item>
          <el-form-item label="库位状态">
            <el-select v-model="locationStatus" placeholder="请选择库位状态">
              <el-option label="全部" value=""></el-option>
              <el-option label="空闲" value="1"></el-option>
              <el-option label="工作" value="2"></el-option>
              <el-option label="禁用" value="4"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="仓库编码">
            <el-select v-model="warehouseCode" placeholder="请选择仓库编码">
              <el-option
                v-for="item in warehouseList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="容器状态">
            <el-select v-model="containerStatus" placeholder="请选择容器状态">
              <el-option label="全部" value=""></el-option>
              <el-option label="有容器" value="available"></el-option>
              <el-option label="无容器" value="unavailable"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-row>
              <el-col :span="8">
                <el-button type="primary" size="small" @click="handleQuery"
                  >查询</el-button
                >
              </el-col>
              <el-col :span="8">
                <el-button type="success" size="small" @click="handleAdd"
                  >新增</el-button
                >
              </el-col>
            </el-row>
            <el-row style="margin-top: 5px">
              <el-col :span="8">
                <el-button type="danger" size="small" @click="handleDelete"
                  >删除</el-button
                >
              </el-col>
              <el-col :span="8">
                <el-button size="small" @click="handleExport">导出</el-button>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8" :offset="2">
                <!-- 修改点击事件 -->
                <el-button
                  type="success"
                  size="small"
                  @click="handleChangeStatus"
                >
                  更改状态
                </el-button>
              </el-col>
            </el-row>
          </el-form-item>

          <el-form-item>
            <div style="margin-left: -80px">
              <el-card :style="{ width: '205px', margin: '0 auto' }">
                <template #header>
                  <div class="card-header">
                    <span>容器维护</span>
                  </div>
                </template>
                <el-form-item label="容器号">
                  <el-input
                    v-model="containerNumber"
                    placeholder="请输入容器号"
                  ></el-input>
                </el-form-item>
                <el-row style="display: flex">
                  <el-col style="padding-left: 16px">
                    <el-button
                      type="danger"
                      size="small"
                      @click="handleContainerDelete"
                      >删除</el-button
                    >
                  </el-col>
                  <el-col>
                    <el-button
                      type="warning"
                      size="small"
                      @click="handleContainerEdit"
                      >写入容器</el-button
                    >
                  </el-col>
                </el-row>
              </el-card>
            </div>
          </el-form-item>
        </el-form>
      </el-card>
    </el-aside>
    <el-dialog
      title="新增"
      :visible.sync="dialogFormVisible"
      width="30%"
      center
    >
      <el-tabs v-model="activeTab">
        <el-tab-pane label="单个新增" name="single">
          <el-form :model="form" label-width="100px">
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="前缀">
                  <el-input v-model="form.prefix" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="连接符">
                  <el-input
                    v-model="form.connector"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="PLC行索引1">
                  <el-input
                    v-model="form.plcRowIndex1"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="PLC行索引2">
                  <el-input
                    v-model="form.plcRowIndex2"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="堆垛机标记">
                  <el-select
                    v-model="form.srmCode"
                    placeholder="请选择堆垛机标记"
                  >
                    <el-option label="标记1" value="1"></el-option>
                    <el-option label="标记2" value="2"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="巷道">
                  <el-input
                    v-model="form.roadway"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="行数">
                  <el-input
                    v-model="form.rowCount"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="列数">
                  <el-input
                    v-model="form.columnCount"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="层数">
                  <el-input
                    v-model="form.layerCount"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>

                <el-form-item label="库位类型">
                  <el-select
                    v-model="form.locationType"
                    placeholder="请选择库位类型"
                  >
                    <el-option label="类型1" value="1"></el-option>
                    <el-option label="类型2" value="2"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="区域">
                  <el-input v-model="form.area" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="仓库">
                  <el-select v-model="form.warehouse" placeholder="请选择仓库">
                    <el-option
                      v-for="item in warehouseList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="批量新增" name="batch">
          <el-form :model="batchForm" label-width="100px">
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="前缀">
                  <el-input
                    v-model="batchForm.prefix"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="连接符">
                  <el-input
                    v-model="batchForm.connector"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="PLC行索引1">
                  <el-input
                    v-model="batchForm.plcRowIndex1"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="PLC行索引2">
                  <el-input
                    v-model="batchForm.plcRowIndex2"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="堆垛机标记">
                  <el-select
                    v-model="batchForm.srmCode"
                    placeholder="请选择堆垛机标记"
                  >
                    <el-option label="标记1" value="1"></el-option>
                    <el-option label="标记2" value="2"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="巷道">
                  <el-input
                    v-model="batchForm.roadway"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="行数">
                  <el-row :gutter="12">
                    <el-col :span="11" style="padding-left: 0">
                      <el-input
                        v-model="batchForm.rowCount"
                        autocomplete="off"
                      ></el-input>
                    </el-col>
                    <el-col :span="11" style="padding-left: 0">
                      <el-input
                        v-model="batchForm.rowCount2"
                        autocomplete="off"
                      ></el-input>
                    </el-col>
                  </el-row>
                </el-form-item>
                <el-form-item label="列数">
                  <el-row :gutter="12">
                    <el-col :span="11" style="padding-left: 0">
                      <el-input
                        v-model="batchForm.columnCount"
                        autocomplete="off"
                      ></el-input>
                    </el-col>
                    <el-col :span="11" style="padding-left: 0">
                      <el-input
                        v-model="batchForm.columnCount2"
                        autocomplete="off"
                      ></el-input>
                    </el-col>
                  </el-row>
                </el-form-item>
                <el-form-item label="层数">
                  <el-row :gutter="12">
                    <el-col :span="11" style="padding-left: 0">
                      <el-input
                        v-model="batchForm.layerCount"
                        autocomplete="off"
                      ></el-input>
                    </el-col>
                    <el-col :span="11" style="padding-left: 0">
                      <el-input
                        v-model="batchForm.layerCount2"
                        autocomplete="off"
                      ></el-input>
                    </el-col>
                  </el-row>
                </el-form-item>

                <el-form-item label="库位类型">
                  <el-select
                    v-model="batchForm.locationType"
                    placeholder="请选择库位类型"
                  >
                    <el-option label="类型1" value="1"></el-option>
                    <el-option label="类型2" value="2"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="区域">
                  <el-input
                    v-model="batchForm.area"
                    autocomplete="off"
                  ></el-input>
                </el-form-item>
                <el-form-item label="仓库">
                  <el-select v-model="form.warehouse" placeholder="请选择仓库">
                    <el-option
                      v-for="item in warehouseList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-tab-pane>
      </el-tabs>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleAddData">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="更改状态"
      :visible.sync="changeStatusDialogVisible"
      width="30%"
      center
    >
      <el-form label-width="100px">
        <el-form-item label="库位号">
          <el-input
            v-model="selectedLocationCode"
            placeholder="请输入库位号"
          ></el-input>
        </el-form-item>
        <el-form-item label="更改状态">
          <el-select v-model="newLocationStatus" placeholder="请选择新状态">
            <el-option label="全部" value=""></el-option>
            <el-option label="空闲" value="1"></el-option>
            <el-option label="工作" value="2"></el-option>
            <el-option label="禁用" value="4"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="changeStatusDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="confirmChangeStatus">确定</el-button>
      </span>
    </el-dialog>
    <el-main>
      <el-card>
        <el-table
          :data="tableData"
          style="width: 100%"
          :height="TableHeight"
          border
          highlight-current-row
          @selection-change="handleSelectionChange"
          @row-click="handleRowClick"
          ref="multipleTable"
        >
          <el-table-column type="selection" width="55"></el-table-column>

          <el-table-column prop="code" label="库位编码"></el-table-column>
          <el-table-column prop="linkCode" label="关联库位"></el-table-column>
          <el-table-column
            prop="containerCode"
            label="容器编码"
          ></el-table-column>
          <el-table-column
            prop="locationTypeCode"
            label="类型"
          ></el-table-column>
          <el-table-column prop="row" label="行"></el-table-column>
          <el-table-column prop="column" label="列"></el-table-column>
          <el-table-column prop="layer" label="层"></el-table-column>
          <el-table-column
            prop="destinationArea"
            label="区域"
          ></el-table-column>
          <el-table-column prop="roadway" label="巷道"></el-table-column>
          <el-table-column
            prop="sRMCode"
            label="堆垛机标记"
            width="120"
          ></el-table-column>
          <el-table-column
            prop="rowIndex1"
            label="下位排索引1"
            width="120"
          ></el-table-column>
          <el-table-column
            prop="rowIndex2"
            label="下位排索引2"
            width="120"
          ></el-table-column>
          <el-table-column label="状态">
            <template slot-scope="scope">
              {{ statusMap[scope.row.status] || "未知" }}
            </template>
          </el-table-column>
          <el-table-column prop="warehouseCode" label="仓库"></el-table-column>
        </el-table>
        <el-pagination
          style="margin-top: 15px"
          align="center"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[20, 50, 100]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        />
      </el-card>
    </el-main>
  </el-container>
</template>

<script>
import {
  GetPageLocations,
  CreateLocation,
  CreateLocations,
  DeleteLocations,
  DeleteContainerCodes,
  WriteContainerCode,
  UpdateLocationStatus,
} from "@/api/basicData/location";
import { GetPageWarehouses } from "@/api/basicData/warehouse";
export default {
  name: "location",
  data() {
    return {
      changeStatusDialogVisible: false,
      selectedLocationCode: "",
      newLocationStatus: "", // 选择的新状态
      statusMap: {
        1: "空闲",
        2: "工作",
        4: "禁用",
      },
      containerNumber: "",
      // 修改仓库编码为库位编号
      locationCode: "",
      // 新增关联库位
      associatedLocation: "",
      // 新增容器编码
      containerCode: "",
      // 新增区域
      area: "",
      // 新增库位状态
      locationStatus: "",
      // 新增选中的仓库编码
      warehouseCode: "",
      // 新增仓库列表
      warehouseList: [],
      currentPage: 1,
      total: 0,
      pageSize: 20,
      selectedItems: [],
      tableData: [],
      // 新增容器状态
      containerStatus: "",
      dialogFormVisible: false,
      activeTab: "single", // 默认激活的标签页
      form: {
        prefix: "",
        connector: "",
        plcRowIndex1: 0,
        plcRowIndex2: 0,
        srmCode: "",
        roadway: 0,
        rowCount: 0,
        columnCount: 0,
        layerCount: 0,
        locationType: "",
        area: "",
        warehouse: "",
      },
      batchForm: {
        prefix: "",
        connector: "",
        plcRowIndex1: "",
        plcRowIndex2: "",
        srmCode: "",
        roadway: "",
        rowCount: "",
        rowCount2: "",
        columnCount: "",
        columnCount2: "",
        layerCount: "",
        layerCount2: "",
        locationType: "",
        area: "",
        warehouse: "",
      },
    };
  },
  created() {
    this.getWarehouseOptions();
  },
  computed: {
    TableHeight() {
      return `calc(100vh - 220px )`;
    },
    asideHeight() {
      return `calc(100vh - 150px)`;
    },
    currentUserName() {
      return this.$store.state.user.name;
    },
  },
  methods: {
    handleRowClick(row) {
      this.$refs.multipleTable.toggleRowSelection(row);
    },
    handleSelectionChange(val) {
      this.selectedItems = val;
      // console.log("选中的行数据:", this.selectedItems);
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.handleQuery();
    },

    handleCurrentChange(val) {
      this.currentPage = val;
      this.handleQuery();
    },
    getWarehouseOptions() {
      const requestData = {
        pageNumber: this.currentPage,
        perPageCount: this.pageSize,
        queryConfig: {
          code: "",
        },
      };
      GetPageWarehouses(requestData).then((res) => {
        if (res.code == "Success" && res.data) {
          this.warehouseList = [];
          this.warehouseList.push({ value: "", label: "全部" });
          res.data.data.forEach((x) => {
            this.warehouseList.push({ value: x.code, label: x.name });
          });
          if (this.warehouseList.length > 0) {
            this.form.warehouse = this.warehouseList[0].value;
            this.batchForm.warehouse = this.warehouseList[0].value;
          }
        }
      });
    },
    handleQuery() {
      const requestData = {
        pageNumber: this.currentPage,
        perPageCount: this.pageSize,
        queryConfig: {
          code: this.locationCode.trim(),
          linkCode: this.associatedLocation.trim(),
          warehouseCode: this.warehouseCode.trim(),
          containerCode: this.containerCode.trim(),
          destinationArea: this.area.trim(),
        },
      };
      GetPageLocations(requestData).then((res) => {
        if (res.code == "Success" && res.data) {
          this.tableData = res.data.data || res.data;
          this.total = res.data.totalCount || res.data.data.length;
        }
      });
    },
    handleAdd() {
      this.dialogFormVisible = true;
      this.form = {
        prefix: "",
        connector: "",
        plcRowIndex1: 0,
        plcRowIndex2: 0,
        srmCode: "",
        roadway: 0,
        rowCount: 0,
        columnCount: 0,
        layerCount: 0,
        locationType: "",
        area: "",
        warehouse: "",
      };
      this.batchForm = {
        prefix: "",
        connector: "",
        plcRowIndex1: 0,
        plcRowIndex2: 0,
        srmCode: "",
        roadway: 0,
        rowCount: 0,
        rowCount2: 0,
        columnCount: 0,
        columnCount2: 0,
        layerCount: 0,
        layerCount2: 0,
        locationType: "",
        area: "",
        warehouse: "",
      };
    },
    handleAddData() {
      if (this.activeTab === "single") {
        const requestData = {
          prefix: this.form.prefix,
          rowIndex: this.form.rowCount,
          columnIndex: this.form.columnCount,
          layerIndex: this.form.layerCount,
          rowIndex1: this.form.plcRowIndex1,
          rowIndex2: this.form.plcRowIndex2,
          srmCode: this.form.srmCode,
          type: this.form.locationType,
          connector: this.form.connector,
          roadway: this.form.roadway,
          destinationArea: this.form.area,
          warehouseCode: this.form.warehouse,
          userCode: this.currentUserName,
        };
        CreateLocation(requestData).then((res) => {
          if (res.code === "Success") {
            this.$message.success("新增成功");
            this.dialogFormVisible = false;
            this.handleQuery();
          } else {
            this.$message.error(res.message);
          }
        });
      } else if (this.activeTab === "batch") {
        const batcheDatas = {
          prefix: this.batchForm.prefix,
          rowBeginIndex: this.batchForm.rowCount,
          rowEndIndex: this.batchForm.rowCount2,
          columnBeginIndex: this.batchForm.columnCount,
          columnEndIndex: this.batchForm.columnCount2,
          layerBeginIndex: this.batchForm.layerCount,
          layerEndIndex: this.batchForm.layerCount2,
          rowIndex1: this.batchForm.plcRowIndex1,
          rowIndex2: this.batchForm.plcRowIndex2,
          srmCode: this.batchForm.srmCode,
          type: this.batchForm.locationType,
          hightType: "",
          connector: this.batchForm.connector,
          roadway: this.batchForm.roadway,
          destinationArea: this.batchForm.area,
          warehouseCode: this.batchForm.warehouse,
          userCode: this.currentUserName,
        };
        CreateLocations(batcheDatas).then((res) => {
          if (res.code === "Success") {
            this.$message.success("批量新增成功");
            this.dialogFormVisible = false;
            this.handleQuery();
          } else {
            this.$message.error("批量新增失败");
          }
        });
        console.log("批量新增数据:", batcheDatas);
      }
    },
    handleExport() {
      // 导出逻辑
    },
    handleDelete() {
      console.log(this.selectedItems);
      if (this.selectedItems.length === 0) {
        this.$alert("请至少选择一条数据", "提示", {
          confirmButtonText: "确定",
        });
        return;
      }
      this.$confirm("确定要删除选中的数据吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          const codes = this.selectedItems.map((item) => item.code);
          DeleteLocations(codes).then((res) => {
            if (res.code === "Success") {
              this.$message.success("删除成功");
              this.handleQuery();
            }
          });
        })
        .catch(() => {
          this.$message.info("已取消删除");
        });
    },
    // 新增容器删除方法
    handleContainerDelete() {
      const requestData = [
        {
          code: this.containerNumber,
          linkCode: this.associatedLocation.trim(),
          status: item.status,
          userCode: this.currentUserName,
          warehouseCode: item.warehouseCode,
          containerCode: this.containerNumber,
          destinationArea: this.area,
          isContainerCode: true,
          notContainerCode: false,
        },
      ];
      DeleteContainerCodes(requestData).then((res) => {
        if (res.code === "Success") {
          this.$message.success("删除成功");
          this.handleQuery();
        }
      });
    },
    // 新增容器编辑方法
    handleContainerEdit() {
      if (this.containerNumber === "") {
        this.$message.error("请输入容器编码");
        return;
      }
      const ronqidata = {
        code: this.containerNumber,
        linkCode: this.associatedLocation.trim(),
        status: item.status,
        userCode: this.currentUserName,
        warehouseCode: item.warehouseCode,
        containerCode: this.containerNumber,
        destinationArea: this.area,
        isContainerCode: true,
        notContainerCode: false,
      };
      WriteContainerCode(ronqidata).then((res) => {
        if (res.code === "Success") {
          this.$message.success("编辑成功");
          this.handleQuery();
        } else {
          this.$message.error(res.message);
        }
      });
    },
    // 新增更改状态的方法
    handleChangeStatus() {
      if (this.selectedItems.length === 0) {
        this.$alert("请至少选择一条数据", "提示", {
          confirmButtonText: "确定",
        });
        return;
      }

      this.selectedLocationCode = this.selectedItems
        .map((item) => item.code)
        .join(",");
      this.changeStatusDialogVisible = true;
    },
    confirmChangeStatus() {
      if (!this.selectedLocationCode) {
        this.$message.error("请选择库位号");
        return;
      }
      // 组装请求数据
      const requestData = this.selectedItems.map((item) => ({
        code: item.code,
        linkCode: item.linkCode || "",
        status: parseInt(this.newLocationStatus),
        userCode: this.currentUserName,
        warehouseCode: item.warehouseCode,
        containerCode: item.containerCode || "",
        destinationArea: item.destinationArea || "",
        isContainerCode: false,
        notContainerCode: false,
      }));
      console.log("UpdateLocationStatus 的请求数据:", requestData);
      UpdateLocationStatus(requestData).then((res) => {
        if (res.code === "Success") {
          this.$message.success("状态更改成功");
          this.changeStatusDialogVisible = false;
          this.handleQuery();
        } else {
          this.$message.error(res.message);
        }
      });
    },
  },
};
</script>

<style scoped>
.el-card__body,
.el-main {
  padding: 0 10px 0 10px;
}
::v-deep.el-table thead {
  color: #101010;
  font-weight: 600;
}
.card-header {
  height: 21px;
  text-align: center;
}
.el-card__header {
  padding: 2px 20px !important;
}
.el-form-item {
  margin-bottom: 18px;
}
.el-table__body tr.current-row {
  background-color: #f0f9eb; /* 自定义高亮背景色 */
}
/* 样式定义 */
</style>