• 王天霸's avatar
    1 · b31e778f
    王天霸 提交于
    b31e778f
wddetails.vue 20.8 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
<template>
  <div class="app-container">
    <el-card class="box-card">
      <p class="card-header-tip">
        提现状态:<span class="pay-status">{{ payStatusFormatter(withdrawInfo.pay_status) }}</span>
<!--        提现状态:<strong>{{ payStatusFormatter(withdrawInfo.pay_status) }}</strong>-->
        <span>如果您是电子发票,则不用填写快递公司和单号信息,需上传电子发票图片,同时将电子发票发送至电子邮箱,查看</span>
        <span class="checked-email-rule" @click="isViewSendRuleDialog = true">【电子邮箱及发票发送格式】</span>
      </p>

      <div class="main">
        <div class="card-header-title">
          <span class="blue-block blue-block-goods-title"></span>提现信息
        </div>

        <el-row class="row-title">
          <el-col :span="4" class="text-r">提现流水单号</el-col>
          <el-col :span="9" class="text-l">{{ withdrawInfo.sn }}</el-col>
        </el-row>

        <el-row class="row-title">
          <el-col :span="4" class="text-r">提现时间</el-col>
          <el-col :span="9" class="text-l">{{ formatter(withdrawInfo.created_time) }}</el-col>
        </el-row>

        <el-row class="row-title">
          <el-col :span="4" class="text-r">提现金额</el-col>
          <el-col :span="9" class="text-l">{{ withdrawInfo.amount ? withdrawInfo.amount / 100 : 0 }}</el-col>
        </el-row>

        <el-row class="row-title">
          <el-col :span="4" class="text-r">手续费</el-col>
          <el-col :span="9" class="text-l">{{ 0 }}</el-col>
<!--          <el-col :span="9" class="text-l">{{ withdrawInfo.service_fee ? withdrawInfo.service_fee / 100 : 0 }}</el-col>-->
        </el-row>

        <el-row class="row-title">
          <el-col :span="4" class="text-r">实际到账金额</el-col>
          <el-col :span="9" class="text-l">{{ withdrawInfo.real_amount ? withdrawInfo.real_amount / 100 : 0  }}</el-col>
        </el-row>

        <el-row class="row-title">
          <el-col :span="4" class="text-r">提现至账户</el-col>
          <el-col :span="9" class="text-l">{{ withdrawInfo.bank_name_all }}</el-col>
        </el-row>

        <el-row class="row-title">
          <el-col :span="4" class="text-r">发票信息</el-col>
          <el-col :span="9" class="text-l">
            <el-link v-if="withdrawInfo.invoice_status == 1" :underline="false" type="primary" @click="viewInvoiceDetails">点击查看发票</el-link>
            <el-link v-else disabled>发票未提交</el-link>
          </el-col>
        </el-row>

        <div class="card-header-title">
          <span class="blue-block blue-block-goods-title"></span>打款备注
        </div>
        <div class="remark-con">
          <p v-if="payRemark">{{ payRemark }}</p>
          <p v-else style="color: #555;">暂无备注</p>
        </div>
      </div>

      <div class="footer-btn">
        <el-button type="primary" @click="exportGoodsDetails" style="margin-right:20px;">导出商品明细</el-button>
        <el-button @click="submitInvoiceAgain" :disabled="isSubmitInvoice">补充发票信息</el-button>
      </div>

    </el-card>

    <!-- 电子发票 规则 -->
    <el-dialog
      title="电子发票发送格式"
      :visible.sync="isViewSendRuleDialog"
      width="40%"
      center
    >
      <div class="view-sendemail-rule">
        <p>您好,如果您是电子发票,请通过邮箱按照以下格式发送:</p>
        <p><span class="span-title">标题:</span>【XXX公司】电子发票</p>
        <p><span class="span-title spe-1">收件人:</span>finanical@stbz.net</p>
        <p><span class="span-title">正文内容:</span>【XXX公司】电子发票</p>
        <p><span class="span-title spe-1">附件:</span>电子发票</p>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="isViewSendRuleDialog = false" size="small">关 闭</el-button>
      </span>
    </el-dialog>

    <!-- 补充发票 信息 -->
    <el-dialog
      title="补充发票信息"
      :destroy-on-close="true"
      :visible.sync="isAddInvoiceAgainDialog"
      :before-close="cancelUpInvoiceImg"
      width="40%"
      center>
      <el-form ref="addInvoiceForm" :model="addInvoiceForm" :rules="addInvoiceRule" label-width="150px" class="add-invoice-form" size="small">
        <el-form-item label="快递公司:" prop="express_name">
          <el-select v-model="addInvoiceForm.express_name" filterable placeholder="请选择快递公司" style="width: 80%;">
            <el-option
              v-for="item in expressLists"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="快递单号:" prop="express_sn">
          <el-input v-model="addInvoiceForm.express_sn" placeholder="请输入快递单号" style="width: 80%;"></el-input>
        </el-form-item>

        <el-form-item label="发票图片:" prop="invoice_img">
          <el-upload
            class="avatar-uploader"
            action=""
            list-type="picture-card"
            :http-request="uploadInvoiceImg"
            :before-upload="beforeUpInvoiceImg"
            :file-list="invoiceImgList"
            :limit="1"
            :on-exceed="limitCount1"
            :before-remove ="beforeRemoveInvoiceImg"
            :on-remove="removeInvoiceImg"
            :on-preview="handleInvoiceImg"
          >
            <i class="el-icon-plus"></i>

          </el-upload>
          <el-dialog :visible.sync="dialogVisibleInvoiceImg" class="dialog-img-spe">
            <img width="100%" :src="dialogInvoiceImg" alt=""/>
          </el-dialog>
          <div class="textTip">最多上传一张图片,仅限jpg/png格式,大小限制在500kb以内</div>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitInvoice" size="small">确 定</el-button>
        <el-button type="primary" @click="cancelUpInvoiceImg" size="small">取 消</el-button>
      </span>
    </el-dialog>

    <!-- 查看发票 信息 -->
    <el-dialog
      title="发票信息"
      :destroy-on-close="true"
      :visible.sync="isViewInvoiceAgainDialog"
      width="40%"
      center>
      <el-form :model="viewInvoiceForm" label-width="150px" class="add-invoice-form" size="small">
