@ledvance/ui-biz-bundle 1.1.142 → 1.1.144

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.
Files changed (28) hide show
  1. package/package.json +1 -1
  2. package/src/hooks/DeviceDpStateHooks.ts +1 -1
  3. package/src/modules/flags/FlagPage.tsx +4 -1
  4. package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +1 -1
  5. package/src/modules/timer/TimerPage.tsx +1 -1
  6. package/src/newModules/biorhythm/BiorhythmActions.ts +403 -451
  7. package/src/newModules/biorhythm/BiorhythmBean.ts +230 -230
  8. package/src/newModules/biorhythm/BiorhythmEditPage.tsx +18 -20
  9. package/src/newModules/biorhythm/BiorhythmPage.tsx +653 -698
  10. package/src/newModules/biorhythm/IconSelect.tsx +88 -88
  11. package/src/newModules/biorhythm/Router.ts +33 -33
  12. package/src/newModules/biorhythm/iconListData.ts +30 -30
  13. package/src/newModules/biorhythm/pIdList.ts +35 -35
  14. package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +67 -28
  15. package/src/newModules/energyConsumption/EnergyConsumptionCard.tsx +172 -0
  16. package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +234 -118
  17. package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +3 -0
  18. package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +16 -0
  19. package/src/newModules/energyConsumption/co2Data.ts +5 -0
  20. package/src/newModules/energyConsumption/component/NewBarChart.tsx +172 -168
  21. package/src/newModules/energyConsumption/component/PowerLineChart.tsx +101 -0
  22. package/src/newModules/energyConsumption/res/energy-chart.png +0 -0
  23. package/src/newModules/energyConsumption/res/index.ts +3 -0
  24. package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +1 -1
  25. package/src/newModules/sleepWakeUp/SleepWakeUpDetailPage.tsx +1 -1
  26. package/src/newModules/swithInching/SwithInching.tsx +1 -1
  27. package/src/newModules/timeSchedule/TimeScheduleActions.ts +12 -12
  28. 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,36 @@
1
- import React, { useCallback } from "react";
2
- import {Image, StyleSheet, View, TouchableOpacity} from "react-native";
3
- import {useRoute} from '@react-navigation/core'
4
- import Page from "@ledvance/base/src/components/Page";
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 { queryDpIds } from '@ledvance/base/src/api/native'
2
+ import InfoText from '@ledvance/base/src/components/InfoText'
3
+ import Page from '@ledvance/base/src/components/Page'
4
+ import Segmented from '@ledvance/base/src/components/Segmented'
5
+ import Spacer from '@ledvance/base/src/components/Spacer'
14
6
  import ThemeType from '@ledvance/base/src/config/themeType'
