index.vue 36.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
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="首选项代码" prop="code">
        <el-input
          v-model="queryParams.code"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="首选项名字" prop="name">
        <el-input
          v-model="queryParams.name"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="getList">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row style="margin-top: 6px" :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['config:receiptPreference:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['config:receiptPreference:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['config:receiptPreference:remove']"
        >删除
        </el-button>
      </el-col>

      <right-toolbar :show-search.sync="showSearch" @queryTable="getList" :col-data="colData" @selectData="selectData"/>

    </el-row>


    <!--添加入库首选-->
    <el-dialog :title="title" :visible.sync="open" width="1000px">
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="仓库:" prop="warehouseCode">
              <el-select v-model="form.warehouseCode" placeholder="请选择仓库" :style="{width: '100%'}" size="small"
                         :disabled="form.id == undefined?false:true">
                <el-option
                  v-for="item in warehouseOptions"
                  :key="item.id"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="首选项代码:" prop="code">
              <el-input v-model="form.code" placeholder="请输入首选项代码" size="small"
                        :disabled="form.id == undefined?false:true"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="首选项名字:" prop="name">
              <el-input v-model="form.name" placeholder="请输入首选项名字" size="small"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="入库流程:" prop="receivingFlow">
              <el-select v-model="form.receivingFlow" placeholder="请选择入库流程" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="item in receivingFlowOptions"
                  :key="item.id"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="自动生成托盘号:" prop="autoAssignLPN">
              <el-select v-model="form.autoAssignLPN" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="允许超收:" prop="allowOverReceiving">
              <el-select v-model="form.allowOverReceiving" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="允许超收范围:" prop="allowOverReceivingQty">
              <el-input v-model="form.allowOverReceivingQty" placeholder="请输入0-100的数字" size="small"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="自动定位:" prop="autoLocate">
              <el-select v-model="form.autoLocate" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="RF显示未收数量:" prop="showOpenQty">
              <el-select v-model="form.showOpenQty" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="RF组车收货:" prop="groupPutaway">
              <el-select v-model="form.groupPutaway" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="人工组盘:" prop="manuallyBuildLPN">
              <el-select v-model="form.manuallyBuildLPN" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="定位规则:" prop="locationRule">
              <el-select v-model="form.locationRule" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="item in locationRuleOptions"
                  :key="item.id"
                  :label="item.description"
                  :value="item.code"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="上架规则:" prop="listingRules">
              <el-select v-model="form.listingRules" placeholder="请选择上架规则" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="item in listingRulesOptions"
                  :key="item.id"
                  :label="item.description"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="空库位规则:" prop="emptyLocRule">
              <el-select v-model="form.emptyLocRule" placeholder="请选择空库位规则" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="item in emptyLocRuleOptions"
                  :key="item.id"
                  :label="item.description"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="RF逐件收货:" prop="checkinByPiece">
              <el-select v-model="form.checkinByPiece" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="RF自动提交收货:" prop="pieceConfirm">
              <el-select v-model="form.pieceConfirm" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="abc分类:" prop="abcClass">
              <el-select v-model="form.abcClass" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="保质期(天):" prop="daysToExpire">
              <el-input v-model="form.daysToExpire" placeholder="请输入数字" size="small"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="临期预警:" prop="expiringDays">
              <el-select v-model="form.expiringDays" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in expiringOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收货预警(天):" prop="minShelfLifeDays">
              <el-input v-model="form.minShelfLifeDays" placeholder="请输入数字" size="small"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="RF快速上架:" prop="allowQuickPutaway">
              <el-select v-model="form.allowQuickPutaway" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="属性模板:" prop="attributeTemplateCode">
              <el-input v-model="form.attributeTemplateCode" placeholder="请输入属性模板" size="small"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="快速入库:" prop="useQuickCheckIn">
              <el-select v-model="form.useQuickCheckIn" placeholder="请选择" :style="{width: '100%'}" size="small">
                <el-option
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="生成任务时自动分配库位" label-width="172px" prop="allotWhenCreate">
              <el-switch v-model="form.allotWhenCreate"
                         :active-value="true"
                         :inactive-value="false"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否有效" prop="enable">
              <el-switch v-model="form.enable"
                         :active-value="true"
                         :inactive-value="false"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-table v-loading="loading" :data="typetable" @selection-change="handleSelectionChange" ref="table">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="id" align="center" prop="id" v-if="colData[0].istrue"/>
      <el-table-column label="仓库" align="center" prop="warehouseCode" v-if="colData[1].istrue">
        <template slot-scope="scope">
          {{warehouseCodeFormat(scope.row, scope.column)}}
        </template>
      </el-table-column>
      <el-table-column label="首选项代码" align="center" prop="code" width="100" v-if="colData[2].istrue"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="首选项名字" align="center" prop="name" width="100" v-if="colData[3].istrue"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="入库流程" align="center" prop="receivingFlow" v-if="colData[4].istrue">
        <template slot-scope="scope">
          {{ receivingFlowFormat(scope.row, scope.column) }}
        </template>
      </el-table-column>
      <el-table-column label="自动生成托盘号" align="center" prop="autoAssignLPN" width="120" v-if="colData[5].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.autoAssignLPN | sysFilter" round>{{
            typeFormat(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="允许超收" align="center" prop="allowOverReceiving" v-if="colData[6].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.allowOverReceiving | sysFilter" round>{{
            typeFormat2(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="允许超收范围" align="center" prop="allowOverReceivingQty" width="100" v-if="colData[7].istrue"/>
      <el-table-column label="自动定位" align="center" prop="autoLocate" v-if="colData[8].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.autoLocate | sysFilter" round>{{
            typeFormat3(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="RF显示未收数量" align="center" prop="showOpenQty" width="120" v-if="colData[9].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.showOpenQty | sysFilter" round>{{
            typeFormat4(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="RF组车收货" align="center" prop="groupPutaway" width="90" v-if="colData[10].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.groupPutaway | sysFilter" round>{{
            typeFormat11(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="人工组盘" align="center" prop="manuallyBuildLPN" v-if="colData[11].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.manuallyBuildLPN | sysFilter" round>{{
            typeFormat12(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="定位规则" align="center" prop="locationRule" v-if="colData[12].istrue"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="上架规则" align="center" prop="listingRules" v-if="colData[13].istrue"/>
      <el-table-column label="空库位规则" align="center" prop="emptyLocRule" width="90" v-if="colData[14].istrue"/>
      <el-table-column label="RF逐件收货" align="center" prop="checkinByPiece" width="90" v-if="colData[15].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.checkinByPiece | sysFilter" round>{{
            typeFormat5(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="RF自动提交收货" align="center" prop="pieceConfirm" width="120" v-if="colData[16].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.pieceConfirm | sysFilter" round>{{
            typeFormat6(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="abc分类" align="center" prop="abcClass" v-if="colData[17].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.abcClass | sysFilter" round>{{
            typeFormat7(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="保质期" align="center" prop="daysToExpire" v-if="colData[18].istrue"/>
      <el-table-column label="临期预警" align="center" prop="expiringDays" v-if="colData[19].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.expiringDays | sysFilter" round>{{
            typeFormat8(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="收货预警(天)" align="center" prop="minShelfLifeDays" width="100" v-if="colData[20].istrue"/>
      <el-table-column label="RF快速上架" align="center" prop="allowQuickPutaway" width="90" v-if="colData[21].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.allowQuickPutaway | sysFilter" round>{{
            typeFormat9(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="属性模板" align="center" prop="attributeTemplateCode" v-if="colData[22].istrue"/>
      <el-table-column label="快速入库" align="center" prop="useQuickCheckIn" v-if="colData[23].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.useQuickCheckIn | sysFilter" round>{{
            typeFormat10(scope.row, scope.column)
            }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="生成任务时自动分配库位"
                       align="center"
                       width="170"
                       :show-overflow-tooltip="true"
                       prop="allotWhenCreate"
                       v-if="colData[18].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.allotWhenCreate | sysFilter" round>
            {{typeFormat14(scope.row.allotWhenCreate,'allotWhenCreate')}}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="是否启用" align="center" prop="enable" v-if="colData[24].istrue">
        <template slot-scope="scope">
          <el-button size="mini" :type="scope.row.enable | sysFilter" round>
            {{typeFormat13(scope.row.enable,'enable')}}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="created" width="160" v-if="colData[25].istrue">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.created) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建用户" align="center" prop="createdBy" :show-overflow-tooltip="true"
                       v-if="colData[26].istrue"/>
      <el-table-column label="更新时间" align="center" prop="lastUpdated" width="160" v-if="colData[27].istrue">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdated) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新用户" align="center" prop="lastUpdatedBy" :show-overflow-tooltip="true"
                       v-if="colData[28].istrue"/>
      <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" min-width="120"
                       v-if="colData[29].istrue">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['config:receiptPreference:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['config:receiptPreference:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"/>
  </div>
</template>

<script>
  import {listRpre, getRpre, delRpre, addRpre, updateRpre} from "@/api/config/receipt/receiptPreference";
  import {getWarehouseByUserCode} from "@/api/system/warehouse";
  import {listDetail} from "@/api/config/receipt/filterConfigHeader/detail"
  import {listHeader} from "@/api/config/receipt/statusFlowHeader/header"

  export default {
    name: "ReceiptPreference",
    // filters: {
    //   statusFilter(status) {
    //     const statusMap = {
    //       true: "success",
    //       false: "danger",
    //     };
    //     return statusMap[status];
    //   },
    // },
    data() {
      return {
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 参数表格数据
        typetable: [],
        // 隐藏表格右上方搜索刷新按钮
        showSearch: true,
        // 是否显示弹出层
        open: false,
        // 对话框标题
        title: '',
        loading: true,
        total: 0,
        // 状态数据字典
        statusOptions: [],
        expiringOptions: [],
        // 仓库数据字典
        warehouseOptions: [],
        // 定位规则下拉数据
        locationRuleOptions: [],
        // 空货位规则下拉数据
        emptyLocRuleOptions: [],
        // 上架规则下拉数据
        listingRulesOptions: [],
        // 入库流程数据
        receivingFlowOptions: [],
        // 日期范围
        dateRange: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          code: undefined,
          name: undefined
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          code: [
            {required: true, message: "首选项代码不能为空", trigger: "blur"}
          ],
          name: [
            {required: true, message: "首选项名字不能为空", trigger: "blur"}
          ],
          allowOverReceivingQty: [
            {required: true, message: "允许超收范围不能为空", trigger: "blur"},
            {pattern: /^(?:0|[1-9][0-9]?|100)$/, message: "请输入0-100的正整数", trigger: ["blur", "change"],},
          ],
          groupPutaway: [
            {required: true, message: "组车收货不能为空", trigger: "blur"}
          ],
          manuallyBuildLPN: [
            {required: true, message: "人工组盘不能为空", trigger: "blur"}
          ],
          daysToExpire: [
            {pattern: /^(0|[1-9][0-9]*)$/, message: "请输入正确的正整数", trigger: "blur"}
          ],
          minShelfLifeDays: [
            {pattern: /^(0|[1-9][0-9]*)$/, message: "请输入正确的正整数", trigger: "blur"}
          ]
        },
        colData: [
          {title: "id", istrue: false},
          {title: "仓库", istrue: true},
          {title: "首选项代码", istrue: true},
          {title: "首选项名字", istrue: true},
          {title: "入库流程", istrue: true},
          {title: "自动生成托盘号", istrue: true},
          {title: "允许超收", istrue: true},
          {title: "允许超收范围", istrue: true},
          {title: "自动定位", istrue: true},
          {title: "RF显示未收数量", istrue: true},
          {title: "RF组车收货", istrue: true},
          {title: "人工组盘", istrue: true},
          {title: "定位规则", istrue: true},
          {title: "上架规则", istrue: true},
          {title: "空库位规则", istrue: true},
          {title: "RF逐件收货", istrue: true},
          {title: "RF自动提交收货", istrue: true},
          {title: "abc分类", istrue: true},
          {title: "保质期", istrue: true},
          {title: "临期预警", istrue: true},
          {title: "收货预警(天)", istrue: true},
          {title: "RF快速上架", istrue: true},
          {title: "属性模板", istrue: true},
          {title: "快速入库", istrue: true},
          {title: "是否启用", istrue: true},
          {title: "创建时间", istrue: true},
          {title: "创建用户", istrue: true},
          {title: "更新时间", istrue: false},
          {title: "更新用户", istrue: true},
          {title: "操作", istrue: true, disabled: true},
        ],

      };
    },
    created() {
      this.getList();
      //仓库select下拉接口获取
      getWarehouseByUserCode(this.$store.getters.name).then((response) => {
        this.warehouseOptions = response.data
      });


      //定位规则下拉接口获取
      listDetail({moduleType: "receipt"}).then((response) => {
        response.rows.forEach(item => {
          if (item.recordType == "locationRule") {
            this.locationRuleOptions.push(item)
          }
          if (item.recordType == "emptyLocRule") {
            this.emptyLocRuleOptions.push(item)
          }
          if (item.recordType == "listingRule") {
            this.listingRulesOptions.push(item)
          }
        })
      });

      //流程select下拉接口获取
      listHeader().then((response) => {
        response.rows.forEach(item => {
          if (item.moduleType == "receipt") {
            this.receivingFlowOptions.push(item)
          }
        })
      });

      this.getDicts("false_and_true").then(response => {
        this.statusOptions = response.data;
      });

      this.getDicts("isMix").then(response => {
        this.expiringOptions = response.data;
      });

    },

    beforeUpdate() {
      this.$nextTick(() => {
        this.$refs["table"].doLayout();
      });
    },

    methods: {
      /** 查询参数列表 */
      getList() {
        this.loading = true;
        listRpre(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
            this.typetable = response.rows;
            this.total = response.total;
            this.loading = false;
          }
        );
      },
      // 字典翻译
      typeFormat(row, column) {
        return this.selectDictLabel(this.statusOptions, row.autoAssignLPN);
      },
      typeFormat2(row, column) {
        return this.selectDictLabel(this.statusOptions, row.allowOverReceiving);
      },
      typeFormat3(row, column) {
        return this.selectDictLabel(this.statusOptions, row.autoLocate);
      },
      typeFormat4(row, column) {
        return this.selectDictLabel(this.statusOptions, row.showOpenQty);
      },
      typeFormat5(row, column) {
        return this.selectDictLabel(this.statusOptions, row.checkinByPiece);
      },
      typeFormat6(row, column) {
        return this.selectDictLabel(this.statusOptions, row.pieceConfirm);
      },
      typeFormat7(row, column) {
        return this.selectDictLabel(this.statusOptions, row.abcClass);
      },
      typeFormat8(row, column) {
        return this.selectDictLabel(this.expiringOptions, row.expiringDays);
      },
      typeFormat9(row, column) {
        return this.selectDictLabel(this.statusOptions, row.allowQuickPutaway);
      },
      typeFormat10(row, column) {
        return this.selectDictLabel(this.statusOptions, row.useQuickCheckIn);
      },
      typeFormat11(row, column) {
        return this.selectDictLabel(this.statusOptions, row.groupPutaway);
      },
      typeFormat12(row, column) {
        return this.selectDictLabel(this.statusOptions, row.manuallyBuildLPN);
      },
      typeFormat13(enable, type) {
        return this.selectDictLabel(this.statusOptions,enable)
      },
      typeFormat14(allotWhenCreate, type) {
        return this.selectDictLabel(this.statusOptions,allotWhenCreate)
      },
      // 仓库字典翻译
      warehouseCodeFormat(row, column) {
        return this.selectCommonLabel(this.warehouseOptions, row.warehouseCode);
      },
      // 入库流程字典翻译
      receivingFlowFormat(row, column) {
        return this.selectCommonLabel(this.receivingFlowOptions, row.receivingFlow);
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          warehouseCode: undefined,
          code: undefined,
          name: undefined,
          receivingFlow: undefined,
          autoAssignLPN: 'true',
          allowOverReceiving: 'true',
          allowOverReceivingQty: undefined,
          autoLocate: 'true',
          showOpenQty: 'true',
          groupPutaway: 'true',
          manuallyBuildLPN: 'true',
          locationRule: undefined,
          listingRules: undefined,
          emptyLocRule: undefined,
          checkinByPiece: 'false',
          pieceConfirm: 'false',
          abcClass: 'false',
          enable: 'false',
          daysToExpire: undefined,
          expiringDays: '0',
          minShelfLifeDays: undefined,
          allowQuickPutaway: 'true',
          attributetemplatecode: undefined,
          useQuickCheckIn: 'true',
          allotWhenCreate:'true'
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.dateRange = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加入库首选";
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.code = selection.map((item) => item.code);
        this.single = selection.length != 1
        this.multiple = !selection.length
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const code = row.id || this.ids;
        getRpre(code).then(response => {
          response.data.autoAssignLPN = response.data.autoAssignLPN.toString();
          response.data.allowOverReceiving = response.data.allowOverReceiving.toString();
          response.data.autoLocate = response.data.autoLocate.toString();
          response.data.showOpenQty = response.data.showOpenQty.toString();
          response.data.groupPutaway = response.data.groupPutaway.toString();
          response.data.manuallyBuildLPN = response.data.manuallyBuildLPN.toString();
          response.data.checkinByPiece = response.data.checkinByPiece.toString();
          response.data.pieceConfirm = response.data.pieceConfirm.toString();
          response.data.abcClass = response.data.abcClass.toString();
          response.data.expiringDays = response.data.expiringDays.toString();
          response.data.allowQuickPutaway = response.data.allowQuickPutaway.toString();
          response.data.useQuickCheckIn = response.data.useQuickCheckIn.toString();

          delete response.data.created;
          delete response.data.lastUpdated;
          this.form = response.data;

          response.data.autoAssignLPN = response.data.autoAssignLPN.toString();
          response.data.allowOverReceiving = response.data.allowOverReceiving.toString();
          response.data.autoLocate = response.data.autoLocate.toString();
          response.data.showOpenQty = response.data.showOpenQty.toString();
          response.data.groupPutaway = response.data.groupPutaway.toString();
          response.data.manuallyBuildLPN = response.data.manuallyBuildLPN.toString();
          response.data.checkinByPiece = response.data.checkinByPiece.toString();
          response.data.pieceConfirm = response.data.pieceConfirm.toString();
          response.data.abcClass = response.data.abcClass.toString();
          response.data.expiringDays = response.data.expiringDays.toString();
          response.data.allowQuickPutaway = response.data.allowQuickPutaway.toString();
          response.data.useQuickCheckIn = response.data.useQuickCheckIn.toString();

          this.open = true;
          this.title = "修改入库首选";
        });
      },
      /** 提交按钮 */
      submitForm: function () {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != undefined) {
              updateRpre(this.form).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.getList();
                } else {
                  this.msgError(response.msg);
                }
              });
            } else {
              addRpre(this.form, this.dateRange).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.getList();
                } else {
                  this.msgError(response.msg);
                }
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const codes = row.id || this.ids.toString();
        this.$confirm(
          row.id ? '是否确认删除该条入库首选项信息吗?' : '是否确认删除选中的' + this.ids.length + '条数据项?',
          "警告",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(function () {
          return delRpre(codes);
        }).then(() => {
          this.getList()
          this.msgSuccess("删除成功");
        }).catch(function () {
        });
      },
      /** 表格切换字段显示操作 */
      selectData(val) {
        if (val) {
          this.colData.filter((i) => {
            if (val.indexOf(i.title) !== -1) {
              i.istrue = true;
            } else {
              i.istrue = false;
            }
          });
        }
      },

    }
  };
</script>


<style lang="scss" scoped>
  .el-form-item {
    margin-bottom: 16px;
  }

  .el-button--mini.is-round {
    padding: 5px 10px;
  }
</style>