<!--        <el-form-item label="快递公司:" >-->
<!--          <el-input v-model="viewInvoiceForm.express_name" placeholder="请输入快递单号" disabled style="width: 80%;"></el-input>-->
<!--        </el-form-item>-->

        <el-form-item label="快递公司:" prop="express_name">
          <el-select v-model="viewInvoiceForm.express_name" disabled placeholder="请选择快递公司" style="width: 80%;">
            <el-option
              v-for="item in expressLists"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="快递单号:">
          <el-input v-model="viewInvoiceForm.express_sn" placeholder="请输入快递单号" disabled style="width: 80%;"></el-input>
        </el-form-item>

        <el-form-item label="发票图片:">
          <div v-if="viewInvoiceForm.invoice_img">
            <el-image
              style="width: 100px; height: 100px;border:1px solid #eee;"
              :src="viewInvoiceForm.invoice_img"
              :preview-src-list="viewInvoiceForm.invoiceImgList">
            </el-image>
          </div>
<!--          <div class="textTip">最多上传一张图片,仅限jpg/png格式,大小限制在500kb以内</div>-->
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="isViewInvoiceAgainDialog = false" size="small">关 闭</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
  import { getWithdrawlogDetailsData,exportGoodsDetailsData,getExpressListData ,upLoadImg, addInvoiceData } from '@/api/module/bankcard'
  import {dateFormat} from '@/utils'
  export default {
    name: "Wddetails",
    data() {
      let checkPic = (rule, value, callback) => {
        if(this.invoiceImgList.length > 0) {
          callback();
        }else if(this.invoiceImgList.length === 0) {
          callback(new Error("发票图片不能为空"));
        }
      };
      return {
        withdrawId: 0,
        withdrawInfo: {
          pay_status: 0,
          sn: '',
          created_time: 0,
          amount: 0,
          service_fee: 0,
          real_amount: 0,
          bank_name: '',
          bank_branch_name: '',
          bank_card_id: '',
          bank_name_all: '',
          invoice_status: 0,
        },
        payRemark: '', // 打款备注
        // 查看 电子发票发送格式
        isViewSendRuleDialog: false,
        isSubmitInvoice: false, // 是否 补充提交发票

        // 补充发票
        isAddInvoiceAgainDialog: false, // 补充发票信息 对话框
        expressLists: [],
        invoiceImgList: [],// 发票图片 file
        invoiceImgBase64List: [],// 发票图片 base64格式
        addInvoiceForm: {
          express_name: '',
          express_sn: '',
          invoice_img: ''
        },
        addInvoiceRule: {
          express_name: [{required: true,message: '物流公司名称不能为空',trigger: 'change'}],
          express_sn: [{required: true,message: '快递单号不能为空',trigger: 'blur'}],
          invoice_img: [{ required: true, validator: checkPic}]
        },

        dialogVisibleInvoiceImg: false,
        dialogInvoiceImg: '',

        // 查看 发票信息
        isViewInvoiceAgainDialog: false,
        viewInvoiceForm: {
          express_name: '',
          express_sn: '',
          invoice_img: '',
          invoiceImgList: [],
        }
      }
    }, // data end
    created() {
      // 提现记录 id
      this.withdrawId = Number(this.$route.query.withdrawId);
      // 获取 物流公司 列表
      this.getExpressList();
      //  查询 提现记录 详情
      this.getWithdrawlogDetails();
    },
    methods: {
      /** 查询 提现记录 详情 */
      getWithdrawlogDetails() {
        const id = this.withdrawId
        getWithdrawlogDetailsData({id: id}).then(res=> {
          if (res.code == 1 && res.data) {
            if (res.data.withdraw_info) {
              this.withdrawInfo = res.data.withdraw_info;
              // 提现至账户 处理
              if( this.withdrawInfo.bank_card_id ) {
                let strBankcardId = this.withdrawInfo.bank_card_id + '';
                let Forward4 = strBankcardId.substring(0,4)
                let backward4 = strBankcardId.substring(strBankcardId.length-4,strBankcardId.length)
                this.withdrawInfo.bank_name_all = this.withdrawInfo.bank_name + '\u00a0\u00a0' + Forward4 + '****' + backward4;
              }
              // 补充发票信息 按钮 是否可以点击
              this.isSubmitInvoice = this.withdrawInfo.invoice_status == 1 ? true : false;
            }
            // 打款备注
            if(res.data.action_logs && res.data.action_logs.content) {
              this.payRemark = res.data.action_logs.content;
            }
          }
        });
      },

      /** 导出商品明细 */
      exportGoodsDetails() {
        exportGoodsDetailsData( {id: this.withdrawId} ).then(res=> {
          //debugger
          if (res.code == 1) {
            if(res.data) {
              this.$message({type:'success',message:'导出成功'});
              const aLink = document.createElement('a');
              aLink.href = res.data;
              //aLink.download = '订单.xls'; //下载的文件名
              aLink.style.display = 'none';
              document.body.appendChild(aLink);
              aLink.click();
              document.body.removeChild(aLink);
            }else {
              this.$message({type:'warning',message: res.message || res.msg ? res.message || res.msg: '导出失败'});
            }
          }else {
            this.$message({type:'error',message: res.message || res.msg ? res.message || res.msg: '导出失败'});
          }
        });
      },

      /** 补充发票信息 */
      submitInvoiceAgain() {
        this.isAddInvoiceAgainDialog = true;
      },

      /** 上传 发票图片 数量限制 1  */
      limitCount1(files, fileList) {
        this.$message({message: '最多上传1张图片', type: 'warning'});
      },

      /** 发票图片 各种校验*/
      beforeUpInvoiceImg(file) {
        if (file.type !== "image/png" && file.type !== "image/jpg" && file.type != "image/jpeg") {
          this.$message({
            message: '上传图片格式只支持png/png格式',
            type: "warning"
          });
          return false;
        }
        let isImgSize = (file.size / 1024 ) > 500;
        if (isImgSize) {
          this.$message({
            message: '上传图片大小不能超过500kb',
            type: "warning"
          });
          return false;
        }
      },

      /** 上传 发票 图片 */
      uploadInvoiceImg(param) {
        this.getBase64(param.file).then( res => {
          let result = res.split(",");
          this.Base64img = result[1];
          let data = {"img_data":this.Base64img,"type":2};
          this.invoiceImgBase64List = [] // 初始化
          upLoadImg(data).then( res=> {
            let urlObj = {'url': ''};
            if(res.data) {
              urlObj.url = res.data.image_url;
              this.invoiceImgList.push(urlObj); // 展示用
              this.addInvoiceForm.invoice_img = res.data.image_url // 字段无用,清除校验有用
              this.invoiceImgBase64List.push( data.img_data );
              this.$message({type:'success',message:'图片上传成功'});
              this.$refs.addInvoiceForm.clearValidate('invoice_img');
            }
          });
        });
      },

      /** 发票 删除前 */
      beforeRemoveInvoiceImg(file) {
        if (file.status === "success") {
          return new Promise((res, rej) => {
            this.$confirm(`是否删除此图片`, '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              return res();
            }).catch(() => {
              this.$message({
                type: 'success',
                message: '取消删除!'
              });
              return rej();
            });
          });
        }
      },

      /** 发票图片 删除 */
      removeInvoiceImg(file) {
        if (file.status === "success") {
          for (let i = 0; i < this.invoiceImgList.length; i++) {
            if (file.uid === this.invoiceImgList[i].uid) {
              this.invoiceImgList.splice(i, 1);
              this.invoiceImgBase64List.splice(i, 1);
            }
          }
          this.$message( {type: 'success', message: '删除成功!'} );

          if(this.invoiceImgList.length === 0) {
            this.$refs.addInvoiceForm.validateField('invoice_img')
          }else {
            this.$refs.addInvoiceForm.clearValidate('invoice_img');
          }
        }
      },

      /** 发票图片 预览 */
      handleInvoiceImg(file) {
        this.dialogInvoiceImg = file.url;
        this.dialogVisibleInvoiceImg = true;
      },

      /** 提交 补充的发票信息 */
      submitInvoice() {
        let params = {
          id: '',
          express_company: '',
          express_no: '',
          invoice_img: [],
        }
        this.$refs.addInvoiceForm.validate((valid)=> {
          if (valid) {
            params.id = this.withdrawId;
            //params.express_company = this.addInvoiceForm.express_name;
            params.express_no = this.addInvoiceForm.express_sn;
            params.invoice_img = this.invoiceImgBase64List

            for(let i = 0; i < this.expressLists.length; i++) {
              if(this.addInvoiceForm.express_name == this.expressLists[i].value) {
                params.express_company = this.expressLists[i].label
              }
            }

            addInvoiceData(params).then(res=> {
              if(res.code == 1) {
                this.$message({type:'success',message: '补充发票信息成功'});
                this.isAddInvoiceAgainDialog = false;
                this.resetAddInvoiceForm();
                this.getWithdrawlogDetails();
              }else {
                this.$message({type:'success',message:  res.message || res.msg ? res.message  || res.msg: '补充发票信息失败' });
              }
            });
          }
        });
      },

      /** 取消 提交 补充的发票信息 */
      cancelUpInvoiceImg() {
        this.resetAddInvoiceForm();
        this.isAddInvoiceAgainDialog = false;
      },

      /** 初始化 补充发票的 表单数据 */
      resetAddInvoiceForm() {
        this.addInvoiceForm.express_name = ''
        this.addInvoiceForm.express_sn = ''
        this.addInvoiceForm.invoice_img = ''
        this.invoiceImgList = []
        this.invoiceImgBase64List = []
      },

      /** 查看 发票详情 */
      viewInvoiceDetails() {
        this.isViewInvoiceAgainDialog = true;
        if( this.withdrawInfo.express_company ) {
          this.viewInvoiceForm.express_name = this.withdrawInfo.express_company
        }
        if( this.withdrawInfo.express_no ) {
          this.viewInvoiceForm.express_sn = this.withdrawInfo.express_no
        }
        if( this.withdrawInfo.invoice_img_arr[0] ) {
          this.viewInvoiceForm.invoice_img = this.withdrawInfo.invoice_img_arr[0]
          this.viewInvoiceForm.invoiceImgList = this.withdrawInfo.invoice_img_arr
        }
      },

      /** 获取 物流公司 列表 */
      getExpressList() {
        getExpressListData().then(res=> {
          if (res.code == 1) {
            this.expressLists = res.data.expressLists
          }
        });
      },

      /** 提现状态 格式 */
      payStatusFormatter(type) {
        let typeMsg = '';
        if(type == 0) {
          typeMsg = '打款中'
        }else if (type == 1) {
          typeMsg = '提现成功'
        }
        return typeMsg
      },
      /** 时间格式化 */
      formatter(time) {
        return dateFormat(time * 1000, 'Y-m-d H:i:s')
      },
      /** 图片 base64 */
      getBase64(file) {
        return new Promise(function (resolve, reject) {
          let reader = new FileReader();
          let imgResult = "";
          reader.readAsDataURL(file);
          reader.onload = function () {
            imgResult = reader.result;
          };
          reader.onerror = function (error) {
            reject(error);
          };
          reader.onloadend = function () {
            resolve(imgResult);
          };
        });
      },
    }// methods end
  }
