guhongwei 4 years ago
parent
commit
2a8c5afa05
1 changed files with 50 additions and 35 deletions
  1. 50 35
      src/views/scienceNews/index.vue

+ 50 - 35
src/views/scienceNews/index.vue

@@ -6,20 +6,25 @@
           <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
           <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
         </el-col>
         </el-col>
         <el-col :span="24" class="down">
         <el-col :span="24" class="down">
-          <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="show(item)">
-            <el-col :span="18" class="title textOver">
-              {{ item.title }}
-            </el-col>
-            <el-col :span="6" class="date">
-              {{ item.publish_time }}
-            </el-col>
-            <el-col :span="24" class="other">
-              <p class="textOver">
-                作者:<span>{{ item.publish || '系统管理员' }}</span>
-              </p>
-              <p class="textOver">
-                信息来源:<span>{{ item.orgin }}</span>
-              </p>
+          <el-col :span="24" class="search">
+            <van-search v-model="name" @search="onSearch" placeholder="请输入信息标题" />
+          </el-col>
+          <el-col :span="24" class="data">
+            <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="show(item)">
+              <el-col :span="18" class="title textOver">
+                {{ item.title }}
+              </el-col>
+              <el-col :span="6" class="date">
+                {{ item.publish_time }}
+              </el-col>
+              <el-col :span="24" class="other">
+                <p class="textOver">
+                  作者:<span>{{ item.publish || '系统管理员' }}</span>
+                </p>
+                <p class="textOver">
+                  信息来源:<span>{{ item.orgin }}</span>
+                </p>
+              </el-col>
             </el-col>
             </el-col>
           </el-col>
           </el-col>
         </el-col>
         </el-col>
@@ -50,6 +55,7 @@ export default {
       // 返回
       // 返回
       navShow: true,
       navShow: true,
       list: [],
       list: [],
+      name: '',
     };
     };
   },
   },
   async created() {
   async created() {
@@ -58,6 +64,7 @@ export default {
   methods: {
   methods: {
     ...scienceNews(['query', 'fetch', 'create', 'update', 'delete']),
     ...scienceNews(['query', 'fetch', 'create', 'update', 'delete']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
     async search({ skip = 0, limit = 10, ...info } = {}) {
+      if (this.name) info.title = this.name;
       let res = await this.query({ skip, ...info });
       let res = await this.query({ skip, ...info });
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
         this.$set(this, `list`, res.data);
         this.$set(this, `list`, res.data);
@@ -66,6 +73,10 @@ export default {
     show(data) {
     show(data) {
       this.$router.push({ path: '/scienceNews/detail', query: { id: data.id } });
       this.$router.push({ path: '/scienceNews/detail', query: { id: data.id } });
     },
     },
+    onSearch(data) {
+      this.$set(this, `name`, data);
+      this.search();
+    },
   },
   },
   mounted() {
   mounted() {
     this.title = this.$route.meta.title;
     this.title = this.$route.meta.title;
@@ -89,28 +100,32 @@ export default {
     overflow: hidden;
     overflow: hidden;
   }
   }
   .down {
   .down {
-    padding: 10px;
-    .list {
-      background-color: #fff;
-      border-radius: 5px;
-      margin: 0 0 10px 0;
-      padding: 5px;
-      .title {
-        font-size: 18px;
-        font-weight: bold;
-      }
-      .date {
-        text-align: right;
-        font-size: 16px;
-        padding: 6px 0 0 0;
-      }
-      .other {
-        margin: 5px 0 0 0;
-        p {
+    .search {
+    }
+    .data {
+      padding: 10px;
+      .list {
+        background-color: #fff;
+        border-radius: 5px;
+        margin: 0 0 10px 0;
+        padding: 5px;
+        .title {
+          font-size: 18px;
+          font-weight: bold;
+        }
+        .date {
+          text-align: right;
           font-size: 16px;
           font-size: 16px;
-          padding: 5px 0;
-          span {
-            color: #666;
+          padding: 6px 0 0 0;
+        }
+        .other {
+          margin: 5px 0 0 0;
+          p {
+            font-size: 16px;
+            padding: 5px 0;
+            span {
+              color: #666;
+            }
           }
           }
         }
         }
       }
       }