Skip to content

Commit 0dc0cbc

Browse files
committed
批量
1 parent 7868333 commit 0dc0cbc

File tree

9 files changed

+247
-133
lines changed

9 files changed

+247
-133
lines changed

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.go]
12+
indent_style = tab
13+
indent_size = 4
14+
max_line_length = 120
15+
16+
[*.ts]
17+
ij_typescript_use_double_quotes = false
18+
19+
[*.md]
20+
max_line_length = off
21+
trim_trailing_whitespace = false

public/pages/alarm.json

Lines changed: 88 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,89 @@
11
{
2-
"title": "报警日志",
3-
"template": "table",
4-
"toolbar": [
5-
{
6-
"key": "keyword",
7-
"type": "text",
8-
"placeholder": "请输入关键字"
9-
},
10-
{
11-
"type": "button",
12-
"icon": "search",
13-
"label": "搜索",
14-
"action": {
15-
"type": "script",
16-
"script": "this.keyword=this.toolbar.value.keyword; this.load()"
17-
}
18-
}
19-
],
20-
"keywords": [
21-
"title",
22-
"message"
23-
],
24-
"operators": [
25-
{
26-
"icon": "delete",
27-
"title": "删除",
28-
"confirm": "确认删除?",
29-
"action": {
30-
"type": "script",
31-
"script": "this.request.get('table/alarm/delete/'+data.id).subscribe(res=>{this.load()})"
32-
}
33-
}
34-
],
35-
"columns": [
36-
{
37-
"key": "id",
38-
"label": "ID"
39-
},
40-
{
41-
"key": "device_id",
42-
"label": "设备ID",
43-
"action": {
44-
"type": "page",
45-
"page":"device-detail",
46-
"params_func": "return {id: data.device_id}"
47-
}
48-
},
49-
{
50-
"key": "project_id",
51-
"label": "项目ID",
52-
"action": {
53-
"type": "page",
54-
"page":"project-detail",
55-
"params_func": "return {id: data.project_id}"
56-
}
57-
},
58-
{
59-
"key": "title",
60-
"label": "标题"
61-
},
62-
{
63-
"key": "message",
64-
"label": "消息"
65-
},
66-
{
67-
"key": "level",
68-
"label": "等级"
69-
},
70-
{
71-
"key": "created",
72-
"label": "日期",
73-
"type": "date"
74-
}
75-
],
76-
"search_api": "table/alarm/search",
77-
"mount": "if(this.params.device_id)this.filter.device_id=this.params.device_id;if(this.params.project_id)this.filter.project_id=this.params.project_id;"
78-
}
2+
"title": "报警日志",
3+
"template": "table",
4+
"toolbar": [
5+
{
6+
"label": "批量删除",
7+
"icon": "delete",
8+
"type": "button",
9+
"confirm": "确认批量删除?",
10+
"action": {
11+
"type": "script",
12+
"script": "this.table.selects.forEach(id=>this.request.get('table/alarm/delete/'+id).subscribe(res=>{this.load()}))"
13+
}
14+
},
15+
{
16+
"key": "keyword",
17+
"type": "text",
18+
"placeholder": "请输入关键字"
19+
},
20+
{
21+
"type": "button",
22+
"icon": "search",
23+
"label": "搜索",
24+
"action": {
25+
"type": "script",
26+
"script": "this.keyword=this.toolbar.value.keyword; this.load()"
27+
}
28+
}
29+
],
30+
"keywords": [
31+
"title",
32+
"message"
33+
],
34+
"operators": [
35+
{
36+
"icon": "delete",
37+
"title": "删除",
38+
"confirm": "确认删除?",
39+
"action": {
40+
"type": "script",
41+
"script": "this.request.get('table/alarm/delete/'+data.id).subscribe(res=>{this.load()})"
42+
}
43+
}
44+
],
45+
"batch": true,
46+
"columns": [
47+
{
48+
"key": "id",
49+
"label": "ID"
50+
},
51+
{
52+
"key": "device_id",
53+
"label": "设备ID",
54+
"action": {
55+
"type": "page",
56+
"page": "device-detail",
57+
"params_func": "return {id: data.device_id}"
58+
}
59+
},
60+
{
61+
"key": "project_id",
62+
"label": "项目ID",
63+
"action": {
64+
"type": "page",
65+
"page": "project-detail",
66+
"params_func": "return {id: data.project_id}"
67+
}
68+
},
69+
{
70+
"key": "title",
71+
"label": "标题"
72+
},
73+
{
74+
"key": "message",
75+
"label": "消息"
76+
},
77+
{
78+
"key": "level",
79+
"label": "等级"
80+
},
81+
{
82+
"key": "created",
83+
"label": "日期",
84+
"type": "date"
85+
}
86+
],
87+
"search_api": "table/alarm/search",
88+
"mount": "if(this.params.device_id)this.filter.device_id=this.params.device_id;if(this.params.project_id)this.filter.project_id=this.params.project_id;"
89+
}

