Skip to content

Commit ffd226d

Browse files
committed
统计,显示文本
1 parent 8c01665 commit ffd226d

18 files changed

Lines changed: 39 additions & 22 deletions

pages/device-values.json

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,35 @@
1515
"auto_refresh": 10,
1616
"load_api": "device/:id/values",
1717
"load_success": "this.render_values()",
18-
"mount": "this.load_device(); this.value_action={type:'dialog',page:'device-history',params_func:'return {id:this.params.id, point:data.key}'}",
18+
"mount": "this.load_device();",
1919
"methods": {
2020
"load_values": "this.request.get('device/'+this.params.id+'/values').subscribe(res=>{if(res.error)return; this.data=res.data; })",
21-
"load_values_delay": ["delay", "setTimeout(()=>this.load_values(), delay || 1000)"],
21+
"load_values_delay": [
22+
"delay",
23+
"setTimeout(()=>this.load_values(), delay || 1000)"
24+
],
2225
"refresh_values": "this.request.get('device/'+this.params.id+'/sync').subscribe(res=>{if(res.error)return; this.load_values_delay();})",
2326
"refresh_child_values": "this.request.get('device/'+this.device.gateway_id+'/sync/'+this.params.id).subscribe(res=>{if(res.error)return; this.load_values_delay()})",
2427
"load_device": "this.request.get('table/device/detail/'+this.params.id).subscribe(res=>{if(res.error)return; this.device=res.data; this.load_model(res.data.product_id)})",
25-
"load_model": ["pid","this.request.get('product/'+pid+'/setting/model').subscribe(res=>{if(res.error)return; res.data.content && this.render_properties(res.data.content); setTimeout(()=>this.render_values(),100); })"],
26-
"render_properties": ["properties", "properties && properties.map(p=>{ this.content.children.push({span: 24, content:{title:p.name,template:'statistic', items: this.render_points(p.points)} }) })"],
27-
"render_points": ["points", "return points && points.map(p=>{return{key:p.name,label:p.label,suffix:p.unit,span:6,action:this.value_action}}) "],
28+
"load_model": [
29+
"pid",
30+
"this.request.get('product/'+pid+'/setting/model').subscribe(res=>{if(res.error)return; res.data.content && this.render_properties(res.data.content); setTimeout(()=>this.render_values(),100); })"
31+
],
32+
"render_properties": [
33+
"properties",
34+
"properties && properties.map(p=>{ this.content.children.push({span: 24, content:{title:p.name,template:'statistic', items: this.render_points(p.points)} }) })"
35+
],
36+
"render_points": [
37+
"points",
38+
"return points && points.map(p=>{return{key:p.name,label:p.label,suffix:p.unit,span:6,action:this.content.value_action}}) "
39+
],
2840
"render_values": "this.pageComponent.children.map(p=>{p.componentRef.setInput('data', this.data) })"
2941
},
42+
"value_action": {
43+
"type": "dialog",
44+
"page": "device-history",
45+
"params_func": "return {id:this.params.id, point:data.key}"
46+
},
3047
"children": [
3148
]
3249
}

src/app/template/statistic/statistic.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<nz-col [nzSpan]="12" [nzMd]="item.span || 8" [nzXs]="24">
1010
<nz-card>
1111
<nz-statistic
12-
[nzValue]="(data?.[item.key] | number: item.format || '1.0-2')||'-'"
12+
[nzValue]="(typeof data?.[item.key] == 'number') ? (data?.[item.key] | number: item.format || '1.0-2') : (data?.[item.key] || '-')"
1313
[nzTitle]="item.label"
1414
[nzPrefix]="item.prefix"
1515
[nzSuffix]="item.suffix"
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)