applyWithdrawal.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <a-modal
  3. v-model="opened"
  4. :title="title"
  5. centered
  6. :maskClosable="false"
  7. :confirmLoading="confirmLoading"
  8. :width="560"
  9. :footer="null"
  10. @cancel="cancel"
  11. >
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <a-form-model
  14. id="applyWithdrawal-form"
  15. ref="ruleForm"
  16. :model="form"
  17. :rules="rules"
  18. :label-col="formItemLayout.labelCol"
  19. :wrapper-col="formItemLayout.wrapperCol"
  20. >
  21. <a-form-model-item label="申请提现金额" prop="amount">
  22. <a-input-number
  23. v-model="form.amount"
  24. style="width: 73%;"
  25. :precision="2"
  26. :min="0"
  27. :max="activeAmount-0.5"
  28. id="applyWithdrawal-amount"
  29. placeholder="请输入正数(最多两位小数)" />
  30. <a-button type="primary" class="button-primary" @click="handleAmount" id="applyWithdrawal-getNum-btn">全部</a-button>
  31. </a-form-model-item>
  32. <a-form-model-item label="实际扣除金额">
  33. <span>{{ toThousands(serviceCharge,2)||'--' }}元 </span><span style="color: #999;">(申请提现金额+提现手续费)</span>
  34. </a-form-model-item>
  35. <a-form-model-item label="提现账户">
  36. <span style="display: block;" v-if="pageInfo">{{ pageInfo.merchantBankAccountEntity?pageInfo.merchantBankAccountEntity.bankAccount:'' }}{{ ' ( '+ pageInfo.dealerName +' ) ' }}</span>
  37. <span v-if="pageInfo">{{ pageInfo.merchantBankAccountEntity?pageInfo.merchantBankAccountEntity.bankCard:"" }}</span>
  38. </a-form-model-item>
  39. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;">
  40. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="applyWithdrawal-btn-submit">确定</a-button>
  41. <a-button @click="cancel" style="margin-left: 15px" id="applyWithdrawal-btn-back">取消</a-button>
  42. </a-form-model-item>
  43. </a-form-model>
  44. </a-spin>
  45. </a-modal>
  46. </template>
  47. <script>
  48. import { commonMixin } from '@/utils/mixin'
  49. import { saveMerchantCashOut } from '@/api/merchantNew'
  50. export default {
  51. mixins: [commonMixin],
  52. props: {
  53. isOpenModal: {
  54. type: Boolean,
  55. default: false
  56. },
  57. pageInfo: {
  58. type: Object,
  59. default: () => {
  60. return null
  61. }
  62. }
  63. },
  64. computed: {
  65. serviceCharge () {
  66. return !this.form.amount ? 0 : this.form.amount + 0.5
  67. }
  68. },
  69. data () {
  70. return {
  71. formItemLayout: {
  72. labelCol: { span: 6 },
  73. wrapperCol: { span: 15 }
  74. },
  75. form: {
  76. amount: '' // 金额
  77. },
  78. activeAmount: null,
  79. opened: this.isOpenModal, // 提现弹框
  80. title: '申请提现',
  81. confirmLoading: false, // 确认按钮loading
  82. spinning: false,
  83. rules: { amount: [{ required: true, message: '请输入提现金额', trigger: 'blur' }] }
  84. }
  85. },
  86. methods: {
  87. handleAmount () {
  88. this.form.amount = this.activeAmount - 0.5
  89. },
  90. // 保存
  91. handleSubmit () {
  92. const _this = this
  93. this.$refs.ruleForm.validate(valid => {
  94. if (valid) {
  95. const form = JSON.parse(JSON.stringify(_this.form))
  96. if (form.amount <= 0) {
  97. _this.$message.warning('提现金额不能小于等于0')
  98. return
  99. }
  100. form.serviceCharge = this.serviceCharge
  101. form.merchantType = 'DEALER'
  102. form.merchantSn = _this.pageInfo ? _this.pageInfo.merchantSn : ''
  103. _this.spinning = true
  104. saveMerchantCashOut(form).then(res => {
  105. if (res.status == 200) {
  106. _this.$message.success(res.message)
  107. setTimeout(() => {
  108. _this.cancel()
  109. _this.$emit('refresh')
  110. _this.spinning = false
  111. }, 1000)
  112. } else {
  113. _this.spinning = false
  114. }
  115. })
  116. } else {
  117. return false
  118. }
  119. })
  120. },
  121. // 取消
  122. cancel () {
  123. this.form.amount = ''
  124. this.$refs.ruleForm.resetFields()
  125. this.$emit('close')
  126. }
  127. },
  128. watch: {
  129. isOpenModal (nVal, oVal) {
  130. this.opened = nVal
  131. },
  132. opened (nVal, oVal) {
  133. if (!nVal) {
  134. this.form.amount = ''
  135. this.$emit('close')
  136. } else {
  137. this.activeAmount = this.pageInfo && (this.pageInfo.activeAmount || this.pageInfo.activeAmount == 0) ? this.pageInfo.activeAmount : null
  138. }
  139. }
  140. }
  141. }
  142. </script>
  143. <style>
  144. </style>