浏览代码

提交代码

guhongwei 5 年之前
父节点
当前提交
8fb9924083

+ 6 - 2
src/layout/government/column.vue

@@ -7,7 +7,7 @@
             <span>栏目列表</span>
           </el-col>
           <el-col :span="12" class="topAdd">
-            <el-button type="primary" size="mini"><i class="el-icon-plus"></i></el-button>
+            <el-button type="primary" size="mini" @click="addData()"><i class="el-icon-plus"></i></el-button>
           </el-col>
         </el-col>
         <el-col :span="24" class="list">
@@ -38,7 +38,11 @@ export default {
   data: () => ({}),
   created() {},
   computed: {},
-  methods: {},
+  methods: {
+    addData() {
+      this.$router.push({ path: '/government/columnDetail' });
+    },
+  },
 };
 </script>
 

+ 97 - 0
src/layout/government/columnDetail.vue

@@ -0,0 +1,97 @@
+<template>
+  <div id="columnDetail">
+    <el-row>
+      <el-col :span="24">
+        <el-col :span="24" class="top">
+          <el-col :span="12" class="topTitle">
+            添加栏目
+          </el-col>
+          <el-col :span="12" class="topBtn">
+            <el-button type="primary" size="mini" @click="returnBtn()">返回</el-button>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="messgae">
+          <el-form ref="form" :model="form" label-width="80px">
+            <el-form-item label="栏目名称">
+              <el-input v-model="form.name"></el-input>
+            </el-form-item>
+            <el-form-item label="所在位置">
+              <el-select v-model="form.site" placeholder="请选择所在位置">
+                <el-option label="最新资讯" value="zixun"></el-option>
+                <el-option label="通知公告" value="tonggao"></el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" @click="onSubmit()">提交</el-button>
+            </el-form-item>
+          </el-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('column');
+export default {
+  name: 'columnDetail',
+  props: {},
+  components: {},
+  data: () => ({
+    form: {},
+  }),
+  created() {
+    // this.search();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  methods: {
+    ...mapActions(['fetch', 'create', 'update']),
+    // async search() {
+    //   if (this.$route.query.id) {
+    //     const res = await this.fetch(this.id);
+    //     this.$set(this, `form`, res.data);
+    //   }
+    // },
+    async onSubmit(form) {
+      let data = this.form;
+      console.log(data);
+      let res;
+      let msg;
+      if (data.id) {
+        res = await this.update(data);
+        msg = `${this.keyWord}修改成功`;
+      } else {
+        res = await this.create(data);
+        msg = `${this.keyWord}添加成功`;
+      }
+      if (this.$checkRes(res, msg)) this.$router.push({ path: '/government/index' });
+    },
+    returnBtn() {
+      this.$router.push({ path: '/government/index' });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  padding: 15px 0;
+}
+.top .topTitle {
+  text-align: left;
+}
+.top .topBtn {
+  text-align: right;
+  padding: 0 5px;
+}
+</style>

+ 19 - 0
src/layout/government/messageDetail.vue

@@ -0,0 +1,19 @@
+<template>
+  <div id="messageDetail">
+    <p>messageDetail</p>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'messageDetail',
+  props: {},
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {},
+};
+</script>
+
+<style lang="less" scoped></style>

+ 4 - 1
src/layout/government/messageInfo.vue

@@ -7,7 +7,7 @@
             <span>信息列表</span>
           </el-col>
           <el-col :span="12" class="topAdd">
-            <el-button type="primary" size="mini"><i class="el-icon-plus"></i></el-button>
+            <el-button type="primary" size="mini" @click="addData()"><i class="el-icon-plus"></i></el-button>
           </el-col>
         </el-col>
         <el-col :span="24" class="list">
@@ -59,6 +59,9 @@ export default {
     handleCurrentChange(val) {
       console.log(`当前页: ${val}`);
     },
+    addData() {
+      this.$router.push({ path: '/government/messageInfoDetail' });
+    },
   },
 };
 </script>

+ 11 - 0
src/router/index.js

@@ -16,6 +16,17 @@ export default new Router({
       path: '/government/index',
       component: () => import('../views/government/index.vue'),
     },
+    // 栏目列表
+    {
+      path: '/government/columnDetail',
+      component: () => import('../views/government/columnDetail.vue'),
+    },
+    // 信息列表
+    {
+      path: '/government/messageInfoDetail',
+      component: () => import('../views/government/messageInfoDetail.vue'),
+    },
+
     // 站点信息
     {
       path: '/site/index',

+ 38 - 0
src/store/column.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  columnInfo: `/api/affairs/column`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.columnInfo}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.columnInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.columnInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.columnInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.columnInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 4 - 0
src/store/index.js

@@ -2,6 +2,8 @@ import Vue from 'vue';
 import Vuex from 'vuex';
 import link from './link';
 import site from './site';
+import news from './news';
+import column from './column';
 
 Vue.use(Vuex);
 
@@ -9,6 +11,8 @@ export default new Vuex.Store({
   modules: {
     link,
     site,
+    news,
+    column,
   },
   state: {},
   mutations: {},

+ 38 - 0
src/store/news.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  newsInfo: `/api/news`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.newsInfo}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.newsInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.newsInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.newsInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.newsInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 40 - 0
src/views/government/columnDetail.vue

@@ -0,0 +1,40 @@
+<template>
+  <div id="columnDetail">
+    <el-row>
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle"></topInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <column></column>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import column from '@/layout/government/columnDetail.vue';
+export default {
+  name: 'columnDetail',
+  props: {},
+  components: {
+    column,
+    topInfo,
+  },
+  data: () => ({
+    topTitle: '添加栏目',
+  }),
+  created() {},
+  computed: {},
+  methods: {},
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  padding: 20px;
+  margin: 10px 20px;
+  border: 1px solid #ccc;
+  width: 96%;
+}
+</style>

+ 22 - 0
src/views/government/messageInfoDetail.vue

@@ -0,0 +1,22 @@
+<template>
+  <div id="messageInfoDetail">
+    <message></message>
+  </div>
+</template>
+
+<script>
+import message from '@/layout/government/messageDetail.vue';
+export default {
+  name: 'messageInfoDetail',
+  props: {},
+  components: {
+    message,
+  },
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {},
+};
+</script>
+
+<style lang="less" scoped></style>

+ 6 - 0
vue.config.js

@@ -30,6 +30,12 @@ module.exports = {
         changeOrigin: true,
         ws: true,
       },
+      '/api/affairs': {
+        target: 'http://10.16.9.108:9002',
+        changeOrigin: true,
+        ws: true,
+        // pathRewrite: { '^/api/affairs': '/api' },
+      },
     },
   },
 };