lex-xin 5 years ago
parent
commit
7192ea80ac
1 changed files with 61 additions and 2 deletions
  1. 61 2
      src/views/studentManager/components/studentOrder.vue

+ 61 - 2
src/views/studentManager/components/studentOrder.vue

@@ -136,8 +136,11 @@
             <el-radio :label="2">扣除</el-radio>
           </el-radio-group>
         </el-form-item>
+        <el-form-item :label="moneyForm.titleType == 'account' ? '课程余额' : '账户余额'">
+          <el-input type="number" disabled :value="moneyForm.titleType == 'account' ? dataInfo.courseBalance : dataInfo.balance"></el-input>
+        </el-form-item>
         <el-form-item label="金额" prop="money">
-          <el-input type="number" @mousewheel.native.prevent v-model.trim="moneyForm.money"></el-input>
+          <el-input type="number" @mousewheel.native.prevent v-model="moneyForm.money"></el-input>
         </el-form-item>
         <el-form-item label="备注" prop="remark">
           <el-input type="textarea" v-model="moneyForm.remark"></el-input>
@@ -280,7 +283,63 @@ export default {
     submitMoney(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          
+          let moneyForm = this.moneyForm
+          let dataInfo = this.dataInfo
+          let courseBalance = 0,
+              balance = 0
+          if(moneyForm.titleType == 'account') { // 课程余额
+            if(moneyForm.type == 1) {
+              courseBalance = Number((Number(moneyForm.money) + Number(dataInfo.courseBalance)).toFixed(2))
+            } else if(moneyForm.type == 2) {
+              if(dataInfo.courseBalance - moneyForm.money  < 0) {
+                this.$message.error('扣除金额不能大于' + dataInfo.courseBalance)
+                return
+              } else {
+                courseBalance = Number(Number(dataInfo.courseBalance) - (Number(moneyForm.money)).toFixed(2))
+              }
+            }
+            updateCourseBalance({
+              userId: this.searchForm.studentId,
+              decimal: courseBalance,
+              memo: moneyForm.remark
+            }).then(res => {
+              let result = res.data
+              if (res.code == 200) {
+                this.$message.success('保存成功')
+                this.__init()
+                this.moneyVisible = false
+              } else {
+                this.$message.error(res.msg)
+              }
+            })
+          } else if(moneyForm.titleType == 'recharge') { // 账户余额
+            if(moneyForm.type == 1) {
+              balance = moneyForm.money
+            } else if(moneyForm.type == 2) {
+              if(dataInfo.balance - moneyForm.money  < 0) {
+                this.$message.error('扣除金额不能大于' + dataInfo.balance)
+                return
+              } else {
+                balance = -moneyForm.money
+              }
+            }
+            // console.log(balance)
+            // return
+            updateBalance({
+              userId: this.searchForm.studentId,
+              decimal: balance,
+              memo: moneyForm.remark
+            }).then(res => {
+              let result = res.data
+              if (res.code == 200) {
+                this.$message.success('保存成功')
+                this.__init()
+                this.moneyVisible = false
+              } else {
+                this.$message.error(res.msg)
+              }
+            })
+          }
         } else {
           return false
         }