Files
airport-chengdu-web/src/app/pages/system-management/role-management/role-management.component.ts
T

78 lines
2.5 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { HttpClientService } from '../../../services/http-client.service';
import { Router } from '@angular/router';
import { NzMessageService } from 'ng-zorro-antd';
import 'ztree';
declare var $: any;
declare var jQuery: any;
@Component({
selector: 'app-role-management',
templateUrl: './role-management.component.html',
styleUrls: ['./role-management.component.scss']
})
export class RoleManagementComponent implements OnInit {
collectionSize: any;
public tableData: any = [];
statusParamsTable: any = { //获取用户列表接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据
status: 1,
}
statusParamsDetail: any = { //获取用户详情接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据
status: 1,
}
public search: any = {
page_index: '1',
page_size: '10',
role_name: '',
}
constructor(
private http: HttpClientService,
private router: Router,
private message: NzMessageService,
) { }
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(`删除失败`)
}
})
}
//获取列表
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;
}
})
}
}