</script>

<style scoped>
  ::v-deep  .el-card__body{
    height: 100%;
    overflow: hidden;
  }

  .card-header-tip {
    height: 48px;
    line-height: 48px;
    background: #FFF5ED;
    border: 1px solid #F1914E;
    font-size: 14px;
    font-weight: 400;
    color: #333333;
    padding: 0 15px;
    margin-bottom: 0;
    overflow: hidden;
  }
  .pay-status {
    margin: 0 10px;
    font-size: 16px;
    font-weight: 600;
  }
  .checked-email-rule {
    color: #F1914E;
    cursor: pointer;
  }

  .main {
    height: calc(100% - 130px);
    overflow-y: auto;
  }

  .card-header-title {
    line-height: 24px;
    font-size: 18px;
    color: #000;
    font-weight: bold;
    margin: 20px 0;
  }

  .blue-block {
    display: inline-block;
    width: 5px;
    height: 24px;
    background: #3A84FF;
    margin: 0 9px 0 0;
    border-radius: 2px;
    vertical-align: bottom;
  }

  /* 提现信息 */
  .row-title {
    font-size: 14px;
    color: #333;
  }

  ::v-deep .el-col {
    border: 1px solid #eee;
    padding: 0 10px;
    height: 45px;
    display: flex;
    align-items: center;
  }

  .text-r {
    justify-content: center;
    background: #F7F8FA;
    align-items: center;
  }
  .text-l {
    justify-content: center;
    align-items: center;
  }

  .view-sendemail-rule {
    margin: 20px 20%;
  }
  .view-sendemail-rule > p{
    line-height: 30px;
  }
  .span-title {
    display: inline-block;
    width: 100px;
    text-align: left;
    font-weight: 500;
  }

  .spe-1 {
    margin-right: 7px;
  }

  .remark-con {
    min-height: 140px;
    width: 70%;
    background: #F7F8FA;
    border: 1px solid #E7E7EB;
    margin: 0 0 20px;
    font-size: 14px;
    padding: 0 20px;
    color: #333333;
  }

  .remark-con > p {
    line-height: 24px;
  }

  .footer-btn {
    width: calc(100% + 40px);
    margin-left: -20px;
    padding-top: 20px;
    height:65px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    box-shadow: 0 -8px 9px 1px rgba(51, 51, 51, 0.06);
  }

  /* 补充发票 */
  .add-invoice-form {
    margin: 0 40px;
  }
</style>