dutycard add data
parent
20b9016f51
commit
ff880de466
|
|
@ -1,4 +1,4 @@
|
||||||
import { View, Text } from '@tarojs/components';
|
import { View } from '@tarojs/components';
|
||||||
import { Component, ReactNode } from 'react';
|
import { Component, ReactNode } from 'react';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import { AtCard, AtTimeline, AtAccordion } from 'taro-ui';
|
import { AtCard, AtTimeline, AtAccordion } from 'taro-ui';
|
||||||
|
|
@ -11,19 +11,37 @@ interface CardContent {
|
||||||
title: string;
|
title: string;
|
||||||
note: string;
|
note: string;
|
||||||
extra: JSX.Element | string;
|
extra: JSX.Element | string;
|
||||||
content: JSX.Element;
|
content: () => JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mainPageCard(c: CardContent): JSX.Element {
|
function mainPageCard(c: CardContent): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<View style={{ marginTop: 10 }}>
|
<View style={{ marginTop: 10 }}>
|
||||||
<AtCard note={c.note} extra={c.extra} title={c.title}>
|
<AtCard note={c.note} extra={c.extra} title={c.title}>
|
||||||
{c.content}
|
{c.content()}
|
||||||
</AtCard>
|
</AtCard>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DutyState = 'off' | '1' | '2' | '3';
|
||||||
|
|
||||||
|
class DutyData {
|
||||||
|
constructor() {
|
||||||
|
this.isInDuty = false;
|
||||||
|
this.inDutyCnt = 3;
|
||||||
|
this.currentDuty = '2';
|
||||||
|
this.offDutyReason = '学园维修';
|
||||||
|
this.dutyRecoverTime = '下周一';
|
||||||
|
}
|
||||||
|
|
||||||
|
isInDuty: boolean;
|
||||||
|
inDutyCnt: number;
|
||||||
|
currentDuty: DutyState;
|
||||||
|
offDutyReason: string;
|
||||||
|
dutyRecoverTime: string;
|
||||||
|
}
|
||||||
|
|
||||||
class ExpandItem extends Component {
|
class ExpandItem extends Component {
|
||||||
state = {
|
state = {
|
||||||
open: false,
|
open: false,
|
||||||
|
|
@ -53,13 +71,39 @@ class ExpandItem extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
class DutyInfo extends Component {
|
class DutyInfo extends Component {
|
||||||
render(): ReactNode {
|
props = {
|
||||||
|
data: new DutyData(),
|
||||||
|
};
|
||||||
|
|
||||||
|
offDutyContent(): ReactNode {
|
||||||
|
const data = this.props.data;
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<Text>x人在岗</Text>
|
<View>当前未值班</View>
|
||||||
|
<View>{data.offDutyReason}</View>
|
||||||
|
<View>恢复值班时间:{data.dutyRecoverTime}</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inDutyContent(): ReactNode {
|
||||||
|
const data = this.props.data;
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<View>值班中</View>
|
||||||
|
<View>当前班次 {data.currentDuty}</View>
|
||||||
|
<View>当前{data.inDutyCnt}人在岗</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): ReactNode {
|
||||||
|
if (this.props.data.isInDuty) {
|
||||||
|
return this.inDutyContent();
|
||||||
|
} else {
|
||||||
|
return this.offDutyContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StepInfo extends Component {
|
class StepInfo extends Component {
|
||||||
|
|
@ -84,23 +128,24 @@ class TipsInfo extends Component {
|
||||||
|
|
||||||
export default class Index extends Component {
|
export default class Index extends Component {
|
||||||
state = {
|
state = {
|
||||||
|
dutyData: new DutyData(),
|
||||||
dutyInfoCard: {
|
dutyInfoCard: {
|
||||||
title: pt.get().mainPage.cardTitle.dutyInfo,
|
title: pt.get().mainPage.cardTitle.dutyInfo,
|
||||||
note: 'Tips',
|
note: 'Tips',
|
||||||
extra: '额外信息',
|
extra: '额外信息',
|
||||||
content: <DutyInfo />,
|
content: () => <DutyInfo data={this.state.dutyData} />,
|
||||||
},
|
},
|
||||||
stepInfoCard: {
|
stepInfoCard: {
|
||||||
title: pt.get().mainPage.cardTitle.stepInfo,
|
title: pt.get().mainPage.cardTitle.stepInfo,
|
||||||
note: 'Tips 请在20:30以前取走自己的物品哦',
|
note: 'Tips 请在20:30以前取走自己的物品哦',
|
||||||
extra: '额外信息',
|
extra: '额外信息',
|
||||||
content: <StepInfo />,
|
content: () => <StepInfo />,
|
||||||
},
|
},
|
||||||
tipsInfoCard: {
|
tipsInfoCard: {
|
||||||
title: pt.get().mainPage.cardTitle.tipsInfo,
|
title: pt.get().mainPage.cardTitle.tipsInfo,
|
||||||
note: 'Tips',
|
note: 'Tips',
|
||||||
extra: '额外信息',
|
extra: '额外信息',
|
||||||
content: <TipsInfo />,
|
content: () => <TipsInfo />,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue