zaijin пре 2 година
родитељ
комит
f7fe021cc6
1 измењених фајлова са 17 додато и 9 уклоњено
  1. 17 9
      pages/handleMonthly/handleMonthly.vue

+ 17 - 9
pages/handleMonthly/handleMonthly.vue

@@ -137,15 +137,12 @@
 			};
 		},
 		watch: {
-			'form.month'(val) {
-				let freeNum = 0;
-				if (this.monthlyRuleObj.giveFlag && Number(this.monthlyRuleObj.giveFlag) === 1) {
-					let remainNum = Number(val) % Number(this.monthlyRuleObj.minMonth),
-						timesNum = Number(val) / Number(this.monthlyRuleObj.minMonth);
-					if (remainNum === 0) {
-						this.freeMonthNum = Number(timesNum) * Number(this.monthlyRuleObj.giveMonth);
-					}
-				}
+			'form.month':{
+					handler(val){
+						this.calcFreeMonthNum(val)
+					},
+					deep:true,
+					immediate:false
 			}
 		},
 		onLoad(page) {
@@ -310,9 +307,20 @@
 				}).then(res => {
 					if (res.code === 200) {
 						this.monthlyRuleObj = res?.rows[0] ?? {}
+						this.calcFreeMonthNum(this.form.month)
 					}
 				})
 			},
+			calcFreeMonthNum(val){
+				let freeNum = 0;
+				if (this.monthlyRuleObj.giveFlag && Number(this.monthlyRuleObj.giveFlag) === 1) {
+					// let remainNum = Number(val) % Number(this.monthlyRuleObj.minMonth)
+					let	timesNum = parseInt(Number(val) / Number(this.monthlyRuleObj.minMonth));
+					if (timesNum > 0) {
+						this.freeMonthNum = Number(timesNum) * Number(this.monthlyRuleObj.giveMonth);
+					}
+				}
+			},
 			/**
 			 * 提交包月信息
 			 * @date 2022-10-09