员工管理

This commit is contained in:
Taric Xin
2021-11-30 11:11:02 +08:00
parent 08d5b09401
commit 83208b4934
22 changed files with 650 additions and 53 deletions

View File

@ -0,0 +1,24 @@
<div class="modal-header">
<div class="modal-title">{{ i.id === 0 ? '添加员工' : '编辑员工' }}</div>
</div>
<div>
<sf #sf [compact]="true" [ui]="ui" [schema]="schema" [button]="'none'">
<ng-template sf-template="account" let-me let-ui="ui" let-schema="schema">
<sv-container labelWidth="1">
<sv label="">
<div class="staffBox">
<!-- <img [src]="i.avatar" alt="" /> -->
<dl>
<!-- <dt>{{ i.name }}</dt> -->
<dd>{{ i.phone }}</dd>
</dl>
</div>
</sv>
</sv-container>
</ng-template>
</sf>
</div>
<div class="modal-footer">
<button nz-button type="button" (click)="close()">取消</button>
<button nz-button type="button" nzType="primary" (click)="sure()" [disabled]="!sf.valid">保存</button>
</div>

View File

@ -0,0 +1,146 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { SFComponent, SFSchema, SFUISchema } from '@delon/form';
import { _HttpClient } from '@delon/theme';
import { copy } from '@delon/util';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
import { map } from 'rxjs/operators';
import { EAEnterpriseService } from 'src/app/shared/services/business/enterprise.service';
import { SystemService } from '../../../services/system.service';
@Component({
selector: 'app-system-add',
templateUrl: './staff-modal.component.html',
styleUrls: ['./staff-modal.less']
})
export class SystemStaffStaffModalComponent implements OnInit {
@ViewChild('sf', { static: false })
sf!: SFComponent;
i: any;
schema!: SFSchema;
ui!: SFUISchema;
roleList = [];
roleNames: any = [];
constructor(
private modal: NzModalRef,
public msgSrv: NzMessageService,
public service: SystemService,
private enterpriseSrv: EAEnterpriseService
) {}
ngOnInit(): void {
if (this.i?.id !== 0) {
this.i.roleIds = this.i.roleId !== '' ? this.i.roleId.split(',') : [];
}
this.initSF(this.i);
}
initSF(staff: any) {
console.log(staff);
this.schema = {
properties: {
name: {
title: '员工姓名',
type: 'string',
maxLength: 32,
ui: { widget: staff?.name ? 'text' : 'string', placeholder: '请输入员工姓名' },
default: staff.name
},
phone: {
title: '手机号码',
type: 'string',
format: 'mobile',
maxLength: 11,
ui: { widget: staff?.phone ? 'text' : 'string', placeholder: '请输入员工手机号' },
default: staff.phone
},
roleIds: {
title: '角色',
type: 'string',
ui: {
widget: 'select',
placeholder: '请选择员工角色',
mode: 'multiple',
maxMultipleCount: 5,
// asyncData: () => {
// return this.service.request(this.service.$api_getAppRoleList).pipe(
// map((res: any) => {
// this.roleList = res;
// return res.map((item: any) => {
// return { label: item.roleName, value: item.id };
// });
// }),
// );
// },
change: (i: any) => {
this.sf.value.roleIds = i;
this.sf?.setValue('/roleIds', i);
}
},
default: staff?.roleIds
}
},
required: ['name', 'phone', 'roleIds']
};
this.ui = {
'*': {
spanLabelFixed: 120,
grid: { span: 24 }
}
};
}
sure() {
if (!this.sf.value.roleIds || this.sf.value.roleIds.length === 0) {
this.service.msgSrv.error('员工角色不能为空!');
return;
}
this.roleNames = [];
this.roleList.forEach((item: { id: any; roleName: string }) => {
this.sf.value.roleIds.forEach((ele: any) => {
if (ele === item.id) {
this.roleNames.push(item.roleName);
}
});
});
if (this.i.id === 0) {
const params: any = {
...this.sf.value,
roleId: this.sf.value.roleIds,
roleNames: this.roleNames.join(','),
telephone: this.sf.value.phone,
staffName: this.sf.value.name
};
// this.service.request(this.service.$api_addStaff, params).subscribe((res) => {
// console.log(res);
// if (res) {
// this.service.msgSrv.success('保存成功!');
// this.modal.close(true);
// }
// // this.showInviteFlag = true;
// // this.inviteCode = res.inviteCode;
// });
} else {
const params: any = {
appUserId: this.i.appUserId,
staffName: this.sf.value.name,
roleId: this.sf.value.roleIds,
telephone: this.i.telephone
};
// this.service.request(this.service.$api_editorStaff, params).subscribe((res) => {
// this.service.msgSrv.success('编辑成功!');
// // this.loadMyIdentity();
// this.modal.close(true);
// });
}
}
loadMyIdentity() {
this.enterpriseSrv.loadEnterpises().subscribe((data: any[]) => {
this.enterpriseSrv.setCache(data);
});
}
close() {
this.modal.destroy();
}
}

View File

@ -0,0 +1,25 @@
.info {
width: 100%;
margin: 0 auto 10px auto;
color: #333;
text-indent: 24px;
}
.staffBox {
display: flex;
img {
width: 30px;
height: 30px;
overflow: hidden;
border-radius: 50px;
}
dl {
margin: 0 0 0 5px;
dt {
font-size: 14px;
line-height: 28px;
}
dd {
font-size: 12px;
}
}
}