guhongwei 4 tahun lalu
induk
melakukan
d29b4d6c17

+ 3 - 3
src/layout/policy/fenlei.vue

@@ -6,9 +6,9 @@
     </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>
   </div>

+ 3 - 3
src/layout/policy/fenleis.vue

@@ -6,9 +6,9 @@
     </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.name }}</span></el-menu-item
-        >
+        <el-menu-item index="1" v-for="(item, index) in liebiaoList" :key="index">
+          <span slot="title" @click="clickUrl()">{{ item.name }}</span>
+        </el-menu-item>
       </el-menu>
     </el-col>
   </div>

+ 6 - 3
src/views/government/governmentList.vue

@@ -41,6 +41,7 @@ export default {
     // 右侧信息列表
     contentList: [],
     total: 0,
+    // 右侧栏目标题
     columnName: '',
     // 右侧详情
     policyInfo: {},
@@ -93,9 +94,11 @@ export default {
     async fetchInfo(id) {
       this.display = 'detail';
       const res = await this.newsFetch(id);
-      const result = await this.columnInfo(res.data.column_id);
-      this.$set(this, `columnName`, result.data.name);
-      this.$set(this, `policyInfo`, res.data);
+      let column = this.nativeList.find(i => i.id == res.data.column_id);
+      if (res) {
+        this.$set(this, `policyInfo`, res.data);
+        this.$set(this, `columnName`, column.name);
+      }
     },
   },
 };

+ 20 - 16
src/views/policy/lawDetail.vue

@@ -5,9 +5,9 @@
 </template>
 
 <script>
+import _ from 'loadsh';
 import lawDetailDetail from '@/components/policy/lawDetail.vue';
 import { createNamespacedHelpers, mapGetters } from 'vuex';
-import _ from 'loadsh';
 const { mapActions: mapSite } = createNamespacedHelpers('site');
 const { mapActions: mappolicyColumn } = createNamespacedHelpers('policyColumn');
 const { mapActions: mappolicyNews } = createNamespacedHelpers('policyNews');
@@ -18,44 +18,48 @@ export default {
     lawDetailDetail,
   },
   data: () => ({
+    // 站点信息
     info: {},
+    // 栏目信息
     liebiaoList: [],
+    // 右侧信息栏目标题
     columnTitle: '',
+    // 详情
     lawDetailInfo: {},
   }),
   async created() {
-    this.searchSite();
-    await this.policyColumn();
+    await this.search();
     await this.searchInfo();
   },
-  computed: {},
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+  },
   methods: {
     ...mapSite(['showInfo']),
     ...mappolicyColumn({ policyColumns: 'query', policyfetch: 'fetch' }),
     ...mappolicyNews({ 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 policyColumn({ ...info } = {}) {
-      const res = await this.policyColumns({ ...info });
+      res = await this.policyColumns({ ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `liebiaoList`, res.data);
       }
     },
+    // 查询详情
     async searchInfo() {
-      let detailId = this.$route.query.id;
-      const res = await this.newsFetch(detailId);
-      const result = await this.policyfetch(res.data.column_id);
-      this.$set(this, `columnTitle`, result.data.name);
-      this.$set(this, `lawDetailInfo`, res.data);
+      const res = await this.newsFetch(this.id);
+      let column = this.liebiaoList.find(i => i.id == res.data.column_id);
+      if (res) {
+        this.$set(this, `lawDetailInfo`, res.data);
+        this.$set(this, `columnTitle`, column.name);
+      }
     },
   },
 };

+ 17 - 20
src/views/policy/policy.vue

@@ -29,7 +29,9 @@ export default {
     policyDetail,
   },
   data: () => ({
+    // 站点信息
     info: {},
+    // 查询栏目
     liebiaoList: [],
     display: 'list',
     columnName: '',
@@ -40,27 +42,25 @@ export default {
     policyInfo: {},
   }),
   async created() {
-    this.searchSite();
-    await this.policyColumn();
+    await this.search();
     await this.defaultColumn();
+    // this.searchSite();
+    // await this.policyColumn();
+    //
   },
   computed: {},
   methods: {
     ...mapSite(['showInfo']),
     ...mappolicyColumn({ policyColumns: 'query', policyfetch: 'fetch' }),
     ...mappolicyNews({ 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 policyColumn({ ...info } = {}) {
-      const res = await this.policyColumns({ ...info });
+      res = await this.policyColumns({ ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `liebiaoList`, res.data);
       }
@@ -68,18 +68,15 @@ export default {
     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.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);
+      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.data.length);
+        this.$set(this, `columnName`, columnName.name);
       }
     },
     async defaultColumn() {
@@ -88,13 +85,13 @@ export default {
       if (!id) return;
       this.submit({ id });
     },
+    // 查询详情
     async fetchInfo(id) {
       this.display = 'detail';
       const res = await this.newsFetch(id);
       const result = await this.policyfetch(res.data.column_id);
       this.$set(this, `columnTitle`, result.data.name);
       this.$set(this, `policyInfo`, res.data);
-      // 查询详情,赋值
     },
   },
 };