Преглед изворни кода

签到管理 抽奖配置 提示概率总和等于100%

DESKTOP-O04BTUJ\muzen пре 2 година
родитељ
комит
a1aec07c9c
1 измењених фајлова са 28 додато и 17 уклоњено
  1. 28 17
      src/views/registration/lottery/detail.vue

+ 28 - 17
src/views/registration/lottery/detail.vue

@@ -20,7 +20,8 @@
         <span class="input-number">次</span>
       </el-form-item>
       <el-form-item label="活动规则:" prop="rule">
-        <el-input v-model="form.rule" type="textarea" :autosize="{ minRows: 5, maxRows: 10}" :maxlength="150" show-word-limit placeholder="请输入活动规则" />
+        <el-input v-model="form.rule" type="textarea" :autosize="{ minRows: 5, maxRows: 10}" :maxlength="150"
+          show-word-limit placeholder="请输入活动规则" />
       </el-form-item>
       <el-form-item label="转盘数量:" prop="goodNum">
         <el-select v-model.number="form.goodNum" placeholder="请选择转盘数量" :disabled="form.id ? true : false"
@@ -58,7 +59,7 @@
           </el-table-column>
           <el-table-column label="中奖概率 / %" align="center">
             <template slot-scope="scope">
-              <el-input v-model="scope.row.rate" />
+              <el-input-number style="width: 120px" v-model="scope.row.rate" :controls="false" />
             </template>
           </el-table-column>
         </el-table>
@@ -166,6 +167,7 @@ export default {
 
     // 更改转盘数量
     getChange() {
+      this.form.lotteryConfigGoodList = []
       for (let i = 0; i < this.form.goodNum; i++) {
         this.form.lotteryConfigGoodList.push({})
       }
@@ -183,24 +185,33 @@ export default {
 
     // 确定
     getSubmit() {
+      let rate = 0
+      this.form.lotteryConfigGoodList.map(i => {
+        rate += i.rate
+      })
       this.$refs.form.validate((valid) => {
         if (valid) {
-          this.form.startTime = this.form.date[0]
-          this.form.endTime = this.form.date[1]
-          delete this.form.date
-          if (this.form.id) {
-            edit(this.form).then(res => {
-              if (res.code === 0) {
-                this.$message.success('编辑成功!')
-              }
-            })
+          if (rate !== 100) {
+            this.$message.error('中奖概率总和要满足100%')
           } else {
-            create(this.form).then(res => {
-              if (res.code === 0) {
-                this.$message.success('新增成功!')
-                this.cancel()
-              }
-            })
+            this.form.startTime = this.form.date[0]
+            this.form.endTime = this.form.date[1]
+            delete this.form.date
+            if (this.form.id) {
+              edit(this.form).then(res => {
+                if (res.code === 0) {
+                  this.$message.success('编辑成功!')
+                  this.getList()
+                }
+              })
+            } else {
+              create(this.form).then(res => {
+                if (res.code === 0) {
+                  this.$message.success('新增成功!')
+                  this.cancel()
+                }
+              })
+            }
           }
         } else {
           return false