lilei 2 gadi atpakaļ
vecāks
revīzija
16d1e5776b

+ 20 - 10
src/views/inventoryManagement/intelligentReplenishment/edit.vue

@@ -129,14 +129,17 @@ export default {
           this.form.stockPredictRange = res.data.stockPredictRange != undefined ? Number(res.data.stockPredictRange) : 1
           if (res.data.state == 'RUN') {
             this.current = 2
+            this.spinning = false
           } else {
             this.current = 0
+            if (this.form.stockPredictRange == 0) {
+              this.getTrendSn()
+            }
           }
         } else {
           this.detailData = null
+          this.spinning = false
         }
-        this.getTrendSn()
-        this.spinning = false
       })
     },
     // 产品范围 ok
@@ -144,6 +147,9 @@ export default {
       predictRangeSave(params).then(res => {
         if (res.status == 200) {
           this.$refs.productRange.refreshList()
+          if (this.current == 0) { //  产品设置
+            this.handleSave(true)
+          }
         }
       })
     },
@@ -151,12 +157,7 @@ export default {
     handleNext () {
       const _this = this
       if (this.current == 0) { //  产品设置
-        const params = {
-          id: this.detailData.id,
-          stockPredictSn: this.$route.params.sn,
-          stockPredictRange: this.form.stockPredictRange
-        }
-        this.handleSave(params)
+        this.handleSave(false)
       } else if (this.current == 1) { //  参数设置
         this.$refs.ruleForm.validate(valid => {
           if (valid) {
@@ -177,11 +178,18 @@ export default {
       }
     },
     // 保存
-    handleSave (params) {
+    handleSave (noNext) {
+      const params = {
+        id: this.detailData.id,
+        stockPredictSn: this.$route.params.sn,
+        stockPredictRange: this.form.stockPredictRange
+      }
       this.spinning = true
       predictSave(params).then(res => {
         if (res.status == 200) {
-          this.current++
+          if (!noNext) {
+            this.current++
+          }
           this.spinning = false
         } else {
           this.spinning = false
@@ -217,6 +225,7 @@ export default {
     },
     // 获取默认服务水平
     getTrendSn () {
+      this.spinning = true
       predictTrendList({ defaultFlag: 1 }).then(res => {
         if (res.status == 200) {
           this.form.trendSn = (res.data && res.data[0] && res.data[0].trendSn) ? res.data[0].trendSn : undefined
@@ -227,6 +236,7 @@ export default {
           this.form.serviceLevel = ''
           this.form.safetyFactor = ''
         }
+        this.spinning = false
       })
     },
     setTableH () {