assignOrder.vue 32.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
<template>
  <d2-container>
    <el-card shadow="never"
             slot="header">
      <el-form :inline="true"
               :model="formInline"
               class="demo-form-inline"
               size="small">
        <el-form-item label="子订单号">
          <el-input v-model="formInline.merchantOrder"
                    placeholder="请输入子订单号"
                    clearable />
        </el-form-item>
        <el-form-item label="发货单号">
          <el-input v-model="formInline.dispatchOrderCode"
                    placeholder="请输入发货单号"
                    clearable />
        </el-form-item>
        <el-form-item label="下单客户">
          <el-input v-model="formInline.merchantName"
                    placeholder="请输入下单客户"
                    clearable />
        </el-form-item>
        <el-form-item label="物料编码">
          <el-input v-model="formInline.materialName"
                    placeholder="请输入物料编码"
                    clearable />
        </el-form-item><br>
        <el-form-item label="订单状态">
          <el-select v-model="formInline.status"
                     placeholder="请选择">
            <el-option value=""
                       label="全部">全部</el-option>
            <el-option value="8"
                       label="待分配">待分配</el-option>
            <el-option value="2"
                       label="待发货">待发货</el-option>
            <el-option value="3"
                       label="部分发货">部分发货</el-option>
            <!-- <el-option value="0" label="已驳回">已驳回</el-option> -->
            <el-option value="5"
                       label="完成发货">完成发货</el-option>
            <el-option value="7"
                       label="提前结束发货">提前结束发货</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="渠道类型">
          <el-select v-model="formInline.channelId"
                     placeholder="请选择">
            <el-option value
                       label="全部">全部</el-option>
            <el-option v-for="item in merchantIdList"
                       :key="item.id"
                       :value="item.id"
                       :label="item.name">{{item.name}}</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算主体">
          <el-select v-model="formInline.merchantSettleBody"
                     placeholder="请选择">
            <el-option value
                       label="全部">全部</el-option>
            <el-option v-for="item in settleBodyList"
                       :key="item.merchantSettleBody"
                       :value="item.merchantSettleBody"
                       :label="item.merchantSettleBodyName">{{item.merchantSettleBodyName}}
            </el-option>
          </el-select>
        </el-form-item><br>
        <el-form-item label="审核时间">
          <el-date-picker v-model="registerDate"
                          type="daterange"
                          range-separator="至"
                          start-placeholder="开始日期"
                          end-placeholder="结束日期"
                          value-format="yyyy-MM-dd" />
        </el-form-item>
        <el-form-item label="发货时间">
          <el-date-picker v-model="sendDate"
                          type="daterange"
                          range-separator="至"
                          start-placeholder="开始日期"
                          end-placeholder="结束日期"
                          value-format="yyyy-MM-dd" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
                     icon="el-icon-search"
                     :loading="tableLoading"
                     @click="getList()">搜索</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
                     icon="el-icon-download"
                     :loading="exportLoading"
                     @click="exportInfo()">导出</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
                     @click="batchAssignShipment()">批量分配发货</el-button>
        </el-form-item>
        <!-- <el-form-item>
          <el-button type="primary"  @click="batchDirectDelivery()">批量直接发货</el-button>
        </el-form-item> -->
      </el-form>
    </el-card>

    <!-- 表格区域 开始 -->
    <div class="table_box">
      <el-table v-loading="tableLoading"
                :data="tableData"
                @selection-change="selectChange"
                stripe
                style="width: 100%"
                size="small"
                border>
        <el-table-column type="selection"
                         width="50"
                         fixed="left"
                         align="center" />
        <el-table-column type="index"
                         :index="index => {return index+1}"
                         label="序号"
                         width="80" />
        <el-table-column prop="merchantOrder"
                         label="子订单号"
                         width="200" />
        <el-table-column prop="channelName"
                         label="商户渠道"
                         width="150" />
        <el-table-column prop="merchantLoginName"
                         label="下单客户"
                         width="200"
                         show-overflow-tooltip />
        <el-table-column prop="merchantSettleBodyName"
                         label="结算主体"
                         :width="tdWidth" />
        <el-table-column prop="materialCode"
                         label="审核物料编号"
                         :width="tdWidth" />
        <el-table-column prop="materialName"
                         label="审核物料名称"
                         width="250" />
        <el-table-column prop="deviceTypeName"
                         label="设备类型"
                         width="80" />
        <el-table-column prop="status"
                         label="订单状态"
                         width="80">
          <template slot-scope="scope">
            {{statusShow[scope.row.status]}}
          </template>
        </el-table-column>
        <el-table-column prop="totalCheck"
                         label="需发货数量"
                         width="90" />
        <el-table-column prop="totalSends"
                         label="已发数量"
                         width="70" />
        <el-table-column prop="totalOwes"
                         label="欠数"
                         width="70" />
        <el-table-column prop="checkBy"
                         label="审核人"
                         width="70" />
        <el-table-column prop="checkTime"
                         label="审核时间"
                         width="140">
          <template
                    slot-scope="scope">{{ scope.row.checkTime ? DATEFORMATE(scope.row.checkTime, 'YYYY/MM/DD HH:mm:ss') : '' }}</template>
        </el-table-column>
        <el-table-column prop="checkRemark"
                         label="审核备注"
                         width="200"
                         show-overflow-tooltip />
        <el-table-column prop="bsAddressDto.address"
                         label="收货地址"
                         width="200"
                         show-overflow-tooltip>
          <template slot-scope="scope"
                    v-if="scope.row.bsAddressDto">
            {{ (scope.row.bsAddressDto.provinceName ? scope.row.bsAddressDto.provinceName + '省' : '') + 
                          (scope.row.bsAddressDto.cityName ? scope.row.bsAddressDto.cityName + '市' : '') + 
                          (scope.row.bsAddressDto.areaName ? scope.row.bsAddressDto.areaName : '') +  
                          (scope.row.bsAddressDto.address ? scope.row.bsAddressDto.address : '') }}
          </template>
        </el-table-column>
        <el-table-column prop="bsAddressDto.name"
                         label="收货联系人"
                         :width="tdWidth" />
        <el-table-column prop="bsAddressDto.mobile"
                         label="收货联系电话"
                         :width="tdWidth" />
        <el-table-column prop="subjectName"
                         label="项目"
                         :width="tdWidth" />
        <el-table-column prop="logisticsDesc"
                         label="发货信息"
                         :width="tdWidth"
                         show-overflow-tooltip />
        <el-table-column label="操作"
                         fixed="right"
                         align="center"
                         width="150">
          <!-- <template slot-scope="scope">
              <el-button type="primary" size="mini" v-if="scope.row.status == '8'" @click="assignShipment(scope.row)">分配发货</el-button>
              <el-button type="primary" size="mini" v-if="scope.row.status == '8' && scope.row.deviceScanType == 'N'" @click="directDelivery(scope.row)">直接发货</el-button>
              <el-button type="primary" size="mini" v-if="scope.row.status == '3' && scope.row.deviceScanType == 'N'" @click="continueDelivery(scope.row)">继续发货</el-button>
              <el-button type="danger" size="mini" v-if="scope.row.status == '8'" @click="reject(scope.row)">驳回</el-button>
              <el-button type="danger" size="mini" v-if="scope.row.status == '2'" @click="withdraw(scope.row)">撤回</el-button>
              <el-button type="success" size="mini" v-if="scope.row.status == '3'" @click="advanceOver(scope.row)">提前结束</el-button>
              <el-button type="primary" size="mini" v-if="scope.row.urlDispatchBills" @click="downloadInvoice(scope.row)">下载发货单</el-button>
            </template> -->
          <template slot-scope="scope">
            <el-dropdown size="mini"
                         split-button
                         type="primary"
                         @command="e => handleCommand(e,scope.row)"
                         v-if="showButton(scope.row)">
              操作
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="assignShipment"
                                  v-if="scope.row.status == '8'">分配发货</el-dropdown-item>
                <el-dropdown-item command="directDelivery"
                                  v-if="scope.row.status == '8' && scope.row.deviceScanType == 'N'">
                  直接发货</el-dropdown-item>
                <el-dropdown-item command="continueDelivery"
                                  v-if="scope.row.status == '3' && scope.row.deviceScanType == 'N'">
                  继续发货</el-dropdown-item>
                <el-dropdown-item command="reject"
                                  v-if="scope.row.status == '8'">驳回</el-dropdown-item>
                <el-dropdown-item command="withdraw"
                                  v-if="scope.row.status == '2'">撤回</el-dropdown-item>
                <el-dropdown-item command="advanceOver"
                                  v-if="scope.row.status == '3'">提前结束</el-dropdown-item>
                <el-dropdown-item command="downloadInvoice"
                                  v-if="scope.row.urlDispatchBills">下载发货单</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination_list">
        <el-pagination background
                       layout="sizes, total,prev, pager, next, jumper"
                       :total="pageTotal"
                       :page-size="pageSize"
                       :page-sizes="pageSizes"
                       @current-change="getList"
                       @size-change="changePageSize" />
      </div>
    </div>
    <!-- 表格区域 end -->

    <!-- 分配发货弹框 开始 -->
    <assign-shipment :show="showAssignShipmentDialog"
                     v-if="showAssignShipmentDialog"
                     :info="info"
                     @closed="closeAssignShipmentDialog" />
    <!-- 分配发货弹框 结束 -->

    <!-- 批量分配发货弹框 开始 -->
    <assign-shipment-for-batch :show="showAssignShipmentForBatchDialog"
                               v-if="showAssignShipmentForBatchDialog"
                               :infoList="selectList"
                               @closed="closeAssignShipmentForBatchDialog" />
    <!-- 批量分配发货弹框 结束 -->

    <!-- 直接发货弹框 开始 -->
    <direct-delivery :show="showDirectDeliveryDialog"
                     v-if="showDirectDeliveryDialog"
                     :info="info"
                     @closed="closeDirectDeliveryDialog" />
    <!-- 直接发货弹框 结束 -->

    <!-- 继续发货弹框 开始 -->
    <continue-delivery :show="showContinueDeliveryDialog"
                       v-if="showContinueDeliveryDialog"
                       :info="info"
                       @closed="closeContinueDeliveryDialog" />
    <!-- 继续发货弹框 结束 -->

    <!-- 批量直接发货弹框 开始 -->
    <glsx-dialog :show="showImportDialog"
                 title="批量直接发货"
                 width="30%"
                 usefooter
                 @closed="closeImportDialog">
      <div class="upload_box">
        <span class="h3">注意:此功能只能不需要工厂/仓库出货,且无需明细的设备,请谨慎操作</span>
        <h2 class="h2">
          请点击"
          <a :href="GPSDEVICEDOWNLOADTEMPLATE"
             target="_blank">下载物料发货物流清单模板</a>", 并填写导入信息
        </h2>
        <h2 class="h2">请导入无需扫明细的物料发货物流清单</h2>
        <div class="upload_cell">
          <span class="name">选择文件:</span>
          <div class="content">
            <el-input type="text"
                      class="a_input"
                      :value="uploadFile.name"
                      readonly />
            <el-upload class="upload-demo"
                       ref="upload"
                       :action="DEVICEIMPORT"
                       multiple
                       :limit="1"
                       :data="uploadForm"
                       :on-exceed="handleExceed"
                       :file-list="fileList"
                       :show-file-list="false"
                       :on-change="uploadChange"
                       :on-success="uploadSuccess">
              <el-button size="small"
                         type="primary">选择文件</el-button>
            </el-upload>
          </div>
        </div>
        <div class="upload_cell cell_center"
             v-if="uploadError.totalCount || uploadError.totalCount==0">
          <span>检验成功{{uploadError.successCount}}条,失败{{uploadError.failCount}}条</span>
          <span>请下载</span>
          <a :href="uploadError.url"
             target="_blank">导出失败列表</a>
        </div>
      </div>
      <div slot="footer"
           class="btn_group">
        <el-button type="success"
                   @click="uploadInfoToServer">导入</el-button>
        <el-button @click="closeImportDialog">取消</el-button>
      </div>
    </glsx-dialog>
    <!-- 批量直接发货弹框 end -->

  </d2-container>