public/pages/device.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@
2121
"page":"device-import"
2222
}
2323
},
24+
{
25+
"label": "导出",
26+
"icon": "download",
27+
"type": "button",
28+
"action": {
29+
"type": "page",
30+
"page":"device-export"
31+
}
32+
},
33+
{
34+
"label": "批量删除",
35+
"icon": "delete",
36+
"type": "button",
37+
"confirm": "确认批量删除?",
38+
"action": {
39+
"type": "script",
40+
"script": "this.table.selects.forEach(id=>this.request.get('table/device/delete/'+id).subscribe(res=>{this.load()}))"
41+
}
42+
},
2443
{
2544
"key": "keyword",
2645
"type": "text",
@@ -67,6 +86,7 @@
6786
}
6887
}
6988
],
89+
"batch": true,
7090
"columns": [
7191
{
7292
"key": "id",
@@ -119,4 +139,4 @@
119139
"methods": {
120140
"get_extend_fields": "this.request.get('iot/device/extend/fields').subscribe(res=>{if(res.error)return; res.data.map(f=>this.content.columns.push(f)) })"
121141
}
122-
}
142+
}

src/app/lib/smart-table/smart-table.component.html

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,53 @@
11
<nz-table #table
2-
nzSize="small"
3-
[nzData]="datum"
4-
[nzLoading]="loading"
5-
[nzShowPagination]="true"
6-
[nzShowTotal]="totalTemplate"
7-
[nzFrontPagination]="false"
8-
[nzPageIndex]="pageIndex"
9-
[nzPageSize]="pageSize"
10-
[nzTotal]="total"
11-
[nzShowQuickJumper]="true"
12-
[nzShowSizeChanger]="true"
13-
(nzQueryParams)="onQuery($event)">
2+
nzSize="small"
3+
[nzData]="datum"
4+
[nzLoading]="loading"
5+
[nzShowPagination]="true"
6+
[nzShowTotal]="totalTemplate"
7+
[nzFrontPagination]="false"
8+
[nzPageIndex]="pageIndex"
9+
[nzPageSize]="pageSize"
10+
[nzPageSizeOptions]="[10,20,50,100,500,1000]"
11+
(nzPageSizeChange)="onPageSizeChange($event)"
12+
[nzTotal]="total"
13+
[nzShowQuickJumper]="true"
14+
[nzShowSizeChanger]="true"
15+
(nzQueryParams)="onQuery($event)">
1416
<thead>
15-
<tr>
16-
@for (item of columns; track item) {
17-
<th
18-
[nzColumnKey]="item.key"
19-
[nzShowSort]="item.sortable"
20-
[nzSortFn]="true"
21-
[nzShowFilter]="!!item.filter"
22-
[nzFilterFn]="true"
23-
[nzFilters]="item.filter || []">
24-
{{ item.label }}
25-
</th>
26-
}
27-
@if (operators && operators.length) {
28-
<th>操作</th>
29-
}
30-
</tr>
17+
<tr>
18+
@if (batch) {
19+
<th
20+
[nzChecked]="true"
21+
[nzIndeterminate]="indeterminate"
22+
(nzCheckedChange)="onAllChecked($event)">
23+
</th>
24+
}
25+
@for (item of columns; track item) {
26+
<th
27+
[nzColumnKey]="item.key"
28+
[nzShowSort]="item.sortable"
29+
[nzSortFn]="true"
30+
[nzShowFilter]="!!item.filter"
31+
[nzFilterFn]="true"
32+
[nzFilters]="item.filter || []">
33+
{{ item.label }}
34+
</th>
35+
}
36+
@if (operators && operators.length) {
37+
<th>操作</th>
38+
}
39+
</tr>
3140
</thead>
3241
<tbody>
3342
@for (data of table.data; track data; let i = $index) {
3443
<tr>
44+
@if (batch) {
45+
<td
46+
[nzChecked]="selects.has(data.id)"
47+
[nzLabel]="data.name"
48+
(nzCheckedChange)="onItemChecked(data.id, $event)"
49+
></td>
50+
}
3551
@for (item of columns; track item) {
3652
<td [nzEllipsis]="item.ellipsis" [nzBreakWord]="item.break">
3753
@switch (item.type) {
@@ -86,25 +102,25 @@
86102
<span class="operator">
87103
@if (o.confirm) {
88104
<a [title]="o.title||''" nz-popconfirm [nzPopconfirmTitle]="o.confirm"
89-
(nzOnConfirm)="action.emit({action:o.action, data:data, index: i})">
105+
(nzOnConfirm)="action.emit({action:o.action, data:data, index: i})">
90106
@if (o.icon) {
91107
<i nz-icon [nzType]="o.icon"></i>
92-
}{{ o.label }}
108+
}{{ o.label }}
93109
</a>
94-
} @else {
95-
<a [title]="o.title||''" (click)="action.emit({action:o.action, data:data, index: i})">
110+
} @else {
111+
<a [title]="o.title||''" (click)="action.emit({action:o.action, data:data, index: i})">
96112
@if (o.icon) {
97113
<i nz-icon [nzType]="o.icon"></i>
98-
}{{ o.label }}
114+
}{{ o.label }}
99115
</a>
100-
}
101-
</span>
102116
}
103-
</td>
117+
</span>
104118
}
105-
</tr>
119+
</td>
106120
}
107-
</tbody>
108-
</nz-table>
121+
</tr>
122+
}
123+
</tbody>
124+
</nz-table>
109125

110-
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template>
126+
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template>

0 commit comments

Comments
 (0)