From c7f8558e8cc074df591fb7b13f4777c1f17fb205 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Tue, 2 Jun 2020 12:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5=E9=80=BB=E8=BE=91=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=E6=9C=8D=E5=8A=A1=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Active.tsx | 16 +++++++++++----- src/Manager.tsx | 22 +++++++++++++++------- src/User.tsx | 10 ++++++++-- src/result.ts | 29 +++++++++++++---------------- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/src/Active.tsx b/src/Active.tsx index a26a652..99f1199 100644 --- a/src/Active.tsx +++ b/src/Active.tsx @@ -1,6 +1,6 @@ import React from "react"; import {Button, Form, Image, ListGroup, Tab, Table, Tabs} from "react-bootstrap"; -import {ManagerActivity} from "./entity"; +import {ManagerActivity, PageProps} from "./entity"; import {JSONResponse, Method, request} from "./interface"; import {API, prefix} from "./api"; import {EmptyBodyTransform, FindActivityRes, FindActivityTransform, PageDataMessage, SimpleMessage} from "./result"; @@ -8,6 +8,7 @@ import {MyDialog} from "./ui/MyDialog"; import moment from "moment"; import {Input} from "./ui/InputGroup"; import {UploadImg} from "./ui/UploadImg"; +import {Page} from "./ui/Page"; const contentMaxLength=50 /** @@ -68,7 +69,8 @@ class EditActive extends React.Component< export class Active extends React.Component; tipContent:JSX.Element|null - dialog:JSX.Element|null + dialog:JSX.Element|null, + page?:PageProps }>{ @@ -77,7 +79,7 @@ export class Active extends React.Component + {this.state.page?this.loadActive(page)} currentPage={this.state.page.currentPage} + totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/> + :丢失分页数据} + {this.state.dialog} { constructor(props: Readonly) { @@ -98,7 +100,7 @@ export class Manager extends React.Component< this.state={ tipContent: null, - dialog:null, + dialog:null } } @@ -138,12 +140,17 @@ export class Manager extends React.Component< currentPage:page+"" },new ManagerTransform(),function (res:ManagerList) { switch (res.customResult) { - case SimpleMessage.ok: + case PageDataMessage.ok: that.setState({ - managerList:res.dataList + managerList:res.dataList, + page: res.page + }) + break + case PageDataMessage.fail: + that.setState({ + tipContent:

加载数据失败,请联系管理员

}) break - case SimpleMessage.fail: } }) @@ -234,11 +241,12 @@ export class Manager extends React.Component< + {this.state.page?this.loadManager(page)} currentPage={this.state.page.currentPage} + totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/>:null} {this.state.dialog} - this.setState({ tipContent:null diff --git a/src/User.tsx b/src/User.tsx index 6625657..65079b7 100644 --- a/src/User.tsx +++ b/src/User.tsx @@ -1,6 +1,6 @@ import React from "react"; import {Button, Form, Image, Tab, Table, Tabs} from "react-bootstrap"; -import {UserEntity, UserType} from "./entity"; +import {PageProps, UserEntity, UserType} from "./entity"; import {Input} from "./ui/InputGroup"; import {JSONResponse, Method, request} from "./interface"; import {API, prefix} from "./api"; @@ -8,6 +8,7 @@ import {EmptyBodyTransform, FindUserRes, FindUserTransform, PageDataMessage, Sim import {MyDialog} from "./ui/MyDialog"; import {Address} from "./ui/Address"; import {UploadImg} from "./ui/UploadImg"; +import {Page} from "./ui/Page"; /** * 图片尺寸限制 */ @@ -162,6 +163,7 @@ export class User extends React.Component< user?:UserEntity; headImg?:string; dialog:JSX.Element|null; + page?:PageProps; }>{ @@ -186,7 +188,8 @@ export class User extends React.Component< switch (res.customResult) { case PageDataMessage.ok: that.setState({ - userList:res.dataList + userList:res.dataList, + page:res.page }) break case PageDataMessage.fail: @@ -264,6 +267,9 @@ export class User extends React.Component< + {this.state.page?this.loadUser(page)} currentPage={this.state.page.currentPage} + totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/> + :丢失分页数据} {this.state.dialog} diff --git a/src/result.ts b/src/result.ts index 6ba9519..0b11728 100644 --- a/src/result.ts +++ b/src/result.ts @@ -65,22 +65,6 @@ export class RegisterTransform extends EmptyBodyDiffMsg{ } -export class ManagerList extends JSONResponse{ - dataList?:Array -} - -export class ManagerTransform extends TransformData{ - protected newObject(): ManagerList { - return new ManagerList(); - } - - protected transformBody(data: any) { - if (data.body) { - this.target.dataList = data.body.body - } - } -} - /** * 分页数据转换 */ @@ -110,6 +94,19 @@ export abstract class PageDataTransform extends Transform } } + + + +export class ManagerList extends PageDataRes{ + dataList?:Array +} + +export class ManagerTransform extends PageDataTransform{ + protected newObject(): ManagerList { + return new ManagerList(); + } +} + /** * 用户信息实体 */