cashOutModal.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <a-modal
  3. centered
  4. class="cashOutModal-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="申请提现"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="800">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <!-- 表单 -->
  13. <div>
  14. <a-form-model
  15. id="cashOutModal-form"
  16. ref="ruleForm"
  17. :model="form"
  18. :rules="rules"
  19. :label-col="formItemLayout.labelCol"
  20. :wrapper-col="formItemLayout.wrapperCol"
  21. >
  22. <a-form-model-item label="申请提现金额" prop="amount">
  23. <a-input-number
  24. id="cashOutModal-amount"
  25. v-model="form.amount"
  26. :precision="2"
  27. :min="0.01"
  28. :max="maxAmount"
  29. :placeholder="'请输入'+ maxAmount +'以内的金额'"
  30. style="width: 100%;" />
  31. </a-form-model-item>
  32. <a-form-model-item label="实际扣除金额" prop="brandName">
  33. <strong>{{ toThousands(deductionAmount) }}</strong>元(申请提现金额+提现手续费)
  34. </a-form-model-item>
  35. <a-form-model-item label="提现账户" prop="brandName">
  36. <div>{{ nowData&&nowData.bankName || '--' }}({{ nowData&&nowData.accountName || '--' }})</div>
  37. <div>{{ nowData&&nowData.accountNo || '--' }}</div>
  38. </a-form-model-item>
  39. </a-form-model>
  40. <div class="btn-cont">
  41. <a-button type="primary" id="product-brand-edit-modal-save" @click="handleSave">提交</a-button>
  42. <a-button id="product-brand-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  43. </div>
  44. </div>
  45. </a-spin>
  46. </a-modal>
  47. </template>
  48. <script>
  49. import { commonMixin } from '@/utils/mixin'
  50. import { satelliteWHWithdrawalApply } from '@/api/satelliteWH'
  51. export default {
  52. name: 'ProductBrandEditModal',
  53. mixins: [commonMixin],
  54. props: {
  55. openModal: { // 弹框显示状态
  56. type: Boolean,
  57. default: false
  58. },
  59. nowData: {
  60. type: Object,
  61. default: null
  62. }
  63. },
  64. data () {
  65. return {
  66. isShow: this.openModal, // 是否打开弹框
  67. formItemLayout: {
  68. labelCol: { span: 6 },
  69. wrapperCol: { span: 16 }
  70. },
  71. form: {
  72. amount: ''
  73. },
  74. rules: {
  75. amount: [
  76. { required: true, message: '请输入申请提现金额', trigger: 'blur' }
  77. ]
  78. },
  79. spinning: false
  80. }
  81. },
  82. computed: {
  83. maxAmount () {
  84. const balance = this.nowData && this.nowData.balance ? this.nowData.balance : 0
  85. const serviceCharge = this.nowData && this.nowData.serviceCharge ? this.nowData.serviceCharge : 0
  86. if ((Number(balance) * 100 - Number(serviceCharge) * 100) <= 0) {
  87. return 0
  88. } else {
  89. return (Number(balance) * 100 - Number(serviceCharge) * 100) / 100
  90. }
  91. },
  92. deductionAmount () {
  93. const amount = this.form.amount || 0
  94. const serviceCharge = this.nowData && this.nowData.serviceCharge ? this.nowData.serviceCharge : 0
  95. if (amount == 0) {
  96. return 0
  97. } else {
  98. return (Number(amount) * 100 + Number(serviceCharge) * 100) / 100
  99. }
  100. }
  101. },
  102. methods: {
  103. // 提现
  104. handleSave () {
  105. const _this = this
  106. _this.$refs.ruleForm.validate(valid => {
  107. if (valid) {
  108. const params = {
  109. amount: this.form.amount,
  110. bankName: this.nowData.bankName,
  111. bankAccount: this.nowData.accountName,
  112. bankAccountNo: this.nowData.accountNo
  113. }
  114. _this.spinning = true
  115. satelliteWHWithdrawalApply(params).then(res => {
  116. if (res.status == 200) {
  117. _this.$message.success(res.message)
  118. _this.$emit('ok')
  119. _this.isShow = false
  120. _this.spinning = false
  121. } else {
  122. _this.spinning = false
  123. }
  124. })
  125. } else {
  126. return false
  127. }
  128. })
  129. }
  130. },
  131. watch: {
  132. // 父页面传过来的弹框状态
  133. openModal (newValue, oldValue) {
  134. this.isShow = newValue
  135. },
  136. // 重定义的弹框状态
  137. isShow (newValue, oldValue) {
  138. if (!newValue) {
  139. this.$emit('close')
  140. this.$refs.ruleForm.resetFields()
  141. }
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="less">
  147. .cashOutModal-modal{
  148. .ant-modal-body {
  149. padding: 40px 40px 24px;
  150. }
  151. .btn-cont {
  152. text-align: center;
  153. margin: 35px 0 10px;
  154. }
  155. }
  156. </style>