guhongwei 4 tahun lalu
induk
melakukan
4871cf2350

+ 1 - 1
src/components/government/governmentDetail.vue

@@ -18,7 +18,7 @@
         <div class="w_1200">
           <el-col :span="5" class="left">
             <el-col :span="24" class="leftTop">
-              <native :nativeList="nativeList"></native>
+              <native :nativeList="nativeList" v-on="$listeners"></native>
             </el-col>
             <el-col :span="24" class="leftDiao">
               <examine></examine>

+ 3 - 3
src/layout/government/native.vue

@@ -7,7 +7,7 @@
     <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 nativeList" :key="index"
-          ><span slot="title" @click="clickUrl()">{{ item.name }}</span></el-menu-item
+          ><span slot="title" @click="clickUrl(item)">{{ item.name }}</span></el-menu-item
         >
       </el-menu>
     </el-col>
@@ -27,8 +27,8 @@ export default {
   created() {},
   computed: {},
   methods: {
-    clickUrl() {
-      this.$router.push({ path: '/government/governmentList' });
+    clickUrl(data) {
+      this.$emit('clickUrl', data);
     },
     handleOpen(key, keyPath) {
       console.log(key, keyPath);

+ 2 - 2
src/layout/government/natives.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 nativeList" :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 nativeList" :key="index" @click="clickUrl(item.id)"
+          ><span slot="title">{{ item.name }}</span></el-menu-item
         >
       </el-menu>
     </el-col>

+ 21 - 28
src/views/government/government.vue

@@ -29,8 +29,12 @@ export default {
     governmentDetail,
   },
   data: () => ({
+    // 站点信息
     info: {},
-    leftId: '',
+    // 友情链接
+    linkList: [],
+    // 科技政务栏目
+    affairsCol: [],
     // 图片新闻
     tpxwList: [],
     // 创新吉林
@@ -119,13 +123,9 @@ export default {
         pic: require('@/assets/zw8.png'),
       },
     ],
-    // 友情链接
-    linkList: [],
   }),
   created() {
-    this.searchSite();
-    this.searchLink();
-    this.searchColumn();
+    this.search();
   },
   computed: {},
   methods: {
@@ -133,39 +133,32 @@ export default {
     ...mapLink({ linksList: 'query' }),
     ...mapColumn({ columnList: 'query', columnInfo: 'fetch' }),
     ...mapNews({ newsList: 'query' }),
-    // 查询站点信息
-    async searchSite() {
+    // 查询站点信息+友情链接
+    async search({ ...info } = {}) {
       let res = await this.showInfo();
       let object = JSON.parse(JSON.stringify(res.data));
       if (object) {
         this.$set(this, `info`, res.data);
-      } else {
-        this.$message.error(res.errmsg ? res.errmsg : 'error');
       }
-    },
-    //查询标题
-    async searchLink({ ...info } = {}) {
-      const res = await this.linksList({ ...info });
+      res = await this.linksList({ skip: 0, limit: 4 });
       if (this.$checkRes(res)) {
         this.$set(this, `linkList`, res.data);
       }
-    },
-    // 查询科技政务栏目
-    async searchColumn({ ...info } = {}) {
-      const res = await this.columnList({ ...info });
-      for (const val of res.data) {
-        this.tpxwSearch({ column_id: val.id, site: val.site });
+      // 科技政务栏目
+      res = await this.columnList({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `affairsCol`, res.data);
+        this.searchaffnews();
       }
     },
-    // 查询信息列表
-    async tpxwSearch({ skip = 0, limit = 10, column_id, site } = {}) {
-      const res = await this.newsList({ column_id: column_id });
-      for (const val of res.data) {
-        const result = await this.columnInfo(val.column_id);
-        val.column_name = result.data.name;
+    async searchaffnews() {
+      let column = this.affairsCol;
+      for (const val of column) {
+        let res = await this.newsList({ skip: 0, limit: 8, column_id: val.id });
+        if (this.$checkRes(res)) {
+          this.$set(this, `${val.site}List`, res.data);
+        }
       }
-      this.$set(this, `${site}List`, res.data);
-      console.log(res.data);
     },
   },
 };

+ 39 - 34
src/views/government/governmentDetail.vue

@@ -1,6 +1,12 @@
 <template>
   <div id="governmentDetail">
-    <governmentDetail-layout :info="info" :nativeList="nativeList" :columnTitle="columnTitle" :governmentDetail="governmentDetail"></governmentDetail-layout>
+    <governmentDetail-layout
+      :info="info"
+      :nativeList="nativeList"
+      :columnTitle="columnTitle"
+      :governmentDetail="governmentDetail"
+      @clickUrl="clickUrl"
+    ></governmentDetail-layout>
   </div>
 </template>
 
@@ -17,57 +23,56 @@ export default {
     governmentDetailLayout,
   },
   data: () => ({
+    // 站点信息
     info: {},
+    // 栏目列表
     nativeList: [],
+    // 头部标题
     columnTitle: '',
+    // 详情
     governmentDetail: {},
   }),
-  created() {
-    this.searchSite();
-    this.searchColumn();
-    this.searchInfo();
+  async created() {
+    await this.search();
+    await this.searchInfo();
+    // this.searchColumn();
+    // this.searchInfo();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
   },
-  computed: {},
   methods: {
     ...mapSite(['showInfo']),
     ...mapColumn({ columnList: 'query', columnInfo: 'fetch' }),
     ...mapNews({ newsList: 'query', newsInfo: 'fetch' }),
-    // 查询站点信息
-    async searchSite() {
+    // 查询站点信息+友情链接
+    async search({ ...info } = {}) {
       let res = await this.showInfo();
       let object = JSON.parse(JSON.stringify(res.data));
       if (object) {
         this.$set(this, `info`, res.data);
-      } else {
-        this.$message.error(res.errmsg ? res.errmsg : 'error');
+      }
+      // 科技政务栏目
+      res = await this.columnList({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `nativeList`, res.data);
       }
     },
-    // 查询科技政务栏目
-    async searchColumn({ ...info } = {}) {
-      const res = await this.columnList({ ...info });
-      this.$set(this, `nativeList`, res.data);
-      console.log(res);
-      // for (const val of res.data) {
-      //   this.tpxwSearch({ column_id: val.id, site: val.site });
-      // }
-    },
+    // 查询详情
     async searchInfo() {
-      let detailId = this.$route.query.id;
-      const res = await this.newsInfo(detailId);
-      const result = await this.columnInfo(res.data.column_id);
-      this.$set(this, `columnTitle`, result.data.name);
-      this.$set(this, `governmentDetail`, res.data);
+      const res = await this.newsInfo(this.id);
+      let column = this.nativeList.find(i => i.id == res.data.column_id);
+      if (res) {
+        this.$set(this, `governmentDetail`, res.data);
+        this.$set(this, `columnTitle`, column.name);
+      }
+    },
+    // 点击左侧栏目
+    clickUrl(data) {
+      this.$router.push({ path: '/government/governmentList' });
     },
-    // // 查询信息列表
-    // async tpxwSearch({ skip = 0, limit = 10, column_id, site } = {}) {
-    //   const res = await this.newsList({ skip, limit, column_id: column_id });
-    //   for (const val of res.data) {
-    //     const result = await this.columnInfo(val.column_id);
-    //     val.column_name = result.data.name;
-    //   }
-    //   this.$set(this, `${site}List`, res.data);
-    //   console.log(res.data);
-    // },
   },
 };
 </script>

+ 27 - 28
src/views/government/governmentList.vue

@@ -7,7 +7,7 @@
       :columnName="columnName"
       :contentList="contentList"
       :total="total"
-      :columnTitle="columnTitle"
+      :columnTitle="columnName"
       :policyInfo="policyInfo"
       @clickLists="submit"
       @fetch="fetchInfo"
@@ -30,19 +30,23 @@ export default {
     governmentListsLayout,
   },
   data: () => ({
+    // 站点信息
     info: {},
-    nativeList: [],
+    // 显示
     display: 'list',
-    columnName: '',
+    // 左侧栏目列表
+    nativeList: [],
+    // 左侧点击存储栏目id
+    leftId: '',
+    // 右侧信息列表
     contentList: [],
     total: 0,
-    leftId: '',
-    columnTitle: '',
+    columnName: '',
+    // 右侧详情
     policyInfo: {},
   }),
   async created() {
-    this.searchSite();
-    await this.searchColumn();
+    await this.search();
     await this.defaultColumn();
   },
   computed: {},
@@ -50,53 +54,48 @@ export default {
     ...mapSite(['showInfo']),
     ...mapColumn({ columnList: 'query', columnInfo: 'fetch' }),
     ...mapNews({ policyNew: 'query', newsFetch: 'fetch' }),
-    // 查询站点信息
-    async searchSite() {
+    // 查询站点信息+友情链接
+    async search({ ...info } = {}) {
       let res = await this.showInfo();
       let object = JSON.parse(JSON.stringify(res.data));
       if (object) {
         this.$set(this, `info`, res.data);
-      } else {
-        this.$message.error(res.errmsg ? res.errmsg : 'error');
       }
-    },
-    // 查询科技政务栏目
-    async searchColumn({ ...info } = {}) {
-      const res = await this.columnList({ ...info });
+      // 科技政务栏目
+      res = await this.columnList({ ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `nativeList`, res.data);
       }
     },
+    // 点击左侧存储栏目id,并查询右侧信息
     submit({ id }) {
       this.$set(this, `leftId`, id);
       this.display = 'list';
-      this.searchRight();
+      this.searchrightnews();
     },
-    async searchRight({ skip = 0, limit = 10, column_id } = {}) {
+    async searchrightnews({ 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.columnInfo(val.column_id);
-        val.column_name = result.data.name;
-      }
-      this.$set(this, `contentList`, res.data);
-      this.$set(this, `total`, res.total);
-      for (const val of res.data) {
-        this.$set(this, `columnName`, val.column_name);
+      let columnName = this.nativeList.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);
       }
     },
-    async defaultColumn() {
+    // 查询默认栏目
+    defaultColumn() {
       if (!(this.nativeList.length > 0)) return;
       let id = _.get(this.nativeList[0], 'id', false);
       if (!id) return;
       this.submit({ id });
     },
+    // 查询详情
     async fetchInfo(id) {
       this.display = 'detail';
       const res = await this.newsFetch(id);
       const result = await this.columnInfo(res.data.column_id);
-      this.$set(this, `columnTitle`, result.data.name);
+      this.$set(this, `columnName`, result.data.name);
       this.$set(this, `policyInfo`, res.data);
-      // 查询详情,赋值
     },
   },
 };