@ecip/system
Version:
755 lines (749 loc) • 73.1 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@ecip/shared'), require('@angular/router'), require('rxjs'), require('@angular/forms'), require('rxjs/index'), require('@delon/cache'), require('@ecip/service'), require('@angular/core'), require('ng-zorro-antd'), require('@delon/theme')) :
typeof define === 'function' && define.amd ? define('@ecip/system', ['exports', '@ecip/shared', '@angular/router', 'rxjs', '@angular/forms', 'rxjs/index', '@delon/cache', '@ecip/service', '@angular/core', 'ng-zorro-antd', '@delon/theme'], factory) :
(factory((global.ecip = global.ecip || {}, global.ecip.system = {}),global['1']['0']['0-rc']['5'],global.ng.router,global.rxjs,global.ng.forms,global.rxjs.index,global.cache,global['1']['0']['0-rc']['5'],global.ng.core,global.ngZorroAntd,global.theme));
}(this, (function (exports,shared,router,rxjs,forms,index,cache,service,core,ngZorroAntd,theme) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SystemResourceEditComponent = /** @class */ (function () {
function SystemResourceEditComponent(modal, msgSrv, resourceService, userService, appsService, http, fb, cacheService) {
var _this = this;
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 {?}
*/function (control) {
return rxjs.Observable.create(( /**
* @param {?} observer
* @return {?}
*/function (observer) {
if (!control.value) {
observer.next(null);
observer.complete();
return;
}
_this.resourceService.checkCode({ code: control.value, id: _this.record.id }).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
if (res.valid === true) {
observer.next(null);
}
else {
observer.next({ error: true, duplicated: true });
}
observer.complete();
}));
}));
});
}
/**
* @return {?}
*/
SystemResourceEditComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.loading = true;
/*this.appsService.getList().subscribe(appList => {
this.optionList = appList;
});*/
this.typeSrcList.subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
if (res) {
_this.typeSrc = res[0];
}
}));
this.urlTargetList.subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
if (res) {
_this.urlTarget = res[0];
}
}));
this.typeNodeList.subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
if (res) {
_this.typeNode = res[0];
}
}));
/** @type {?} */
var flagBreadcrumb;
/** @type {?} */
var flagMenuGroup;
/** @type {?} */
var nodeLevel;
/** @type {?} */
var pid = null;
/** @type {?} */
var 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 {?} */
var 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, [forms.Validators.required], [this.codeAsyncValidator]],
rsrcName: [null, [forms.Validators.required]],
deptId: [null, []],
pid: [pid, []],
path: [path, []],
typeSrc: [this.typeSrc ? this.typeSrc.value : '', [forms.Validators.required]],
typeNode: [this.typeNode ? this.typeNode.value : '', [forms.Validators.required]],
url: [null, []],
urlTarget: [this.urlTarget ? this.urlTarget.value : '', []],
rsrcIcon: [null, []],
rsrcStatus: [1, [forms.Validators.required]],
flagBreadcrumb: [flagBreadcrumb, [forms.Validators.required]],
flagMenuGroup: [flagMenuGroup, [forms.Validators.required]],
sortNm: [0, [forms.Validators.required]],
permission: [null, []],
beginTime: [null, []],
endTime: [null, []],
nodeLevel: [nodeLevel, []],
defaultpermission: [false, [forms.Validators.required]],
});
if (!this.record.id) {
return;
}
this.resourceService.getById(this.record.id).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
_this.form.patchValue(res);
// this.form.patchValue({code: res.code});
_this.i = res;
}));
};
/**
* @param {?} c1
* @param {?} c2
* @return {?}
*/
SystemResourceEditComponent.prototype.compareNumStr = /**
* @param {?} c1
* @param {?} c2
* @return {?}
*/
function (c1, c2) {
return c1 == c2;
};
/**
* @return {?}
*/
SystemResourceEditComponent.prototype.submit = /**
* @return {?}
*/
function () {
var _this = this;
for (var 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 {?}
*/function (res) {
_this.msgSrv.success('保存成功');
if (_this.form.value.defaultpermission) {
_this.resourceService.addDefaultPermission(res).subscribe(( /**
* @param {?} data
* @return {?}
*/function (data) {
res.children = [];
data.forEach(( /**
* @param {?} it
* @return {?}
*/function (it) {
res.children.push(it);
}));
}));
}
_this.modal.close(res);
}));
return;
}
//修改
this.resourceService.put(this.record.id, this.form.value).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
_this.msgSrv.success('保存成功');
// 是否新增默认权限
if (_this.form.value.defaultpermission) {
// 新增默认权限
_this.resourceService.addDefaultPermission(res).subscribe(( /**
* @return {?}
*/function () { }));
}
_this.modal.close({ result: res, addFlag: _this.form.value.defaultpermission });
}));
};
/**
* @return {?}
*/
SystemResourceEditComponent.prototype.close = /**
* @return {?}
*/
function () {
this.modal.destroy();
};
SystemResourceEditComponent.decorators = [
{ type: core.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 = function () {
return [
{ type: ngZorroAntd.NzModalRef },
{ type: ngZorroAntd.NzMessageService },
{ type: service.ResourceService },
{ type: service.UserService },
{ type: service.AppsService },
{ type: theme._HttpClient },
{ type: forms.FormBuilder },
{ type: cache.CacheService }
];
};
return SystemResourceEditComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SystemResourceComponent = /** @class */ (function () {
function SystemResourceComponent(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 {?}
*/
SystemResourceComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
/*this.data.forEach(item => {
this.expandDataCache[ item.key ] = this.convertTreeToList(item);
});
console.log(this.expandDataCache)*/
var _this = this;
this.appsService.getList().subscribe(( /**
* @param {?} appList
* @return {?}
*/function (appList) {
_this.appList = appList;
}));
this.appChange();
};
/**
* @return {?}
*/
SystemResourceComponent.prototype.appChange = /**
* @return {?}
*/
function () {
var _this = this;
this.resourceService.getList({ appId: this.appId }).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
_this.data = res;
_this.data.forEach(( /**
* @param {?} item
* @return {?}
*/function (item) {
_this.dataList[item.id] = item;
}));
}));
};
/**
* @param {?} parentId
* @return {?}
*/
SystemResourceComponent.prototype.addChild = /**
* @param {?} parentId
* @return {?}
*/
function (parentId) {
this.selectId = parentId;
this.add(false);
};
/**
* @param {?} isRoot
* @return {?}
*/
SystemResourceComponent.prototype.add = /**
* @param {?} isRoot
* @return {?}
*/
function (isRoot) {
var _this = this;
/** @type {?} */
var 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 {?}
*/function (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 {?}
*/
SystemResourceComponent.prototype.addpermission = /**
* @param {?} item
* @return {?}
*/
function (item) {
this.resourceService.addDefaultPermission(item).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
if (!item.children) {
item.children = [];
}
res.forEach(( /**
* @param {?} it
* @return {?}
*/function (it) {
item.children.push(it);
}));
}));
};
/**
* @param {?} item
* @return {?}
*/
SystemResourceComponent.prototype.edit = /**
* @param {?} item
* @return {?}
*/
function (item) {
var _this = this;
this.modal
.createStatic(SystemResourceEditComponent, { record: item })
.subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
item = Object.assign(item, res.result);
if (res.addFlag) {
_this.resourceService.getChildren(res.result.id).subscribe(( /**
* @param {?} data
* @return {?}
*/function (data) {
item.children = [];
data.forEach(( /**
* @param {?} it
* @return {?}
*/function (it) {
item.children.push(it);
}));
}));
}
_this.dataList[res.result.id] = item;
}));
};
/**
* @param {?} item
* @return {?}
*/
SystemResourceComponent.prototype.delete = /**
* @param {?} item
* @return {?}
*/
function (item) {
var _this = this;
this.resourceService.deleteById(item.id).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
_this.msgSrv.success('删除成功');
//根节点
if (!item.pid) {
_this.data = _this.data.filter(( /**
* @param {?} _item
* @return {?}
*/function (_item) { return _item.id !== item.id; }));
_this.dataList[item.id] = null;
return;
}
//子节点
_this.dataList[item.pid].children =
_this.dataList[item.pid].children.filter(( /**
* @param {?} _item
* @return {?}
*/function (_item) { return _item.id !== item.id; }));
}));
};
/**
* @param {?} data
* @param {?} $event
* @return {?}
*/
SystemResourceComponent.prototype.collapse = /**
* @param {?} data
* @param {?} $event
* @return {?}
*/
function (data, $event) {
var _this = this;
if (!$event || data.children.length > 0) {
return;
}
this.resourceService.getChildren(data.id).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
data.children = res;
data.children.forEach(( /**
* @param {?} item
* @return {?}
*/function (item) {
_this.dataList[item.id] = item;
}));
}));
};
SystemResourceComponent.decorators = [
{ type: core.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)\"> <!–<ng-template #expand let-item let-index=\"index\" let-column=\"column\"> {{ item.description }} </ng-template>–> <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 = function () {
return [
{ type: service.ResourceService },
{ type: service.AppsService },
{ type: theme.ModalHelper },
{ type: ngZorroAntd.NzMessageService },
{ type: cache.CacheService }
];
};
SystemResourceComponent.propDecorators = {
nzTable: [{ type: core.ViewChild, args: ['nzTable',] }]
};
return SystemResourceComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SystemDictEditComponent = /** @class */ (function () {
function SystemDictEditComponent(modal, msgSrv, fb, dictService, cacheService) {
var _this = this;
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 {?}
*/function (control) {
return index.Observable.create(( /**
* @param {?} observer
* @return {?}
*/function (observer) {
if (!control.value) {
observer.next(null);
observer.complete();
return;
}
/** @type {?} */
var parentId = _this.parent ? _this.parent.id : null;
_this.dictService.checkVkey({ id: _this.record.id, pid: parentId, vkey: control.value }).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
if (res.valid === true) {
observer.next(null);
}
else {
observer.next({ error: true, duplicated: true });
}
observer.complete();
}));
}));
});
this.typeAsyncValidator = ( /**
* @param {?} control
* @return {?}
*/function (control) {
return index.Observable.create(( /**
* @param {?} observer
* @return {?}
*/function (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 {?}
*/function (res) {
if (res.valid === true) {
observer.next(null);
}
else {
observer.next({ error: true, duplicated: true });
}
observer.complete();
}));
}
else {
observer.next(null);
observer.complete();
}
}));
});
}
/**
* @return {?}
*/
SystemDictEditComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var pid = null;
/** @type {?} */
var 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, [forms.Validators.required], [this.typeAsyncValidator]],
//SystemDictEditComponent.typeAsyncValidator(this.dictService, this.record)
vkey: ['', [], [this.codeAsyncValidator]],
//SystemDictEditComponent.codeAsyncValidator(this.dictService, this.record, this.parent)
vname: [null, [forms.Validators.required]],
remark: [null, []],
sortNum: [0, [forms.Validators.required]],
rsvn: [null, []],
valid: [1, [forms.Validators.required]],
createTime: [null, []],
updateTime: [null, []],
creator: [null, []],
operator: [null, []],
});
if (!this.record.id) {
return;
}
if (this.isRoot) {
/** @type {?} */
var vkeyCtl = this.form.get("vkey");
vkeyCtl.clearAsyncValidators();
vkeyCtl.updateValueAndValidity();
}
this.dictService.getById(this.record.id).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
_this.isRoot = !res.pid;
_this.form.patchValue(res);
_this.i = res;
}));
};
/**
* @param {?} c1
* @param {?} c2
* @return {?}
*/
SystemDictEditComponent.prototype.compareNumStr = /**
* @param {?} c1
* @param {?} c2
* @return {?}
*/
function (c1, c2) {
return c1 == c2;
};
/**
* @return {?}
*/
SystemDictEditComponent.prototype.submit = /**
* @return {?}
*/
function () {
var _this = this;
for (var 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 {?}
*/function (res) {
_this.msgSrv.success('保存成功');
_this.modal.close(res);
}));
return;
}
//修改
this.dictService.put(this.record.id, this.form.value).subscribe(( /**
* @param {?} res
* @return {?}
*/function (res) {
_this.msgSrv.success('保存成功');
_this.modal.close(res);
}));
};
/**
* @return {?}
*/
SystemDictEditComponent.prototype.close = /**
* @return {?}
*/
function () {
this.modal.destroy();
};
SystemDictEditComponent.decorators = [
{ type: core.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