wolyshaw 4 years ago
parent
commit
c24ead0513
1 changed files with 21 additions and 13 deletions
  1. 21 13
      src/components/save-form/index.vue

+ 21 - 13
src/components/save-form/index.vue

@@ -21,20 +21,23 @@ export default {
     }
   },
   mounted() {
-    const searchs = new Searchs(this.saveKey || this.$route.path)
-    this.searchs = searchs
-    const active = searchs.get()
-    for (const key in active.form) {
-      if (active.form.hasOwnProperty(key)) {
-        const item = active.form[key]
-        this.model[key] = item
-      }
-    }
-    if (this.saveKey) {
-      this.searchs.update(this.$route.path, undefined, 'bind')
-    }
+    this.setFormValue()
   },
   methods: {
+    setFormValue() {
+      const searchs = new Searchs(this.saveKey || this.$route.path)
+      this.searchs = searchs
+      const active = searchs.get()
+      for (const key in active.form) {
+        if (active.form.hasOwnProperty(key)) {
+          const item = active.form[key]
+          this.model[key] = item
+        }
+      }
+      if (this.saveKey) {
+        this.searchs.update(this.$route.path, undefined, 'bind')
+      }
+    },
     submit(evt) {
       evt.stopPropagation()
       evt.stopImmediatePropagation()
@@ -44,12 +47,17 @@ export default {
         this.$listeners.submit(evt)
       }
     },
-    reset() {
+    reset(evt) {
+      evt.stopPropagation()
+      evt.stopImmediatePropagation()
+      evt.preventDefault()
       if (this.$listeners.reset) {
         this.$listeners.reset()
         this.$nextTick(() => {
           this.resetFields()
+          // this.setFormValue()
         })
+        console.log({...this.model})
       } else {
         this.resetFields()
       }