yoyo-ng-modulewindy
Version:
服务于52ABP模板的前端开源的相关组件内容。整合了ng-alain和你NG ZORRO的内容
9,686 lines • 403 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common/http'), require('@angular/common'), require('yoyo-ng-module/util'), require('yoyo-ng-module/theme'), require('yoyo-ng-module/abc'), require('@angular/router'), require('ng-zorro-antd'), require('file-saver'), require('@angular/cdk/observers'), require('yoyo-ng-module/abp/localization/localization.service'), require('date-fns/format'), require('date-fns/add_seconds'), require('ngx-countdown'), require('rxjs/operators'), require('@angular/forms'), require('yoyo-ng-module/abp/auth/permission-checker.service'), require('@abp/localization/localization.service'), require('tslib'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/platform-browser'), require('date-fns/distance_in_words_to_now'), require('extend'), require('date-fns/parse'), require('date-fns/start_of_week'), require('date-fns/end_of_week'), require('date-fns/sub_weeks'), require('date-fns/start_of_month'), require('date-fns/end_of_month'), require('date-fns/sub_months'), require('date-fns/start_of_year'), require('date-fns/end_of_year'), require('date-fns/sub_years'), require('date-fns/add_days')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs', '@angular/common/http', '@angular/common', 'yoyo-ng-module/util', 'yoyo-ng-module/theme', 'yoyo-ng-module/abc', '@angular/router', 'ng-zorro-antd', 'file-saver', '@angular/cdk/observers', 'yoyo-ng-module/abp/localization/localization.service', 'date-fns/format', 'date-fns/add_seconds', 'ngx-countdown', 'rxjs/operators', '@angular/forms', 'yoyo-ng-module/abp/auth/permission-checker.service', '@abp/localization/localization.service', 'tslib', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/platform-browser', 'date-fns/distance_in_words_to_now', 'extend', 'date-fns/parse', 'date-fns/start_of_week', 'date-fns/end_of_week', 'date-fns/sub_weeks', 'date-fns/start_of_month', 'date-fns/end_of_month', 'date-fns/sub_months', 'date-fns/start_of_year', 'date-fns/end_of_year', 'date-fns/sub_years', 'date-fns/add_days'], factory) :
(factory((global.ng = global.ng || {}, global.ng.yoyoModule = {}),global.ng.core,global.Rx,global.ng.common.http,global.ng.common,null,null,null,global.ng.router,global.ngZorro.antd,global.saveAs,null,null,global['date-fns/format/index'],global['date-fns/add_seconds/index'],global.ngxCountDown,global.Rx.Observable.prototype,global.ng.forms,null,null,null,null,null,global.ng.platformBrowser,global['date-fns/distance_in_words_to_now/index'],global.extend,global['date-fns/parse/index'],global['date-fns/start_of_week/index'],global['date-fns/end_of_week/index'],global['date-fns/sub_weeks/index'],global['date-fns/start_of_month/index'],global['date-fns/end_of_month/index'],global['date-fns/sub_months/index'],global['date-fns/start_of_year/index'],global['date-fns/end_of_year/index'],global['date-fns/sub_years/index'],global['date-fns/add_days/index']));
}(this, (function (exports,i0,rxjs,i1,i3,util,theme,abc,router,i1$1,fileSaver,observers,localization_service,format_,addSeconds,ngxCountdown,operators,forms,permissionChecker_service,localization_service$1,tslib_1,overlay,portal,i1$2,distanceInWordsToNow_,deepExtend_,parse_,startOfWeek_,endOfWeek_,subWeeks_,startOfMonth_,endOfMonth_,subMonths_,startOfYear_,endOfYear_,subYears_,addDays_) { 'use strict';
var format___default = format_['default'];
addSeconds = addSeconds && addSeconds.hasOwnProperty('default') ? addSeconds['default'] : addSeconds;
var AbpSessionService = /** @class */ (function () {
function AbpSessionService() {
}
Object.defineProperty(AbpSessionService.prototype, "userId", {
get: function () {
return abp.session.userId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AbpSessionService.prototype, "tenantId", {
get: function () {
return abp.session.tenantId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AbpSessionService.prototype, "impersonatorUserId", {
get: function () {
return abp.session.impersonatorUserId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AbpSessionService.prototype, "impersonatorTenantId", {
get: function () {
return abp.session.impersonatorTenantId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AbpSessionService.prototype, "multiTenancySide", {
get: function () {
return abp.session.multiTenancySide;
},
enumerable: true,
configurable: true
});
AbpSessionService.decorators = [
{ type: i0.Injectable },
];
return AbpSessionService;
}());
var PermissionCheckerService = /** @class */ (function () {
function PermissionCheckerService() {
}
PermissionCheckerService.prototype.isGranted = function (permissionName) {
return abp.auth.isGranted(permissionName);
};
PermissionCheckerService.decorators = [
{ type: i0.Injectable },
];
return PermissionCheckerService;
}());
var FeatureCheckerService = /** @class */ (function () {
function FeatureCheckerService() {
}
FeatureCheckerService.prototype.get = function (featureName) {
return abp.features.get(featureName);
};
FeatureCheckerService.prototype.getValue = function (featureName) {
return abp.features.getValue(featureName);
};
FeatureCheckerService.prototype.isEnabled = function (featureName) {
return abp.features.isEnabled(featureName);
};
FeatureCheckerService.decorators = [
{ type: i0.Injectable },
];
return FeatureCheckerService;
}());
var LocalizationService = /** @class */ (function () {
function LocalizationService() {
}
Object.defineProperty(LocalizationService.prototype, "languages", {
get: function () {
return abp.localization.languages;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LocalizationService.prototype, "currentLanguage", {
get: function () {
return abp.localization.currentLanguage;
},
enumerable: true,
configurable: true
});
LocalizationService.prototype.localize = function (key, sourceName) {
return abp.localization.localize(key, sourceName);
};
LocalizationService.prototype.getSource = function (sourceName) {
return abp.localization.getSource(sourceName);
};
LocalizationService.prototype.l = function (key) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var localizedText = this.localize(key, LocalizationService.localizationSourceName);
if (!localizedText) {
localizedText = key;
}
if (!args || !args.length) {
return localizedText;
}
args.unshift(localizedText);
return abp.utils.formatString.apply(this, args);
};
/**
* 默认的语言Source名称
*/
LocalizationService.localizationSourceName = '';
LocalizationService.decorators = [
{ type: i0.Injectable },
];
return LocalizationService;
}());
var SettingService = /** @class */ (function () {
function SettingService() {
}
SettingService.prototype.get = function (name) {
return abp.setting.get(name);
};
SettingService.prototype.getBoolean = function (name) {
return abp.setting.getBoolean(name);
};
SettingService.prototype.getInt = function (name) {
return abp.setting.getInt(name);
};
SettingService.decorators = [
{ type: i0.Injectable },
];
return SettingService;
}());
var NotifyService = /** @class */ (function () {
function NotifyService() {
}
NotifyService.prototype.info = function (message, title, options) {
abp.notify.info(message, title, options);
};
NotifyService.prototype.success = function (message, title, options) {
abp.notify.success(message, title, options);
};
NotifyService.prototype.warn = function (message, title, options) {
abp.notify.warn(message, title, options);
};
NotifyService.prototype.error = function (message, title, options) {
abp.notify.error(message, title, options);
};
NotifyService.decorators = [
{ type: i0.Injectable },
];
return NotifyService;
}());
var MessageService = /** @class */ (function () {
function MessageService() {
}
MessageService.prototype.info = function (message, title, isHtml) {
return abp.message.info(message, title, isHtml);
};
MessageService.prototype.success = function (message, title, isHtml) {
return abp.message.success(message, title, isHtml);
};
MessageService.prototype.warn = function (message, title, isHtml) {
return abp.message.warn(message, title, isHtml);
};
MessageService.prototype.error = function (message, title, isHtml) {
return abp.message.error(message, title, isHtml);
};
MessageService.prototype.confirm = function (message, titleOrCallBack, callback, isHtml) {
if (typeof titleOrCallBack == 'string') {
return abp.message.confirm(message, titleOrCallBack, callback, isHtml);
}
else {
return abp.message.confirm(message, undefined, titleOrCallBack, isHtml);
}
};
MessageService.decorators = [
{ type: i0.Injectable },
];
return MessageService;
}());
var LogService = /** @class */ (function () {
function LogService() {
}
LogService.prototype.debug = function (logObject) {
abp.log.debug(logObject);
};
LogService.prototype.info = function (logObject) {
abp.log.info(logObject);
};
LogService.prototype.warn = function (logObject) {
abp.log.warn(logObject);
};
LogService.prototype.error = function (logObject) {
abp.log.error(logObject);
};
LogService.prototype.fatal = function (logObject) {
abp.log.fatal(logObject);
};
LogService.decorators = [
{ type: i0.Injectable },
];
return LogService;
}());
var AbpMultiTenancyService = /** @class */ (function () {
function AbpMultiTenancyService() {
}
Object.defineProperty(AbpMultiTenancyService.prototype, "isEnabled", {
get: function () {
return abp.multiTenancy.isEnabled;
},
enumerable: true,
configurable: true
});
AbpMultiTenancyService.decorators = [
{ type: i0.Injectable },
];
return AbpMultiTenancyService;
}());
var TokenService = /** @class */ (function () {
function TokenService() {
}
TokenService.prototype.getToken = function () {
return abp.auth.getToken();
};
TokenService.prototype.getTokenCookieName = function () {
return abp.auth.tokenCookieName;
};
TokenService.prototype.clearToken = function () {
abp.auth.clearToken();
};
TokenService.prototype.setToken = function (authToken, expireDate) {
abp.auth.setToken(authToken, expireDate);
};
TokenService.decorators = [
{ type: i0.Injectable },
];
return TokenService;
}());
var UtilsService = /** @class */ (function () {
function UtilsService() {
}
UtilsService.prototype.getCookieValue = function (key) {
return abp.utils.getCookieValue(key);
};
UtilsService.prototype.setCookieValue = function (key, value, expireDate, path) {
abp.utils.setCookieValue(key, value, expireDate, path);
};
UtilsService.prototype.deleteCookie = function (key, path) {
abp.utils.deleteCookie(key, path);
};
UtilsService.decorators = [
{ type: i0.Injectable },
];
return UtilsService;
}());
var AbpHttpConfiguration = /** @class */ (function () {
function AbpHttpConfiguration(_messageService, _logService) {
this._messageService = _messageService;
this._logService = _logService;
this.defaultError = {
message: 'An error has occurred!',
details: 'Error details were not sent by server.'
};
this.defaultError401 = {
message: 'You are not authenticated!',
details: 'You should be authenticated (sign in) in order to perform this operation.'
};
this.defaultError403 = {
message: 'You are not authorized!',
details: 'You are not allowed to perform this operation.'
};
this.defaultError404 = {
message: 'Resource not found!',
details: 'The resource requested could not be found on the server.'
};
}
AbpHttpConfiguration.prototype.logError = function (error) {
this._logService.error(error);
};
AbpHttpConfiguration.prototype.showError = function (error) {
if (error.details) {
return this._messageService.error(error.details, error.message || this.defaultError.message);
}
else {
return this._messageService.error(error.message || this.defaultError.message);
}
};
AbpHttpConfiguration.prototype.handleTargetUrl = function (targetUrl) {
if (!targetUrl) {
location.href = '/';
}
else {
location.href = targetUrl;
}
};
AbpHttpConfiguration.prototype.handleUnAuthorizedRequest = function (messagePromise, targetUrl) {
var _this = this;
var self = this;
if (messagePromise) {
messagePromise.done(function () {
_this.handleTargetUrl(targetUrl || '/');
});
}
else {
self.handleTargetUrl(targetUrl || '/');
}
};
AbpHttpConfiguration.prototype.handleNonAbpErrorResponse = function (response) {
var self = this;
switch (response.status) {
case 401:
self.handleUnAuthorizedRequest(self.showError(self.defaultError401), '/');
break;
case 403:
self.showError(self.defaultError403);
break;
case 404:
self.showError(self.defaultError404);
break;
default:
self.showError(self.defaultError);
break;
}
};
AbpHttpConfiguration.prototype.handleAbpResponse = function (response, ajaxResponse) {
var newResponse;
if (ajaxResponse.success) {
newResponse = response.clone({
body: ajaxResponse.result
});
if (ajaxResponse.targetUrl) {
this.handleTargetUrl(ajaxResponse.targetUrl);
}
}
else {
newResponse = response.clone({
body: ajaxResponse.result
});
if (!ajaxResponse.error) {
ajaxResponse.error = this.defaultError;
}
this.logError(ajaxResponse.error);
this.showError(ajaxResponse.error);
if (response.status === 401) {
this.handleUnAuthorizedRequest(null, ajaxResponse.targetUrl);
}
}
return newResponse;
};
AbpHttpConfiguration.prototype.getAbpAjaxResponseOrNull = function (response) {
if (!response || !response.headers) {
return null;
}
var contentType = response.headers.get('Content-Type');
if (!contentType) {
this._logService.warn('Content-Type is not sent!');
return null;
}
if (contentType.indexOf("application/json") < 0) {
this._logService.warn('Content-Type is not application/json: ' + contentType);
return null;
}
var responseObj = JSON.parse(JSON.stringify(response.body));
if (!responseObj.__abp) {
return null;
}
return responseObj;
};
AbpHttpConfiguration.prototype.handleResponse = function (response) {
var ajaxResponse = this.getAbpAjaxResponseOrNull(response);
if (ajaxResponse == null) {
return response;
}
return this.handleAbpResponse(response, ajaxResponse);
};
AbpHttpConfiguration.prototype.blobToText = function (blob) {
return new rxjs.Observable(function (observer) {
if (!blob) {
observer.next("");
observer.complete();
}
else {
var reader = new FileReader();
reader.onload = function () {
observer.next(this.result);
observer.complete();
};
reader.readAsText(blob);
}
});
};
AbpHttpConfiguration.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
AbpHttpConfiguration.ctorParameters = function () { return [
{ type: MessageService },
{ type: LogService }
]; };
return AbpHttpConfiguration;
}());
var AbpUserConfigurationService = /** @class */ (function () {
function AbpUserConfigurationService(_http) {
this._http = _http;
}
AbpUserConfigurationService.prototype.initialize = function () {
this._http.get('/AbpUserConfiguration/GetAll')
.subscribe(function (result) {
jQuery.extend(true, abp, JSON.parse(JSON.stringify(result)));
});
};
AbpUserConfigurationService.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
AbpUserConfigurationService.ctorParameters = function () { return [
{ type: i1.HttpClient }
]; };
return AbpUserConfigurationService;
}());
var AbpModule = /** @class */ (function () {
function AbpModule() {
}
AbpModule.decorators = [
{ type: i0.NgModule, args: [{
declarations: [],
providers: [
AbpSessionService,
PermissionCheckerService,
FeatureCheckerService,
LocalizationService,
SettingService,
NotifyService,
MessageService,
LogService,
AbpMultiTenancyService,
AbpUserConfigurationService,
AbpHttpConfiguration,
TokenService,
UtilsService
]
},] },
];
return AbpModule;
}());
var AdErrorCollectConfig = /** @class */ (function () {
function AdErrorCollectConfig() {
/**
* 监听频率
*/
this.freq = 500;
/**
* 顶部偏移值
*/
this.offsetTop = 65 + 64 + 8 * 2;
}
AdErrorCollectConfig.decorators = [
{ type: i0.Injectable },
];
return AdErrorCollectConfig;
}());
/**
* 错误消息采集器
* PS:虽然此法并不好看,但对响应式表单&模板表单有很好的效果。
*/
var ErrorCollectComponent = /** @class */ (function () {
function ErrorCollectComponent(cog, el, renderer, cd, doc) {
this.el = el;
this.renderer = renderer;
this.cd = cd;
this.doc = doc;
this.$time = null;
this._freq = 500;
this._offsetTop = 65 + 64 + 8 * 2;
this._hiden = true;
this.count = 0;
Object.assign(this, cog);
}
Object.defineProperty(ErrorCollectComponent.prototype, "freq", {
get: function () {
return this._freq;
},
set: function (value) {
this._freq = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorCollectComponent.prototype, "offsetTop", {
get: function () {
return this._offsetTop;
},
set: function (value) {
this._offsetTop = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorCollectComponent.prototype, "errEls", {
get: function () {
return this.formEl.querySelectorAll('.has-error');
},
enumerable: true,
configurable: true
});
ErrorCollectComponent.prototype.update = function () {
var count = this.errEls.length;
if (count === this.count)
return;
this.count = count;
this._hiden = count === 0;
this.cd.markForCheck();
};
ErrorCollectComponent.prototype._click = function () {
if (this.count === 0)
return false;
// nz-form-control
var els = this.errEls;
var formItemEl = this.findParent(els[0], '[nz-form-control]') || els[0];
formItemEl.scrollIntoView(true);
// fix header height
this.doc.documentElement.scrollTop -= this.offsetTop;
};
ErrorCollectComponent.prototype.install = function () {
var _this = this;
this.uninstall();
this.$time = setInterval(function () { return _this.update(); }, this.freq);
this.update();
};
ErrorCollectComponent.prototype.uninstall = function () {
clearInterval(this.$time);
};
ErrorCollectComponent.prototype.findParent = function (el, selector) {
var retEl = null;
while (el) {
if (el.querySelector(selector)) {
retEl = el;
break;
}
el = el.parentElement;
}
return retEl;
};
ErrorCollectComponent.prototype.ngOnInit = function () {
this.formEl = this.findParent(this.el.nativeElement, 'form');
if (this.formEl === null)
throw new Error('未找到有效 form 元素');
this.el.nativeElement.classList.add('error-collect', 'pr-lg', 'text-error', 'point');
this.install();
};
ErrorCollectComponent.prototype.ngOnDestroy = function () {
this.uninstall();
};
ErrorCollectComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'error-collect, [error-collect]',
template: "\n <i class=\"anticon anticon-exclamation-circle\"></i>\n <span class=\"pl-sm\">{{count}}</span>",
changeDetection: i0.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
ErrorCollectComponent.ctorParameters = function () { return [
{ type: AdErrorCollectConfig },
{ type: i0.ElementRef },
{ type: i0.Renderer2 },
{ type: i0.ChangeDetectorRef },
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.DOCUMENT,] }] }
]; };
ErrorCollectComponent.propDecorators = {
freq: [{ type: i0.Input }],
offsetTop: [{ type: i0.Input }],
_hiden: [{ type: i0.HostBinding, args: ['class.d-none',] }],
_click: [{ type: i0.HostListener, args: ['click',] }]
};
return ErrorCollectComponent;
}());
var COMPONENTS = [ErrorCollectComponent];
var AdErrorCollectModule = /** @class */ (function () {
function AdErrorCollectModule() {
}
AdErrorCollectModule.forRoot = function () {
return {
ngModule: AdErrorCollectModule,
providers: [AdErrorCollectConfig],
};
};
AdErrorCollectModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS.slice(),
exports: COMPONENTS.slice(),
},] },
];
return AdErrorCollectModule;
}());
var CLS = 'ad-footer-toolbar';
var FooterToolbarComponent = /** @class */ (function () {
function FooterToolbarComponent(el, renderer, doc) {
this.el = el;
this.renderer = renderer;
this.doc = doc;
this._errorCollect = false;
}
Object.defineProperty(FooterToolbarComponent.prototype, "errorCollect", {
get: function () {
return this._errorCollect;
},
set: function (value) {
this._errorCollect = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
FooterToolbarComponent.prototype.ngOnInit = function () {
this.el.nativeElement.classList.add(CLS);
this.renderer.addClass(this.el.nativeElement, CLS);
this.doc.querySelector('body').classList.add("has-" + CLS);
};
FooterToolbarComponent.prototype.ngOnDestroy = function () {
this.doc.querySelector('body').classList.remove("has-" + CLS);
};
FooterToolbarComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'footer-toolbar',
template: "\n <div class=\"left\"><ng-container *ngIf=\"extra\" [ngTemplateOutlet]=\"extra\"></ng-container></div>\n <div class=\"right\">\n <error-collect *ngIf=\"errorCollect\"></error-collect>\n <ng-content></ng-content>\n </div>\n ",
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
FooterToolbarComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.Renderer2 },
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.DOCUMENT,] }] }
]; };
FooterToolbarComponent.propDecorators = {
errorCollect: [{ type: i0.Input }],
extra: [{ type: i0.ContentChild, args: ['extra',] }]
};
return FooterToolbarComponent;
}());
var COMPONENTS$1 = [FooterToolbarComponent];
var AdFooterToolbarModule = /** @class */ (function () {
function AdFooterToolbarModule() {
}
AdFooterToolbarModule.forRoot = function () {
return { ngModule: AdFooterToolbarModule, providers: [] };
};
AdFooterToolbarModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, AdErrorCollectModule],
declarations: COMPONENTS$1.slice(),
exports: COMPONENTS$1.slice(),
},] },
];
return AdFooterToolbarModule;
}());
var SidebarNavComponent = /** @class */ (function () {
// mapKeys = [];
// mapVals = [];
function SidebarNavComponent(menuService, settings, reuseTabService) {
this.menuService = menuService;
this.settings = settings;
this.reuseTabService = reuseTabService;
// menu 展示数组
this.openMap = [];
this.processMenuOpen(reuseTabService.curUrl, this.menuService.menus);
}
SidebarNavComponent.prototype.hasChildren = function (item) {
if (item.items) {
return true;
}
return false;
};
/**
* 处理菜单展开状态
*/
SidebarNavComponent.prototype.processMenuOpen = function (currentUrl, menus, parentMenu) {
var _this = this;
menus.forEach(function (item) {
if (parentMenu && item.route === currentUrl) {
parentMenu.isOpen = true;
}
if (item.items && item.items.length > 0) {
_this.processMenuOpen(currentUrl, item.items, item);
}
});
};
SidebarNavComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'sidebar-nav',
template: "\n <ul nz-menu [nzMode]=\"'inline'\" [nzInlineCollapsed]=\"settings.layout.collapsed\" id=\"left_menu_ul\">\n <ng-template ngFor let-menuItem [ngForOf]=\"menuService.menus\" let-mainMenuItemIndex=\"index\">\n <li *ngIf=\"!hasChildren(menuItem)&&menuItem.isDisplay\" nz-menu-item routerLinkActive=\"ant-menu-item-selected\">\n <a [routerLink]=\"[menuItem.route]\">\n <i *ngIf=\"menuItem.icon\" class=\"{{menuItem.icon}}\"></i>\n <span>{{menuItem.name}}</span>\n </a>\n </li>\n\n <li *ngIf=\"hasChildren(menuItem)&&menuItem.isDisplay\" nz-submenu [nzOpen]=\"menuItem.isOpen\">\n <span title>\n <i *ngIf=\"menuItem.icon\" class=\"{{menuItem.icon}}\"></i>\n <span>{{menuItem.name}}</span>\n </span>\n <ul>\n <ng-template ngFor let-subMenuItem [ngForOf]=\"menuItem.items\" let-mainMenuItemIndex=\"index\">\n <li *ngIf=\"!hasChildren(subMenuItem)&&subMenuItem.isDisplay\" nz-menu-item routerLinkActive=\"ant-menu-item-selected\">\n <a [routerLink]=\"[subMenuItem.route]\">\n <i *ngIf=\"subMenuItem.icon\" class=\"{{subMenuItem.icon}}\"></i>\n <span>{{subMenuItem.name}}</span>\n </a>\n </li>\n\n <li *ngIf=\"hasChildren(subMenuItem)&&subMenuItem.isDisplay\" nz-submenu>\n <span title>\n <i *ngIf=\"subMenuItem.icon\" class=\"{{subMenuItem.icon}}\"></i>\n <span>{{subMenuItem.name}}</span>\n </span>\n\n <ul>\n <ng-template ngFor let-subSubMenuItem [ngForOf]=\"subMenuItem.items\" let-mainMenuItemIndex=\"index\">\n <li *ngIf=\"!hasChildren(subSubMenuItem)&&subSubMenuItem.isDisplay\" nz-menu-item routerLinkActive=\"ant-menu-item-selected\">\n <a [routerLink]=\"[subSubMenuItem.route]\">\n <i *ngIf=\"subSubMenuItem.icon\" class=\"{{subSubMenuItem.icon}}\"></i>\n <span>{{subSubMenuItem.name}}</span>\n </a>\n </li>\n </ng-template>\n </ul>\n </li>\n </ng-template>\n </ul>\n </li>\n </ng-template>\n</ul>\n\n ",
// templateUrl: './sidebar-nav.component.html',
changeDetection: i0.ChangeDetectionStrategy.Default,
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
SidebarNavComponent.ctorParameters = function () { return [
{ type: theme.MenuService },
{ type: theme.SettingsService },
{ type: abc.ReuseTabService }
]; };
return SidebarNavComponent;
}());
var AdSidebarNavModule = /** @class */ (function () {
function AdSidebarNavModule() {
}
AdSidebarNavModule.forRoot = function () {
return { ngModule: AdSidebarNavModule, providers: [] };
};
AdSidebarNavModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, router.RouterModule, i1$1.NgZorroAntdModule],
declarations: [SidebarNavComponent],
exports: [SidebarNavComponent],
},] },
];
return AdSidebarNavModule;
}());
/**
* 文件下载
*
* ```html
* <button nz-button down-file http-url="assets/demo{{i}}" file-name="demo中文">{{i}}</button>
* ```
*/
var DownFileDirective = /** @class */ (function () {
function DownFileDirective(el, http, _http) {
this.el = el;
this.http = http;
this._http = _http;
/** 请求类型 */
this.httpMethod = 'get';
/** 成功回调 */
this.success = new i0.EventEmitter();
/** 错误回调 */
this.error = new i0.EventEmitter();
}
DownFileDirective.prototype.getDisposition = function (data) {
var arr = (data || '')
.split(';')
.filter(function (i) { return i.includes('='); })
.map(function (v) {
var strArr = v.split('=');
var utfId = "UTF-8''";
var value = strArr[1];
if (value.startsWith(utfId))
value = value.substr(utfId.length);
return _a = {}, _a[strArr[0].trim()] = value, _a;
var _a;
});
return arr.reduce(function (o, item) { return item; }, {});
};
DownFileDirective.prototype._click = function () {
var _this = this;
this.el.nativeElement.disabled = true;
(this._http || this.http).request(this.httpMethod, this.httpUrl, {
params: this.httpData || {},
responseType: 'blob',
observe: 'response',
})
.subscribe(function (res) {
if (res.status !== 200 || res.body.size <= 0) {
_this.error.emit(res);
return;
}
var disposition = _this.getDisposition(res.headers.get('content-disposition'));
var fileName = _this.fileName ||
disposition["filename*"] ||
disposition["filename"] ||
res.headers.get('filename') ||
res.headers.get('x-filename');
fileSaver.saveAs(res.body, decodeURI(fileName));
_this.success.emit(res);
_this.el.nativeElement.disabled = false;
}, function (err) {
_this.error.emit(err);
_this.el.nativeElement.disabled = false;
});
};
DownFileDirective.decorators = [
{ type: i0.Directive, args: [{ selector: '[down-file]' },] },
];
/** @nocollapse */
DownFileDirective.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i1.HttpClient },
{ type: theme._HttpClient, decorators: [{ type: i0.Optional }] }
]; };
DownFileDirective.propDecorators = {
httpData: [{ type: i0.Input, args: ['http-data',] }],
httpMethod: [{ type: i0.Input, args: ['http-method',] }],
httpUrl: [{ type: i0.Input, args: ['http-url',] }],
fileName: [{ type: i0.Input, args: ['file-name',] }],
success: [{ type: i0.Output }],
error: [{ type: i0.Output }],
_click: [{ type: i0.HostListener, args: ['click',] }]
};
return DownFileDirective;
}());
var DIRECTIVES = [DownFileDirective];
var AdDownFileModule = /** @class */ (function () {
function AdDownFileModule() {
}
AdDownFileModule.forRoot = function () {
return { ngModule: AdDownFileModule, providers: [] };
};
AdDownFileModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: DIRECTIVES.slice(),
exports: DIRECTIVES.slice(),
},] },
];
return AdDownFileModule;
}());
var AdImageConfig = /** @class */ (function () {
function AdImageConfig() {
/**
* 默认大小,默认值:`64`,单位:px
*/
this.size = 64;
/**
* 错误图片
*/
this.error = './assets/img/logo.svg';
}
AdImageConfig.decorators = [
{ type: i0.Injectable },
];
return AdImageConfig;
}());
/**
* img标签
* + 支持微信、qq头像规则缩略图规则
* + 支持移除http&https协议http
* + 支持增加onerror事件
*/
var ImageDirective = /** @class */ (function () {
function ImageDirective(el, render, DEF) {
this.el = el;
this.render = render;
this.size = 64;
this.error = './assets/img/logo.svg';
this.inited = false;
Object.assign(this, util.deepCopy(DEF));
}
ImageDirective.prototype.ngOnInit = function () {
this.update();
this.updateError();
this.inited = true;
};
ImageDirective.prototype.ngOnChanges = function (changes) {
if (this.inited) {
if (changes.error) {
this.updateError();
}
else {
this.update();
}
}
};
ImageDirective.prototype.update = function () {
var newSrc = this.src;
// region: fix weixin & qq avatar size
if (newSrc.includes('qlogo.cn')) {
var arr = newSrc.split('/'), size = arr[arr.length - 1];
arr[arr.length - 1] =
size === '0' || +size !== this.size ? this.size.toString() : size;
newSrc = arr.join('/');
}
// endregion
// region: remove https & http
var isHttp = newSrc.startsWith('http:'), isHttps = newSrc.startsWith('https:');
if (isHttp || isHttps)
newSrc = newSrc.substr(isHttp ? 5 : 6);
// endregion
this.render.setAttribute(this.el.nativeElement, 'src', newSrc);
};
ImageDirective.prototype.updateError = function () {
this.render.setAttribute(this.el.nativeElement, 'onerror', "this.src='" + this.error + "';");
};
ImageDirective.decorators = [
{ type: i0.Directive, args: [{ selector: '[_src]' },] },
];
/** @nocollapse */
ImageDirective.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.Renderer2 },
{ type: AdImageConfig }
]; };
ImageDirective.propDecorators = {
src: [{ type: i0.Input, args: ['_src',] }],
size: [{ type: i0.Input }],
error: [{ type: i0.Input }]
};
return ImageDirective;
}());
var DIRECTIVES$1 = [ImageDirective];
var AdImageModule = /** @class */ (function () {
function AdImageModule() {
}
AdImageModule.forRoot = function () {
return { ngModule: AdImageModule, providers: [AdImageConfig] };
};
AdImageModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, util.DelonUtilModule],
declarations: DIRECTIVES$1.slice(),
exports: DIRECTIVES$1.slice(),
},] },
];
return AdImageModule;
}());
var AvatarListItemComponent = /** @class */ (function () {
function AvatarListItemComponent() {
}
AvatarListItemComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'avatar-list-item, [avatar-list-item]',
template: "",
},] },
];
AvatarListItemComponent.propDecorators = {
src: [{ type: i0.Input }],
text: [{ type: i0.Input }],
icon: [{ type: i0.Input }],
tips: [{ type: i0.Input }]
};
return AvatarListItemComponent;
}());
var AvatarListComponent = /** @class */ (function () {
function AvatarListComponent() {
this._size = '';
this._avatarSize = '';
}
Object.defineProperty(AvatarListComponent.prototype, "size", {
set: function (value) {
this._size = value === 'default' ? '' : value;
switch (value) {
case 'large':
case 'small':
case 'default':
this._avatarSize = value;
break;
default:
this._avatarSize = 'small';
break;
}
},
enumerable: true,
configurable: true
});
AvatarListComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'avatar-list',
template: "\n <ul>\n <li *ngFor=\"let i of _items\" class=\"item\" [ngClass]=\"_size\">\n <nz-tooltip *ngIf=\"i.tips\" [nzTitle]=\"i.tips\">\n <nz-avatar nz-tooltip [nzSrc]=\"i.src\" [nzText]=\"i.text\" [nzIcon]=\"i.icon\" [nzSize]=\"_avatarSize\"></nz-avatar>\n </nz-tooltip>\n <nz-avatar *ngIf=\"!i.tips\" [nzSrc]=\"i.src\" [nzText]=\"i.text\" [nzIcon]=\"i.icon\" [nzSize]=\"_avatarSize\"></nz-avatar>\n </li>\n </ul>\n ",
host: { '[class.ad-avatar-list]': 'true' },
preserveWhitespaces: false,
},] },
];
AvatarListComponent.propDecorators = {
size: [{ type: i0.Input }],
_items: [{ type: i0.ContentChildren, args: [AvatarListItemComponent,] }]
};
return AvatarListComponent;
}());
var COMPONENTS$2 = [AvatarListComponent, AvatarListItemComponent];
var ZORROMODULES = [i1$1.NgZorroAntdModule];
// endregion
var AdAvatarListModule = /** @class */ (function () {
function AdAvatarListModule() {
}
AdAvatarListModule.forRoot = function () {
return { ngModule: AdAvatarListModule, providers: [] };
};
AdAvatarListModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule].concat(ZORROMODULES),
declarations: COMPONENTS$2.slice(),
exports: COMPONENTS$2.slice(),
},] },
];
return AdAvatarListModule;
}());
var DescListItemComponent = /** @class */ (function () {
function DescListItemComponent(renderer) {
this.renderer = renderer;
// region fields
this._term = '';
this._noDefault = false;
this.detailClass = '';
}
Object.defineProperty(DescListItemComponent.prototype, "term", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._term = null;
this._termTpl = value;
}
else
this._term = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DescListItemComponent.prototype, "noDefault", {
get: function () {
return this._noDefault;
},
set: function (value) {
this._noDefault = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
DescListItemComponent.prototype.checkContent = function () {
if (!this.contentElement) {
return;
}
var el = this.contentElement.nativeElement;
var cls = "ad-desc-list__default";
if (!this.noDefault && util.isEmpty(el)) {
this.renderer.addClass(el, cls);
}
else {
this.renderer.removeClass(el, cls);
}
};
DescListItemComponent.prototype.ngAfterViewInit = function () {
this.checkContent();
};
DescListItemComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'desc-list-item',
template: "\n <ng-template #tpl>\n <div class=\"ad-desc-list__term\" *ngIf=\"_term || _termTpl\">\n <ng-container *ngIf=\"_term; else _termTpl\">{{_term}}</ng-container>\n </div>\n <div class=\"ad-desc-list__detail {{detailClass}}\" (cdkObserveContent)=\"checkContent()\" #contentElement><ng-content></ng-content></div>\n </ng-template>\n ",
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
DescListItemComponent.ctorParameters = function () { return [
{ type: i0.Renderer2 }
]; };
DescListItemComponent.propDecorators = {
contentElement: [{ type: i0.ViewChild, args: ['contentElement',] }],
term: [{ type: i0.Input }],
noDefault: [{ type: i0.Input }],
detailClass: [{ type: i0.Input }],
tpl: [{ type: i0.ViewChild, args: ['tpl',] }]
};
return DescListItemComponent;
}());
var AdDescListConfig = /** @class */ (function () {
function AdDescListConfig() {
/**
* 布局方式
*/
this.layout = 'horizontal';
/**
* 列表项间距,单位为 `px`
*/
this.gutter = 32;
}
AdDescListConfig.decorators = [
{ type: i0.Injectable },
];
return AdDescListConfig;
}());
var DescListComponent = /** @class */ (function () {
// endregion
function DescListComponent(cog, el, renderer) {
this.el = el;
this.renderer = renderer;
// region fields
this._title = '';
this._gutter = 32;
this.layout = 'horizontal';
this._xs = 24;
this._sm = 12;
this._md = 8;
this._col = 3;
this._classMap = [];
Object.assign(this, cog);
}
Object.defineProperty(DescListComponent.prototype, "title", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._title = null;
this._titleTpl = value;
}
else
this._title = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DescListComponent.prototype, "gutter", {
/** 列表项间距,单位为 `px` */
get: function () {
return this._gutter;
},
set: function (value) {
this._gutter = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DescListComponent.prototype, "col", {
/** 指定信息最多分几列展示,最终一行几列由 col 配置结合响应式规则决定 */
get: function () {
return this._col;
},
set: function (value) {
this._col = util.toNumber(value);
},
enumerable: true,
configurable: true
});
DescListComponent.prototype.setClass = function () {
var _this = this;
this._classMap.forEach(function (cls) {
return _this.renderer.removeClass(_this.el.nativeElement, cls);
});
this._classMap = ['ad-desc-list', 'clearfix', this.layout];
if (this.size)
this._classMap.push(this.size);
this._classMap.forEach(function (cls) {
return _this.renderer.addClass(_this.el.nativeElement, cls);
});
};
DescListComponent.prototype.setResponsive = function () {
var responsive = {
1: { xs: 24 },
2: { xs: 24, sm: 12 },
3: { xs: 24, sm: 12, md: 8 },
4: { xs: 24, sm: 12, md: 6 },
}[this.col > 4 ? 4 : this.col];
this._xs = responsive.xs;
this._sm = responsive.sm;
this._md = responsive.md;
};
DescListComponent.prototype.ngOnInit = function () {
this.setClass();
};
DescListComponent.prototype.ngOnChanges = function (changes) {
this.setClass();
if (changes.col)
this.setResponsive();
};
DescListComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'desc-list',
template: "\n <div *ngIf=\"_title || _titleTpl\" class=\"ad-desc-list__title\">\n <ng-container *ngIf=\"_title; else _titleTpl\">{{_title}}</ng-container>\n </div>\n <div nz-row [nzGutter]=\"gutter\">\n <div nz-col [nzXs]=\"_xs\" [nzSm]=\"_sm\" [nzMd]=\"_md\" *ngFor=\"let i of _items\">\n <ng-template [ngTemplateOutlet]=\"i.tpl\"></ng-template>\n </div>\n </div>\n ",
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
DescListComponent.ctorParameters = function () { return [
{ type: AdDescListConfig },
{ type: i0.ElementRef },
{ type: i0.Renderer2 }
]; };
DescListComponent.propDecorators = {
title: [{ type: i0.Input }],
size: [{ type: i0.Input }],
gutter: [{ type: i0.Input }],
layout: [{ type: i0.Input }],
col: [{ type: i0.Input }],
_items: [{ type: i0.ContentChildren, args: [DescListItemComponent,] }]
};
return DescListComponent;
}());
var COMPONENTS$3 = [DescListComponent, DescListItemComponent];
var AdDescListModule = /** @class */ (function () {
function AdDescListModule() {
}
AdDescListModule.forRoot = function () {
return { ngModule: AdDescListModule, providers: [AdDescListConfig] };
};
AdDescListModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule, observers.ObserversModule],
declarations: COMPONENTS$3.slice(),
exports: COMPONENTS$3.slice(),
},] },
];
return AdDescListModule;
}());
var EllipsisComponent = /** @class */ (function () {
function EllipsisComponent(el, render) {
this._lines = 3;
render.setStyle(el.nativeElement, '-webkit-box-orient', 'vertical');
}
Object.defineProperty(EllipsisComponent.prototype, "lines", {
/** 在按照行数截取下最大的行数,超过则截取省略 */
get: function () {
return this._lines;
},
set: function (value) {
this._lines = util.toNumber(value);
},
enumerable: true,
configurable: true
});
EllipsisComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'ellipsis',
template: "<ng-content></ng-content>",
host: { '[class.ad-ellipsis]': 'true' },
},] },
];
/** @nocollapse */
EllipsisComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.Renderer2 }
]; };
EllipsisComponent.propDecorators = {
lines: [{ type: i0.Input }, { type: i0.HostBinding, args: ['style.-webkit-line-clamp',] }]
};
return EllipsisComponent;
}());
var COMPONENTS$4 = [EllipsisComponent];
var AdEllipsisModule = /** @class */ (function () {
function AdEllipsisModule() {
}
AdEllipsisModule.forRoot = function () {
return { ngModule: AdEllipsisModule, providers: [] };
};
AdEllipsisModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$4.slice(),
exports: COMPONENTS$4.slice(),
},] },
];
return AdEllipsisModule;
}());
var GlobalFooterComponent = /** @class */ (function () {
function GlobalFooterComponent() {
}
GlobalFooterComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'global-footer',
template: "\n <div *ngIf=\"links && links.length > 0\" class=\"links\">\n <a *ngFor=\"let i of links\" routerLink=\"{{i.href}}\" [attr.target]=\"i.blankTarget\">{{i.title}}</a>\n </div>\n <div class=\"copyright\"><ng-content></ng-content></div>\n ",
host: { '[class.ad-global-footer]': 'true' },
preserveWhitespaces: false,
},] },
];
GlobalFooterComponent.propDecorators = {
links: [{ type: i0.Input }]
};
return GlobalFooterComponent;
}());
var COMPONENTS$5 = [GlobalFooterComponent];
var AdGlobalFooterModule = /** @class */ (function () {
function AdGlobalFooterModule() {
}
AdGlobalFooterModule.forRoot = function () {
return { ngModule: AdGlobalFooterModule, providers: [] };
};
AdGlobalFooterModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, router.RouterModule],
declarations: COMPONENTS$5.slice(),
exports: COMPONENTS$5.slice(),
},] },
];
return AdGlobalFooterModule;
}());
var ExceptionComponent = /** @class */ (function () {
function ExceptionComponent() {
this._img = '';
this._title = '';
this._desc = '';
}
Object.defineProperty(ExceptionComponent.prototype, "type", {
set: function (value) {
var item = {
403: {
img: 'https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOEYFcZDnb.svg',
title: '403',
desc: '抱歉,你无权访问该页面',
},
404: {
img: 'https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozzI.svg',
title: '404',
desc: '抱歉,你访问的页面不存在',
},
500: {
img: 'https://gw.alipayobjects.com/zos/rmsportal/RVRUAYdCGeYNBWoKiIwB.svg',
title: '500',
desc: '抱歉,服务器出错了',
},
}[value];
if (!item)
return;
this._img = item.img;
this._title = item.title;
this._desc = item.desc;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ExceptionComponent.prototype, "img", {
set: function (value) {
this._img = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ExceptionComponent.prototype, "title", {
set: function (value) {
this._title = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ExceptionComponent.prototype, "desc", {
set: function (value) {
this._desc = value;
},
enumerable: true,
configurable: true
});
ExceptionComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'exception',
template: "\n <div class=\"img-block\">\n <div class=\"img\" [ngStyle]=\"{'background-image': 'url(' + _img + ')'}\"></div>\n </div>\n <div class=\"cont\">\n <h1 [innerHTML]=\"_title\"></h1>\n <div class=\"desc\" [innerHTML]=\"_desc\"></div>\n <ng-template #defaultActions>\n <button nz-button [routerLink]=\"['/']\" [nzType]=\"'primary'\">\u8FD4\u56DE\u9996\u9875</button>\n <ng-content></ng-content>\n </ng-template>\n <div class=\"actions\" *ngIf=\"actions; else defaultActions\">\n <ng-template [ngTemplateOutlet]=\"actions\"></ng-template>\n <ng-content></ng-content>\n </div>\n </div>\n ",
host: { '[class.ad-exception]': 'true' },
preserveWhitespaces: false,
},] },
];
ExceptionComponent.propDecorators = {
type: [{ type: i0.Input }],
img: [{ type: i0.Input }],
title: [{ type: i0.Input }],
desc: [{ type: i0.Input }],
actions: [{ type: i0.ContentChild, args: ['actions',] }]
};
return ExceptionComponent;
}());
var COMPONENTS$6 = [ExceptionComponent];
var AdExceptionModule = /** @class */ (function () {
function AdExceptionModule() {
}
AdExceptionModule.forRoot = function () {
return { ngModule: AdExceptionModule, providers: [] };
};
AdExceptionModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, router.RouterModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$6.slice(),
exports: COMPONENTS$6.slice(),
},] },
];
return AdExceptionModule;
}());
var NoticeIconComponent = /** @class */ (function () {
function NoticeIconComponent() {
this.data = [];
this._loading = false;
this.select = new i0.EventEmitter();
this.clear = new i0.EventEmitter();
this._popoverVisible = false;
this.popoverVisibleChange = new i0.EventEmitter();
}
Object.defineProperty(NoticeIconComponent.prototype, "count", {
/** 图标上的消息总数 */
get: function () {
return this._count;
},
set: function (value) {
this._count = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NoticeIconComponent.prototype, "loading", {
/** 弹出卡片加载状态 */
get: function () {
return this._loading;
},
set: function (value) {
this._loading = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NoticeIconComponent.prototype, "popoverVisible", {
/** 手动控制Popover显示 */
get: function () {
return this._popoverVisible;
},
set: function (value) {
this._popoverVisible = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
NoticeIconComponent.prototype.onVisibleChange = function (result) {
this.popoverVisibleChange.emit(result);
};
NoticeIconComponent.prototype.onSelect = function (i) {
this.select.emit(i);
};
NoticeIconComponent.prototype.onClear = function (title) {
this.clear.emit(title);
};
NoticeIconComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'notice-icon',
template: "\n <nz-badge *ngIf=\"data?.length === 0\" [nzCount]=\"count\">\n <i class=\"anticon anticon-bell\"></i>\n </nz-badge>\n <nz-popover *ngIf=\"data?.length > 0\"\n [nzVisible]=\"popoverVisible\" (nzVisibleChange)=\"onVisibleChange($event)\" nzTrigger=\"click\"\n nzPlacement=\"bottomRight\"\n nzOverlayClassName=\"ad-notice-icon-con\">\n <div nz-popover class=\"item\">\n <nz-badge [nzCount]=\"count\">\n <i class=\"anticon anticon-bell\"></i>\n </nz-badge>\n </div>\n <ng-template #nzTemplate>\n <nz-spin [nzSpinning]=\"loading\" [nzDelay]=\"0\">\n <nz-tabset>\n <nz-tab *ngFor=\"let i of data\" [nzTitle]=\"i.title\">\n <notice-icon-tab\n [data]=\"i\"\n (select)=\"onSelect($event)\"\n (clear)=\"onClear($event)\"></notice-icon-tab>\n </nz-tab>\n </nz-tabset>\n </nz-spin>\n </ng-template>\n </nz-popover>\n ",
host: { '[class.ad-notice-icon]': 'true' },
preserveWhitespaces: false,
},] },
];
NoticeIconComponent.propDecorators = {
data: [{ type: i0.Input }],
count: [{ type: i0.Input }],
loading: [{ type: i0.Input }],
select: [{ type: i0.Output }],
clear: [{ type: i0.Output }],
popoverVisible: [{ type: i0.Input }],
popoverVisibleChange: [{ type: i0.Output }]
};
return NoticeIconComponent;
}());
var NoticeIconTabComponent = /** @class */ (function () {
function NoticeIconTabComponent() {
this.select = new i0.EventEmitter();
this.clear = new i0.EventEmitter();
}
NoticeIconTabComponent.prototype.onClick = function (item) {
this.select.emit({
title: this.data.title,
item: item,
});
};
NoticeIconTabComponent.prototype.onClear = function () {
this.clear.emit(this.data.title);
};
NoticeIconTabComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'notice-icon-tab',
template: "\n <div *ngIf=\"data.list?.length === 0; else listTpl\" class=\"not-found\">\n <img *ngIf=\"data.emptyImage\" src=\"{{data.emptyImage}}\" alt=\"not found\" />\n <p>{{data.emptyText || '\u65E0\u901A\u77E5'}}</p>\n </div>\n <ng-template #listTpl>\n <nz-list [nzDataSource]=\"data.list\" [nzRenderItem]=\"item\">\n <ng-template #item let-item>\n <nz-list-item (click)=\"onClick(item)\" [ngClass]=\"{'read': item.read}\">\n <nz-list-item-meta\n [nzTitle]=\"nzTitle\"\n [nzDescription]=\"nzDescription\"\n [nzAvatar]=\"item.avatar\">\n <ng-template #nzTitle>\n {{item.title}}\n <div class=\"extra\" *ngIf=\"item.extra\"><nz-tag [nzColor]=\"item.color\">{{item.extra}}</nz-tag></div>\n </ng-template>\n <ng-template #nzDescription>\n <div *ngIf=\"item.description\" class=\"description\">{{item.description}}</div>\n <div *ngIf=\"item.datetime\" class=\"datetime\">{{item.datetime}}</div>\n </ng-template>\n </nz-list-item-meta>\n </nz-list-item>\n </ng-template>\n </nz-list>\n <div class=\"clear\" (click)=\"onClear()\">{{ data.clearText || '\u6E05\u7A7A' }}</div>\n </ng-template>\n ",
preserveWhitespaces: false,
},] },
];
NoticeIconTabComponent.propDecorators = {
data: [{ type: i0.Input }],
select: [{ type: i0.Output }],
clear: [{ type: i0.Output }]
};
return NoticeIconTabComponent;
}());
var COMPONENTS$7 = [NoticeIconComponent];
var ZORROMODULES$1 = [i1$1.NgZorroAntdModule];
// endregion
var AdNoticeIconModule = /** @class */ (function () {
function AdNoticeIconModule() {
}
AdNoticeIconModule.forRoot = function () {
return { ngModule: AdNoticeIconModule, providers: [] };
};
AdNoticeIconModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule].concat(ZORROMODULES$1),
declarations: COMPONENTS$7.concat([NoticeIconTabComponent]),
exports: COMPONENTS$7.slice(),
},] },
];
return AdNoticeIconModule;
}());
var NumberInfoComponent = /** @class */ (function () {
function NumberInfoComponent(el, renderer, cd) {
this.el = el;
this.renderer = renderer;
this.cd = cd;
this._title = '';
this._subTitle = '';
this._total = '';
this._isSubTotal = false;
this._subTotal = '';
/** 状态样式 */
this.theme = 'light';
this._gap = 8;
this._classMap = [];
}
Object.defineProperty(NumberInfoComponent.prototype, "title", {
/** 标题 */
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._title = null;
this._titleTpl = value;
}
else
this._title = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NumberInfoComponent.prototype, "subTitle", {
/** 子标题 */
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._subTitle = null;
this._subTitleTpl = value;
}
else
this._subTitle = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NumberInfoComponent.prototype, "total", {
/** 总量 */
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._total = null;
this._totalTpl = value;
}
else
this._total = '' + value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NumberInfoComponent.prototype, "subTotal", {
/** 总量后缀 */
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._subTotal = null;
this._subTotalTpl = value;
}
else
this._subTotal = value;
this._isSubTotal = !!value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NumberInfoComponent.prototype, "gap", {
/** 设置数字和描述直接的间距(像素) */
get: function () {
return this._gap;
},
set: function (value) {
this._gap = util.toNumber(value);
},
enumerable: true,
configurable: true
});
NumberInfoComponent.prototype.setClass = function () {
var _this = this;
this._classMap.forEach(function (cls) {
return _this.renderer.removeClass(_this.el.nativeElement, cls);
});
this._classMap = ['ad-number-info'];
if (this.theme)
this._classMap.push(this.theme);
this._classMap.forEach(function (cls) {
return _this.renderer.addClass(_this.el.nativeElement, cls);
});
this.cd.detectChanges();
};
NumberInfoComponent.prototype.ngOnChanges = function () {
this.setClass();
};
NumberInfoComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'number-info',
template: "\n <div *ngIf=\"_title || _titleTpl\" class=\"title\"><ng-container *ngIf=\"_title; else _titleTpl\">{{_title}}</ng-container></div>\n <div *ngIf=\"_subTitle || _subTitleTpl\" class=\"sub-title\"><ng-container *ngIf=\"_subTitle; else _subTitleTpl\">{{_subTitle}}</ng-container></div>\n <div class=\"value\" [ngStyle]=\"{'margin-top.px': gap}\">\n <span><ng-container *ngIf=\"_total; else _totalTpl\">{{_total}}</ng-container><em class=\"suffix\" *ngIf=\"suffix\">{{suffix}}</em></span>\n <span *ngIf=\"status || _isSubTotal\" class=\"sub-total\">\n <ng-container *ngIf=\"_subTotal; else _subTotalTpl\">{{_subTotal}}</ng-container>\n <i *ngIf=\"status\" class=\"anticon anticon-caret-{{status}}\"></i>\n </span>\n </div>\n ",
preserveWhitespaces: false,
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
NumberInfoComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.Renderer2 },
{ type: i0.ChangeDetectorRef }
]; };
NumberInfoComponent.propDecorators = {
title: [{ type: i0.Input }],
subTitle: [{ type: i0.Input }],
total: [{ type: i0.Input }],
subTotal: [{ type: i0.Input }],
suffix: [{ type: i0.Input }],
status: [{ type: i0.Input }],
theme: [{ type: i0.Input }],
gap: [{ type: i0.Input }]
};
return NumberInfoComponent;
}());
var COMPONENTS$8 = [NumberInfoComponent];
var AdNumberInfoModule = /** @class */ (function () {
function AdNumberInfoModule() {
}
AdNumberInfoModule.forRoot = function () {
return { ngModule: AdNumberInfoModule, providers: [] };
};
AdNumberInfoModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$8.slice(),
exports: COMPONENTS$8.slice(),
},] },
];
return AdNumberInfoModule;
}());
var AdPageHeaderConfig = /** @class */ (function () {
function AdPageHeaderConfig() {
/**
* 首页文本,若指定空表示不显示
*/
this.home = '首页';
/**
* 首页链接
*/
this.home_link = '/';
/**
* 自动生成导航,以当前路由从主菜单中定位
*/
this.autoBreadcrumb = true;
/**
* 自动生成标题,以当前路由从主菜单中定位
*/
this.autoTitle = true;
/**
* 是否自动将标准信息同步至 `TitleService`、`ReuseService` 下
*/
this.titleSync = false;
}
AdPageHeaderConfig.decorators = [
{ type: i0.Injectable },
];
return AdPageHeaderConfig;
}());
var PageHeaderComponent = /** @class */ (function () {
// endregion
function PageHeaderComponent(cog, renderer, route, menuSrv, titleSrv, reuseSrv, localizationSrv) {
this.renderer = renderer;
this.route = route;
this.menuSrv = menuSrv;
this.titleSrv = titleSrv;
this.reuseSrv = reuseSrv;
this.localizationSrv = localizationSrv;
this.inited = false;
//首页链接是否可点击
this.home_link_enabled = true;
this._autoBreadcrumb = true;
this._autoTitle = true;
this._titleSync = false;
this.paths = [];
Object.assign(this, cog);
}
Object.defineProperty(PageHeaderComponent.prototype, "menus", {
get: function () {
if (this._menus) {
return this._menus;
}
this._menus = this.menuSrv.getPathByUrl(this.route.url);
return this._menus;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PageHeaderComponent.prototype, "autoBreadcrumb", {
/**
* 自动生成导航,以当前路由从主菜单中定位
*/
get: function () {
return this._autoBreadcrumb;
},
set: function (value) {
this._autoBreadcrumb = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PageHeaderComponent.prototype, "autoTitle", {
/**
* 自动生成标题,以当前路由从主菜单中定位
*/
get: function () {
return this._autoTitle;
},
set: function (value) {
this._autoTitle = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PageHeaderComponent.prototype, "titleSync", {
/**
* 是否自动将标准信息同步至 `TitleService`、`ReuseService` 下
*/
get: function () {
return this._titleSync;
},
set: function (value) {
this._titleSync = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
PageHeaderComponent.prototype.refresh = function () {
this.setTitle().genBreadcrumb();
};
PageHeaderComponent.prototype.genBreadcrumb = function () {
var _this = this;
if (this.breadcrumb || !this.autoBreadcrumb || this.menus.length <= 0)
return;
var paths = [];
this.menus.forEach(function (item) {
if (typeof item.hideInBreadcrumb !== 'undefined' && item.hideInBreadcrumb)
return;
var title = _this.l(item.name);
paths.push({ title: title, link: item.route && [item.route], icon: item.icon });
});
// add home
if (this.home) {
var homeBreadcrumb = {
title: this.l(this.home),
link: [this.home_link],
icon: 'anticon anticon-home'
};
paths.splice(0, 0, homeBreadcrumb);
}
this.paths = paths;
return this;
};
PageHeaderComponent.prototype.setTitle = function () {
if (typeof this.title === 'undefined' &&
this.autoTitle &&
this.menus.length > 0) {
var item = this.menus[this.menus.length - 1];
var title = item.name;
this.title = title;
}
if (this.titleSync) {
if (this.titleSrv) {
this.titleSrv.setTitle(this.title);
}
if (this.reuseSrv) {
this.reuseSrv.title = this.title;
}
}
return this;
};
PageHeaderComponent.prototype.checkContent = function () {
if (util.isEmpty(this.conTpl.nativeElement)) {
this.renderer.setAttribute(this.conTpl.nativeElement, 'hidden', '');
}
else {
this.renderer.removeAttribute(this.conTpl.nativeElement, 'hidden');
}
};
PageHeaderComponent.prototype.ngOnInit = function () {
this.refresh();
this.inited = true;
};
PageHeaderComponent.prototype.ngAfterViewInit = function () {
this.checkContent();
};
PageHeaderComponent.prototype.ngOnChanges = function () {
if (this.inited)
this.refresh();
};
PageHeaderComponent.prototype.l = function (key) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return this.localizationSrv.l(key, args);
};
PageHeaderComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'page-header',
template: "\n <ng-container *ngIf=\"!breadcrumb; else breadcrumb\">\n <nz-breadcrumb *ngIf=\"paths && paths.length > 0\">\n <nz-breadcrumb-item *ngFor=\"let i of paths;let isLast=last;\">\n <ng-container *ngIf=\"i.link\">\n <a [routerLink]=\"i.link\" *ngIf=\"!isLast&&home_link_enabled\"> \n <i *ngIf=\"i.icon\" class=\"{{i.icon}}\"></i> \n {{i.title}}\n </a>\n <a *ngIf=\"!isLast&&!home_link_enabled\"> \n <i *ngIf=\"i.icon\" class=\"{{i.icon}}\"></i> \n {{i.title}}\n </a>\n <a *ngIf=\"isLast\"> \n <i *ngIf=\"i.icon\" class=\"{{i.icon}}\"></i> \n {{i.title}}\n </a>\n </ng-container>\n <ng-container *ngIf=\"!i.link\">\n <i *ngIf=\"i.icon\" class=\"{{i.icon}}\"></i> \n {{i.title}}\n </ng-container>\n </nz-breadcrumb-item>\n </nz-breadcrumb>\n </ng-container>\n <div class=\"detail\">\n <div *ngIf=\"logo\" class=\"logo\"><ng-template [ngTemplateOutlet]=\"logo\"></ng-template></div>\n <div class=\"main\">\n <div class=\"row\">\n <h1 *ngIf=\"title\" class=\"title\">\n {{title}} \n <span *ngIf=\"desc\" class=\"text-sm text-grey-dark\">\n <nz-divider nzType=\"vertical\"></nz-divider>\n {{desc}}\n </span> \n </h1> \n <div *ngIf=\"action\" class=\"action\">\n <ng-template [ngTemplateOutlet]=\"action\"></ng-template>\n </div> \n </div>\n <div class=\"row\">\n <div class=\"desc\" (cdkObserveContent)=\"checkContent()\" #conTpl><ng-content></ng-content><ng-template [ngTemplateOutlet]=\"content\"></ng-template></div>\n <div *ngIf=\"extra\" class=\"extra\"><ng-template [ngTemplateOutlet]=\"extra\"></ng-template></div>\n </div>\n </div>\n </div>\n <ng-template [ngTemplateOutlet]=\"tab\"></ng-template>\n ",
host: {
'[class.content__title]': 'true',
'[class.ad-ph]': 'true',
},
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
PageHeaderComponent.ctorParameters = function () { return [
{ type: AdPageHeaderConfig },
{ type: i0.Renderer2 },
{ type: router.Router },
{ type: theme.MenuService },
{ type: theme.TitleService, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [theme.TitleService,] }] },
{ type: abc.ReuseTabService, decorators: [{ type: i0.Inject, args: [abc.ReuseTabService,] }] },
{ type: localization_service.LocalizationService }
]; };
PageHeaderComponent.propDecorators = {
conTpl: [{ type: i0.ViewChild, args: ['conTpl',] }],
title: [{ type: i0.Input }],
desc: [{ type: i0.Input }],
home: [{ type: i0.Input }],
home_link: [{ type: i0.Input }],
home_link_enabled: [{ type: i0.Input }],
home_i18n: [{ type: i0.Input }],
autoBreadcrumb: [{ type: i0.Input }],
autoTitle: [{ type: i0.Input }],
titleSync: [{ type: i0.Input }],
breadcrumb: [{ type: i0.ContentChild, args: ['breadcrumb',] }],
logo: [{ type: i0.ContentChild, args: ['logo',] }],
action: [{ type: i0.ContentChild, args: ['action',] }],
content: [{ type: i0.ContentChild, args: ['content',] }],
extra: [{ type: i0.ContentChild, args: ['extra',] }],
tab: [{ type: i0.ContentChild, args: ['tab',] }]
};
return PageHeaderComponent;
}());
var COMPONENTS$9 = [PageHeaderComponent];
var ZORROMODULES$2 = [i1$1.NgZorroAntdModule];
// endregion
var AdPageHeaderModule = /** @class */ (function () {
function AdPageHeaderModule() {
}
AdPageHeaderModule.forRoot = function () {
return { ngModule: AdPageHeaderModule, providers: [AdPageHeaderConfig] };
};
AdPageHeaderModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, router.RouterModule, util.DelonUtilModule].concat(ZORROMODULES$2),
declarations: COMPONENTS$9.slice(),
exports: COMPONENTS$9.slice(),
},] },
];
return AdPageHeaderModule;
}());
var ResultComponent = /** @class */ (function () {
function ResultComponent() {
// region: fields
this._type = '';
this._icon = '';
this._title = '';
this._description = '';
this._extra = '';
// endregion
}
Object.defineProperty(ResultComponent.prototype, "type", {
set: function (value) {
this._type = value;
switch (value) {
case 'success':
this._icon = 'check-circle';
break;
case 'error':
this._icon = 'close-circle';
break;
default:
this._icon = value;
break;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(ResultComponent.prototype, "title", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._title = null;
this._titleTpl = value;
}
else
this._title = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ResultComponent.prototype, "description", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._description = null;
this._descriptionTpl = value;
}
else
this._description = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ResultComponent.prototype, "extra", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._extra = null;
this._extraTpl = value;
}
else
this._extra = value;
},
enumerable: true,
configurable: true
});
ResultComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'result',
template: "\n <div class=\"icon\"><i class=\"anticon anticon-{{_icon}} {{_type}}\"></i></div>\n <div class=\"title\"><ng-container *ngIf=\"_title; else _titleTpl\">{{_title}}</ng-container></div>\n <div *ngIf=\"_description || _descriptionTpl\" class=\"description\"><ng-container *ngIf=\"_description; else _descriptionTpl\">{{_description}}</ng-container></div>\n <div *ngIf=\"_extra || _extraTpl\" class=\"extra\">\n <ng-container *ngIf=\"_extra; else _extraTpl\">{{_extra}}</ng-container>\n </div>\n <div class=\"actions\"><ng-content></ng-content></div>\n ",
host: { '[class.ad-result]': 'true' },
preserveWhitespaces: false,
},] },
];
ResultComponent.propDecorators = {
type: [{ type: i0.Input }],
title: [{ type: i0.Input }],
description: [{ type: i0.Input }],
extra: [{ type: i0.Input }]
};
return ResultComponent;
}());
var COMPONENTS$10 = [ResultComponent];
var AdResultModule = /** @class */ (function () {
function AdResultModule() {
}
AdResultModule.forRoot = function () {
return { ngModule: AdResultModule, providers: [] };
};
AdResultModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$10.slice(),
exports: COMPONENTS$10.slice(),
},] },
];
return AdResultModule;
}());
var StandardFormRowComponent = /** @class */ (function () {
function StandardFormRowComponent(el, renderer) {
this.el = el;
this.renderer = renderer;
}
Object.defineProperty(StandardFormRowComponent.prototype, "block", {
/** 是否整行 */
get: function () {
return this._block;
},
set: function (value) {
this._block = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(StandardFormRowComponent.prototype, "last", {
/** 是否最后一行 */
get: function () {
return this._last;
},
set: function (value) {
this._last = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(StandardFormRowComponent.prototype, "grid", {
/** 是否网格布局 */
get: function () {
return this._grid;
},
set: function (value) {
this._grid = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
StandardFormRowComponent.prototype.setClass = function () {
var classMap = (_a = {},
_a['ad-standard-form-row'] = true,
_a['block'] = this.block,
_a['grid'] = this.grid,
_a['last'] = this.last,
_a);
util.updateHostClass(this.el.nativeElement, this.renderer, classMap);
var _a;
};
StandardFormRowComponent.prototype.ngOnChanges = function (changes) {
this.setClass();
};
StandardFormRowComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'standard-form-row',
template: "\n <div *ngIf=\"title\" class=\"label\"><span>{{title}}</span></div>\n <div class=\"control\"><ng-content></ng-content></div>\n ",
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
StandardFormRowComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.Renderer2 }
]; };
StandardFormRowComponent.propDecorators = {
title: [{ type: i0.Input }],
block: [{ type: i0.Input }],
last: [{ type: i0.Input }],
grid: [{ type: i0.Input }]
};
return StandardFormRowComponent;
}());
var COMPONENTS$11 = [StandardFormRowComponent];
var AdStandardFormRowModule = /** @class */ (function () {
function AdStandardFormRowModule() {
}
AdStandardFormRowModule.forRoot = function () {
return { ngModule: AdStandardFormRowModule, providers: [] };
};
AdStandardFormRowModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$11.slice(),
exports: COMPONENTS$11.slice(),
},] },
];
return AdStandardFormRowModule;
}());
var TagSelectComponent = /** @class */ (function () {
function TagSelectComponent() {
this._expandable = true;
this.expand = false;
this.change = new i0.EventEmitter();
}
Object.defineProperty(TagSelectComponent.prototype, "expandable", {
/** 是否启用 `展开与收进` */
get: function () {
return this._expandable;
},
set: function (value) {
this._expandable = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
TagSelectComponent.prototype.trigger = function () {
this.expand = !this.expand;
this.change.emit(this.expand);
};
TagSelectComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'tag-select',
template: "\n <ng-content></ng-content>\n <a *ngIf=\"expandable\" class=\"trigger\" (click)=\"trigger()\">{{expand ? '\u6536\u8D77' : '\u5C55\u5F00'}}<i class=\"anticon anticon-{{expand ? 'up' : 'down'}} ml-sm\"></i></a>",
host: { '[class.ad-tag-select]': 'true' },
preserveWhitespaces: false,
},] },
];
TagSelectComponent.propDecorators = {
expandable: [{ type: i0.HostBinding, args: ['class.has-expand',] }, { type: i0.Input }],
expand: [{ type: i0.HostBinding, args: ['class.expanded',] }],
change: [{ type: i0.Output }]
};
return TagSelectComponent;
}());
var COMPONENTS$12 = [TagSelectComponent];
var AdTagSelectModule = /** @class */ (function () {
function AdTagSelectModule() {
}
AdTagSelectModule.forRoot = function () {
return { ngModule: AdTagSelectModule, providers: [] };
};
AdTagSelectModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$12.slice(),
exports: COMPONENTS$12.slice(),
},] },
];
return AdTagSelectModule;
}());
var TrendComponent = /** @class */ (function () {
function TrendComponent() {
this._colorful = true;
}
Object.defineProperty(TrendComponent.prototype, "colorful", {
/** 是否彩色标记 */
get: function () {
return this._colorful;
},
set: function (value) {
this._colorful = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
TrendComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'trend',
template: "\n <ng-content></ng-content>\n <span *ngIf=\"flag\" class=\"{{flag}}\"><i class=\"anticon anticon-caret-{{flag}}\"></i></span>\n ",
host: {
'[class.ad-trend]': 'true',
'[class.grey]': '!colorful',
},
preserveWhitespaces: false,
},] },
];
TrendComponent.propDecorators = {
flag: [{ type: i0.Input }],
colorful: [{ type: i0.Input }]
};
return TrendComponent;
}());
var COMPONENTS$13 = [TrendComponent];
var AdTrendModule = /** @class */ (function () {
function AdTrendModule() {
}
AdTrendModule.forRoot = function () {
return { ngModule: AdTrendModule, providers: [] };
};
AdTrendModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$13.slice(),
exports: COMPONENTS$13.slice(),
},] },
];
return AdTrendModule;
}());
var CountDownComponent = /** @class */ (function () {
function CountDownComponent() {
this.begin = new i0.EventEmitter();
this.notify = new i0.EventEmitter();
this.end = new i0.EventEmitter();
}
Object.defineProperty(CountDownComponent.prototype, "target", {
/**
* 目标时间
*/
set: function (value) {
this.config = {
template: "$!h!:$!m!:$!s!",
stopTime: typeof value === 'number'
? addSeconds(new Date(), value).valueOf()
: format___default(value, 'x'),
};
},
enumerable: true,
configurable: true
});
CountDownComponent.prototype._start = function () {
this.begin.emit();
};
CountDownComponent.prototype._notify = function (time) {
this.notify.emit(time);
};
CountDownComponent.prototype._finished = function () {
this.end.emit();
};
CountDownComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'count-down',
template: "\n <countdown *ngIf=\"config\" [config]=\"config\"\n (start)=\"_start()\"\n (finished)=\"_finished()\"\n (notify)=\"_notify($event)\"></countdown>\n ",
preserveWhitespaces: false,
},] },
];
CountDownComponent.propDecorators = {
config: [{ type: i0.Input }],
target: [{ type: i0.Input }],
begin: [{ type: i0.Output }],
notify: [{ type: i0.Output }],
end: [{ type: i0.Output }]
};
return CountDownComponent;
}());
var COMPONENTS$14 = [CountDownComponent];
var AdCountDownModule = /** @class */ (function () {
function AdCountDownModule() {
}
AdCountDownModule.forRoot = function () {
return { ngModule: AdCountDownModule, providers: [] };
};
AdCountDownModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, ngxCountdown.CountdownModule],
declarations: COMPONENTS$14.slice(),
exports: COMPONENTS$14.slice(),
},] },
];
return AdCountDownModule;
}());
var AdSimpleTableConfig = /** @class */ (function () {
function AdSimpleTableConfig() {
/**
* pagination中每页显示条目数下拉框值
*/
this.pageSizeOptions = [10, 20, 30, 40, 50];
/**
* 是否显示总数据量,默认:`共 {{total}} 条`
*/
this.showTotal = "\u5171 {{total}} \u6761";
/**
* 是否多排序,当 `sort` 多个相同值时自动合并,建议后端支持时使用
*/
this.multiSort = false;
/**
* 前端分页,当 `data` 为`any[]` 或 `Observable<any[]>` 有效
*/
this.frontPagination = true;
}
AdSimpleTableConfig.decorators = [
{ type: i0.Injectable },
];
return AdSimpleTableConfig;
}());
var DA_XLSX_CONFIG = new i0.InjectionToken('DA_XLSX_CONFIG');
var XlsxService = /** @class */ (function () {
function XlsxService(config, http, lazy) {
this.config = config;
this.http = http;
this.lazy = lazy;
}
XlsxService.prototype.init = function () {
var config = Object.assign({
url: "//cdn.bootcss.com/xlsx/0.12.12/xlsx.full.min.js",
modules: [],
}, this.config);
return this.lazy.load([config.url].concat(config.modules));
};
XlsxService.prototype.read = function (wb) {
var ret = {};
wb.SheetNames.forEach(function (name) {
var sheet = wb.Sheets[name];
ret[name] = XLSX.utils.sheet_to_json(sheet, { header: 1 });
});
return ret;
};
/**
* 导入Excel并输出JSON,支持 `<input type="file">`、URL 形式
* @param rABS 加载数据方式 `readAsBinaryString` (默认) 或 `readAsArrayBuffer`,[更多细节](http://t.cn/R3n63A0)
*/
XlsxService.prototype.import = function (fileOrUrl, rABS) {
var _this = this;
if (rABS === void 0) { rABS = 'readAsBinaryString'; }
return new Promise(function (resolver, reject) {
_this.init().then(function () {
// from url
if (typeof fileOrUrl === 'string') {
_this.http
.request('GET', fileOrUrl, { responseType: 'arraybuffer' })
.subscribe(function (res) {
var wb = XLSX.read(new Uint8Array(res), { type: 'array' });
resolver(_this.read(wb));
}, function (err) {
reject(err);
});
return;
}
// from file
var reader = new FileReader();
reader.onload = function (e) {
var wb = XLSX.read(e.target.result, { type: 'binary' });
resolver(_this.read(wb));
};
reader[rABS](fileOrUrl);
});
});
};
/** 导出 */
XlsxService.prototype.export = function (options) {
return this.init().then(function () {
var wb = XLSX.utils.book_new();
if (Array.isArray(options.sheets)) {
options.sheets.forEach(function (value, index) {
var ws = XLSX.utils.aoa_to_sheet(value.data);
XLSX.utils.book_append_sheet(wb, ws, value.name || "Sheet" + (index + 1));
});
}
else {
wb.SheetNames = Object.keys(options.sheets);
wb.Sheets = options.sheets;
}
if (options.callback)
options.callback(wb);
var wbout = XLSX.write(wb, Object.assign({
bookType: 'xlsx',
bookSST: false,
type: 'array',
}, options.opts));
fileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), options.filename || 'export.xlsx');
});
};
XlsxService.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
XlsxService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: i0.Inject, args: [DA_XLSX_CONFIG,] }] },
{ type: i1.HttpClient },
{ type: util.LazyService }
]; };
return XlsxService;
}());
var SimpleTableExport = /** @class */ (function () {
function SimpleTableExport(xlsxSrv) {
this.xlsxSrv = xlsxSrv;
}
SimpleTableExport.prototype._stGet = function (item, col) {
var ret = { t: 's', v: '' };
if (col.format) {
ret.v = col.format(item, col);
}
else {
var val = util.deepGet(item, col.index, '');
ret.v = val;
switch (col.type) {
case 'currency':
ret.t = 'n';
break;
case 'date':
ret.t = 'd';
break;
case 'yn':
ret.v = ret.v === col.ynTruth ? col.ynYes || '是' : col.ynNo || '否';
break;
}
}
return ret;
};
SimpleTableExport.prototype.genSheet = function (opt) {
var sheets = {};
var sheet = (sheets[opt.sheetname || 'Sheet1'] = {});
var colData = opt._c.filter(function (w) {
return w.exported !== false &&
w.index &&
(!w.buttons || w.buttons.length === 0);
});
var cc = colData.length, dc = opt._d.length;
// region: column
for (var i = 0; i < cc; i++) {
sheet[String.fromCharCode(65 + i) + "1"] = {
t: 's',
v: colData[i].title,
};
}
// endregion
// region: content
for (var i = 0; i < dc; i++) {
for (var j = 0; j < cc; j++) {
sheet["" + String.fromCharCode(65 + j) + (i + 2)] = this._stGet(opt._d[i], colData[j]);
}
}
// endregion
if (cc > 0 && dc > 0) {
sheet['!ref'] = "A1:" + String.fromCharCode(65 + cc - 1) + (dc + 1);
}
return sheets;
};
SimpleTableExport.prototype.export = function (opt) {
if (!this.xlsxSrv)
throw new Error("muse be import 'AdXlsxModule' module, but got null");
var sheets = this.genSheet(opt);
return this.xlsxSrv.export({
sheets: sheets,
filename: opt.filename,
callback: opt.callback,
});
};
SimpleTableExport.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
SimpleTableExport.ctorParameters = function () { return [
{ type: XlsxService, decorators: [{ type: i0.Optional }] }
]; };
return SimpleTableExport;
}());
var SimpleTableComponent = /** @class */ (function () {
// endregion
function SimpleTableComponent(defConfig, http, router$$1, el, renderer, exportSrv, modal, currenty, date, yn, number, doc) {
this.defConfig = defConfig;
this.http = http;
this.router = router$$1;
this.el = el;
this.renderer = renderer;
this.exportSrv = exportSrv;
this.modal = modal;
this.currenty = currenty;
this.date = date;
this.yn = yn;
this.number = number;
this.doc = doc;
this._inited = false;
this._data = [];
this._isAjax = false;
this._isPagination = true;
this._classMap = [];
this._allChecked = false;
this._indeterminate = false;
this._columns = [];
/** 请求方法 */
this.reqMethod = 'GET';
this._reqReName = { pi: 'pi', ps: 'ps' };
/** 请求异常时回调 */
this.reqError = new i0.EventEmitter();
this._resReName = { total: ['total'], list: ['list'] };
/** 列描述 */
this.columns = [];
this._ps = 10;
this._pi = 1;
this._total = 0;
this._loading = false;
this._loadingDelay = 0;
this._bordered = false;
/** table大小 */
this.size = 'default';
this._showSizeChanger = false;
this._showQuickJumper = false;
/** 是否显示总数据量 */
this._totalTpl = "";
this._isPageIndexReset = true;
/** 分页方向 */
this.pagePlacement = 'right';
this._toTopInChange = true;
this._toTopOffset = 100;
/** 页码、每页数量变化时回调 */
this.change = new i0.EventEmitter();
/** checkbox变化时回调,参数为当前所选清单 */
this.checkboxChange = new i0.EventEmitter();
/** radio变化时回调,参数为当前所选 */
this.radioChange = new i0.EventEmitter();
/** 排序回调 */
this.sortChange = new i0.EventEmitter();
/** Filter回调 */
this.filterChange = new i0.EventEmitter();
this._zeroIndexedOnPage = false;
// endregion
// region: sort
this._sortMap = {};
this._sortColumn = null;
Object.assign(this, util.deepCopy(defConfig));
}
Object.defineProperty(SimpleTableComponent.prototype, "reqReName", {
get: function () {
return this._reqReName;
},
/**
* 重命名请求参数 `pi`、`ps`
* - `{ pi: 'Page' }` => `pi` 会被替换成 Page
*/
set: function (value) {
this._reqReName = Object.assign(this._reqReName, value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "resReName", {
get: function () {
return this._resReName;
},
/**
* 重命名返回参数 `total`、`list`
* - `{ total: 'Total' }` => Total 会被当作 `total`
*/
set: function (cur) {
var ret = {};
if (cur) {
if (cur.list)
ret.list = Array.isArray(cur.list) ? cur.list : cur.list.split('.');
else
ret.list = ['list'];
if (cur.total)
ret.total = Array.isArray(cur.total) ? cur.total : cur.total.split('.');
else
ret.total = ['total'];
}
else {
ret = { total: ['total'], list: ['list'] };
}
this._resReName = ret;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "ps", {
/** 每页数量,当设置为 `0` 表示不分页,默认:`10` */
get: function () {
return this._ps;
},
set: function (value) {
this._ps = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "pi", {
/** 当前页码 */
get: function () {
return this._pi;
},
set: function (value) {
this._pi = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "total", {
/** 数据总量 */
get: function () {
return this._total;
},
set: function (value) {
this._total = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "showPagination", {
/** 是否显示分页器 */
get: function () {
return this._showPagination;
},
set: function (value) {
this._showPagination = util.toBoolean(value, true);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "loading", {
/** 是否显示Loading */
get: function () {
return this._loading;
},
set: function (value) {
this._loading = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "loadingDelay", {
/** 延迟显示加载效果的时间(防止闪烁) */
get: function () {
return this._loadingDelay;
},
set: function (value) {
this._loadingDelay = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "bordered", {
/** 是否显示边框 */
get: function () {
return this._bordered;
},
set: function (value) {
this._bordered = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "showSizeChanger", {
/** 是否显示pagination中改变页数 */
get: function () {
return this._showSizeChanger;
},
set: function (value) {
this._showSizeChanger = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "showQuickJumper", {
/** 是否显示pagination中快速跳转 */
get: function () {
return this._showQuickJumper;
},
set: function (value) {
this._showQuickJumper = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "showTotal", {
set: function (value) {
if (typeof value === 'string' && value.length) {
this._totalTpl = value;
}
else if (util.toBoolean(value)) {
this._totalTpl = "\u5171 {{total}} \u6761";
}
else {
this._totalTpl = '';
}
},
enumerable: true,
configurable: true
});
SimpleTableComponent.prototype.renderTotal = function (total, range) {
return this._totalTpl
? this._totalTpl
.replace('{{total}}', total)
.replace('{{range[0]}}', range[0])
.replace('{{range[1]}}', range[1])
: '';
};
Object.defineProperty(SimpleTableComponent.prototype, "frontPagination", {
/**
* 前端分页,当 `data` 为`any[]` 或 `Observable<any[]>` 有效,默认:`true`
* - `true` 由 `simple-table` 根据 `data` 长度受控分页,包括:排序、过滤等
* - `false` 由用户通过 `total` 和 `data` 参数受控分页,并维护 `(change)` 当分页变更时重新加载数据
*/
get: function () {
return this._frontPagination;
},
set: function (value) {
this._frontPagination = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "isPageIndexReset", {
/** 数据变更后是否保留在数据变更前的页码 */
get: function () {
return this._isPageIndexReset;
},
set: function (value) {
this._isPageIndexReset = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "toTopInChange", {
/** 切换分页时返回顶部 */
get: function () {
return this._toTopInChange;
},
set: function (value) {
this._toTopInChange = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "toTopOffset", {
/** 返回顶部偏移值 */
get: function () {
return this._toTopOffset;
},
set: function (value) {
this._toTopOffset = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "multiSort", {
/** 是否多排序,当 `sort` 多个相同值时自动合并,建议后端支持时使用 */
get: function () {
return this._multiSort;
},
set: function (value) {
if (typeof value === 'object') {
this._multiSort = Object.assign({
key: 'sort',
separator: '-',
name_separator: '.',
}, value);
}
else {
this._multiSort = util.toBoolean(value);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(SimpleTableComponent.prototype, "zeroIndexedOnPage", {
/** 后端分页是否采用`1`基索引,只在`data`类型为`string`时有效 */
get: function () {
return this._zeroIndexedOnPage;
},
set: function (value) {
this._zeroIndexedOnPage = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
// region: data
/**
* 根据页码重新加载数据
*
* @param pi 指定当前页码,默认:`1`
* @param extraParams 重新指定 `extraParams` 值
*/
SimpleTableComponent.prototype.load = function (pi, extraParams) {
if (pi === void 0) { pi = 1; }
if (pi !== -1)
this.pi = pi;
if (typeof extraParams !== 'undefined') {
this.extraParams = extraParams;
}
this._change('pi');
};
/**
* 重新刷新当前页
* @param extraParams 重新指定 `extraParams` 值
*/
SimpleTableComponent.prototype.reload = function (extraParams) {
this.load(-1, extraParams);
};
/**
* 重置且重新设置 `pi` 为 `1`
*
* @param extraParams 重新指定 `extraParams` 值
*/
SimpleTableComponent.prototype.reset = function (extraParams) {
this.load(1, extraParams);
};
SimpleTableComponent.prototype.getAjaxData = function (url) {
var _this = this;
var params = Object.assign((_a = {},
_a[this.reqReName.pi] = this._zeroIndexedOnPage ? this.pi - 1 : this.pi,
_a[this.reqReName.ps] = this.ps,
_a), this.extraParams, this.getReqSortMap(), this.getReqFilterMap());
return this.http
.request(this.reqMethod || 'GET', url || this._url, {
params: params,
body: this.reqBody,
headers: this.reqHeaders,
})
.pipe(operators.map(function (res) {
// list
var ret = util.deepGet(res, _this.resReName.list, []);
if (ret == null || !Array.isArray(ret)) {
ret = [];
}
// total
var retTotal = _this.resReName.total &&
util.deepGet(res, _this.resReName.total, null);
_this.total = retTotal == null ? _this.total || 0 : +retTotal;
return ret;
}));
var _a;
};
SimpleTableComponent.prototype._genAjax = function (forceRefresh) {
var _this = this;
if (forceRefresh === void 0) { forceRefresh = false; }
if (!this._isAjax)
return;
this.loading = true;
if (forceRefresh === true)
this.pi = 1;
this.getAjaxData().subscribe(function (res) { return _this.checkPaged().subscribeData(res); }, function (err) {
_this.loading = false;
_this.reqError.emit(err);
});
};
SimpleTableComponent.prototype._genData = function (forceRefresh) {
if (forceRefresh === void 0) { forceRefresh = false; }
if (this._isAjax)
return;
var data = this.data.slice(0);
// sort
var sorterFn = this.getSorterFn();
if (sorterFn) {
data = data.sort(sorterFn);
}
// filter
this._columns.filter(function (w) { return w.filters && w.filters.length; }).forEach(function (c) {
var values = c.filters.filter(function (w) { return w.checked; });
if (values.length === 0)
return;
var onFilter = c.filter;
data = data.filter(function (record) { return values.some(function (v) { return onFilter(v, record); }); });
});
if (forceRefresh) {
if (this.isPageIndexReset) {
this.pi = 1;
}
else {
var maxPageIndex = Math.ceil(data.length / this.ps);
this.pi = !this.pi
? 1
: this.pi > maxPageIndex
? maxPageIndex
: this.pi;
}
}
this.total = this.frontPagination
? data.length
: this.total <= 0
? data.length
: this.total;
this.checkPaged().subscribeData(this._isPagination && this.frontPagination
? data.slice((this.pi - 1) * this.ps, this.pi * this.ps)
: data);
};
SimpleTableComponent.prototype._toTop = function () {
if (!this.toTopInChange)
return;
if (this.scroll) {
this.el.nativeElement
.querySelector('.ant-table-body')
.scrollTo(0, 0);
return;
}
this.el.nativeElement.scrollIntoView();
// fix header height
this.doc.documentElement.scrollTop -= this.toTopOffset;
};
SimpleTableComponent.prototype.checkPaged = function () {
this._isPagination =
typeof this.showPagination === 'undefined'
? this.ps > 0 && this.total > this.ps
: this.showPagination;
return this;
};
SimpleTableComponent.prototype.processData = function () {
var _this = this;
if (!this.data) {
this._isAjax = false;
this.data = [];
return;
}
this._isAjax = false;
if (typeof this.data === 'string') {
this._url = this.data;
this._isAjax = true;
this._genAjax(true);
}
else if (Array.isArray(this.data)) {
this._genData(this.frontPagination);
}
else {
if (this.data$) {
this.data$.unsubscribe();
}
this.data$ = this.data
.pipe(operators.tap(function () { return (_this.loading = true); }))
.subscribe(function (res) {
_this.data = res;
_this._genData(_this.frontPagination);
});
}
};
SimpleTableComponent.prototype.subscribeData = function (res) {
var _this = this;
if (this.preDataChange)
res = this.preDataChange(res);
this.loading = false;
var _loop_1 = function (i) {
i._values = this_1._columns.map(function (c) { return _this._get(i, c); });
};
var this_1 = this;
for (var _i = 0, res_1 = res; _i < res_1.length; _i++) {
var i = res_1[_i];
_loop_1(i);
}
this._data = res;
this._refCheck();
};
SimpleTableComponent.prototype._change = function (type) {
if (!this._inited)
return;
this._genAjax();
if (this.frontPagination)
this._genData();
this._toTop();
this.change.emit({
type: type,
pi: this.pi,
ps: this.ps,
total: this.total,
});
};
SimpleTableComponent.prototype._get = function (item, col) {
if (col.format)
return col.format(item, col);
var value = util.deepGet(item, col.index, col.default);
var ret = value;
switch (col.type) {
case 'img':
ret = value ? "<img src=\"" + value + "\" class=\"img\">" : '';
break;
case 'number':
ret = this.number.transform(value, col.numberDigits);
break;
case 'currency':
ret = this.currenty.transform(value);
break;
case 'date':
ret = this.date.transform(value, col.dateFormat);
break;
case 'yn':
ret = this.yn.transform(value === col.ynTruth, col.ynYes, col.ynNo);
break;
}
return ret;
};
SimpleTableComponent.prototype._click = function (e, item, col) {
e.preventDefault();
e.stopPropagation();
var res = col.click(item, this);
if (typeof res === 'string') {
this.router.navigateByUrl(res);
}
return false;
};
SimpleTableComponent.prototype.getReqSortMap = function () {
var _this = this;
var ret = {};
if (!this._sortOrder)
return ret;
var ms = this.multiSort;
if (ms) {
Object.keys(this._sortMap).forEach(function (key) {
var item = _this._sortMap[key];
ret[item.key] =
(item.column.sortReName || _this.sortReName || {})[item.v] || item.v;
});
// 合并处理
if (typeof ms === 'object') {
ret = (_a = {},
_a[ms.key] = Object.keys(ret)
.map(function (key) { return key + ms.name_separator + ret[key]; })
.join(ms.separator),
_a);
}
}
else {
var mapData = this._sortMap[this._sortIndex];
ret[mapData.key] =
(this._sortColumn.sortReName || this.sortReName || {})[mapData.v] ||
mapData.v;
}
return ret;
var _a;
};
SimpleTableComponent.prototype.getSorterFn = function () {
var _this = this;
if (!this._sortOrder || !this._sortColumn) {
return;
}
return function (a, b) {
var result = _this._sortColumn.sorter(a, b);
if (result !== 0) {
return _this._sortOrder === 'descend' ? -result : result;
}
return 0;
};
};
SimpleTableComponent.prototype.sort = function (index, value) {
var _this = this;
this._sortColumn = this._columns[index];
this._sortOrder = value;
this._sortIndex = index;
if (this.multiSort) {
this._sortMap[index].v = value;
}
else {
Object.keys(this._sortMap).forEach(function (key) { return (_this._sortMap[key].v = +key === index ? value : null); });
}
this._genAjax(true);
this._genData(true);
this.sortChange.emit({
value: value,
map: this.getReqSortMap(),
column: this._sortColumn,
});
};
// endregion
// region: filter
SimpleTableComponent.prototype.getReqFilterMap = function () {
var ret = {};
this._columns.filter(function (w) { return w.filtered === true; }).forEach(function (col) {
var values = col.filters.filter(function (f) { return f.checked === true; });
var obj = {};
if (col.filterReName) {
obj = col.filterReName(col.filters, col);
}
else {
obj[col.filterKey || col.indexKey] = values.map(function (i) { return i.value; }).join(',');
}
ret = Object.assign(ret, obj);
});
return ret;
};
SimpleTableComponent.prototype.handleFilter = function (col) {
col.filtered = col.filters.findIndex(function (w) { return w.checked; }) !== -1;
this._genAjax(true);
this._genData(true);
this.filterChange.emit(col);
};
SimpleTableComponent.prototype.filterConfirm = function (col) {
this.handleFilter(col);
};
SimpleTableComponent.prototype.filterClear = function (col) {
col.filters.forEach(function (i) { return (i.checked = false); });
this.handleFilter(col);
};
SimpleTableComponent.prototype.filterRadio = function (col, item, checked) {
col.filters.forEach(function (i) { return (i.checked = false); });
item.checked = checked;
};
// endregion
// region: checkbox
/** 清除所有 `checkbox` */
SimpleTableComponent.prototype.clearCheck = function () {
return this._checkAll(false);
};
SimpleTableComponent.prototype._checkAll = function (checked) {
checked = typeof checked === 'undefined' ? this._allChecked : checked;
this._data.filter(function (w) { return !w.disabled; }).forEach(function (i) { return (i.checked = checked); });
return this._refCheck()._checkNotify();
};
SimpleTableComponent.prototype._checkSelection = function (i, value) {
i.checked = value;
return this._refCheck()._checkNotify();
};
SimpleTableComponent.prototype._refCheck = function () {
var validData = this._data.filter(function (w) { return !w.disabled; });
var checkedList = validData.filter(function (w) { return w.checked === true; });
this._allChecked =
checkedList.length > 0 && checkedList.length === validData.length;
var allUnChecked = validData.every(function (value) { return !value.checked; });
this._indeterminate = !this._allChecked && !allUnChecked;
return this;
};
SimpleTableComponent.prototype._rowSelection = function (row) {
row.select(this._data);
return this._refCheck()._checkNotify();
};
SimpleTableComponent.prototype._checkNotify = function () {
this.checkboxChange.emit(this._data.filter(function (w) { return !w.disabled && w.checked === true; }));
return this;
};
// endregion
// region: radio
/** 清除所有 `radio` */
SimpleTableComponent.prototype.clearRadio = function () {
this._data.filter(function (w) { return w.checked; }).forEach(function (item) { return (item.checked = false); });
this.radioChange.emit(null);
return this;
};
SimpleTableComponent.prototype._refRadio = function (checked, item) {
// if (item.disabled === true) return;
this._data.filter(function (w) { return !w.disabled; }).forEach(function (i) { return (i.checked = false); });
item.checked = checked;
this.radioChange.emit(item);
return this;
};
// endregion
// region: buttons
SimpleTableComponent.prototype.btnCoerce = function (list) {
if (!list)
return [];
var ret = [];
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
var item = list_1[_i];
if (item.type === 'del' && typeof item.pop === 'undefined')
item.pop = true;
if (item.pop === true) {
item._type = 2;
if (typeof item.popTitle === 'undefined')
item.popTitle = "\u786E\u8BA4\u5220\u9664\u5417\uFF1F";
}
if (item.children && item.children.length > 0) {
item._type = 3;
item.children = this.btnCoerce(item.children);
}
if (!item._type)
item._type = 1;
ret.push(item);
}
this.btnCoerceIf(ret);
return ret;
};
SimpleTableComponent.prototype.btnCoerceIf = function (list) {
for (var _i = 0, list_2 = list; _i < list_2.length; _i++) {
var item = list_2[_i];
if (!item.iif)
item.iif = function () { return true; };
if (!item.children) {
item.children = [];
}
else {
this.btnCoerceIf(item.children);
}
}
};
SimpleTableComponent.prototype.btnClick = function (record, btn) {
var _this = this;
if (btn.type === 'modal' || btn.type === 'static') {
var obj = {};
obj[btn.paramName || this.defConfig.modalParamsName || 'record'] = record;
var options = Object.assign({}, btn.modal);
// TODO: deprecated
if (btn.size)
options.size = btn.size;
if (btn.modalOptions)
options.modalOptions = btn.modalOptions;
this.modal[btn.type === 'modal' ? 'create' : 'createStatic'](btn.component, Object.assign(obj, btn.params && btn.params(record)), options)
.pipe(operators.filter(function (w) { return typeof w !== 'undefined'; }))
.subscribe(function (res) { return _this.btnCallback(record, btn, res); });
return;
}
else if (btn.type === 'link') {
var clickRes = this.btnCallback(record, btn);
if (typeof clickRes === 'string') {
this.router.navigateByUrl(clickRes);
}
return;
}
this.btnCallback(record, btn);
};
SimpleTableComponent.prototype.btnCallback = function (record, btn, modal) {
if (!btn.click)
return;
if (typeof btn.click === 'string') {
switch (btn.click) {
case 'load':
this.load();
break;
case 'reload':
this.reload();
break;
}
}
else {
return btn.click(record, modal, this);
}
};
SimpleTableComponent.prototype.btnText = function (record, btn) {
if (btn.format)
return btn.format(record, btn);
return btn.text;
};
// endregion
// region: fixed
SimpleTableComponent.prototype.fixedCoerce = function (list) {
list.forEach(function (item, idx) {
if (item.fixed && item.width) {
if (item.fixed === 'left') {
item._left = idx === 0 ? '0px' : list[idx - 1].width;
}
else {
item._right = idx === list.length - 1 ? '0px' : list[idx + 1].width;
}
}
});
};
// endregion
// region: export
/**
* 导出Excel,确保已经注册 `AdXlsxModule`
* @param urlOrData 重新指定数据,例如希望导出所有数据非常有用
* @param opt 额外参数
*/
SimpleTableComponent.prototype.export = function (urlOrData, opt) {
var _this = this;
(urlOrData
? typeof urlOrData === 'string'
? this.getAjaxData(urlOrData)
: rxjs.of(urlOrData)
: this._isAjax
? this.getAjaxData()
: rxjs.of(this.data)).subscribe(function (res) {
return _this.exportSrv.export(Object.assign({}, opt, {
_d: res,
_c: _this._columns,
}));
});
};
// endregion
SimpleTableComponent.prototype.ngOnInit = function () {
this._inited = true;
this.updateColumns();
this.processData();
};
SimpleTableComponent.prototype.setClass = function () {
var _this = this;
this._classMap.forEach(function (cls) {
return _this.renderer.removeClass(_this.el.nativeElement, cls);
});
this._classMap = [];
if (this.pagePlacement)
this._classMap.push('ad-st__p' + this.pagePlacement);
this._classMap.forEach(function (cls) {
return _this.renderer.addClass(_this.el.nativeElement, cls);
});
};
SimpleTableComponent.prototype.updateColumns = function () {
this._columns = [];
if (!this.columns || this.columns.length === 0)
throw new Error("the columns property muse be define!");
var checkboxCount = 0;
var radioCount = 0;
var sortMap = {};
var idx = 0;
var newColumns = [];
var copyColumens = util.deepCopy(this.columns);
for (var _i = 0, copyColumens_1 = copyColumens; _i < copyColumens_1.length; _i++) {
var item = copyColumens_1[_i];
if (item.index) {
if (!Array.isArray(item.index))
item.index = item.index.split('.');
item.indexKey = item.index.join('.');
}
// rowSelection
if (!item.selections)
item.selections = [];
if (item.type === 'checkbox') {
++checkboxCount;
if (!item.width) {
item.width = (item.selections.length > 0 ? 60 : 50) + "px";
}
}
if (item.type === 'radio') {
++radioCount;
item.selections = [];
if (!item.width)
item.width = '50px';
}
if (item.type === 'yn' && typeof item.ynTruth === 'undefined') {
item.ynTruth = true;
}
if ((item.type === 'link' && typeof item.click !== 'function') ||
(item.type === 'badge' && typeof item.badge === 'undefined') ||
(item.type === 'tag' && typeof item.tag === 'undefined')) {
item.type = '';
}
if (!item.className) {
item.className = {
// 'checkbox': 'text-center',
// 'radio': 'text-center',
number: 'text-right',
currency: 'text-right',
date: 'text-center',
}[item.type];
}
// sorter
if (item.sorter && typeof item.sorter === 'function') {
sortMap[idx] = {
enabled: true,
v: item.sort,
key: item.sortKey || item.indexKey,
column: item,
};
if (item.sort && !this._sortColumn) {
this._sortColumn = item;
this._sortOrder = item.sort;
this._sortIndex = idx;
}
}
else {
sortMap[idx] = {
enabled: false,
};
}
// filter
if (!item.filter || !item.filters)
item.filters = [];
if (typeof item.filterMultiple === 'undefined')
item.filterMultiple = true;
if (!item.filterConfirmText)
item.filterConfirmText = "\u786E\u8BA4";
if (!item.filterClearText)
item.filterClearText = "\u91CD\u7F6E";
if (!item.filterIcon)
item.filterIcon = "anticon anticon-filter";
item.filtered = item.filters.findIndex(function (w) { return w.checked; }) !== -1;
// buttons
item.buttons = this.btnCoerce(item.buttons);
// i18n
++idx;
newColumns.push(item);
}
if (checkboxCount > 1)
throw new Error("just only one column checkbox");
if (radioCount > 1)
throw new Error("just only one column radio");
this.fixedCoerce(newColumns);
this._columns = newColumns;
this._sortMap = sortMap;
};
SimpleTableComponent.prototype.ngOnChanges = function (changes) {
if (changes.columns && this._inited)
this.updateColumns();
if (changes.data && this._inited)
this.processData();
this.setClass();
};
SimpleTableComponent.prototype.ngOnDestroy = function () {
if (this.data$) {
this.data$.unsubscribe();
this.data$ = null;
}
};
SimpleTableComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'simple-table',
template: "\n <nz-table [nzData]=\"_data\" [(nzPageIndex)]=\"pi\" (nzPageIndexChange)=\"_change('pi')\" [(nzPageSize)]=\"ps\" (nzPageSizeChange)=\"_change('ps')\"\n [nzTotal]=\"total\" [nzShowPagination]=\"_isPagination\" [nzFrontPagination]=\"false\" [nzBordered]=\"bordered\" [nzSize]=\"size\"\n [nzLoading]=\"loading\" [nzLoadingDelay]=\"loadingDelay\" [nzScroll]=\"scroll\" [nzTitle]=\"header\" [nzFooter]=\"footer\" [nzNoResult]=\"noResult\"\n [nzPageSizeOptions]=\"pageSizeOptions\" [nzShowQuickJumper]=\"showQuickJumper\" [nzShowSizeChanger]=\"showSizeChanger\" [nzShowTotal]=\"totalTpl\">\n <thead class=\"ad-st-head\">\n <tr>\n <th *ngIf=\"expand\" [nzShowExpand]=\"expand\"></th>\n <th *ngFor=\"let c of _columns; let index=index\" [nzWidth]=\"c.width\" [nzLeft]=\"c._left\" [nzRight]=\"c._right\" [ngClass]=\"c.className\"\n [attr.colspan]=\"c.colSpan\" [attr.data-col]=\"c.indexKey\" [nzShowSort]=\"_sortMap[index].enabled\" [nzSort]=\"_sortMap[index].v\"\n (nzSortChange)=\"sort(index, $event)\">\n <ng-template #renderTitle [ngTemplateOutlet]=\"c.__renderTitle\" [ngTemplateOutletContext]=\"{$implicit: c, index: index }\"></ng-template>\n <ng-container *ngIf=\"!c.__renderTitle; else renderTitle\">\n <ng-container [ngSwitch]=\"c.type\">\n <ng-container *ngSwitchCase=\"'checkbox'\">\n <label nz-checkbox class=\"ad-st-checkall\" [(ngModel)]=\"_allChecked\" [nzIndeterminate]=\"_indeterminate\" (ngModelChange)=\"_checkAll()\"></label>\n <nz-dropdown *ngIf=\"c.selections.length\" class=\"ad-st-checkselection\">\n <span nz-dropdown>\n <i class=\"anticon anticon-down\"></i>\n </span>\n <ul nz-menu>\n <li nz-menu-item *ngFor=\"let rw of c.selections\" (click)=\"_rowSelection(rw)\" [innerHTML]=\"rw.text\">\n </li>\n </ul>\n </nz-dropdown>\n </ng-container>\n <ng-container *ngSwitchDefault>\n <span [innerHTML]=\"c.title\"></span>\n </ng-container>\n </ng-container>\n <nz-dropdown class=\"ad-st-filter\" *ngIf=\"c.filters.length > 0\" nzTrigger=\"click\" [hasFilterButton]=\"true\" [nzClickHide]=\"false\"\n [(nzVisible)]=\"c.filterVisible\">\n <i class=\"{{c.filterIcon}}\" [ngClass]=\"{'ant-table-filter-selected': c.filtered}\" nz-dropdown></i>\n <ul nz-menu>\n <ng-container *ngIf=\"c.filterMultiple\">\n <li nz-menu-item *ngFor=\"let filter of c.filters\">\n <label nz-checkbox [(ngModel)]=\"filter.checked\">{{filter.text}}</label>\n </li>\n </ng-container>\n <ng-container *ngIf=\"!c.filterMultiple\">\n <li nz-menu-item *ngFor=\"let filter of c.filters\">\n <label nz-radio [ngModel]=\"filter.checked\" (ngModelChange)=\"filterRadio(c, filter, $event)\">{{filter.text}}</label>\n </li>\n </ng-container>\n </ul>\n <div class=\"ant-table-filter-dropdown-btns\">\n <a class=\"ant-table-filter-dropdown-link confirm\" (click)=\"c.filterVisible = false\">\n <span (click)=\"filterConfirm(c)\">{{c.filterConfirmText}}</span>\n </a>\n <a class=\"ant-table-filter-dropdown-link clear\" (click)=\"c.filterVisible = false\">\n <span (click)=\"filterClear(c)\">{{c.filterClearText}}</span>\n </a>\n </div>\n </nz-dropdown>\n </ng-container>\n </th>\n </tr>\n </thead>\n <tbody class=\"ad-st-body\">\n <ng-container *ngFor=\"let i of _data; let index=index\">\n <tr [attr.data-index]=\"index\">\n <td *ngIf=\"expand\" [nzShowExpand]=\"expand\" [(nzExpand)]=\"i.expand\"></td>\n <td *ngFor=\"let c of _columns; let cIdx=index\" [nzLeft]=\"c._left\" [nzRight]=\"c._right\" [nzCheckbox]=\"c.type === 'checkbox'\" [ngClass]=\"c.className\"\n [attr.colspan]=\"c.colSpan\">\n <ng-template #render [ngTemplateOutlet]=\"c.__render\" [ngTemplateOutletContext]=\"{$implicit: i, index: index, column: c }\"></ng-template>\n <ng-container *ngIf=\"!c.__render; else render\">\n <ng-container *ngIf=\"c.index\" [ngSwitch]=\"c.type\">\n <ng-container *ngSwitchCase=\"'checkbox'\">\n <label nz-checkbox [nzDisabled]=\"i.disabled\" [ngModel]=\"i.checked\" (ngModelChange)=\"_checkSelection(i, $event)\"></label>\n </ng-container>\n <ng-container *ngSwitchCase=\"'radio'\">\n <label nz-radio [nzDisabled]=\"i.disabled\" [ngModel]=\"i.checked\" (ngModelChange)=\"_refRadio($event, i)\"></label>\n </ng-container>\n <ng-container *ngSwitchCase=\"'link'\">\n <a (click)=\"_click($event, i, c)\" [innerHTML]=\"i._values[cIdx]\"></a>\n </ng-container>\n <ng-container *ngSwitchCase=\"'tag'\">\n <nz-tag [nzColor]=\"c.tag[i._values[cIdx]].color\">{{c.tag[i._values[cIdx]].text || i._values[cIdx]}}</nz-tag>\n </ng-container>\n <ng-container *ngSwitchCase=\"'badge'\">\n <nz-badge [nzStatus]=\"c.badge[i._values[cIdx]].color\" [nzText]=\"c.badge[i._values[cIdx]].text || i._values[cIdx]\"></nz-badge>\n </ng-container>\n <span *ngSwitchDefault [innerHTML]=\"i._values[cIdx]\"></span>\n </ng-container>\n <ng-container *ngFor=\"let btn of c.buttons; let last=last\">\n <ng-container *ngIf=\"btn.iif(i, btn, c)\" [ngSwitch]=\"btn._type\">\n <ng-container *ngSwitchCase=\"2\">\n <nz-popconfirm [nzTitle]=\"btn.popTitle\" (nzOnConfirm)=\"btnClick(i, btn)\">\n <a nz-popconfirm [innerHTML]=\"btnText(i, btn)\"></a>\n </nz-popconfirm>\n </ng-container>\n <ng-container *ngSwitchCase=\"3\">\n <nz-dropdown>\n <a class=\"ant-dropdown-link\" nz-dropdown>\n <span [innerHTML]=\"btnText(i, btn)\"></span>\n <i class=\"anticon anticon-down\"></i>\n </a>\n <ul nz-menu>\n <ng-container *ngFor=\"let subBtn of btn.children\">\n <li nz-menu-item *ngIf=\"subBtn.iif(i, subBtn, c)\">\n <nz-popconfirm *ngIf=\"subBtn._type === 2\" [nzTitle]=\"subBtn.popTitle\" (nzOnConfirm)=\"btnClick(i, subBtn)\">\n <a nz-popconfirm [innerHTML]=\"btnText(i, subBtn)\"></a>\n </nz-popconfirm>\n <a *ngIf=\"subBtn._type !== 2\" (click)=\"btnClick(i, subBtn)\" [innerHTML]=\"btnText(i, subBtn)\"></a>\n </li>\n </ng-container>\n </ul>\n </nz-dropdown>\n </ng-container>\n <a *ngSwitchDefault (click)=\"btnClick(i, btn)\" [innerHTML]=\"btnText(i, btn)\"></a>\n <nz-divider *ngIf=\"!last\" nzType=\"vertical\"></nz-divider>\n </ng-container>\n </ng-container>\n <ng-template [ngIf]=\"!c.__renderExpanded\" [ngTemplateOutlet]=\"c.__renderExpanded\" [ngTemplateOutletContext]=\"{$implicit: i, index: index, column: c }\"></ng-template>\n </ng-container>\n </td>\n </tr>\n <tr [nzExpand]=\"i.expand\">\n <td></td>\n <td [attr.colspan]=\"_columns.length\">\n <ng-template [ngTemplateOutlet]=\"expand\" [ngTemplateOutletContext]=\"{$implicit: i, index: index, column: c }\"></ng-template>\n </td>\n </tr>\n </ng-container>\n <ng-template [ngIf]=\"!loading\" [ngTemplateOutlet]=\"body\"></ng-template>\n </tbody>\n <ng-template #totalTpl let-range=\"range\" let-total>{{ renderTotal(total, range) }}</ng-template>\n</nz-table>\n\n ",
// templateUrl: './simple-table.component.html',
host: { '[class.ad-st]': 'true' },
providers: [SimpleTableExport, theme.CNCurrencyPipe, theme.DatePipe, theme.YNPipe, i3.DecimalPipe],
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
SimpleTableComponent.ctorParameters = function () { return [
{ type: AdSimpleTableConfig },
{ type: i1.HttpClient },
{ type: router.Router },
{ type: i0.ElementRef },
{ type: i0.Renderer2 },
{ type: SimpleTableExport },
{ type: theme.ModalHelper },
{ type: theme.CNCurrencyPipe },
{ type: theme.DatePipe },
{ type: theme.YNPipe },
{ type: i3.DecimalPipe },
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.DOCUMENT,] }] }
]; };
SimpleTableComponent.propDecorators = {
data: [{ type: i0.Input }],
extraParams: [{ type: i0.Input }],
reqMethod: [{ type: i0.Input }],
reqBody: [{ type: i0.Input }],
reqHeaders: [{ type: i0.Input }],
reqReName: [{ type: i0.Input }],
reqError: [{ type: i0.Output }],
resReName: [{ type: i0.Input }],
columns: [{ type: i0.Input }],
ps: [{ type: i0.Input }],
pi: [{ type: i0.Input }],
total: [{ type: i0.Input }],
showPagination: [{ type: i0.Input }],
loading: [{ type: i0.Input }],
loadingDelay: [{ type: i0.Input }],
bordered: [{ type: i0.Input }],
size: [{ type: i0.Input }],
scroll: [{ type: i0.Input }],
showSizeChanger: [{ type: i0.Input }],
pageSizeOptions: [{ type: i0.Input }],
showQuickJumper: [{ type: i0.Input }],
showTotal: [{ type: i0.Input }],
frontPagination: [{ type: i0.Input }],
isPageIndexReset: [{ type: i0.Input }],
pagePlacement: [{ type: i0.Input }],
toTopInChange: [{ type: i0.Input }],
toTopOffset: [{ type: i0.Input }],
sortReName: [{ type: i0.Input }],
multiSort: [{ type: i0.Input }],
preDataChange: [{ type: i0.Input }],
header: [{ type: i0.ContentChild, args: ['header',] }],
body: [{ type: i0.ContentChild, args: ['body',] }],
footer: [{ type: i0.ContentChild, args: ['footer',] }],
expand: [{ type: i0.ContentChild, args: ['expand',] }],
noResult: [{ type: i0.Input }],
widthConfig: [{ type: i0.Input }],
change: [{ type: i0.Output }],
checkboxChange: [{ type: i0.Output }],
radioChange: [{ type: i0.Output }],
sortChange: [{ type: i0.Output }],
filterChange: [{ type: i0.Output }],
zeroIndexedOnPage: [{ type: i0.Input }]
};
return SimpleTableComponent;
}());
var SimpleTableRowDirective = /** @class */ (function () {
function SimpleTableRowDirective(templateRef, table) {
this.templateRef = templateRef;
this.table = table;
}
SimpleTableRowDirective.prototype.ngOnInit = function () {
var _this = this;
var col = this.table._columns.find(function (w) { return w.render === _this.id; });
if (!col)
return;
switch (this.type) {
case 'title':
col.__renderTitle = this.templateRef;
break;
default:
col.__render = this.templateRef;
break;
}
};
SimpleTableRowDirective.decorators = [
{ type: i0.Directive, args: [{
selector: '[st-row]',
},] },
];
/** @nocollapse */
SimpleTableRowDirective.ctorParameters = function () { return [
{ type: i0.TemplateRef },
{ type: SimpleTableComponent }
]; };
SimpleTableRowDirective.propDecorators = {
id: [{ type: i0.Input, args: ['st-row',] }],
type: [{ type: i0.Input }]
};
return SimpleTableRowDirective;
}());
var COMPONENTS$15 = [SimpleTableComponent, SimpleTableRowDirective];
var ZORROMODULES$3 = [i1$1.NgZorroAntdModule];
// endregion
var AdSimpleTableModule = /** @class */ (function () {
function AdSimpleTableModule() {
}
AdSimpleTableModule.forRoot = function () {
return { ngModule: AdSimpleTableModule, providers: [AdSimpleTableConfig] };
};
AdSimpleTableModule.decorators = [
{ type: i0.NgModule, args: [{
schemas: [i0.NO_ERRORS_SCHEMA],
imports: [i3.CommonModule, forms.FormsModule, util.DelonUtilModule].concat(ZORROMODULES$3),
declarations: COMPONENTS$15.slice(),
exports: COMPONENTS$15.slice(),
},] },
];
return AdSimpleTableModule;
}());
/**
* 复用匹配模式
*/
(function (ReuseTabMatchMode) {
/**
* (推荐)按菜单 `Menu` 配置
*
* 可复用:
* - `{ text:'Dashboard' }`
* - `{ text:'Dashboard', reuse: true }`
*
* 不可复用:
* - `{ text:'Dashboard', reuse: false }`
*/
ReuseTabMatchMode[ReuseTabMatchMode["Menu"] = 0] = "Menu";
/**
* 按菜单 `Menu` 强制配置
*
* 可复用:
* - `{ text:'Dashboard', reuse: true }`
*
* 不可复用:
* - `{ text:'Dashboard' }`
* - `{ text:'Dashboard', reuse: false }`
*/
ReuseTabMatchMode[ReuseTabMatchMode["MenuForce"] = 1] = "MenuForce";
/**
* 对所有路由有效,可以配合 `excludes` 过滤无须复用路由
*/
ReuseTabMatchMode[ReuseTabMatchMode["URL"] = 2] = "URL";
})(exports.ReuseTabMatchMode || (exports.ReuseTabMatchMode = {}));
var MenuService = /** @class */ (function () {
/**
* 构造函数
* @param _permissionService 权限检测服务
*/
function MenuService(_permissionService, _localizationService) {
this._permissionService = _permissionService;
this._localizationService = _localizationService;
this.data = [];
this._change$ = new rxjs.BehaviorSubject([]);
}
Object.defineProperty(MenuService.prototype, "menus", {
get: function () {
return this.data;
},
set: function (items) {
this.data = items;
this.processMenu(this.data);
},
enumerable: true,
configurable: true
});
/**
* 处理菜单信息
* @param menus 菜单
*/
MenuService.prototype.processMenu = function (menus) {
var _this = this;
menus.forEach(function (item) {
item.name = _this._localizationService.l(item.name);
// 权限校验设置隐藏
if (item.permissionName != '' && item.isDisplay) {
item.isDisplay = _this._permissionService.isGranted(item.permissionName);
}
if (item.items && item.items.length > 0) {
_this.processMenu(item.items);
}
});
};
/**
* 清空菜单
*/
MenuService.prototype.clear = function () {
this.data = [];
};
/**
* 根据URL设置菜单 `_open` 属性
* @param url URL地址
*/
MenuService.prototype.openedByUrl = function (url) {
if (!url)
return;
};
/**
* 根据url获取菜单列表
* @param url
*/
MenuService.prototype.getPathByUrl = function (url) {
var result = [];
this.findMenuItem(url, this.data, result);
result.reverse();
return result;
};
MenuService.prototype.findMenuItem = function (url, items, result) {
var item;
for (var i = 0; i < items.length; i++) {
item = items[i];
if (item.items && item.items.length) {
if (this.findMenuItem(url, item.items, result)) {
result.push(item);
return true;
}
}
if (item.route === url || (!(item.items && item.items.length) && url.startsWith(item.route))) {
result.push(item);
return true;
}
}
};
/**
* 获取当前菜单项
* @param url 当前路由地址
*/
MenuService.prototype.getMenuByUrl = function (url) {
var menus = this.getPathByUrl(url);
if (!menus || menus.length === 0)
return null;
return menus.pop();
};
Object.defineProperty(MenuService.prototype, "change", {
get: function () {
return this._change$.pipe(operators.share());
},
enumerable: true,
configurable: true
});
MenuService.prototype.visit = function (callback) {
var inFn = function (list, parentMenu, depth) {
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
var item = list_1[_i];
callback(item, parentMenu, depth);
if (item.items && item.items.length > 0) {
inFn(item.items, item, depth + 1);
}
else {
item.items = [];
}
}
};
inFn(this.data, null, 0);
};
MenuService.prototype.ngOnDestroy = function () {
this._change$.unsubscribe();
};
MenuService.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
MenuService.ctorParameters = function () { return [
{ type: permissionChecker_service.PermissionCheckerService },
{ type: localization_service$1.LocalizationService }
]; };
return MenuService;
}());
/**
* 路由复用类,提供复用所需要一些基本接口
*
* **注:** 所有缓存数据来源于路由离开后才会产生
*/
var ReuseTabService = /** @class */ (function () {
// endregion
function ReuseTabService(injector, menuService) {
this.injector = injector;
this.menuService = menuService;
this._max = 10;
this._debug = false;
this._mode = exports.ReuseTabMatchMode.Menu;
this._excludes = [];
this._cachedChange = new rxjs.BehaviorSubject(null);
this._cached = [];
this._titleCached = {};
this._closableCached = {};
}
Object.defineProperty(ReuseTabService.prototype, "curUrl", {
// region: public
/** 当前路由地址 */
get: function () {
return this.getUrl(this.injector.get(router.ActivatedRoute).snapshot);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabService.prototype, "max", {
/** 允许最多复用多少个页面,取值范围 `2-100` */
set: function (value) {
this._max = Math.min(Math.max(value, 2), 100);
for (var i = this._cached.length; i > this._max; i--) {
this._cached.pop();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabService.prototype, "mode", {
get: function () {
return this._mode;
},
/** 设置匹配模式 */
set: function (value) {
this._mode = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabService.prototype, "debug", {
get: function () {
return this._debug;
},
/** 设置Debug模式 */
set: function (value) {
this._debug = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabService.prototype, "excludes", {
get: function () {
return this._excludes;
},
/** 排除规则,限 `mode=URL` */
set: function (values) {
if (!values)
return;
this._excludes = values;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabService.prototype, "items", {
/** 获取已缓存的路由 */
get: function () {
return this._cached;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabService.prototype, "count", {
/** 获取当前缓存的路由总数 */
get: function () {
return this._cached.length;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabService.prototype, "change", {
/** 订阅缓存变更通知 */
get: function () {
return this._cachedChange.asObservable(); // .pipe(filter(w => w !== null));
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabService.prototype, "title", {
/** 自定义当前标题 */
set: function (value) {
var url = this.curUrl;
if (typeof value === 'string')
value = { text: value };
this._titleCached[url] = value;
this.di('update current tag title: ', value);
this._cachedChange.next({
active: 'title',
title: value,
list: this._cached,
});
},
enumerable: true,
configurable: true
});
/** 获取指定路径缓存所在位置,`-1` 表示无缓存 */
ReuseTabService.prototype.index = function (url) {
return this._cached.findIndex(function (w) { return w.url === url; });
};
/** 获取指定路径缓存是否存在 */
ReuseTabService.prototype.exists = function (url) {
return this.index(url) !== -1;
};
/** 获取指定路径缓存 */
ReuseTabService.prototype.get = function (url) {
return url ? this._cached.find(function (w) { return w.url === url; }) || null : null;
};
ReuseTabService.prototype.remove = function (url, includeNonCloseable) {
var idx = typeof url === 'string' ? this.index(url) : url;
var item = idx !== -1 ? this._cached[idx] : null;
if (!item || (!includeNonCloseable && !item.closable))
return false;
this.destroy(item._handle);
this._cached.splice(idx, 1);
delete this._titleCached[url];
return true;
};
/**
* 根据URL移除标签
*
* @param [includeNonCloseable=false] 是否强制包含不可关闭
*/
ReuseTabService.prototype.close = function (url, includeNonCloseable) {
if (includeNonCloseable === void 0) { includeNonCloseable = false; }
this.removeUrlBuffer = url;
this.remove(url, includeNonCloseable);
this._cachedChange.next({ active: 'close', url: url, list: this._cached });
this.di('close tag', url);
return true;
};
/**
* 根据URL关闭其他标签
* @param url 当前URL
* @param includeNonCloseable [includeNonCloseable=false] 是否强制包含不可关闭
*/
ReuseTabService.prototype.closeOther = function (url, includeNonCloseable) {
var _this = this;
if (includeNonCloseable === void 0) { includeNonCloseable = false; }
this._cached.forEach(function (w) {
if (w.url !== url) {
if (!includeNonCloseable && w.closable)
_this.destroy(w._handle);
}
});
//过滤出当前标签,其他标签已经关闭,只显示当前标签
this._cached = this._cached.filter(function (w) { return w.url === url; });
this.removeUrlBuffer = null;
this._cachedChange.next({ active: 'closeOther', list: this._cached });
};
/**
* 清除右边
*
* @param [includeNonCloseable=false] 是否强制包含不可关闭
*/
ReuseTabService.prototype.closeRight = function (url, includeNonCloseable) {
if (includeNonCloseable === void 0) { includeNonCloseable = false; }
var start = this.index(url);
for (var i = this.count - 1; i > start; i--) {
this.remove(i, includeNonCloseable);
}
this.removeUrlBuffer = null;
this._cachedChange.next({ active: 'closeRight', url: url, list: this._cached });
this.di('close right tages', url);
return true;
};
/**
* 清除所有缓存
*
* @param [includeNonCloseable=false] 是否强制包含不可关闭
*/
ReuseTabService.prototype.clear = function (includeNonCloseable) {
var _this = this;
if (includeNonCloseable === void 0) { includeNonCloseable = false; }
this._cached.forEach(function (w) {
if (!includeNonCloseable && w.closable)
_this.destroy(w._handle);
});
this._cached = this._cached.filter(function (w) { return !includeNonCloseable && !w.closable; });
this.removeUrlBuffer = null;
this._cachedChange.next({ active: 'clear', list: this._cached });
this.di('clear all catch');
};
/**
* 移动缓存数据
* @param url 要移动的URL地址
* @param position 新位置,下标从 `0` 开始
*
* @example
* ```
* // source
* [ '/a/1', '/a/2', '/a/3', '/a/4', '/a/5' ]
* move('/a/1', 2);
* // output
* [ '/a/2', '/a/3', '/a/1', '/a/4', '/a/5' ]
* move('/a/1', -1);
* // output
* [ '/a/2', '/a/3', '/a/4', '/a/5', '/a/1' ]
* ```
*/
ReuseTabService.prototype.move = function (url, position) {
var start = this._cached.findIndex(function (w) { return w.url === url; });
if (start === -1)
return;
var data = this._cached.slice();
data.splice(position < 0 ? data.length + position : position, 0, data.splice(start, 1)[0]);
this._cached = data;
this._cachedChange.next({
active: 'move',
url: url,
position: position,
list: this._cached,
});
};
/**
* 强制关闭当前路由(包含不可关闭状态),并重新导航至 `newUrl` 路由
*/
ReuseTabService.prototype.replace = function (newUrl) {
var url = this.curUrl;
if (this.exists(url)) {
this.close(url, true);
}
else {
this.removeUrlBuffer = url;
}
this.injector.get(router.Router).navigateByUrl(newUrl);
};
/**
* 获取标题,顺序如下:
*
* 1. 组件内使用 `ReuseTabService.title = 'new title'` 重新指定文本
* 2. 路由配置中 data 属性中包含 titleI18n > title
* 3. 菜单数据中 text 属性
*
* @param url 指定URL
* @param route 指定路由快照
*/
ReuseTabService.prototype.getTitle = function (url, route) {
if (this._titleCached[url])
return this._titleCached[url];
if (route && route.data && (route.data.titleI18n || route.data.title))
return { text: route.data.title, i18n: route.data.titleI18n };
var menu = this.mode !== exports.ReuseTabMatchMode.URL ? this.getMenu(url) : null;
return menu ? { text: menu.name, i18n: menu.name } : { text: url };
};
/**
* 获取菜单对应的图标,如果为空,返回anticon-appstore-o图标
* @param url 路由地址
* @param route 当前激活路由
*/
ReuseTabService.prototype.getIcon = function (url, route) {
var menu = this.mode !== exports.ReuseTabMatchMode.URL ? this.getMenu(url) : null;
return menu ? menu.icon : 'anticon anticon-appstore-o';
};
/**
* 清除标题缓存
*/
ReuseTabService.prototype.clearTitleCached = function () {
this._titleCached = {};
};
Object.defineProperty(ReuseTabService.prototype, "closable", {
/** 自定义当前 `closable` 状态 */
set: function (value) {
var url = this.curUrl;
this._closableCached[url] = value;
this.di('update current tag closable: ', value);
this._cachedChange.next({
active: 'closable',
closable: value,
list: this._cached,
});
},
enumerable: true,
configurable: true
});
/**
* 获取 `closable` 状态,顺序如下:
*
* 1. 组件内使用 `ReuseTabService.closable = true` 重新指定 `closable` 状态
* 2. 路由配置中 data 属性中包含 `reuseClosable`
* 3. 菜单数据中 `reuseClosable` 属性
*
* @param url 指定URL
* @param route 指定路由快照
*/
ReuseTabService.prototype.getClosable = function (url, route) {
if (typeof this._closableCached[url] !== 'undefined')
return this._closableCached[url];
if (route && route.data && typeof route.data.reuseClosable === 'boolean')
return route.data.reuseClosable;
var menu = this.mode !== exports.ReuseTabMatchMode.URL ? this.getMenu(url) : null;
if (menu && typeof menu.reuseClosable === 'boolean')
return menu.reuseClosable;
return true;
};
/**
* 清空 `closable` 缓存
*/
ReuseTabService.prototype.clearClosableCached = function () {
this._closableCached = {};
};
ReuseTabService.prototype.getTruthRoute = function (route) {
var next = route;
while (next.firstChild)
next = next.firstChild;
return next;
};
/**
* 根据快照获取URL地址
*/
ReuseTabService.prototype.getUrl = function (route) {
var next = this.getTruthRoute(route);
var segments = [];
while (next) {
segments.push(next.url.join('/'));
next = next.parent;
}
var url = '/' +
segments
.filter(function (i) { return i; })
.reverse()
.join('/');
return url;
};
/**
* 检查快照是否允许被复用
*/
ReuseTabService.prototype.can = function (route) {
var url = this.getUrl(route);
if (url === this.removeUrlBuffer)
return false;
if (route.data && typeof route.data.reuse === 'boolean')
return route.data.reuse;
if (this.mode !== exports.ReuseTabMatchMode.URL) {
var menu = this.getMenu(url);
if (!menu)
return false;
if (this.mode === exports.ReuseTabMatchMode.Menu) {
if (menu.reuse === false)
return false;
}
else {
if (!menu.reuse || menu.reuse !== true)
return false;
}
return true;
}
return this._excludes.findIndex(function (r) { return r.test(url); }) === -1;
};
/**
* 刷新,触发一个 refresh 类型事件
*/
ReuseTabService.prototype.refresh = function (data) {
this._cachedChange.next({ active: 'refresh', data: data });
};
// endregion
// region: privates
ReuseTabService.prototype.destroy = function (_handle) {
if (_handle && _handle.componentRef && _handle.componentRef.destroy)
_handle.componentRef.destroy();
};
ReuseTabService.prototype.di = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (!this.debug)
return;
// tslint:disable-next-line:no-console
console.warn.apply(console, args);
};
ReuseTabService.prototype.getMenu = function (url) {
var menus = this.menuService ? this.menuService.getPathByUrl(url) : [];
if (!menus || menus.length === 0)
return null;
return menus.pop();
};
ReuseTabService.prototype.runHook = function (method, url, comp) {
if (comp.instance && typeof comp.instance[method] === 'function')
comp.instance[method]();
};
ReuseTabService.prototype.hasInValidRoute = function (route) {
return (!route.routeConfig ||
route.routeConfig.loadChildren ||
route.routeConfig.children);
};
/**
* 决定是否允许路由复用,若 `true` 会触发 `store`
*/
ReuseTabService.prototype.shouldDetach = function (route) {
if (this.hasInValidRoute(route))
return false;
this.di('#shouldDetach', this.can(route), this.getUrl(route));
return this.can(route);
};
/**
* 存储
*/
ReuseTabService.prototype.store = function (_snapshot, _handle) {
if (this.count >= this._max)
this._cached.shift();
var url = this.getUrl(_snapshot);
var idx = this.index(url);
var item = {
title: this.getTitle(url, _snapshot),
closable: this.getClosable(url, _snapshot),
url: url,
_snapshot: _snapshot,
_handle: _handle,
};
if (idx === -1) {
this._cached.push(item);
}
else {
this._cached[idx] = item;
}
this.removeUrlBuffer = null;
this.di('#store', idx === -1 ? '[new]' : '[override]', url);
if (_handle && _handle.componentRef) {
this.runHook('_onReuseDestroy', url, _handle.componentRef);
}
this._cachedChange.next({ active: 'add', item: item, list: this._cached });
};
/**
* 决定是否允许应用缓存数据
*/
ReuseTabService.prototype.shouldAttach = function (route) {
if (this.hasInValidRoute(route))
return false;
var url = this.getUrl(route);
var data = this.get(url);
var ret = !!(data && data._handle);
this.di('#shouldAttach', ret, url);
if (ret && data._handle.componentRef) {
this.runHook('_onReuseInit', url, data._handle.componentRef);
}
return ret;
};
/**
* 提取复用数据
*/
ReuseTabService.prototype.retrieve = function (route) {
if (this.hasInValidRoute(route))
return null;
var url = this.getUrl(route);
var data = this.get(url);
var ret = (data && data._handle) || null;
this.di('#retrieve', url, ret);
return ret;
};
/**
* 决定是否应该进行复用路由处理
*/
ReuseTabService.prototype.shouldReuseRoute = function (future, curr) {
var ret = future.routeConfig === curr.routeConfig;
if (!ret)
return false;
var path = ((future.routeConfig && future.routeConfig.path) ||
'');
if (path.length > 0 && ~path.indexOf(':')) {
var futureUrl = this.getUrl(future);
var currUrl = this.getUrl(curr);
ret = futureUrl === currUrl;
}
this.di('=====================');
this.di('#shouldReuseRoute', ret, this.getUrl(curr) + "=>" + this.getUrl(future), future, curr);
return ret;
};
ReuseTabService.prototype.ngOnDestroy = function () {
this._cached = [];
this._cachedChange.unsubscribe();
};
ReuseTabService.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
/** @nocollapse */
ReuseTabService.ctorParameters = function () { return [
{ type: i0.Injector },
{ type: theme.MenuService, decorators: [{ type: i0.Optional }] }
]; };
ReuseTabService.ngInjectableDef = i0.defineInjectable({ factory: function ReuseTabService_Factory() { return new ReuseTabService(i0.inject(i0.INJECTOR), i0.inject(MenuService, 8)); }, token: ReuseTabService, providedIn: "root" });
return ReuseTabService;
}());
var ReuseTabContextMenuComponent = /** @class */ (function () {
function ReuseTabContextMenuComponent() {
this.close = new i0.EventEmitter();
}
Object.defineProperty(ReuseTabContextMenuComponent.prototype, "i18n", {
get: function () {
return this._i18n;
},
set: function (value) {
this._i18n = Object.assign({
close: '关闭标签',
closeOther: '关闭其它标签',
closeRight: '关闭右侧标签',
clear: '清空',
}, value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabContextMenuComponent.prototype, "includeNonCloseable", {
get: function () {
return this.event.ctrlKey;
},
enumerable: true,
configurable: true
});
ReuseTabContextMenuComponent.prototype.notify = function (type, item) {
this.close.next({
type: type,
item: this.item,
includeNonCloseable: this.includeNonCloseable,
});
};
ReuseTabContextMenuComponent.prototype.ngOnInit = function () {
if (this.includeNonCloseable)
this.item.closable = true;
};
ReuseTabContextMenuComponent.prototype.click = function (e, type) {
e.preventDefault();
e.stopPropagation();
if (type === 'close' && !this.item.closable)
return;
if (type === 'closeRight' && this.item.last)
return;
this.notify(type, this.item);
};
ReuseTabContextMenuComponent.prototype.closeMenu = function (event) {
if (event.type === 'click' && event.button === 2)
return;
this.notify(null, null);
};
ReuseTabContextMenuComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'reuse-tab-context-menu',
template: "\n <ul nz-menu>\n <li nz-menu-item (click)=\"click($event, 'close')\" data-type=\"close\" [nzDisabled]=\"!item.closable\" [innerHTML]=\"i18n.close\"></li>\n <li nz-menu-item (click)=\"click($event, 'closeOther')\" data-type=\"closeOther\" [innerHTML]=\"i18n.closeOther\"></li>\n <li nz-menu-item (click)=\"click($event, 'closeRight')\" data-type=\"closeRight\" [nzDisabled]=\"item.last\" [innerHTML]=\"i18n.closeRight\"></li>\n <li nz-menu-item (click)=\"click($event, 'clear')\" data-type=\"clear\" [innerHTML]=\"i18n.clear\"></li>\n </ul>",
preserveWhitespaces: false,
},] },
];
ReuseTabContextMenuComponent.propDecorators = {
i18n: [{ type: i0.Input }],
item: [{ type: i0.Input }],
event: [{ type: i0.Input }],
close: [{ type: i0.Output }],
closeMenu: [{ type: i0.HostListener, args: ['document:click', ['$event'],] }, { type: i0.HostListener, args: ['document:contextmenu', ['$event'],] }]
};
return ReuseTabContextMenuComponent;
}());
var ReuseTabContextService = /** @class */ (function () {
function ReuseTabContextService(overlay$$1) {
this.overlay = overlay$$1;
this.show = new rxjs.Subject();
this.close = new rxjs.Subject();
}
ReuseTabContextService.prototype.remove = function () {
if (!this.ref)
return;
this.ref.detach();
this.ref.dispose();
this.ref = null;
};
ReuseTabContextService.prototype.open = function (context) {
var _this = this;
this.remove();
var event = context.event, item = context.item;
var fakeElement = new i0.ElementRef({
getBoundingClientRect: function () { return ({
bottom: event.clientY,
height: 0,
left: event.clientX,
right: event.clientX,
top: event.clientY,
width: 0,
}); },
});
var positions = [
new overlay.ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'top' }),
new overlay.ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' }),
];
var positionStrategy = this.overlay
.position()
.flexibleConnectedTo(fakeElement)
.withPositions(positions);
this.ref = this.overlay.create({
positionStrategy: positionStrategy,
panelClass: 'reuse-tab-cm',
scrollStrategy: this.overlay.scrollStrategies.close(),
});
var comp = this.ref.attach(new portal.ComponentPortal(ReuseTabContextMenuComponent));
var instance = comp.instance;
instance.i18n = this.i18n;
instance.item = tslib_1.__assign({}, item);
instance.event = event;
var sub$ = new rxjs.Subscription();
sub$.add(instance.close.subscribe(function (res) {
_this.close.next(res);
_this.remove();
}));
comp.onDestroy(function () { return sub$.unsubscribe(); });
};
ReuseTabContextService.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
ReuseTabContextService.ctorParameters = function () { return [
{ type: overlay.Overlay }
]; };
return ReuseTabContextService;
}());
var ReuseTabComponent = /** @class */ (function () {
function ReuseTabComponent(srv, cd, router$$1, route, el, render, doc, localizationService, nzDropdownService //右键菜单
) {
var _this = this;
this.srv = srv;
this.cd = cd;
this.router = router$$1;
this.route = route;
this.el = el;
this.render = render;
this.doc = doc;
this.localizationService = localizationService;
this.nzDropdownService = nzDropdownService; //右键菜单
this.list = [];
this.pos = 0;
// region: properties
/** 设置匹配模式 */
this.mode = exports.ReuseTabMatchMode.Menu;
this._debug = false;
this._allowClose = true;
this._fixed = true;
this._showCurrent = true;
/** 切换时回调 */
this.change = new i0.EventEmitter();
/** 关闭回调 */
this.close = new i0.EventEmitter();
var route$ = this.router.events.pipe(operators.filter(function (evt) { return evt instanceof router.NavigationEnd; }));
this.sub$ = rxjs.combineLatest(this.srv.change, route$).subscribe(function (_a) {
var res = _a[0], e = _a[1];
return _this.genList(res);
});
}
Object.defineProperty(ReuseTabComponent.prototype, "debug", {
/** 是否Debug模式 */
get: function () { return this._debug; },
set: function (value) {
this._debug = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabComponent.prototype, "max", {
/** 允许最多复用多少个页面 */
get: function () {
return this._max;
},
set: function (value) {
this._max = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabComponent.prototype, "allowClose", {
/** 允许关闭 */
get: function () {
return this._allowClose;
},
set: function (value) {
this._allowClose = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabComponent.prototype, "fixed", {
/** 是否固定 */
get: function () {
return this._fixed;
},
set: function (value) {
this._fixed = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReuseTabComponent.prototype, "showCurrent", {
/** 总是显示当前页 */
get: function () {
return this._showCurrent;
},
set: function (value) {
this._showCurrent = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
ReuseTabComponent.prototype.genTit = function (title) {
return title.text;
};
ReuseTabComponent.prototype.genList = function (notify) {
var _this = this;
var isClosed = notify && notify.active === 'close';
var beforeClosePos = isClosed
? this.list.findIndex(function (w) { return w.url === notify.url; })
: -1;
var ls = this.srv.items.map(function (item, index) {
return {
url: item.url,
title: _this.genTit(item.title),
closable: _this.allowClose && item.closable && _this.srv.count > 0,
index: index,
active: false,
last: false,
icon: _this.srv.getIcon(item.url)
};
});
if (this.showCurrent) {
var snapshot = this.route.snapshot;
var url_1 = this.srv.getUrl(snapshot);
var idx = ls.findIndex(function (w) { return w.url === url_1; });
// jump directly when the current exists in the list
// or create a new current item and jump
if (idx !== -1 || (isClosed && notify.url === url_1)) {
this.pos = isClosed
? idx >= beforeClosePos
? this.pos - 1
: this.pos
: idx;
}
else {
var snapshotTrue = this.srv.getTruthRoute(snapshot);
ls.push({
url: url_1,
title: this.genTit(this.srv.getTitle(url_1, snapshotTrue)),
closable: this.allowClose &&
this.srv.count > 0 &&
this.srv.getClosable(url_1, snapshotTrue),
index: ls.length,
active: false,
last: false,
icon: this.srv.getIcon(url_1)
});
this.pos = ls.length - 1;
}
// fix unabled close last item
if (ls.length <= 1)
ls[0].closable = false;
}
this.list = ls;
if (ls.length && isClosed) {
this.to(null, this.pos);
}
this.refStatus(false);
this.visibility();
this.cd.detectChanges();
};
ReuseTabComponent.prototype.visibility = function () {
if (this.showCurrent)
return;
this.render.setStyle(this.el.nativeElement, 'display', this.list.length === 0 ? 'none' : 'block');
};
// region: UI
ReuseTabComponent.prototype.cmChange = function (res) {
switch (res.type) {
case 'close':
this._close(null, res.item.index, res.includeNonCloseable);
break;
case 'closeRight':
this.srv.closeRight(res.item.url, res.includeNonCloseable);
this.close.emit(null);
break;
case 'clear':
case 'closeOther':
this.srv.clear(res.includeNonCloseable);
this.close.emit(null);
break;
}
};
ReuseTabComponent.prototype.refStatus = function (dc) {
var _this = this;
if (dc === void 0) { dc = true; }
if (this.list.length) {
this.list[this.list.length - 1].last = true;
this.list.forEach(function (i, idx) { return (i.active = _this.pos === idx); });
}
if (dc)
this.cd.detectChanges();
};
ReuseTabComponent.prototype.to = function (e, index) {
var _this = this;
if (e) {
e.preventDefault();
e.stopPropagation();
}
index = Math.max(0, Math.min(index, this.list.length - 1));
var item = this.list[index];
this.router.navigateByUrl(item.url).then(function (res) {
if (!res)
return;
_this.pos = index;
_this.item = item;
_this.refStatus();
_this.change.emit(item);
});
};
ReuseTabComponent.prototype._close = function (e, idx, includeNonCloseable) {
if (e) {
e.preventDefault();
e.stopPropagation();
}
var item = this.list[idx];
this.srv.close(item.url, includeNonCloseable);
this.close.emit(item);
this.cd.detectChanges();
return false;
};
// endregion
ReuseTabComponent.prototype.ngOnInit = function () {
this.setClass();
this.genList();
};
ReuseTabComponent.prototype.setClass = function () {
var body = this.doc.querySelector('body');
var bodyCls = "has-ad-rt";
if (this.fixed) {
this.render.addClass(body, bodyCls);
}
else {
this.render.removeClass(body, bodyCls);
}
};
ReuseTabComponent.prototype.ngOnChanges = function (changes) {
if (changes.max)
this.srv.max = this.max;
if (changes.excludes)
this.srv.excludes = this.excludes;
if (changes.mode)
this.srv.mode = this.mode;
this.srv.debug = this.debug;
this.setClass();
this.cd.detectChanges();
};
ReuseTabComponent.prototype.ngOnDestroy = function () {
this.sub$.unsubscribe();
if (this.i18n$)
this.i18n$.unsubscribe();
};
ReuseTabComponent.prototype.l = function (key) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return this.localizationService.l(key, args);
};
/**
* 打开右键菜单
* @param $event 鼠标事件
* @param template 创建右键的模板内容
*/
ReuseTabComponent.prototype.openContextMenu = function ($event, template) {
this._contextMenuDropdown = this.nzDropdownService.create($event, template);
};
/**
* 右键菜单项点击事件
* @param $event 当前项点击事件
* @param closeType 关闭类型
* @param item 当前路由复用项
*/
ReuseTabComponent.prototype.contextMenuItemClick = function ($event, closeType, item) {
if (closeType === 'close' && !item.closable)
return;
if (closeType === 'closeRight' && item.last)
return;
var includeNonCloseable = $event.ctrlKey; //是否强制清除(按Ctrl键)
switch (closeType) {
case 'close':
this.srv.close(item.url, includeNonCloseable);
break;
case 'closeOther':
this.srv.closeOther(item.url, includeNonCloseable);
break;
case 'closeRight':
this.srv.closeRight(item.url, includeNonCloseable);
break;
case 'clear':
this.srv.clear(includeNonCloseable);
break;
default:
this.srv.refresh();
break;
}
//关闭右键菜单
this._contextMenuDropdown.close();
};
ReuseTabComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'reuse-tab',
template: "\n <nz-tabset [nzSelectedIndex]=\"pos\" [nzAnimated]=\"false\" nzType=\"line\">\n <nz-tab *ngFor=\"let i of list; let index = index\" [nzTitle]=\"titleTemplate\">\n <ng-template #titleTemplate>\n <span [context-menu]=\"i\" (click)=\"to($event, index)\" class=\"name\">\n <i *ngIf=\"i.icon\" [class]=\"i.icon\"></i>\n {{l(i.title)}}\n </span>\n <i *ngIf=\"i.closable\" class=\"anticon anticon-close op\" (click)=\"_close($event, index, false)\"></i>\n </ng-template>\n </nz-tab>\n</nz-tabset>\n<reuse-tab-context [i18n]=\"i18n\" (change)=\"cmChange($event)\"></reuse-tab-context>\n ",
// templateUrl: './reuse-tab.component.html',
changeDetection: i0.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
providers: [ReuseTabContextService],
host: {
'[class.ad-rt]': 'true',
'[class.fixed]': 'fixed',
},
},] },
];
/** @nocollapse */
ReuseTabComponent.ctorParameters = function () { return [
{ type: ReuseTabService },
{ type: i0.ChangeDetectorRef },
{ type: router.Router },
{ type: router.ActivatedRoute },
{ type: i0.ElementRef },
{ type: i0.Renderer2 },
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.DOCUMENT,] }] },
{ type: localization_service.LocalizationService },
{ type: i1$1.NzDropdownService }
]; };
ReuseTabComponent.propDecorators = {
mode: [{ type: i0.Input }],
i18n: [{ type: i0.Input }],
debug: [{ type: i0.Input }],
max: [{ type: i0.Input }],
excludes: [{ type: i0.Input }],
allowClose: [{ type: i0.Input }],
fixed: [{ type: i0.Input }],
showCurrent: [{ type: i0.Input }],
change: [{ type: i0.Output }],
close: [{ type: i0.Output }]
};
return ReuseTabComponent;
}());
var ReuseTabContextComponent = /** @class */ (function () {
function ReuseTabContextComponent(srv) {
var _this = this;
this.srv = srv;
this.sub$ = new rxjs.Subscription();
this.change = new i0.EventEmitter();
this.sub$.add(srv.show.subscribe(function (context) { return _this.srv.open(context); }));
this.sub$.add(srv.close.subscribe(function (res) { return _this.change.emit(res); }));
}
Object.defineProperty(ReuseTabContextComponent.prototype, "i18n", {
set: function (value) {
this.srv.i18n = value;
},
enumerable: true,
configurable: true
});
ReuseTabContextComponent.prototype.ngOnDestroy = function () {
this.sub$.unsubscribe();
};
ReuseTabContextComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'reuse-tab-context',
template: "",
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
ReuseTabContextComponent.ctorParameters = function () { return [
{ type: ReuseTabContextService }
]; };
ReuseTabContextComponent.propDecorators = {
i18n: [{ type: i0.Input }],
change: [{ type: i0.Output }]
};
return ReuseTabContextComponent;
}());
var ReuseTabContextDirective = /** @class */ (function () {
function ReuseTabContextDirective(srv) {
this.srv = srv;
}
ReuseTabContextDirective.prototype.onContextMenu = function (event) {
this.srv.show.next({
event: event,
item: this.item,
});
event.preventDefault();
event.stopPropagation();
};
ReuseTabContextDirective.decorators = [
{ type: i0.Directive, args: [{
selector: '[context-menu]',
},] },
];
/** @nocollapse */
ReuseTabContextDirective.ctorParameters = function () { return [
{ type: ReuseTabContextService }
]; };
ReuseTabContextDirective.propDecorators = {
item: [{ type: i0.Input, args: ['context-menu',] }],
onContextMenu: [{ type: i0.HostListener, args: ['contextmenu', ['$event'],] }]
};
return ReuseTabContextDirective;
}());
var COMPONENTS$16 = [ReuseTabComponent];
var NOEXPORTS = [
ReuseTabContextMenuComponent,
ReuseTabContextComponent,
ReuseTabContextDirective,
];
var AdReuseTabModule = /** @class */ (function () {
function AdReuseTabModule() {
}
AdReuseTabModule.forRoot = function () {
return {
ngModule: AdReuseTabModule,
};
};
AdReuseTabModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, router.RouterModule, i1$1.NgZorroAntdModule, overlay.OverlayModule],
declarations: COMPONENTS$16.concat(NOEXPORTS),
entryComponents: [ReuseTabContextMenuComponent],
exports: COMPONENTS$16.slice(),
},] },
];
return AdReuseTabModule;
}());
var FullContentService = /** @class */ (function () {
function FullContentService() {
this._change = new rxjs.BehaviorSubject(null);
}
/** 切换全屏工作区状态 */
FullContentService.prototype.toggle = function () {
this._change.next(true);
};
Object.defineProperty(FullContentService.prototype, "change", {
get: function () {
return this._change.pipe(operators.share());
},
enumerable: true,
configurable: true
});
FullContentService.decorators = [
{ type: i0.Injectable },
];
return FullContentService;
}());
var cls = "ad-full-content-wrap";
var fsCls = "ad-full-content-fs";
var hideTitleCls = "ad-full-content-ht";
var FullContentComponent = /** @class */ (function () {
// endregion
function FullContentComponent(el, router$$1, cd, srv, doc) {
this.el = el;
this.router = router$$1;
this.cd = cd;
this.srv = srv;
this.doc = doc;
this.inited = false;
this.id = "_full-content-" + Math.random()
.toString(36)
.substring(2);
this._height = 0;
this._hideTitle = true;
this._padding = 24;
this.fullscreenChange = new i0.EventEmitter();
// region: resize
this.scroll$ = null;
}
Object.defineProperty(FullContentComponent.prototype, "fullscreen", {
// region: fields
get: function () {
return this._fullscreen;
},
set: function (value) {
this._fullscreen = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FullContentComponent.prototype, "hideTitle", {
get: function () {
return this._hideTitle;
},
set: function (value) {
this._hideTitle = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FullContentComponent.prototype, "padding", {
get: function () {
return this._padding;
},
set: function (value) {
this._padding = util.toNumber(value);
},
enumerable: true,
configurable: true
});
FullContentComponent.prototype.ngOnInit = function () {
var _this = this;
this.inited = true;
this.bodyEl = this.doc.querySelector('body');
this.bodyEl.classList.add(cls);
this.el.nativeElement.id = this.id;
this.update();
this.installResizeEvent();
this.srv$ = this.srv.change.subscribe(function (res) {
if (res)
_this.toggle();
});
this.route$ = this.router.events
.pipe(operators.filter(function (e) {
return e instanceof router.ActivationStart || e instanceof router.ActivationEnd;
}), operators.debounceTime(200))
.subscribe(function (e) {
if (!!document.querySelector('#' + _this.id)) {
_this.bodyEl.classList.add(cls);
_this.updateFsCls();
}
else {
_this.bodyEl.classList.remove(cls, fsCls, hideTitleCls);
}
});
};
FullContentComponent.prototype.ngAfterViewInit = function () {
var _this = this;
setTimeout(function () { return _this.updateHeight(); });
};
FullContentComponent.prototype.updateFsCls = function () {
if (this.fullscreen) {
this.bodyEl.classList.add(fsCls);
if (this.hideTitle)
this.bodyEl.classList.add(hideTitleCls);
}
else {
this.bodyEl.classList.remove(fsCls);
if (this.hideTitle)
this.bodyEl.classList.remove(hideTitleCls);
}
};
FullContentComponent.prototype.update = function () {
this.updateFsCls();
this.fullscreenChange.emit(this.fullscreen);
};
FullContentComponent.prototype.updateHeight = function () {
this._height =
this.bodyEl.getBoundingClientRect().height -
this.el.nativeElement.getBoundingClientRect().top -
this.padding;
this.cd.detectChanges();
};
FullContentComponent.prototype.toggle = function () {
this.fullscreen = !this.fullscreen;
this.update();
this.updateHeight();
};
FullContentComponent.prototype.ngOnChanges = function (changes) {
if (this.inited)
this.update();
};
FullContentComponent.prototype.ngOnDestroy = function () {
this.bodyEl.classList.remove(cls, fsCls, hideTitleCls);
this.uninstallResizeEvent();
this.srv$.unsubscribe();
this.route$.unsubscribe();
};
FullContentComponent.prototype.installResizeEvent = function () {
var _this = this;
this.scroll$ = rxjs.fromEvent(window, 'resize')
.pipe(operators.debounceTime(200))
.subscribe(function () { return _this.updateHeight(); });
};
FullContentComponent.prototype.uninstallResizeEvent = function () {
this.scroll$.unsubscribe();
};
FullContentComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'full-content',
template: "<ng-content></ng-content>",
host: { '[class.ad-full-content]': 'true' },
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
FullContentComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: router.Router },
{ type: i0.ChangeDetectorRef },
{ type: FullContentService },
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.DOCUMENT,] }] }
]; };
FullContentComponent.propDecorators = {
_height: [{ type: i0.HostBinding, args: ['style.height.px',] }],
fullscreen: [{ type: i0.Input }],
hideTitle: [{ type: i0.Input }],
padding: [{ type: i0.Input }],
fullscreenChange: [{ type: i0.Output }]
};
return FullContentComponent;
}());
var FullContentToggleDirective = /** @class */ (function () {
function FullContentToggleDirective(parent) {
this.parent = parent;
}
FullContentToggleDirective.prototype._click = function () {
this.parent.toggle();
};
FullContentToggleDirective.decorators = [
{ type: i0.Directive, args: [{
selector: '[full-toggle]',
},] },
];
/** @nocollapse */
FullContentToggleDirective.ctorParameters = function () { return [
{ type: FullContentComponent }
]; };
FullContentToggleDirective.propDecorators = {
_click: [{ type: i0.HostListener, args: ['click',] }]
};
return FullContentToggleDirective;
}());
var COMPONENTS$17 = [FullContentComponent, FullContentToggleDirective];
var AdFullContentModule = /** @class */ (function () {
function AdFullContentModule() {
}
AdFullContentModule.forRoot = function () {
return {
ngModule: AdFullContentModule,
providers: [FullContentService],
};
};
AdFullContentModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$17.slice(),
exports: COMPONENTS$17.slice(),
},] },
];
return AdFullContentModule;
}());
var XlsxDirective = /** @class */ (function () {
function XlsxDirective(srv) {
this.srv = srv;
}
XlsxDirective.prototype._click = function () {
this.srv.export(this.data);
};
XlsxDirective.decorators = [
{ type: i0.Directive, args: [{ selector: '[xlsx]' },] },
];
/** @nocollapse */
XlsxDirective.ctorParameters = function () { return [
{ type: XlsxService }
]; };
XlsxDirective.propDecorators = {
data: [{ type: i0.Input, args: ['xlsx',] }],
_click: [{ type: i0.HostListener, args: ['click',] }]
};
return XlsxDirective;
}());
var COMPONENTS$18 = [XlsxDirective];
var AdXlsxModule = /** @class */ (function () {
function AdXlsxModule() {
}
AdXlsxModule.forRoot = function (config) {
return {
ngModule: AdXlsxModule,
providers: [XlsxService, { provide: DA_XLSX_CONFIG, useValue: config }],
};
};
AdXlsxModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, util.DelonUtilModule],
declarations: COMPONENTS$18.slice(),
exports: COMPONENTS$18.slice(),
},] },
];
return AdXlsxModule;
}());
var DA_ZIP_CONFIG = new i0.InjectionToken('DA_ZIP_CONFIG');
var ZipService = /** @class */ (function () {
function ZipService(config, http, lazy) {
this.config = config;
this.http = http;
this.lazy = lazy;
}
ZipService.prototype.init = function () {
var config = Object.assign({
url: "//cdn.bootcss.com/jszip/3.1.5/jszip.min.js",
utils: [],
}, this.config);
return this.lazy.load([config.url].concat(config.utils));
};
ZipService.prototype.check = function (zip) {
if (!zip)
throw new Error('get instance via `ZipService.create()`');
};
/** 解压 */
ZipService.prototype.read = function (fileOrUrl, options) {
var _this = this;
return new Promise(function (resolve, reject) {
_this.init().then(function () {
// from url
if (typeof fileOrUrl === 'string') {
_this.http
.request('GET', fileOrUrl, { responseType: 'arraybuffer' })
.subscribe(function (res) {
JSZip.loadAsync(res, options).then(function (ret) { return resolve(ret); });
}, function (err) {
reject(err);
});
return;
}
// from file
var reader = new FileReader();
reader.onload = function (e) {
JSZip.loadAsync(e.target.result, options).then(function (ret) { return resolve(ret); });
};
reader.readAsBinaryString(fileOrUrl);
});
});
};
/** 创建 Zip 实例,用于创建压缩文件 */
ZipService.prototype.create = function () {
var _this = this;
return new Promise(function (resolve) {
_this.init().then(function () {
var zipFile = new JSZip();
resolve(zipFile);
});
});
};
/**
* 下载URL资源并写入 zip
* @param zip Zip 实例
* @param path Zip 路径,例如: `text.txt`、`txt/hi.txt`
* @param url URL 地址
*/
ZipService.prototype.pushUrl = function (zip, path, url) {
var _this = this;
this.check(zip);
return new Promise(function (resolve, reject) {
_this.http.request('GET', url, { responseType: 'arraybuffer' }).subscribe(function (res) {
zip.file(path, res);
resolve();
}, function (error) {
reject({ url: url, error: error });
});
});
};
/**
* 保存Zip并执行打开保存对话框
*
* @param zip zip 对象,务必通过 `create()` 构建
* @param options 额外参数,
*/
ZipService.prototype.save = function (zip, options) {
this.check(zip);
var opt = Object.assign({}, options);
return new Promise(function (resolve, reject) {
zip
.generateAsync(Object.assign({ type: 'blob' }, opt.options), opt.update)
.then(function (data) {
if (opt.callback)
opt.callback(data);
fileSaver.saveAs(data, opt.filename || 'download.zip');
resolve();
}, function (err) {
reject(err);
});
});
};
ZipService.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
ZipService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: i0.Inject, args: [DA_ZIP_CONFIG,] }] },
{ type: i1.HttpClient },
{ type: util.LazyService }
]; };
return ZipService;
}());
var AdZipModule = /** @class */ (function () {
function AdZipModule() {
}
AdZipModule.forRoot = function (config) {
return {
ngModule: AdZipModule,
providers: [ZipService, { provide: DA_ZIP_CONFIG, useValue: config }],
};
};
AdZipModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, util.DelonUtilModule],
},] },
];
return AdZipModule;
}());
function numberToChinese(value, rmb, options) {
if (rmb === void 0) { rmb = true; }
options = Object.assign({
minusSymbol: '负',
validThrow: false,
}, options);
if (typeof value === 'number')
value = value.toString();
if (!/^-?\d+(\.\d+)?$/.test(value) && options.validThrow)
throw new Error(value + " is invalid number type");
var integer, decimal;
_a = value.split('.'), integer = _a[0], decimal = _a[1];
var symbol = '';
if (integer.startsWith('-')) {
symbol = options.minusSymbol;
integer = integer.substr(1);
}
if (/^-?\d+$/.test(value))
decimal = null;
integer = (+integer).toString();
var unit = {
num: rmb
? ['', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '点']
: ['', '一', '二', '三', '四', '五', '六', '七', '八', '九', '点'],
radice: rmb
? [
'',
'拾',
'佰',
'仟',
'万',
'拾',
'佰',
'仟',
'亿',
'拾',
'佰',
'仟',
'万亿',
'拾',
'佰',
'仟',
'兆',
'拾',
'佰',
'仟',
]
: [
'',
'十',
'百',
'千',
'万',
'十',
'百',
'千',
'亿',
'十',
'百',
'千',
'万亿',
'十',
'百',
'千',
'兆',
'十',
'百',
'千',
],
dec: ['角', '分', '厘', '毫'],
};
if (rmb)
value = (+value).toFixed(5).toString();
var integerRes = '';
var integerCount = integer.length;
if (integer === '0' || integerCount === 0) {
integerRes = '零';
}
else {
var cnDesc = '';
for (var i = 0; i < integerCount; i++) {
var n = +integer[i], j = integerCount - i - 1, isZero = i > 1 && n !== 0 && integer[i - 1] === '0', cnZero = isZero ? '零' : '', isEmpptyUnit = (n === 0 && j % 4 !== 0) || integer.substr(i - 3, 4) === '0000', descMark = cnDesc;
var cnNum = unit.num[n];
cnDesc = isEmpptyUnit ? '' : unit.radice[j];
// 第一位是一十
if (i === 0 && cnNum === '一' && cnDesc === '十')
cnNum = '';
var isChangeEr = n > 1 &&
cnNum === '二' && // 去除首位
['', '十', '百'].indexOf(cnDesc) === -1 && // 不读两\两十\两百
descMark !== '十'; // 不读十两
if (isChangeEr)
cnNum = '两';
integerRes += cnZero + cnNum + cnDesc;
}
}
// 小数部分拼接
var decimalRes = '';
var decimalCount = decimal ? decimal.toString().length : 0;
if (decimal === null) {
decimalRes = rmb ? '整' : '';
}
else if (decimal === '0') {
decimalRes = '零';
}
else {
for (var i = 0; i < decimalCount; i++) {
if (rmb && i > unit.dec.length - 1)
break;
var n = decimal[i], cnZero = n === '0' ? '零' : '', cnNum = unit.num[n], cnDesc = rmb ? unit.dec[i] : '';
decimalRes += cnZero + cnNum + cnDesc;
}
}
var ret = symbol +
(rmb
? integerRes + (decimalRes === '零' ? '元整' : "\u5143" + decimalRes)
: integerRes + (decimalRes === '' ? '' : "\u70B9" + decimalRes));
return ret;
var _a;
}
var NumberToChinesePipe = /** @class */ (function () {
function NumberToChinesePipe() {
}
NumberToChinesePipe.prototype.transform = function (value, rmb, minusSymbol) {
if (rmb === void 0) { rmb = true; }
if (minusSymbol === void 0) { minusSymbol = '负'; }
return numberToChinese(value, rmb, { minusSymbol: minusSymbol });
};
NumberToChinesePipe.decorators = [
{ type: i0.Pipe, args: [{ name: 'n2c' },] },
];
return NumberToChinesePipe;
}());
var PIPES = [NumberToChinesePipe];
var AdNumberToChineseModule = /** @class */ (function () {
function AdNumberToChineseModule() {
}
AdNumberToChineseModule.forRoot = function () {
return { ngModule: AdNumberToChineseModule, providers: [] };
};
AdNumberToChineseModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: PIPES,
exports: PIPES,
},] },
];
return AdNumberToChineseModule;
}());
var AdLodopConfig = /** @class */ (function () {
function AdLodopConfig() {
}
AdLodopConfig.decorators = [
{ type: i0.Injectable },
];
return AdLodopConfig;
}());
// TODO: zone
var LodopService = /** @class */ (function () {
function LodopService(defCog, scriptSrv) {
this.defCog = defCog;
this.scriptSrv = scriptSrv;
this.pending = false;
this._lodop = null;
this._init = new rxjs.Subject();
this._events = new rxjs.Subject();
this.printBuffer = [];
this.cog = defCog;
}
Object.defineProperty(LodopService.prototype, "cog", {
/**
* 获取或重新设置配置
*
* **注:**重新设置会倒置重新加载脚本资源
*/
get: function () {
return this._cog;
},
set: function (value) {
this._cog = Object.assign({
url: 'https://localhost:8443/CLodopfuncs.js',
name: 'CLODOP',
companyName: '',
checkMaxCount: 100,
}, this.defCog, value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(LodopService.prototype, "events", {
/** 事件变更通知 */
get: function () {
return this._events.asObservable();
},
enumerable: true,
configurable: true
});
LodopService.prototype.check = function () {
if (!this._lodop)
throw new Error("\u8BF7\u52A1\u5FC5\u5148\u8C03\u7528 lodop \u83B7\u53D6\u5BF9\u8C61");
};
LodopService.prototype.request = function () {
var _this = this;
this.pending = true;
var url = this.cog.url + "?name=" + this.cog.name;
var checkMaxCount = this.cog.checkMaxCount;
var onResolve = function (status, error) {
_this._init.next({
ok: status === 'ok',
status: status,
error: error,
lodop: _this._lodop,
});
};
var checkStatus = function () {
--checkMaxCount;
if (_this._lodop.webskt && _this._lodop.webskt.readyState === 1) {
onResolve('ok');
}
else {
if (checkMaxCount < 0) {
onResolve('check-limit');
return;
}
setTimeout(function () { return checkStatus(); }, 100);
}
};
this.scriptSrv.load(url).then(function (res) {
if (res.length === 1 && res[0].status !== 'ok') {
_this.pending = false;
onResolve('script-load-error', res[0]);
return;
}
_this._lodop =
window.hasOwnProperty(_this.cog.name) &&
window[_this.cog.name];
if (_this._lodop === null) {
onResolve('load-variable-name-error', { name: _this.cog.name });
return;
}
_this._lodop.SET_LICENSES(_this.cog.companyName, _this.cog.license, _this.cog.licenseA, _this.cog.licenseB);
checkStatus();
});
};
/** 重置 lodop 对象 */
LodopService.prototype.reset = function () {
this._lodop = null;
this.pending = false;
this.request();
};
Object.defineProperty(LodopService.prototype, "lodop", {
/** 获取 lodop 对象 */
get: function () {
if (this._lodop)
return rxjs.of({ ok: true, lodop: this._lodop });
if (this.pending)
return this._init.asObservable();
this.request();
return this._init.asObservable();
},
enumerable: true,
configurable: true
});
Object.defineProperty(LodopService.prototype, "printer", {
/** 获取打印机列表 */
get: function () {
this.check();
var ret = [];
var count = this._lodop.GET_PRINTER_COUNT();
for (var index = 0; index < count; index++) {
ret.push(this._lodop.GET_PRINTER_NAME(index));
}
return ret;
},
enumerable: true,
configurable: true
});
/**
* 附加代码至 `lodop` 对象上,字符串类支持 `{{key}}` 的动态参数
*
* **注:** 代码是指打印设计所产生字符串数据
*
* @param code 代码
* @param contextObj 动态参数上下文对象
* @param parser 自定义解析表达式,默认:`/LODOP\.([^(]+)\(([^\n]+)\);/i`
*/
LodopService.prototype.attachCode = function (code, contextObj, parser) {
var _this = this;
this.check();
if (!parser)
parser = /LODOP\.([^(]+)\(([^\n]+)\);/i;
code.split('\n').forEach(function (line) {
var res = parser.exec(line.trim());
if (!res)
return;
var fn = _this._lodop[res[1]];
if (fn) {
var arr = void 0;
try {
var fakeFn = new Function("return [" + res[2] + "]");
arr = fakeFn();
}
catch (_a) { }
if (Array.isArray(arr) && contextObj) {
for (var i = 0; i < arr.length; i++) {
if (typeof arr[i] === 'string') {
arr[i] = arr[i].replace(/{{(.*?)}}/g, function (match, key) { return contextObj[key.trim()] || ''; });
}
}
}
fn.apply(_this._lodop, arr);
}
});
};
/**
* 打开打印设计关闭后自动返回代码
*
* **注:** 自动监听 `On_Return` 事件,运行后会移除
*/
LodopService.prototype.design = function () {
var _this = this;
this.check();
var tid = this._lodop.PRINT_DESIGN();
return new Promise(function (resolve) {
_this._lodop.On_Return = function (taskID, value) {
if (tid !== taskID)
return;
_this._lodop.On_Return = null;
resolve('' + value);
};
});
};
LodopService.prototype.printDo = function () {
var _this = this;
var data = this.printBuffer.shift();
if (!data)
return;
this.attachCode(data.code, data.item, data.parser);
var tid = this._lodop.PRINT();
this._lodop.On_Return = function (taskID, value) {
if (tid !== taskID)
return;
_this._lodop.On_Return = null;
_this._events.next(Object.assign({
ok: value === true,
error: value === true ? null : value,
}, data));
_this.printDo();
};
};
/**
* 立即打印,一般用于批量套打
*
* @param code 代码
* @param contextObj 动态参数上下文对象
* @param parser 自定义解析表达式,默认:`/LODOP\.([^(]+)\(([^\n]+)\);/i`
*/
LodopService.prototype.print = function (code, contextObj, parser) {
this.check();
if (contextObj) {
(_a = this.printBuffer).push.apply(_a, (Array.isArray(contextObj) ? contextObj : [contextObj]).map(function (item) {
return { code: code, parser: parser, item: item };
}));
}
this.printDo();
var _a;
};
LodopService.prototype.ngOnDestroy = function () {
this._init.unsubscribe();
this._events.unsubscribe();
};
LodopService.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
LodopService.ctorParameters = function () { return [
{ type: AdLodopConfig },
{ type: util.LazyService }
]; };
return LodopService;
}());
var AdLodopModule = /** @class */ (function () {
function AdLodopModule() {
}
AdLodopModule.forRoot = function () {
return {
ngModule: AdLodopModule,
providers: [LodopService, AdLodopConfig],
};
};
AdLodopModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [util.DelonUtilModule],
},] },
];
return AdLodopModule;
}());
var QuickMenuComponent = /** @class */ (function () {
// endregion
function QuickMenuComponent(cd, el, render) {
this.cd = cd;
this.el = el;
this.render = render;
// region: fields
this.icon = 'anticon anticon-question-circle-o';
this.top = 120;
this.width = 200;
this.bgColor = '#fff';
this.borderColor = '#ddd';
this.show = false;
this.ctrlStyle = {};
this.initFlag = false;
}
QuickMenuComponent.prototype._click = function () {
this.show = !this.show;
this.setStyle();
};
QuickMenuComponent.prototype.setStyle = function () {
this.ctrlStyle = {
'background-color': this.bgColor,
'border-color': this.borderColor,
};
var res = [
"top:" + this.top + "px",
"width:" + this.width + "px",
"background-color:" + this.bgColor,
"border-color:" + this.borderColor,
"margin-right:-" + (this.show ? 0 : this.width) + "px",
];
this.render.setAttribute(this.el.nativeElement, 'style', res.join(';'));
this.cd.detectChanges();
};
QuickMenuComponent.prototype.ngOnInit = function () {
this.initFlag = true;
this.setStyle();
};
QuickMenuComponent.prototype.ngOnChanges = function (changes) {
if (this.initFlag)
this.setStyle();
};
QuickMenuComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'quick-menu',
template: "\n <div class=\"ad-quick-menu__inner\">\n <div class=\"ad-quick-menu__ctrl\" [ngStyle]=\"ctrlStyle\">\n <i [ngClass]=\"icon\"></i>\n </div>\n <ng-content></ng-content>\n </div>\n ",
host: { '[class.ad-quick-menu]': 'true' },
preserveWhitespaces: false,
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
QuickMenuComponent.ctorParameters = function () { return [
{ type: i0.ChangeDetectorRef },
{ type: i0.ElementRef },
{ type: i0.Renderer2 }
]; };
QuickMenuComponent.propDecorators = {
icon: [{ type: i0.Input }],
top: [{ type: i0.Input }],
width: [{ type: i0.Input }],
bgColor: [{ type: i0.Input }],
borderColor: [{ type: i0.Input }],
_click: [{ type: i0.HostListener, args: ['click',] }]
};
return QuickMenuComponent;
}());
var COMPONENTS$19 = [QuickMenuComponent];
var AdQuickMenuModule = /** @class */ (function () {
function AdQuickMenuModule() {
}
AdQuickMenuModule.forRoot = function () {
return { ngModule: AdQuickMenuModule, providers: [] };
};
AdQuickMenuModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$19.slice(),
exports: COMPONENTS$19.slice(),
},] },
];
return AdQuickMenuModule;
}());
var AdQRConfig = /** @class */ (function () {
function AdQRConfig() {
/** 背景,默认:`white` */
this.background = 'white';
/** 背景透明级别,范围:`0-1` 之间,默认:`1.0` */
this.backgroundAlpha = 1.0;
/** 前景,默认:`black` */
this.foreground = 'black';
/** 前景透明级别,范围:`0-1` 之间,默认:`1.0` */
this.foregroundAlpha = 1.0;
/** 误差校正级别,默认:`L` */
this.level = 'L';
/** 二维码输出图片MIME类型,默认:`image/png` */
this.mime = 'image/png';
/** 内边距(单位:px),默认:`10` */
this.padding = 10;
/** 大小(单位:px),默认:`220` */
this.size = 220;
}
return AdQRConfig;
}());
var QRService = /** @class */ (function () {
function QRService(cog) {
/** 背景透明级别,范围:`0-1` 之间 */
this.backgroundAlpha = 1.0;
Object.assign(this, cog);
this.qr = new QRious();
}
/**
* 生成二维码,并返回Base64编码
*
* @param [value] 重新指定值
*/
QRService.prototype.refresh = function (value) {
this.qr.set(typeof value === 'object' ? value : {
background: this.background,
backgroundAlpha: this.backgroundAlpha,
foreground: this.foreground,
foregroundAlpha: this.foregroundAlpha,
level: this.level,
padding: this.padding,
size: this.size,
value: value || this.value,
});
return this.dataURL;
};
Object.defineProperty(QRService.prototype, "dataURL", {
/**
* 返回当前二维码Base64编码
*/
get: function () {
return this.qr.toDataURL();
},
enumerable: true,
configurable: true
});
QRService.decorators = [
{ type: i0.Injectable },
];
/** @nocollapse */
QRService.ctorParameters = function () { return [
{ type: AdQRConfig }
]; };
return QRService;
}());
var QRComponent = /** @class */ (function () {
// endregion
function QRComponent(cog, srv, cd) {
this.srv = srv;
this.cd = cd;
/** 变更时回调 */
this.change = new i0.EventEmitter();
Object.assign(this, cog);
}
QRComponent.prototype.ngOnChanges = function (changes) {
this.dataURL = this.srv.refresh({
background: this.background,
backgroundAlpha: this.backgroundAlpha,
foreground: this.foreground,
foregroundAlpha: this.foregroundAlpha,
level: this.level,
mime: this.mime,
padding: this.padding,
size: this.size,
value: this.value
});
this.cd.detectChanges();
this.change.emit(this.dataURL);
};
QRComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'qr',
template: "\n <img src=\"{{dataURL}}\">\n ",
preserveWhitespaces: false,
host: { '[class.ad-qr]': 'true' },
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
QRComponent.ctorParameters = function () { return [
{ type: AdQRConfig },
{ type: QRService },
{ type: i0.ChangeDetectorRef }
]; };
QRComponent.propDecorators = {
background: [{ type: i0.Input }],
backgroundAlpha: [{ type: i0.Input }],
foreground: [{ type: i0.Input }],
foregroundAlpha: [{ type: i0.Input }],
level: [{ type: i0.Input }],
mime: [{ type: i0.Input }],
padding: [{ type: i0.Input }],
size: [{ type: i0.HostBinding, args: ['style.height.px',] }, { type: i0.HostBinding, args: ['style.width.px',] }, { type: i0.Input }],
value: [{ type: i0.Input }],
change: [{ type: i0.Output }]
};
return QRComponent;
}());
var COMPONENTS$20 = [QRComponent];
var AdQRModule = /** @class */ (function () {
function AdQRModule() {
}
AdQRModule.forRoot = function () {
return { ngModule: AdQRModule, providers: [AdQRConfig, QRService] };
};
AdQRModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$20.slice(),
exports: COMPONENTS$20.slice(),
},] },
];
return AdQRModule;
}());
var AdSHFConfig = /** @class */ (function () {
function AdSHFConfig() {
/**
* 列数,默认:`2`
*/
this.col = 2;
/**
* 标签文本宽度,单位:`px`,默认:`100`
*/
this.labelWidth = 100;
}
AdSHFConfig.decorators = [
{ type: i0.Injectable },
];
return AdSHFConfig;
}());
var SHFWrapDirective = /** @class */ (function () {
function SHFWrapDirective(cog, el, ren) {
this.el = el;
this.ren = ren;
this._col = 2;
this._labelWidth = 100;
this.nzLayout = 'horizontal';
Object.assign(this, cog);
}
Object.defineProperty(SHFWrapDirective.prototype, "col", {
get: function () {
return this._col;
},
set: function (value) {
var a = util.toNumber(value, 0);
if (a <= 0)
return;
this._col = util.toNumber(value, 0);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SHFWrapDirective.prototype, "labelWidth", {
get: function () {
return this._labelWidth;
},
set: function (value) {
this._labelWidth = util.toNumber(value, 0);
},
enumerable: true,
configurable: true
});
SHFWrapDirective.prototype.ngAfterViewInit = function () {
var el = this.el.nativeElement;
this.ren.addClass(el.querySelector('.ant-card-body') || el, 'ad-shf__wrap');
this.ren.addClass(el, "ad-shf__" + this.nzLayout);
};
SHFWrapDirective.decorators = [
{ type: i0.Directive, args: [{
selector: 'shf-wrap, [shf-wrap]',
},] },
];
/** @nocollapse */
SHFWrapDirective.ctorParameters = function () { return [
{ type: AdSHFConfig },
{ type: i0.ElementRef },
{ type: i0.Renderer2 }
]; };
SHFWrapDirective.propDecorators = {
col: [{ type: i0.Input, args: ['shf-wrap',] }],
labelWidth: [{ type: i0.Input }],
nzLayout: [{ type: i0.Input }]
};
return SHFWrapDirective;
}());
var SHFItemComponent = /** @class */ (function () {
function SHFItemComponent(wrap, el, ren, cd) {
this.wrap = wrap;
this.el = el;
this.ren = ren;
this.cd = cd;
this.invalid = false;
this._label = '';
this.controlClass = '';
}
Object.defineProperty(SHFItemComponent.prototype, "label", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._label = null;
this._labelTpl = value;
}
else {
this._label = value;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(SHFItemComponent.prototype, "col", {
get: function () {
return this._span;
},
set: function (value) {
this._span = 24 / util.toNumber(value, 2);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SHFItemComponent.prototype, "labelWidth", {
get: function () {
return this._labelWidth;
},
set: function (value) {
this._labelWidth = util.toNumber(value, 0);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SHFItemComponent.prototype, "isHorizontal", {
// endregion
get: function () {
return !this.wrap || (this.wrap && this.wrap.nzLayout === 'horizontal');
},
enumerable: true,
configurable: true
});
SHFItemComponent.prototype.fixLabelWidth = function () {
var w = this.wrap;
if (typeof this.col === 'undefined') {
this.col = w ? w.col : 2;
}
if (typeof this.labelWidth === 'undefined') {
this.labelWidth = w ? w.labelWidth : 100;
}
if (!this.isHorizontal)
this._labelWidth = null;
return this;
};
SHFItemComponent.prototype.setClassMap = function () {
var classMap = (_a = {},
_a["ant-form-item"] = true,
_a["ant-col-" + this.col] = this.isHorizontal,
_a["ad-shf__item"] = true,
_a);
util.updateHostClass(this.el.nativeElement, this.ren, classMap);
this.cd.detectChanges();
var _a;
};
SHFItemComponent.prototype.ngOnChanges = function () {
this.fixLabelWidth().setClassMap();
};
SHFItemComponent.prototype.ngAfterViewInit = function () {
var _this = this;
this.fixLabelWidth().setClassMap();
if (this.ngModel) {
this.status$ = this.ngModel.statusChanges.subscribe(function (res) {
var status = res !== 'VALID';
if (_this.invalid === status)
return;
_this.invalid = status;
_this.cd.detectChanges();
});
}
};
SHFItemComponent.prototype.ngOnDestroy = function () {
if (this.status$) {
this.status$.unsubscribe();
}
};
SHFItemComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'shf-item',
template: "\n <div class=\"ant-form-item-label ad-shf__label\"\n [class.ad-shf__nolabel]=\"!_label && !_labelTpl\" [style.width.px]=\"labelWidth\">\n <ng-container *ngIf=\"_label; else _labelTpl\">{{_label}}</ng-container>\n</div>\n<div class=\"ant-form-item-control-wrapper ad-shf__control\">\n <div class=\"ant-form-item-control {{controlClass}}\" [class.has-error]=\"invalid\" [attr.title]=\"tip\">\n <ng-content></ng-content>\n </div>\n</div>\n ",
// templateUrl: './item.component.html',
preserveWhitespaces: false,
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
SHFItemComponent.ctorParameters = function () { return [
{ type: SHFWrapDirective, decorators: [{ type: i0.Optional }, { type: i0.Host }] },
{ type: i0.ElementRef },
{ type: i0.Renderer2 },
{ type: i0.ChangeDetectorRef }
]; };
SHFItemComponent.propDecorators = {
ngModel: [{ type: i0.ContentChild, args: [forms.NgModel,] }],
tip: [{ type: i0.Input }],
label: [{ type: i0.Input }],
col: [{ type: i0.Input }],
labelWidth: [{ type: i0.Input }],
controlClass: [{ type: i0.Input }]
};
return SHFItemComponent;
}());
var COMPONENTS$21 = [SHFWrapDirective, SHFItemComponent];
var AdSHFModule = /** @class */ (function () {
function AdSHFModule() {
}
AdSHFModule.forRoot = function () {
return { ngModule: AdSHFModule, providers: [AdSHFConfig] };
};
AdSHFModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$21.slice(),
exports: COMPONENTS$21.slice(),
},] },
];
return AdSHFModule;
}());
var G2BarComponent = /** @class */ (function () {
function G2BarComponent(el, cd, zone) {
this.el = el;
this.cd = cd;
this.zone = zone;
// region: fields
this._title = '';
this.color = 'rgba(24, 144, 255, 0.85)';
this._height = 0;
this._autoLabel = true;
// region: resize
this.autoHideXLabels = false;
this.scroll$ = null;
}
Object.defineProperty(G2BarComponent.prototype, "title", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._title = null;
this._titleTpl = value;
}
else
this._title = value;
this.cd.detectChanges();
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2BarComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2BarComponent.prototype, "autoLabel", {
get: function () {
return this._autoLabel;
},
set: function (value) {
this._autoLabel = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
G2BarComponent.prototype.runInstall = function () {
var _this = this;
this.zone.runOutsideAngular(function () { return setTimeout(function () { return _this.install(); }, 100); });
};
G2BarComponent.prototype.install = function () {
if (!this.data || (this.data && this.data.length < 1))
return;
// this.uninstall();
this.node.nativeElement.innerHTML = '';
var padding = Object.assign([], this.padding);
if (padding.length <= 0)
padding = [32, 0, this.autoHideXLabels ? 8 : 32, 40];
var chart = new G2.Chart({
container: this.node.nativeElement,
forceFit: true,
height: +this.height - 22,
legend: null,
padding: padding,
});
chart.axis('x', !this.autoHideXLabels);
chart.axis('y', {
title: false,
line: false,
tickLine: false,
});
chart.source(this.data, {
x: {
type: 'cat',
},
y: {
min: 0,
},
});
chart.tooltip({
showTitle: false,
});
chart
.interval()
.position('x*y')
.color(this.color)
.tooltip('x*y', function (x, y) {
return {
name: x,
value: y,
};
});
chart.render();
this.chart = chart;
};
G2BarComponent.prototype.uninstall = function () {
if (this.chart) {
this.chart.destroy();
this.chart = null;
}
};
G2BarComponent.prototype.ngOnInit = function () {
this.installResizeEvent();
};
G2BarComponent.prototype.ngOnChanges = function () {
this.resize();
};
G2BarComponent.prototype.ngOnDestroy = function () {
this.uninstallResizeEvent();
this.uninstall();
};
G2BarComponent.prototype.installResizeEvent = function () {
var _this = this;
if (!this.autoLabel || this.scroll$)
return;
this.scroll$ = rxjs.fromEvent(window, 'resize')
.pipe(operators.debounceTime(200))
.subscribe(function () { return _this.resize(); });
};
G2BarComponent.prototype.uninstallResizeEvent = function () {
if (this.scroll$)
this.scroll$.unsubscribe();
};
G2BarComponent.prototype.resize = function () {
var canvasWidth = this.el.nativeElement.clientWidth;
var minWidth = this.data.length * 30;
if (canvasWidth <= minWidth) {
if (!this.autoHideXLabels) {
this.autoHideXLabels = true;
this.runInstall();
return;
}
}
else if (this.autoHideXLabels) {
this.autoHideXLabels = false;
this.runInstall();
return;
}
if (!this.chart)
this.runInstall();
};
G2BarComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-bar',
template: "\n <ng-container *ngIf=\"_title; else _titleTpl\"><h4>{{_title}}</h4></ng-container>\n <div #container></div>",
host: { '[class.g2-chart]': 'true' },
changeDetection: i0.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
G2BarComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.ChangeDetectorRef },
{ type: i0.NgZone }
]; };
G2BarComponent.propDecorators = {
title: [{ type: i0.Input }],
color: [{ type: i0.Input }],
height: [{ type: i0.HostBinding, args: ['style.height.px',] }, { type: i0.Input }],
padding: [{ type: i0.Input }],
data: [{ type: i0.Input }],
autoLabel: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }]
};
return G2BarComponent;
}());
var COMPONENTS$22 = [G2BarComponent];
var AdG2BarModule = /** @class */ (function () {
function AdG2BarModule() {
}
AdG2BarModule.forRoot = function () {
return { ngModule: AdG2BarModule, providers: [] };
};
AdG2BarModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$22.slice(),
exports: COMPONENTS$22.slice(),
},] },
];
return AdG2BarModule;
}());
var G2CardComponent = /** @class */ (function () {
function G2CardComponent() {
// region fields
this._bordered = false;
this._avatar = '';
this._title = '';
this._action = '';
this.total = '';
this._height = 'auto';
this._footer = '';
this._loading = false;
// endregion
}
Object.defineProperty(G2CardComponent.prototype, "bordered", {
/** 是否显示边框 */
get: function () {
return this._bordered;
},
set: function (value) {
this._bordered = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2CardComponent.prototype, "avatar", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._avatar = null;
this._avatarTpl = value;
}
else
this._avatar = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2CardComponent.prototype, "title", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._title = null;
this._titleTpl = value;
}
else
this._title = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2CardComponent.prototype, "action", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._action = null;
this._actionTpl = value;
}
else
this._action = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2CardComponent.prototype, "contentHeight", {
set: function (value) {
this._orgHeight = value;
this._height =
typeof value === 'number' ? (this._height = value + "px") : value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2CardComponent.prototype, "footer", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._footer = null;
this._footerTpl = value;
}
else
this._footer = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2CardComponent.prototype, "loading", {
/** 是否显示Loading */
get: function () {
return this._loading;
},
set: function (value) {
this._loading = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
G2CardComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-card',
template: "\n <nz-card [nzBodyStyle]=\"{padding: '20px 24px 8px 24px'}\" [nzBordered]=\"bordered\">\n <nz-spin [nzSpinning]=\"loading\">\n <div class=\"chart-card\">\n <div class=\"chart-top\">\n <div class=\"avatar\"><ng-container *ngIf=\"_avatar; else _avatarTpl\">{{ _avatar }}</ng-container></div>\n <div class=\"meta-wrap\">\n <div class=\"meta\">\n <span class=\"title\" *ngIf=\"_title; else _titleTpl\">{{ _title }}</span>\n <span class=\"action\" *ngIf=\"_action || _actionTpl\">\n <ng-container *ngIf=\"_action; else _actionTpl\">{{ _action }}</ng-container>\n </span>\n </div>\n <p *ngIf=\"total\" class=\"total\" [innerHTML]=\"total\"></p>\n </div>\n </div>\n <div class=\"desc\" [ngStyle]=\"{'height':_height}\">\n <div [ngClass]=\"{'fixed': !!_orgHeight }\">\n <ng-content></ng-content>\n </div>\n </div>\n <div class=\"footer\" *ngIf=\"_footer || _footerTpl\">\n <ng-container *ngIf=\"_footer; else _footerTpl\">{{ _footer }}</ng-container>\n </div>\n </div>\n </nz-spin>\n </nz-card>",
host: { '[class.ad-g2-card]': 'true' },
preserveWhitespaces: false,
},] },
];
G2CardComponent.propDecorators = {
bordered: [{ type: i0.Input }],
avatar: [{ type: i0.Input }],
title: [{ type: i0.Input }],
action: [{ type: i0.Input }],
total: [{ type: i0.Input }],
contentHeight: [{ type: i0.Input }],
footer: [{ type: i0.Input }],
loading: [{ type: i0.Input }]
};
return G2CardComponent;
}());
var COMPONENTS$23 = [G2CardComponent];
var AdG2CardModule = /** @class */ (function () {
function AdG2CardModule() {
}
AdG2CardModule.forRoot = function () {
return { ngModule: AdG2CardModule, providers: [] };
};
AdG2CardModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$23.slice(),
exports: COMPONENTS$23.slice(),
},] },
];
return AdG2CardModule;
}());
var G2ChartComponent = /** @class */ (function () {
// endregion
function G2ChartComponent(el) {
this.el = el;
this._resizeTime = 0;
this.render = new i0.EventEmitter();
this.resize = new i0.EventEmitter();
this.destroy = new i0.EventEmitter();
// region: resize
this.resize$ = null;
}
Object.defineProperty(G2ChartComponent.prototype, "height", {
// region: fields
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2ChartComponent.prototype, "resizeTime", {
get: function () {
return this._resizeTime;
},
set: function (value) {
this._resizeTime = util.toNumber(value);
},
enumerable: true,
configurable: true
});
G2ChartComponent.prototype.renderChart = function () {
this.el.nativeElement.innerHTML = '';
this.render.emit(this.el);
this.installResizeEvent();
};
G2ChartComponent.prototype.ngOnInit = function () {
var _this = this;
setTimeout(function () { return _this.renderChart(); }, 200);
};
G2ChartComponent.prototype.ngOnDestroy = function () {
this.destroy.emit(this.el);
this.uninstallResizeEvent();
};
G2ChartComponent.prototype.installResizeEvent = function () {
var _this = this;
if (this.resizeTime <= 0 || !this.resize$)
return;
if (this.resizeTime <= 200)
this.resizeTime = 200;
this.resize$ = rxjs.fromEvent(window, 'resize')
.pipe(operators.debounceTime(this.resizeTime))
.subscribe(function () { return _this.resize.emit(_this.el); });
};
G2ChartComponent.prototype.uninstallResizeEvent = function () {
if (this.resize$)
this.resize$.unsubscribe();
};
G2ChartComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-chart',
template: "",
},] },
];
/** @nocollapse */
G2ChartComponent.ctorParameters = function () { return [
{ type: i0.ElementRef }
]; };
G2ChartComponent.propDecorators = {
height: [{ type: i0.HostBinding, args: ['style.height.px',] }, { type: i0.Input }],
resizeTime: [{ type: i0.Input }],
render: [{ type: i0.Output }],
resize: [{ type: i0.Output }],
destroy: [{ type: i0.Output }]
};
return G2ChartComponent;
}());
var COMPONENTS$24 = [G2ChartComponent];
var AdG2ChartModule = /** @class */ (function () {
function AdG2ChartModule() {
}
AdG2ChartModule.forRoot = function () {
return { ngModule: AdG2ChartModule, providers: [] };
};
AdG2ChartModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$24.slice(),
exports: COMPONENTS$24.slice(),
},] },
];
return AdG2ChartModule;
}());
var G2GaugeComponent = /** @class */ (function () {
function G2GaugeComponent(zone) {
this.zone = zone;
this.color = '#2F9CFF';
this.bgColor = '#F0F2F5';
this.initFlag = false;
}
Object.defineProperty(G2GaugeComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2GaugeComponent.prototype, "percent", {
get: function () {
return this._percent;
},
set: function (value) {
this._percent = util.toNumber(value);
},
enumerable: true,
configurable: true
});
G2GaugeComponent.prototype.ngOnInit = function () {
var _this = this;
this.initFlag = true;
this.zone.runOutsideAngular(function () { return setTimeout(function () { return _this.install(); }, 100); });
};
G2GaugeComponent.prototype.createData = function () {
return [{ name: this.title, value: +this.percent }];
};
G2GaugeComponent.prototype.draw = function () {
if (!this.chart)
return;
this.chart.guide().clear();
var data = this.createData();
// 绘制仪表盘背景
this.chart.guide().arc({
zIndex: 0,
top: false,
start: [0, 0.95],
end: [100, 0.95],
style: {
// 底灰色
stroke: this.bgColor,
lineWidth: 12,
},
});
// 绘制指标
this.chart.guide().arc({
zIndex: 1,
start: [0, 0.95],
end: [data[0].value, 0.95],
style: {
stroke: this.color,
lineWidth: 12,
},
});
this.chart.changeData(data);
};
G2GaugeComponent.prototype.install = function () {
this.node.nativeElement.innerHTML = '';
var Shape = G2.Shape;
// 自定义Shape 部分
Shape.registerShape('point', 'pointer', {
drawShape: function (cfg, group) {
var point = cfg.points[0]; // 获取第一个标记点
point = this.parsePoint(point);
var center = this.parsePoint({
// 获取极坐标系下画布中心点
x: 0,
y: 0,
});
// 绘制指针
group.addShape('line', {
attrs: {
x1: center.x,
y1: center.y,
x2: point.x,
y2: point.y,
stroke: cfg.color,
lineWidth: 2,
lineCap: 'round',
},
});
var origin = cfg.origin;
group.addShape('text', {
attrs: {
x: center.x,
y: center.y + 80,
text: origin._origin.value + "%",
textAlign: 'center',
fontSize: 24,
fill: 'rgba(0, 0, 0, 0.85)',
},
});
return group.addShape('circle', {
attrs: {
x: center.x,
y: center.y,
r: 9.75,
stroke: cfg.color,
lineWidth: 2,
fill: '#fff',
},
});
},
});
var data = this.createData();
var chart = new G2.Chart({
container: this.node.nativeElement,
forceFit: true,
height: this.height,
padding: [10, 10, 30, 10],
});
chart.source(data);
chart.coord('polar', {
startAngle: -1.2 * Math.PI,
endAngle: 0.2 * Math.PI,
});
chart.scale('value', {
min: 0,
max: 100,
nice: true,
tickCount: 6,
});
chart.axis('1', false);
// 刻度值
chart.axis('value', {
zIndex: 2,
line: null,
label: {
offset: -12,
formatter: this.format,
},
tickLine: null,
grid: null,
});
chart.legend(false);
chart
.point({
generatePoints: true,
})
.position('value*1')
.shape('pointer')
.color(this.color)
.active(false);
this.chart = chart;
this.draw();
};
G2GaugeComponent.prototype.uninstall = function () {
if (this.chart)
this.chart.destroy();
};
G2GaugeComponent.prototype.ngOnChanges = function () {
if (this.initFlag)
this.draw();
};
G2GaugeComponent.prototype.ngOnDestroy = function () {
this.uninstall();
};
G2GaugeComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-gauge',
template: "<div #container></div>",
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
G2GaugeComponent.ctorParameters = function () { return [
{ type: i0.NgZone }
]; };
G2GaugeComponent.propDecorators = {
title: [{ type: i0.Input }],
height: [{ type: i0.Input }],
color: [{ type: i0.Input }],
bgColor: [{ type: i0.Input }],
format: [{ type: i0.Input }],
percent: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }]
};
return G2GaugeComponent;
}());
var COMPONENTS$25 = [G2GaugeComponent];
var AdG2GaugeModule = /** @class */ (function () {
function AdG2GaugeModule() {
}
AdG2GaugeModule.forRoot = function () {
return { ngModule: AdG2GaugeModule, providers: [] };
};
AdG2GaugeModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$25.slice(),
exports: COMPONENTS$25.slice(),
},] },
];
return AdG2GaugeModule;
}());
var G2MiniAreaComponent = /** @class */ (function () {
function G2MiniAreaComponent(zone) {
this.zone = zone;
// region: fields
this.color = 'rgba(24, 144, 255, 0.2)';
this.borderColor = '#1890FF';
this._borderWidth = 2;
this._fit = true;
this._line = false;
this._animate = true;
this.padding = [8, 8, 8, 8];
}
Object.defineProperty(G2MiniAreaComponent.prototype, "borderWidth", {
get: function () {
return this._borderWidth;
},
set: function (value) {
this._borderWidth = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2MiniAreaComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2MiniAreaComponent.prototype, "fit", {
get: function () {
return this._fit;
},
set: function (value) {
this._fit = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2MiniAreaComponent.prototype, "line", {
get: function () {
return this._line;
},
set: function (value) {
this._line = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2MiniAreaComponent.prototype, "animate", {
get: function () {
return this._animate;
},
set: function (value) {
this._animate = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
G2MiniAreaComponent.prototype.install = function () {
if (!this.data || (this.data && this.data.length < 1))
return;
this.node.nativeElement.innerHTML = '';
var chart = new G2.Chart({
container: this.node.nativeElement,
forceFit: this.fit,
height: +this.height,
animate: this.animate,
padding: this.padding,
legend: null,
});
if (!this.xAxis && !this.yAxis) {
chart.axis(false);
}
if (this.xAxis) {
chart.axis('x', this.xAxis);
}
else {
chart.axis('x', false);
}
if (this.yAxis) {
chart.axis('y', this.yAxis);
}
else {
chart.axis('y', false);
}
var dataConfig = {
x: {
type: 'cat',
range: [0, 1],
xAxis: this.xAxis,
},
y: {
min: 0,
yAxis: this.yAxis,
},
};
chart.tooltip({
showTitle: false,
hideMarkders: false,
'g2-tooltip': { padding: 4 },
'g2-tooltip-list-item': { margin: "0px 4px" },
});
var view = chart.view();
view.source(this.data, dataConfig);
view
.area()
.position('x*y')
.color(this.color)
.tooltip('x*y', function (x, y) {
return {
name: x,
value: y,
};
})
.shape('smooth')
.style({ fillOpacity: 1 });
if (this.line) {
var view2 = chart.view();
view2.source(this.data, dataConfig);
view2
.line()
.position('x*y')
.color(this.borderColor)
.size(this.borderWidth)
.shape('smooth');
view2.tooltip(false);
}
chart.render();
this.chart = chart;
};
G2MiniAreaComponent.prototype.uninstall = function () {
if (this.chart) {
this.chart.destroy();
this.chart = null;
}
};
G2MiniAreaComponent.prototype.ngOnChanges = function (changes) {
var _this = this;
this.zone.runOutsideAngular(function () { return setTimeout(function () { return _this.install(); }, 100); });
};
G2MiniAreaComponent.prototype.ngOnDestroy = function () {
this.uninstall();
};
G2MiniAreaComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-mini-area',
template: "<div #container></div>",
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
G2MiniAreaComponent.ctorParameters = function () { return [
{ type: i0.NgZone }
]; };
G2MiniAreaComponent.propDecorators = {
color: [{ type: i0.Input }],
borderColor: [{ type: i0.Input }],
borderWidth: [{ type: i0.Input }],
height: [{ type: i0.HostBinding, args: ['style.height.px',] }, { type: i0.Input }],
fit: [{ type: i0.Input }],
line: [{ type: i0.Input }],
animate: [{ type: i0.Input }],
xAxis: [{ type: i0.Input }],
yAxis: [{ type: i0.Input }],
padding: [{ type: i0.Input }],
data: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }]
};
return G2MiniAreaComponent;
}());
var COMPONENTS$26 = [G2MiniAreaComponent];
var AdG2MiniAreaModule = /** @class */ (function () {
function AdG2MiniAreaModule() {
}
AdG2MiniAreaModule.forRoot = function () {
return { ngModule: AdG2MiniAreaModule, providers: [] };
};
AdG2MiniAreaModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$26.slice(),
exports: COMPONENTS$26.slice(),
},] },
];
return AdG2MiniAreaModule;
}());
var G2MiniBarComponent = /** @class */ (function () {
function G2MiniBarComponent(zone) {
this.zone = zone;
// region: fields
this.color = '#1890FF';
this._height = 0;
this._borderWidth = 5;
this.padding = [8, 8, 8, 8];
}
Object.defineProperty(G2MiniBarComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2MiniBarComponent.prototype, "borderWidth", {
get: function () {
return this._borderWidth;
},
set: function (value) {
this._borderWidth = util.toNumber(value);
},
enumerable: true,
configurable: true
});
G2MiniBarComponent.prototype.install = function () {
if (!this.data || (this.data && this.data.length < 1))
return;
this.node.nativeElement.innerHTML = '';
var chart = new G2.Chart({
container: this.node.nativeElement,
forceFit: true,
height: +this.height,
padding: this.padding,
legend: null,
});
chart.axis(false);
chart.source(this.data, {
x: {
type: 'cat',
},
y: {
min: 0,
},
});
chart.tooltip({
showTitle: false,
hideMarkders: false,
crosshairs: false,
'g2-tooltip': { padding: 4 },
'g2-tooltip-list-item': { margin: "0px 4px" },
});
chart
.interval()
.position('x*y')
.size(this.borderWidth)
.color(this.color)
.tooltip('x*y', function (x, y) {
return {
name: x,
value: y,
};
});
chart.render();
this.chart = chart;
};
G2MiniBarComponent.prototype.uninstall = function () {
if (this.chart) {
this.chart.destroy();
this.chart = null;
}
};
G2MiniBarComponent.prototype.ngOnChanges = function (changes) {
var _this = this;
this.zone.runOutsideAngular(function () { return setTimeout(function () { return _this.install(); }, 100); });
};
G2MiniBarComponent.prototype.ngOnDestroy = function () {
this.uninstall();
};
G2MiniBarComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-mini-bar',
template: "<div #container></div>",
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
G2MiniBarComponent.ctorParameters = function () { return [
{ type: i0.NgZone }
]; };
G2MiniBarComponent.propDecorators = {
color: [{ type: i0.Input }],
height: [{ type: i0.HostBinding, args: ['style.height.px',] }, { type: i0.Input }],
borderWidth: [{ type: i0.Input }],
padding: [{ type: i0.Input }],
data: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }]
};
return G2MiniBarComponent;
}());
var COMPONENTS$27 = [G2MiniBarComponent];
var AdG2MiniBarModule = /** @class */ (function () {
function AdG2MiniBarModule() {
}
AdG2MiniBarModule.forRoot = function () {
return { ngModule: AdG2MiniBarModule, providers: [] };
};
AdG2MiniBarModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
declarations: COMPONENTS$27.slice(),
exports: COMPONENTS$27.slice(),
},] },
];
return AdG2MiniBarModule;
}());
var G2ProgressComponent = /** @class */ (function () {
function G2ProgressComponent() {
// region: fields
this.color = '#1890FF';
// endregion
}
Object.defineProperty(G2ProgressComponent.prototype, "target", {
get: function () {
return this._target;
},
set: function (value) {
this._target = Math.min(Math.max(util.toNumber(value), 0), 100);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2ProgressComponent.prototype, "strokeWidth", {
get: function () {
return this._strokeWidth;
},
set: function (value) {
this._strokeWidth = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2ProgressComponent.prototype, "percent", {
get: function () {
return this._percent;
},
set: function (value) {
this._percent = Math.min(Math.max(util.toNumber(value), 0), 100);
},
enumerable: true,
configurable: true
});
G2ProgressComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-mini-progress',
template: "\n <nz-tooltip [nzTitle]=\"'\u76EE\u6807\u503C: ' + target + '%'\">\n <div nz-tooltip class=\"target\" [ngStyle]=\"{'left.%': target}\">\n <span [ngStyle]=\"{'background-color': color}\"></span>\n <span [ngStyle]=\"{'background-color': color}\"></span>\n </div>\n </nz-tooltip>\n <div class=\"progress-wrap\">\n <div class=\"progress\" [ngStyle]=\"{'background-color': color, 'width.%': percent, 'height.px':strokeWidth}\"></div>\n </div>\n ",
host: { '[class.ad-g2-progress]': 'true' },
preserveWhitespaces: false,
},] },
];
G2ProgressComponent.propDecorators = {
color: [{ type: i0.Input }],
target: [{ type: i0.Input }],
strokeWidth: [{ type: i0.Input }],
percent: [{ type: i0.Input }]
};
return G2ProgressComponent;
}());
var COMPONENTS$28 = [G2ProgressComponent];
var AdG2MiniProgressModule = /** @class */ (function () {
function AdG2MiniProgressModule() {
}
AdG2MiniProgressModule.forRoot = function () {
return { ngModule: AdG2MiniProgressModule, providers: [] };
};
AdG2MiniProgressModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$28.slice(),
exports: COMPONENTS$28.slice(),
},] },
];
return AdG2MiniProgressModule;
}());
var G2PieComponent = /** @class */ (function () {
function G2PieComponent(el, cd, zone) {
this.el = el;
this.cd = cd;
this.zone = zone;
this._animate = true;
this.color = 'rgba(24, 144, 255, 0.85)';
this._height = 0;
this._hasLegend = false;
this._legendBlock = false;
this.inner = 0.75;
this.padding = [12, 0, 12, 0];
this._tooltip = true;
this._lineWidth = 0;
this._select = true;
this.initFlag = false;
this.legendData = [];
// region: resize
this.scroll$ = null;
}
Object.defineProperty(G2PieComponent.prototype, "animate", {
// region: fields
get: function () {
return this._animate;
},
set: function (value) {
this._animate = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2PieComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2PieComponent.prototype, "hasLegend", {
get: function () {
return this._hasLegend;
},
set: function (value) {
this._hasLegend = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2PieComponent.prototype, "legendBlock", {
get: function () {
return this._legendBlock;
},
set: function (value) {
this._legendBlock = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2PieComponent.prototype, "percent", {
get: function () {
return this._percent;
},
set: function (value) {
this._percent = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2PieComponent.prototype, "tooltip", {
get: function () {
return this._tooltip;
},
set: function (value) {
this._tooltip = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2PieComponent.prototype, "lineWidth", {
get: function () {
return this._lineWidth;
},
set: function (value) {
this._lineWidth = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2PieComponent.prototype, "select", {
get: function () {
return this._select;
},
set: function (value) {
this._select = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
G2PieComponent.prototype.runInstall = function () {
var _this = this;
this.zone.runOutsideAngular(function () { return setTimeout(function () { return _this.install(); }, 100); });
};
G2PieComponent.prototype.install = function () {
var _this = this;
var formatColor;
var isPercent = typeof this.percent !== 'undefined';
if (isPercent) {
this.select = false;
this.tooltip = false;
formatColor = function (value) {
return value === '占比' ? _this.color || 'rgba(24, 144, 255, 0.85)' : '#F0F2F5';
};
this.data = [
{
x: '占比',
y: this.percent,
},
{
x: '反比',
y: 100 - this.percent,
},
];
}
if (!this.data || (this.data && this.data.length < 1))
return;
this.node.nativeElement.innerHTML = '';
var chart = new G2.Chart({
container: this.node.nativeElement,
forceFit: true,
height: this.height,
padding: this.padding,
animate: this.animate,
});
if (!this.tooltip) {
chart.tooltip(false);
}
else {
chart.tooltip({
showTitle: false,
itemTpl: '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value} %</li>',
});
}
chart.axis(false);
chart.legend(false);
var dv = new DataSet.DataView();
dv.source(this.data).transform({
type: 'percent',
field: 'y',
dimension: 'x',
as: 'percent',
});
chart.source(dv, {
x: {
type: 'cat',
range: [0, 1],
},
y: {
min: 0,
},
});
chart.coord('theta', { innerRadius: this.inner });
chart
.intervalStack()
.position('y')
.style({ lineWidth: this.lineWidth, stroke: '#fff' })
.tooltip('x*percent', function (item, percent) {
return {
name: item,
value: percent,
};
})
.color('x', isPercent ? formatColor : this.colors)
.select(this.select);
chart.render();
this.chart = chart;
if (this.hasLegend) {
this.zone.run(function () {
_this.legendData = chart
.getAllGeoms()[0]
._attrs.dataArray.map(function (item) {
var origin = item[0]._origin;
origin.color = item[0].color;
origin.checked = true;
origin.percent = (origin.percent * 100).toFixed(2);
return origin;
});
_this.cd.detectChanges();
});
}
};
G2PieComponent.prototype.uninstall = function () {
if (this.chart) {
this.chart.destroy();
this.chart = null;
}
};
G2PieComponent.prototype.handleLegendClick = function (i) {
this.legendData[i].checked = !this.legendData[i].checked;
if (this.chart) {
this.chart.filter('x', function (val, item) { return item.checked; });
this.chart.repaint();
}
};
G2PieComponent.prototype.ngOnInit = function () {
this.installResizeEvent();
};
G2PieComponent.prototype.ngAfterViewInit = function () {
this.initFlag = true;
this.runInstall();
};
G2PieComponent.prototype.ngOnChanges = function () {
if (this.initFlag)
this.runInstall();
};
G2PieComponent.prototype.ngOnDestroy = function () {
this.uninstallResizeEvent();
this.uninstall();
};
G2PieComponent.prototype.installResizeEvent = function () {
var _this = this;
if (!this.hasLegend)
return;
this.scroll$ = rxjs.fromEvent(window, 'resize')
.pipe(operators.debounceTime(200))
.subscribe(function () { return _this.resize(); });
};
G2PieComponent.prototype.uninstallResizeEvent = function () {
if (this.scroll$)
this.scroll$.unsubscribe();
};
G2PieComponent.prototype.resize = function () {
if (this.el.nativeElement.clientWidth <= 380) {
if (!this.legendBlock) {
this.legendBlock = true;
}
}
else if (this.legendBlock) {
this.legendBlock = false;
}
if (!this.chart)
this.runInstall();
};
G2PieComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-pie',
template: "\n <div class=\"chart\">\n <div #container></div>\n <div *ngIf=\"subTitle || total\" class=\"total\">\n <h4 *ngIf=\"subTitle\" class=\"pie-sub-title\" [innerHTML]=\"subTitle\"></h4>\n <div *ngIf=\"total\" class=\"pie-stat\" [innerHTML]=\"total\"></div>\n </div>\n </div>\n <ul *ngIf=\"hasLegend && legendData?.length\" class=\"legend\">\n <li *ngFor=\"let item of legendData; let index = index\" (click)=\"handleLegendClick(index)\">\n <span class=\"dot\" [ngStyle]=\"{'background-color': !item.checked ? '#aaa' : item.color}\"></span>\n <span class=\"legend-title\">{{item.x}}</span>\n <nz-divider nzType=\"vertical\"></nz-divider>\n <span class=\"percent\">{{item.percent}}%</span>\n <span class=\"value\" [innerHTML]=\"valueFormat ? valueFormat(item.y) : item.y\"></span>\n </li>\n </ul>",
host: { '[class.ad-pie]': 'true' },
changeDetection: i0.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
G2PieComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.ChangeDetectorRef },
{ type: i0.NgZone }
]; };
G2PieComponent.propDecorators = {
animate: [{ type: i0.Input }],
color: [{ type: i0.Input }],
subTitle: [{ type: i0.Input }],
total: [{ type: i0.Input }],
height: [{ type: i0.Input }],
hasLegend: [{ type: i0.HostBinding, args: ['class.has-legend',] }, { type: i0.Input }],
legendBlock: [{ type: i0.HostBinding, args: ['class.legend-block',] }, { type: i0.Input }],
inner: [{ type: i0.Input }],
padding: [{ type: i0.Input }],
percent: [{ type: i0.Input }],
tooltip: [{ type: i0.Input }],
lineWidth: [{ type: i0.Input }],
select: [{ type: i0.Input }],
data: [{ type: i0.Input }],
valueFormat: [{ type: i0.Input }],
colors: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }]
};
return G2PieComponent;
}());
var COMPONENTS$29 = [G2PieComponent];
var AdG2PieModule = /** @class */ (function () {
function AdG2PieModule() {
}
AdG2PieModule.forRoot = function () {
return { ngModule: AdG2PieModule, providers: [] };
};
AdG2PieModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$29.slice(),
exports: COMPONENTS$29.slice(),
},] },
];
return AdG2PieModule;
}());
var G2RadarComponent = /** @class */ (function () {
function G2RadarComponent(el, cd, zone) {
this.el = el;
this.cd = cd;
this.zone = zone;
// region: fields
this._title = '';
this._height = 0;
this.padding = [44, 30, 16, 30];
this._hasLegend = true;
this._tickCount = 4;
this.data = [];
this.initFlag = false;
this.legendData = [];
}
Object.defineProperty(G2RadarComponent.prototype, "title", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._title = null;
this._titleTpl = value;
}
else
this._title = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2RadarComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2RadarComponent.prototype, "hasLegend", {
get: function () {
return this._hasLegend;
},
set: function (value) {
this._hasLegend = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2RadarComponent.prototype, "tickCount", {
get: function () {
return this._tickCount;
},
set: function (value) {
this._tickCount = util.toNumber(value);
},
enumerable: true,
configurable: true
});
G2RadarComponent.prototype.handleLegendClick = function (i) {
var _this = this;
this.legendData[i].checked = !this.legendData[i].checked;
if (this.chart) {
// const filterItem = this.legendData.filter(l => l.checked).map(l => l.name);
this.chart.filter('name', function (val) { return _this.legendData.find(function (w) { return w.name === val; }).checked; });
this.chart.repaint();
}
};
G2RadarComponent.prototype.runInstall = function () {
var _this = this;
this.zone.runOutsideAngular(function () { return setTimeout(function () { return _this.install(); }, 100); });
};
G2RadarComponent.prototype.install = function () {
var _this = this;
if (!this.data || (this.data && this.data.length < 1))
return;
this.node.nativeElement.innerHTML = '';
var colors = [
'#1890FF',
'#FACC14',
'#2FC25B',
'#8543E0',
'#F04864',
'#13C2C2',
'#fa8c16',
'#a0d911',
];
var chart = new G2.Chart({
container: this.node.nativeElement,
forceFit: true,
height: +this.height - (this.hasLegend ? 80 : 22),
padding: this.padding,
});
chart.source(this.data, {
value: {
min: 0,
tickCount: this.tickCount,
},
});
chart.coord('polar');
chart.legend(false);
chart.axis('label', {
line: null,
labelOffset: 8,
labels: {
label: {
fill: 'rgba(0, 0, 0, .65)',
},
},
grid: {
line: {
stroke: '#e9e9e9',
lineWidth: 1,
lineDash: [0, 0],
},
},
});
chart.axis('value', {
grid: {
type: 'polygon',
line: {
stroke: '#e9e9e9',
lineWidth: 1,
lineDash: [0, 0],
},
},
labels: {
label: {
fill: 'rgba(0, 0, 0, .65)',
},
},
});
chart
.line()
.position('label*value')
.color('name', colors);
chart
.point()
.position('label*value')
.color('name', colors)
.shape('circle')
.size(3);
chart.render();
this.chart = chart;
if (this.hasLegend) {
this.zone.run(function () {
_this.legendData = chart
.getAllGeoms()[0]
._attrs.dataArray.map(function (item) {
var origin = item[0]._origin;
var result = {
name: origin.name,
color: item[0].color,
checked: true,
value: item.reduce(function (p, n) { return p + n._origin.value; }, 0),
};
return result;
});
_this.cd.detectChanges();
});
}
};
G2RadarComponent.prototype.uninstall = function () {
if (this.chart) {
this.chart.destroy();
this.chart = null;
}
};
G2RadarComponent.prototype.ngOnInit = function () {
this.initFlag = true;
this.runInstall();
};
G2RadarComponent.prototype.ngOnChanges = function (changes) {
if (this.initFlag)
this.runInstall();
};
G2RadarComponent.prototype.ngOnDestroy = function () {
this.uninstall();
};
G2RadarComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-radar',
template: "\n <h4 *ngIf=\"_title; else _titleTpl\">{{ _title }}</h4>\n <div #container></div>\n <div nz-row class=\"legend\" *ngIf=\"hasLegend\">\n <div nz-col [nzSpan]=\"24 / legendData.length\" *ngFor=\"let i of legendData; let idx = index\" (click)=\"handleLegendClick(idx)\">\n <div class=\"legend-item\">\n <p>\n <i class=\"dot\" [ngStyle]=\"{'background-color': !i.checked ? '#aaa' : i.color}\"></i>\n <span>{{i.name}}</span>\n </p>\n <h6>{{i.value}}</h6>\n </div>\n </div>\n </div>",
host: { '[class.ad-radar]': 'true' },
changeDetection: i0.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
G2RadarComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.ChangeDetectorRef },
{ type: i0.NgZone }
]; };
G2RadarComponent.propDecorators = {
title: [{ type: i0.Input }],
height: [{ type: i0.HostBinding, args: ['style.height.px',] }, { type: i0.Input }],
padding: [{ type: i0.Input }],
hasLegend: [{ type: i0.Input }],
tickCount: [{ type: i0.Input }],
data: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }]
};
return G2RadarComponent;
}());
var COMPONENTS$30 = [G2RadarComponent];
var AdG2RadarModule = /** @class */ (function () {
function AdG2RadarModule() {
}
AdG2RadarModule.forRoot = function () {
return { ngModule: AdG2RadarModule, providers: [] };
};
AdG2RadarModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$30.slice(),
exports: COMPONENTS$30.slice(),
},] },
];
return AdG2RadarModule;
}());
var G2TagCloudComponent = /** @class */ (function () {
function G2TagCloudComponent(el, cd, zone) {
this.el = el;
this.cd = cd;
this.zone = zone;
// region: fields
this.color = 'rgba(24, 144, 255, 0.85)';
this._height = 0;
this.padding = 0;
this._autoLabel = true;
this.initFlag = false;
}
Object.defineProperty(G2TagCloudComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
this.cd.detectChanges();
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2TagCloudComponent.prototype, "autoLabel", {
get: function () {
return this._autoLabel;
},
set: function (value) {
this._autoLabel = util.toBoolean(value);
},
enumerable: true,
configurable: true
});
G2TagCloudComponent.prototype.initTagCloud = function () {
// 给point注册一个词云的shape
G2.Shape.registerShape('point', 'cloud', {
drawShape: function (cfg, container) {
var attrs = Object.assign({}, {
fillOpacity: cfg.opacity,
fontSize: cfg.origin._origin.size,
rotate: cfg.origin._origin.rotate,
text: cfg.origin._origin.text,
textAlign: 'center',
fontFamily: cfg.origin._origin.font,
fill: cfg.color,
textBaseline: 'Alphabetic',
}, cfg.style);
return container.addShape('text', {
attrs: Object.assign(attrs, {
x: cfg.x,
y: cfg.y,
}),
});
},
});
};
G2TagCloudComponent.prototype.renderChart = function () {
if (!this.data || (this.data && this.data.length < 1))
return;
this.node.nativeElement.innerHTML = '';
var dv = new DataSet.View().source(this.data);
var range = dv.range('value');
var min = range[0];
var max = range[1];
var height = +this.height;
var width = +this.el.nativeElement.offsetWidth;
dv.transform({
type: 'tag-cloud',
fields: ['name', 'value'],
size: [width, height],
padding: this.padding,
timeInterval: 5000,
rotate: function () {
var random = ~~(Math.random() * 4) % 4;
if (random === 2) {
random = 0;
}
return random * 90; // 0, 90, 270
},
fontSize: function (d) {
if (d.value) {
return (d.value - min) / (max - min) * (80 - 24) + 24;
}
return 0;
},
});
var chart = new G2.Chart({
container: this.node.nativeElement,
width: width,
height: height,
padding: this.padding,
forceFit: true,
});
chart.source(dv, {
x: { nice: false },
y: { nice: false },
});
chart.legend(false);
chart.axis(false);
chart.tooltip({
showTitle: false,
});
chart.coord().reflect();
chart
.point()
.position('x*y')
.color('text')
.shape('cloud')
.tooltip('value*category');
chart.render();
this.chart = chart;
};
G2TagCloudComponent.prototype.uninstall = function () {
if (this.chart) {
this.chart.destroy();
this.chart = null;
}
};
G2TagCloudComponent.prototype.ngOnInit = function () {
var _this = this;
this.initFlag = true;
this.zone.runOutsideAngular(function () {
return setTimeout(function () {
_this.initTagCloud();
_this.renderChart();
}, 100);
});
};
G2TagCloudComponent.prototype.ngOnChanges = function () {
var _this = this;
if (this.initFlag) {
this.zone.runOutsideAngular(function () {
return setTimeout(function () { return _this.renderChart(); }, 100);
});
}
};
G2TagCloudComponent.prototype.ngOnDestroy = function () {
this.uninstall();
};
G2TagCloudComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-tag-cloud',
template: "<div #container [ngStyle]=\"{'height.px': height}\"></div>",
changeDetection: i0.ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
G2TagCloudComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.ChangeDetectorRef },
{ type: i0.NgZone }
]; };
G2TagCloudComponent.propDecorators = {
color: [{ type: i0.Input }],
height: [{ type: i0.Input }],
padding: [{ type: i0.Input }],
data: [{ type: i0.Input }],
autoLabel: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }]
};
return G2TagCloudComponent;
}());
var COMPONENTS$31 = [G2TagCloudComponent];
var AdG2TagCloudModule = /** @class */ (function () {
function AdG2TagCloudModule() {
}
AdG2TagCloudModule.forRoot = function () {
return { ngModule: AdG2TagCloudModule, providers: [] };
};
AdG2TagCloudModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$31.slice(),
exports: COMPONENTS$31.slice(),
},] },
];
return AdG2TagCloudModule;
}());
var G2TimelineComponent = /** @class */ (function () {
function G2TimelineComponent(cd, zone) {
this.cd = cd;
this.zone = zone;
// region: fields
this._title = '';
this.colorMap = { y1: '#1890FF', y2: '#2FC25B' };
this.mask = 'HH:mm';
this.position = 'top';
this._height = 400;
this.padding = [60, 20, 40, 40];
this._borderWidth = 2;
this.initFlag = false;
}
Object.defineProperty(G2TimelineComponent.prototype, "title", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._title = null;
this._titleTpl = value;
}
else {
this._title = value;
}
this.cd.detectChanges();
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2TimelineComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2TimelineComponent.prototype, "borderWidth", {
get: function () {
return this._borderWidth;
},
set: function (value) {
this._borderWidth = util.toNumber(value);
},
enumerable: true,
configurable: true
});
G2TimelineComponent.prototype.ngOnInit = function () {
this.initFlag = true;
};
G2TimelineComponent.prototype.ngAfterViewInit = function () {
this.runInstall();
};
G2TimelineComponent.prototype.runInstall = function () {
var _this = this;
this.zone.runOutsideAngular(function () {
setTimeout(function () { return _this.install(); }, 100);
});
};
G2TimelineComponent.prototype.install = function () {
if (!this.data || (this.data && this.data.length < 1))
return;
// clean
this.sliderNode.nativeElement.innerHTML = '';
this.node.nativeElement.innerHTML = '';
var MAX = 8;
var begin = this.data.length > MAX ? (this.data.length - MAX) / 2 : 0;
var ds = new DataSet({
state: {
start: this.data[begin - 1].x,
end: this.data[begin - 1 + MAX].x,
},
});
var dv = ds.createView().source(this.data);
dv.source(this.data).transform({
type: 'filter',
callback: function (obj) {
var time = new Date(obj.x).getTime(); // !注意:时间格式,建议转换为时间戳进行比较
return time >= ds.state.start && time <= ds.state.end;
},
});
var chart = new G2.Chart({
container: this.node.nativeElement,
forceFit: true,
height: +this.height,
padding: this.padding,
});
chart.axis('x', { title: false });
chart.axis('y1', {
title: false,
});
chart.axis('y2', false);
var max;
if (this.data[0] && this.data[0].y1 && this.data[0].y2) {
max = Math.max(this.data.sort(function (a, b) { return b.y1 - a.y1; })[0].y1, this.data.sort(function (a, b) { return b.y2 - a.y2; })[0].y2);
}
chart.source(dv, {
x: {
type: 'timeCat',
tickCount: MAX,
mask: this.mask,
range: [0, 1],
},
y1: {
alias: this.titleMap.y1,
max: max,
min: 0,
},
y2: {
alias: this.titleMap.y2,
max: max,
min: 0,
},
});
chart.legend({
position: this.position,
custom: true,
clickable: false,
items: [
{ value: this.titleMap.y1, fill: this.colorMap.y1 },
{ value: this.titleMap.y2, fill: this.colorMap.y2 },
],
});
chart
.line()
.position('x*y1')
.color(this.colorMap.y1)
.size(this.borderWidth);
chart
.line()
.position('x*y2')
.color(this.colorMap.y2)
.size(this.borderWidth);
chart.render();
var sliderPadding = Object.assign([], this.padding);
sliderPadding[0] = 0;
var slider = new Slider({
container: this.sliderNode.nativeElement,
height: 26,
padding: sliderPadding,
scales: {
x: {
type: 'time',
tickCount: 16,
mask: this.mask,
},
},
backgroundChart: {
type: 'line',
},
start: ds.state.start,
end: ds.state.end,
xAxis: 'x',
yAxis: 'y1',
data: this.data,
onChange: function (_a) {
var startValue = _a.startValue, endValue = _a.endValue;
ds.setState('start', startValue);
ds.setState('end', endValue);
},
});
slider.render();
this.chart = chart;
this.slider = slider;
};
G2TimelineComponent.prototype.uninstall = function () {
if (this.chart)
this.chart.destroy();
if (this.slider)
this.slider.destroy();
};
G2TimelineComponent.prototype.ngOnChanges = function () {
if (this.initFlag)
this.runInstall();
};
G2TimelineComponent.prototype.ngOnDestroy = function () {
this.uninstall();
};
G2TimelineComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-timeline',
template: "\n <ng-container *ngIf=\"_title; else _titleTpl\"><h4>{{_title}}</h4></ng-container>\n <div #container></div>\n <div #slider></div>",
changeDetection: i0.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
G2TimelineComponent.ctorParameters = function () { return [
{ type: i0.ChangeDetectorRef },
{ type: i0.NgZone }
]; };
G2TimelineComponent.propDecorators = {
title: [{ type: i0.Input }],
data: [{ type: i0.Input }],
titleMap: [{ type: i0.Input }],
colorMap: [{ type: i0.Input }],
mask: [{ type: i0.Input }],
position: [{ type: i0.Input }],
height: [{ type: i0.Input }],
padding: [{ type: i0.Input }],
borderWidth: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }],
sliderNode: [{ type: i0.ViewChild, args: ['slider',] }]
};
return G2TimelineComponent;
}());
var COMPONENTS$32 = [G2TimelineComponent];
var AdG2TimelineModule = /** @class */ (function () {
function AdG2TimelineModule() {
}
AdG2TimelineModule.forRoot = function () {
return { ngModule: AdG2TimelineModule, providers: [] };
};
AdG2TimelineModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$32.slice(),
exports: COMPONENTS$32.slice(),
},] },
];
return AdG2TimelineModule;
}());
var G2WaterWaveComponent = /** @class */ (function () {
function G2WaterWaveComponent(el, renderer, cd, zone) {
this.el = el;
this.renderer = renderer;
this.cd = cd;
this.zone = zone;
// region: fields
this._title = '';
this.color = '#1890FF';
this._height = 160;
this.initFlag = false;
this.scroll$ = null;
}
Object.defineProperty(G2WaterWaveComponent.prototype, "title", {
set: function (value) {
if (value instanceof i0.TemplateRef) {
this._title = null;
this._titleTpl = value;
}
else {
this._title = value;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2WaterWaveComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = util.toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2WaterWaveComponent.prototype, "percent", {
get: function () {
return this._percent;
},
set: function (value) {
this._percent = util.toNumber(value);
},
enumerable: true,
configurable: true
});
G2WaterWaveComponent.prototype.renderChart = function () {
var data = this.percent / 100;
if (!data)
return;
this.node.nativeElement.innerHTML = '';
var self = this;
var canvas = this.node.nativeElement;
var ctx = canvas.getContext('2d');
var canvasWidth = canvas.width;
var canvasHeight = canvas.height;
var radius = canvasWidth / 2;
var lineWidth = 2;
var cR = radius - lineWidth;
ctx.beginPath();
ctx.lineWidth = lineWidth * 2;
var axisLength = canvasWidth - lineWidth;
var unit = axisLength / 8;
var range = 0.2; // 振幅
var currRange = range;
var xOffset = lineWidth;
var sp = 0; // 周期偏移量
var currData = 0;
var waveupsp = 0.005; // 水波上涨速度
var arcStack = [];
var bR = radius - lineWidth;
var circleOffset = -(Math.PI / 2);
var circleLock = true;
for (var i = circleOffset; i < circleOffset + 2 * Math.PI; i += 1 / (8 * Math.PI)) {
arcStack.push([radius + bR * Math.cos(i), radius + bR * Math.sin(i)]);
}
var cStartPoint = arcStack.shift();
ctx.strokeStyle = this.color;
ctx.moveTo(cStartPoint[0], cStartPoint[1]);
function drawSin() {
ctx.beginPath();
ctx.save();
var sinStack = [];
for (var i = xOffset; i <= xOffset + axisLength; i += 20 / axisLength) {
var x = sp + (xOffset + i) / unit;
var y = Math.sin(x) * currRange;
var dx = i;
var dy = 2 * cR * (1 - currData) + (radius - cR) - unit * y;
ctx.lineTo(dx, dy);
sinStack.push([dx, dy]);
}
var startPoint = sinStack.shift();
ctx.lineTo(xOffset + axisLength, canvasHeight);
ctx.lineTo(xOffset, canvasHeight);
ctx.lineTo(startPoint[0], startPoint[1]);
var gradient = ctx.createLinearGradient(0, 0, 0, canvasHeight);
gradient.addColorStop(0, '#ffffff');
gradient.addColorStop(1, '#1890FF');
ctx.fillStyle = gradient;
ctx.fill();
ctx.restore();
}
function render() {
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
if (circleLock) {
if (arcStack.length) {
var temp = arcStack.shift();
ctx.lineTo(temp[0], temp[1]);
ctx.stroke();
}
else {
circleLock = false;
ctx.lineTo(cStartPoint[0], cStartPoint[1]);
ctx.stroke();
arcStack = null;
ctx.globalCompositeOperation = 'destination-over';
ctx.beginPath();
ctx.lineWidth = lineWidth;
ctx.arc(radius, radius, bR, 0, 2 * Math.PI, true);
ctx.beginPath();
ctx.save();
ctx.arc(radius, radius, radius - 3 * lineWidth, 0, 2 * Math.PI, true);
ctx.restore();
ctx.clip();
ctx.fillStyle = '#1890FF';
}
}
else {
if (data >= 0.85) {
if (currRange > range / 4) {
var t = range * 0.01;
currRange -= t;
}
}
else if (data <= 0.1) {
if (currRange < range * 1.5) {
var t = range * 0.01;
currRange += t;
}
}
else {
if (currRange <= range) {
var t = range * 0.01;
currRange += t;
}
if (currRange >= range) {
var t = range * 0.01;
currRange -= t;
}
}
if (data - currData > 0) {
currData += waveupsp;
}
if (data - currData < 0) {
currData -= waveupsp;
}
sp += 0.07;
drawSin();
}
self.timer = requestAnimationFrame(render);
}
render();
};
G2WaterWaveComponent.prototype.uninstall = function () { };
G2WaterWaveComponent.prototype.updateRadio = function (radio) {
this.renderer.setStyle(this.el.nativeElement, 'transform', "scale(" + radio + ")");
};
G2WaterWaveComponent.prototype.ngOnInit = function () {
var _this = this;
this.initFlag = true;
this.cd.detectChanges();
this.zone.runOutsideAngular(function () {
_this.updateRadio(1);
_this.installResizeEvent();
setTimeout(function () { return _this.resize(); }, 130);
});
};
G2WaterWaveComponent.prototype.ngOnChanges = function () {
var _this = this;
if (this.initFlag) {
this.cd.detectChanges();
this.zone.runOutsideAngular(function () { return _this.renderChart(); });
}
};
G2WaterWaveComponent.prototype.ngOnDestroy = function () {
if (this.timer)
cancelAnimationFrame(this.timer);
this.uninstallResizeEvent();
this.uninstall();
};
G2WaterWaveComponent.prototype.installResizeEvent = function () {
var _this = this;
if (this.scroll$)
return;
this.scroll$ = rxjs.fromEvent(window, 'resize')
.pipe(operators.debounceTime(500))
.subscribe(function () { return _this.resize(); });
};
G2WaterWaveComponent.prototype.uninstallResizeEvent = function () {
if (this.scroll$)
this.scroll$.unsubscribe();
};
G2WaterWaveComponent.prototype.resize = function () {
var offsetWidth = this.el.nativeElement.parentNode.offsetWidth;
this.updateRadio(offsetWidth < this.height ? offsetWidth / this.height : 1);
this.renderChart();
};
G2WaterWaveComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'g2-water-wave',
template: "\n <div [ngStyle]=\"{'height.px': height, 'width.px': height, 'overflow': 'hidden'}\">\n <canvas #container class=\"canvas-wrap\" width=\"{{height*2}}\" height=\"{{height*2}}\"></canvas>\n </div>\n <div class=\"text\" [ngStyle]=\"{'width.px': height}\">\n <ng-container *ngIf=\"_title; else _titleTpl\"><span>{{_title}}</span></ng-container>\n <h4>{{percent}}%</h4>\n </div>",
host: { '[class.ad-water-wave]': 'true' },
changeDetection: i0.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
},] },
];
/** @nocollapse */
G2WaterWaveComponent.ctorParameters = function () { return [
{ type: i0.ElementRef },
{ type: i0.Renderer2 },
{ type: i0.ChangeDetectorRef },
{ type: i0.NgZone }
]; };
G2WaterWaveComponent.propDecorators = {
title: [{ type: i0.Input }],
color: [{ type: i0.Input }],
height: [{ type: i0.Input }],
percent: [{ type: i0.Input }],
node: [{ type: i0.ViewChild, args: ['container',] }]
};
return G2WaterWaveComponent;
}());
var COMPONENTS$33 = [G2WaterWaveComponent];
var AdG2WaterWaveModule = /** @class */ (function () {
function AdG2WaterWaveModule() {
}
AdG2WaterWaveModule.forRoot = function () {
return { ngModule: AdG2WaterWaveModule, providers: [] };
};
AdG2WaterWaveModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, i1$1.NgZorroAntdModule],
declarations: COMPONENTS$33.slice(),
exports: COMPONENTS$33.slice(),
},] },
];
return AdG2WaterWaveModule;
}());
var MODULES = [
AdErrorCollectModule,
AdFooterToolbarModule,
AdSidebarNavModule,
AdDownFileModule,
AdImageModule,
AdAvatarListModule,
AdDescListModule,
AdEllipsisModule,
AdGlobalFooterModule,
AdExceptionModule,
AdNoticeIconModule,
AdNumberInfoModule,
AdPageHeaderModule,
AdResultModule,
AdStandardFormRowModule,
AdTagSelectModule,
AdTrendModule,
AdCountDownModule,
AdSimpleTableModule,
AdReuseTabModule,
AdFullContentModule,
AdXlsxModule,
AdZipModule,
AdNumberToChineseModule,
AdLodopModule,
AdQuickMenuModule,
AdQRModule,
AdSHFModule,
// charts
AdG2BarModule,
AdG2CardModule,
AdG2ChartModule,
AdG2GaugeModule,
AdG2MiniAreaModule,
AdG2MiniBarModule,
AdG2MiniProgressModule,
AdG2PieModule,
AdG2RadarModule,
AdG2TagCloudModule,
AdG2TimelineModule,
AdG2WaterWaveModule,
];
// endregion
var DelonABCRootModule = /** @class */ (function () {
function DelonABCRootModule() {
}
DelonABCRootModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [
AdErrorCollectModule.forRoot(),
AdFooterToolbarModule.forRoot(),
AdSidebarNavModule.forRoot(),
AdDownFileModule.forRoot(),
AdImageModule.forRoot(),
AdAvatarListModule.forRoot(),
AdDescListModule.forRoot(),
AdEllipsisModule.forRoot(),
AdExceptionModule.forRoot(),
AdExceptionModule.forRoot(),
AdNoticeIconModule.forRoot(),
AdNumberInfoModule.forRoot(),
AdPageHeaderModule.forRoot(),
AdResultModule.forRoot(),
AdStandardFormRowModule.forRoot(),
AdTagSelectModule.forRoot(),
AdTrendModule.forRoot(),
AdCountDownModule.forRoot(),
AdSimpleTableModule.forRoot(),
AdReuseTabModule.forRoot(),
AdFullContentModule.forRoot(),
AdXlsxModule.forRoot(),
AdZipModule.forRoot(),
AdNumberToChineseModule.forRoot(),
AdLodopModule.forRoot(),
AdQuickMenuModule.forRoot(),
AdQRModule.forRoot(),
AdSHFModule.forRoot(),
// charts
AdG2BarModule.forRoot(),
AdG2CardModule.forRoot(),
AdG2ChartModule.forRoot(),
AdG2GaugeModule.forRoot(),
AdG2MiniAreaModule.forRoot(),
AdG2MiniBarModule.forRoot(),
AdG2MiniProgressModule.forRoot(),
AdG2PieModule.forRoot(),
AdG2RadarModule.forRoot(),
AdG2TagCloudModule.forRoot(),
AdG2TimelineModule.forRoot(),
AdG2WaterWaveModule.forRoot(),
],
exports: MODULES,
},] },
];
return DelonABCRootModule;
}());
var DelonABCModule = /** @class */ (function () {
function DelonABCModule() {
}
DelonABCModule.forRoot = function () {
return { ngModule: DelonABCRootModule };
};
DelonABCModule.decorators = [
{ type: i0.NgModule, args: [{ exports: MODULES },] },
];
return DelonABCModule;
}());
var ReuseTabStrategy = /** @class */ (function () {
function ReuseTabStrategy(srv) {
this.srv = srv;
}
ReuseTabStrategy.prototype.shouldDetach = function (route) {
return this.srv.shouldDetach(route);
};
ReuseTabStrategy.prototype.store = function (route, handle) {
this.srv.store(route, handle);
};
ReuseTabStrategy.prototype.shouldAttach = function (route) {
return this.srv.shouldAttach(route);
};
ReuseTabStrategy.prototype.retrieve = function (route) {
return this.srv.retrieve(route);
};
ReuseTabStrategy.prototype.shouldReuseRoute = function (future, curr) {
return this.srv.shouldReuseRoute(future, curr);
};
return ReuseTabStrategy;
}());
var WINDOW = new i0.InjectionToken('Window');
function preloaderFinished() {
var body = document.querySelector('body');
var preloader = document.querySelector('.preloader');
body.style.overflow = 'hidden';
function remove() {
// preloader value null when running --hmr
if (!preloader)
return;
preloader.addEventListener('transitionend', function () {
preloader.className = 'preloader-hidden';
});
preloader.className += ' preloader-hidden-add preloader-hidden-add-active';
}
window.appBootstrap = function () {
setTimeout(function () {
remove();
body.style.overflow = '';
}, 100);
};
}
var ScrollService = /** @class */ (function () {
function ScrollService(win, doc) {
this.win = win;
this.doc = doc;
}
/**
* 设置滚动条至指定元素
* @param element 指定元素,默认 `document.body`
* @param topOffset 偏移值,默认 `0`
*/
ScrollService.prototype.scrollToElement = function (element, topOffset) {
if (topOffset === void 0) { topOffset = 0; }
if (!element)
element = this.doc.body;
element.scrollIntoView();
var w = this.win;
if (w && w.scrollBy) {
w.scrollBy(0, element.getBoundingClientRect().top - topOffset);
if (w.pageYOffset < 20) {
w.scrollBy(0, -w.pageYOffset);
}
}
};
/**
* 滚动至顶部
* @param topOffset 偏移值,默认 `0`
*/
ScrollService.prototype.scrollToTop = function (topOffset) {
if (topOffset === void 0) { topOffset = 0; }
this.scrollToElement(this.doc.body, topOffset);
};
ScrollService.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
/** @nocollapse */
ScrollService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: i0.Inject, args: [WINDOW,] }] },
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.DOCUMENT,] }] }
]; };
ScrollService.ngInjectableDef = i0.defineInjectable({ factory: function ScrollService_Factory() { return new ScrollService(i0.inject(WINDOW), i0.inject(i3.DOCUMENT)); }, token: ScrollService, providedIn: "root" });
return ScrollService;
}());
var LAYOUT_KEY = 'layout';
var USER_KEY = 'user';
var APP_KEY = 'app';
var SettingsService = /** @class */ (function () {
function SettingsService() {
this._app = null;
this._user = null;
this._layout = null;
}
SettingsService.prototype.get = function (key) {
return JSON.parse(localStorage.getItem(key) || 'null') || null;
};
SettingsService.prototype.set = function (key, value) {
localStorage.setItem(key, JSON.stringify(value));
};
Object.defineProperty(SettingsService.prototype, "layout", {
get: function () {
if (!this._layout) {
this._layout = Object.assign({
fixed: true,
collapsed: false,
boxed: false,
lang: null,
}, this.get(LAYOUT_KEY));
this.set(LAYOUT_KEY, this._layout);
}
return this._layout;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SettingsService.prototype, "app", {
get: function () {
if (!this._app) {
this._app = Object.assign({
year: new Date().getFullYear(),
}, this.get(APP_KEY));
this.set(APP_KEY, this._app);
}
return this._app;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SettingsService.prototype, "user", {
get: function () {
if (!this._user) {
this._user = Object.assign({}, this.get(USER_KEY));
this.set(USER_KEY, this._user);
}
return this._user;
},
enumerable: true,
configurable: true
});
SettingsService.prototype.setLayout = function (name, value) {
if (typeof this.layout[name] !== 'undefined') {
this.layout[name] = value;
this.set(LAYOUT_KEY, this._layout);
return true;
}
return false;
};
SettingsService.prototype.setApp = function (val) {
this._app = val;
this.set(APP_KEY, val);
};
SettingsService.prototype.setUser = function (val) {
this._user = val;
this.set(USER_KEY, val);
};
SettingsService.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
SettingsService.ngInjectableDef = i0.defineInjectable({ factory: function SettingsService_Factory() { return new SettingsService(); }, token: SettingsService, providedIn: "root" });
return SettingsService;
}());
/**
* 设置标题
* @see http://ng-alain.com/docs/service#TitleService
*/
var TitleService = /** @class */ (function () {
function TitleService(injector, title, menuSrv, doc) {
this.injector = injector;
this.title = title;
this.menuSrv = menuSrv;
this.doc = doc;
this._prefix = '';
this._suffix = '';
this._separator = ' - ';
this._reverse = false;
this._default = 'Not Page Name';
}
Object.defineProperty(TitleService.prototype, "separator", {
/** 设置分隔符 */
set: function (value) {
this._separator = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TitleService.prototype, "prefix", {
/** 设置前缀 */
set: function (value) {
this._prefix = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TitleService.prototype, "suffix", {
/** 设置后缀 */
set: function (value) {
this._suffix = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TitleService.prototype, "reverse", {
/** 设置是否反转 */
set: function (value) {
this._reverse = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TitleService.prototype, "default", {
/** 设置默认标题名 */
set: function (value) {
this._default = value;
},
enumerable: true,
configurable: true
});
TitleService.prototype.getByElement = function () {
var el = this.doc.querySelector('.content__title h1') ||
this.doc.querySelector('pro-header h1.title');
if (el) {
return el.firstChild.textContent.trim();
}
return '';
};
TitleService.prototype.getByRoute = function () {
var next = this.injector.get(router.ActivatedRoute);
while (next.firstChild)
next = next.firstChild;
var data = (next.snapshot && next.snapshot.data) || {};
return data.title;
};
TitleService.prototype.getByMenu = function () {
var menus = this.menuSrv.getPathByUrl(this.injector.get(router.Router).url);
if (!menus || menus.length <= 0)
return '';
var item = menus[menus.length - 1];
return item.name;
};
/**
* 设置标题,若不指定具体名称,则按以顺序获取:
* - 路由配置 `{ data: { title: 'page name' } }`
* - 根据当前 URL 解析菜单数据
* - 页面 `content__title` 中获取 `h1` 内容
* - 默认标题名
*/
TitleService.prototype.setTitle = function (title) {
if (!title) {
title =
this.getByRoute() ||
this.getByMenu() ||
this.getByElement() ||
this._default;
}
if (title && !Array.isArray(title)) {
title = [title];
}
var newTitles = [];
if (this._prefix) {
newTitles.push(this._prefix);
}
newTitles.push.apply(newTitles, title);
if (this._suffix) {
newTitles.push(this._suffix);
}
if (this._reverse) {
newTitles = newTitles.reverse();
}
this.title.setTitle(newTitles.join(this._separator));
};
TitleService.prototype.ngOnDestroy = function () {
if (this.i18n$)
this.i18n$.unsubscribe();
};
TitleService.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
/** @nocollapse */
TitleService.ctorParameters = function () { return [
{ type: i0.Injector },
{ type: i1$2.Title },
{ type: MenuService },
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.DOCUMENT,] }] }
]; };
TitleService.ngInjectableDef = i0.defineInjectable({ factory: function TitleService_Factory() { return new TitleService(i0.inject(i0.INJECTOR), i0.inject(i1$2.Title), i0.inject(MenuService), i0.inject(i3.DOCUMENT)); }, token: TitleService, providedIn: "root" });
return TitleService;
}());
/**
* 对话框辅助类
*/
var ModalHelper = /** @class */ (function () {
function ModalHelper(srv) {
this.srv = srv;
this.zIndex = 500;
}
/**
* 构建一个对话框
*
* @param comp 组件
* @param params 组件参数
* @param options 额外参数
*
* 示例:
```ts
this.modalHelper.create(FormEditComponent, { i }).subscribe(res => this.load());
// 对于组件的成功&关闭的处理说明
// 成功
this.NzModalRef.close(data);
this.NzModalRef.close();
// 关闭
this.NzModalRef.destroy();
```
*/
ModalHelper.prototype.create = function (comp, params, options) {
var _this = this;
options = Object.assign({
size: 'lg',
exact: true,
includeTabs: false,
}, options);
return rxjs.Observable.create(function (observer) {
var cls = '', width = '';
if (options.size) {
if (typeof options.size === 'number') {
width = options.size + "px";
}
else {
cls = "modal-" + options.size;
}
}
if (options.includeTabs) {
cls += ' modal-include-tabs';
}
var defaultOptions = {
nzWrapClassName: cls,
nzContent: comp,
nzWidth: width ? width : undefined,
nzFooter: null,
nzComponentParams: params,
nzZIndex: ++_this.zIndex,
};
var subject = _this.srv.create(Object.assign(defaultOptions, options.modalOptions));
var afterClose$ = subject.afterClose.subscribe(function (res) {
if (options.exact === true) {
if (res != null) {
observer.next(res);
}
else {
observer.error(res);
}
}
else {
observer.next(res);
}
observer.complete();
afterClose$.unsubscribe();
});
});
};
/**
* 构建静态框,点击蒙层不允许关闭
*
* @param comp 组件
* @param params 组件参数
* @param options 额外参数
*
* 示例:
```ts
this.modalHelper.open(FormEditComponent, { i }).subscribe(res => this.load());
// 对于组件的成功&关闭的处理说明
// 成功
this.NzModalRef.close(data);
this.NzModalRef.close();
// 关闭
this.NzModalRef.destroy();
```
*/
ModalHelper.prototype.createStatic = function (comp, params, options) {
var modalOptions = Object.assign({ nzMaskClosable: false }, options && options.modalOptions);
return this.create(comp, params, Object.assign({}, options, { modalOptions: modalOptions }));
};
/**
* 打开对话框
* @param comp 组件
* @param params 组件参数
* @param size 大小;例如:lg、600,默认:lg
* @param options 对话框 `ModalOptionsForService` 参数
*
* 示例:
```ts
this.modalHelper.open(FormEditComponent, { i }).subscribe(res => this.load());
// 对于组件的成功&关闭的处理说明
// 成功
this.NzModalRef.close(data);
this.NzModalRef.close();
// 关闭
this.NzModalRef.destroy();
```
*/
ModalHelper.prototype.open = function (comp, params, size, options) {
if (size === void 0) { size = 'lg'; }
return this.create(comp, params, {
size: size,
modalOptions: options,
exact: false,
});
};
/**
* 静态框,点击蒙层不允许关闭
* @param comp 组件
* @param params 组件参数
* @param size 大小;例如:lg、600,默认:lg
* @param options 对话框 `ModalOptionsForService` 参数
*
* 示例:
```ts
this.modalHelper.open(FormEditComponent, { i }).subscribe(res => this.load());
// 对于组件的成功&关闭的处理说明
// 成功
this.NzModalRef.close(data);
this.NzModalRef.close();
// 关闭
this.NzModalRef.destroy();
```
*/
ModalHelper.prototype.static = function (comp, params, size, options) {
if (size === void 0) { size = 'lg'; }
return this.open(comp, params, size, Object.assign({
nzMaskClosable: false,
}, options));
};
ModalHelper.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
/** @nocollapse */
ModalHelper.ctorParameters = function () { return [
{ type: i1$1.NzModalService }
]; };
ModalHelper.ngInjectableDef = i0.defineInjectable({ factory: function ModalHelper_Factory() { return new ModalHelper(i0.inject(i1$1.NzModalService)); }, token: ModalHelper, providedIn: "root" });
return ModalHelper;
}());
/**
* 封装HttpClient,主要解决:
* + 优化HttpClient在参数上便利性
* + 统一实现 loading
* + 统一处理时间格式问题
*/
var _HttpClient = /** @class */ (function () {
function _HttpClient(http) {
this.http = http;
this._loading = false;
}
Object.defineProperty(_HttpClient.prototype, "loading", {
/** 是否正在加载中 */
get: function () {
return this._loading;
},
enumerable: true,
configurable: true
});
_HttpClient.prototype.parseParams = function (params) {
var ret = new i1.HttpParams();
// tslint:disable-next-line:forin
for (var key in params) {
var _data = params[key];
// 将时间转化为:时间戳 (秒)
if (_data instanceof Date) {
_data = _data.valueOf();
}
ret = ret.set(key, _data);
}
return ret;
};
_HttpClient.prototype.appliedUrl = function (url, params) {
if (!params)
return url;
url += ~url.indexOf('?') ? '' : '?';
var arr = [];
// tslint:disable-next-line:forin
for (var key in params) {
arr.push(key + "=" + params[key]);
}
return url + arr.join('&');
};
_HttpClient.prototype.begin = function () {
var _this = this;
// console.time('http');
setTimeout(function () { return (_this._loading = true); });
};
_HttpClient.prototype.end = function () {
var _this = this;
// console.timeEnd('http');
setTimeout(function () { return (_this._loading = false); });
};
/**
* GET 请求
*/
_HttpClient.prototype.get = function (url, params, options) {
return this.request('GET', url, Object.assign({
params: params,
}, options));
};
/**
* POST 请求
*/
_HttpClient.prototype.post = function (url, body, params, options) {
return this.request('POST', url, Object.assign({
body: body,
params: params,
}, options));
};
/**
* POST 请求
*/
_HttpClient.prototype.delete = function (url, params, options) {
return this.request('DELETE', url, Object.assign({
params: params,
}, options));
};
// endregion
/**
* `jsonp` 请求
*
* @param url URL地址
* @param params 请求参数
* @param callbackParam CALLBACK值,默认:JSONP_CALLBACK
*/
_HttpClient.prototype.jsonp = function (url, params, callbackParam) {
var _this = this;
if (callbackParam === void 0) { callbackParam = 'JSONP_CALLBACK'; }
return this.http.jsonp(this.appliedUrl(url, params), callbackParam).pipe(operators.tap(function () {
_this.end();
}), operators.catchError(function (res) {
_this.end();
return rxjs.throwError(res);
}));
};
/**
* `patch` 请求
*
* @param url URL地址
* @param body 请求参数
*/
_HttpClient.prototype.patch = function (url, body, params) {
return this.request('PATCH', url, Object.assign({
params: params,
body: body || null,
}));
};
/**
* `put` 请求
*
* @param url URL地址
* @param body 请求参数
*/
_HttpClient.prototype.put = function (url, body, params) {
return this.request('PUT', url, Object.assign({
params: params,
body: body || null,
}));
};
/**
* `request` 请求
*
* @param method 请求方法类型
* @param url URL地址
* @param options 参数
*/
_HttpClient.prototype.request = function (method, url, options) {
var _this = this;
this.begin();
if (options) {
if (options.params)
options.params = this.parseParams(options.params);
}
return this.http.request(method, url, options).pipe(operators.tap(function () {
_this.end();
}), operators.catchError(function (res) {
_this.end();
return rxjs.throwError(res);
}));
};
_HttpClient.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
/** @nocollapse */
_HttpClient.ctorParameters = function () { return [
{ type: i1.HttpClient }
]; };
_HttpClient.ngInjectableDef = i0.defineInjectable({ factory: function _HttpClient_Factory() { return new _HttpClient(i0.inject(i1.HttpClient)); }, token: _HttpClient, providedIn: "root" });
return _HttpClient;
}());
var format = format_;
var distanceInWordsToNow = distanceInWordsToNow_;
/**
* @see http://ng-alain.com/docs/service-pipe#%E6%97%A5%E6%9C%9F-_date
*/
var DatePipe = /** @class */ (function () {
function DatePipe() {
}
DatePipe.prototype.transform = function (value, formatString) {
if (formatString === void 0) { formatString = 'YYYY-MM-DD HH:mm'; }
if (value) {
if (formatString === 'fn') {
return distanceInWordsToNow(value, {
locale: window.__locale__,
});
}
return format(value, formatString);
}
else {
return '';
}
};
DatePipe.decorators = [
{ type: i0.Pipe, args: [{ name: '_date' },] },
];
return DatePipe;
}());
/**
* @see http://ng-alain.com/docs/service-pipe#%E8%B4%A7%E5%B8%81-_currenty
*/
// tslint:disable-next-line:use-pipe-transform-interface
var CNCurrencyPipe = /** @class */ (function (_super) {
tslib_1.__extends(CNCurrencyPipe, _super);
function CNCurrencyPipe() {
return _super !== null && _super.apply(this, arguments) || this;
}
CNCurrencyPipe.prototype.transform = function (value, currencyCode, display, digits) {
if (currencyCode === void 0) { currencyCode = '¥'; }
if (display === void 0) { display = 'code'; }
return _super.prototype.transform.call(this, value, currencyCode, display, digits);
};
CNCurrencyPipe.decorators = [
{ type: i0.Pipe, args: [{ name: '_currency' },] },
];
return CNCurrencyPipe;
}(i3.CurrencyPipe));
/**
* @see https://ng-alain.com/docs/common#%E5%8F%AF%E8%BF%AD%E4%BB%A3-keys
*/
var KeysPipe = /** @class */ (function () {
function KeysPipe() {
}
KeysPipe.prototype.transform = function (value, keyIsNumber) {
if (keyIsNumber === void 0) { keyIsNumber = false; }
var ret = [];
// tslint:disable-next-line:forin
for (var key in value) {
ret.push({ key: keyIsNumber ? +key : key, value: value[key] });
}
return ret;
};
KeysPipe.decorators = [
{ type: i0.Pipe, args: [{ name: 'keys' },] },
];
return KeysPipe;
}());
/**
* @see http://ng-alain.com/docs/service-pipe#%E5%BE%BD%E7%AB%A0-yn
*/
var YNPipe = /** @class */ (function () {
function YNPipe() {
}
YNPipe.prototype.transform = function (value, yes, no) {
if (value) {
return '<span class="badge badge-success">' + (yes || '是') + '</span>';
}
else {
return '<span class="badge badge-error">' + (no || '否') + '</span>';
}
};
YNPipe.decorators = [
{ type: i0.Pipe, args: [{ name: 'yn' },] },
];
return YNPipe;
}());
var HELPERS = [ModalHelper, permissionChecker_service.PermissionCheckerService];
// components
var COMPONENTS$34 = [];
var PIPES$1 = [DatePipe, CNCurrencyPipe, KeysPipe, YNPipe];
// endregion
var AlainThemeModule = /** @class */ (function () {
function AlainThemeModule() {
}
AlainThemeModule.forRoot = function () {
return {
ngModule: AlainThemeModule,
providers: [
{ provide: WINDOW, useValue: window }
].concat(HELPERS),
};
};
AlainThemeModule.forChild = function () {
return {
ngModule: AlainThemeModule,
providers: HELPERS.slice(),
};
};
AlainThemeModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule, router.RouterModule],
declarations: COMPONENTS$34.concat(PIPES$1),
exports: COMPONENTS$34.concat(PIPES$1),
},] },
];
return AlainThemeModule;
}());
var VERSION = new i0.Version('0.0.0-PLACEHOLDER');
var MenuItem = /** @class */ (function () {
/**
* 菜单项构造函数
* @param name 菜单名称
* @param permissionName 菜单访问权限名称
* @param icon 图标
* @param route 路由地址
* @param childItems 子菜单项
* @param isDisplay 是否显示到silderbar上 默认:true
* @param reuse 复用标签,本质是解决不同路由页切换时组件数据不丢失问题。默认值:true
* @param reuseClosable Tab中是否允许关闭 默认值:true
* @param hideInBreadcrumb 是否隐藏面包屑导航 默认值:false
* @param isOpen 是否展开(存在子菜单时生效)) 默认值:false
*/
function MenuItem(name, permissionName, icon, route, childItems, isDisplay, reuse, reuseClosable, hideInBreadcrumb, isOpen) {
if (isDisplay === void 0) { isDisplay = true; }
if (reuse === void 0) { reuse = true; }
if (reuseClosable === void 0) { reuseClosable = true; }
if (hideInBreadcrumb === void 0) { hideInBreadcrumb = false; }
if (isOpen === void 0) { isOpen = false; }
/**
* 是否展开(只有存在子项时启用)
*/
this.isOpen = false;
/**
* 菜单名称(abp处理多语言)
*/
this.name = '';
/**
* 权限名称(abp权限)
*/
this.permissionName = '';
/**
* 图标
*/
this.icon = '';
/**
* 路由
*/
this.route = '';
/**
* tab中是否允许关闭
*/
this.reuseClosable = true;
/**
* 复用标签在中台系统非常常见,本质是解决不同路由页切换时组件数据不丢失问题。
*/
this.reuse = true;
/**
* 是否隐藏面包屑导航
*/
this.hideInBreadcrumb = false;
/**
* 是否显示到silderbar上
*/
this.isDisplay = true;
this.name = name;
this.permissionName = permissionName;
this.icon = icon;
this.route = route;
this.items = childItems;
this.isDisplay = isDisplay;
this.reuse = reuse;
this.reuseClosable = reuseClosable;
this.hideInBreadcrumb = hideInBreadcrumb;
this.isOpen = isOpen;
}
return MenuItem;
}());
var deepExtend = deepExtend_;
/**
* 类似 `_.get`,根据 `path` 获取安全值
* jsperf: https://jsperf.com/es-deep-getttps://jsperf.com/es-deep-get
*
* @param obj 数据源,无效时直接返回 `defaultValue` 值
* @param path 若 `null`、`[]`、未定义及未找到时返回 `defaultValue` 值
* @param defaultValue 默认值
*/
function deepGet(obj, path, defaultValue) {
if (!obj || path == null || path.length === 0)
return defaultValue;
if (!Array.isArray(path)) {
path = ~path.indexOf('.') ? path.split('.') : [path];
}
if (path.length === 1) {
var checkObj = obj[path[0]];
return typeof checkObj === 'undefined' ? defaultValue : checkObj;
}
return path.reduce(function (o, k) { return (o || {})[k]; }, obj) || defaultValue;
}
function deepCopy(obj) {
var result = deepExtend(true, {}, { _: obj });
return result._;
}
/** 复制内容至剪贴板 */
function copy(value) {
return new Promise(function (resolve, reject) {
var copyTextArea = null;
try {
copyTextArea = document.createElement('textarea');
copyTextArea.style.height = '0px';
copyTextArea.style.opacity = '0';
copyTextArea.style.width = '0px';
document.body.appendChild(copyTextArea);
copyTextArea.value = value;
copyTextArea.select();
document.execCommand('copy');
resolve(value);
}
finally {
if (copyTextArea && copyTextArea.parentNode) {
copyTextArea.parentNode.removeChild(copyTextArea);
}
}
});
}
/**
* 字符串格式化
* ```
* format('this is ${name}', { name: 'asdf' })
* // output: this is asdf
* format('this is ${user.name}', { user: { name: 'asdf' } }, true)
* // output: this is asdf
* ```
*/
function format$1(str, obj, needDeepGet) {
if (needDeepGet === void 0) { needDeepGet = false; }
return (str || '').replace(/\${([^}]+)}/g, function (work, key) {
return needDeepGet
? deepGet(obj, key.split('.'), '')
: (obj || {})[key] || '';
});
}
/**
* 转化成RMB元字符串
* @param digits 当数字类型时,允许指定小数点后数字的个数,默认2位小数
*/
function yuan(value, digits) {
if (digits === void 0) { digits = 2; }
if (typeof value === 'number')
value = value.toFixed(digits);
return "¥ " + value;
}
var parse = parse_;
var startOfWeek = startOfWeek_;
var endOfWeek = endOfWeek_;
var subWeeks = subWeeks_;
var startOfMonth = startOfMonth_;
var endOfMonth = endOfMonth_;
var subMonths = subMonths_;
var startOfYear = startOfYear_;
var endOfYear = endOfYear_;
var subYears = subYears_;
var addDays = addDays_;
/**
* 获取时间范围
* @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数
* @param time 开始时间
*/
function getTimeDistance(type, time) {
time = parse(time || new Date());
switch (type) {
case 'today':
case '-today':
return [time, time];
case 'week':
return [startOfWeek(time), endOfWeek(time)];
case '-week':
return [startOfWeek(subWeeks(time, 1)), endOfWeek(subWeeks(time, 1))];
case 'month':
return [startOfMonth(time), endOfMonth(time)];
case '-month':
return [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];
case 'year':
return [startOfYear(time), endOfYear(time)];
case '-year':
return [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];
default:
return type > 0
? [time, addDays(time, type)]
: [addDays(time, type), time];
}
}
var LazyService = /** @class */ (function () {
function LazyService(doc) {
this.doc = doc;
this.list = {};
this.cached = {};
this._notify = new rxjs.BehaviorSubject([]);
}
Object.defineProperty(LazyService.prototype, "change", {
get: function () {
return this._notify
.asObservable()
.pipe(operators.share(), operators.filter(function (ls) { return ls.length !== 0; }));
},
enumerable: true,
configurable: true
});
LazyService.prototype.clear = function () {
this.list = {};
this.cached = {};
};
LazyService.prototype.load = function (paths) {
var _this = this;
if (!Array.isArray(paths))
paths = [paths];
var promises = [];
paths.forEach(function (path) {
if (path.includes('.js'))
promises.push(_this.loadScript(path));
else
promises.push(_this.loadStyle(path));
});
return Promise.all(promises).then(function (res) {
_this._notify.next(res);
return Promise.resolve(res);
});
};
LazyService.prototype.loadScript = function (path) {
var _this = this;
return new Promise(function (resolve) {
if (_this.list[path] === true) {
resolve(_this.cached[path]);
return;
}
_this.list[path] = true;
var onSuccess = function (item) {
_this.cached[path] = item;
resolve(item);
};
var node = _this.doc.createElement('script');
node.type = 'text/javascript';
node.src = path;
node.charset = 'utf-8';
if (node.readyState) {
// IE
node.onreadystatechange = function () {
if (node.readyState === 'loaded' ||
node.readyState === 'complete') {
node.onreadystatechange = null;
onSuccess({
path: path,
loaded: true,
status: 'ok',
});
}
};
}
else {
node.onload = function () {
onSuccess({
path: path,
loaded: true,
status: 'ok',
});
};
}
node.onerror = function (error) {
return onSuccess({
path: path,
loaded: false,
status: 'error',
});
};
_this.doc.getElementsByTagName('head')[0].appendChild(node);
});
};
LazyService.prototype.loadStyle = function (path, rel) {
var _this = this;
if (rel === void 0) { rel = 'stylesheet'; }
return new Promise(function (resolve) {
if (_this.list[path] === true) {
resolve(_this.cached[path]);
return;
}
_this.list[path] = true;
var onSuccess = function (item) {
_this.cached[path] = item;
resolve(item);
};
var node = _this.doc.createElement('link');
node.rel = rel;
node.type = 'text/css';
node.href = path;
_this.doc.getElementsByTagName('head')[0].appendChild(node);
onSuccess({
path: path,
loaded: true,
status: 'ok',
});
});
};
LazyService.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
/** @nocollapse */
LazyService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.DOCUMENT,] }] }
]; };
LazyService.ngInjectableDef = i0.defineInjectable({ factory: function LazyService_Factory() { return new LazyService(i0.inject(i3.DOCUMENT)); }, token: LazyService, providedIn: "root" });
return LazyService;
}());
/** 是否为数字 */
function isNum(value) {
return /^((-?\d+\.\d+)|(-?\d+)|(-?\.\d+))$/.test(value.toString());
}
/** 是否为整数 */
function isInt(value) {
// tslint:disable-next-line:triple-equals
return isNum(value) && parseInt(value.toString(), 10) == value;
}
/** 是否为小数 */
function isDecimal(value) {
return isNum(value) && !isInt(value);
}
/** 是否为身份证 */
function isIdCard(value) {
return (typeof value === 'string' && /(^\d{15}$)|(^\d{17}([0-9]|X)$)/i.test(value));
}
/** 是否为手机号 */
function isMobile(value) {
return (typeof value === 'string' &&
/^(0|\+?86|17951)?(13[0-9]|15[0-9]|17[0678]|18[0-9]|14[57])[0-9]{8}$/.test(value));
}
/** 一套日常验证器 */
// tslint:disable-next-line:class-name
var _Validators = /** @class */ (function () {
function _Validators() {
}
/** 是否为数字 */
_Validators.num = function (control) {
return isNum(control.value) ? null : { num: true };
};
/** 是否为整数 */
_Validators.int = function (control) {
return isInt(control.value) ? null : { int: true };
};
/** 是否为小数 */
_Validators.decimal = function (control) {
return isDecimal(control.value) ? null : { decimal: true };
};
/** 是否为身份证 */
_Validators.idCard = function (control) {
return isIdCard(control.value) ? null : { idCard: true };
};
/** 是否为手机号 */
_Validators.mobile = function (control) {
return isMobile(control.value) ? null : { mobile: true };
};
return _Validators;
}());
function isEmpty(element) {
var nodes = element.childNodes;
for (var i = 0; i < nodes.length; i++) {
var node = nodes.item(i);
if (node.nodeType === 1 &&
node.outerHTML.toString().trim().length !== 0) {
return false;
}
else if (node.nodeType === 3 &&
node.textContent.toString().trim().length !== 0) {
return false;
}
}
return true;
}
function toBoolean(value, allowUndefined) {
if (allowUndefined === void 0) { allowUndefined = false; }
return allowUndefined && typeof value === 'undefined'
? undefined
: value != null && "" + value !== 'false';
}
function toNumber(value, fallbackValue) {
if (fallbackValue === void 0) { fallbackValue = 0; }
return !isNaN(parseFloat(value)) && !isNaN(Number(value))
? Number(value)
: fallbackValue;
}
function removeClass(el, classMap, renderer) {
// tslint:disable-next-line:forin
for (var i in classMap) {
renderer.removeClass(el, i);
}
}
function addClass(el, classMap, renderer) {
for (var i in classMap) {
if (classMap[i]) {
renderer.addClass(el, i);
}
}
}
/**
* 更新宿主组件样式 `class`,例如:
*
* ```ts
* updateHostClass(
* this.el.nativeElement,
* {
* [ 'classname' ]: true,
* [ 'classname' ]: this.type === '1',
* [ this.cls ]: true,
* [ `a-${this.cls}` ]: true
* },
* this.renderer)
* ```
*
* @param [cleanAll] 是否先清理所有 `class` 值,默认:`false`
*/
function updateHostClass(el, renderer, classMap, cleanAll) {
if (cleanAll === void 0) { cleanAll = false; }
if (cleanAll === true) {
renderer.removeAttribute(el, 'class');
}
else {
removeClass(el, classMap, renderer);
}
classMap = tslib_1.__assign({}, classMap);
addClass(el, classMap, renderer);
}
var DelonUtilConfig = /** @class */ (function () {
function DelonUtilConfig() {
}
DelonUtilConfig.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
DelonUtilConfig.ngInjectableDef = i0.defineInjectable({ factory: function DelonUtilConfig_Factory() { return new DelonUtilConfig(); }, token: DelonUtilConfig, providedIn: "root" });
return DelonUtilConfig;
}());
var ArrayService = /** @class */ (function () {
function ArrayService(cog) {
this.c = Object.assign({
deepMapName: 'deep',
parentMapName: 'parent',
idMapName: 'id',
parentIdMapName: 'parent_id',
childrenMapName: 'children',
titleMapName: 'title',
checkedMapname: 'checked',
selectedMapname: 'selected',
expandedMapname: 'expanded',
disabledMapname: 'disabled',
}, cog && cog.array);
}
/**
* 将树结构转换成数组结构
*/
ArrayService.prototype.treeToArr = function (tree, options) {
options = Object.assign({
deepMapName: this.c.deepMapName,
parentMapName: this.c.parentMapName,
childrenMapName: this.c.childrenMapName,
clearChildren: true,
cb: null,
}, options);
var result = [];
var inFn = function (list, parent, deep) {
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
var i = list_1[_i];
i[options.deepMapName] = deep;
i[options.parentMapName] = parent;
if (options.cb)
options.cb(i, parent, deep);
result.push(i);
var children = i[options.childrenMapName];
if (children != null &&
Array.isArray(children) &&
children.length > 0) {
inFn(children, i, deep + 1);
}
if (options.clearChildren)
delete i[options.childrenMapName];
}
};
inFn(tree, 1, null);
return result;
};
/**
* 数组转换成树数据
*/
ArrayService.prototype.arrToTree = function (arr, options) {
options = Object.assign({
idMapName: this.c.idMapName,
parentIdMapName: this.c.parentIdMapName,
childrenMapName: this.c.childrenMapName,
cb: null,
}, options);
var tree = [];
var childrenOf = {};
for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
var item = arr_1[_i];
var id = item[options.idMapName], pid = item[options.parentIdMapName];
childrenOf[id] = childrenOf[id] || [];
item[options.childrenMapName] = childrenOf[id];
if (options.cb)
options.cb(item);
if (pid) {
childrenOf[pid] = childrenOf[pid] || [];
childrenOf[pid].push(item);
}
else {
tree.push(item);
}
}
return tree;
};
/**
* 数组转换成 `nz-tree` 数据源,通过 `options` 转化项名,也可以使用 `options.cb` 更高级决定数据项
*/
ArrayService.prototype.arrToTreeNode = function (arr, options) {
options = Object.assign({
expanded: false,
idMapName: this.c.idMapName,
parentIdMapName: this.c.parentIdMapName,
titleMapName: this.c.titleMapName,
isLeafMapName: 'isLeaf',
checkedMapname: this.c.checkedMapname,
selectedMapname: this.c.selectedMapname,
expandedMapname: this.c.expandedMapname,
disabledMapname: this.c.disabledMapname,
cb: null,
}, options);
var tree = this.arrToTree(arr, {
idMapName: options.idMapName,
parentIdMapName: options.parentIdMapName,
childrenMapName: 'children',
});
this.visitTree(tree, function (item, parent, deep) {
item.key = item[options.idMapName];
item.title = item[options.titleMapName];
item.checked = item[options.checkedMapname];
item.selected = item[options.selectedMapname];
item.expanded = item[options.expandedMapname];
item.disabled = item[options.disabledMapname];
if (item[options.isLeafMapName] == null) {
item.isLeaf = item.children.length === 0;
}
else {
item.isLeaf = item[options.isLeafMapName];
}
if (options.cb)
options.cb(item, parent, deep);
});
return tree.map(function (node) { return new i1$1.NzTreeNode(node); });
};
/**
* 递归访问整个树
*/
ArrayService.prototype.visitTree = function (tree, cb, options) {
options = Object.assign({
childrenMapName: this.c.childrenMapName,
}, options);
var inFn = function (data, parent, deep) {
for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
var item = data_1[_i];
cb(item, parent, deep);
var childrenVal = item[options.childrenMapName];
if (childrenVal && childrenVal.length > 0) {
inFn(childrenVal, item, deep + 1);
}
}
};
inFn(tree, null, 1);
};
/**
* 获取所有已经选中的 `key` 值
*/
ArrayService.prototype.getKeysByTreeNode = function (tree, options) {
options = Object.assign({
includeHalfChecked: true,
}, options);
var keys = [];
this.visitTree(tree, function (item, parent, deep) {
if (item.isChecked ||
(options.includeHalfChecked && item.isHalfChecked)) {
keys.push(options.cb
? options.cb(item, parent, deep)
: options.keyMapName
? item.origin[options.keyMapName]
: item.key);
}
});
return keys;
};
ArrayService.decorators = [
{ type: i0.Injectable, args: [{ providedIn: 'root' },] },
];
/** @nocollapse */
ArrayService.ctorParameters = function () { return [
{ type: DelonUtilConfig }
]; };
ArrayService.ngInjectableDef = i0.defineInjectable({ factory: function ArrayService_Factory() { return new ArrayService(i0.inject(DelonUtilConfig)); }, token: ArrayService, providedIn: "root" });
return ArrayService;
}());
var DelonUtilModule = /** @class */ (function () {
function DelonUtilModule() {
}
DelonUtilModule.forRoot = function () {
return {
ngModule: DelonUtilModule,
};
};
DelonUtilModule.decorators = [
{ type: i0.NgModule, args: [{
imports: [i3.CommonModule],
},] },
];
return DelonUtilModule;
}());
/**
* @module
* @description
* Entry point for all public APIs of the Angular Module
*/
exports.AbpModule = AbpModule;
exports.DelonABCModule = DelonABCModule;
exports.ErrorCollectComponent = ErrorCollectComponent;
exports.AdErrorCollectModule = AdErrorCollectModule;
exports.FooterToolbarComponent = FooterToolbarComponent;
exports.AdFooterToolbarModule = AdFooterToolbarModule;
exports.SidebarNavComponent = SidebarNavComponent;
exports.AdSidebarNavModule = AdSidebarNavModule;
exports.DownFileDirective = DownFileDirective;
exports.AdDownFileModule = AdDownFileModule;
exports.ImageDirective = ImageDirective;
exports.AdImageConfig = AdImageConfig;
exports.AdImageModule = AdImageModule;
exports.AvatarListItemComponent = AvatarListItemComponent;
exports.AvatarListComponent = AvatarListComponent;
exports.AdAvatarListModule = AdAvatarListModule;
exports.DescListComponent = DescListComponent;
exports.DescListItemComponent = DescListItemComponent;
exports.AdDescListModule = AdDescListModule;
exports.EllipsisComponent = EllipsisComponent;
exports.AdEllipsisModule = AdEllipsisModule;
exports.GlobalFooterComponent = GlobalFooterComponent;
exports.AdGlobalFooterModule = AdGlobalFooterModule;
exports.ExceptionComponent = ExceptionComponent;
exports.AdExceptionModule = AdExceptionModule;
exports.NoticeIconComponent = NoticeIconComponent;
exports.AdNoticeIconModule = AdNoticeIconModule;
exports.NumberInfoComponent = NumberInfoComponent;
exports.AdNumberInfoModule = AdNumberInfoModule;
exports.AdPageHeaderConfig = AdPageHeaderConfig;
exports.PageHeaderComponent = PageHeaderComponent;
exports.AdPageHeaderModule = AdPageHeaderModule;
exports.ResultComponent = ResultComponent;
exports.AdResultModule = AdResultModule;
exports.StandardFormRowComponent = StandardFormRowComponent;
exports.AdStandardFormRowModule = AdStandardFormRowModule;
exports.TagSelectComponent = TagSelectComponent;
exports.AdTagSelectModule = AdTagSelectModule;
exports.TrendComponent = TrendComponent;
exports.AdTrendModule = AdTrendModule;
exports.CountDownComponent = CountDownComponent;
exports.AdCountDownModule = AdCountDownModule;
exports.SimpleTableComponent = SimpleTableComponent;
exports.SimpleTableRowDirective = SimpleTableRowDirective;
exports.AdSimpleTableConfig = AdSimpleTableConfig;
exports.AdSimpleTableModule = AdSimpleTableModule;
exports.ReuseTabComponent = ReuseTabComponent;
exports.ReuseTabService = ReuseTabService;
exports.ReuseTabStrategy = ReuseTabStrategy;
exports.AdReuseTabModule = AdReuseTabModule;
exports.FullContentComponent = FullContentComponent;
exports.FullContentService = FullContentService;
exports.FullContentToggleDirective = FullContentToggleDirective;
exports.AdFullContentModule = AdFullContentModule;
exports.XlsxService = XlsxService;
exports.XlsxDirective = XlsxDirective;
exports.AdXlsxModule = AdXlsxModule;
exports.DA_XLSX_CONFIG = DA_XLSX_CONFIG;
exports.ZipService = ZipService;
exports.AdZipModule = AdZipModule;
exports.DA_ZIP_CONFIG = DA_ZIP_CONFIG;
exports.numberToChinese = numberToChinese;
exports.NumberToChinesePipe = NumberToChinesePipe;
exports.AdNumberToChineseModule = AdNumberToChineseModule;
exports.AdLodopConfig = AdLodopConfig;
exports.LodopService = LodopService;
exports.AdLodopModule = AdLodopModule;
exports.QuickMenuComponent = QuickMenuComponent;
exports.AdQuickMenuModule = AdQuickMenuModule;
exports.QRService = QRService;
exports.QRComponent = QRComponent;
exports.AdQRConfig = AdQRConfig;
exports.AdQRModule = AdQRModule;
exports.SHFWrapDirective = SHFWrapDirective;
exports.SHFItemComponent = SHFItemComponent;
exports.AdSHFModule = AdSHFModule;
exports.G2BarComponent = G2BarComponent;
exports.AdG2BarModule = AdG2BarModule;
exports.G2CardComponent = G2CardComponent;
exports.AdG2CardModule = AdG2CardModule;
exports.G2ChartComponent = G2ChartComponent;
exports.AdG2ChartModule = AdG2ChartModule;
exports.G2GaugeComponent = G2GaugeComponent;
exports.AdG2GaugeModule = AdG2GaugeModule;
exports.G2MiniAreaComponent = G2MiniAreaComponent;
exports.AdG2MiniAreaModule = AdG2MiniAreaModule;
exports.G2MiniBarComponent = G2MiniBarComponent;
exports.AdG2MiniBarModule = AdG2MiniBarModule;
exports.G2ProgressComponent = G2ProgressComponent;
exports.AdG2MiniProgressModule = AdG2MiniProgressModule;
exports.G2PieComponent = G2PieComponent;
exports.AdG2PieModule = AdG2PieModule;
exports.G2RadarComponent = G2RadarComponent;
exports.AdG2RadarModule = AdG2RadarModule;
exports.G2TagCloudComponent = G2TagCloudComponent;
exports.AdG2TagCloudModule = AdG2TagCloudModule;
exports.G2TimelineComponent = G2TimelineComponent;
exports.AdG2TimelineModule = AdG2TimelineModule;
exports.G2WaterWaveComponent = G2WaterWaveComponent;
exports.AdG2WaterWaveModule = AdG2WaterWaveModule;
exports.WINDOW = WINDOW;
exports.preloaderFinished = preloaderFinished;
exports.ScrollService = ScrollService;
exports.TitleService = TitleService;
exports._HttpClient = _HttpClient;
exports.DatePipe = DatePipe;
exports.CNCurrencyPipe = CNCurrencyPipe;
exports.KeysPipe = KeysPipe;
exports.YNPipe = YNPipe;
exports.AlainThemeModule = AlainThemeModule;
exports.VERSION = VERSION;
exports.MenuItem = MenuItem;
exports.MenuService = MenuService;
exports.SettingsService = SettingsService;
exports.ModalHelper = ModalHelper;
exports._Validators = _Validators;
exports.format = format$1;
exports.yuan = yuan;
exports.getTimeDistance = getTimeDistance;
exports.LazyService = LazyService;
exports.isNum = isNum;
exports.isInt = isInt;
exports.isDecimal = isDecimal;
exports.isIdCard = isIdCard;
exports.isMobile = isMobile;
exports.isEmpty = isEmpty;
exports.toBoolean = toBoolean;
exports.toNumber = toNumber;
exports.deepGet = deepGet;
exports.deepCopy = deepCopy;
exports.copy = copy;
exports.updateHostClass = updateHostClass;
exports.ArrayService = ArrayService;
exports.DelonUtilModule = DelonUtilModule;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=yoyo-ng-module.umd.js.map