瀏覽代碼

mock的数据跟新

wangziqian 5 年之前
父節點
當前提交
d8ce415f55
共有 1 個文件被更改,包括 21 次插入5 次删除
  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') {