Browse Source

视频分页和key设定

pzc 4 years ago
parent
commit
bbb5810586
1 changed files with 26 additions and 9 deletions
  1. 26 9
      UI/src/pages/vedioManage/vedioList.js

+ 26 - 9
UI/src/pages/vedioManage/vedioList.js

@@ -139,6 +139,8 @@ class VedioList extends React.Component{
                 },
             ],
             data: [],
+            total:0,
+            currentPage:1,
             tagModal: false,          //标签modal
             tagColumns: [
                 { title: '标签id', dataIndex:'tagTypeId', tagTypeId: 'tagTypeId'  },
@@ -205,24 +207,32 @@ class VedioList extends React.Component{
         this.loadDepartmentList()   //科室列表
     }
     //搜索视频列表
-    searchDataList() {
+    searchDataList(page) {
+        var pageNum = page?page:1;
         request({
             url: ymallAPI + '/ymall/video/queryVideos',
             method: 'post',
             data: {
                 pageSize: 10,
-                pageIndex: this.state.searchVideoPage,
+                pageIndex: pageNum,
                 filters: this.state.filters 
             }
         }).then(res => {
             console.log('视频列表', res)
+            
+            let itemdata = [];
+            for(var item of  res.items){
+                 item['key'] = item.id;
+                 itemdata.push(item);
+            }
             this.setState({
-                data: this.state.data.concat(res.items),
-                searchVideoPage: this.state.searchVideoPage +1
+                data: itemdata,
+                currentPage: page,
+                total:res.totalCount
             }, () => {
-                if(this.state.data.length < res.totalCount ) {
-                    this.searchDataList()
-                }
+                // if(this.state.data.length < res.totalCount ) {
+                //     this.searchDataList()
+                // }
             })
         })
     }
@@ -707,6 +717,13 @@ class VedioList extends React.Component{
             onChange: this.onSelectChange,
         };
         let SsoToken = util.auth.getToken()
+
+        const { currentPage } = this.state;
+        const paginationProps = {
+            page: currentPage,
+            onChange : (page) => this.searchDataList(page),
+            total: this.state.total,
+        }
         return(
             <div style={{ padding: '50px',width: '100%', backgroundColor:'#fff'}}>
 
@@ -817,8 +834,8 @@ class VedioList extends React.Component{
                     bordered
                     rowKey={ record => record.id }
                     rowSelection={rowSelection}
-                    pagination={{current: this.state.currentVideoPage}}
-                    onChange={(e) => { this.setState({ currentVideoPage: e.current }) }}
+                    pagination={paginationProps}
+                    // onChange={(e) => { this.setState({ currentVideoPage: e.current }) }}
                 >
                 </Table>