@ledvance/ui-biz-bundle 1.1.141 → 1.1.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/hooks/DeviceDpStateHooks.ts +1 -1
- package/src/modules/flags/FlagPage.tsx +4 -1
- package/src/modules/mood/MixMood/RecommendMixMoodItem.tsx +1 -1
- package/src/modules/mood/RecommendMoodItem.tsx +1 -1
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +1 -1
- package/src/modules/timer/TimerPage.tsx +1 -1
- package/src/newModules/biorhythm/BiorhythmActions.ts +403 -451
- package/src/newModules/biorhythm/BiorhythmBean.ts +230 -230
- package/src/newModules/biorhythm/BiorhythmEditPage.tsx +18 -20
- package/src/newModules/biorhythm/BiorhythmPage.tsx +653 -698
- package/src/newModules/biorhythm/IconSelect.tsx +88 -88
- package/src/newModules/biorhythm/Router.ts +33 -33
- package/src/newModules/biorhythm/iconListData.ts +30 -30
- package/src/newModules/biorhythm/pIdList.ts +35 -35
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +66 -28
- package/src/newModules/energyConsumption/EnergyConsumptionCard.tsx +172 -0
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +204 -118
- package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +3 -0
- package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +16 -0
- package/src/newModules/energyConsumption/co2Data.ts +5 -0
- package/src/newModules/energyConsumption/component/NewBarChart.tsx +172 -168
- package/src/newModules/energyConsumption/component/PowerLineChart.tsx +108 -0
- package/src/newModules/energyConsumption/res/energy-chart.png +0 -0
- package/src/newModules/energyConsumption/res/index.ts +3 -0
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +1 -1
- package/src/newModules/mood/RecommendMoodItem.tsx +1 -1
- package/src/newModules/sleepWakeUp/SleepWakeUpDetailPage.tsx +1 -1
- package/src/newModules/swithInching/SwithInching.tsx +1 -1
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +12 -12
- package/tsconfig.json +73 -46
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { queryDpIds } from '@ledvance/base/src/api/native'
|
|
2
|
+
import Card from '@ledvance/base/src/components/Card'
|
|
3
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
4
|
+
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
5
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
6
|
+
import { useDeviceId, useSolarPlug } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
7
|
+
import { useIsFocused, useNavigation } from '@react-navigation/native'
|
|
8
|
+
import { useInterval, useReactive } from 'ahooks'
|
|
9
|
+
import React, { useEffect } from 'react'
|
|
10
|
+
import { Image, StyleSheet, Text, View } from 'react-native'
|
|
11
|
+
import { Utils } from 'tuya-panel-kit'
|
|
12
|
+
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
13
|
+
import { getEnergyGenerationValue, useElectricCurrent, usePower, useVoltage } from './EnergyConsumptionActions'
|
|
14
|
+
import { EnergyConsumptionPageProps } from './EnergyConsumptionPage'
|
|
15
|
+
import Res from './res'
|
|
16
|
+
|
|
17
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
18
|
+
const { withTheme } = Utils.ThemeUtils
|
|
19
|
+
|
|
20
|
+
export interface EnergyConsumptionProp {
|
|
21
|
+
theme?: ThemeType
|
|
22
|
+
electricDpCode: string
|
|
23
|
+
powerDpCode: string
|
|
24
|
+
voltageDpCode: string
|
|
25
|
+
addEleDpCode: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const EnergyConsumptionCard = (props: EnergyConsumptionProp) => {
|
|
29
|
+
const devId = useDeviceId()
|
|
30
|
+
const navigation = useNavigation()
|
|
31
|
+
const isFocused = useIsFocused()
|
|
32
|
+
const isSolarPlug = useSolarPlug()
|
|
33
|
+
const power = usePower(props.powerDpCode)
|
|
34
|
+
const electricCurrent = useElectricCurrent(props.electricDpCode)
|
|
35
|
+
const voltage = useVoltage(props.voltageDpCode)
|
|
36
|
+
|
|
37
|
+
const state = useReactive({
|
|
38
|
+
loading: false,
|
|
39
|
+
flag: Symbol(),
|
|
40
|
+
isGeneration: false
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
useInterval(() => {
|
|
44
|
+
if (isFocused) {
|
|
45
|
+
const jsonData = JSON.stringify([props.electricDpCode, props.powerDpCode, props.voltageDpCode])
|
|
46
|
+
queryDpIds(jsonData, devId).then()
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
3000,
|
|
50
|
+
{ immediate: true }
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
getEnergyGenerationValue(devId).then(data => {
|
|
55
|
+
state.isGeneration = isSolarPlug !== (data?.generationMode || false)
|
|
56
|
+
})
|
|
57
|
+
}, [isFocused, isSolarPlug])
|
|
58
|
+
|
|
59
|
+
const unitDivision = (str: string) => {
|
|
60
|
+
if (!str) {
|
|
61
|
+
return ['', '']
|
|
62
|
+
}
|
|
63
|
+
const strIndex = str.indexOf('(') || str.indexOf('(')
|
|
64
|
+
const unit = str.substring(strIndex)
|
|
65
|
+
const name = str.split(unit)[0]
|
|
66
|
+
return [name, unit]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const styles = StyleSheet.create({
|
|
70
|
+
consumedEnergyCard: {
|
|
71
|
+
marginHorizontal: cx(24),
|
|
72
|
+
},
|
|
73
|
+
consumedEnergyHeadline: {
|
|
74
|
+
flexDirection: 'row',
|
|
75
|
+
justifyContent: 'space-between',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
marginHorizontal: cx(16),
|
|
78
|
+
},
|
|
79
|
+
consumedEnergyCardTitle: {
|
|
80
|
+
color: props.theme?.global.fontColor,
|
|
81
|
+
fontSize: cx(16),
|
|
82
|
+
// fontFamily: 'helvetica_neue_lt_std_bd',
|
|
83
|
+
fontWeight: 'bold',
|
|
84
|
+
},
|
|
85
|
+
consumedEnergyContent: {
|
|
86
|
+
flexDirection: 'row',
|
|
87
|
+
},
|
|
88
|
+
consumedEnergyItem: {
|
|
89
|
+
flex: 1,
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
},
|
|
92
|
+
consumedEnergyItemValue: {
|
|
93
|
+
color: props.theme?.global.secondBrand,
|
|
94
|
+
fontSize: cx(24),
|
|
95
|
+
// fontFamily: 'helvetica_neue_lt_std_bd',
|
|
96
|
+
fontWeight: 'bold',
|
|
97
|
+
},
|
|
98
|
+
consumedEnergyItemUnit: {
|
|
99
|
+
color: props.theme?.global.secondFontColor,
|
|
100
|
+
fontSize: cx(14),
|
|
101
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
102
|
+
textAlign: 'center'
|
|
103
|
+
},
|
|
104
|
+
subContent: {
|
|
105
|
+
flex: 1,
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
marginBottom: cx(9)
|
|
108
|
+
},
|
|
109
|
+
valueText: {
|
|
110
|
+
fontSize: cx(24),
|
|
111
|
+
fontWeight: 'bold',
|
|
112
|
+
color: props.theme?.global.secondBrand,
|
|
113
|
+
},
|
|
114
|
+
titleText: {
|
|
115
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
116
|
+
fontSize: cx(14),
|
|
117
|
+
color: props.theme?.global.secondFontColor,
|
|
118
|
+
textAlign: 'center',
|
|
119
|
+
},
|
|
120
|
+
unitText: {
|
|
121
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
122
|
+
fontSize: cx(14),
|
|
123
|
+
color: props.theme?.global.secondFontColor,
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const ConsumedEnergyItem = (props: { value: number, unit: string }) => {
|
|
128
|
+
return (
|
|
129
|
+
<View style={styles.subContent}>
|
|
130
|
+
<Text style={styles.valueText}>{(props.value) || 0}</Text>
|
|
131
|
+
<Spacer height={cx(4)}/>
|
|
132
|
+
<Text style={styles.titleText}>
|
|
133
|
+
{unitDivision(props.unit)[0]}
|
|
134
|
+
</Text>
|
|
135
|
+
<Text style={styles.titleText}>
|
|
136
|
+
{unitDivision(props.unit)[1]}
|
|
137
|
+
</Text>
|
|
138
|
+
</View>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return <Card
|
|
143
|
+
style={styles.consumedEnergyCard}
|
|
144
|
+
onPress={() => navigation.navigate(ui_biz_routerKey.ui_biz_energy_consumption, {
|
|
145
|
+
electricDpCode: props.electricDpCode,
|
|
146
|
+
powerDpCode: props.powerDpCode,
|
|
147
|
+
voltageDpCode: props.voltageDpCode,
|
|
148
|
+
addEleDpCode: props.addEleDpCode,
|
|
149
|
+
} as EnergyConsumptionPageProps)}>
|
|
150
|
+
<Spacer height={cx(16)}/>
|
|
151
|
+
<View style={styles.consumedEnergyHeadline}>
|
|
152
|
+
<Text
|
|
153
|
+
style={styles.consumedEnergyCardTitle}>{I18n.getLang(state.isGeneration ? 'sockets_headline_power' : 'sockets_ce')}</Text>
|
|
154
|
+
<Image source={Res.energyChart} style={{ width: cx(24), height: cx(24), tintColor: props.theme?.icon.normal }}/>
|
|
155
|
+
</View>
|
|
156
|
+
<Spacer height={cx(18)}/>
|
|
157
|
+
<View style={styles.consumedEnergyContent}>
|
|
158
|
+
<ConsumedEnergyItem
|
|
159
|
+
value={power}
|
|
160
|
+
unit={I18n.getLang('consumption_data_field2_value_text1')}/>
|
|
161
|
+
<ConsumedEnergyItem
|
|
162
|
+
value={electricCurrent}
|
|
163
|
+
unit={I18n.getLang('consumption_data_field2_value_text2')}/>
|
|
164
|
+
<ConsumedEnergyItem
|
|
165
|
+
value={voltage}
|
|
166
|
+
unit={I18n.getLang('consumption_data_field2_value_text3')}/>
|
|
167
|
+
</View>
|
|
168
|
+
<Spacer height={cx(17)}/>
|
|
169
|
+
</Card>
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export default withTheme(EnergyConsumptionCard)
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import res from "@ledvance/base/src/res";
|
|
6
|
-
import I18n from "@ledvance/base/src/i18n";
|
|
7
|
-
import {Utils} from "tuya-panel-kit";
|
|
8
|
-
import NewBarChart from "./component/NewBarChart";
|
|
9
|
-
import { loopsText, monthFormat} from "@ledvance/base/src/utils/common";
|
|
10
|
-
import {OverviewItem} from "./EnergyConsumptionPage";
|
|
11
|
-
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
12
|
-
import InfoText from "@ledvance/base/src/components/InfoText";
|
|
13
|
-
import dayjs from "dayjs";
|
|
1
|
+
import InfoText from '@ledvance/base/src/components/InfoText'
|
|
2
|
+
import Page from '@ledvance/base/src/components/Page'
|
|
3
|
+
import Segmented from '@ledvance/base/src/components/Segmented'
|
|
4
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
14
5
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
6
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
7
|
+
import { useDeviceId } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
8
|
+
import res from '@ledvance/base/src/res'
|
|
9
|
+
import { loopsText, monthFormat } from '@ledvance/base/src/utils/common'
|
|
10
|
+
import { overDays } from '@ledvance/base/src/utils/index'
|
|
11
|
+
import PowerLineChart from '@ledvance/ui-biz-bundle/src/newModules/energyConsumption/component/PowerLineChart'
|
|
12
|
+
import { useRoute } from '@react-navigation/core'
|
|
13
|
+
import { useReactive, useUpdateEffect } from 'ahooks'
|
|
14
|
+
import dayjs from 'dayjs'
|
|
15
|
+
import React, { useCallback, useMemo } from 'react'
|
|
16
|
+
import { Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
|
|
17
|
+
import { Utils } from 'tuya-panel-kit'
|
|
18
|
+
import { ChartType, DateType } from './co2Data'
|
|
19
|
+
import DateSelectedItem from './component/DateSelectedItem'
|
|
20
|
+
import DateSwitch from './component/DateSwitch'
|
|
21
|
+
import DateTypeItem from './component/DateTypeItem'
|
|
22
|
+
import NewBarChart from './component/NewBarChart'
|
|
23
|
+
import { exportEnergyCsv, getElectricity, getPowerData, PowerDataItem } from './EnergyConsumptionActions'
|
|
24
|
+
import { OverviewItem } from './EnergyConsumptionPage'
|
|
23
25
|
|
|
24
|
-
const {convertX: cx} = Utils.RatioUtils
|
|
25
|
-
const {withTheme} = Utils.ThemeUtils
|
|
26
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
27
|
+
const { withTheme } = Utils.ThemeUtils
|
|
26
28
|
|
|
27
29
|
export interface EnergyConsumptionChartProps {
|
|
28
30
|
addEleDpCode: string
|
|
31
|
+
powerDpCode: string
|
|
29
32
|
headlineText: string
|
|
30
33
|
chartData: OverviewItem[],
|
|
31
34
|
over365Days?: boolean
|
|
@@ -39,7 +42,7 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
|
|
|
39
42
|
const devId = useDeviceId()
|
|
40
43
|
|
|
41
44
|
const params = useRoute().params as EnergyConsumptionChartProps
|
|
42
|
-
const {price, unit, date, addEleDpCode, over365Days, over7Days} = params
|
|
45
|
+
const { price, unit, date, addEleDpCode, powerDpCode, over365Days, over7Days } = params
|
|
43
46
|
const styles = StyleSheet.create({
|
|
44
47
|
listEmptyView: {
|
|
45
48
|
alignItems: 'center',
|
|
@@ -58,25 +61,53 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
|
|
|
58
61
|
position: 'absolute',
|
|
59
62
|
right: 0,
|
|
60
63
|
top: cx(10)
|
|
64
|
+
},
|
|
65
|
+
intervalContainer: {
|
|
66
|
+
flexDirection: 'row',
|
|
67
|
+
justifyContent: 'center',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
},
|
|
70
|
+
intervalItem: {
|
|
71
|
+
flex: 1,
|
|
72
|
+
marginHorizontal: cx(5),
|
|
73
|
+
padding: cx(5),
|
|
74
|
+
borderWidth: cx(1),
|
|
75
|
+
borderRadius: cx(25),
|
|
76
|
+
borderColor: props.theme?.icon.normal,
|
|
77
|
+
},
|
|
78
|
+
intervalItemChecked: {
|
|
79
|
+
borderColor: props.theme?.icon.primary,
|
|
80
|
+
},
|
|
81
|
+
intervalText: {
|
|
82
|
+
textAlign: 'center',
|
|
83
|
+
color: props.theme?.global.fontColor,
|
|
84
|
+
},
|
|
85
|
+
intervalTextChecked: {
|
|
86
|
+
textAlign: 'center',
|
|
87
|
+
color: props.theme?.icon.primary,
|
|
61
88
|
}
|
|
62
|
-
})
|
|
89
|
+
})
|
|
63
90
|
|
|
64
91
|
const getDateType = useCallback((date: string) => {
|
|
65
|
-
const datejs = dayjs(date)
|
|
92
|
+
const datejs = dayjs(date)
|
|
66
93
|
if (datejs.isValid()) {
|
|
67
94
|
if (datejs.format('YYYY') === date) {
|
|
68
|
-
return DateType.Year
|
|
95
|
+
return DateType.Year
|
|
69
96
|
} else if (datejs.format('YYYYMM') === date) {
|
|
70
|
-
return DateType.Month
|
|
97
|
+
return DateType.Month
|
|
71
98
|
} else if (datejs.format('YYYY/MM/DD') === date) {
|
|
72
|
-
return DateType.Day
|
|
99
|
+
return DateType.Day
|
|
73
100
|
}
|
|
74
101
|
}
|
|
75
|
-
return DateType.Day
|
|
76
|
-
}, [])
|
|
77
|
-
const dateType = getDateType(date)
|
|
102
|
+
return DateType.Day
|
|
103
|
+
}, [])
|
|
104
|
+
const dateType = getDateType(date)
|
|
105
|
+
const intervalLabels = useMemo(() => {
|
|
106
|
+
return ['charttime_type1', 'charttime_type2', 'charttime_type3', 'charttime_type4']
|
|
107
|
+
}, [])
|
|
78
108
|
const state = useReactive({
|
|
79
109
|
loading: false,
|
|
110
|
+
chartType: ChartType.kWh,
|
|
80
111
|
dateType: dateType,
|
|
81
112
|
date: date,
|
|
82
113
|
headlineText: dateType === DateType.Year ? date : params.headlineText,
|
|
@@ -86,20 +117,31 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
|
|
|
86
117
|
price: isNaN(Number(price)) ? 0 : Number(price),
|
|
87
118
|
over365Days: over365Days,
|
|
88
119
|
over7Days: over7Days,
|
|
89
|
-
|
|
120
|
+
interval: 5,
|
|
121
|
+
powerData: [] as PowerDataItem[]
|
|
122
|
+
})
|
|
90
123
|
|
|
91
124
|
useUpdateEffect(() => {
|
|
92
|
-
state.over365Days = overDays(state.date, 365)
|
|
93
|
-
state.over7Days = overDays(state.date, 7)
|
|
94
|
-
updateHeadlineText(dayjs(state.date))
|
|
95
|
-
state.loading = true
|
|
96
|
-
|
|
97
|
-
state.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
125
|
+
state.over365Days = overDays(state.date, 365)
|
|
126
|
+
state.over7Days = overDays(state.date, 7)
|
|
127
|
+
updateHeadlineText(dayjs(state.date))
|
|
128
|
+
state.loading = true
|
|
129
|
+
if (state.chartType === ChartType.kWh) {
|
|
130
|
+
getElectricity(devId, addEleDpCode, state.date, state.dateType).then((res) => {
|
|
131
|
+
state.chartData = res
|
|
132
|
+
state.loading = false
|
|
133
|
+
}).catch(() => {
|
|
134
|
+
state.loading = false
|
|
135
|
+
})
|
|
136
|
+
} else {
|
|
137
|
+
getPowerData(devId, powerDpCode, state.interval).then((res: PowerDataItem[]) => {
|
|
138
|
+
state.powerData = res
|
|
139
|
+
state.loading = false
|
|
140
|
+
}).catch(() => {
|
|
141
|
+
state.loading = false
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
}, [state.chartType, state.date])
|
|
103
145
|
|
|
104
146
|
const getEmptyDataTip = useCallback(() => {
|
|
105
147
|
if (state.over365Days && state.dateType !== DateType.Day) {
|
|
@@ -109,34 +151,34 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
|
|
|
109
151
|
return I18n.getLang('energyconsumption_hourlylimit')
|
|
110
152
|
}
|
|
111
153
|
return I18n.getLang('energyconsumption_emptydata')
|
|
112
|
-
}, [state.dateType, state.over365Days, state.over7Days])
|
|
154
|
+
}, [state.dateType, state.over365Days, state.over7Days])
|
|
113
155
|
|
|
114
156
|
const updateHeadlineText = useCallback((date: dayjs.Dayjs) => {
|
|
115
|
-
const year = date.year().toString()
|
|
116
|
-
const month = (date.month() + 1).toString().padStart(2, '0')
|
|
117
|
-
const day = date.date().toString().padStart(2, '0')
|
|
118
|
-
const dayOfWeek = date.day() % 7
|
|
157
|
+
const year = date.year().toString()
|
|
158
|
+
const month = (date.month() + 1).toString().padStart(2, '0')
|
|
159
|
+
const day = date.date().toString().padStart(2, '0')
|
|
160
|
+
const dayOfWeek = date.day() % 7
|
|
119
161
|
switch (state.dateType) {
|
|
120
162
|
case DateType.Year:
|
|
121
|
-
state.headlineText = year
|
|
163
|
+
state.headlineText = year
|
|
122
164
|
break
|
|
123
165
|
case DateType.Month:
|
|
124
|
-
state.headlineText = `${monthFormat(month)} ${year}
|
|
166
|
+
state.headlineText = `${monthFormat(month)} ${year}`
|
|
125
167
|
break
|
|
126
168
|
case DateType.Day:
|
|
127
|
-
state.headlineText = `${day}/${month}/${year}\n${loopsText[dayOfWeek]}
|
|
169
|
+
state.headlineText = `${day}/${month}/${year}\n${loopsText[dayOfWeek]}`
|
|
128
170
|
break
|
|
129
171
|
}
|
|
130
|
-
}, [state.dateType, state.headlineText])
|
|
172
|
+
}, [state.dateType, state.headlineText])
|
|
131
173
|
|
|
132
174
|
useUpdateEffect(() => {
|
|
133
|
-
const date = dayjs()
|
|
134
|
-
const year = date.year().toString()
|
|
135
|
-
const month = (date.month() + 1).toString().padStart(2, '0')
|
|
136
|
-
const day = date.date().toString().padStart(2, '0')
|
|
175
|
+
const date = dayjs()
|
|
176
|
+
const year = date.year().toString()
|
|
177
|
+
const month = (date.month() + 1).toString().padStart(2, '0')
|
|
178
|
+
const day = date.date().toString().padStart(2, '0')
|
|
137
179
|
switch (state.dateType) {
|
|
138
180
|
case DateType.Year:
|
|
139
|
-
state.date = year
|
|
181
|
+
state.date = year
|
|
140
182
|
break
|
|
141
183
|
case DateType.Month:
|
|
142
184
|
state.date = `${year}${month}`
|
|
@@ -145,79 +187,123 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
|
|
|
145
187
|
state.date = `${year}${month}${day}`
|
|
146
188
|
break
|
|
147
189
|
}
|
|
148
|
-
}, [state.dateType])
|
|
190
|
+
}, [state.dateType])
|
|
191
|
+
|
|
192
|
+
const requestPowerData = useCallback((interval: number) => {
|
|
193
|
+
state.loading = true
|
|
194
|
+
getPowerData(devId, powerDpCode, interval).then((res: PowerDataItem[]) => {
|
|
195
|
+
state.powerData = res
|
|
196
|
+
state.loading = false
|
|
197
|
+
}).catch(() => {
|
|
198
|
+
state.loading = false
|
|
199
|
+
})
|
|
200
|
+
}, [])
|
|
149
201
|
|
|
150
202
|
return (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
203
|
+
<Page
|
|
204
|
+
backText={I18n.getLang('consumption_data_annual_bar_chart_system_back_text')}
|
|
205
|
+
showGreenery={false}
|
|
206
|
+
loading={state.loading}
|
|
207
|
+
greeneryIcon={res.energy_consumption_greenery}
|
|
208
|
+
>
|
|
209
|
+
<ScrollView nestedScrollEnabled={true} style={{ marginHorizontal: cx(24) }}>
|
|
210
|
+
<Spacer/>
|
|
211
|
+
|
|
212
|
+
<Segmented
|
|
213
|
+
options={[
|
|
214
|
+
{ label: I18n.getLang('chartdisplay_energy'), value: ChartType.kWh },
|
|
215
|
+
{ label: I18n.getLang('chartdisplay_power'), value: ChartType.Watt }
|
|
216
|
+
]}
|
|
217
|
+
value={state.chartType}
|
|
218
|
+
onChange={(chartType: ChartType) => {
|
|
219
|
+
state.chartType = chartType
|
|
220
|
+
}}/>
|
|
221
|
+
{
|
|
222
|
+
state.chartType === ChartType.kWh ? (
|
|
223
|
+
<>
|
|
224
|
+
<View style={{ width: '100%', flexDirection: 'row', marginVertical: cx(15) }}>
|
|
225
|
+
<DateSwitch
|
|
226
|
+
style={{ flex: 1 }}
|
|
160
227
|
date={state.date}
|
|
161
228
|
dateType={state.dateType}
|
|
162
229
|
headlineText={state.headlineText}
|
|
163
230
|
onDateChange={(date) => {
|
|
164
|
-
state.date = date
|
|
231
|
+
state.date = date
|
|
165
232
|
}}/>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
<Image
|
|
173
|
-
style={styles.downloadIcon}
|
|
174
|
-
source={{ uri: state.chartData?.length ? res.download_icon : undefined}}/>
|
|
175
|
-
</TouchableOpacity>
|
|
176
|
-
</View>
|
|
177
|
-
}
|
|
178
|
-
>
|
|
179
|
-
<View style={{marginHorizontal: cx(24)}}>
|
|
180
|
-
|
|
181
|
-
<View style={{flexDirection: 'row'}}>
|
|
182
|
-
<DateTypeItem
|
|
183
|
-
style={{flex: 1}}
|
|
184
|
-
dateType={state.dateType}
|
|
185
|
-
onDateTypeChange={(dateType) => {
|
|
186
|
-
state.dateType = dateType;
|
|
187
|
-
}}/>
|
|
188
|
-
<DateSelectedItem
|
|
189
|
-
style={{flex: 1, marginStart: cx(10),marginBottom:cx(15)}}
|
|
190
|
-
dateType={state.dateType}
|
|
191
|
-
date={state.date}
|
|
192
|
-
onDateChange={date => {
|
|
193
|
-
state.date = date;
|
|
194
|
-
}}
|
|
195
|
-
/>
|
|
196
|
-
|
|
197
|
-
</View>
|
|
198
|
-
{
|
|
199
|
-
(state.chartData.length <= 0) ? (
|
|
200
|
-
<View style={styles.listEmptyView}>
|
|
201
|
-
<Spacer height={cx(26)}/>
|
|
233
|
+
<TouchableOpacity
|
|
234
|
+
style={{ width: cx(30) }}
|
|
235
|
+
onPress={() => {
|
|
236
|
+
const values = state.chartData.map(item => [item.key, item.value, (Number(params.price) * Number(item.value)).toFixed(2)])
|
|
237
|
+
exportEnergyCsv(values, params.unit)
|
|
238
|
+
}}>
|
|
202
239
|
<Image
|
|
240
|
+
style={styles.downloadIcon}
|
|
241
|
+
source={{ uri: state.chartData?.length ? res.download_icon : undefined }}/>
|
|
242
|
+
</TouchableOpacity>
|
|
243
|
+
</View>
|
|
244
|
+
<View style={{ flexDirection: 'row', marginBottom: cx(15) }}>
|
|
245
|
+
<DateTypeItem
|
|
246
|
+
style={{ flex: 1, marginHorizontal: cx(5) }}
|
|
247
|
+
dateType={state.dateType}
|
|
248
|
+
onDateTypeChange={(dateType) => {
|
|
249
|
+
state.dateType = dateType
|
|
250
|
+
}}/>
|
|
251
|
+
<DateSelectedItem
|
|
252
|
+
style={{ flex: 1 }}
|
|
253
|
+
dateType={state.dateType}
|
|
254
|
+
date={state.date}
|
|
255
|
+
onDateChange={date => {
|
|
256
|
+
state.date = date
|
|
257
|
+
}}
|
|
258
|
+
/>
|
|
259
|
+
</View>
|
|
260
|
+
{
|
|
261
|
+
(state.chartData.length <= 0) ? (
|
|
262
|
+
<View style={styles.listEmptyView}>
|
|
263
|
+
<Spacer height={cx(26)}/>
|
|
264
|
+
<Image
|
|
203
265
|
style={styles.listEmptyImage}
|
|
204
|
-
source={{uri: res.ldv_timer_empty}}/>
|
|
205
|
-
|
|
206
|
-
|
|
266
|
+
source={{ uri: res.ldv_timer_empty }}/>
|
|
267
|
+
<Spacer height={cx(14)}/>
|
|
268
|
+
<InfoText
|
|
207
269
|
text={getEmptyDataTip()}
|
|
208
270
|
icon={res.ic_info}
|
|
209
271
|
textStyle={styles.listEmptyText}
|
|
210
272
|
contentColor={props.theme?.global.fontColor}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
273
|
+
/>
|
|
274
|
+
</View>
|
|
275
|
+
) : (
|
|
276
|
+
!state.loading && <NewBarChart height={cx(400)} data={state.chartData} price={state.price} unit={unit}/>
|
|
277
|
+
)
|
|
278
|
+
}
|
|
279
|
+
</>
|
|
280
|
+
) : (
|
|
281
|
+
<>
|
|
282
|
+
{!state.loading ? <PowerLineChart height={cx(400)} data={state.powerData}/> :
|
|
283
|
+
<View style={{ height: cx(400) }}></View>}
|
|
284
|
+
<View style={styles.intervalContainer}>
|
|
285
|
+
{
|
|
286
|
+
[24 * 60, 6 * 60, 60, 5].map((item, index) => {
|
|
287
|
+
const isChecked = item === state.interval
|
|
288
|
+
return (
|
|
289
|
+
<TouchableOpacity
|
|
290
|
+
key={index}
|
|
291
|
+
style={[styles.intervalItem, isChecked ? styles.intervalItemChecked : {}]}
|
|
292
|
+
onPress={() => {
|
|
293
|
+
state.interval = item
|
|
294
|
+
requestPowerData(item)
|
|
295
|
+
}}>
|
|
296
|
+
<Text
|
|
297
|
+
style={isChecked ? styles.intervalTextChecked : styles.intervalText}>{I18n.getLang(intervalLabels[index])}</Text>
|
|
298
|
+
</TouchableOpacity>)
|
|
299
|
+
})
|
|
300
|
+
}
|
|
301
|
+
</View>
|
|
302
|
+
</>
|
|
303
|
+
)
|
|
304
|
+
}
|
|
305
|
+
</ScrollView>
|
|
306
|
+
</Page>
|
|
221
307
|
)
|
|
222
308
|
}
|
|
223
309
|
|
|
@@ -28,6 +28,7 @@ const { withTheme } = Utils.ThemeUtils
|
|
|
28
28
|
|
|
29
29
|
export interface EnergyConsumptionDetailProps {
|
|
30
30
|
addEleDpCode: string
|
|
31
|
+
powerDpCode: string
|
|
31
32
|
curMonth: OverviewItem
|
|
32
33
|
price: string
|
|
33
34
|
unit: string
|
|
@@ -282,6 +283,7 @@ const EnergyConsumptionDetail = (props: {theme?: ThemeType}) => {
|
|
|
282
283
|
price:state.price,
|
|
283
284
|
unit:state.unit,
|
|
284
285
|
addEleDpCode:params.addEleDpCode,
|
|
286
|
+
powerDpCode: params.powerDpCode,
|
|
285
287
|
date:params.curMonth.headlineText,
|
|
286
288
|
} as EnergyConsumptionChartProps)
|
|
287
289
|
}}
|
|
@@ -296,6 +298,7 @@ const EnergyConsumptionDetail = (props: {theme?: ThemeType}) => {
|
|
|
296
298
|
price:state.price,
|
|
297
299
|
unit:state.unit,
|
|
298
300
|
addEleDpCode:params.addEleDpCode,
|
|
301
|
+
powerDpCode: params.powerDpCode,
|
|
299
302
|
date:item.headlineText,
|
|
300
303
|
} as EnergyConsumptionChartProps)
|
|
301
304
|
}}
|
|
@@ -353,6 +353,20 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
|
|
|
353
353
|
<Spacer />
|
|
354
354
|
<Card
|
|
355
355
|
style={styles.cardContainer}
|
|
356
|
+
onPress={() => {
|
|
357
|
+
if (!state.price) {
|
|
358
|
+
return
|
|
359
|
+
}
|
|
360
|
+
navigation.navigate(ui_biz_routerKey.ui_biz_energy_consumption_chart, {
|
|
361
|
+
headlineText: chartHeadline,
|
|
362
|
+
chartData: state.overviewList,
|
|
363
|
+
price: state.price,
|
|
364
|
+
unit: state.unit,
|
|
365
|
+
addEleDpCode: params.addEleDpCode,
|
|
366
|
+
powerDpCode: params.powerDpCode,
|
|
367
|
+
date: (new Date()).getFullYear().toString(),
|
|
368
|
+
} as EnergyConsumptionChartProps)
|
|
369
|
+
}}
|
|
356
370
|
>
|
|
357
371
|
<Text style={styles.cardTitle}>{I18n.getLang('consumption_data_field2_headline_text')}</Text>
|
|
358
372
|
<Spacer height={cx(15)} />
|
|
@@ -495,12 +509,14 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
|
|
|
495
509
|
price: state.price,
|
|
496
510
|
unit: state.unit,
|
|
497
511
|
addEleDpCode: params.addEleDpCode,
|
|
512
|
+
powerDpCode: params.powerDpCode,
|
|
498
513
|
date: (new Date()).getFullYear().toString(),
|
|
499
514
|
} as EnergyConsumptionChartProps)
|
|
500
515
|
}}
|
|
501
516
|
overviewItemClick={(item) => {
|
|
502
517
|
navigation.navigate(ui_biz_routerKey.ui_biz_energy_consumption_detail, {
|
|
503
518
|
addEleDpCode: params.addEleDpCode,
|
|
519
|
+
powerDpCode: params.powerDpCode,
|
|
504
520
|
curMonth: item,
|
|
505
521
|
price: state.price,
|
|
506
522
|
unit: state.unit,
|
|
@@ -23659,3 +23659,8 @@ export enum DateType {
|
|
|
23659
23659
|
Month = 'Month',
|
|
23660
23660
|
Day = 'Day',
|
|
23661
23661
|
}
|
|
23662
|
+
|
|
23663
|
+
export enum ChartType {
|
|
23664
|
+
kWh = 'kWh',
|
|
23665
|
+
Watt = 'Watt',
|
|
23666
|
+
}
|