Procházet zdrojové kódy

生效时的活动数量不可减少

DESKTOP-SVI9JE1\muzen před 2 roky
rodič
revize
1d28fcbb89
1 změnil soubory, kde provedl 17 přidání a 4 odebrání
  1. 17 4
      src/views/operation/activity/detail.vue

+ 17 - 4
src/views/operation/activity/detail.vue

@@ -40,8 +40,9 @@
           <el-table-column label="领取数量" align="center">
             <template slot-scope="scope">
               <el-form-item :prop="`deviceRespList.${scope.$index}.totalNum`"
-                :rules="{ required: true, trigger: 'change' }">
-                <el-input-number v-model="scope.row.totalNum" :controls="false" :min="1" placeholder="请输入领取数量" />
+                :rules="[{ type: 'number', required: true, min: num[scope.$index] ? num[scope.$index] : 1, trigger: 'blur' }]">
+                <el-input-number v-model="scope.row.totalNum" :controls="false" :min="1" placeholder="请输入领取数量"
+                  @change="handleChange($event, scope.$index)" />
               </el-form-item>
             </template>
           </el-table-column>
@@ -76,6 +77,8 @@ export default {
       types: [2, 4],
       // 生效期内禁止修改活动设备
       disabledActivity: this.$route.query.activityState == 0 ? true : false,
+      // 生效期内领取数量禁止下调
+      num: [],
       // 只读
       disabled: Boolean(this.$route.query.boolean),
       // 校验
@@ -93,13 +96,13 @@ export default {
     }
   },
   watch: {
-    // 禁用已关联设备
     'form.deviceRespList': {
       handler(val) {
         for (let i in this.devOptions) {
           this.devOptions[i].disabled = false
         }
-        val.map(i => {
+        // 禁用已关联设备
+        val.map((i, index) => {
           if (i.deviceId) {
             let index = this.devOptions.findIndex(j => j.value === i.deviceId)
             this.devOptions[index].disabled = true
@@ -120,6 +123,9 @@ export default {
       detail(this.$route.query.id).then(res => {
         if (res.code === 0) {
           this.form = res.data
+          res.data.deviceRespList.map(i => {
+            this.num.push(i.totalNum)
+          })
         }
       })
     },
@@ -134,6 +140,13 @@ export default {
       this.form.deviceRespList.push({})
     },
 
+    // 已生效的活动 设备数量不能修改的比之前小
+    handleChange(e, index) {
+      if (this.disabledActivity && this.num[index] > e) {
+        this.$message.error('已生效活动,当前领取数量不可减少')
+      }
+    },
+
     // 删除
     getDelete(deviceId, index) {
       this.form.deviceRespList.splice(index, 1)