@ledvance/ui-biz-bundle 1.1.143 → 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.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.143",
7
+ "version": "1.1.144",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -10,7 +10,7 @@ import {
10
10
  getSpecifiedTimeDpReportLogs
11
11
  } from '@ledvance/base/src/models/TuyaApi'
12
12
  import { exportCsvFile, localeNumber, loopsText, monthFormat, monthFormatShort } from '@ledvance/base/src/utils/common'
13
- import { overDays, xLog } from '@ledvance/base/src/utils'
13
+ import { overDays } from '@ledvance/base/src/utils'
14
14
  import dayjs from 'dayjs'
15
15
  import CustomParseFormat from 'dayjs/plugin/customParseFormat'
16
16
  import { isEmpty } from 'lodash'
@@ -145,6 +145,7 @@ const getDpResultByDate = async (devId: string, addEleDpCode: string, date: stri
145
145
  export interface PowerDataItem {
146
146
  key: string
147
147
  chartTitle: string
148
+ time: number,
148
149
  value: number
149
150
  }
150
151
 
@@ -165,11 +166,11 @@ export async function getPowerData(devId: string, powerDpCode: string, interval:
165
166
  backoffFactor: 2
166
167
  }
167
168
  ) as DpReportSataData[]
168
- xLog('powerData', dpResult)
169
169
  return dpResult.map(dp => {
170
170
  return {
171
171
  key: dp.timeStr,
172
- chartTitle: dayjs.unix(dp.timeStamp).format('HH:mm:ss'),
172
+ chartTitle: dayjs.unix(dp.timeStamp).format('MM/DD/YYYY HH:mm:ss'),
173
+ time: dp.timeStamp * 1000,
173
174
  value: parseFloat(dp.value) / 10
174
175
  }
175
176
  })
@@ -1,3 +1,4 @@
1
+ import { queryDpIds } from '@ledvance/base/src/api/native'
1
2
  import InfoText from '@ledvance/base/src/components/InfoText'
2
3
  import Page from '@ledvance/base/src/components/Page'
3
4
  import Segmented from '@ledvance/base/src/components/Segmented'
@@ -7,10 +8,11 @@ import I18n from '@ledvance/base/src/i18n'
7
8
  import { useDeviceId } from '@ledvance/base/src/models/modules/NativePropsSlice'
8
9
  import res from '@ledvance/base/src/res'
9
10
  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'
11
+ import { overDays } from '@ledvance/base/src/utils'
12
+ import { useIsFocused } from '@react-navigation/core'
13
+ import PowerLineChart from './component/PowerLineChart'
12
14
  import { useRoute } from '@react-navigation/core'
13
- import { useReactive, useUpdateEffect } from 'ahooks'
15
+ import { useInterval, useReactive, useUpdateEffect } from 'ahooks'
14
16
  import dayjs from 'dayjs'
15
17
  import React, { useCallback, useMemo } from 'react'
16
18
  import { Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
@@ -40,9 +42,20 @@ export interface EnergyConsumptionChartProps {
40
42
 
41
43
  const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
42
44
  const devId = useDeviceId()
45
+ const isFocused = useIsFocused()
43
46
 
44
47
  const params = useRoute().params as EnergyConsumptionChartProps
45
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
+ )
46
59
  const styles = StyleSheet.create({
47
60
  listEmptyView: {
48
61
  alignItems: 'center',
@@ -166,7 +179,7 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
166
179
  state.headlineText = `${monthFormat(month)} ${year}`
167
180
  break
168
181
  case DateType.Day:
169
- state.headlineText = `${day}/${month}/${year}\n${loopsText[dayOfWeek]}`
182
+ state.headlineText = `${day}/${month}/${year} (${loopsText[dayOfWeek]})`
170
183
  break
171
184
  }
172
185
  }, [state.dateType, state.headlineText])
@@ -279,8 +292,25 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
279
292
  </>
280
293
  ) : (
281
294
  <>
282
- {!state.loading ? <PowerLineChart height={cx(400)} data={state.powerData}/> :
283
- <View style={{ height: cx(400) }}></View>}
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
+ }
284
314
  <View style={styles.intervalContainer}>
285
315
  {
286
316
  [24 * 60, 6 * 60, 60, 5].map((item, index) => {
@@ -18,12 +18,8 @@ interface PowerLineChartProps {
18
18
  const PowerLineChart = (props: PowerLineChartProps) => {
19
19
  const echarts = useRef()
20
20
  const { data, height } = props
21
- const dataX = data?.map(item => {
22
- return item.chartTitle
23
- })
24
- const dataY = data?.map(item => {
25
- return item.value
26
- })
21
+
22
+ const values = data?.map(item => ([item.time, item.value]))
27
23
 
28
24
  const option = {
29
25
  tooltip: {
@@ -35,15 +31,12 @@ const PowerLineChart = (props: PowerLineChartProps) => {
35
31
  right: 0
36
32
  },
37
33
  xAxis: {
38
- data: dataX,
34
+ type: 'time',
39
35
  axisTick: {
40
36
  show: false,
41
37
  },
42
38
  axisLabel: {
43
39
  show: true,
44
- formatter: function (value: string) {
45
- return value.substring(0, 5)
46
- },
47
40
  color: props.theme?.global.secondFontColor,
48
41
  interval: 'auto',
49
42
  rotate: 45,
@@ -79,7 +72,7 @@ const PowerLineChart = (props: PowerLineChartProps) => {
79
72
  {
80
73
  name: I18n.getLang('consumption_data_field2_value_text1'),
81
74
  type: 'line',
82
- data: dataY,
75
+ data: values,
83
76
  areaStyle: {},
84
77
  showSymbol: false,
85
78
  color: '#F49431',
@@ -90,7 +83,7 @@ const PowerLineChart = (props: PowerLineChartProps) => {
90
83
  start: 0,
91
84
  type: 'inside',
92
85
  zoomLock: false,
93
- filterMode: 'filter'
86
+ filterMode: 'none'
94
87
  },
95
88
  customMapData: {}
96
89
  }