UNPKG

@ecip/user

Version:
941 lines (934 loc) 55.2 kB
import { SharedModule } from '@ecip/shared'; import { RouterModule } from '@angular/router'; import { _HttpClient, ModalHelper } from '@delon/theme'; import '@delon/abc'; import '@delon/form'; import { FormBuilder, Validators } from '@angular/forms'; import { Observable } from 'rxjs'; import { CacheService } from '@delon/cache'; import { Component, ViewChild, NgModule } from '@angular/core'; import { NzModalRef, NzMessageService, NzTreeNode } from 'ng-zorro-antd'; import { UserService, RoleService, DeptService, AppsService } from '@ecip/service'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class UserLocalViewComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} userService */ constructor(modal, msgSrv, userService) { this.modal = modal; this.msgSrv = msgSrv; this.userService = userService; this.record = {}; } /** * @return {?} */ ngOnInit() { this.userService.getById(this.record.id).subscribe((/** * @param {?} res * @return {?} */ res => this.i = res)); } /** * @return {?} */ close() { this.modal.destroy(); } } UserLocalViewComponent.decorators = [ { type: Component, args: [{ selector: 'app-user-local-view', template: "<div class=\"modal-header\">\r\n <div class=\"modal-title\">\u67E5\u770B {{ record.username }} \u4FE1\u606F</div>\r\n</div>\r\n<nz-spin *ngIf=\"!i\" class=\"modal-spin\"></nz-spin>\r\n<sv-container *ngIf=\"i\">\r\n <sv label=\"\u7F16\u53F7\">{{ i.id }}</sv>\r\n <sv label=\"\u8D26\u53F7\">{{ i.username }}</sv>\r\n <sv label=\"\u59D3\u540D\">{{ i.realName }}</sv>\r\n <sv label=\"\u6027\u522B\">{{ i.sexText }}</sv>\r\n <sv label=\"\u90AE\u7BB1\">{{ i.email }}</sv>\r\n <sv label=\"\u521B\u5EFA\u65F6\u95F4\">{{ i.createTime }}</sv>\r\n</sv-container>\r\n<div class=\"modal-footer\">\r\n <button nz-button type=\"button\" (click)=\"close()\">\u5173\u95ED</button>\r\n</div>" }] } ]; /** @nocollapse */ UserLocalViewComponent.ctorParameters = () => [ { type: NzModalRef }, { type: NzMessageService }, { type: UserService } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class UserLocalEditComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} http * @param {?} fb * @param {?} deptService * @param {?} roleService * @param {?} userService * @param {?} cacheService */ constructor(modal, msgSrv, http, fb, deptService, roleService, userService, cacheService) { this.modal = modal; this.msgSrv = msgSrv; this.http = http; this.fb = fb; this.deptService = deptService; this.roleService = roleService; this.userService = userService; this.cacheService = cacheService; this.record = {}; this.depts = []; // allRole = [{id:1, roleName: 'djsf'},{id:2, roleName: 'djsf'}]; this.roleList = []; this.genderList = this.cacheService.get(`api/dict/type/sex`); this.confirmValidator = (/** * @param {?} control * @return {?} */ (control) => { if (!control.value) { if (this.form && this.form.controls.loginPwd.value) { return { required: true }; } return {}; } else if (control.value !== this.form.controls.loginPwd.value) { return { confirm: true, error: true }; } }); } /** * @return {?} */ ngOnInit() { //获取所有组织机构 this.deptService.treeSelect().subscribe((/** * @param {?} res * @return {?} */ (res) => { /** @type {?} */ let depts = []; res.forEach((/** * @param {?} item * @return {?} */ item => { depts.push(new NzTreeNode({ key: item.key, title: item.title, children: item.children, isLeaf: item.isLeaf, expanded: true })); })); this.depts = depts; })); this.roleService.getList().subscribe((/** * @param {?} res * @return {?} */ (res) => { this.roleList = res; })); this.form = this.fb.group({ deptId: [null, []], username: [null, [Validators.required], [UserLocalEditComponent.userNameAsyncValidator(this.userService, this.record.id)]], realName: [null, [Validators.required]], loginPwd: [null, [Validators.required, Validators.minLength(6)]], confirm: [null, [this.confirmValidator]], sex: [null, [Validators.required]], email: [null, [Validators.email]], roleIds: [null, []] }); if (!this.record.id) { this.form.get('deptId').setValue(this.deptId); return; } /** @type {?} */ let loginPwdCtl = this.form.get('loginPwd'); loginPwdCtl.clearValidators(); loginPwdCtl.setValidators(Validators.minLength(6)); loginPwdCtl.updateValueAndValidity(); Observable.forkJoin([this.userService.getById(this.record.id), this.userService.findRoleIds(this.record.id)]).subscribe((/** * @param {?} __0 * @return {?} */ ([user, roleIds]) => { this.form.patchValue(user); this.i = user; this.form.get('roleIds').setValue(roleIds); // this.form.get('sex').setValue("1"); })); /*this.userService.getById(this.record.id).subscribe(res => { this.form.patchValue(res); this.i = res; });*/ } /** * @param {?} userService * @param {?} id * @return {?} */ static userNameAsyncValidator(userService, id) { return (/** * @param {?} control * @return {?} */ (control) => { return userService.checkAccount({ account: control.value, id: id }).map((/** * @param {?} res * @return {?} */ res => { return res ? null : { error: true, duplicated: true }; })); }); } /** * @return {?} */ validateConfirmPassword() { setTimeout((/** * @return {?} */ () => this.form.controls.confirm.updateValueAndValidity())); } /** * @return {?} */ submit() { for (const i in this.form.controls) { this.form.controls[i].markAsDirty(); this.form.controls[i].updateValueAndValidity(); } if (this.form.invalid) return; if (!this.record.id) { //新增 this.userService.post(this.form.value).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('保存成功'); this.modal.close(true); })); return; } //修改 this.userService.put(this.record.id, this.form.value).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('保存成功'); this.modal.close(true); })); } /** * @return {?} */ close() { this.modal.destroy(); } } UserLocalEditComponent.decorators = [ { type: Component, args: [{ selector: 'app-user-local-edit', template: "<div class=\"modal-header\">\r\n <div *ngIf=\"!record.id\" class=\"modal-title\">\u65B0\u589E\u4FE1\u606F</div>\r\n <div *ngIf=\"record.id\" class=\"modal-title\">\u7F16\u8F91 {{ record.account }} \u4FE1\u606F</div>\r\n</div>\r\n<nz-spin *ngIf=\"!i && record.id\" class=\"modal-spin\"></nz-spin>\r\n<form *ngIf=\"!record.id || record.id && i\" nz-form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"deptId\">\u7EC4\u7EC7</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <nz-tree-select formControlName=\"deptId\"\r\n nzPlaceHolder=\"\u8BF7\u9009\u62E9\"\r\n nzShowSearch\r\n [nzDropdownMatchSelectWidth]=\"true\"\r\n [nzShowLine]=\"true\"\r\n [nzDropdownStyle]=\"{ 'max-height': '300px' }\"\r\n [nzNodes]=\"depts\">\r\n </nz-tree-select>\r\n </nz-form-control>\r\n </nz-form-item>\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"username\">\u8D26\u53F7</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"username\">\r\n <nz-form-explain *ngIf=\"form.get('username').dirty && form.get('username').errors || form.get('username').pending \">\r\n <ng-container *ngIf=\"form.get('username').hasError('required')\">\r\n \u8BF7\u8F93\u5165\u8D26\u53F7\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('username').hasError('duplicated')\">\r\n \u8D26\u53F7\u5DF2\u5B58\u5728\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('username').pending\">\r\n \u6821\u9A8C\u4E2D...\r\n </ng-container>\r\n </nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"realName\">\u59D3\u540D</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"realName\">\r\n <nz-form-explain *ngIf=\"form.get('realName').dirty && form.get('realName').errors\">\u8BF7\u8F93\u5165\u59D3\u540D</nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" [nzRequired]=\"!record.id\" nzFor=\"loginPwd\">\u5BC6\u7801</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input type=\"password\" nz-input formControlName=\"loginPwd\" (ngModelChange)=\"validateConfirmPassword()\">\r\n <nz-form-explain *ngIf=\"form.get('loginPwd').dirty && form.get('loginPwd').errors\">\r\n \u8BF7\u8F93\u5165\u5BC6\u7801\u4E14\u957F\u5EA6\u4E0D\u5C0F\u4E8E6\r\n </nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" [nzRequired]=\"!record.id\" nzFor=\"confirm\">\u786E\u8BA4\u5BC6\u7801</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input type=\"password\" nz-input formControlName=\"confirm\">\r\n <nz-form-explain *ngIf=\"form.get('confirm').dirty && form.get('confirm').errors\">\r\n <ng-container *ngIf=\"form.get('confirm').hasError('required')\">\r\n \u8BF7\u8F93\u5165\u786E\u8BA4\u5BC6\u7801\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('confirm').hasError('confirm')\">\r\n \u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u6837\r\n </ng-container>\r\n </nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"sex\" nzRequired >\u6027\u522B</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <nz-radio-group formControlName=\"sex\">\r\n <!--<label nz-radio [nzValue]=\"0\">\u7537</label>-->\r\n <!--<label nz-radio [nzValue]=\"1\">\u5973</label>-->\r\n <label nz-radio *ngFor=\"let gender of genderList | async\" [nzValue]=\"gender.value\">{{gender.label}} </label>\r\n </nz-radio-group>\r\n <nz-form-explain *ngIf=\"form.get('sex').dirty && form.get('sex').errors\">\r\n \u8BF7\u9009\u62E9\u6027\u522B\r\n </nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"email\">\u90AE\u7BB1</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"email\">\r\n <nz-form-explain *ngIf=\"form.get('email').dirty && form.get('email').errors\">\u8BF7\u8F93\u5165\u6B63\u786E\u90AE\u7BB1</nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"roleIds\">\u89D2\u8272</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <!--<input nz-input formControlName=\"roles\">-->\r\n <nz-select nzShowSearch nzAllowClear\r\n nzMode=\"multiple\"\r\n nzPlaceHolder=\"\u9009\u62E9\u89D2\u8272\" formControlName=\"roleIds\">\r\n <nz-option *ngFor=\"let role of roleList\" [nzLabel]=\"role.roleName\"\r\n [nzValue]=\"role.id\"></nz-option>\r\n </nz-select>\r\n </nz-form-control>\r\n </nz-form-item>\r\n <div class=\"modal-footer\">\r\n <button nz-button type=\"button\" (click)=\"close()\">\u5173\u95ED</button>\r\n <button nz-button type=\"submit\" [disabled]=\"!form.valid\" nzType=\"primary\" [nzLoading]=\"userService.http.loading\">\u4FDD\u5B58</button>\r\n </div>\r\n</form>\r\n\r\n<!--<sf *ngIf=\"i\" #sf mode=\"edit\" [schema]=\"schema\" [ui]=\"ui\" [formData]=\"i\" button=\"none\">\r\n <div class=\"modal-footer\">\r\n <button nz-button type=\"button\" (click)=\"close()\">\u5173\u95ED</button>\r\n <button nz-button type=\"submit\" [nzType]=\"'primary'\" (click)=\"save(sf.value)\" [disabled]=\"!sf.valid\" [nzLoading]=\"http.loading\">\u4FDD\u5B58</button>\r\n </div>\r\n</sf>-->\r\n" }] } ]; /** @nocollapse */ UserLocalEditComponent.ctorParameters = () => [ { type: NzModalRef }, { type: NzMessageService }, { type: _HttpClient }, { type: FormBuilder }, { type: DeptService }, { type: RoleService }, { type: UserService }, { type: CacheService } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class UserLocalRoleComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} roleService * @param {?} userService * @param {?} fb */ constructor(modal, msgSrv, roleService, userService, fb) { this.modal = modal; this.msgSrv = msgSrv; this.roleService = roleService; this.userService = userService; this.fb = fb; this.record = {}; this.roleList = []; this.loading = false; } /** * @return {?} */ ngOnInit() { this.form = this.fb.group({ roleIds: [null, []] }); this.loading = true; Observable.forkJoin([this.roleService.getList(), this.userService.findRoleIds(this.record.id)]).subscribe((/** * @param {?} __0 * @return {?} */ ([roleList, roleIds]) => { this.roleList = roleList; this.form.get('roleIds').setValue(roleIds); this.loading = false; })); } /** * @return {?} */ submit() { for (const i in this.form.controls) { this.form.controls[i].markAsDirty(); this.form.controls[i].updateValueAndValidity(); } if (this.form.invalid) return; //修改 this.userService.saveRole(this.record.id, this.form.get('roleIds').value).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('保存成功'); this.modal.close(true); })); } /** * @return {?} */ close() { this.modal.destroy(); } } UserLocalRoleComponent.decorators = [ { type: Component, args: [{ selector: 'app-user-local-role', template: "<div class=\"modal-header\">\r\n <div class=\"modal-title\">{{ record.realName }}-\u5206\u914D\u89D2\u8272</div>\r\n</div>\r\n<nz-spin *ngIf=\"loading\" class=\"modal-spin\"></nz-spin>\r\n<form *ngIf=\"!loading\" nz-form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"roleIds\">\u4EBA\u5458</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" >\r\n <nz-select nzShowSearch nzAllowClear\r\n nzMode=\"multiple\"\r\n nzPlaceHolder=\"\u9009\u62E9\u89D2\u8272\" formControlName=\"roleIds\">\r\n <nz-option *ngFor=\"let role of roleList\" [nzLabel]=\"role.roleName\"\r\n [nzValue]=\"role.id\"></nz-option>\r\n </nz-select>\r\n </nz-form-control>\r\n </nz-form-item>\r\n \r\n <div class=\"modal-footer\">\r\n <button nz-button type=\"button\" (click)=\"close()\">\u5173\u95ED</button>\r\n <button nz-button type=\"submit\" [disabled]=\"!form.valid\" nzType=\"primary\" [nzLoading]=\"loading\">\u4FDD\u5B58</button>\r\n </div>\r\n</form>\r\n" }] } ]; /** @nocollapse */ UserLocalRoleComponent.ctorParameters = () => [ { type: NzModalRef }, { type: NzMessageService }, { type: RoleService }, { type: UserService }, { type: FormBuilder } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class UserLocalAppComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} appsService * @param {?} userService * @param {?} fb */ constructor(modal, msgSrv, appsService, userService, fb) { this.modal = modal; this.msgSrv = msgSrv; this.appsService = appsService; this.userService = userService; this.fb = fb; this.record = {}; this.appList = []; this.loading = false; } /** * @return {?} */ ngOnInit() { this.form = this.fb.group({ appIds: [null, []] }); this.loading = true; Observable.forkJoin([this.appsService.getList(), this.userService.findAppIds(this.record.id)]).subscribe((/** * @param {?} __0 * @return {?} */ ([appList, appIds]) => { this.appList = appList; this.form.get('appIds').setValue(appIds); this.loading = false; })); } /** * @return {?} */ submit() { for (const i in this.form.controls) { this.form.controls[i].markAsDirty(); this.form.controls[i].updateValueAndValidity(); } if (this.form.invalid) return; //修改 this.userService.saveApp(this.record.id, this.form.get('appIds').value).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('保存成功'); this.modal.close(true); })); } /** * @return {?} */ close() { this.modal.destroy(); } } UserLocalAppComponent.decorators = [ { type: Component, args: [{ selector: 'app-user-local-app', template: "<div class=\"modal-header\">\r\n <div class=\"modal-title\">{{ record.realName }}-\u7CFB\u7EDF</div>\r\n</div>\r\n<nz-spin *ngIf=\"loading\" class=\"modal-spin\"></nz-spin>\r\n<form *ngIf=\"!loading\" nz-form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"appIds\">\u80FD\u8BBF\u95EE\u7CFB\u7EDF</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" >\r\n <nz-select nzShowSearch nzAllowClear\r\n nzMode=\"multiple\"\r\n [compareWith]=\"userService.compareNumStr\"\r\n nzPlaceHolder=\"\u9009\u62E9\u7CFB\u7EDF\" formControlName=\"appIds\">\r\n <nz-option *ngFor=\"let app of appList\" [nzLabel]=\"app.appName\"\r\n [nzValue]=\"app.appId\"></nz-option>\r\n </nz-select>\r\n </nz-form-control>\r\n </nz-form-item>\r\n \r\n <div class=\"modal-footer\">\r\n <button nz-button type=\"button\" (click)=\"close()\">\u5173\u95ED</button>\r\n <button nz-button type=\"submit\" [disabled]=\"!form.valid\" nzType=\"primary\" [nzLoading]=\"loading\">\u4FDD\u5B58</button>\r\n </div>\r\n</form>\r\n" }] } ]; /** @nocollapse */ UserLocalAppComponent.ctorParameters = () => [ { type: NzModalRef }, { type: NzMessageService }, { type: AppsService }, { type: UserService }, { type: FormBuilder } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class UserLocalComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} deptService * @param {?} userService */ constructor(modal, msgSrv, deptService, userService) { this.modal = modal; this.msgSrv = msgSrv; this.deptService = deptService; this.userService = userService; this.url = `api/v1/sysrUser/list`; this.searchSchema = { properties: { id: { type: 'string', title: '编号' }, username: { type: 'string', title: '账号' }, realName: { type: 'string', title: '姓名' } } }; this.columns = [ // { title: '编号', index: 'id' }, { title: '账号', index: 'username' }, { title: '姓名', index: 'realName' }, { title: '性别', index: 'sexText' }, { title: '邮箱', index: 'email' }, { title: '创建时间', type: 'date', index: 'createTime' }, { title: '操作', width: '100px', buttons: [ { text: '删除', type: 'del', click: (/** * @param {?} item * @return {?} */ (item) => { //删除 this.userService.deleteById(item.id).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('删除成功'); this.st.reload(); })); }), acl: { ability: ['local:remove'] } }, { text: '', children: [ { text: '查看', type: 'static', component: UserLocalViewComponent, click: 'reload', acl: { ability: ['local:view'] } }, { text: '编辑', type: 'static', component: UserLocalEditComponent, click: 'reload', acl: { ability: ['local:edit'] } }, { text: '角色', type: 'static', component: UserLocalRoleComponent, click: 'reload', acl: { ability: ['role:choose'] } }, { text: '系统', type: 'static', component: UserLocalAppComponent, click: 'reload', acl: { ability: ['system:choose'] } }, { text: '重置密码', pop: true, popTitle: '你确认要重置密码吗', click: (/** * @param {?} item * @return {?} */ (item) => { //重置密码 this.userService.resetPasswordById(item.id).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('重置密码成功'); this.st.reload(); })); }), acl: { ability: ['password:reset'] } } ], }, ], index: 'operate' } ]; this.depts = []; } /** * @return {?} */ ngOnInit() { //获取组织机构 this.deptService.getList().subscribe((/** * @param {?} res * @return {?} */ (res) => { /** @type {?} */ let root = []; res.forEach((/** * @param {?} item * @return {?} */ item => { /** @type {?} */ let node = new NzTreeNode({ key: item.id, title: item.shortName, children: item.children, isLeaf: !item.children }); root.push(node); })); this.depts = root; })); } /** * @return {?} */ add() { this.modal .createStatic(UserLocalEditComponent, { i: {}, deptId: this.deptId }) .subscribe((/** * @return {?} */ () => this.st.reload())); } /** * @param {?} e * @param {?} st * @return {?} */ deptClick(e, st) { this.deptId = e.node.key; st.reload({ deptId: this.deptId }); } } UserLocalComponent.decorators = [ { type: Component, args: [{ selector: 'app-user-local', template: "<page-header [action]=\"phPhAction\">\r\n <ng-template #phPhAction>\r\n <button acl [acl-ability]=\"'local:add'\" (click)=\"add()\" nz-button nzType=\"primary\">\u65B0\u5EFA</button>\r\n </ng-template>\r\n</page-header>\r\n<nz-layout>\r\n <nz-sider nzCollapsible [nzWidth]=\"200\">\r\n <div style=\"margin: 10px\">\u7EC4\u7EC7\u673A\u6784</div>\r\n <nz-tree [(ngModel)]=\"depts\" [nzShowLine]=\"true\" [nzAsyncData]=\"true\" (nzExpandChange)=\"deptService.deptExpand($event)\" (nzClick)=\"deptClick($event, st)\"></nz-tree>\r\n </nz-sider>\r\n <nz-content>\r\n <nz-card>\r\n <sf mode=\"search\" [schema]=\"searchSchema\" (formSubmit)=\"st.reset($event)\" (formReset)=\"st.reset($event)\"></sf>\r\n <st #st [data]=\"url\" [columns]=\"columns\"></st>\r\n </nz-card>\r\n </nz-content>\r\n</nz-layout>", styles: [":host ::ng-deep .ant-layout-sider-children{border-top:1px solid #e8e8e8;border-left:1px solid #e8e8e8}"] }] } ]; /** @nocollapse */ UserLocalComponent.ctorParameters = () => [ { type: ModalHelper }, { type: NzMessageService }, { type: DeptService }, { type: UserService } ]; UserLocalComponent.propDecorators = { st: [{ type: ViewChild, args: ['st',] }] }; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class UserDeptEditComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} fb * @param {?} deptService * @param {?} cacheService */ constructor(modal, msgSrv, fb, deptService, cacheService) { this.modal = modal; this.msgSrv = msgSrv; this.fb = fb; this.deptService = deptService; this.cacheService = cacheService; this.record = {}; this.stateList = this.cacheService.get(`api/dict/type/enableState`); this.codeAsyncValidator = (/** * @param {?} control * @return {?} */ (control) => Observable.create((/** * @param {?} observer * @return {?} */ (observer) => { if (!control.value) { observer.next(null); observer.complete(); return; } this.deptService.checkCode({ code: control.value, id: this.record.id }).subscribe((/** * @param {?} res * @return {?} */ (res) => { if (res.valid === true) { observer.next(null); } else { observer.next({ error: true, duplicated: true }); } observer.complete(); })); }))); } /** * @return {?} */ ngOnInit() { /** @type {?} */ let nodeLevel; /** @type {?} */ let pid = null; /** @type {?} */ let path = ''; if (!this.record.id) { if (this.isRoot) { nodeLevel = 0; } else { pid = this.parent.id; /** @type {?} */ let parentPath = this.parent.path; if (!parentPath) { //id逗号分隔,从下到上 path = `,${this.parent.id},`; } else { path = `,${this.parent.id}${this.parent.path}`; } nodeLevel = this.parent.nodeLevel + 1; } } this.form = this.fb.group({ pid: [pid, []], nodeLevel: [nodeLevel, []], path: [path, []], shortName: [null, [Validators.required]], fullName: [null, []], remark: [null, []], deptLegal: [null, []], telphone1: [null, []], telphone2: [null, []], address: [null, []], deptNature: [null, []], areaCode: [null, []], // typeShow: [null, [Validators.required]], typeTradec: [null, []], typeRI: [null, []], runStatus: [null, []], beginDate: [null, []], endDate: [null, []], rsvn: [null, []], benchmark: [null, [Validators.required]], status: [1, [Validators.required]], sortNum: [0, [Validators.required]], }); if (!this.record.id) { return; } this.deptService.getById(this.record.id).subscribe((/** * @param {?} res * @return {?} */ (res) => { this.form.patchValue(res); // this.form.patchValue({code: res.code}); this.i = res; })); } /** * @param {?} c1 * @param {?} c2 * @return {?} */ compareNumStr(c1, c2) { return c1 == c2; } /** * @return {?} */ submit() { for (const i in this.form.controls) { this.form.controls[i].markAsDirty(); this.form.controls[i].updateValueAndValidity(); } if (this.form.invalid) return; if (!this.record.id) { //新增 this.deptService.post(this.form.value).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('保存成功'); this.modal.close(res); })); return; } //修改 this.deptService.put(this.record.id, this.form.value).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('保存成功'); this.modal.close(res); })); } /** * @return {?} */ close() { this.modal.destroy(); } } UserDeptEditComponent.decorators = [ { type: Component, args: [{ selector: 'app-user-dept-edit', template: "<div class=\"modal-header\">\r\n <div *ngIf=\"!record.id\" class=\"modal-title\">\u65B0\u589E\u4FE1\u606F</div>\r\n <div *ngIf=\"record.id\" class=\"modal-title\">\u7F16\u8F91 {{ record.account }} \u4FE1\u606F</div>\r\n</div>\r\n<nz-spin *ngIf=\"!i && !record.id\" class=\"modal-spin\"></nz-spin>\r\n<form *ngIf=\"!record.id || record.id && i\" nz-form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\r\n <div nz-row>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"shortName\">\u540D\u79F0</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"shortName\">\r\n <nz-form-explain *ngIf=\"form.get('shortName').dirty && form.get('shortName').errors\">\r\n \u8BF7\u8F93\u5165\u540D\u79F0\r\n </nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"fullName\">\u5168\u79F0</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"fullName\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n </div>\r\n <div nz-row>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"deptLegal\">\u8D1F\u8D23\u4EBA</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"deptLegal\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"telphone1\">\u8054\u7CFB\u7535\u8BDD1</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"telphone1\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n </div>\r\n <div nz-row>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"telphone2\">\u8054\u7CFB\u7535\u8BDD2</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"telphone2\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"address\">\u5730\u5740</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"address\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n </div>\r\n\r\n <div nz-row>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"deptNature\">\u516C\u53F8\u6027\u8D28</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"deptNature\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"areaCode\">\u5730\u533A\u7F16\u7801</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"areaCode\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n </div>\r\n\r\n <div nz-row>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"typeTradec\">\u884C\u4E1A\u7C7B\u522B\u4EE3\u7801</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"typeTradec\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"typeRI\">\u6743\u76CA\u7C7B\u578B</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"typeRI\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n </div>\r\n\r\n <div nz-row>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"runStatus\">\u8FD0\u8425\u72B6\u6001</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"runStatus\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"benchmark\">\u53E3\u5F84</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"benchmark\">\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n </div>\r\n\r\n <div nz-row>\r\n\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"sortNm\">\u6392\u5E8F</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"sortNum\">\r\n <nz-form-explain *ngIf=\"form.get('sortNum').dirty && form.get('sortNum').errors\">\r\n \u8BF7\u8F93\u5165\u6392\u5E8F\r\n </nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"status\">\u542F\u7528\u72B6\u6001</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <nz-radio-group formControlName=\"status\">\r\n <!--<label nz-radio [nzValue]=\"1\">\u542F\u7528</label>-->\r\n <!--<label nz-radio [nzValue]=\"0\">\u672A\u542F\u7528</label>-->\r\n <label nz-radio *ngFor=\"let state of stateList | async\" [nzValue]=\"state.value\">{{state.label}}</label>\r\n </nz-radio-group>\r\n <nz-form-explain *ngIf=\"form.get('status').dirty && form.get('status').errors\">\r\n \u8BF7\u9009\u62E9\u542F\u7528\u72B6\u6001\r\n </nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\r\n </div>\r\n\r\n <div class=\"modal-footer\">\r\n <button nz-button type=\"button\" (click)=\"close()\">\u5173\u95ED</button>\r\n <button nz-button type=\"submit\" [disabled]=\"!form.valid\" nzType=\"primary\"\r\n [nzLoading]=\"deptService.http.loading\">\u4FDD\u5B58</button>\r\n </div>\r\n</form>\r\n" }] } ]; /** @nocollapse */ UserDeptEditComponent.ctorParameters = () => [ { type: NzModalRef }, { type: NzMessageService }, { type: FormBuilder }, { type: DeptService }, { type: CacheService } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class UserDeptComponent { //所有节点的map,key为id,value为节点对象 /** * @param {?} modal * @param {?} msgSrv * @param {?} deptService */ constructor(modal, msgSrv, deptService) { this.modal = modal; this.msgSrv = msgSrv; this.deptService = deptService; this.searchSchema = { properties: { shortName: { type: 'string', title: '名称' } } }; this.data = []; this.dataList = {}; //所有节点的map,key为id,value为节点对象 } /** * @return {?} */ ngOnInit() { this.deptService.getList(this.sf.value).subscribe((/** * @param {?} res * @return {?} */ (res) => { this.data = res; this.data.forEach((/** * @param {?} item * @return {?} */ item => { this.dataList[item.id] = item; // 递归判定,然后将+ 变成 - // this.expansion(item); })); })); } // expansion(item: any) { // // if (item.children !== null || item.children !== []) { // let judge = JSON.stringify({"shortName": item.shortName}) ===JSON.stringify(this.sf.value); // if (judge) { // return; // } // if (item.children) { // // console.log(JSON.stringify({"shortName": item.shortName}) ===JSON.stringify(this.sf.value)); // item.children.forEach(it => { // item.expand = true; // this.expansion(it); // }); // } // return; // } /** * @param {?} parentId * @return {?} */ addChild(parentId) { this.selectId = parentId; this.add(false); } /** * @param {?} isRoot * @return {?} */ add(isRoot) { /** @type {?} */ let parent; if (!isRoot) { if (!this.selectId) { this.msgSrv.warning("请选择父节点"); return; } parent = this.dataList[this.selectId]; } this.modal .createStatic(UserDeptEditComponent, { i: {}, isRoot: isRoot, parent: parent }) .subscribe((/** * @param {?} res * @return {?} */ (res) => { this.dataList[res.id] = res; if (isRoot) { this.data.push(res); return; } if (!parent.children) { parent.children = []; parent.expand = true; } parent.children.push(res); })); } /** * @param {?} item * @return {?} */ edit(item) { this.modal .createStatic(UserDeptEditComponent, { record: item }) .subscribe((/** * @param {?} res * @return {?} */ (res) => { item = Object.assign(item, res); this.dataList[res.id] = res; })); } /** * @param {?} item * @return {?} */ delete(item) { this.deptService.deleteById(item.id).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('删除成功'); //根节点 if (!item.pid) { this.data = this.data.filter((/** * @param {?} _item * @return {?} */ _item => _item.id !== item.id)); this.dataList[item.id] = null; return; } //子节点 this.dataList[item.pid].children = this.dataList[item.pid].children.filter((/** * @param {?} _item * @return {?} */ _item => _item.id !== item.id)); })); } /** * @param {?} data * @param {?} $event * @return {?} */ collapse(data, $event) { if (!$event || data.children.length > 0) { return; } this.deptService.getChildren(data.id).subscribe((/** * @param {?} res * @return {?} */ res => { data.children = res; data.children.forEach((/** * @param {?} item * @return {?} */ item => { this.dataList[item.id] = item; })); })); } } UserDeptComponent.decorators = [ { type: Component, args: [{ selector: 'app-user-dept', template: "<page-header [action]=\"phPhAction\">\r\n <ng-template #phPhAction>\r\n <nz-dropdown>\r\n <button nz-button nz-dropdown nzType=\"primary\" acl [acl-ability]=\"'dept:add'\">\r\n \u65B0\u5EFA\r\n <i class=\"anticon anticon-down\"></i>\r\n </button>\r\n <ul nz-menu>\r\n <li (click)=\"add(true)\" nz-menu-item>\r\n <a>\u6839\u8282\u70B9</a>\r\n </li>\r\n <li (click)=\"add(false)\" nz-menu-item>\r\n <a>\u5B50\u8282\u70B9</a>\r\n </li>\r\n </ul>\r\n </nz-dropdown>\r\n </ng-template>\r\n</page-header>\r\n<nz-card>\r\n <sf #sf mode=\"search\" [schema]=\"searchSchema\" (formSubmit)=\"ngOnInit()\" (formReset)=\"sf.reset()\"></sf>\r\n <!--<div>-->\r\n <!--<label>\u7EC4\u7EC7\u540D\u79F0\uFF1A</label>-->\r\n <!--<input nz-input [nzSize]=\"'default'\" style=\"width: 15%\" [(ngModel)]=\"deptName\">-->\r\n <!--</div>-->\r\n <!--<simple-table [data]=\"url\" [extraParams]=\"params\" [total]=\"total\" [columns]=\"columns\" [preDataChange]=\"dataChange\" [resReName]=\"{list: 'results' }\" (radioChange)=\"radioChange($event)\"> &lt;!&ndash;<ng-template #expand let-item let-index=\"index\" let-column=\"column\"> {{ item.description }} </ng-template>&ndash;&gt; <ng-template st-row=\"custom\" let-item let-index=\"index\"> <nz-tooltip [nzTitle]=\"'\u5E74\u9F84\uFF1A' + item.phone\"> <span nz-tooltip>tooltip: {{item.phone}}-{{index}}</span> </nz-tooltip> </ng-template> </simple-table>-->\r\n <nz-radio-group style=\"display: inline\" [(ngModel)]=\"selectId\">\r\n <nz-table style=\"margin-top: 16px\" #nzTable [nzData]=\"data\" [nzShowPagination]=\"false\" [nzFrontPagination]=\"false\" [nzBordered]=\"true\" [nzLoading]=\"deptService.http.loading\" [nzScroll]=\"{x:'2000px'}\">\r\n <thead>\r\n <tr>\r\n <th nzWidth=\"65px\" nzLeft=\"0px\"></th>\r\n <th nzWidth=\"200px\" nzLeft=\"65px\">\u540D\u79F0</th>\r\n <th>\u5168\u79F0</th>\r\n <th>\u8D1F\u8D23\u4EBA</th>\r\n <th>\u8054\u7CFB\u7535\u8BDD1</th>\r\n <th>\u8054\u7CFB\u7535\u8BDD2</th>\r\n <th>\u5730\u5740</th>\r\n <th>\u516C\u53F8\u6027\u8D28</th>\r\n <th>\u5730\u533A\u7F16\u7801</th>\r\n <th>\u884C\u4E1A\u7C7B\u522B\u4EE3\u7801</th>\r\n <th>\u6743\u76CA\u7C7B\u578B</th>\r\n <th>\u8FD0\u8425\u72B6\u6001</th>\r\n <th>\u53E3\u5F84</th>\r\n <th>\u6392\u5E8F</th>\r\n <th>\u542F\u7528\u72B6\u6001</th>\r\n <th nzWidth=\"150px\" nzRight=\"0px\">\u64CD\u4F5C</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <ng-template #recursiveList let-data>\r\n <ng-template ngFor let-item [ngForOf]=\"data\">\r\n <tr>\r\n <td nzLeft=\"0px\">\r\n <label nz-radio [nzValue]=\"item.id\"></label>\r\n </td>\r\n <td nzLeft=\"65px\" [nzIndentSize]=\"(item.nodeLevel)*20\" [nzShowExpand]=\"item.children\" [(nzExpand)]=\"item.expand\" (nzExpandChange)=\"collapse(item,$event)\">{{item.shortName}}</td>\r\n <td>{{item.fullName}}</td>\r\n <td>{{item.deptLegal}}</td>\r\n <td>{{item.telphone1}}</td>\r\n <td>{{item.telphone2}}</td>\r\n <td>{{item.address}}</td>\r\n <td>{{item.deptNature}}</td>\r\n <td>{{item.areaCode}}</td>\r\n <td>{{item.typeTradec}}</td>\r\n <td>{{item.typeRI}}</td>\r\n <td>{{item.runStatus}}</td>\r\n <td>{{item.benchmark}}</td>\r\n <td>{{item.sortNum}}</td>\r\n <td>{{item.statusText}}</td>\r\n <td nzRight=\"0px\">\r\n <a acl [acl-ability]=\"'dept:add'\" (click)=\"addChild(item.id)\">\u6DFB\u52A0\u5B50\u8282\u70B9</a>\r\n <nz-divider nzType=\"vertical\" acl [acl-ability]=\"'dept:add'\"></nz-divider>\r\n <nz-dropdown [acl]=\"{ ability: ['dept:edit', 'dept:remove'], mode: 'oneOf' }\">\r\n <a nz-dropdown>\r\n <i class=\"anticon anticon-down\"></i>\r\n </a>\r\n <ul nz-menu>\r\n <li acl [acl-ability]=\"'dept:edit'\" (click)=\"edit(item)\" nz-menu-item>\r\n <a>\u7F16\u8F91</a>\r\n </li>\r\n <li acl [acl-ability]=\"'dept:remove'\" nz-popconfirm nzTitle=\"\u786E\u8BA4\u5220\u9664\u5417?\" (nzOnConfirm)=\"delete(item)\" nz-menu-item>\r\n <a>\u5220\u9664</a>\r\n </li>\r\n </ul>\r\n </nz-dropdown>\r\