ReceiptModal.vue 28.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
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-row :gutter="24">
      <a-col :span="12">
        <a-table
          rowKey="id"
          size="middle"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="true"
          :customRow="clickThenChange"
          :rowSelection="{type: 'radio',selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
<!--            <span slot="action" slot-scope="text, record">-->
<!--              <a-input-number placeholder="" v-model="record.taskQty" :value="text"/>-->
<!--            </span>-->
          <span slot="action" slot-scope="text, record">
              <a-button type="primary" :loading="receiveLoading" @click="quickReceive(record)">快速收货</a-button>
          </span>
          <span slot="inventoryStatus" slot-scope="inventoryStatus">
              <a-tag :key="inventoryStatus" color="blue" :color="getStatusColor(inventoryStatus)">
                 {{ solutionInvStatus(inventoryStatus) }}
              </a-tag>
            </span>
        </a-table>
      </a-col>
      <a-col :span="12">
        <div class="table-operator">
          <!--          <a-button v-has="'cycleCountHeader:add'" type="danger" icon="delete" @click="handleDelete(record.id)"-->
          <!--                    theme="twoTone">取消收货-->
          <!--          </a-button>-->
          <!--          <a-button v-has="'cycleCountHeader:export'" :style="{background: '#fba70f', color: '#fff'}"-->
          <!--                    icon="check-circle" @click="createTask(record)">生成任务-->
          <!--          </a-button>-->
          <a-form-model ref="form" :model="model" :rules="validatorRules">
            <a-form-model-item label="容器编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="containerCode">
              <a-row :gutter="8">
                <a-col :span="16">
                  <a-input ref="containerCode" v-model="model.containerCode" placeholder="请输入容器编码" style="width: 100%"/>
                </a-col>
                <a-col :span="8">
                  <a-button type="primary" :loading="receiveLoading" @click="inputContainerCodeReceive()">组盘</a-button>
                </a-col>
              </a-row>
            </a-form-model-item>
          </a-form-model>
        </div>
        <div>
          <a-table
            ref="table1"
            size="middle"
            bordered
            rowKey="id"
            :scroll="{x:true}"
            :columns="columns1"
            :dataSource="dataSource1"
            :pagination="pagination1"
            :loading="loading1"
            :rowSelection="{type: 'radio',selectedRowKeys: selectedRowKeys1, onChange: onSelectChange1}"
            class="j-table-force-nowrap"
            @change="loadingContainerDetailByCode">
             <span slot="status_dictText" slot-scope="status_dictText">
                <a-tag :key="status_dictText" :color="getStatusColor(status_dictText)">
                  {{ status_dictText }}
                </a-tag>
              </span>
            <span slot="taskType_dictText" slot-scope="taskType_dictText">
                <a-tag :key="taskType_dictText" :color="getStatusColor(taskType_dictText)">
                  {{ taskType_dictText }}
                </a-tag>
             </span>
          </a-table>
        </div>
        <a-card :bordered="false" :body-style="{padding:0}">
          <template #title>
            <span :style="{ color: titleColor }">库存详情</span>
          </template>
          <a-table
            size="middle"
            bordered
            :rowKey="record=>record.containeCode+'_'+record.id"
            :scroll="{ x: true }"
            :columns="columns2"
            :dataSource="dataSource2"
            :pagination="pagination2"
            :loading="loading2"
            class="j-table-force-nowrap"
            @change="loadingInventoryDetailList">
              <span slot="action2" slot-scope="text, record, index">
                <a-button type="primary" :loading="receiveLoading" @click="receive(record, index)">组盘</a-button>
              </span>
            <span slot="containerStatus_dictText" slot-scope="containerStatus_dictText">
                <a-tag :key="containerStatus_dictText" :color="getStatusColor(containerStatus_dictText)">
                  {{ containerStatus_dictText }}
                </a-tag>
              </span>
            <span slot="enable_dictText" slot-scope="enable_dictText">
                <a-tag :key="enable_dictText" :color="getStatusColor(enable_dictText)">
                  {{ enable_dictText }}
                </a-tag>
              </span>
            <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
                <a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
                  {{ inventoryStatus_dictText }}
                </a-tag>
              </span>
          </a-table>
        </a-card>
        <a-card :bordered="false" :body-style="{padding:0}">
          <template #title>
            <span :style="{ color: titleColor }">库存交易</span>
          </template>
          <a-table
            size="middle"
            bordered
            :rowKey="record=>record.containeCode+'_'+record.id"
            :scroll="{ x: true }"
            :columns="columns3"
            :dataSource="dataSource3"
            :pagination="pagination3"
            :loading="loading3"
            class="j-table-force-nowrap"
            @change="loadingInventoryTransactionSelectContainerlist">
              <span slot="action3" slot-scope="text, record, index">
                <a-button type="primary" :loading="receiveLoading" @click="receive(record, index)">组盘</a-button>
              </span>
            <span slot="zoneCode" slot-scope="zoneCode">
                <a-tag :key="zoneCode" color=blue>
                  {{ solutionZoneCode(zoneCode) }}
                </a-tag>
              </span>
            <span slot="companyCode" slot-scope="companyCode">
                <a-tag :key="companyCode" color="blue">
                  {{ solutionCompany(companyCode) }}
                </a-tag>
              </span>
          </a-table>
        </a-card>
        <a-card :bordered="false" :body-style="{padding:0}">
          <template #title>
            <span :style="{ color: titleColor }">空料盒</span>
          </template>
          <a-table
            size="middle"
            bordered
            :rowKey="record=>record.containeCode+'_'+record.id"
            :scroll="{ x: true }"
            :columns="columns4"
            :dataSource="dataSource4"
            :pagination="pagination4"
            :loading="loading4"
            class="j-table-force-nowrap"
            @change="loadingListEmptyContainerInLocation">
              <span slot="action4" slot-scope="text, record, index">
                  <a-button type="primary" :loading="receiveLoading" @click="receive(record, index)">组盘</a-button>
              </span>
          </a-table>
        </a-card>
      </a-col>
    </a-row>
  </j-modal>

