wxy 4 jaren geleden
bovenliggende
commit
95d82b973d
5 gewijzigde bestanden met toevoegingen van 54 en 41 verwijderingen
  1. 2 2
      src/layout/shuju/fenleis.vue
  2. 2 1
      src/layout/shuju/rightcont.vue
  3. 5 0
      src/router/index.js
  4. 17 22
      src/views/shuju/shuju.vue
  5. 28 16
      src/views/shuju/shujulist.vue

+ 2 - 2
src/layout/shuju/fenleis.vue

@@ -6,8 +6,8 @@
     </el-col>
     <el-col>
       <el-menu default-active="1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" text-color="#215299" active-text-color="#215299">
-        <el-menu-item index="1" v-for="(item, index) in liebiaoList" :key="index"
-          ><span slot="title" @click="clickUrl(item.id)">{{ item.name }}</span></el-menu-item
+        <el-menu-item index="1" v-for="(item, index) in liebiaoList" :key="index" @click="clickUrl(item.id)"
+          ><span slot="title">{{ item.name }}</span></el-menu-item
         >
       </el-menu>
     </el-col>

+ 2 - 1
src/layout/shuju/rightcont.vue

@@ -40,7 +40,8 @@ export default {
   components: {},
   data: () => ({
     currentPage: 1,
-    pageSize: 15,
+    //这一页显示几条数据
+    pageSize: 10,
     origin: [],
     list: [],
   }),

+ 5 - 0
src/router/index.js

@@ -4,6 +4,11 @@ import checkLogin from '@common/router/before';
 
 Vue.use(VueRouter);
 
+const originalPush = VueRouter.prototype.push;
+VueRouter.prototype.push = function push(location) {
+  return originalPush.call(this, location).catch(err => err);
+};
+
 const live = [
   {
     path: '/live',

+ 17 - 22
src/views/shuju/shuju.vue

@@ -60,11 +60,12 @@ export default {
         date: '2019-01-02',
       },
     ],
+    //科技政务
+    science: [],
   }),
   async created() {
-    this.searchSite();
-    await this.policyColumn();
-    await this.affairsColumn();
+    await this.searchSite();
+    await this.kjzwSearch();
   },
   computed: {},
   methods: {
@@ -72,8 +73,8 @@ export default {
     ...mappolicyColumn({ policyColumns: 'query', policyfetch: 'fetch' }),
     ...mapAffairsColumn({ affairsColumns: 'query', affairsInfo: 'fetch' }),
     ...mapAffairsNews({ affairsList: 'query' }),
-    // 查询站点信息
-    async searchSite() {
+    // 查询站点信息+列表查询+科技政务栏目
+    async searchSite({ ...info } = {}) {
       let res = await this.showInfo();
       let object = JSON.parse(JSON.stringify(res.data));
       if (object) {
@@ -81,28 +82,22 @@ export default {
       } else {
         this.$message.error(res.errmsg ? res.errmsg : 'error');
       }
-    },
-    async policyColumn({ ...info } = {}) {
-      const res = await this.policyColumns({ ...info });
+      res = await this.policyColumns({ ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `liebiaoList`, res.data);
+        // this.kjzwSearch();
       }
-    },
-    // 查询科技政务栏目
-    async affairsColumn({ ...info } = {}) {
-      const res = await this.affairsColumns({ ...info });
-      for (const val of res.data) {
-        this.kjzwSearch({ column_id: val.id, site: val.site });
+      res = await this.affairsColumns({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `science`, res.data);
       }
     },
-    async kjzwSearch({ skip = 0, limit = 10, column_id, site } = {}) {
-      if (site === 'tzgg') {
-        const res = await this.affairsList({ skip, limit, column_id: column_id });
-        for (const val of res.data) {
-          const result = await this.affairsInfo(val.column_id);
-          val.column_name = result.data.name;
-        }
-        this.$set(this, `${site}List`, res.data);
+    //科技政务信息查询
+    async kjzwSearch() {
+      let tzgg = this.science.find(i => i.site == 'tzgg');
+      let res = await this.affairsList({ skip: 0, limit: 8, column_id: tzgg.id });
+      if (this.$checkRes(res)) {
+        this.$set(this, `${tzgg.site}List`, res.data);
       }
     },
   },

+ 28 - 16
src/views/shuju/shujulist.vue

@@ -7,7 +7,7 @@
       :columnName="columnName"
       :contentList="contentList"
       :total="total"
-      :columnTitle="columnTitle"
+      :columnTitle="columnName"
       :policyInfo="policyInfo"
       @clickLists="submit"
       @fetch="fetchInfo"
@@ -31,16 +31,19 @@ export default {
     info: {},
     liebiaoList: [],
     display: 'list',
+    // 右侧栏目标题
     columnName: '',
     contentList: [],
-    total: 1,
+    total: 0,
     leftId: '',
     columnTitle: '',
     policyInfo: {},
+    // 左侧栏目列表
+    nativeList: [],
   }),
   async created() {
     this.searchSite();
-    await this.policyColumn();
+    // await this.policyColumn();
     await this.defaultColumn();
   },
   computed: {},
@@ -48,8 +51,8 @@ export default {
     ...mapSite(['showInfo']),
     ...mappolicyColumn({ policyColumns: 'query', policyfetch: 'fetch' }),
     ...mappolicyNews({ policyNew: 'query', newsFetch: 'fetch' }),
-    // 查询站点信息
-    async searchSite() {
+    // 查询站点信息+分类导航栏目+
+    async searchSite({ ...info } = {}) {
       let res = await this.showInfo();
       let object = JSON.parse(JSON.stringify(res.data));
       if (object) {
@@ -57,13 +60,19 @@ export default {
       } else {
         this.$message.error(res.errmsg ? res.errmsg : 'error');
       }
-    },
-    async policyColumn({ ...info } = {}) {
-      const res = await this.policyColumns({ ...info });
+      res = await this.policyColumns({ ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `liebiaoList`, res.data);
       }
     },
+    // async policyColumn({ ...info } = {}) {
+    //   const res = await this.policyColumns({ ...info });
+    //   console.log(res);
+    //   if (this.$checkRes(res)) {
+    //     this.$set(this, `liebiaoList`, res.data);
+    //   }
+    // },
+    //点击左侧存储栏目id,并查询右侧信息
     submit({ id }) {
       this.$set(this, `leftId`, id);
       this.display = 'list';
@@ -71,15 +80,18 @@ export default {
     },
     async searchRight({ skip = 0, limit = 10, column_id } = {}) {
       const res = await this.policyNew({ column_id: this.leftId });
-      for (const val of res.data) {
-        const result = await this.policyfetch(val.column_id);
-        val.column_name = result.data.name;
-      }
-      this.$set(this, `contentList`, res.data);
-      this.$set(this, `total`, res.data.length);
-      for (const val of res.data) {
-        this.$set(this, `columnName`, val.column_name);
+      console.log(res);
+      let columnName = this.liebiaoList.find(i => i.id == this.leftId);
+      if (this.$checkRes(res)) {
+        this.$set(this, `contentList`, res.data);
+        this.$set(this, `total`, res.total);
+        this.$set(this, `columnName`, columnName.name);
       }
+      // this.$set(this, `contentList`, res.data);
+      // this.$set(this, `total`, res.data.length);
+      // for (const val of res.data) {
+      //   this.$set(this, `columnName`, val.column_name);
+      // }
     },
     async defaultColumn() {
       if (!(this.liebiaoList.length > 0)) return;