yuanyiming 2 anni fa
parent
commit
d28b53c78c
1 ha cambiato i file con 64 aggiunte e 5 eliminazioni
  1. 64 5
      src/views/messageNotification.vue

+ 64 - 5
src/views/messageNotification.vue

@@ -10,7 +10,7 @@
       <div class="selectTwo">
           <div class="selectsBlock">
               <el-input v-model="selectInput" style="width:200px" placeholder="请输入"></el-input>
-              <el-button type="primary" class="btn2" >查询</el-button>
+              <el-button type="primary" class="btn2" @click="getCourseManagement">查询</el-button>
           </div>
       </div>
         <el-button type="primary" class="btn" @click="addMessage" size="mini">新建全站通知</el-button>
@@ -23,6 +23,7 @@
       :data="tableData"
       tooltip-effect="dark"
       stripe
+      style="height: 550px;"
       class="fontSize"
       :header-cell-style="{ background: '#f2f2f2',color:'#000' }"
       >
@@ -66,7 +67,17 @@
     </el-table>
     </div>
 <!-- 通知表格结束-->
-
+        <!-- 分页 -->
+        <el-pagination
+            @current-change="handleCurrentChange"
+            :current-page="table.currentPage"
+            :page-size="table.packageSize"
+            layout=" prev, pager, next"
+            background
+            class="pagination"
+            :total="table.total">
+          </el-pagination>
+        <!-- 分页结束 -->
 
 <!-- 添加全站通知开始 -->
     <el-dialog
@@ -171,7 +182,13 @@
 
         }
         ],
-         
+        // 分页数据
+        table:{
+          total:10,
+          packageSize:10,
+          currentPage:1
+        },
+        // 添加数据
           addMess:{
             tit:'',
             con:''
@@ -202,7 +219,7 @@
         addMessage(){
           this.dialogVisible=true;
         },
-        confirmAdd(){
+        confirmAdd(){   //新建全站通知发送数据
             let param ={
               uid:this.$store.state.userInfo.userid,
               title:this.addMess.tit,
@@ -221,14 +238,56 @@
         },
         lookIntro(){
           this.dialogVisible2=true;
-        }
+        },
+        getCourseManagement(){    //分页获取数据请求
+            if(this.value==1){
+              this.value=''
+            }
+            let currentPage=this.table.currentPage;
+            let packageSize=this.table.packageSize;
+            const param={
+              uid:this.$store.state.userInfo.userid,
+              title:this.selectInput,
+              noePage:currentPage,
+              lim:10
+            }
+            this.ajax
+              .get(this.$store.state.api+'/SelectNotification',param)
+              .then(res=>{  
+                // 不是在第一页进行分页请求,请求数据为空,再发送一次请求获取数据,判断是否为第一页,防止无限循环
+                console.log(res)
+                // if(this.table.currentPage!==1 && res.data[1].length==0){
+                //   this.table.currentPage=1
+                //   this.getCourseManagement();
+                // }
+                // console.log(res.data);
+                // this.items=res.data[1]
+                // this.table.total=res.data[0][0].total
+              },err=>{
+                console.log(err);
+              })
+          },
+        // 分页
+        handleCurrentChange(val) {   //当页数发生改变的时候调用获取列表数据请求
+          // console.log(`当前页: ${val}`);
+          this.table.currentPage=val
+          this.getCourseManagement()
+        },
+      },
+      mounted(){
+        this.getCourseManagement()
       }
+      
     }
 </script>
 
 <style lang="less">
 .messageNotification{
 
+  .pagination{
+    float: right;
+    margin: 20px 35px 10px;
+  }
   .el-dialog{
       border-radius:5px;
       overflow: hidden;