You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
4.1 KiB
133 lines
4.1 KiB
3 years ago
|
import { Component, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
|
||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||
|
import { NzModalService } from 'ng-zorro-antd/modal';
|
||
|
import { NzMessageService } from 'ng-zorro-antd/message';
|
||
|
import { HttpClient } from '@angular/common/http';
|
||
|
import { AddFileOfLicenseComponent } from './add-file-of-license/add-file-of-license.component';
|
||
|
import { EditFileOfLicenseComponent } from './edit-file-of-license/edit-file-of-license.component';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'app-file-of-license',
|
||
|
templateUrl: './file-of-license.component.html',
|
||
|
styleUrls: ['./file-of-license.component.scss']
|
||
|
})
|
||
|
export class FileOfLicenseComponent implements OnInit {
|
||
|
|
||
|
constructor(private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient) { }
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
this.getLicense()
|
||
|
}
|
||
|
|
||
|
listOfData: any[] = [];
|
||
|
|
||
|
//获取证照列表
|
||
|
|
||
|
getLicense() {
|
||
|
let params = {
|
||
|
SkipCount: '0',
|
||
|
MaxResultCount: '999'
|
||
|
}
|
||
|
this.http.get('/api/services/app/FileLicenseType/GetAll', {
|
||
|
params: params
|
||
|
}).subscribe((data: any) => {
|
||
|
console.log('证照列表', data.result.items)
|
||
|
this.listOfData = data.result.items
|
||
|
})
|
||
|
}
|
||
|
|
||
|
addRole(): void {
|
||
|
const modal = this.modal.create({
|
||
|
nzTitle: '新增证照',
|
||
|
nzContent: AddFileOfLicenseComponent,
|
||
|
nzViewContainerRef: this.viewContainerRef,
|
||
|
nzWidth: 288,
|
||
|
nzComponentParams: {},
|
||
|
nzOnOk: async () => {
|
||
|
if (instance.validateForm.valid) {
|
||
|
await new Promise(resolve => {
|
||
|
console.log('表单信息', instance.validateForm)
|
||
|
let body = {
|
||
|
licenseName: instance.validateForm.value.name,
|
||
|
}
|
||
|
this.http.post('/api/services/app/FileLicenseType/Create', body).subscribe(data => {
|
||
|
resolve(data)
|
||
|
this.message.create('success', '创建成功!');
|
||
|
this.getLicense()
|
||
|
return true
|
||
|
})
|
||
|
})
|
||
|
} else {
|
||
|
this.message.create('warning', '请填写完整!');
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
const instance = modal.getContentComponent();
|
||
|
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
|
||
|
// Return a result when closed
|
||
|
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
|
||
|
}
|
||
|
|
||
|
|
||
|
edit(item) {
|
||
|
const modal = this.modal.create({
|
||
|
nzTitle: '编辑证照',
|
||
|
nzContent: EditFileOfLicenseComponent,
|
||
|
nzViewContainerRef: this.viewContainerRef,
|
||
|
nzWidth: 325,
|
||
|
nzComponentParams: {
|
||
|
data: item
|
||
|
},
|
||
|
nzOnOk: async () => {
|
||
|
if (instance.validateForm.valid) {
|
||
|
await new Promise(resolve => {
|
||
|
console.log('表单信息', instance.validateForm)
|
||
|
let body = {
|
||
|
id: item.id,
|
||
|
licenseName: instance.validateForm.value.name
|
||
|
}
|
||
|
this.http.put('/api/services/app/FileLicenseType/Update', body).subscribe(data => {
|
||
|
resolve(data)
|
||
|
this.message.create('success', '修改成功!');
|
||
|
this.getLicense()
|
||
|
return true
|
||
|
})
|
||
|
})
|
||
|
} else {
|
||
|
this.message.create('warning', '请填写完整!');
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
const instance = modal.getContentComponent();
|
||
|
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
|
||
|
// Return a result when closed
|
||
|
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
|
||
|
}
|
||
|
|
||
|
delete(item) {
|
||
|
console.log(item)
|
||
|
this.modal.confirm({
|
||
|
nzTitle: `确定要删除${item.licenseName}这个证照吗?`,
|
||
|
nzOkText: '确定',
|
||
|
nzOkType: 'danger',
|
||
|
nzOnOk: () => {
|
||
|
this.http.delete('/api/services/app/FileLicenseType/Delete', {
|
||
|
params: {
|
||
|
Id: item.id
|
||
|
}
|
||
|
}).subscribe(data => {
|
||
|
this.message.create('success', '删除成功!');
|
||
|
this.getLicense()
|
||
|
})
|
||
|
},
|
||
|
nzCancelText: '取消',
|
||
|
nzOnCancel: () => {
|
||
|
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|