|
@@ -5,7 +5,7 @@
|
|
|
<topInfo :topTitle="topTitle"></topInfo>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="main">
|
|
|
- <siteMain :form="form"></siteMain>
|
|
|
+ <siteMain :form="form" @submitDate="submit" :loading="loading"></siteMain>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
@@ -14,7 +14,8 @@
|
|
|
<script>
|
|
|
import topInfo from '@/layout/public/top.vue';
|
|
|
import siteMain from '@/layout/site/siteMain.vue';
|
|
|
-
|
|
|
+import { createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions } = createNamespacedHelpers('site');
|
|
|
export default {
|
|
|
name: 'index',
|
|
|
props: {},
|
|
@@ -25,10 +26,39 @@ export default {
|
|
|
data: () => ({
|
|
|
topTitle: '站点信息管理',
|
|
|
form: {},
|
|
|
+ loading: true,
|
|
|
}),
|
|
|
- created() {},
|
|
|
- computed: {},
|
|
|
- methods: {},
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ keyWord() {
|
|
|
+ let meta = this.$route.meta;
|
|
|
+ let main = meta.title || '';
|
|
|
+ return main;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions(['showInfo', 'create', 'update']),
|
|
|
+ async search() {
|
|
|
+ this.loading = false;
|
|
|
+ const res = await this.showInfo();
|
|
|
+ this.$set(this, `form`, res.data);
|
|
|
+ this.loading = true;
|
|
|
+ },
|
|
|
+ async submit({ id, data }) {
|
|
|
+ let res;
|
|
|
+ let msg;
|
|
|
+ if (id) {
|
|
|
+ res = await this.update(data);
|
|
|
+ msg = `${this.keyWord}修改成功`;
|
|
|
+ } else {
|
|
|
+ res = await this.create(data);
|
|
|
+ msg = `${this.keyWord}添加成功`;
|
|
|
+ }
|
|
|
+ this.$checkRes(res, msg);
|
|
|
+ },
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|