</template>

<script>
import {getAction, httpAction} from '@/api/manage'
import {ajaxGetDictItems, listReceiveByReceiptId, getZoneList, getCompanyList, createReceiptTask} from '@/api/api'

export default {
  name: 'ReceiptModal',
  components: {},
  props: {
    mainId: {
      type: String,
      required: false,
      default: ''
    }
  },
  data() {
    return {
      title: '操作',
      width: (parseFloat('90%') / 100) * window.innerWidth,
      visible: false,
      loading1: false,
      loading2: false,
      loading3: false,
      loading4: false,
      receiveLoading: false,
      titleColor: 'red',
      materialList: {},
      companyList: [],
      zoneCode: [],
      querySource: {},
      dataSource: [],
      dataSource1: [],
      dataSource2: [],
      dataSource3: [],
      dataSource4: [],
      pagination1: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      pagination2: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      pagination3: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      pagination4: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      invStatus: [],
      selectedRowKeys: [],
      selectedRowKeys1: [],
      selectedRows: [],
      selectedRows1: [],
      model: {},
      labelCol: {
        xs: {span: 24},
        sm: {span: 2}
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 8}
      },
      columns: [
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          scopedSlots: {customRender: 'action'},
          width: 60
        },
        {
          title: '明细id',
          dataIndex: 'id',
          align: 'center'
        },
        {
          title: '物料编码',
          dataIndex: 'materialCode',
          align: 'center'
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
          align: 'center'
        },
        {
          title: '可收数量',
          dataIndex: 'qty',
          align: 'center',
          width: 80
        },
        // {
        //   title: '组盘数量',
        //   dataIndex: 'action',
        //   align: 'center',
        //   key: 'action',
        //   scopedSlots: {customRender: 'action'}
        // },
        {
          title: '库存状态',
          dataIndex: 'inventoryStatus',
          align: 'center',
          width: 96,
          scopedSlots: {customRender: 'inventoryStatus'}
        }
      ],
      columns1: [
        // {
        //   title: '操作',
        //   dataIndex: 'action2',
        //   align: "center",
        //   width: 147,
        //   scopedSlots: {customRender: 'action2'}
        // },
        {
          title: '组盘明细id',
          dataIndex: 'id',
          align: 'center'
        },
        {
          title: '组盘头id',
          dataIndex: 'receiptContainerId',
          align: 'center'
        },
        {
          title: '容器编码',
          dataIndex: 'containerCode',
          align: 'center'
        },
        {
          title: '库位编码',
          dataIndex: 'locationCode',
          align: 'center'
        },
        {
          title: '物料编码',
          dataIndex: 'materialCode',
          align: 'center'
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
          align: 'center'
        },
        {
          title: '数量',
          dataIndex: 'qty',
          align: 'center'
        },
        {
          title: '入库单明细id',
          dataIndex: 'receiptDetailId',
          align: 'center'
        },
        {
          title: '创建人',
          dataIndex: 'createBy',
          align: 'center'
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          align: 'center'
        }
      ],
      columns2: [
        {
          title: '操作',
          dataIndex: 'action2',
          align: "center",
          scopedSlots: {customRender: 'action2'}
        },
        {
          title: '库存id',
          dataIndex: 'id',
          align: 'center'
        },
        {
          title: '容器编码',
          dataIndex: 'containerCode',
          align: 'center'
        },
        {
          title: '库位编码',
          dataIndex: 'locationCode',
          align: 'center'
        },
        {
          title: '物料编码',
          dataIndex: 'materialCode',
          align: 'center'
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
          align: 'center'
        },
        {
          title: '数量',
          dataIndex: 'qty',
          align: 'center',
          width: 80
        },
        {
          title: '容器状态',
          align: "center",
          dataIndex: 'containerStatus_dictText',
          scopedSlots: {customRender: 'containerStatus_dictText'},
          filterMultiple: false,
          filters: [
            {text: '空闲', value: 'empty'},
            {text: '锁定', value: 'lock'},
          ]
        },
        {
          title: '库存状态',
          align: 'center',
          dataIndex: 'inventoryStatus_dictText',
          scopedSlots: {customRender: 'inventoryStatus_dictText'},
          filterMultiple: true,
          filters: [
            {text: '良品', value: 'good'},
            {text: '次品', value: 'defective'},
            {text: '报废品', value: 'scrap'},
            {text: '待确认', value: 'discussed'},
          ]
        },
        {
          title: '可用状态',
          align: 'center',
          dataIndex: 'enable_dictText',
          scopedSlots: {customRender: 'enable_dictText'},
          filterMultiple: false,
          filters: [
            {text: '正常', value: '0'},
            {text: '冻结', value: '1'},
          ]
        },
        {
          title: '创建人',
          dataIndex: 'createBy',
          align: 'center'
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          align: 'center'
        }
      ],
      columns3: [
        {
          title: '操作',
          dataIndex: 'action3',
          align: "center",
          scopedSlots: {customRender: 'action3'}
        },
        {
          title: '货主',
          align: 'center',
          dataIndex: 'companyCode',
          key: 'companyCode',
          scopedSlots: {customRender: 'companyCode'}
        },
        {
          title: '库区',
          align: "center",
          dataIndex: 'zoneCode',
          key: 'zoneCode',
          scopedSlots: {customRender: 'zoneCode'}
        },
        {
          title: '容器编码',
          align: 'center',
          dataIndex: 'containerCode'
        },
        {
          title: '起始库位编码',
          align: 'center',
          dataIndex: 'fromLocationCode'
        },
        {
          title: '目标库位编码',
          align: 'center',
          dataIndex: 'toLocationCode'
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName'
        },
        {
          title: '交易类型',
          align: 'center',
          dataIndex: 'type_dictText'
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'qty'
        },
        {
          title: '交易时间',
          align: 'center',
          dataIndex: 'createTime'
        }
      ],
      columns4: [
        {
          title: '操作',
          dataIndex: 'action4',
          align: "center",
          scopedSlots: {customRender: 'action4'}
        },
        {
          title: '容器编码',
          dataIndex: 'containerCode',
          align: 'center'
        },
        {
          title: '库位编码',
          dataIndex: 'code',
          align: 'center'
        },
        {
          title: '库区',
          align: "center",
          dataIndex: 'zoneCode',
          key: 'zoneCode',
          scopedSlots: {customRender: 'zoneCode'}
        },
        {
          title: '行',
          dataIndex: 'row',
          align: 'center'
        },
        {
          title: '列',
          dataIndex: 'icolumn',
          align: 'center'
        }, {
          title: '层',
          dataIndex: 'layer',
          align: 'center'
        },

      ],
      validatorRules: {
        containerCode: [{required: true, message: '请输入容器编码!'}]
      },
      dictOptions: {},
      superFieldList: [],
      url: {
        listReceiptContainerDetailByMainId: '/receipt/receiptContainerHeader/listReceiptContainerDetailByMainId',
        queryInventoryDetailList: '/inventory/inventoryDetail/list',
        inventoryTransactionSelectContainerlist: "/inventory/inventoryTransaction/selectContainerlist",
        listEmptyContainerInLocation: "/config/location/listEmptyContainerInLocation",
        add: '/receipt/receiveHeader/receiving',
        edit: '/receipt/receiptHeader/editReceiptDetail'
      }
    }
  },
  created() {
    //备份model原始值
    // this.searchReceive()
    this.getSuperFieldList()
    // this.modelDefault = JSON.parse(JSON.stringify(this.model))
    this.loadFrom();
  },
  methods: {
    edit(record) {
      this.model = Object.assign({}, record)
      this.visible = true
      this.searchReceive()
    },
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({type: 'string', value: 'inventoryStatus', text: '库存状态', dictCode: 'inventory_status'})
      this.superFieldList = fieldList
    },
    solutionInvStatus(value) {
      var actions = []
      Object.keys(this.invStatus).some(key => {
        if (this.invStatus[key].value == '' + value) {
          actions.push(this.invStatus[key].text)
          return true
        }
      })
      return actions.join('')
    },
    solutionCompany(value) {
      var actions = []
      Object.keys(this.companyList).some(key => {
        if (this.companyList[key].code == '' + value) {
          actions.push(this.companyList[key].name)
          return true
        }
      })
      return actions.join('')
    },
    solutionZoneCode(value) {
      var actions = []
      Object.keys(this.zoneList).some((key) => {
        if (this.zoneList[key].code == ('' + value)) {
          actions.push(this.zoneList[key].name)
          return true
        }
      })
      return actions.join('')
    },
    loadFrom() {
      ajaxGetDictItems('inventory_status').then((res) => {
        if (res.success) {
          this.invStatus = res.result
        }
      });
      getZoneList().then((res) => {
        if (res.success) {
          this.zoneList = res.result
          //延迟半秒执行,避免组件未加载完,数据已经加载完
          setTimeout(() => {
            //slice可以在数组的任何位置进行删除/添加操作
            this.zoneOptions.splice(0, 1);
            for (let i = 0; i < res.result.length; i++) {
              this.zoneOptions.push({value: res.result[i].code, text: res.result[i].name})
            }
          }, 500)
        }
      });
      getCompanyList().then(res => {
        if (res.success) {
          this.companyList = res.result
        }
      })
    },
    getStatusColor(status) {
      const colors = {
        'good ': 'green',
        'defective': 'red',
        'discussed': 'grey',
        'scrap': 'purple',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
    searchReceive() {
      const that = this
      that.querySource.receiptCode = that.model.code
      listReceiveByReceiptId(that.querySource).then(res => {
        that.dataSource = res.result
      })
    },
    createTask(record) {
      this.loading1 = true;
      let createTaskModel = Object.assign({}, record);
      createReceiptTask(createTaskModel).then((res) => {
        this.loading1 = false;
        if (res.success) {
          this.$message.success(res.message);
        } else {
          this.$message.error(res.message);
        }
      });
      this.searchReceive();
      this.loadingContainerDetailByCode();
    },
    quickReceive(record) {
      console.log('record',record)
      this.receiveLoading = true
      let httpurl = ''
      let method = ''
      httpurl += this.url.add
      method = 'post'
      record.taskQty = record.qty;
      httpAction(httpurl, [record], method)
        .then(res => {
          if (res.success) {
            this.$message.success(res.message)
            this.clearData();
            this.searchReceive();
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.receiveLoading = false
        })
    },
    inputContainerCodeReceive() {
      this.$refs.form.validate((err, values) => {
        if (!err) {
          return
        }
        this.receiveLoading = true
        let httpurl = ''
        let method = ''
        httpurl += this.url.add
        method = 'post'
        if (this.selectedRows[0] == null) {
          this.receiveLoading = false
          this.$message.warning('请选择入库单明细!')
          return
        }
        if (!this.model.containerCode) {
          this.receiveLoading = false;
          this.$message.warning('请输入容器编码!')
          return
        }
        this.selectedRows.forEach(data => {
          data.containerCode = this.model.containerCode;
          data.taskQty = data.qty;
        })
        httpAction(httpurl, this.selectedRows, method)
          .then(res => {
            if (res.success) {
              this.$message.success(res.message)
              this.clearData();
              this.searchReceive();
            } else {
              this.$message.warning(res.message)
            }
          })
          .finally(() => {
            this.receiveLoading = false
          })
      })
    },
    receive(record, index) {
      debugger;
      console.log("开始组盘");
      this.receiveLoading = true
      let httpurl = ''
      let method = ''
      httpurl += this.url.add
      method = 'post'
      if (this.selectedRows[0] == null) {
        this.receiveLoading = false
        this.$message.warning('请选择入库单明细!')
        return
      }
      this.selectedRows.forEach(data => {
        data.containerCode = record.containerCode;
        data.taskQty = data.qty;
      })
      httpAction(httpurl, this.selectedRows, method)
        .then(res => {
          if (res.success) {
            this.$message.success(res.message)
            this.clearData();
            this.searchReceive();
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.receiveLoading = false
        })
    },
    clickThenChange(record) {
      return {
        on: {
          click: () => {
            this.onSelectChange([record.id], [record])
          }
        }
      }
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys;
      this.selectedRows = selectedRows;
      this.loadingContainerDetailByCode();
      this.loadingInventoryDetailList();
      this.loadingInventoryTransactionSelectContainerlist();
      this.loadingListEmptyContainerInLocation();
    },
    onSelectChange1(selectedRowKeys, selectedRows) {
      this.selectedRowKeys1 = selectedRowKeys;
      this.selectedRows1 = selectedRows;
    },
    updatePagination(pagination, targetPagination) {
      if (pagination) {
        targetPagination.current = pagination.current;
        targetPagination.pageNo = pagination.current;
        targetPagination.pageSize = pagination.pageSize;
      }
    },
    loadingContainerDetailByCode(pagination) {
      this.loading1 = true;
      this.updatePagination(pagination, this.pagination1);
      let selectedRows = this.selectedRows;
      let receiptContainerDetail = {
        receiptCode: selectedRows[0].receiptCode,
      }
      let requestPayload = {
        ...this.pagination1,
        ...receiptContainerDetail
      }
      getAction(this.url.listReceiptContainerDetailByMainId, requestPayload).then(res => {
          if (res.success) {
            this.dataSource1 = res.result.records;
            this.pagination1.total = res.result.total;
          } else {
            this.$message.warning(res.message)
          }
          this.loading1 = false;
        }
      )
    },
    loadingInventoryDetailList(pagination) {
      this.loading2 = true;
      this.updatePagination(pagination, this.pagination2);
      let selectedRows = this.selectedRows;
      let inventoryDetail = {
        materialCode: selectedRows[0].materialCode,
      }
      let requestPayload = {
        ...this.pagination2,
        ...inventoryDetail
      }
      getAction(this.url.queryInventoryDetailList, requestPayload).then(res => {
          if (res.success) {
            this.dataSource2 = res.result.records;
            this.pagination2.total = res.result.total;
          } else {
            this.$message.warning(res.message)
          }
          this.loading2 = false;
        }
      )
    },
    loadingInventoryTransactionSelectContainerlist(pagination) {
      this.loading3 = true;
      this.updatePagination(pagination, this.pagination3);
      let selectedRows = this.selectedRows;
      let inventoryTransaction = {
        materialCode: selectedRows[0].materialCode,
      }
      let requestPayload = {
        ...this.pagination3,
        ...inventoryTransaction
      }
      getAction(this.url.inventoryTransactionSelectContainerlist, requestPayload).then(res => {
          if (res.success) {
            this.dataSource3 = res.result.records;
            this.pagination3.total = res.result.total;
          } else {
            this.$message.warning(res.message)
          }
          this.loading3 = false;
        }
      )
    },
    loadingListEmptyContainerInLocation(pagination) {
      this.loading4 = true;
      this.updatePagination(pagination, this.pagination4);
      let requestPayload = {
        ...this.pagination4
      }
      getAction(this.url.listEmptyContainerInLocation, requestPayload).then(res => {
          if (res.success) {
            this.dataSource4 = res.result.records;
            this.pagination4.total = res.result.total;
          } else {
            this.$message.warning(res.message)
          }
          this.loading4 = false;
        }
      )
    },
    handleOk() {
      this.close();
    },
    handleCancel() {
      this.close()
    },
    close() {
      this.$emit('close')
      this.visible = false
      // this.$refs.form.clearValidate()
      this.clearData();
      // 重置 model 为初始空对象
      this.model = {};
      // 可以根据需要继续添加其他数据属性的重置操作
    },
    clearData() {
      // 清空 dataSource 数组
      this.dataSource = [];
      // 清空 dataSource1 数组
      this.dataSource1 = [];
      // 清空 dataSource2 数组
      this.dataSource2 = [];
      // 清空 dataSource3 数组
      this.dataSource3 = [];
      // 清空 dataSource4 数组
      this.dataSource4 = [];
      // 重置 pagination1 为初始状态
      this.pagination1 = {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      };
      // 重置 pagination2 为初始状态
      this.pagination2 = {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      };
      // 重置 pagination3 为初始状态
      this.pagination3 = {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      };
      // 重置 pagination4 为初始状态
      this.pagination4 = {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      };
      // 清空 selectedRowKeys 数组
      this.selectedRowKeys = [];
      this.selectedRowKeys1 = [];
    }
  }
}
</script>