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 1/2] =?UTF-8?q?=E5=88=86=E9=A1=B5=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=AF=B9=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(); + } +} + /** * 用户信息实体 */ From 30b2560ca6f8e9cffeb02c597526d514e0a2b357 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Tue, 2 Jun 2020 22:29:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20=E5=AF=B9=E6=8E=A5=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=A5=96=E5=8A=B1=E6=97=B6=E9=97=B4=E5=B8=81=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/money.svg | 1 + src/Active.tsx | 55 +++++++++++++++++++++++++++++++++++++-- src/App.test.tsx | 2 +- src/App.tsx | 3 --- src/Main.tsx | 38 ++++++++++++++++++--------- src/User.tsx | 1 + src/account/PropCookie.ts | 2 +- src/account/Register.tsx | 1 + src/api.ts | 4 ++- src/entity.ts | 6 ++++- src/index.css | 8 ++++++ src/index.tsx | 2 +- src/public.tsx | 1 - src/result.ts | 20 +++++++++++--- src/ui/MyDialog.tsx | 2 +- 15 files changed, 118 insertions(+), 28 deletions(-) create mode 100644 public/money.svg diff --git a/public/money.svg b/public/money.svg new file mode 100644 index 0000000..729d9fc --- /dev/null +++ b/public/money.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Active.tsx b/src/Active.tsx index 99f1199..c9a4d1a 100644 --- a/src/Active.tsx +++ b/src/Active.tsx @@ -3,7 +3,15 @@ import {Button, Form, Image, ListGroup, Tab, Table, Tabs} from "react-bootstrap" import {ManagerActivity, PageProps} from "./entity"; import {JSONResponse, Method, request} from "./interface"; import {API, prefix} from "./api"; -import {EmptyBodyTransform, FindActivityRes, FindActivityTransform, PageDataMessage, SimpleMessage} from "./result"; +import { + EmptyBodyTransform, + FindActivityRes, + FindActivityTransform, + FindTimeScoreRes, + PageDataMessage, + ScoreTransform, + SimpleMessage +} from "./result"; import {MyDialog} from "./ui/MyDialog"; import moment from "moment"; import {Input} from "./ui/InputGroup"; @@ -143,7 +151,7 @@ export class Active extends React.Component {active.helpUser.map((userId,index) => - {userId})} + {userId}this.loadScore(userId,active.activityId)} className="timeScore" src={"money.svg"}/>)} :'无' } @@ -200,4 +208,47 @@ export class Active extends React.Component该用户没有结算时间币记录 + }) + }else { + that.setState({ + tipContent: + + + + + + + + + + + + +
结算时间时间币
{moment(res.timeScore?.createTime).format("YYYY-MM-DD HH:mm:ss")}{res.timeScore?.timeScore}
+ }) + } + break + case SimpleMessage.fail: + that.setState({ + tipContent:

时间币查询失败,请联系管理员

+ }) + break + } + }) + } } diff --git a/src/App.test.tsx b/src/App.test.tsx index 4db7ebc..56f0583 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render } from '@testing-library/react'; +import {render} from '@testing-library/react'; import App from './App'; test('renders learn react link', () => { diff --git a/src/App.tsx b/src/App.tsx index 7e9ae08..85ed38f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,13 +2,10 @@ import React from 'react'; import './App.css'; import 'bootstrap/dist/css/bootstrap.min.css'; import {Login} from './account/Login'; -import {instanceOf} from 'prop-types'; import {Cookies, withCookies} from 'react-cookie'; import {Main} from "./Main"; import {Register} from "./account/Register"; import {manager_cookie} from "./account/PropCookie"; -import {Method, request} from "./interface"; -import {API} from "./api"; import {LoginRes} from "./result"; diff --git a/src/Main.tsx b/src/Main.tsx index 50f2ee9..a694567 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -1,11 +1,9 @@ import React from "react"; -import {Navbar,Nav,Button} from "react-bootstrap"; +import {Nav, Navbar} from "react-bootstrap"; import {Manager} from "./Manager"; import {User} from "./User"; import {Active} from "./Active"; import {Cookies} from "react-cookie"; -import {manager_cookie} from "./account/PropCookie"; -import {fontEnd} from "./api"; /** * 菜单标记 @@ -40,7 +38,17 @@ export class Main extends React.Component< //获取菜单名颜色 getMenuColor(menu:Menu){ - return this.state.menu===menu?"black":"blue" + if(this.state.menu===menu){ + return { + color:"white", + backgroundColor:"blue" + } + }else{ + return { + color:"blue", + backgroundColor: "white" + } + } } //切换菜单 @@ -65,22 +73,26 @@ export class Main extends React.Component< } } + + render() { return (
-
diff --git a/src/User.tsx b/src/User.tsx index 65079b7..7c61ce8 100644 --- a/src/User.tsx +++ b/src/User.tsx @@ -9,6 +9,7 @@ import {MyDialog} from "./ui/MyDialog"; import {Address} from "./ui/Address"; import {UploadImg} from "./ui/UploadImg"; import {Page} from "./ui/Page"; + /** * 图片尺寸限制 */ diff --git a/src/account/PropCookie.ts b/src/account/PropCookie.ts index 7323f25..0b980f4 100644 --- a/src/account/PropCookie.ts +++ b/src/account/PropCookie.ts @@ -1,4 +1,4 @@ -import {Cookies } from 'react-cookie'; +import {Cookies} from 'react-cookie'; /** * cookie信息,组件间传递 diff --git a/src/account/Register.tsx b/src/account/Register.tsx index cc3e721..16233b4 100644 --- a/src/account/Register.tsx +++ b/src/account/Register.tsx @@ -7,6 +7,7 @@ import {API} from "../api"; import {RegisterRes, RegisterTransform} from "../result"; import {MyDialog} from "../ui/MyDialog"; import {register} from '../public' + /** * 注册 */ diff --git a/src/api.ts b/src/api.ts index 0716d33..10fe2bc 100644 --- a/src/api.ts +++ b/src/api.ts @@ -29,7 +29,9 @@ export const API={ //查询活动信息 findActivity:prefix.manager+'/find/activity', //修改活动信息 - updateActivity:prefix.manager+'/update/' + updateActivity:prefix.manager+'/update/', + //加载时间币 + timeScore:prefix.manager+'/score' }, user:{ diff --git a/src/entity.ts b/src/entity.ts index 6bae0be..1d50daa 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -2,7 +2,6 @@ import {PropCookie} from "./account/PropCookie"; - export interface ManagerEntity { managerId:string; } @@ -200,3 +199,8 @@ export interface OnChangeAddress { value?:string; } +export interface TimeScore { + createTime:number; + timeScore:number; +} + diff --git a/src/index.css b/src/index.css index 3c3b1b6..1cabd84 100644 --- a/src/index.css +++ b/src/index.css @@ -27,3 +27,11 @@ code { height: 20px; width: 20px; } + +/** +时间币图标尺寸 + */ +.timeScore{ + width: 30px; + height: 30px; +} diff --git a/src/index.tsx b/src/index.tsx index a4e0dd0..50aa992 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import * as serviceWorker from './serviceWorker'; -import { CookiesProvider } from 'react-cookie'; +import {CookiesProvider} from 'react-cookie'; ReactDOM.render( diff --git a/src/public.tsx b/src/public.tsx index 247d3c5..8224b43 100644 --- a/src/public.tsx +++ b/src/public.tsx @@ -1,4 +1,3 @@ - //注册 import {JSONResponse, Method, request} from "./interface"; import {API} from "./api"; diff --git a/src/result.ts b/src/result.ts index 0b11728..5d30a64 100644 --- a/src/result.ts +++ b/src/result.ts @@ -1,6 +1,5 @@ -import {JSONResponse, Result, TransformData} from "./interface"; -import {ManagerActivity, ManagerEntity, PageProps, UserEntity} from "./entity"; -import {User} from "./User"; +import {JSONResponse, TransformData} from "./interface"; +import {ManagerActivity, ManagerEntity, PageProps, TimeScore, UserEntity} from "./entity"; /** * 空body响应 @@ -133,3 +132,18 @@ export class FindActivityTransform extends PageDataTransform{ } } + +export class FindTimeScoreRes extends JSONResponse{ + timeScore?:TimeScore; +} + +export class ScoreTransform extends TransformData{ + protected newObject(): FindTimeScoreRes { + return new FindTimeScoreRes(); + } + + + protected transformBody(data: any) { + this.target.timeScore=data.body + } +} diff --git a/src/ui/MyDialog.tsx b/src/ui/MyDialog.tsx index 5793437..e97749d 100644 --- a/src/ui/MyDialog.tsx +++ b/src/ui/MyDialog.tsx @@ -1,7 +1,7 @@ import React from "react"; import Dialog from "@material-ui/core/Dialog"; import Draggable from "react-draggable"; -import {Paper, styled, withWidth} from "@material-ui/core"; +import {Paper, styled} from "@material-ui/core"; import {MyDialogProps} from "../entity"; import {CloseDialog} from "./CloseDialog";