1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="top">
- <topInfo :topTitle="topTitle"></topInfo>
- </el-col>
- <el-col :span="24" class="main">
- <siteMain :form="form" @submitDate="submit" :loading="loading"></siteMain>
- </el-col>
- </el-row>
- </div>
- </template>
- <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: {},
- components: {
- topInfo, //头部信息
- siteMain, //站点信息
- },
- data: () => ({
- topTitle: '站点信息管理',
- form: {},
- loading: false,
- }),
- created() {
- this.search();
- },
- computed: {
- keyWord() {
- let meta = this.$route.meta;
- let main = meta.title || '';
- return main;
- },
- },
- methods: {
- ...mapActions(['showInfo', 'create', 'update']),
- async search() {
- let res = await this.showInfo();
- let object = JSON.parse(JSON.stringify(res.data));
- if (object) {
- this.$set(this, `form`, res.data);
- }
- this.$set(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>
- <style lang="less" scoped>
- .main {
- padding: 20px;
- margin: 10px 20px;
- border: 1px solid #ccc;
- width: 96%;
- }
- </style>
|