15
- import {overDays} from "@ledvance/base/src/utils/index";
16
- import DateTypeItem from "./component/DateTypeItem";
17
- import {DateType} from "./co2Data";
18
- import DateSelectedItem from "./component/DateSelectedItem";
19
- import {useReactive, useUpdateEffect} from "ahooks";
20
- import {exportEnergyCsv, getElectricity} from "./EnergyConsumptionActions";
21
- import {useDeviceId} from "@ledvance/base/src/models/modules/NativePropsSlice";
22
- import DateSwitch from "./component/DateSwitch";
7
+ import I18n from '@ledvance/base/src/i18n'
8
+ import { useDeviceId } from '@ledvance/base/src/models/modules/NativePropsSlice'
9
+ import res from '@ledvance/base/src/res'
10
+ import { loopsText, monthFormat } from '@ledvance/base/src/utils/common'
11
+ import { overDays } from '@ledvance/base/src/utils'
12
+ import { useIsFocused } from '@react-navigation/core'
13
+ import PowerLineChart from './component/PowerLineChart'
14
+ import { useRoute } from '@react-navigation/core'
15
+ import { useInterval, useReactive, useUpdateEffect } from 'ahooks'
16
+ import dayjs from 'dayjs'
17
+ import React, { useCallback, useMemo } from 'react'
18
+ import { Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
19
+ import { Utils } from 'tuya-panel-kit'
20
+ import { ChartType, DateType } from './co2Data'
21
+ import DateSelectedItem from './component/DateSelectedItem'
22
+ import DateSwitch from './component/DateSwitch'
23
+ import DateTypeItem from './component/DateTypeItem'
24
+ import NewBarChart from './component/NewBarChart'
25
+ import { exportEnergyCsv, getElectricity, getPowerData, PowerDataItem } from './EnergyConsumptionActions'
26
+ import { OverviewItem } from './EnergyConsumptionPage'
23
27
 
24
- const {convertX: cx} = Utils.RatioUtils
25
- const {withTheme} = Utils.ThemeUtils
28
+ const { convertX: cx } = Utils.RatioUtils
29
+ const { withTheme } = Utils.ThemeUtils
26
30
 
27
31
  export interface EnergyConsumptionChartProps {
28
32
  addEleDpCode: string
33
+ powerDpCode: string
29
34
  headlineText: string
30
35
  chartData: OverviewItem[],
31
36
  over365Days?: boolean
@@ -37,9 +42,20 @@ export interface EnergyConsumptionChartProps {
37
42
 
38
43
  const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
39
44
  const devId = useDeviceId()
45
+ const isFocused = useIsFocused()
40
46
 
41
47
  const params = useRoute().params as EnergyConsumptionChartProps
42
- const {price, unit, date, addEleDpCode, over365Days, over7Days} = params;
48
+ const { price, unit, date, addEleDpCode, powerDpCode, over365Days, over7Days } = params
49
+
50
+ useInterval(() => {
51
+ if (isFocused) {
52
+ const jsonData = JSON.stringify([powerDpCode])
53
+ queryDpIds(jsonData, devId).then()
54
+ }
55
+ },
56
+ 5000,
57
+ {immediate: true}
58
+ )
43
59
  const styles = StyleSheet.create({
44
60
  listEmptyView: {
45
61
  alignItems: 'center',
@@ -58,25 +74,53 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
58
74
  position: 'absolute',
59
75
  right: 0,
60
76
  top: cx(10)
77
+ },
78
+ intervalContainer: {
79
+ flexDirection: 'row',
80
+ justifyContent: 'center',
81
+ alignItems: 'center',
82
+ },
83
+ intervalItem: {
84
+ flex: 1,
85
+ marginHorizontal: cx(5),
86
+ padding: cx(5),
87
+ borderWidth: cx(1),
88
+ borderRadius: cx(25),
89
+ borderColor: props.theme?.icon.normal,
90
+ },
91
+ intervalItemChecked: {
92
+ borderColor: props.theme?.icon.primary,
93
+ },
94
+ intervalText: {
95
+ textAlign: 'center',
96
+ color: props.theme?.global.fontColor,
97
+ },
98
+ intervalTextChecked: {
99
+ textAlign: 'center',
100
+ color: props.theme?.icon.primary,
61
101
  }
62
- });
102
+ })
63
103
 
64
104
  const getDateType = useCallback((date: string) => {
65
- const datejs = dayjs(date);
105
+ const datejs = dayjs(date)
66
106
  if (datejs.isValid()) {
67
107
  if (datejs.format('YYYY') === date) {
68
- return DateType.Year;
108
+ return DateType.Year
69
109
  } else if (datejs.format('YYYYMM') === date) {
70
- return DateType.Month;
110
+ return DateType.Month
71
111
  } else if (datejs.format('YYYY/MM/DD') === date) {
72
- return DateType.Day;
112
+ return DateType.Day
73
113
  }
74
114
  }
75
- return DateType.Day;
76
- }, []);
77
- const dateType = getDateType(date);
115
+ return DateType.Day
116
+ }, [])
117
+ const dateType = getDateType(date)
118
+ const intervalLabels = useMemo(() => {
119
+ return ['charttime_type1', 'charttime_type2', 'charttime_type3', 'charttime_type4']
120
+ }, [])
78
121
  const state = useReactive({
79
122
  loading: false,
123
+ chartType: ChartType.kWh,
80
124
  dateType: dateType,
81
125
  date: date,
82
126
  headlineText: dateType === DateType.Year ? date : params.headlineText,
@@ -86,20 +130,31 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
86
130
  price: isNaN(Number(price)) ? 0 : Number(price),
87
131
  over365Days: over365Days,
88
132
  over7Days: over7Days,
89
- });
133
+ interval: 5,
134
+ powerData: [] as PowerDataItem[]
135
+ })
90
136
 
91
137
  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
- getElectricity(devId, addEleDpCode, state.date, state.dateType).then((res) => {
97
- state.chartData = res;
98
- state.loading = false;
99
- }).catch(()=>{
100
- state.loading = false;
101
- });
102
- }, [state.date]);
138
+ state.over365Days = overDays(state.date, 365)
139
+ state.over7Days = overDays(state.date, 7)
140
+ updateHeadlineText(dayjs(state.date))
141
+ state.loading = true
142
+ if (state.chartType === ChartType.kWh) {
143
+ getElectricity(devId, addEleDpCode, state.date, state.dateType).then((res) => {
144
+ state.chartData = res
145
+ state.loading = false
146
+ }).catch(() => {
147
+ state.loading = false
148
+ })
149
+ } else {
150
+ getPowerData(devId, powerDpCode, state.interval).then((res: PowerDataItem[]) => {
151
+ state.powerData = res
152
+ state.loading = false
153
+ }).catch(() => {
154
+ state.loading = false
155
+ })
156
+ }
157
+ }, [state.chartType, state.date])
103
158
 
