Skip to content

Commit

Permalink
fix(设备管理): 设备管理->运行状态属性类型错误
Browse files Browse the repository at this point in the history
类型为对象是渲染报错,value为number时才显示图表

fix #198
  • Loading branch information
Lind-pro committed Sep 9, 2020
1 parent ba54421 commit b449167
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/pages/device/instance/editor/detail/status/PropertiesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,17 @@ const PropertiesCard: React.FC<Props> = props => {
const [edit, setEdit] = useState<boolean>(false);
useEffect(() => {
item.subscribe((resp: any) => {
if ((data.visitData || []).length > 14) {
data.visitData.shift();
const value = resp.value.value;
const type = typeof (value);
if (type === 'number') {
if ((data.visitData || []).length > 14) {
data.visitData.shift();
}
if (!data.visitData) {
data.visitData = [];
}
data.visitData.push({ x: resp.timeString, y: resp.value.value });
}
if (!data.visitData) {
data.visitData = [];
}
data.visitData.push({ x: resp.timeString, y: resp.value.value });
setData({
...data,
...resp.value,
Expand Down Expand Up @@ -129,7 +133,7 @@ const PropertiesCard: React.FC<Props> = props => {
</div>
}
total={
<AutoHide title={data.formatValue || '/'} style={{ width: '100%' }} />
<AutoHide title={typeof (data.formatValue) === 'object' ? JSON.stringify(data.formatValue) : data.formatValue || '/'} style={{ width: '100%' }} />
}
>
<MiniArea height={40} color="#975FE4" data={data.visitData} />
Expand Down

0 comments on commit b449167

Please sign in to comment.