guhongwei 5 anos atrás
pai
commit
1ab2791d39

+ 14 - 5
src/components/newsList.vue

@@ -12,10 +12,10 @@
       <el-col :span="24" class="main">
         <div class="w_1200">
           <el-col :span="5" class="mainNav">
-            <listLeft :Color="Color"></listLeft>
+            <listLeft v-if="sideMenu" :sideMenu="sideMenu" :Color="Color"></listLeft>
           </el-col>
-          <el-col :span="18" class="mainList">
-            <newsInfo :newsList="newsList" :Color="Color"></newsInfo>
+          <el-col :span="listSpan" class="mainList">
+            <newsInfo :newsList="newsList" :Color="Color" :title="title"></newsInfo>
           </el-col>
         </div>
       </el-col>
@@ -40,6 +40,8 @@ export default {
     backColor: null, //导航菜单背景颜色
     newsList: null, //列表信息
     menuList: null, //菜单
+    sideMenu: null, //侧菜单
+    title: null, //标题
   },
   components: {
     top, //头部
@@ -50,7 +52,14 @@ export default {
   },
   data: () => ({}),
   created() {},
-  computed: {},
+  computed: {
+    listSpan() {
+      let span = 18;
+      if (this.sideMenu === null) span = 18;
+      else span = 24;
+      return span;
+    },
+  },
   methods: {},
 };
 </script>
