UNPKG

@ecip/system

Version:
904 lines (900 loc) 59.6 kB
import { SharedModule } from '@ecip/shared'; import { RouterModule } from '@angular/router'; import { Observable } from 'rxjs'; import '@delon/abc'; import '@delon/form'; import { FormBuilder, Validators } from '@angular/forms'; import { Observable as Observable$1 } from 'rxjs/index'; import { CacheService } from '@delon/cache'; import { UserService, AppsService, ResourceService, DictService } from '@ecip/service'; import { Component, ViewChild, NgModule } from '@angular/core'; import { NzModalRef, NzMessageService } from 'ng-zorro-antd'; import { _HttpClient, ModalHelper } from '@delon/theme'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class SystemResourceEditComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} resourceService * @param {?} userService * @param {?} appsService * @param {?} http * @param {?} fb * @param {?} cacheService */ constructor(modal, msgSrv, resourceService, userService, appsService, http, fb, cacheService) { this.modal = modal; this.msgSrv = msgSrv; this.resourceService = resourceService; this.userService = userService; this.appsService = appsService; this.http = http; this.fb = fb; this.cacheService = cacheService; this.record = {}; this.isViewpermission = false; this.defaultpermission = false; this.loading = false; this.stateList = this.cacheService.get(`api/dict/type/enableState`); this.typeSrcList = this.cacheService.get(`api/dict/type/typeSrc`); this.urlTargetList = this.cacheService.get(`api/dict/type/urlTarget`); this.typeNodeList = this.cacheService.get(`api/dict/type/typeNode`); this.codeAsyncValidator = (/** * @param {?} control * @return {?} */ (control) => Observable.create((/** * @param {?} observer * @return {?} */ (observer) => { if (!control.value) { observer.next(null); observer.complete(); return; } this.resourceService.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() { this.loading = true; /*this.appsService.getList().subscribe(appList => { this.optionList = appList; });*/ this.typeSrcList.subscribe((/** * @param {?} res * @return {?} */ res => { if (res) { this.typeSrc = res[0]; } })); this.urlTargetList.subscribe((/** * @param {?} res * @return {?} */ res => { if (res) { this.urlTarget = res[0]; } })); this.typeNodeList.subscribe((/** * @param {?} res * @return {?} */ res => { if (res) { this.typeNode = res[0]; } })); /** @type {?} */ let flagBreadcrumb; /** @type {?} */ let flagMenuGroup; /** @type {?} */ let nodeLevel; /** @type {?} */ let pid = null; /** @type {?} */ let path = ''; if (!this.record.id) { if (this.isRoot) { nodeLevel = 0; flagBreadcrumb = false; flagMenuGroup = true; } else { this.isViewpermission = this.parent.typeNode !== 2; flagBreadcrumb = true; flagMenuGroup = false; 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; } } else { this.isViewpermission = this.record.typeNode !== 2; } this.form = this.fb.group({ appId: [this.appId, []], code: [null, [Validators.required], [this.codeAsyncValidator]], rsrcName: [null, [Validators.required]], deptId: [null, []], pid: [pid, []], path: [path, []], typeSrc: [this.typeSrc ? this.typeSrc.value : '', [Validators.required]], typeNode: [this.typeNode ? this.typeNode.value : '', [Validators.required]], url: [null, []], urlTarget: [this.urlTarget ? this.urlTarget.value : '', []], rsrcIcon: [null, []], rsrcStatus: [1, [Validators.required]], flagBreadcrumb: [flagBreadcrumb, [Validators.required]], flagMenuGroup: [flagMenuGroup, [Validators.required]], sortNm: [0, [Validators.required]], permission: [null, []], beginTime: [null, []], endTime: [null, []], nodeLevel: [nodeLevel, []], defaultpermission: [false, [Validators.required]], }); if (!this.record.id) { return; } this.resourceService.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.resourceService.post(this.form.value).subscribe((/** * @param {?} res * @return {?} */ (res) => { this.msgSrv.success('保存成功'); if (this.form.value.defaultpermission) { this.resourceService.addDefaultPermission(res).subscribe((/** * @param {?} data * @return {?} */ (data) => { res.children = []; data.forEach((/** * @param {?} it * @return {?} */ it => { res.children.push(it); })); })); } this.modal.close(res); })); return; } //修改 this.resourceService.put(this.record.id, this.form.value).subscribe((/** * @param {?} res * @return {?} */ (res) => { this.msgSrv.success('保存成功'); // 是否新增默认权限 if (this.form.value.defaultpermission) { // 新增默认权限 this.resourceService.addDefaultPermission(res).subscribe((/** * @return {?} */ () => { })); } this.modal.close({ result: res, addFlag: this.form.value.defaultpermission }); })); } /** * @return {?} */ close() { this.modal.destroy(); } } SystemResourceEditComponent.decorators = [ { type: Component, args: [{ selector: 'app-system-resource-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=\"code\">\u7F16\u7801</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"code\">\r\n <nz-form-explain *ngIf=\"form.get('code').dirty && form.get('code').errors || form.get('code').pending \">\r\n <ng-container *ngIf=\"form.get('code').hasError('required')\">\r\n \u8BF7\u8F93\u5165\u7F16\u7801\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('code').hasError('duplicated')\">\r\n \u7F16\u7801\u5DF2\u5B58\u5728\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('code').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 </div>\r\n\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"urlTarget\">url\u7C7B\u578B</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <nz-select [compareWith]=\"compareNumStr\" nzAllowClear formControlName=\"urlTarget\">\r\n <nz-option *ngFor=\"let urlTarget of urlTargetList | async\" [nzValue]=\"urlTarget.value\" [nzLabel]=\"urlTarget.label\"></nz-option>\r\n </nz-select>\r\n <nz-form-explain *ngIf=\"form.get('urlTarget').dirty && form.get('urlTarget').errors\">\r\n \u8BF7\u9009\u62E9url\u7C7B\u578B\r\n </nz-form-explain>\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\" nzRequired nzFor=\"rsrcName\">\u8D44\u6E90\u540D\u79F0</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"rsrcName\">\r\n <nz-form-explain *ngIf=\"form.get('rsrcName').dirty && form.get('rsrcName').errors\">\r\n \u8BF7\u8F93\u5165\u8D44\u6E90\u540D\u79F0\r\n </nz-form-explain>\r\n </nz-form-control>\r\n </nz-form-item>\r\n </div>\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=\"typeSrc\">\u8D44\u6E90\u5206\u7C7B</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <nz-select [compareWith]=\"compareNumStr\" nzAllowClear formControlName=\"typeSrc\">\r\n <nz-option *ngFor=\"let typeSrc of typeSrcList | async\" [nzValue]=\"typeSrc.value\" [nzLabel]=\"typeSrc.label\"></nz-option>\r\n </nz-select>\r\n <nz-form-explain *ngIf=\"form.get('typeSrc').dirty && form.get('typeSrc').errors\">\r\n \u8BF7\u9009\u62E9\u8D44\u6E90\u5206\u7C7B\r\n </nz-form-explain>\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\" nzRequired nzFor=\"typeNode\">\u8D44\u6E90\u7C7B\u578B</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <nz-select [compareWith]=\"compareNumStr\" nzAllowClear formControlName=\"typeNode\">\r\n <nz-option *ngFor=\"let typeNode of typeNodeList | async\" [nzValue]=\"typeNode.value\" [nzLabel]=\"typeNode.label\"></nz-option>\r\n </nz-select>\r\n <nz-form-explain *ngIf=\"form.get('typeNode').dirty && form.get('typeNode').errors\">\r\n \u8BF7\u9009\u62E9\u8D44\u6E90\u7C7B\u578B\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=\"url\">URL</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"url\">\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=\"rsrcIcon\">\u8D44\u6E90\u6837\u5F0F</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"rsrcIcon\">\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=\"permission\">\u6743\u9650\u6807\u5FD7</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"permission\">\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\" nzRequired nzFor=\"flagBreadcrumb\">\u663E\u793A\u5728\u9762\u5305\u5C51</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <nz-radio-group formControlName=\"flagBreadcrumb\">\r\n <label nz-radio [nzValue]=\"true\">\u663E\u793A</label>\r\n <label nz-radio [nzValue]=\"false\">\u4E0D\u663E\u793A</label>\r\n </nz-radio-group>\r\n <nz-form-explain *ngIf=\"form.get('flagBreadcrumb').dirty && form.get('flagBreadcrumb').errors\">\r\n \u8BF7\u9009\u62E9\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=\"flagMenuGroup\">\u662F\u5426\u83DC\u5355\u7EC4</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <nz-radio-group formControlName=\"flagMenuGroup\">\r\n <label nz-radio [nzValue]=\"true\">\u662F</label>\r\n <label nz-radio [nzValue]=\"false\">\u5426</label>\r\n </nz-radio-group>\r\n <nz-form-explain *ngIf=\"form.get('flagMenuGroup').dirty && form.get('flagMenuGroup').errors\">\r\n \u8BF7\u9009\u62E9\r\n </nz-form-explain>\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\" 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=\"sortNm\">\r\n <nz-form-explain *ngIf=\"form.get('sortNm').dirty && form.get('sortNm').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=\"rsrcStatus\">\u542F\u7528\u72B6\u6001</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <nz-radio-group formControlName=\"rsrcStatus\">\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('rsrcStatus').dirty && form.get('rsrcStatus').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 nz-row *ngIf=\"this.isViewpermission\">\r\n <div nz-col nzSpan=\"12\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"defaultpermission\">\u65B0\u589E\u9ED8\u8BA4\u6743\u9650</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <nz-radio-group formControlName=\"defaultpermission\">\r\n <label nz-radio [nzValue]=\"true\">\u662F</label>\r\n <label nz-radio [nzValue]=\"false\">\u5426</label>\r\n </nz-radio-group>\r\n <nz-form-explain *ngIf=\"form.get('defaultpermission').dirty && form.get('defaultpermission').errors\">\r\n \u8BF7\u9009\u62E9\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\" [nzLoading]=\"http.loading\">\u4FDD\u5B58</button>\r\n </div>\r\n</form>\r\n" }] } ]; /** @nocollapse */ SystemResourceEditComponent.ctorParameters = () => [ { type: NzModalRef }, { type: NzMessageService }, { type: ResourceService }, { type: UserService }, { type: AppsService }, { type: _HttpClient }, { type: FormBuilder }, { type: CacheService } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class SystemResourceComponent { /** * @param {?} resourceService * @param {?} appsService * @param {?} modal * @param {?} msgSrv * @param {?} cacheService */ constructor(resourceService, appsService, modal, msgSrv, cacheService) { this.resourceService = resourceService; this.appsService = appsService; this.modal = modal; this.msgSrv = msgSrv; this.cacheService = cacheService; // url = `api/v1/sysrResource/list`; this.searchSchema = { properties: { id: { type: 'string', title: '编号' } } }; this.data = []; this.dataList = {}; //所有节点的map,key为id,value为节点对象 this.appId = -1; } /** * @return {?} */ ngOnInit() { /*this.data.forEach(item => { this.expandDataCache[ item.key ] = this.convertTreeToList(item); }); console.log(this.expandDataCache)*/ this.appsService.getList().subscribe((/** * @param {?} appList * @return {?} */ appList => { this.appList = appList; })); this.appChange(); } /** * @return {?} */ appChange() { this.resourceService.getList({ appId: this.appId }).subscribe((/** * @param {?} res * @return {?} */ (res) => { this.data = res; this.data.forEach((/** * @param {?} item * @return {?} */ item => { this.dataList[item.id] = item; })); })); } /** * @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(SystemResourceEditComponent, { i: {}, isRoot: isRoot, parent: parent, appId: this.appId }) .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 {?} */ addpermission(item) { this.resourceService.addDefaultPermission(item).subscribe((/** * @param {?} res * @return {?} */ (res) => { if (!item.children) { item.children = []; } res.forEach((/** * @param {?} it * @return {?} */ it => { item.children.push(it); })); })); } /** * @param {?} item * @return {?} */ edit(item) { this.modal .createStatic(SystemResourceEditComponent, { record: item }) .subscribe((/** * @param {?} res * @return {?} */ (res) => { item = Object.assign(item, res.result); if (res.addFlag) { this.resourceService.getChildren(res.result.id).subscribe((/** * @param {?} data * @return {?} */ (data) => { item.children = []; data.forEach((/** * @param {?} it * @return {?} */ it => { item.children.push(it); })); })); } this.dataList[res.result.id] = item; })); } /** * @param {?} item * @return {?} */ delete(item) { this.resourceService.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.resourceService.getChildren(data.id).subscribe((/** * @param {?} res * @return {?} */ res => { data.children = res; data.children.forEach((/** * @param {?} item * @return {?} */ item => { this.dataList[item.id] = item; })); })); } } SystemResourceComponent.decorators = [ { type: Component, args: [{ selector: 'app-system-resource', template: "<page-header [action]=\"phPhAction\">\r\n <ng-template #phPhAction>\r\n <nz-dropdown>\r\n <button acl [acl-ability]=\"'resource:add'\" nz-button nz-dropdown nzType=\"primary\">\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 <form nz-form [nzLayout]=\"'inline'\">\r\n <!--<nz-form-item> <nz-col class=\"ant-form-item-control-wrapper\"> <div class=\"ant-form-item-control\"> <button nz-popconfirm nzTitle=\"\u786E\u8BA4\u6388\u6743\u5417?\" (nzOnConfirm)=\"assign()\" nz-button nzType=\"primary\">\u6388\u6743</button> <button nz-popconfirm nzTitle=\"\u786E\u8BA4\u53D6\u6D88\u6388\u6743\u5417?\" (nzOnConfirm)=\"cancel()\" nz-button nzType=\"warning\">\u53D6\u6D88\u6388\u6743</button> </div> </nz-col> </nz-form-item>-->\r\n <nz-form-item>\r\n <nz-form-label>\u7CFB\u7EDF</nz-form-label>\r\n <nz-col class=\"ant-form-item-control-wrapper\">\r\n <div class=\"ant-form-item-control\">\r\n <nz-select style=\"width: 240px\" name=\"appId\" nzShowSearch [(ngModel)]=\"appId\" (ngModelChange)=\"appChange()\">\r\n <nz-option *ngFor=\"let option of appList\" [nzLabel]=\"option.appName\" [nzValue]=\"option.appId\"></nz-option>\r\n </nz-select>\r\n </div>\r\n </nz-col>\r\n </nz-form-item>\r\n </form>\r\n <!--<sf mode=\"search\" [schema]=\"searchSchema\" (formSubmit)=\"st.reset($event)\" (formReset)=\"st.reset($event)\"></sf>-->\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]=\"resourceService.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\">\u8D44\u6E90\u540D\u79F0</th>\r\n <!--<th >\u7CFB\u7EDF</th>-->\r\n <th>\u7F16\u7801</th>\r\n <!--<th>\u7EC4\u7EC7\u673A\u6784</th>-->\r\n <th>\u8D44\u6E90\u5206\u7C7B</th>\r\n <th>\u8D44\u6E90\u7C7B\u578B</th>\r\n <th>AppID</th>\r\n <th>URL</th>\r\n <th>URL\u7C7B\u578B</th>\r\n <th>\u8D44\u6E90\u6837\u5F0F</th>\r\n <th>\u6743\u9650\u6807\u5FD7</th>\r\n <th>\u663E\u793A\u5728\u9762\u5305\u5C51</th>\r\n <th>\u662F\u5426\u83DC\u5355\u7EC4</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.rsrcName}}</td>\r\n <!--<td>{{item.appId}}</td>-->\r\n <td>{{item.code}}</td>\r\n <!--<td>{{item.deptId}}</td>-->\r\n <td>{{item.typeSrc | dictLabel : \"typeSrc\" | async}}</td>\r\n <td>{{item.typeNode | dictLabel : \"typeNode\" | async}}</td>\r\n <td>{{item.appId}}</td>\r\n <td>{{item.url}}</td>\r\n <td>{{item.urlTarget}}</td>\r\n <td>{{item.rsrcIcon}}</td>\r\n <td>{{item.permission}}</td>\r\n <td>{{item.flagBreadcrumbText}}</td>\r\n <td>{{item.flagMenuGroupText}}</td>\r\n <td>{{item.sortNm}}</td>\r\n <td>{{item.rsrcStatusText}}</td>\r\n <td nzRight=\"0px\">\r\n <a acl [acl-ability]=\"'resource:add'\" (click)=\"addChild(item.id)\">\u6DFB\u52A0\u5B50\u8282\u70B9</a>\r\n <nz-divider nzType=\"vertical\" acl [acl-ability]=\"'resource:add'\"></nz-divider>\r\n <nz-dropdown [acl]=\"{ ability: ['resource:auth', 'resource:edit', 'resource: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]=\"'resource:auth'\" nz-popconfirm nzTitle=\"\u662F\u5426\u6DFB\u52A0\uFF1A\u67E5\u770B\u3001\u65B0\u589E\u3001\u4FEE\u6539\u3001\u5220\u9664\u9ED8\u8BA4\u6743\u9650\uFF1F\" (nzOnConfirm)=\"addpermission(item)\" nz-menu-item>\r\n <a>\u65B0\u589E\u9ED8\u8BA4\u6743\u9650</a>\r\n </li>\r\n <li acl [acl-ability]=\"'resource:edit'\" (click)=\"edit(item)\" nz-menu-item>\r\n <a>\u7F16\u8F91</a>\r\n </li>\r\n <li acl [acl-ability]=\"'resource: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\n </td>\r\n </tr>\r\n <ng-container *ngIf=\"item.expand && item.children?.length > 0\">\r\n <ng-container *ngTemplateOutlet=\"recursiveList; context:{ $implicit: item.children }\"></ng-container>\r\n </ng-container>\r\n </ng-template>\r\n </ng-template>\r\n <ng-container *ngTemplateOutlet=\"recursiveList; context:{ $implicit: data }\"></ng-container>\r\n </tbody>\r\n </nz-table>\r\n </nz-radio-group>\r\n</nz-card>\r\n", styles: [":host ::ng-deep .ant-table-wrapper{margin-top:16px}"] }] } ]; /** @nocollapse */ SystemResourceComponent.ctorParameters = () => [ { type: ResourceService }, { type: AppsService }, { type: ModalHelper }, { type: NzMessageService }, { type: CacheService } ]; SystemResourceComponent.propDecorators = { nzTable: [{ type: ViewChild, args: ['nzTable',] }] }; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class SystemDictEditComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} fb * @param {?} dictService * @param {?} cacheService */ constructor(modal, msgSrv, fb, dictService, cacheService) { this.modal = modal; this.msgSrv = msgSrv; this.fb = fb; this.dictService = dictService; this.cacheService = cacheService; this.record = {}; this.stateList = this.cacheService.get(`api/dict/type/enableState`); this.codeAsyncValidator = (/** * @param {?} control * @return {?} */ (control) => Observable$1.create((/** * @param {?} observer * @return {?} */ (observer) => { if (!control.value) { observer.next(null); observer.complete(); return; } /** @type {?} */ let parentId = this.parent ? this.parent.id : null; this.dictService.checkVkey({ id: this.record.id, pid: parentId, vkey: control.value }).subscribe((/** * @param {?} res * @return {?} */ (res) => { if (res.valid === true) { observer.next(null); } else { observer.next({ error: true, duplicated: true }); } observer.complete(); })); }))); this.typeAsyncValidator = (/** * @param {?} control * @return {?} */ (control) => Observable$1.create((/** * @param {?} observer * @return {?} */ (observer) => { if (!control.value) { observer.next(null); observer.complete(); return; } if (this.isRoot) { this.dictService.checkDictType({ id: this.record.id, dictType: control.value }).subscribe((/** * @param {?} res * @return {?} */ (res) => { if (res.valid === true) { observer.next(null); } else { observer.next({ error: true, duplicated: true }); } observer.complete(); })); } else { observer.next(null); observer.complete(); } }))); } /** * @return {?} */ ngOnInit() { /** @type {?} */ let pid = null; /** @type {?} */ let dictType = ''; if (!this.record.id) { if (this.isRoot) { this.ableOperate = true; } else { this.ableOperate = false; pid = this.parent.id; dictType = this.parent.dictType; } } this.form = this.fb.group({ pid: [pid, []], dictType: [dictType, [Validators.required], [this.typeAsyncValidator]], //SystemDictEditComponent.typeAsyncValidator(this.dictService, this.record) vkey: ['', [], [this.codeAsyncValidator]], //SystemDictEditComponent.codeAsyncValidator(this.dictService, this.record, this.parent) vname: [null, [Validators.required]], remark: [null, []], sortNum: [0, [Validators.required]], rsvn: [null, []], valid: [1, [Validators.required]], createTime: [null, []], updateTime: [null, []], creator: [null, []], operator: [null, []], }); if (!this.record.id) { return; } if (this.isRoot) { /** @type {?} */ let vkeyCtl = this.form.get("vkey"); vkeyCtl.clearAsyncValidators(); vkeyCtl.updateValueAndValidity(); } this.dictService.getById(this.record.id).subscribe((/** * @param {?} res * @return {?} */ (res) => { this.isRoot = !res.pid; this.form.patchValue(res); 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.dictService.post(this.form.value).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('保存成功'); this.modal.close(res); })); return; } //修改 this.dictService.put(this.record.id, this.form.value).subscribe((/** * @param {?} res * @return {?} */ res => { this.msgSrv.success('保存成功'); this.modal.close(res); })); } /** * @return {?} */ close() { this.modal.destroy(); } } SystemDictEditComponent.decorators = [ { type: Component, args: [{ selector: 'app-system-dict-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=\"24\" *ngIf=\"!isRoot\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"vkey\">\u7F16\u7801</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"vkey\" required>\r\n <nz-form-explain *ngIf=\"form.get('vkey').dirty && form.get('vkey').errors || form.get('vkey').pending \">\r\n <ng-container *ngIf=\"form.get('vkey').hasError('required')\">\r\n \u8BF7\u8F93\u5165\u7F16\u7801\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('vkey').hasError('duplicated')\">\r\n \u7F16\u7801\u5DF2\u5B58\u5728\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('vkey').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 </div>\r\n </div>\r\n <div nz-row>\r\n <div nz-col nzSpan=\"24\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"vname\">\u540D\u79F0</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"vname\">\r\n <nz-form-explain *ngIf=\"form.get('vname').dirty && form.get('vname').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>\r\n\r\n <div nz-row>\r\n <div nz-col nzSpan=\"24\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"dictType\">\u5206\u7C7B</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input *ngIf=\"isRoot\" nz-input formControlName=\"dictType\">\r\n <nz-form-text *ngIf=\"!isRoot\">{{form.get('dictType').value}}</nz-form-text>\r\n <nz-form-explain *ngIf=\"form.get('dictType').dirty && form.get('dictType').errors || form.get('dictType').pending \">\r\n <ng-container *ngIf=\"form.get('dictType').hasError('required')\">\r\n \u8BF7\u8F93\u5165\u7C7B\u578B\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('dictType').hasError('duplicated')\">\r\n \u6839\u7C7B\u578B\u5DF2\u5B58\u5728\r\n </ng-container>\r\n <ng-container *ngIf=\"form.get('dictType').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 </div>\r\n </div>\r\n <div nz-row>\r\n <div nz-col nzSpan=\"24\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"sortNum\">\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>\r\n\r\n <div nz-row>\r\n <div nz-col nzSpan=\"24\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzFor=\"remark\">\u5907\u6CE8</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\" nzHasFeedback>\r\n <input nz-input formControlName=\"remark\">\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=\"24\">\r\n <nz-form-item>\r\n <nz-form-label nzXs=\"24\" nzSm=\"7\" nzRequired nzFor=\"valid\">\u542F\u7528\u72B6\u6001</nz-form-label>\r\n <nz-form-control nzXs=\"24\" nzSm=\"12\" nzMd=\"10\">\r\n <nz-radio-group formControlName=\"valid\">\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('valid').dirty && form.get('valid').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\" [nzLoading]=\"dictService.http.loading\">\u4FDD\u5B58</button>\r\n </div>\r\n</form>\r\n" }] } ]; /** @nocollapse */ SystemDictEditComponent.ctorParameters = () => [ { type: NzModalRef }, { type: NzMessageService }, { type: FormBuilder }, { type: DictService }, { type: CacheService } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class SystemDictComponent { /** * @param {?} modal * @param {?} msgSrv * @param {?} dictService */ constructor(modal, msgSrv, dictService) { this.modal = modal; this.msgSrv = msgSrv; this.dictService = dictService; this.isVisible = false; this.isOkLoading = false; this.searchSchema = { properties: { vkey: { type: 'string', title: '编码' } } }; this.data = []; this.dataList = {}; } /** * @return {?} */ ngOnInit() { // console.log(this.nzTable); this.dictService.getList(this.sf.value).subscribe((/** * @param {?} res * @return {?} */ (res) => { this.data = res; this.data.forEach((/** * @param {?} item * @return {?} */ item => { this.dataList[item.id] = item; })); })); } /** * @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(SystemDictEditComponent, { 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(SystemDictEditComponent, { record: item }) .subscribe((/** * @param {?} res * @return {?} */ (res) => { if (res.length > 1) { this.dictService.getList().subscribe((/** * @param {?} result * @return {?} */ (result) => { this.data = result; this.data.forEach((/** * @param {?} it * @return {?} */ it => { this.dataList[it.id] = it; })); })); } else { item = Object.assign(item, res[0]); this.dataList[res.id] = res[0]; } })); } /** * @param {?} data * @param {?} $event * @return {?} */ collapse(data, $event) { if (!$event || data.children.length > 0) { return; } this.dictService.getChildren(data.id).subscribe((/** * @param {?} res * @return {?} */ res => { data.children = res; data.children.forEach((/** * @param {?} item * @return {?} */ item => { this.dataList[item.id] = item; })); })); } /** * @return {?} */ deleteModal() { this.isVisible = true; } /** * @param {?} item * @return {?} */ deleteOk(item) { this.isOkLoading = true; this.dictService.deleteById(item.id).subscribe((/** * @param {?} res * @return {?} */ res => { this.isVisible = false; this.isOkLoading = false; 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)); })); } /** * @return {?} */ deleteCancel() { this.isVisible = false; } } SystemDictComponent.decorators = [ { type: Component, args: [{ selector: 'app-system-dict', template: "<page-header [action]=\"phPhAction\">\r\n <ng-template #phPhAction>\r\n <nz-dropdown>\r\n <button acl [acl-ability]=\"'dict:add'\" nz-button nz-dropdown nzType=\"primary\">\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($event)\"></sf>\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]=\"dictService.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>\u7F16\u7801</th>\r\n <th>\u5206\u7C7B</th>\r\n <th>\u5907\u6CE8</th>\r\n <th>\u6392\u5E8F</th>\r\n <!--<th>\u7248\u672C</th>-->\r\n <th>\u54