Просмотр исходного кода

稿件列表页面添加查询条件

reghao 2 лет назад
Родитель
Сommit
1939807cea
2 измененных файлов с 31 добавлено и 6 удалено
  1. 1 1
      src/api/admin.js
  2. 30 5
      src/views/admin/PostList.vue

+ 1 - 1
src/api/admin.js

@@ -24,7 +24,7 @@ export function getUserList(page) {
 
 // 获取稿件列表
 export function getPostList(page) {
-  return get(adminApi.postListApi + '?page=' + page)
+  return get(adminApi.postListApi, page)
 }
 
 // 获取源数据

+ 30 - 5
src/views/admin/PostList.vue

@@ -1,6 +1,20 @@
 <template>
   <el-row>
     <el-row>
+      <el-form :inline="true" :model="searchForm" class="demo-form-inline">
+        <el-form-item>
+          <el-select v-model="searchForm.type" placeholder="查询类型">
+            <el-option label="稿件标题" value="1" />
+            <el-option label="用户ID" value="2" />
+          </el-select>
+        </el-form-item>
+        <el-form-item>
+          <el-input v-model="searchForm.content" placeholder="" />
+        </el-form-item>
+        <el-form-item>
+          <el-button size="mini" type="warning" @click="search">查询</el-button>
+        </el-form-item>
+      </el-form>
       <el-table
         :data="dataList"
         border
@@ -301,23 +315,29 @@ export default {
         videoId: null,
         scope: '1'
       },
-      videoResources: []
+      videoResources: [],
+      searchForm: {
+        page: 1,
+        type: '1',
+        content: null
+      }
     }
   },
   created() {
     document.title = '稿件列表'
-    this.getData()
+    this.getData(this.searchForm)
   },
   methods: {
     handleCurrentChange(pageNumber) {
       this.currentPage = pageNumber
-      this.getData()
+      this.searchForm.page = this.currentPage
+      this.getData(this.searchForm)
       // 回到顶部
       scrollTo(0, 0)
     },
-    getData() {
+    getData(searchForm) {
       this.dataList = []
-      getPostList(this.currentPage).then(resp => {
+      getPostList(searchForm).then(resp => {
         if (resp.code === 0) {
           this.dataList = resp.data.list
           this.totalSize = resp.data.totalSize
@@ -439,6 +459,11 @@ export default {
           duration: 3000
         })
       })
+    },
+    search() {
+      this.currentPage = 1
+      this.searchForm.page = this.currentPage
+      this.getData(this.searchForm)
     }
   }
 }