@@ -74,7 +83,7 @@ export default {
   overflow: hidden;
 }
 .mainList {
-  width: 746px;
+  // width: 746px;
   margin: 0 0 0 20px;
 }
 .foot {

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

@@ -7,7 +7,7 @@
             {{ newsList.title || title }}
           </el-col>
           <el-col :span="6" class="link">
-            <el-link :underline="false" @click="$router.push({ path: path })">
+            <el-link :underline="false" @click="$router.push({ path: path, query: { title: newsList.title } })">
               MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i>
             </el-link>
           </el-col>

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

@@ -7,7 +7,7 @@
             {{ noticeList.title || title }}
           </el-col>
           <el-col :span="6" class="link">
-            <el-link :underline="false" @click="$router.push({ path: path })">
+            <el-link :underline="false" @click="$router.push({ path: path, query: { title: noticeList.title } })">
               MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i>
             </el-link>
           </el-col>

+ 11 - 21
src/layout/list/listLeft.vue

@@ -2,22 +2,14 @@
   <div id="listLeft">
     <el-row>
       <el-col :span="24" class="listLeft">
-        <el-menu default-active="1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose">
-          <el-menu-item index="1" :style="`color:${Color}`">
-            <span slot="title">就业动态</span>
-          </el-menu-item>
-          <el-menu-item index="2" :style="`color:${Color}`">
-            <span slot="title">学校动态</span>
-          </el-menu-item>
-          <el-menu-item index="3" :style="`color:${Color}`">
-            <span slot="title">文化动态</span>
-          </el-menu-item>
-          <el-menu-item index="4" :style="`color:${Color}`">
-            <span slot="title">招生动态</span>
-          </el-menu-item>
-          <el-menu-item index="5" :style="`color:${Color}`">
-            <span slot="title">考试动态</span>
-          </el-menu-item>
+        <el-menu :default-active="$route.path" class="el-menu-vertical-demo" :router="true">
+          <template v-for="(item, index) in sideMenu">
+            <el-menu-item v-if="item.type !== 'url' && item.type !== 'content'" :index="item.path" :key="index" :style="`color:${Color}`">
+              {{ item.title }}
+            </el-menu-item>
+            <el-menu-item v-else-if="item.type === 'content'" :index="item.path" :key="index" :style="`color:${Color}`">{{ item.title }}</el-menu-item>
+            <el-menu-item v-else :index="``" :key="index" @click="turnTo(item.url)" :style="`color:${Color}`">{{ item.title }}</el-menu-item>
+          </template>
         </el-menu>
       </el-col>
     </el-row>
@@ -28,6 +20,7 @@
 export default {
   name: 'listLeft',
   props: {
+    sideMenu: null,
     Color: null,
   },
   components: {},
@@ -35,11 +28,8 @@ export default {
   created() {},
   computed: {},
   methods: {
-    handleOpen(key, keyPath) {
-      console.log(key, keyPath);
-    },
-    handleClose(key, keyPath) {
-      console.log(key, keyPath);
+    turnTo(url) {
+      window.open(url);
     },
   },
 };

+ 2 - 2
src/layout/list/listRight.vue

@@ -22,7 +22,7 @@
               <el-col :span="4" class="date">{{ item.date }}</el-col>
             </el-col>
             <el-col :span="20" class="content">
-              <p>{{ item.content }}</p>
+              <p v-html="item.content"></p>
             </el-col>
           </el-col>
         </el-col>
@@ -48,10 +48,10 @@ export default {
   props: {
     rightList: null,
     Color: null,
+    title: { type: String, default: '就业动态' },
   },
   components: {},
   data: () => ({
-    title: '就业动态',
     currentPage4: 1,
   }),
   created() {},

+ 4 - 3
src/layout/list/newsInfo.vue

@@ -29,7 +29,7 @@
               </el-col>
             </el-col>
             <el-col :span="17" class="content">
-              <p>{{ item.content }}</p>
+              <p v-html="item.content"></p>
             </el-col>
           </el-col>
         </el-col>
@@ -55,6 +55,7 @@ export default {
   props: {
     newsList: null,
     Color: null,
+    title: { type: String, default: '就业动态' },
   },
   components: {},
   data: () => ({
@@ -138,7 +139,7 @@ p {
 .rightList .content {
   padding: 0 10px;
 }
-.rightList .content p {
+/deep/.rightList .content p p {
   font-size: 14px;
   color: #4f4f4f;
   overflow: hidden;
@@ -147,7 +148,7 @@ p {
   word-break: break-all;
   display: -webkit-box;
   -webkit-box-orient: vertical;
-  line-height: 25px;
+  // line-height: 25px;
 }
 .rightList:hover .title p {
   cursor: pointer;

+ 32 - 97
src/views/newsList.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="newsList">
-    <list-detail :menuList="menu" :info="site" :backColor="backColor" :Color="Color" :newsList="newsList"></list-detail>
+    <list-detail :menuList="menu" :info="site" :backColor="backColor" :Color="Color" :newsList="newsList" :sideMenu="sideMenu" :title="title"></list-detail>
   </div>
 </template>
 
@@ -33,92 +33,7 @@ export default {
     },
     backColor: '#0457c7',
     Color: '#0457c7',
-    newsList: [
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-      {
-        pic: require('@/assets/news.png'),
-        title: '我省成功举办“创业有我•就在吉林',
-        date: '2019-12-03',
-        content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
-      },
-    ],
+    newsList: [],
     menu: [],
     sideMenu: [],
     site: {},
@@ -126,7 +41,8 @@ export default {
   }),
   async created() {
     await this.toGetSite(); //获取主站信息
-    this.loadMenu(); //获取菜单信息
+    await this.loadMenu(); //获取菜单信息
+    this.toGetNews(); //获取数据
   },
   computed: {
     type() {
@@ -135,12 +51,15 @@ export default {
     id() {
       return this.$route.params.id;
     },
+    title() {
+      return this.$route.query.title;
+    },
   },
   watch: {
     type: 'getSubMenu',
   },
   methods: {
-    ...mapActions(['getSite', 'getMenu', 'getColumn']),
+    ...mapActions(['getSite', 'getMenu', 'getColumn', 'getNews']),
     //站点信息
     async toGetSite() {
       let site = sessionStorage.getItem('site');
@@ -168,9 +87,9 @@ export default {
       let menu = sessionStorage.getItem('menu');
       if (menu) {
         this.$set(this, `menu`, JSON.parse(menu));
-        this.finishedMenu();
-        return;
+        await this.finishedMenu();
       } else this.toGetMenu();
+      this.getSubMenu();
     },
     async toGetMenu() {
       let result = await this.getMenu({ type: `list` });
@@ -211,14 +130,30 @@ export default {
     },
     //侧菜单
     getSubMenu() {
-      console.log('in function:');
       let data;
-      if (this.type === `module`) data = sessionStorage.getItem(`module`);
-      else {
-        for (const item of this.menu) {
-          let res = item.children.filter(fil => fil.id === this.id);
-          console.log(res);
+      if (this.type === `module`) {
+        data = sessionStorage.getItem(`modules`);
+        this.$set(this, `sideMenu`, []);
+      } else {
+        let res = this.menu.filter(fil => {
+          if (fil.children) {
+            let res = fil.children.filter(filc => filc.id === this.id);
+            return res.length > 0;
+          } else return false;
+        });
+        this.$set(this, `sideMenu`, res.length > 0 ? res[0].children : []);
+      }
+    },
+    //请求数据
+    async toGetNews() {
+      let result = await this.getNews({ type: 'list', data: { parent_id: this.id } });
+      if (result.errcode === 0) {
+        let data = result.data;
+        for (const item of data) {
+          let info = await this.getNews({ type: 'fetch', data: { id: item.id } });
+          if (info.errcode === 0) item.content = info.data.content;
         }
+        this.$set(this, `newsList`, result.data);
       }
     },
   },