|
@@ -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: {
|