104
159
  const getEmptyDataTip = useCallback(() => {
105
160
  if (state.over365Days && state.dateType !== DateType.Day) {
@@ -109,34 +164,34 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
109
164
  return I18n.getLang('energyconsumption_hourlylimit')
110
165
  }
111
166
  return I18n.getLang('energyconsumption_emptydata')
112
- }, [state.dateType, state.over365Days, state.over7Days]);
167
+ }, [state.dateType, state.over365Days, state.over7Days])
113
168
 
114
169
  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;
170
+ const year = date.year().toString()
171
+ const month = (date.month() + 1).toString().padStart(2, '0')
172
+ const day = date.date().toString().padStart(2, '0')
173
+ const dayOfWeek = date.day() % 7
119
174
  switch (state.dateType) {
120
175
  case DateType.Year:
121
- state.headlineText = year;
176
+ state.headlineText = year
122
177
  break
123
178
  case DateType.Month:
124
- state.headlineText = `${monthFormat(month)} ${year}`;
179
+ state.headlineText = `${monthFormat(month)} ${year}`
125
180
  break
126
181
  case DateType.Day:
127
- state.headlineText = `${day}/${month}/${year}\n${loopsText[dayOfWeek]}`;
182
+ state.headlineText = `${day}/${month}/${year} (${loopsText[dayOfWeek]})`
128
183
  break
129
184
  }
130
- }, [state.dateType, state.headlineText]);
185
+ }, [state.dateType, state.headlineText])
131
186
 
132
187
  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');
188
+ const date = dayjs()
189
+ const year = date.year().toString()
190
+ const month = (date.month() + 1).toString().padStart(2, '0')
191
+ const day = date.date().toString().padStart(2, '0')
137
192
  switch (state.dateType) {
138
193
  case DateType.Year:
139
- state.date = year;
194
+ state.date = year
140
195
  break
141
196
  case DateType.Month:
142
197
  state.date = `${year}${month}`
@@ -145,79 +200,140 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
145
200
  state.date = `${year}${month}${day}`
146
201
  break
147
202
  }
148
- }, [state.dateType]);
203
+ }, [state.dateType])
204
+
205
+ const requestPowerData = useCallback((interval: number) => {
206
+ state.loading = true
207
+ getPowerData(devId, powerDpCode, interval).then((res: PowerDataItem[]) => {
208
+ state.powerData = res
209
+ state.loading = false
210
+ }).catch(() => {
211
+ state.loading = false
212
+ })
213
+ }, [])
149
214
 
