Commit 8f89c614 authored by wangqinghua's avatar wangqinghua

update

parent 2b1ed70b
<p-table [value]="sales">
<ng-template pTemplate="header">
<tr>
<th rowspan="3">Brand</th>
<th colspan="4">Sale Rate</th>
</tr>
<tr>
<th colspan="2">Sales</th>
<th colspan="2">Profits</th>
</tr>
<tr>
<th>Last Year</th>
<th>This Year</th>
<th>Last Year</th>
<th>This Year</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-sale>
<tr>
<td>{{sale.brand}}</td>
<td>{{sale.lastYearSale}}</td>
<td>{{sale.thisYearSale}}</td>
<td>{{sale.lastYearProfit}}</td>
<td>{{sale.thisYearProfit}}</td>
</tr>
</ng-template>
<ng-template pTemplate="footer">
<tr>
<td colspan="3">Totals</td>
<td>$506,202</td>
<td>$531,020</td>
</tr>
</ng-template>
</p-table>
<!--资源可用性统计-->
<div nz-row class="breadcrumbs">
<div nz-col nzSpan="16">
<nz-breadcrumb class="padding-8-0">
<nz-breadcrumb-item>
当前位置:首页
</nz-breadcrumb-item>
</nz-breadcrumb>
</div>
<div nz-col nzSpan="8" class="text-right">
<button (click)="search()" nz-button nzType="primary"><i class="anticon anticon-search"></i></button>
<button nz-button nzType="primary"><i class="anticon anticon-sync"></i></button>
<button nz-button nzType="primary"><i class="anticon anticon-arrows-alt"></i></button>
</div>
</div>
<div nz-row nzGutter="4">
<div nz-col nzSpan="16">
<nz-spin [nzSpinning]="isTopLoading">
<div echarts [options]="chartTopOption" style="height: 400px;width: 100%"></div>
</nz-spin>
</div>
<div nz-col nzSpan="12">
<nz-spin [nzSpinning]="isLastLoading">
<div echarts [options]="chartLastOption" style="height: 400px;width: 100%"></div>
</nz-spin>
</div>
</div>
......@@ -12,9 +12,11 @@ import { Account, Principal } from '../shared';
})
export class HomeComponent implements OnInit {
account: Account;
modalRef: NgbModalRef;
sales: any[];
leftOneChart;
leftTwoChart;
rightOneChart;
rightTwoChart;
constructor(
private principal: Principal,
......@@ -23,34 +25,7 @@ export class HomeComponent implements OnInit {
}
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() {
......
......@@ -49,8 +49,8 @@
<div nz-col nzSpan="18">
<div class="padding-15-0">
<button (click)="showUserModal()" nz-button nzType="primary">新增用户</button>
<button nz-button nzType="default">批量删除</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>
......@@ -72,14 +72,16 @@
<tbody>
<tr *ngFor="let data of basicTable.data">
<td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="refreshStatus($event)"></td>
<td>{{data.name}}</td>
<td>{{data.user.name}}</td>
<td>{{data.loginName}}</td>
<td>{{data.mobile}}</td>
<td>{{data.key4}}</td>
<td>{{data.user.phoneNumber}}</td>
<td>
<span *ngFor="let item of data.roles">{{item.name}}</span>
</td>
<td class="handle">
<span (click)="grantRole(data)">授权</span>
<span>查看</span>
<span>编辑</span>
<span (click)="showEditModal(data)">编辑</span>
<span (click)="deleteUser(data)">删除</span>
</td>
</tr>
......
......@@ -26,24 +26,24 @@ export class GroupComponent implements OnInit {
nodes: any[];
isVisible = true;
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,
private modalSer: NzModalService, private commonSer: CommonService) {
}
checkAll(value: boolean): void {
this.displayData.forEach(data => data.checked = value);
this.dataSet.forEach(data => data.checked = value);
this.refreshStatus();
}
currentPageDataChange($event: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }>): void {
this.displayData = $event;
currentPageDataChange($event: Array<{ checked: boolean }>): void {
this.dataSet = $event;
}
refreshStatus(): void {
const allChecked = this.displayData.every(value => value.checked === true);
const allUnChecked = this.displayData.every(value => !value.checked);
const allChecked = this.dataSet.every(value => value.checked === true);
const allUnChecked = this.dataSet.every(value => !value.checked);
this.allChecked = allChecked;
this.indeterminate = (!allChecked) && (!allUnChecked);
this.disabledButton = !this.dataSet.some(value => value.checked);
......@@ -117,22 +117,30 @@ export class GroupComponent implements OnInit {
//新增用户
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({
nzTitle: '删除',
nzContent: '<b style="color: red">确定删除该用户吗</b>',
nzOkText: '确定',
nzCancelText: '取消',
nzOnOk: () => {
this.systemSer.deleteUser(data.id).subscribe(
const data = {
id:item.user.id
};
this.systemSer.deleteUser(data).subscribe(
(res) => {
// if(res.errCode == 10000){
// }
if(res.data == 1){
this.getUser();
}
}
);
},
......@@ -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() {
this.smartGroupModal.showModal(this.groupList);
......
......@@ -15,10 +15,10 @@
</nz-form-control>
</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">
<input nz-input formControlName="mobile" id="mobile">
<nz-form-explain *ngIf="validateForm.get('mobile').dirty && validateForm.get('mobile').errors">手机号码错误!</nz-form-explain>
<input nz-input formControlName="phoneNumber" id="phoneNumber">
<nz-form-explain *ngIf="validateForm.get('phoneNumber').dirty && validateForm.get('phoneNumber').errors">手机号码错误!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
......@@ -39,24 +39,24 @@
</nz-form-control>
</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-select id="orgId" formControlName="organizeId" nzPlaceHolder="选择部门">
<nz-select id="organizationId" formControlName="organizationId" nzPlaceHolder="选择部门">
<ng-container *ngFor="let item of groupList">
<nz-option nzValue="{{item.id}}" nzLabel="{{item.name}}"></nz-option>
</ng-container>
</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-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-select id="comments" formControlName="comments" nzPlaceHolder="选择职位">
<nz-select id="position" formControlName="position" nzPlaceHolder="选择职位">
<nz-option nzValue="1" nzLabel="组长"></nz-option>
<nz-option nzValue="2" nzLabel="组员"></nz-option>
</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-item>
<nz-form-item>
......
......@@ -17,10 +17,11 @@ import {NzMessageService} from 'ng-zorro-antd';
export class UserComponent implements OnInit {
@Output() done = new EventEmitter<any>();
title = '新增用户';
title;
isVisible = false;
groupList:any[];
validateForm:FormGroup;
userId;
constructor(private fb:FormBuilder,private systemSer:SystemService,
private message:NzMessageService) {
......@@ -34,22 +35,42 @@ export class UserComponent implements OnInit {
this.validateForm = this.fb.group({
name:[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]],
email:[null,[Validators.email]],
organizeId:[null,[Validators.required]],
comments:[null,[Validators.required]],
organizationId:[null,[Validators.required]],
position:[null,[Validators.required]],
status:[null,[Validators.required]],
})
}
showModal(data){
showAddModal(data,title){
this.groupList = data;
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(){
this.isVisible = false;
this.initForm();
}
handleOk(){
......@@ -62,6 +83,15 @@ export class UserComponent implements OnInit {
if(this.validateForm.invalid){
return false;
}
if(this.title == "新增用户"){
this.create();
}
if(this.title == "编辑用户"){
this.update();
}
}
create(){
this.systemSer.adduser(this.validateForm.value).subscribe(
(res)=>{
if(res.errCode == 10000){
......@@ -74,4 +104,19 @@ export class UserComponent implements OnInit {
}
)
}
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 {
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){
return this.http.delete(SERVER_API_URL_coms + '/user/'+ params);
batchDeleteUser(data): Observable<any>{
return this.http.post(SERVER_API_URL_coms + '/user/batchDeleteUser' ,data);
}
//组织结构列表 /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