فهرست منبع

Merge branch 'master' of http://git.cc-lotus.info/live-platform/live-cms

guhongwei 4 سال پیش
والد
کامیت
47a939b9a3
1فایلهای تغییر یافته به همراه33 افزوده شده و 3 حذف شده
  1. 33 3
      src/views/contact/index.vue

+ 33 - 3
src/views/contact/index.vue

@@ -38,6 +38,7 @@
 import wangEditor from '@/components/wang-editor.vue';
 import topInfo from '@/layout/public/top.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: contact } = createNamespacedHelpers('contact');
 export default {
   name: 'index',
   props: {},
@@ -51,10 +52,39 @@ export default {
       rules: {},
     };
   },
-  created() {},
+  created() {
+    this.searchInfo();
+  },
   methods: {
-    submitForm() {
-      alert(this.form);
+    ...contact(['query', 'update', 'create']),
+    async searchInfo({ skip = 0, limit = 1, ...info } = {}) {
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        if (res.data.length > 0) {
+          this.$set(this, `form`, res.data[0]);
+        }
+      }
+    },
+    async submitForm() {
+      if (this.form.id) {
+        const res = await this.update(this.form);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '更新信息成功',
+            type: 'success',
+          });
+          this.searchInfo();
+        }
+      } else {
+        const res = await this.create(this.form);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '添加信息成功',
+            type: 'success',
+          });
+          this.searchInfo();
+        }
+      }
     },
   },
   computed: {