guhongwei 5 年之前
父節點
當前提交
998c61b21a

+ 19 - 4
src/layout/government/column.vue

@@ -13,11 +13,20 @@
         <el-col :span="24" class="list">
           <template>
             <el-table :data="columnInfo" style="width: 100%">
-              <el-table-column prop="title" label="栏目列表" align="center"> </el-table-column>
+              <el-table-column label="栏目名称" align="center">
+                <template slot-scope="scoped">
+                  <el-tooltip effect="dark" content="点击查询栏目" placement="left">
+                    <el-col :span="24" @click.native="handleClick(scoped.row)">{{ scoped.row.name }}</el-col>
+                  </el-tooltip>
+                </template>
+              </el-table-column>
+              <!-- <el-table-column prop="name" label="栏目列表" align="center"> </el-table-column> -->
               <el-table-column label="操作" align="center">
-                <template slot-scope="scope">
-                  <el-button type="text" size="small" @click="handleEdit(scope.$index, tableData)"><i class="el-icon-edit"></i></el-button>
-                  <el-button type="text" size="small" @click.prevent="deleteRow(scope.$index, tableData)"><i class="el-icon-delete"></i></el-button>
+                <template slot-scope="scoped">
+                  <el-button type="text" size="small" @click="$router.push({ path: '/government/columnDetail', query: { id: scoped.row.id } })"
+                    ><i class="el-icon-edit"></i
+                  ></el-button>
+                  <el-button type="text" size="small" @click="handleDelete(scoped.row)"><i class="el-icon-delete"></i></el-button>
                 </template>
               </el-table-column>
             </el-table>
@@ -42,6 +51,12 @@ export default {
     addData() {
       this.$router.push({ path: '/government/columnDetail' });
     },
+    handleDelete(item) {
+      this.$emit('delete', item);
+    },
+    handleClick(row) {
+      this.$emit('list', { data: row });
+    },
   },
 };
 </script>

+ 8 - 39
src/layout/government/columnDetail.vue

@@ -32,49 +32,18 @@
 </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;
-    },
+  props: {
+    form: null,
   },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
   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' });
+    onSubmit() {
+      this.$emit('submitDate', { data: this.form, id: this.form.id });
     },
     returnBtn() {
       this.$router.push({ path: '/government/index' });

+ 56 - 4
src/layout/government/messageDetail.vue

@@ -1,19 +1,71 @@
 <template>
   <div id="messageDetail">
-    <p>messageDetail</p>
+    <el-row>
+      <el-col :span="24">
+        <el-col :span="24" class="topBtn">
+          <el-button type="primary" size="mini" @click="returnBtn()">返回</el-button>
+        </el-col>
+      </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.title"></el-input>
+            </el-form-item>
+            <el-form-item label="来源">
+              <el-input v-model="form.orgin"></el-input>
+            </el-form-item>
+            <el-form-item label="正文">
+              <el-input v-model="form.content"></el-input>
+            </el-form-item>
+            <el-form-item label="所属栏目">
+              <el-select v-model="form.column_id" filterable @change="selectChild">
+                <el-option v-for="(item, index) in columnList" :key="index" :value="item.id" :label="item.name"></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>
 export default {
   name: 'messageDetail',
-  props: {},
+  props: {
+    form: null,
+    columnList: null,
+  },
   components: {},
   data: () => ({}),
   created() {},
   computed: {},
-  methods: {},
+  methods: {
+    returnBtn() {
+      this.$router.push({ path: '/government/index' });
+    },
+    onSubmit() {
+      this.$emit('submitDate', { data: this.form, id: this.form.id });
+    },
+    selectChild(column_id) {
+      let res = this.columnList.filter(fil => fil.id === column_id);
+      if (res.length > 0) {
+        console.log(res[0].name);
+        this.$set(this.form, `column_name`, res[0].name);
+      }
+      this.$forceUpdate();
+    },
+  },
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.topBtn {
+  text-align: right;
+  padding: 15px 5px;
+}
+</style>

+ 11 - 5
src/layout/government/messageInfo.vue

@@ -14,12 +14,14 @@
           <template>
             <el-table :data="message" style="width: 100%">
               <el-table-column prop="title" label="标题" align="center"> </el-table-column>
-              <el-table-column prop="column" label="所属栏目" align="center"> </el-table-column>
-              <el-table-column prop="state" label="状态" align="center"> </el-table-column>
+              <el-table-column prop="column_name" label="所属栏目" align="center"> </el-table-column>
+              <!-- <el-table-column prop="state" label="状态" align="center"> </el-table-column> -->
               <el-table-column label="操作" align="center">
                 <template slot-scope="scope">
-                  <el-button type="text" size="small" @click="handleEdit(scope.$index, tableData)"><i class="el-icon-edit"></i></el-button>
-                  <el-button type="text" size="small" @click.prevent="deleteRow(scope.$index, tableData)"><i class="el-icon-delete"></i></el-button>
+                  <el-button type="text" size="small" @click="$router.push({ path: '/government/messageInfoDetail', query: { id: scope.row.id } })"
+                    ><i class="el-icon-edit"></i
+                  ></el-button>
+                  <el-button type="text" size="small" @click="handleDelete(scope.row)"><i class="el-icon-delete"></i></el-button>
                 </template>
               </el-table-column>
             </el-table>
@@ -29,7 +31,7 @@
                 @current-change="handleCurrentChange"
                 :current-page="currentPage"
                 layout="total, prev, pager, next, jumper"
-                :total="1"
+                :total="total"
               >
               </el-pagination>
             </el-col>
@@ -45,6 +47,7 @@ export default {
   name: 'messageInfo',
   props: {
     message: null,
+    total: null,
   },
   components: {},
   data: () => ({
@@ -62,6 +65,9 @@ export default {
     addData() {
       this.$router.push({ path: '/government/messageInfoDetail' });
     },
+    handleDelete(item) {
+      this.$emit('delete', item);
+    },
   },
 };
 </script>

+ 1 - 0
src/layout/layout-part/menus.vue

@@ -3,6 +3,7 @@
     <el-menu :default-active="thisRouter()" class="el-menu-vertical-demo" :router="false" :default-openeds="defalutMenu" @select="to">
       <el-menu-item index="/"> <i class="el-icon-s-grid"></i>首页 </el-menu-item>
       <el-menu-item index="/government/index"> <i class="el-icon-s-grid"></i>科技政务</el-menu-item>
+      <el-menu-item index="/policy/index"> <i class="el-icon-s-grid"></i>科技政策</el-menu-item>
       <el-menu-item index="/site/index"> <i class="el-icon-s-grid"></i>站点信息管理</el-menu-item>
       <el-menu-item index="/links/index"> <i class="el-icon-attract"></i>友情链接管理</el-menu-item>
     </el-menu>

+ 1 - 1
src/store/link.js

@@ -3,7 +3,7 @@ import Vuex from 'vuex';
 import _ from 'lodash';
 Vue.use(Vuex);
 const api = {
-  links: `/api/link`,
+  links: `/api/setting/link`,
 };
 const state = () => ({});
 const mutations = {};

+ 3 - 3
src/store/news.js

@@ -3,14 +3,14 @@ import Vuex from 'vuex';
 import _ from 'lodash';
 Vue.use(Vuex);
 const api = {
-  newsInfo: `/api/news`,
+  newsInfo: `/api/affairs/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 });
+  async query({ commit }, { skip = 0, limit, column_id, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.newsInfo}`, { skip, limit, column_id, ...info });
     return res;
   },
   async create({ commit }, payload) {

+ 2 - 2
src/store/site.js

@@ -3,8 +3,8 @@ import Vuex from 'vuex';
 import _ from 'lodash';
 Vue.use(Vuex);
 const api = {
-  site: `/api/set`,
-  shows: `/api/set/show`,
+  site: `/api/setting/set`,
+  shows: `/api/setting/set/show`,
 };
 const state = () => ({});
 const mutations = {};

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

@@ -5,7 +5,7 @@
         <topInfo :topTitle="topTitle"></topInfo>
       </el-col>
       <el-col :span="24" class="main">
-        <column></column>
+        <column :form="form" @submitDate="onSubmit"></column>
       </el-col>
     </el-row>
   </div>
@@ -14,6 +14,8 @@
 <script>
 import topInfo from '@/layout/public/top.vue';
 import column from '@/layout/government/columnDetail.vue';
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('column');
 export default {
   name: 'columnDetail',
   props: {},
@@ -23,10 +25,44 @@ export default {
   },
   data: () => ({
     topTitle: '添加栏目',
+    form: {},
   }),
-  created() {},
-  computed: {},
-  methods: {},
+  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' });
+    },
+  },
 };
 </script>
 

+ 45 - 22
src/views/government/index.vue

@@ -6,10 +6,10 @@
       </el-col>
       <el-col :span="24" class="main">
         <el-col :span="7" class="column">
-          <column :columnInfo="columnInfo"></column>
+          <column :columnInfo="columnInfo" @delete="deleteData" @list="handleList"></column>
         </el-col>
         <el-col :span="17" class="message">
-          <messageInfo :message="message"></messageInfo>
+          <messageInfo :message="message" :total="total" @delete="deleteMess"></messageInfo>
         </el-col>
       </el-col>
     </el-row>
@@ -20,7 +20,9 @@
 import topInfo from '@/layout/public/top.vue';
 import column from '@/layout/government/column.vue';
 import messageInfo from '@/layout/government/messageInfo.vue';
-
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapColumn } = createNamespacedHelpers('column');
+const { mapActions: mapNews } = createNamespacedHelpers('news');
 export default {
   name: 'index',
   props: {},
@@ -31,27 +33,48 @@ export default {
   },
   data: () => ({
     topTitle: '科技政务',
-    columnInfo: [
-      {
-        title: '栏目标题',
-      },
-    ],
-    message: [
-      {
-        title: '标题',
-        column: '所属栏目',
-        state: '未审核',
-      },
-      {
-        title: '十条数据',
-        column: '所属栏目',
-        state: '未审核',
-      },
-    ],
+    columnInfo: [],
+    message: [],
+    total: 0,
+    leftId: null,
   }),
-  created() {},
+  created() {
+    this.search();
+  },
   computed: {},
-  methods: {},
+  methods: {
+    ...mapColumn(['query', 'delete', 'fetch']),
+    ...mapNews({ queryList: 'query', deleteList: 'delete' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `columnInfo`, res.data);
+      }
+    },
+    async deleteData(item) {
+      const res = await this.delete(item.id);
+      this.$checkRes(res, '删除成功', '删除失败');
+      this.search();
+    },
+    handleList({ data }) {
+      this.$set(this, `leftId`, data.id);
+      this.searchRight();
+    },
+    async searchRight({ skip = 0, limit = 10, column_id } = {}) {
+      const res = await this.queryList({ skip, limit, column_id: this.leftId });
+      for (const val of res.data) {
+        const result = await this.fetch(val.column_id);
+        val.column_name = result.data.name;
+      }
+      this.$set(this, `message`, res.data);
+      this.$set(this, `total`, res.total);
+    },
+    async deleteMess(item) {
+      const res = await this.deleteList(item.id);
+      this.$checkRes(res, '删除成功', '删除失败');
+      this.search();
+    },
+  },
 };
 </script>
 

