Commit 8f89c614 authored by wangqinghua's avatar wangqinghua

update

parent 2b1ed70b
<p-table [value]="sales"> <!--资源可用性统计-->
<ng-template pTemplate="header"> <div nz-row class="breadcrumbs">
<tr> <div nz-col nzSpan="16">
<th rowspan="3">Brand</th> <nz-breadcrumb class="padding-8-0">
<th colspan="4">Sale Rate</th> <nz-breadcrumb-item>
</tr> 当前位置:首页
<tr> </nz-breadcrumb-item>
<th colspan="2">Sales</th> </nz-breadcrumb>
<th colspan="2">Profits</th> </div>
</tr> <div nz-col nzSpan="8" class="text-right">
<tr> <button (click)="search()" nz-button nzType="primary"><i class="anticon anticon-search"></i></button>
<th>Last Year</th> <button nz-button nzType="primary"><i class="anticon anticon-sync"></i></button>
<th>This Year</th> <button nz-button nzType="primary"><i class="anticon anticon-arrows-alt"></i></button>
<th>Last Year</th> </div>
<th>This Year</th> </div>
</tr> <div nz-row nzGutter="4">
</ng-template> <div nz-col nzSpan="16">
<ng-template pTemplate="body" let-sale> <nz-spin [nzSpinning]="isTopLoading">
<tr> <div echarts [options]="chartTopOption" style="height: 400px;width: 100%"></div>
<td>{{sale.brand}}</td> </nz-spin>
<td>{{sale.lastYearSale}}</td> </div>
<td>{{sale.thisYearSale}}</td> <div nz-col nzSpan="12">
<td>{{sale.lastYearProfit}}</td> <nz-spin [nzSpinning]="isLastLoading">
<td>{{sale.thisYearProfit}}</td> <div echarts [options]="chartLastOption" style="height: 400px;width: 100%"></div>
</tr> </nz-spin>
</ng-template> </div>
<ng-template pTemplate="footer"> </div>
<tr>
<td colspan="3">Totals</td>
<td>$506,202</td>
<td>$531,020</td>
</tr>
</ng-template>
</p-table>
...@@ -12,9 +12,11 @@ import { Account, Principal } from '../shared'; ...@@ -12,9 +12,11 @@ import { Account, Principal } from '../shared';
}) })
export class HomeComponent implements OnInit { export class HomeComponent implements OnInit {
account: Account;
modalRef: NgbModalRef; leftOneChart;
sales: any[]; leftTwoChart;
rightOneChart;
rightTwoChart;
constructor( constructor(
private principal: Principal, private principal: Principal,
...@@ -23,34 +25,7 @@ export class HomeComponent implements OnInit { ...@@ -23,34 +25,7 @@ export class HomeComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.sales = [
{ brand: 'Apple', lastYearSale: '51%', thisYearSale: '40%', lastYearProfit: '$54,406.00', thisYearProfit: '$43,342' },
{ brand: 'Samsung', lastYearSale: '83%', thisYearSale: '96%', lastYearProfit: '$423,132', thisYearProfit: '$312,122' },
{ brand: 'Microsoft', lastYearSale: '38%', thisYearSale: '5%', lastYearProfit: '$12,321', thisYearProfit: '$8,500' },
{ brand: 'Philips', lastYearSale: '49%', thisYearSale: '22%', lastYearProfit: '$745,232', thisYearProfit: '$650,323,' },
{ brand: 'Song', lastYearSale: '17%', thisYearSale: '79%', lastYearProfit: '$643,242', thisYearProfit: '500,332' },
{ brand: 'LG', lastYearSale: '52%', thisYearSale: ' 65%', lastYearProfit: '$421,132', thisYearProfit: '$150,005' },
{ brand: 'Sharp', lastYearSale: '82%', thisYearSale: '12%', lastYearProfit: '$131,211', thisYearProfit: '$100,214' },
{ brand: 'Panasonic', lastYearSale: '44%', thisYearSale: '45%', lastYearProfit: '$66,442', thisYearProfit: '$53,322' },
{ brand: 'HTC', lastYearSale: '90%', thisYearSale: '56%', lastYearProfit: '$765,442', thisYearProfit: '$296,232' },
{ brand: 'Toshiba', lastYearSale: '75%', thisYearSale: '54%', lastYearProfit: '$21,212', thisYearProfit: '$12,533' }
];
// this.principal.identity().then((account) => {
// this.account = account;
// });
// this.registerAuthenticationSuccess();
}
registerAuthenticationSuccess() {
this.eventManager.subscribe('authenticationSuccess', (message) => {
this.principal.identity().then((account) => {
this.account = account;
});
});
}
isAuthenticated() {
return this.principal.isAuthenticated();
} }
login() { login() {
......
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
<div nz-col nzSpan="18"> <div nz-col nzSpan="18">
<div class="padding-15-0"> <div class="padding-15-0">
<button (click)="showUserModal()" nz-button nzType="primary">新增用户</button> <button (click)="showUserModal()" nz-button nzType="primary">新增用户</button>
<button nz-button nzType="default">批量删除</button> <button (click)="batchDelete()" nz-button nzType="default">批量删除</button>
<button nz-button nzType="default">批量修改</button> <!--<button nz-button nzType="default">批量修改</button>-->
<button nz-button nzType="default">导出模版</button> <button nz-button nzType="default">导出模版</button>
<button nz-button nzType="default">导入组织</button> <button nz-button nzType="default">导入组织</button>
<button nz-button nzType="default">导入用户</button> <button nz-button nzType="default">导入用户</button>
...@@ -72,14 +72,16 @@ ...@@ -72,14 +72,16 @@
<tbody> <tbody>
<tr *ngFor="let data of basicTable.data"> <tr *ngFor="let data of basicTable.data">
<td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="refreshStatus($event)"></td> <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="refreshStatus($event)"></td>
<td>{{data.name}}</td> <td>{{data.user.name}}</td>
<td>{{data.loginName}}</td> <td>{{data.loginName}}</td>
<td>{{data.mobile}}</td> <td>{{data.user.phoneNumber}}</td>
<td>{{data.key4}}</td> <td>
<span *ngFor="let item of data.roles">{{item.name}}</span>
</td>
<td class="handle"> <td class="handle">
<span (click)="grantRole(data)">授权</span> <span (click)="grantRole(data)">授权</span>
<span>查看</span> <span>查看</span>
<span>编辑</span> <span (click)="showEditModal(data)">编辑</span>
<span (click)="deleteUser(data)">删除</span> <span (click)="deleteUser(data)">删除</span>
</td> </td>
</tr> </tr>
......
...@@ -26,24 +26,24 @@ export class GroupComponent implements OnInit { ...@@ -26,24 +26,24 @@ export class GroupComponent implements OnInit {
nodes: any[]; nodes: any[];
isVisible = true; isVisible = true;
userId; userId;
displayData: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }> = []; // displayData: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }> = [];
constructor(private systemSer: SystemService, private message: NzMessageService, constructor(private systemSer: SystemService, private message: NzMessageService,
private modalSer: NzModalService, private commonSer: CommonService) { private modalSer: NzModalService, private commonSer: CommonService) {
} }
checkAll(value: boolean): void { checkAll(value: boolean): void {
this.displayData.forEach(data => data.checked = value); this.dataSet.forEach(data => data.checked = value);
this.refreshStatus(); this.refreshStatus();
} }
currentPageDataChange($event: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }>): void { currentPageDataChange($event: Array<{ checked: boolean }>): void {
this.displayData = $event; this.dataSet = $event;
} }
refreshStatus(): void { refreshStatus(): void {
const allChecked = this.displayData.every(value => value.checked === true); const allChecked = this.dataSet.every(value => value.checked === true);
const allUnChecked = this.displayData.every(value => !value.checked); const allUnChecked = this.dataSet.every(value => !value.checked);
this.allChecked = allChecked; this.allChecked = allChecked;
this.indeterminate = (!allChecked) && (!allUnChecked); this.indeterminate = (!allChecked) && (!allUnChecked);
this.disabledButton = !this.dataSet.some(value => value.checked); this.disabledButton = !this.dataSet.some(value => value.checked);
...@@ -117,22 +117,30 @@ export class GroupComponent implements OnInit { ...@@ -117,22 +117,30 @@ export class GroupComponent implements OnInit {
//新增用户 //新增用户
showUserModal() { showUserModal() {
this.smartUser.showModal(this.groupList); this.smartUser.showAddModal(this.groupList,"新增用户");
} }
//删除用户 //编辑用户
deleteUser(data) { showEditModal(item){
this.smartUser.showEditModal(this.groupList,"编辑用户",item.user.id);
}
//删除用户--单个
deleteUser(item) {
this.modalSer.confirm({ this.modalSer.confirm({
nzTitle: '删除', nzTitle: '删除',
nzContent: '<b style="color: red">确定删除该用户吗</b>', nzContent: '<b style="color: red">确定删除该用户吗</b>',
nzOkText: '确定', nzOkText: '确定',
nzCancelText: '取消', nzCancelText: '取消',
nzOnOk: () => { nzOnOk: () => {
this.systemSer.deleteUser(data.id).subscribe( const data = {
id:item.user.id
};
this.systemSer.deleteUser(data).subscribe(
(res) => { (res) => {
// if(res.errCode == 10000){ if(res.data == 1){
this.getUser();
// } }
} }
); );
}, },
...@@ -141,6 +149,35 @@ export class GroupComponent implements OnInit { ...@@ -141,6 +149,35 @@ export class GroupComponent implements OnInit {
}); });
} }
//删除用户-- 批量
batchDelete(){
let bool = false;
this.dataSet.forEach(e=>{
if(e.checked){
bool = true;
}
});
if(!bool){
this.message.warning("请选择需要删除的用户");
return false;
}
let arr = [];
this.dataSet.forEach(e=>{
if(e.checked){
arr.push(e.user.id);
}
});
this.commonSer.deleteThing("确定删除选择的用户",()=>{
this.systemSer.batchDeleteUser(arr).subscribe(
(res) => {
if(res.errCode == 10000){
this.getUser();
}
}
);
})
}
//新增部门 //新增部门
showGroupModal() { showGroupModal() {
this.smartGroupModal.showModal(this.groupList); this.smartGroupModal.showModal(this.groupList);
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="mobile" nzRequired>手机号码</nz-form-label> <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="phoneNumber" nzRequired>手机号码</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24"> <nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="mobile" id="mobile"> <input nz-input formControlName="phoneNumber" id="phoneNumber">
<nz-form-explain *ngIf="validateForm.get('mobile').dirty && validateForm.get('mobile').errors">手机号码错误!</nz-form-explain> <nz-form-explain *ngIf="validateForm.get('phoneNumber').dirty && validateForm.get('phoneNumber').errors">手机号码错误!</nz-form-explain>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
...@@ -39,24 +39,24 @@ ...@@ -39,24 +39,24 @@
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="organizeId">所属部门</nz-form-label> <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="organizationId">所属部门</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24"> <nz-form-control [nzSm]="14" [nzXs]="24">
<nz-select id="orgId" formControlName="organizeId" nzPlaceHolder="选择部门"> <nz-select id="organizationId" formControlName="organizationId" nzPlaceHolder="选择部门">
<ng-container *ngFor="let item of groupList"> <ng-container *ngFor="let item of groupList">
<nz-option nzValue="{{item.id}}" nzLabel="{{item.name}}"></nz-option> <nz-option nzValue="{{item.id}}" nzLabel="{{item.name}}"></nz-option>
</ng-container> </ng-container>
</nz-select> </nz-select>
<nz-form-explain *ngIf="validateForm.get('organizeId').dirty && validateForm.get('organizeId').errors">请选择所属部门!</nz-form-explain> <nz-form-explain *ngIf="validateForm.get('organizationId').dirty && validateForm.get('organizationId').errors">请选择所属部门!</nz-form-explain>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="comments">职位</nz-form-label> <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="position">职位</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24"> <nz-form-control [nzSm]="14" [nzXs]="24">
<nz-select id="comments" formControlName="comments" nzPlaceHolder="选择职位"> <nz-select id="position" formControlName="position" nzPlaceHolder="选择职位">
<nz-option nzValue="1" nzLabel="组长"></nz-option> <nz-option nzValue="1" nzLabel="组长"></nz-option>
<nz-option nzValue="2" nzLabel="组员"></nz-option> <nz-option nzValue="2" nzLabel="组员"></nz-option>
</nz-select> </nz-select>
<nz-form-explain *ngIf="validateForm.get('comments').dirty && validateForm.get('comments').errors">请选择职位!</nz-form-explain> <nz-form-explain *ngIf="validateForm.get('position').dirty && validateForm.get('position').errors">请选择职位!</nz-form-explain>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
......
...@@ -17,10 +17,11 @@ import {NzMessageService} from 'ng-zorro-antd'; ...@@ -17,10 +17,11 @@ import {NzMessageService} from 'ng-zorro-antd';
export class UserComponent implements OnInit { export class UserComponent implements OnInit {
@Output() done = new EventEmitter<any>(); @Output() done = new EventEmitter<any>();
title = '新增用户'; title;
isVisible = false; isVisible = false;
groupList:any[]; groupList:any[];
validateForm:FormGroup; validateForm:FormGroup;
userId;
constructor(private fb:FormBuilder,private systemSer:SystemService, constructor(private fb:FormBuilder,private systemSer:SystemService,
private message:NzMessageService) { private message:NzMessageService) {
...@@ -34,22 +35,42 @@ export class UserComponent implements OnInit { ...@@ -34,22 +35,42 @@ export class UserComponent implements OnInit {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
name:[null,[Validators.required,Validators.maxLength(10)]], name:[null,[Validators.required,Validators.maxLength(10)]],
loginName:[null,[Validators.required,Validators.maxLength(10)]], loginName:[null,[Validators.required,Validators.maxLength(10)]],
mobile:[null,[Validators.required,Validators.min(11),Validators.maxLength(11)]], phoneNumber:[null,[Validators.required,Validators.min(11),Validators.maxLength(11)]],
gender:[null,[Validators.required]], gender:[null,[Validators.required]],
email:[null,[Validators.email]], email:[null,[Validators.email]],
organizeId:[null,[Validators.required]], organizationId:[null,[Validators.required]],
comments:[null,[Validators.required]], position:[null,[Validators.required]],
status:[null,[Validators.required]], status:[null,[Validators.required]],
}) })
} }
showModal(data){ showAddModal(data,title){
this.groupList = data; this.groupList = data;
this.isVisible = true; this.isVisible = true;
this.title = title;
}
showEditModal(data,title,id){
this.userId = id;
this.groupList = data;
this.isVisible = true;
this.title = title;
this.systemSer.getUser(this.userId).subscribe(
(res)=>{
if(res.errCode == 10000){
res.data.gender += "";
res.data.position += "";
res.data.status += "";
res.data.organizationId += "";
this.validateForm.patchValue(res.data);
}
}
)
} }
handleCancel(){ handleCancel(){
this.isVisible = false; this.isVisible = false;
this.initForm();
} }
handleOk(){ handleOk(){
...@@ -62,15 +83,39 @@ export class UserComponent implements OnInit { ...@@ -62,15 +83,39 @@ export class UserComponent implements OnInit {
if(this.validateForm.invalid){ if(this.validateForm.invalid){
return false; return false;
} }
if(this.title == "新增用户"){
this.create();
}
if(this.title == "编辑用户"){
this.update();
}
}
create(){
this.systemSer.adduser(this.validateForm.value).subscribe( this.systemSer.adduser(this.validateForm.value).subscribe(
(res)=>{ (res)=>{
if(res.errCode == 10000){ if(res.errCode == 10000){
this.isVisible = false; this.isVisible = false;
this.initForm(); this.initForm();
this.done.emit(); this.done.emit();
}else{ }else{
this.message.error(res.errMsg); this.message.error(res.errMsg);
} }
}
)
}
update(){
this.validateForm.addControl('id',new FormControl(this.userId));
this.systemSer.updateUser(this.validateForm.value).subscribe(
(res)=>{
if(res.errCode == 10000){
this.isVisible = false;
this.initForm();
this.done.emit();
}else{
this.message.error(res.errMsg);
}
} }
) )
} }
......
...@@ -45,9 +45,24 @@ export class SystemService { ...@@ -45,9 +45,24 @@ export class SystemService {
return this.http.post(SERVER_API_URL_coms + '/user/createUser',data); return this.http.post(SERVER_API_URL_coms + '/user/createUser',data);
} }
//编辑用户
updateUser(data): Observable<any>{
return this.http.post(SERVER_API_URL_coms + '/user/updateUser',data);
}
//查找用户
getUser(params): Observable<any>{
return this.http.get(SERVER_API_URL_coms + '/user/getUserById/'+params);
}
//删除用户
deleteUser(data): Observable<any>{
return this.http.get(SERVER_API_URL_coms + '/user/deleteUser?' + this.commonSer.toQuery(data) );
}
//删除用户 //删除用户
deleteUser(params){ batchDeleteUser(data): Observable<any>{
return this.http.delete(SERVER_API_URL_coms + '/user/'+ params); return this.http.post(SERVER_API_URL_coms + '/user/batchDeleteUser' ,data);
} }
//组织结构列表 /organization/updateOrganization //组织结构列表 /organization/updateOrganization
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment