wuhongyu 5 anos atrás
pai
commit
af7cfe2250

+ 1 - 1
src/layout/index/jobs.vue

@@ -11,7 +11,7 @@
         class="leftcontext"
         v-for="(item, index) in jobsList"
         :key="index"
-        @click.native="$router.push({ path: '/news/listDetail', query: { col_name: '工作动态', id: 'id', display: '1' } })"
+        @click.native="$router.push({ path: '/news/listDetail', query: { col_name: '工作动态', id: item.id, display: '1' } })"
       >
         <el-col :span="20" class="title"> <span></span>{{ item.title }} </el-col>
         <el-col :span="4" class="date">{{ item.date }}</el-col>

+ 12 - 7
src/views/index.vue

@@ -41,7 +41,8 @@
 </template>
 
 <script>
-// const { mapActions: login } = createNamespacedHelpers('login');
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: news } = createNamespacedHelpers('news');
 import top from '@/layout/common/top.vue';
 import menus from '@/layout/common/menus.vue';
 import dynamic from '@/layout/index/dynamic.vue';
@@ -179,13 +180,17 @@ export default {
   },
   computed: {},
   methods: {
-    // ...{ departmentQuery: 'query', departmentFetch: 'fetch' },
+    ...news({ newsQuery: 'query', newsFetch: 'fetch' }),
+
     async search() {
-      let res = await this.toLogin({ col_name: '工作动态' });
-      if (this.$checkRes(res)) {
-        this.$set(this, `jobsList`, res.data);
-      }
-      jobsList;
+      let res = await this.newsQuery({ skip: 0, limit: 6, col_name: '工作动态', status: 2 });
+      if (this.$checkRes(res)) this.$set(this, `jobsList`, res.data);
+      res = await this.newsQuery({ skip: 0, limit: 6, col_name: '通知通告', status: 2 });
+      if (this.$checkRes(res)) this.$set(this, `noticeList`, res.data);
+      res = await this.newsQuery({ skip: 0, limit: 6, col_name: '科技合作', status: 2 });
+      if (this.$checkRes(res)) this.$set(this, `serviceList`, res.data);
+      res = await this.newsQuery({ skip: 0, limit: 6, col_name: '技术问答', status: 2 });
+      if (this.$checkRes(res)) this.$set(this, `jishuList`, res.data);
     },
   },
 };

+ 15 - 2
src/views/news/index.vue

@@ -31,6 +31,7 @@
 </template>
 
 <script>
+const { mapActions: news } = createNamespacedHelpers('news');
 import top from '@/layout/common/top.vue';
 import menus from '@/layout/common/menus.vue';
 import foot from '@/layout/common/foot.vue';
@@ -81,8 +82,20 @@ export default {
       ],
     };
   },
-  created() {},
-  methods: {},
+  created() {
+    this.search();
+  },
+  methods: {
+    ...news({ newsQuery: 'query', newsFetch: 'fetch' }),
+    async search() {
+      let res = await this.newsQuery({ skip: 0, limit: 6, col_name: '科技资讯', status: 2 });
+      if (this.$checkRes(res)) this.$set(this, `oneList`, res.data);
+      res = await this.newsQuery({ skip: 0, limit: 6, col_name: '技术前沿', status: 2 });
+      if (this.$checkRes(res)) this.$set(this, `twoList`, res.data);
+      res = await this.newsQuery({ skip: 0, limit: 6, col_name: '工作动态', status: 2 });
+      if (this.$checkRes(res)) this.$set(this, `threeList`, res.data);
+    },
+  },
   computed: {
     ...mapState(['user']),
     pageTitle() {

+ 28 - 5
src/views/news/listDetail.vue

@@ -32,7 +32,7 @@
                   <span>{{ columnName }}</span>
                 </el-col>
                 <el-col :span="24" class="list">
-                  <newsList :list="list" :total="total" @detailBtn="detailBtn"></newsList>
+                  <newsList :list="list" :total="total" @detailBtn="detailBtn" :limit="limit" @query="changeMenu"></newsList>
                 </el-col>
               </span>
               <span v-else>
@@ -58,6 +58,7 @@ import foot from '@/layout/common/foot.vue';
 import newsList from './parts/newsList.vue';
 import newsDetail from './parts/newsDetail.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: news } = createNamespacedHelpers('news');
 export default {
   name: 'listDetail',
   props: {},
@@ -87,7 +88,8 @@ export default {
         },
       ],
       // 总数
-      total: 10,
+      total: 0,
+      limit: 14,
       // 详情
       details: {
         title: '信息标题',
@@ -101,40 +103,61 @@ export default {
     this.changeColumn();
   },
   methods: {
+    ...news({ newsQuery: 'query', newsFetch: 'fetch' }),
     // 选择栏目
-    changeColumn() {
+    async changeColumn() {
       if (this.col_name == '科技资讯') {
         this.menuIndex = 0;
         this.columnName = this.col_name;
         this.menuColor = 'rgb(5,73,130)';
+        let name = this.columnName;
+        this.changeMenu(name);
         this.$set(this, `displays`, this.display);
       } else if (this.col_name == '技术前沿') {
         this.menuIndex = 1;
         this.columnName = this.col_name;
         this.menuColor = 'rgb(5,73,130)';
+        let name = this.columnName;
+        this.changeMenu(name);
         this.$set(this, `displays`, this.display);
       } else if (this.col_name == '工作动态') {
         this.menuIndex = 2;
         this.columnName = this.col_name;
         this.menuColor = 'rgb(5,73,130)';
+        let name = this.columnName;
+        this.changeMenu(name);
         this.$set(this, `displays`, this.display);
       } else if (this.col_name == '通知通告') {
         this.menuIndex = 3;
         this.columnName = this.col_name;
         this.menuColor = 'rgb(5,73,130)';
+        let name = this.columnName;
+        this.changeMenu(name);
         this.$set(this, `displays`, this.display);
       }
     },
     // 点击选择菜单
-    changeMenu(name, index) {
+    async changeMenu(name, index) {
+      if (this.display == '0') {
+        let res = await this.newsQuery({ skip: 0, limit: 14, col_name: name, status: 2 });
+        if (this.$checkRes(res)) this.$set(this, `list`, res.data);
+      } else {
+        let res = await this.newsFetch(this.id);
+        if (this.$checkRes(res)) this.$set(this, `details`, res.data);
+      }
+
       this.menuIndex = index;
       this.columnName = name;
       this.menuColor = 'rgb(5,73,130)';
       this.$set(this, `displays`, 0);
     },
     // 点击详情
-    detailBtn(id) {
+    async detailBtn(id) {
+      let res = await this.newsFetch(id);
+      if (this.$checkRes(res)) this.$set(this, `details`, res.data);
+
       this.$set(this, `displays`, 1);
+      console.log(id);
     },
   },
   computed: {

+ 3 - 3
src/views/news/parts/newsDetail.vue

@@ -4,10 +4,10 @@
       <el-col :span="24" class="info">
         <h3>{{ details.title }}</h3>
         <div>
-          <span>文章来源:{{ details.source }}</span>
-          <span>时间:{{ details.date }}</span>
+          <span>文章来源:{{ details.publish_unit }}</span>
+          <span>时间:{{ details.publish_time }}</span>
         </div>
-        <p>{{ details.content }}</p>
+        <p v-html="details.content"></p>
       </el-col>
     </el-row>
   </div>

+ 2 - 1
src/views/news/parts/newsList.vue

@@ -8,7 +8,7 @@
           <span>{{ item.date }}</span>
         </el-col>
         <el-col :span="24" class="page">
-          <pagination :total="total"></pagination>
+          <pagination :total="total" :limit="limit" position="right"></pagination>
         </el-col>
       </el-col>
     </el-row>
@@ -23,6 +23,7 @@ export default {
   props: {
     list: null,
     total: null,
+    limit: null,
   },
   components: {
     pagination,