2018-10-29 16:27:34 +08:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2018-12-10 18:31:18 +08:00
|
|
|
import { HttpClientService } from '../../../services/http-client.service';
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd';
|
|
|
|
|
|
|
|
|
|
import 'ztree';
|
2019-04-17 13:56:14 +08:00
|
|
|
declare var $: any;
|
2018-12-10 18:31:18 +08:00
|
|
|
declare var jQuery: any;
|
2018-10-29 16:27:34 +08:00
|
|
|
|
|
|
|
|
@Component({
|
2019-04-17 13:56:14 +08:00
|
|
|
selector: 'app-role-management',
|
|
|
|
|
templateUrl: './role-management.component.html',
|
|
|
|
|
styleUrls: ['./role-management.component.scss']
|
2018-10-29 16:27:34 +08:00
|
|
|
})
|
|
|
|
|
export class RoleManagementComponent implements OnInit {
|
2019-04-17 13:56:14 +08:00
|
|
|
collectionSize: any;
|
|
|
|
|
public tableData: any = [];
|
|
|
|
|
statusParamsTable: any = { //获取用户列表接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据
|
|
|
|
|
status: 1,
|
|
|
|
|
}
|
2018-10-29 16:27:34 +08:00
|
|
|
|
2019-04-17 13:56:14 +08:00
|
|
|
statusParamsDetail: any = { //获取用户详情接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据
|
|
|
|
|
status: 1,
|
|
|
|
|
}
|
|
|
|
|
public search: any = {
|
|
|
|
|
page_index: '1',
|
|
|
|
|
page_size: '10',
|
|
|
|
|
role_name: '',
|
|
|
|
|
}
|
2018-10-29 16:27:34 +08:00
|
|
|
|
2019-04-17 13:56:14 +08:00
|
|
|
constructor(
|
|
|
|
|
private http: HttpClientService,
|
|
|
|
|
private router: Router,
|
|
|
|
|
private message: NzMessageService,
|
|
|
|
|
) { }
|
2018-12-10 18:31:18 +08:00
|
|
|
|
2019-04-17 13:56:14 +08:00
|
|
|
ngOnInit() {
|
|
|
|
|
this.queryTable();
|
|
|
|
|
}
|
|
|
|
|
//新增、修改 1新增 2修改
|
|
|
|
|
addModify(type, item?) {
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
this.router.navigate(['app/system/roles/modify'], { queryParams: { operateType: 1 } })
|
|
|
|
|
} else if (type == 2) {
|
|
|
|
|
this.router.navigate(['app/system/roles/modify'], { queryParams: { operateType: 2, id: item.rid } })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//删除
|
|
|
|
|
delectConfirm(item) {
|
|
|
|
|
this.http.delete('/sysapi/setting/role/delete/' + item.rid).subscribe((json) => {
|
|
|
|
|
if (json.is_success) {
|
|
|
|
|
this.message.success(`删除成功!`);
|
|
|
|
|
this.queryTable();
|
|
|
|
|
} else {
|
|
|
|
|
this.message.error(`删除失败`)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2018-10-29 16:27:34 +08:00
|
|
|
|
2019-04-17 13:56:14 +08:00
|
|
|
//获取列表
|
|
|
|
|
queryTable(): void {
|
|
|
|
|
this.statusParamsTable.status = 1;
|
|
|
|
|
this.http.get('/sysapi/setting/role/list', this.search).subscribe((json) => {
|
|
|
|
|
if (json.is_success) {
|
|
|
|
|
this.tableData = json.body.list;
|
|
|
|
|
this.collectionSize = json.body.total;
|
|
|
|
|
if (json.body.list && json.body.list.length > 0) {
|
|
|
|
|
this.statusParamsTable.status = 3;
|
|
|
|
|
} else {
|
|
|
|
|
this.statusParamsTable.status = 4;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.statusParamsTable.status = 0;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2018-10-29 16:27:34 +08:00
|
|
|
}
|