From 8a8302eb5184691f961071345fc0e7e636bc623b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= Date: Fri, 3 Jul 2020 17:30:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=8B=E9=93=BE=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin-link/admin-link.component.html | 46 +++++----------- .../admin-link/admin-link.component.less | 0 .../admin/admin-link/admin-link.component.ts | 55 ++++++++++++------- .../admin/admin-link/admin-link.module.ts | 24 +++----- 4 files changed, 58 insertions(+), 67 deletions(-) delete mode 100644 src/app/view/admin/admin-link/admin-link.component.less diff --git a/src/app/view/admin/admin-link/admin-link.component.html b/src/app/view/admin/admin-link/admin-link.component.html index ff5ff8d..664abab 100644 --- a/src/app/view/admin/admin-link/admin-link.component.html +++ b/src/app/view/admin/admin-link/admin-link.component.html @@ -1,36 +1,18 @@ -
- - - - - 友链名称 - 友链地址 - 是否可见 - 操作 - - - - {{data.name}} - {{data.url}} - - - - - 编辑 - - 删除 - - - - - -
+ + - - + + + + + + {{value}} + {{value}} = new PageList(); - loading: boolean = true; - pageIndex: number = 1; - pageSize: number = 10; + modalVisible: boolean = false; modalTitle: string = ''; formGroup: FormGroup; - - getLinks = () => this.apiService.adminLinks(this.pageSize, this.pageIndex).subscribe({ - next: data => this.pageList = data.result, - error: () => this.loading = false, - complete: () => this.loading = false, - }) + request: RequestObj; + @ViewChild('commonTableComponent') commonTableComponent: CommonTableComponent + headData: Data[]; ngOnInit(): void { - this.getLinks(); + this.request = { + path: '/admin/links', + method: 'GET', + queryParam: { + count: 10, + page: 1 + } + } + this.headData = [ + {title: '主键', fieldValue: 'id', show: false, primaryKey: true}, + {title: '友链名称', fieldValue: 'name', show: true}, + {title: '友链地址', fieldValue: 'url', show: true}, + {title: '是否可见', fieldValue: 'open', show: true}, + {title: '描述', fieldValue: 'desc', show: false}, + {title: '图标', fieldValue: 'iconPath', show: false}, + {title: '状态', fieldValue: 'delete', show: true}, + { + title: '操作', fieldValue: '', show: true, isActionColumns: true, action: [ + {name: '访问', click: (data) => window.open(data.url)}, + {name: '编辑', click: (data) => this.showEdit(data)}, + {name: '删除', color: 'red', needConfirm: true, click: (data) => this.delete(data.id)}, + ] + }, + ]; } delete(id: number) { this.apiService.deleteLink(id).subscribe({ next: data => { this.messageService.success('删除成功'); - this.getLinks(); + this.commonTableComponent.getData(); }, error: () => { - this.loading = false; this.messageService.error('删除失败'); }, - complete: () => this.loading = false, + complete: () => null, }) } @@ -84,7 +101,7 @@ export class AdminLinkComponent implements OnInit { observable.subscribe({ next: data => this.messageService.success('操作成功'), error: err => this.messageService.error('操作失败,' + err.msg), - complete: () => this.getLinks() + complete: () => this.commonTableComponent.getData() }) } diff --git a/src/app/view/admin/admin-link/admin-link.module.ts b/src/app/view/admin/admin-link/admin-link.module.ts index d69b05a..5c78133 100644 --- a/src/app/view/admin/admin-link/admin-link.module.ts +++ b/src/app/view/admin/admin-link/admin-link.module.ts @@ -2,16 +2,9 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {RouterModule} from '@angular/router'; import {AdminLinkComponent} from './admin-link.component'; -import { - NzButtonModule, - NzCardModule, - NzDividerModule, - NzFormModule, NzIconModule, NzInputModule, - NzModalModule, - NzPopconfirmModule, NzSelectModule, - NzTableModule -} from 'ng-zorro-antd'; -import {ReactiveFormsModule} from '@angular/forms'; +import {CommonTableModule} from '../components/common-table/common-table.module'; +import {NzCheckboxModule, NzFormModule, NzInputModule, NzModalModule, NzSelectModule, NzTagModule} from 'ng-zorro-antd'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; @NgModule({ @@ -21,17 +14,16 @@ import {ReactiveFormsModule} from '@angular/forms'; imports: [ CommonModule, RouterModule.forChild([{path: '', component: AdminLinkComponent}]), - NzCardModule, - NzTableModule, - NzDividerModule, - NzPopconfirmModule, + CommonTableModule, + NzCheckboxModule, NzModalModule, + FormsModule, NzFormModule, ReactiveFormsModule, NzInputModule, NzSelectModule, - NzButtonModule, - NzIconModule + NzTagModule, + ] }) export class AdminLinkModule {