+ 73 - 6
src/views/government/messageInfoDetail.vue

@@ -1,22 +1,89 @@
 <template>
   <div id="messageInfoDetail">
-    <message></message>
+    <el-row>
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle"></topInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <message :form="form" :columnList="columnList" @submitDate="onSubmit"></message>
+      </el-col>
+    </el-row>
   </div>
 </template>
 
 <script>
+import topInfo from '@/layout/public/top.vue';
 import message from '@/layout/government/messageDetail.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapColumn } = createNamespacedHelpers('column');
+const { mapActions: mapNews } = createNamespacedHelpers('news');
 export default {
   name: 'messageInfoDetail',
   props: {},
   components: {
     message,
+    topInfo,
+  },
+  data: () => ({
+    topTitle: '添加信息',
+    form: {},
+    columnList: [],
+  }),
+  created() {
+    this.search();
+    this.searchColumn();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  methods: {
+    ...mapNews(['fetch', 'create', 'update']),
+    ...mapColumn({ queryList: 'query' }),
+    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' });
+    },
+    async searchColumn({ ...info } = {}) {
+      const res = await this.queryList({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `columnList`, res.data);
+      }
+    },
   },
-  data: () => ({}),
-  created() {},
-  computed: {},
-  methods: {},
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.top {
+  padding: 0 0 10px 0;
+}
+.main {
+  padding: 20px;
+  margin: 10px 20px;
+  border: 1px solid #ccc;
+  width: 96%;
+}
+</style>

+ 1 - 1
vue.config.js

@@ -25,7 +25,7 @@ module.exports = {
       '/files': {
         target: 'http://smart.cc-lotus.info',
       },
-      '/api': {
+      '/api/setting': {
         target: 'http://10.16.9.108:9000',
         changeOrigin: true,
         ws: true,