Browse Source

mock的数据跟新

wangziqian 5 years ago
parent
commit
d8ce415f55
1 changed files with 21 additions and 5 deletions
  1. 21 5
      src/views/mock/httprule.vue

+ 21 - 5
src/views/mock/httprule.vue

@@ -634,15 +634,31 @@ export default {
             delete this.dataFrom.expression2
             delete this.dataFrom.judgeType
             delete this.dataFrom.judgeValue
-            updateRule(this.dataFrom).then(() => {
-              this.getList()
-              this.dialogFormVisible = false
-              this.$notify({ title: 'Success', message: 'Update Successfully', type: 'success', duration: 2000 })
-            })
+            if (this.headerList.length > 0) {
+              this.dataFrom.callbackInfo.header = JSON.stringify(this.headerList)
+            }
+            if (this.paramsList.length > 0) {
+              this.dataFrom.callbackInfo.params = JSON.stringify(this.paramsList)
+            }
+            if (this.bodyObj !== null && this.bodyObj !== '') {
+              this.dataFrom.callbackInfo.body = this.bodyObj
+            }
+            if (!this.ruleForm.isCallback) {
+              this.dataFrom.callbackInfo = null
+            }
+            this.updateRule()
           }
         })
       }
     },
+    async updateRule() {
+      const res = await updateRule(this.dataFrom)
+      if (res.code === 200) {
+        this.getList()
+        this.dialogFormVisible = false
+        this.$notify({ title: 'Success', message: 'Update Successfully', type: 'success', duration: 2000 })
+      }
+    },
     formatJson(filterVal, jsonData) {
       return jsonData.map(v => filterVal.map(j => {
         if (j === 'timestamp') {