150
215
  return (
151
- <Page
152
- backText={I18n.getLang('consumption_data_annual_bar_chart_system_back_text')}
153
- showGreenery={false}
154
- loading={state.loading}
155
- greeneryIcon={res.energy_consumption_greenery}
156
- headlineContent={
157
- <View style={{width: '100%',flexDirection:'row'}}>
158
- <DateSwitch
159
- style={{flex: 1}}
216
+ <Page
217
+ backText={I18n.getLang('consumption_data_annual_bar_chart_system_back_text')}
218
+ showGreenery={false}
219
+ loading={state.loading}
220
+ greeneryIcon={res.energy_consumption_greenery}
221
+ >
222
+ <ScrollView nestedScrollEnabled={true} style={{ marginHorizontal: cx(24) }}>
223
+ <Spacer/>
224
+
225
+ <Segmented
226
+ options={[
227
+ { label: I18n.getLang('chartdisplay_energy'), value: ChartType.kWh },
228
+ { label: I18n.getLang('chartdisplay_power'), value: ChartType.Watt }
229
+ ]}
230
+ value={state.chartType}
231
+ onChange={(chartType: ChartType) => {
232
+ state.chartType = chartType
233
+ }}/>
234
+ {
235
+ state.chartType === ChartType.kWh ? (
236
+ <>
237
+ <View style={{ width: '100%', flexDirection: 'row', marginVertical: cx(15) }}>
238
+ <DateSwitch
239
+ style={{ flex: 1 }}
160
240
  date={state.date}
161
241
  dateType={state.dateType}
162
242
  headlineText={state.headlineText}
163
243
  onDateChange={(date) => {
164
- state.date = date;
244
+ state.date = date
165
245
  }}/>
166
- <TouchableOpacity
167
- style={{width: cx(30)}}
168
- onPress={() => {
169
- const values = state.chartData.map(item => [item.key, item.value, (Number(params.price) * Number(item.value)).toFixed(2)])
170
- exportEnergyCsv(values, params.unit)
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)}/>
246
+ <TouchableOpacity
247
+ style={{ width: cx(30) }}
248
+ onPress={() => {
249
+ const values = state.chartData.map(item => [item.key, item.value, (Number(params.price) * Number(item.value)).toFixed(2)])
250
+ exportEnergyCsv(values, params.unit)
251
+ }}>
202
252
  <Image
253
+ style={styles.downloadIcon}
254
+ source={{ uri: state.chartData?.length ? res.download_icon : undefined }}/>
255
+ </TouchableOpacity>
256
+ </View>
257
+ <View style={{ flexDirection: 'row', marginBottom: cx(15) }}>
258
+ <DateTypeItem
259
+ style={{ flex: 1, marginHorizontal: cx(5) }}
260
+ dateType={state.dateType}
261
+ onDateTypeChange={(dateType) => {
262
+ state.dateType = dateType
263
+ }}/>
264
+ <DateSelectedItem
265
+ style={{ flex: 1 }}
266
+ dateType={state.dateType}
267
+ date={state.date}
268
+ onDateChange={date => {
269
+ state.date = date
270
+ }}
271
+ />
272
+ </View>
273
+ {
274
+ (state.chartData.length <= 0) ? (
275
+ <View style={styles.listEmptyView}>
276
+ <Spacer height={cx(26)}/>
277
+ <Image
203
278
  style={styles.listEmptyImage}
204
- source={{uri: res.ldv_timer_empty}}/>
205
- <Spacer height={cx(14)}/>
206
- <InfoText
279
+ source={{ uri: res.ldv_timer_empty }}/>
280
+ <Spacer height={cx(14)}/>
281
+ <InfoText
207
282
  text={getEmptyDataTip()}
208
283
  icon={res.ic_info}
209
284
  textStyle={styles.listEmptyText}
210
285
  contentColor={props.theme?.global.fontColor}
211
- />
212
- </View>
213
- ) : (
214
- state.chartData.length > 0 && !state.loading &&
215
- <NewBarChart height={cx(400)} data={state.chartData} price={state.price}
216
- unit={unit}/>
217
- )
218
- }
219
- </View>
220
- </Page>
286
+ />
287
+ </View>
288
+ ) : (
289
+ !state.loading && <NewBarChart height={cx(400)} data={state.chartData} price={state.price} unit={unit}/>
290
+ )
291
+ }
292
+ </>
293
+ ) : (
294
+ <>
295
+ {
296
+ (state.loading || state.powerData.length <= 0) ? (
297
+ <View style={[styles.listEmptyView, {marginVertical: cx(70)}]}>
298
+ <Spacer height={cx(26)}/>
299
+ <Image
300
+ style={styles.listEmptyImage}
301
+ source={{ uri: res.ldv_timer_empty }}/>
302
+ <Spacer height={cx(14)}/>
303
+ <InfoText
304
+ text={I18n.getLang('power_chart_empty')}
305
+ icon={res.ic_info}
306
+ textStyle={styles.listEmptyText}
307
+ contentColor={props.theme?.global.fontColor}
308
+ />
309
+ </View>
310
+ ) : (
311
+ <PowerLineChart height={cx(400)} data={state.powerData}/>
312
+ )
313
+ }
314
+ <View style={styles.intervalContainer}>
315
+ {
316
+ [24 * 60, 6 * 60, 60, 5].map((item, index) => {
317
+ const isChecked = item === state.interval
318
+ return (
319
+ <TouchableOpacity
320
+ key={index}
321
+ style={[styles.intervalItem, isChecked ? styles.intervalItemChecked : {}]}
322
+ onPress={() => {
323
+ state.interval = item
324
+ requestPowerData(item)
325
+ }}>
326
+ <Text
327
+ style={isChecked ? styles.intervalTextChecked : styles.intervalText}>{I18n.getLang(intervalLabels[index])}</Text>
328
+ </TouchableOpacity>)
329
+ })
330
+ }
331
+ </View>
332
+ </>
333
+ )
334
+ }
335
+ </ScrollView>
336
+ </Page>
221
337
  )
222
338
  }
223
339
 
@@ -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
+ }