index.vue 33.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
<template>
  <div class="points">
    <div class="container">
      <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="table-header">
        <!-- <h2>积分提现列表</h2> -->
        <div class="statistics">
          累计结算金额:熠轩
          <span class="price">{{ settleAmount.yiXuanSettleAmount }}</span>
          元,
          薪遇见
          <span class="price">{{ settleAmount.xyjSettleAmount }}</span>
          元,
          云获
          <span class="price">{{ settleAmount.yunHuoSettleAmount }}</span>
          元
        </div>
        <div>
          <div class="select-wrap flex">
            <el-select v-model="operaForm.batch" placeholder="批量操作" class="selectBtn">
              <el-option v-for="(item, index) in batchOptions" :key="index" :label="item" :value="index" @click.native="handleSelectBtn(index, 'batch')"></el-option>
            </el-select>
            <el-select v-model="operaForm.key" placeholder="一键操作" class="selectBtn">
              <el-option v-for="(item, index) in keyOptions" :key="index" :label="item" :value="index" @click.native="handleSelectBtn(index, 'key')"></el-option>
            </el-select>
            <!-- <el-button size="small" @click="handleCheck()" type="primary" plain>批量审核</el-button>
            <el-button size="small" @click="handlePay()">批量付款</el-button> -->
            <el-button size="small" @click="handleImport">提现导入</el-button>
            <el-button size="small" @click="exportExcel">导出</el-button>
          </div>
        </div>
      </div>

      <!-- 表格区域 开始 -->
      <GLTable ref="withdrawRef" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun" @selectionTable="selectionTable">
        <div class="flex_sc" slot="colorStatus" slot-scope="scope">
          <div class="table_point" :style="{ background: colors[scope.scope.status] }"></div>
          <span>{{ tableStatus[scope.scope.status] }}</span>
        </div>
        <div class="table-btns" slot="auth-button" slot-scope="scope">
          <GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton>
        </div>
      </GLTable>
      <!-- 表格区域 end -->
    </div>
    <!-- 审核驳回 -->
    <GLDialog class="gl-form-page gl-form-min" :title="isRefuse != 2 ? '审核' : '驳回'" mode="mid" :visible.sync="showPassDialog" :close-on-click-modal="false" :before-close="clearSelect">
      <el-form ref="form" :model="form" label-width="154px">
        <el-form-item :label="isRefuse != 2 ? '备注:' : '驳回原因:'">
          <el-input type="textarea" v-model="form.remark" :rows="3" maxlength="50"></el-input>
        </el-form-item>
        <span class="describe" v-if="isRefuse != 2">审核通过后,转账业务单据自动流转至财务确认。</span>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button plain size="small" class="btn-three" @click="clearSelect">取消</el-button>
        <el-button type="primary" size="small" :loading="checkLoading" @click="comfirmCheck">确定</el-button>
      </span>
    </GLDialog>
    <!-- 付款 -->
    <GLDialog class="gl-form-page gl-form-min" title="付款" mode="mid" :visible.sync="isPay" :close-on-click-modal="false" :before-close="cancelPay">
      <glsx-combi-form formRef="payChildRef" defaultWidth="284px" ref="payFormRef" :formObj="payForm" :formData="payFormData" :formRules="payRule">
        <tempalte slot="balance" v-if="this.payForm.balance ">
          <div class="channelMoney">
            可用余额:
            <span class="price">{{ this.payForm.balance }}</span>
            元
          </div>
        </tempalte>
        <template slot="captcha">
          <div class="captcha-wrap">
            <el-input v-model="payForm.captcha" placeholder="请输入"></el-input>
            <div class="captcha-text" @click.prevent="getCode">
              {{ !isCodeDisabled ? '获取验证码' : count + 's' }}
            </div>
          </div>
        </template>
      </glsx-combi-form>
      <span slot="footer" class="dialog-footer">
        <el-button plain size="small" class="btn-three" @click="cancelPay">取消</el-button>
        <el-button type="primary" size="small" :loading="loading" @click="comfirmPay">确定</el-button>
      </span>
    </GLDialog>
    <!-- 提现导入 -->
    <GLDialog class="gl-form-page gl-form-min" title="提现导入" mode="mid" :visible.sync="isImport" :close-on-click-modal="false" :before-close="cancelImport">
      <template v-if="importForm.isLoading == 0">
        <el-form ref="form" :model="importForm" label-width="154px" :rules="importRule">
          <el-form-item label="上传文件:" prop="fileName">
            <el-input v-model="importForm.fileName" placeholder="请选择文件" disabled></el-input>
            <div class="import-btn">
              <i class="el-icon-plus"></i>
              选择文件
              <input id="fileUpload" type="file" style="opacity: 0" ref="file" class="import-input" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel" @change="e => uploadFile(e)" />
            </div>
            <a class="download-url" href="https://img01.glsx.com.cn/weapp/resource/saas/scrm/xlsx/提现导入模版.xlsx">下载模版</a>
          </el-form-item>
        </el-form>
      </template>

      <div class="middle" v-if="importForm.isLoading == 1">
        <i class="el-icon el-icon-loading"></i>
        <div class="resulttip">正在处理中</div>
        <div class="state">说明:系统正在加急导入中,请耐心等待;导入过程中,请不要退出当前操作,否则将导致本次提现导入无效。</div>
      </div>
      <div class="middle" v-if="importForm.isSuccess == 1">
        <i class="el-icon el-icon-success"></i>
        <div class="resulttip">处理成功</div>
        <div class="state">已自动为您导入{{ importForm.successCount }}条提现记录,可返回列表查看。</div>
      </div>
      <div class="middle" v-if="importForm.isSuccess == 2">
        <i class="el-icon el-icon-error"></i>
        <div class="resulttip">处理失败</div>
        <div class="state">
          可点击
          <a class="err-url" :href="importForm.errorUrl">下载失败模版</a>
          查看失败原因。
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button plain size="small" class="btn-three" @click="cancelImport" v-show="importForm.isSuccess == 0">取消</el-button>
        <el-button type="primary" size="small" :loading="checkLoading" @click="comfirmImport" v-show="importForm.isLoading != 1">确定</el-button>
      </span>
    </GLDialog>
    <!-- 详情 -->
    <detail-dialog :detail-visible="detailVisible" :id="id" @dialogClose="dialogClose"></detail-dialog>
  </div>
</template>

<script>
import * as XLSX from 'xlsx'
import DetailDialog from './detail.vue'
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import util from '@/utils/index'
const tableStatus = ['待审核', '已审核', '第三方处理', '成功', '失败', '驳回', '受理失败']
const colors = ['#FDB757', '#2CCA74', '#5850FF', '#2CCA74', '#999999', '#EB4E4E', '#2CCA74']
const tabelHeaderModel = ['商户名称', '商户号', '客户名称', '客户手机号', '提现金额', '收款人姓名', '收款人身份证', '收款银行卡号', '收款银行', '收款人手机号']
export default {
  components: {
    DetailDialog
  },
  data() {
    return {
      id: '',
      checkLoading: false,
      loading: false,
      colors,
      tableStatus,
      size: 'small',
      url: url,
      settleAmount: {},
      searchForm: {
        outSettleOrderId: '',
        customerName: '',
        customerPhone: '',
        status: '',
        channel: '',
        merchantName: '',
        transferType: ''
      },
      hasFooter: false,
      tableSearchForm: {},
      showFormData: [
        {
          label: '提现单号',
          name: 'outSettleOrderId',
          type: 'input',
          isClear: true,
          maxlength: 20
        },
        {
          label: '客户名称',
          name: 'customerName',
          type: 'input',
          isClear: true,
          maxlength: 20
        },
        {
          label: '手机号',
          name: 'customerPhone',
          type: 'input',
          isClear: true,
          maxlength: 11
        },
        {
          label: '状态',
          name: 'status',
          type: 'select',
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confLabel',
          optionsName: 'auditStatusStatusList'
        },
        {
          label: '申请时间',
          name: 'applyDateStr',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'beforeRangePickerOptions'
        },
        {
          label: '付款时间',
          name: 'payTimeStr',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'beforeRangePickerOptions'
        },
        {
          label: '付款渠道',
          name: 'channel',
          type: 'select',
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confLabel',
          optionsName: 'channelList'
        },
        {
          label: '所属门店',
          name: 'merchantName',
          type: 'select',
          optionList: [],
          optionId: 'merchantName',
          optionLabel: 'merchantName',
          optionsName: 'merchantList'
        },
        {
          label: '到账时间',
          name: 'receiptDateStr',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'beforeRangePickerOptions'
        },
        {
          label: '提现类型',
          name: 'transferType',
          type: 'select',
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confLabel',
          optionsName: 'withdrawalTypeList'
        }
      ],
      tableButtonList: [
        {
          type: 'el-button',
          name: '查看',
          attrs: {
            type: 'text',
            fn: '查看'
          },
          listeners: {
            click: this.handleDetail
          }
        },
        {
          type: 'el-button',
          name: '审核',
          attrs: {
            type: 'text',
            fn: '审核'
          },
          condition: row => {
            return row.status == 0
          },
          listeners: {
            click: row => {
              this.handleCheck(row)
            }
          }
        },
        {
          type: 'el-button',
          name: '驳回',
          attrs: {
            type: 'text',
            fn: '驳回'
          },
          condition: row => {
            return row.status == 0 || row.status == 1 || row.status == 6
          },
          listeners: {
            click: row => {
              this.handleCheck(row, 2)
            }
          }
        },
        {
          type: 'el-button',
          name: '付款',
          attrs: {
            type: 'text',
            fn: '付款'
          },
          condition: row => {
            return row.status == 1 || row.status == 6
          },
          listeners: {
            click: row => {
              this.handlePay(row)
            }
          }
        }
      ],
      // 表格
      getListApi: this.$apis.withdraw.getList,
      tableParams: {
        listName: 'list',
        tableOption: {
          width: 150
        },
        mutiSelectName: 'goodsIndex',
        mutiSelectUniqueKey: 'id',

        tableColumns: [
          {
            label: '提现单号',
            prop: 'outSettleOrderId',
            line: 1,
            minWidth: 200
          },
          {
            label: '客户名称',
            prop: 'customerName',
            width: 150
          },
          {
            label: '客户手机号',
            prop: 'customerPhone',
            width: '140px'
          },
          {
            label: '所属门店',
            prop: 'merchantName',
            line: 1,
            width: 150
          },
          {
            label: '提现积分',
            prop: 'integralAmount',
            width: 100
          },
          {
            label: '提现金额',
            prop: 'payAmount',
            width: 100,
            formatter: cellValue => {
              return cellValue.payAmount ? (cellValue.payAmount / 100).toFixed(2) : '--'
            }
          },
          {
            label: '收款人姓名',
            prop: 'name',
            width: '110px'
          },
          {
            label: '收款人身份证',
            prop: 'idCardNo',
            width: '180px'
          },
          {
            label: '收款银行卡号',
            prop: 'recvBankCardNo',
            width: 230
          },
          {
            label: '收款银行',
            prop: 'recvBank',
            line: 1,
            width: 150
          },
          {
            label: '收款手机号',
            prop: 'mobile',
            width: '130px'
          },
          {
            label: '状态',
            prop: 'status',
            width: '200px',
            addHtml: 'colorStatus'
          },
          {
            label: '申请时间',
            prop: 'createdDate',
            width: '200px'
          },
          {
            label: '付款时间',
            prop: 'payDate',
            width: '200px'
          },
          {
            label: '付款渠道',
            prop: 'channel',
            width: '200px',
            formatter: cellValue => {
              let arr = this.baseData.channelList.filter(item => item.confId == cellValue.channel)
              return arr.length > 0 ? arr[0].confLabel : '--'
            }
          },
          {
            label: '到账时间',
            prop: 'receiptDate',
            width: '200px'
          },
          {
            label: '结算金额/元',
            prop: 'settleAmount',
            formatter: cellValue => {
              return cellValue.settleAmount ? (cellValue.settleAmount / 100).toFixed(2) : '--'
            },
            width: '150px'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      // 基本数据
      baseData: {
        merchantList: [],
        auditStatusStatusList: [
          {
            confId: '0',
            confLabel: '待审核'
          },
          {
            confId: '1',
            confLabel: '已审核'
          },
          {
            confId: '2',
            confLabel: '第三方处理'
          },
          {
            confId: '3',
            confLabel: '成功'
          },
          {
            confId: '4',
            confLabel: '失败'
          },
          {
            confId: '5',
            confLabel: '驳回'
          },
          {
            confId: '6',
            confLabel: '受理失败'
          }
        ],
        channelList: [
          {
            confId: 'TXIAT',
            confLabel: '熠轩'
          },
          {
            confId: 'XYJ',
            confLabel: '薪遇见'
          },
          {
            confId: 'YUNHUO',
            confLabel: '云获'
          }
        ],
        withdrawalTypeList: [
          {
            confId: '0',
            confLabel: '积分提现'
          },
          {
            confId: '1',
            confLabel: '普通提现'
          }
        ]
      },
      showPassDialog: false,
      form: {
        remark: ''
      },
      detailVisible: false,
      isRefuse: 1,
      recordInfo: '',
      isPay: false,
      isCodeDisabled: false,
      count: '',
      timer: null,
      payForm: {
        payMoney: '',
        admin: '',
        channel: '',
        captcha: '',
        remark: '',
        balance: ''
      },
      payFormData: [
        {
          label: '付款总金额',
          name: 'payMoney',
          type: 'input',
          isDisabled: 'true'
        },
        {
          label: '付款渠道',
          type: 'select',
          name: 'channel',
          optionId: 'confId',
          optionLabel: 'confLabel',
          optionList: [
            {
              confId: 'TXIAT',
              confLabel: '熠轩'
            },
            {
              confId: 'XYJ',
              confLabel: '薪遇见'
            },
            {
              confId: 'YUNHUO',
              confLabel: '云获'
            }
          ]
        },
        {
          label: '',
          name: 'admin',
          type: 'input',
          addHtml: 'balance'
        },
        {
          label: '管理员',
          name: 'admin',
          type: 'input',
          isDisabled: 'true'
        },
        {
          label: '验证码',
          addHtml: 'captcha',
          name: 'captcha'
        },
        {
          label: '备注',
          name: 'remark',
          type: 'input',
          inputType: 'textarea',
          maxlength: 50
        }
      ],
      payRule: {
        channel: [{ required: true, message: '请选择付款渠道', trigger: 'change' }],
        captcha: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
      },
      importRule: {
        fileName: [{ required: true, message: '请选择', trigger: 'blur' }]
      },
      importForm: {
        isLoading: 0,
        isSuccess: 0,
        result: '',
        fileName: '',
        fileUrl: '',
        successCount: '',
        batchNo: '',
        errorUrl: ''
      },
      operaForm: {
        select: true,
        batch: '',
        key: ''
      },
      isImport: false,
      batchOptions: ['批量审核', '批量付款'],
      keyOptions: ['一键审核', '一键付款']
    }
  },
  watch: {
    'searchForm.customerPhone'(newVal) {
      if (isNaN(Number(newVal))) {
        this.searchForm.customerPhone = newVal.replace(/[^\d]/g, '')
      }
    },
    'payForm.channel'(newVal) {
      if (newVal) this.getBalance()
    }
  },
  mounted() {
    this.$utils.getOptionsList(this, 'showFormData')
    this.getMerchantList()
    this.getSettleAmount()
  },
  methods: {
    //批量操作/一键操作
    async handleSelectBtn(index, type) {
      this.operaForm.select = type == 'batch' ? false : true
      this.operaForm[type] = ''
      let result = await this.getAllPayAmount(index, type)
      if (result) {
        if (index == 0) {
          this.handleCheck()
        } else if (index == 1) {
          this.handlePay()
        }
      }
    },
    //canApprove=false的时候就提示只能选待审核的,付款的时候canPay=false就提示只能选待付款和受理失败的
    //获取批量付款的金额
    getAllPayAmount(index, type) {
      return new Promise(resolve => {
        let key = index == 0 ? 'canApprove' : 'canPay',
          params = {},
          Method = type == 'batch' ? 'getPayAmount' : 'getAllPayAmount',
          textErr = ['请选择待审核的提现记录', '请选择已审核或受理失败的提现记录']

        if (type == 'batch') {
          if (!this.ids || this.ids.length == 0) {
            this.$message.error(textErr[index])
            return
          }
          params.ids = this.ids
        } else {
          params = {
            ...this.tableSearchForm
          }
        }
        params[key] = false

        this.$apis.withdraw[Method](params).then(res => {
          if (!res[key]) {
            this.$message.error(textErr[index])
            resolve(false)
          } else {
            if (index == 1) {
              this.payForm.payMoney = (res.payAmount / 100).toFixed(2)
            }
            resolve(true)
          }
        })
      })
    },
    getSettleAmount() {
      this.$apis.withdraw.getSettleAmount({}).then(res => {
        this.settleAmount = res
      })
    },
    getMerchantList() {
      this.$apis.withdraw.getMerchantList({}).then(res => {
        this.baseData.merchantList = res.map(item => {
          return {
            merchantName: item
          }
        })
        this.$utils.getOptionsList(this, 'showFormData', false, 'merchantName')
      })
    },
    getParams() {
      var params = JSON.parse(JSON.stringify(this.searchForm))
      if (this.searchForm.applyDateStr) {
        params.applyDateStart = dayjs(this.searchForm.applyDateStr[0]).format('YYYY-MM-DD') + ' 00:00:01'
        params.applyDateEnd = dayjs(this.searchForm.applyDateStr[1]).format('YYYY-MM-DD') + ' 23:59:59'
      }
      if (this.searchForm.payTimeStr) {
        params.payDateStart = dayjs(this.searchForm.payTimeStr[0]).format('YYYY-MM-DD') + ' 00:00:01'
        params.payDateEnd = dayjs(this.searchForm.payTimeStr[1]).format('YYYY-MM-DD') + ' 23:59:59'
      }
      if (this.searchForm.receiptDateStr) {
        params.receiptDateStart = dayjs(this.searchForm.receiptDateStr[0]).format('YYYY-MM-DD') + ' 00:00:01'
        params.receiptDateEnd = dayjs(this.searchForm.receiptDateStr[1]).format('YYYY-MM-DD') + ' 23:59:59'
      }

      delete params.payTimeStr, delete params.applyDateStr, delete params.receiptDateStr
      return params
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.tableSearchForm = this.getParams()
        delete this.tableSearchForm.payTimeStr
        delete this.tableSearchForm.applyDateStr
        resolve()
      })
    },
    handleSearch() {
      this.$refs.withdrawRef.refreshTable()
    },
    handleReset() {
      this.searchForm = {
        outSettleOrderId: '',
        customerName: '',
        customerPhone: '',
        status: '',
        channel: '',
        merchantName: ''
      }
      this.handleSearch()
    },
    handleDetail(row) {
      // console.log(row)
      this.id = row.id
      this.detailVisible = true
    },
    exportExcel() {
      const params = this.getParams()
      this.$apis.withdraw.orderExport(params).then(res => {
        this.$utils.aToExport(res)
      })
    },
    async uploadFile(e) {
      const file = e.srcElement.files[0]
      let AllImgExt = '.xls|.xlsx'
      let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
      if (AllImgExt.indexOf(extName) === -1) {
        this.$message.error('上传格式不正确')
        return false
      }
      const header = await this.compareHeader(file)
      if (!util.getArrayIsSubset(header, tabelHeaderModel)) {
        this.$message.error('模版错误')
      } else {
        const reader = new FileReader()
        reader.readAsDataURL(file)
        reader.onload = event => {
          const imgFile = event.target.result
          const arrBase64 = imgFile.split(',')
          this.importForm.fileUrl = file.name.split('.').pop() + '@' + arrBase64[1]
          this.importForm.fileName = file.name
        }
      }
    },

    compareHeader(file) {
      return new Promise(resolve => {
        const reader = new FileReader()
        reader.onload = event => {
          /* 解析数据 */
          const bstr = event.target.result
          const wb = XLSX.read(bstr, { type: 'binary' })
          /* 获取文件的第一个工作表(WorkSheet) */
          const wsname = wb.SheetNames[0]
          let ws = wb.Sheets[wsname]
          if (!ws['!ref']) {
            this.$message.error('格式错误')
            return
          }
          ws = this.handleStartTd(ws, 'A9')
          const data = this.getHeaderRow(ws)
          resolve(data)
        }
        reader.readAsBinaryString(file)
      })
    },
    handleStartTd(worksheet, start) {
      let old = worksheet['!ref']
      old = old.split(':')
      worksheet['!ref'] = start + ':' + old[1]
      return worksheet
    },
    getHeaderRow(sheet) {
      // console.log(sheet)
      const headers = []
      /* sheet['!ref']表示所有单元格的范围,例如从A1到F8则记录为 A1:F8*/
      const range = XLSX.utils.decode_range(sheet['!ref'])
      let C,
        R = range.s.r /* 从第一行开始 */
      /* 按列进行数据遍历 */
      for (C = range.s.c; C <= range.e.c; ++C) {
        /* 查找第一行中的单元格 */
        const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]

        let hdr = 'UNKNOWN ' + C // <-- 进行默认值设置
        if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
        if (!hdr.includes('UNKNOWN')) {
          headers.push(hdr)
        }
      }
      return headers
    },
    handleSaveImport() {
      let params = {
        batchNo: this.importForm.batchNo
      }
      this.$apis.withdraw.handleSaveImport(params).then(res => {
        this.handleReset()
      })
    },
    //提现导入
    handleImport() {
      this.isImport = true
      this.clearFile()
    },
    clearFile() {
      this.importForm = {
        isLoading: 0,
        isSuccess: 0,
        result: '',
        fileName: '',
        fileUrl: '',
        successCount: '',
        batchNo: '',
        errorUrl: ''
      }
    },
    comfirmImport() {
      let {
        importForm: { isSuccess, fileName, isLoading },
        isImport
      } = this

      if (fileName == '' && isLoading == 0) {
        this.$message({
          message: '请先选择文件',
          type: 'error'
        })
        return
      }
      if (isImport && isSuccess != 0) {
        this.isImport = false
        this.clearFile()
        return
      }

      this.importForm.isLoading = 1
      this.$apis.withdraw.uploadXlsx({ file: this.importForm.fileUrl }).then(res => {
        if (this.isImport) {
          if (res.code == 0) {
            this.importForm.isLoading = 2
            if (res.data.importStatue == 0) {
              this.importForm.successCount = res.data.successCount
              this.importForm.isSuccess = 1 //处理成功
              this.importForm.batchNo = res.data.batchNo
              this.handleSaveImport()
            } else {
              this.importForm.errorUrl = res.data.errorUrl
              this.importForm.isSuccess = 2 //处理失败
            }
          } else {
            this.importForm.isLoading = 0
            this.$message({
              message: res.message,
              type: 'error'
            })
          }
        }
      })
    },
    cancelImport() {
      this.isImport = false
      this.clearFile()
    },
    //获取复选table数据
    selectionTable(val) {
      this.ids = val.map(item => item.id)
    },
    //批量审核
    handleCheck(row, isRefuse = 0) {
      // console.log(row)
      // isRefuse:  0:审批,2:驳回
      if (row) {
        this.operaForm.select = false
        this.ids = isRefuse == 0 ? [row.id] : row.id
      }
      //驳回
      this.isRefuse = isRefuse
      this.showPassDialog = true
    },
    //付款
    handlePay(row) {
      if (row) {
        this.operaForm.select = false
        this.ids = [row.id]
        this.payForm.payMoney = (row.payAmount / 100).toFixed(2)
      }
      this.getAdmin()
      // this.getBalance()
      // this.payForm.channel= 'TXIAT',
      this.isPay = true
    },
    getAdmin() {
      this.$apis.withdraw.getAdmin({}).then(res => {
        this.payForm.admin = `${res.name} ${res.phone}`
      })
    },
    getBalance() {
      this.$apis.withdraw.getBalance({ channel: this.payForm.channel }).then(res => {
        this.payForm.balance = res
      })
    },
    comfirmCheck() {
      // console.log(this.ids)
      if (this.isRefuse == 2 && this.form.remark == '') {
        this.$message({
          message: '请输入驳回原因',
          type: 'error'
        })
        return
      }
      this.checkLoading = true
      let { isRefuse } = this,
        { select } = this.operaForm, //true为一键操作
        Methods = select ? 'integralAllOut' : this.isRefuse == 2 ? 'integralOut' : 'integralApprove',
        params = select
          ? {
              ...this.tableSearchForm,
              remark: this.form.remark
            }
          : {
              remark: this.form.remark,
              [isRefuse == 2 ? 'id' : 'ids']: this.ids,
              type: isRefuse
            }

      this.$apis.withdraw[Methods](params)
        .then(res => {
          this.$message({
            message: res.code == '0' ? '操作成功' : res.message,
            type: res.code == '0' ? 'success' : 'error'
          })
        })
        .finally(() => {
          this.handleReset()
          this.clearSelect()
          this.checkLoading = false
        })
    },
    clearSelect() {
      this.ids = ''
      this.form.remark = ''
      this.showPassDialog = false
      this.$refs.withdrawRef.clearMutiSelect()
    },
    dialogClose() {
      this.detailVisible = false
    },
    //付款
    comfirmPay() {
      this.$refs.payFormRef.$refs.payChildRef.validate(valid => {
        if (valid) {
          let { select } = this.operaForm,
            Methods = select ? 'integralAllpay' : 'integralpay', //true为一键操作
            params = select
              ? {
                  ...this.tableSearchForm,
                  payChannel: this.payForm.channel,
                  captcha: this.payForm.captcha,
                  remark: this.payForm.remark
                }
              : {
                  ids: this.ids,
                  channel: this.payForm.channel,
                  captcha: this.payForm.captcha,
                  remark: this.payForm.remark
                }
          this.loading = true
          this.$apis.withdraw[Methods](params)
            .then(res => {
              this.$message({
                message: res.code == '0' ? '付款成功' : res.message,
                type: res.code == '0' ? 'success' : 'error'
              })
            })
            .finally(() => {
              this.handleReset()
              this.cancelPay()
              this.loading = false
            })
        }
      })
    },
    cancelPay() {
      this.ids = ''
      this.isPay = false
      this.payForm = {
        payMoney: '',
        admin: '',
        channel: '',
        captcha: '',
        remark: '',
        balance: ''
      }
      this.$refs.withdrawRef.clearMutiSelect()
    },

    getCode() {
      if (this.isCodeDisabled) return
      if (!this.timer) {
        this.count = 60
        // var params = {
        //   phoneType: 'RG',
        //   phone: this.ruleForm.registerPhone
        // }
        this.$apis.withdraw.getSms({}).then(res => {
          if (res.code == 200) {
            this.$message.success('短信验证码发送成功')
          }
        })
        this.isCodeDisabled = true
        this.timer = setInterval(() => {
          if (this.count > 0 && this.count <= 60) {
            this.count--
          } else {
            this.isCodeDisabled = false
            clearInterval(this.timer)
            this.timer = null
          }
        }, 1000)
      }
    }
  }
}
</script>
<style scoped lang='scss'>
.describe {
  font-size: 12px;
  color: #999999;
  margin-left: 154px;
}
.table_point {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 8px;
}
.captcha-wrap {
  .captcha-text {
    font-size: 12px;
    color: #5850ff;
    position: absolute;
    right: 0;
    top: 2px;
    margin-right: 10px;
    cursor: pointer;
    width: 100px;
    height: 32px;
    text-align: right;
  }
}
.table-header {
  .el-button + .el-button {
    margin-left: 10px;
  }
  .selectBtn {
    width: 100px;
    margin-right: 10px;
    /deep/.el-input__inner {
      padding: 0 10px;
    }
  }
}
.price {
  color: #5850ff;
}
.statistics {
  font-size: 14px;
  color: #999999;
}
.channelMoney {
  position: relative;
  font-size: 12px;
  color: #999999;
  right: 322px;
  top: 35px;
  margin-bottom: 20px;
  .price {
    color: #333333;
  }
}
.import-btn {
  position: relative;
  width: 116px;
  height: 32px;
  text-align: center;
  border-radius: 4px;
  color: #666666;
  font-size: 14px;
  margin-left: 8px;
  border: 1px solid #00000026;
  line-height: 32px;
  display: inline-block;
}

.import-input {
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 98px;
  height: 32px;
  cursor: pointer;
  font-size: 0;
}
.download-url {
  margin-top: 7px;
  font-size: 14px;
  font-weight: 400;
  color: #5850ff;
  line-height: 20px;
  display: block;
}
.err-url {
  margin-top: 7px;
  font-size: 14px;
  font-weight: 400;
  color: #5850ff;
  line-height: 20px;
  display: inline-block;
}
.middle {
  margin: 0 auto;
  .el-icon {
    font-size: 48px;
    text-align: center;
    position: relative;
    left: 50%;
    margin-left: -24px;
  }
  .el-icon-success {
    color: #2dca75;
  }
  .el-icon-error {
    color: #ec4f4f;
  }
  .resulttip {
    font-weight: 600;
    font-size: 16px;
    color: #000000;
    margin: 12px 0;
    text-align: center;
  }
  .state {
    font-size: 14px;
    color: #666666;
    text-align: center;
    margin: 0 67px;
    line-height: 20px;
  }
}
.gl-form-page /deep/ .el-dialog__footer {
  text-align: center !important;
}
.select-wrap {
  /deep/ {
    ::-webkit-input-placeholder {
      /*Webkit browsers*/
      color: #606266;
      font-size: 14px;
    }
    :-moz-placeholder {
      /*Mozilla Firefox 4 to 8*/
      color: #606266;
      font-size: 14px;
    }
    ::moz-placeholder {
      /*Mozilla Firefox 19+*/
      color: #606266;
      font-size: 14px;
    }
    :-ms-input-placeholder {
      /*Internet Explorer 10+*/
      color: #606266;
      font-size: 14px;
    }
  }
}
</style>