From a3a8c23b196980732a795713a5eb5fe0c7075bf9 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Wed, 11 Jul 2018 21:47:13 +0800 Subject: [PATCH] Revert "提交" --- src/app/routes/pro/list/table-list/table-list.component.ts | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 154 insertions(+), 0 deletions(-) diff --git a/src/app/routes/pro/list/table-list/table-list.component.ts b/src/app/routes/pro/list/table-list/table-list.component.ts new file mode 100644 index 0000000..f420f8d --- /dev/null +++ b/src/app/routes/pro/list/table-list/table-list.component.ts @@ -0,0 +1,154 @@ +import { Component, OnInit, ViewChild, TemplateRef } from '@angular/core'; +import { NzMessageService, NzModalService } from 'ng-zorro-antd'; +import { _HttpClient } from '@delon/theme'; +import { tap, map } from 'rxjs/operators'; +import { + SimpleTableComponent, + SimpleTableColumn, + SimpleTableData, +} from '@delon/abc'; + +@Component({ + selector: 'pro-table-list', + templateUrl: './table-list.component.html', +}) +export class ProTableListComponent implements OnInit { + q: any = { + pi: 1, + ps: 10, + sorter: '', + status: null, + statusList: [], + }; + data: any[] = []; + loading = false; + status = [ + { index: 0, text: '������', value: false, type: 'default', checked: false }, + { + index: 1, + text: '���������', + value: false, + type: 'processing', + checked: false, + }, + { index: 2, text: '���������', value: false, type: 'success', checked: false }, + { index: 3, text: '������', value: false, type: 'error', checked: false }, + ]; + @ViewChild('st') st: SimpleTableComponent; + columns: SimpleTableColumn[] = [ + { title: '', index: 'key', type: 'checkbox' }, + { title: '������������', index: 'no' }, + { title: '������', index: 'description' }, + { + title: '������������������', + index: 'callNo', + type: 'number', + format: (item: any) => `${item.callNo} ���`, + sorter: (a: any, b: any) => a.callNo - b.callNo, + }, + { + title: '������', + index: 'status', + render: 'status', + filters: this.status, + filter: () => true, + }, + { + title: '������������', + index: 'updatedAt', + type: 'date', + sorter: (a: any, b: any) => a.updatedAt - b.updatedAt, + }, + { + title: '������', + buttons: [ + { + text: '������', + click: (item: any) => this.msg.success(`������${item.no}`), + }, + { + text: '������������', + click: (item: any) => this.msg.success(`������������${item.no}`), + }, + ], + }, + ]; + selectedRows: SimpleTableData[] = []; + description = ''; + totalCallNo = 0; + expandForm = false; + + constructor( + private http: _HttpClient, + public msg: NzMessageService, + private modalSrv: NzModalService, + ) {} + + ngOnInit() { + this.getData(); + } + + getData() { + this.loading = true; + this.q.statusList = this.status + .filter(w => w.checked) + .map(item => item.index); + if (this.q.status !== null && this.q.status > -1) + this.q.statusList.push(this.q.status); + this.http + .get('/rule', this.q) + .pipe( + map((list: any[]) => + list.map(i => { + const statusItem = this.status[i.status]; + i.statusText = statusItem.text; + i.statusType = statusItem.type; + return i; + }), + ), + tap(() => (this.loading = false)), + ) + .subscribe(res => (this.data = res)); + } + + checkboxChange(list: SimpleTableData[]) { + this.selectedRows = list; + this.totalCallNo = this.selectedRows.reduce( + (total, cv) => total + cv.callNo, + 0, + ); + } + + remove() { + this.http + .delete('/rule', { nos: this.selectedRows.map(i => i.no).join(',') }) + .subscribe(() => { + this.getData(); + this.st.clearCheck(); + }); + } + + approval() { + this.msg.success(`��������� ${this.selectedRows.length} ���`); + } + + add(tpl: TemplateRef<{}>) { + this.modalSrv.create({ + nzTitle: '������������', + nzContent: tpl, + nzOnOk: () => { + this.loading = true; + this.http + .post('/rule', { description: this.description }) + .subscribe(() => { + this.getData(); + }); + }, + }); + } + + reset(ls: any[]) { + for (const item of ls) item.value = false; + this.getData(); + } +} -- Gitblit v1.8.0