</template>

<script>
import config from '@/http/config.js' // 倒入默认配置
import { exportExcel } from '@/common/common'
import {
  GPSDEVICEDOWNLOADTEMPLATE,
  DEVICEIMPORT,
  ASSIGNORDERLIST,
  LISTMERCHANTCHANNEL,
  EXPORTSPORDER,
  REBACKSPORDER,
  RECALLSPORDER,
  FINISHSPORDER,
  LISTMERCHANTSETTLEBODY
} from '@/http/interface'
import GlsxDialog from '@/components/dialog/index'
import AssignShipment from './assignShipment'
import AssignShipmentForBatch from './assignShipmentForBatch'
import DirectDelivery from './directDelivery'
import ContinueDelivery from './continueDelivery'
export default {
  name: 'fimsTable7',
  components: {
    'glsx-dialog': GlsxDialog,
    'assign-shipment': AssignShipment,
    'assign-shipment-for-batch': AssignShipmentForBatch,
    'direct-delivery': DirectDelivery,
    'continue-delivery': ContinueDelivery,
  },
  data() {
    return {
      formInline: {},
      tableData: [],
      info: {},
      merchantIdList: [],
      tableLoading: false,
      pageTotal: 0,
      userInfo: {},
      currentPage: 1,
      pageSizes: [10, 20, 30, 40],
      pageSize: 10,
      exportLoading: false,
      registerDate: [],
      sendDate: [],
      tdWidth: 140,
      DATEFORMATE: (str, type) => {
        return this.$Util.dateFormate(str, type)
      },
      statusShow: {
        8: '待分配',
        2: '待发货',
        3: '部分发货',
        0: '已驳回',
        5: '完成发货',
        7: '提前结束发货',
      },
      showImportDialog: false,
      showAssignShipmentDialog: false,
      showAssignShipmentForBatchDialog: false,
      showDirectDeliveryDialog: false,
      showContinueDeliveryDialog: false,
      current: {},
      uploadFile: {},
      GPSDEVICEDOWNLOADTEMPLATE: GPSDEVICEDOWNLOADTEMPLATE,
      DEVICEIMPORT: DEVICEIMPORT,
      uploadError: {},
      selectList: [],
      settleBodyList: [],
    }
  },
  created() { },

  mounted: function () {
    this.getMerchantList()
    this.getSettleBody()
    this.getList()
  },
  methods: {
    /**
     * 获取渠道
     */
    getMerchantList: function () {
      const _this = this
      LISTMERCHANTCHANNEL().then((res) => {
        const { data } = res
        _this.merchantIdList = data || []
      })
    },

    /**获取结算主体 */
    getSettleBody: function () {
      let _this = this
      LISTMERCHANTSETTLEBODY().then((res) => {
        _this.settleBodyList = res.data || []
      })
    },

    /**
     * 查询列表
     */
    getList: function (current) {
      const _this = this
      const oParams = _this.getParams()
      oParams.pageNum = current || _this.currentPage
      _this.tableLoading = true
      ASSIGNORDERLIST(oParams).then((res) => {
        console.log(res)
        _this.tableLoading = false
        if (res.returnCode == 0) {
          const { data } = res
          console.log(data)
          const { total, list } = data
          _this.tableData = list || []
          _this.pageTotal = total
        }
      })
    },

    /**
     * 获取查询参数
     */
    getParams: function () {
      const n = this.formInline
      const m = this.registerDate
      const k = this.sendDate
      let oParams = {}
      if (m && m.length > 0) {
        n.checkTimeStart = m[0] + ' 00:00:01'
        n.checkTimeEnd = m[1] + ' 23:59:59'
      } else {
        delete this.formInline.checkTimeStart
        delete this.formInline.checkTimeEnd
      }

      if (k && k.length > 0) {
        n.sendTimeStart = k[0] + ' 00:00:01'
        n.sendTimeEnd = k[1] + ' 23:59:59'
      } else {
        delete this.formInline.sendTimeStart
        delete this.formInline.sendTimeEnd
      }

      oParams = n
      oParams.pageSize = this.pageSize
      // oParams.condition = n
      return oParams
    },

    /**
     * 每页展示
     */
    changePageSize: function (e) {
      this.pageSize = e
      this.getList()
    },

    /**
     * 导出列表
     */
    exportInfo: function () {
      const _this = this
      const oParams = _this.getParams()
      _this.exportLoading = true
      EXPORTSPORDER(oParams)
        .then((res) => {
          _this.exportLoading = false
        })
        .catch((error) => {
          _this.exportLoading = false
        })
    },

    /**
     * 驳回操作
     */
    reject: function (row) {
      let htmlContent =
        '<span class="warningFont">注意:驳回后,订单无法重新发货,请慎重操作,谢谢!</span><br /><br />' +
        '驳回原因<span class="warningFont">*</span>:'
      this.$prompt(htmlContent, '驳回', {
        dangerouslyUseHTMLString: true,
        inputType: 'textarea',
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        inputValidator: function (inputValue) {
          if (!inputValue) {
            return '请输入驳回原因'
          } else {
            if (inputValue.length > 200) {
              return '原因最多支持200个字'
            }
          }
        },
      })
        .then(({ value }) => {
          let oParams = {}
          oParams.merchantOrder = row.merchantOrder
          oParams.rebackReason = value
          REBACKSPORDER(oParams).then((res) => {
            if (res.returnCode == 0) {
              this.$message({
                type: 'success',
                message: '操作成功!',
              })
              this.getList()
            } else {
              this.$message({
                type: 'error',
                message: '操作失败!',
              })
              return
            }
          })
        })
        .catch(() => {
          // this.$message({
          //   type: 'info',
          //   message: '取消输入'
          // });
        })
    },

    /**
     * 撤回操作
     */
    withdraw: function (row) {
      let htmlContent =
        '<span class="warningFont">注意:撤回后,订单将重新变为待分配状态,工厂/仓库不再看到该出货订单,请慎重操作,谢谢!</span><br /><br />' +
        '撤回原因<span class="warningFont">*</span>:'
      this.$prompt(htmlContent, '撤回', {
        dangerouslyUseHTMLString: true,
        inputType: 'textarea',
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        inputValidator: function (inputValue) {
          if (!inputValue) {
            return '请输入撤回原因'
          } else {
            if (inputValue.length > 200) {
              return '原因最多支持200个字'
            }
          }
        },
      })
        .then(({ value }) => {
          let oParams = {}
          oParams.merchantOrder = row.merchantOrder
          oParams.recallReason = value
          RECALLSPORDER(oParams).then((res) => {
            if (res.returnCode == 0) {
              this.$message({
                type: 'success',
                message: '操作成功!',
              })
              this.getList()
            } else {
              this.$message({
                type: 'error',
                message: '操作失败!',
              })
              return
            }
          })
        })
        .catch(() => {
          // this.$message({
          //   type: 'info',
          //   message: '取消输入'
          // });
        })
    },

    /**
     * 提前结束操作
     */
    advanceOver: function (row) {
      let htmlContent =
        '<span class="warningFont">注意:提前结束后,订单将结束,不再支持发货,请慎重操作,谢谢!</span><br /><br />' +
        '提前结束原因<span class="warningFont">*</span>:'
      this.$prompt(htmlContent, '提前结束', {
        dangerouslyUseHTMLString: true,
        inputType: 'textarea',
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        inputValidator: function (inputValue) {
          if (!inputValue) {
            return '请输入提前结束原因'
          } else {
            if (inputValue.length > 200) {
              return '原因最多支持200个字'
            }
          }
        },
      })
        .then(({ value }) => {
          let oParams = {}
          oParams.merchantOrder = row.merchantOrder
          oParams.finishReason = value
          FINISHSPORDER(oParams).then((res) => {
            if (res.returnCode == 0) {
              this.$message({
                type: 'success',
                message: '操作成功!',
              })
              this.getList()
            } else {
              this.$message({
                type: 'error',
                message: '操作失败!',
              })
              return
            }
          })
        })
        .catch(() => {
          // this.$message({
          //   type: 'info',
          //   message: '取消输入'
          // });
        })
    },

    /**
     * 下载发货单
     */
    downloadInvoice: function (row) {
      console.log(row.urlDispatchBills)

      let fileUrl = row.urlDispatchBills
      if (this.isPicture(fileUrl)) {
        //当文件是图片格式时
        let image = new Image()
        // 解决跨域 Canvas 污染问题
        image.setAttribute('crossOrigin', 'anonymous')
        image.onload = function () {
          let canvas = document.createElement('canvas')
          canvas.width = image.width
          canvas.height = image.height
          let context = canvas.getContext('2d')
          context.drawImage(image, 0, 0, image.width, image.height)
          let url = canvas.toDataURL('image/png') //得到图片的base64编码数据
          let a = document.createElement('a') // 生成一个a元素
          let event = new MouseEvent('click') // 创建一个单击事件
          a.download = '发货单' // 设置图片名称
          a.href = url // 将生成的URL设置为a.href属性
          a.dispatchEvent(event) // 触发a的单击事件
        }
        image.src = row.urlDispatchBills
      } else if (
        fileUrl.indexOf('.PDF') != -1 ||
        fileUrl.indexOf('.pdf') != -1
      ) {
        window.open(fileUrl)
      } else {
        // const params = {'fileName':'发货单'}
        // params.url = row.urlDispatchBills
        // params.method = 'get'
        // params.data = {}
        // exportExcel(params)

        window.location.href = fileUrl

        // let a = document.createElement('a')
        // a.href = row.urlDispatchBills // 这里的请求方式为get,如果需要认证,接口上需要带上token
        // a.click()
      }
    },

    /**
     * 判断是否为图片
     */
    isPicture: function (str) {
      //判断是否是图片 - strFilter必须是小写列举
      var strFilter = '.jpeg|.gif|.jpg|.png|.bmp|.pic|.svg|'
      if (str.indexOf('.') > -1) {
        var p = str.lastIndexOf('.')
        var strPostfix = str.substring(p, str.length) + '|'
        strPostfix = strPostfix.toLowerCase()
        if (strFilter.indexOf(strPostfix) > -1) {
          return true
        }
      }
      return false
    },

    /**
     * 分配发货
     */
    assignShipment: function (row) {
      // row.materialCode = 'GLSX001062'
      // row.bsAddressDto = {name:'111',mobile:'111',address:'111'}
      this.info = row
      console.log(row)
      this.showAssignShipmentDialog = true
    },

    /**
     * 关闭分配发货弹窗
     */
    closeAssignShipmentDialog: function (sub) {
      this.showAssignShipmentDialog = false
      if (sub) {
        this.getList()
      }
    },

    /**
     * 直接发货
     */
    directDelivery: function (row) {
      this.info = row
      this.showDirectDeliveryDialog = true
    },

    /**
     * 关闭直接发货弹窗
     */
    closeDirectDeliveryDialog: function (sub) {
      this.showDirectDeliveryDialog = false
      if (sub) {
        this.getList()
      }
    },

    /**
     * 继续发货
     */
    continueDelivery: function (row) {
      this.info = row
      console.log(row)
      this.showContinueDeliveryDialog = true
    },

    /**
     * 关闭继续发货弹窗
     */
    closeContinueDeliveryDialog: function (sub) {
      this.showContinueDeliveryDialog = false
      if (sub) {
        this.getList()
      }
    },

    // selectCheckBox: function(selection, row){
    //   console.log(selection)
    //   console.log(row)
    // },

    // selectAllCheckBox: function(selection){
    //   console.log(selection)
    // },

    handleCommand: function (methodName, row) {
      this[methodName](row)
    },

    showButton: function (row) {
      let showButtonFlag = false
      if (
        row.urlDispatchBill ||
        row.status == '2' ||
        row.status == '3' ||
        row.status == '8' ||
        (row.status == '3' && row.deviceScanType == 'N') ||
        (row.status == '8' && row.deviceScanType == 'N')
      ) {
        showButtonFlag = true
      }
      return showButtonFlag
    },

    /**
     * 复选框操作
     */
    selectChange: function (selection) {
      console.log(selection)
      this.selectList = selection
    },

    /**
     * 批量分配发货
     */
    batchAssignShipment: function () {
      if (this.selectList.length > 1) {
        let materialCode = this.selectList[0].materialCode
        let flag = true
        for (var key in this.selectList) {
          if (this.selectList[key].materialCode != materialCode) {
            this.$message({
              message: '选择的订单存在不同物料产品,不支持批量发货!',
              type: 'error',
              duration: 2000,
              center: true,
            })
            flag = false
            break
          }
          if (this.selectList[key].status != '8') {
            this.$message({
              message: '选择的订单状态不对!',
              type: 'error',
              duration: 2000,
              center: true,
            })
            flag = false
            break
          }
        }
        if (flag) {
          this.showAssignShipmentForBatchDialog = true
        }
      } else {
        this.$message({
          message: '请选择多个订单进行操作!',
          type: 'error',
          duration: 2000,
          center: true,
        })
      }
    },

    /**
     * 关闭批量分配发货弹框
     */
    closeAssignShipmentForBatchDialog: function () {
      this.showAssignShipmentForBatchDialog = false
    },

    /**
     * 批量直接发货
     */
    batchDirectDelivery: function () {
      if (this.selectList.length > 1) {
        let materialCode = this.selectList[0].materialCode
        let flag = true
        for (var key in this.selectList) {
          if (this.selectList[key].materialCode != materialCode) {
            this.$message({
              message: '选择的订单存在不同物料产品,不支持批量发货!',
              type: 'error',
              duration: 2000,
              center: true,
            })
            flag = false
            break
          }
          if (this.selectList[key].status != '8') {
            this.$message({
              message: '选择的订单状态不对!',
              type: 'error',
              duration: 2000,
              center: true,
            })
            flag = false
            break
          }
        }
        if (flag) {
          this.showImportDialog = true
        }
      } else {
        this.$message({
          message: '请选择多个订单进行操作!',
          type: 'error',
          duration: 2000,
          center: true,
        })
      }
    },

    /**入库 */
    openDialog: function () {
      this.showImportDialog = true
    },

    /**监听文件改变 */
    uploadChange: function (file, fileList) {
      console.log(file)
      this.uploadFile = file
    },

    /**监听文件上传成功 */
    uploadSuccess: function (res, file, fileList) {
      console.log(res)
      //this.$refs.upload.submit();
      let o = res.data || []
      let m = o[0] || {}

      if (m.url) {
        this.$refs.upload.clearFiles()
        this.uploadError = m
        return false
      }
      this.fileInfo = m.msg
    },

    /**手动上传文件 */
    uploadInfoToServer: function () {
      // if(!this.uploadFile || !this.uploadFile.name){

      // }

      let o = this.fileInfo
      if (!o) {
        return false
      }
      let oParams = JSON.parse(o)
      DEVICEIMEISTOKEIMPORT(oParams).then((res) => {
        console.log(res)
      })
    },

    /**
     * 关闭弹框
     */
    closeImportDialog: function () {
      this.$refs.upload.clearFiles()
      this.uploadFile = {}
      this.showImportDialog = false
    },
  },
}
</script>

<style lang="scss">
.table_box {
  margin: 20px 0;
}

.upload_box {
  .h2 {
    font-size: 14px;
    font-weight: normal;
    a {
      color: #337ab7;
    }
  }
  .h3 {
    font-size: 14px;
    color: #f00;
    font-weight: normal;
  }
}
.upload_cell {
  display: flex;
  align-items: center;
  margin: 10px 0;
  .name {
    width: 130px;
    font-weight: bold;
  }
  .content {
    flex: 1;
    display: flex;
    .a_input {
      margin: 0 8px 0 0;
      width: 217px;
    }
  }
}

// .warningInputTitle{
//     font-size:30;
//     color:#f00;
// }
.warningFont {
  font-size: 14px;
  color: #f00;
  font-weight: normal;
}
</style>