UNPKG

dbweb-common

Version:

用`yarn add dbweb-common`安装,不要忘记修改`angular.json`里的 `architect\build\options\assets`,加上

1,339 lines (1,330 loc) 1.12 MB
import { CommonModule, registerLocaleData, formatDate } from '@angular/common'; import { Component, Inject, HostBinding, ViewChild, NgModule, Injectable, ɵɵdefineInjectable, ɵɵinject, EventEmitter, Input, Output, Directive, ViewEncapsulation, ContentChildren, ViewChildren, LOCALE_ID, Injector, INJECTOR, Optional, ElementRef, NO_ERRORS_SCHEMA, ChangeDetectorRef, Renderer2, HostListener, CUSTOM_ELEMENTS_SCHEMA, Pipe } from '@angular/core'; import { clearText, clearCategory, RouteElementService, SimpleReuseStrategy, ElementsService, ProjectService, CurrentService, AuthloginService, ApiService, eleSwitchDept, CoreModule, BillControllerService, AuthService, StoreService, ApplicationInited, ElementApiService, BillFieldDataType, BillOperate, BillBackfaceService, IsDuplicatePKError, SaveStateData, CurrentApiService, fullApiPath, Element } from 'dbweb-core'; import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule, MatButtonModule, MatDialog, MatFormFieldModule as MatFormFieldModule$1, MatInputModule as MatInputModule$1, MatSnackBar, MatIconRegistry as MatIconRegistry$1, MatFormField, MatCheckbox, MatIconModule as MatIconModule$1, MatSnackBarModule, MatCheckboxModule, MatSelectModule, MatRadioModule, MatTableModule, MatSlideToggleModule, MatButtonToggleModule, MatDividerModule as MatDividerModule$1, MatTooltipModule, MatAutocompleteModule, MatSidenavModule as MatSidenavModule$1, MatChipsModule, MatMenuModule as MatMenuModule$1, MatExpansionModule as MatExpansionModule$1, MatProgressSpinnerModule, MatTreeNestedDataSource as MatTreeNestedDataSource$1, MatTreeModule as MatTreeModule$1 } from '@angular/material'; import { moveItemInArray, DragDropModule, CdkDropListGroup, CdkDropList } from '@angular/cdk/drag-drop'; import { FormControl, Validators, FormsModule, ReactiveFormsModule, FormGroup, NgControl, FormControlName } from '@angular/forms'; import { MatBadgeModule } from '@angular/material/badge'; import { MatButtonModule as MatButtonModule$1 } from '@angular/material/button'; import { MatRippleModule } from '@angular/material/core'; import { MatDialogRef as MatDialogRef$1, MatDialogModule as MatDialogModule$1, MatDialog as MatDialog$1 } from '@angular/material/dialog'; import { MatDividerModule } from '@angular/material/divider'; import { MatIconModule, MatIconRegistry } from '@angular/material/icon'; import { MatMenuModule, MatMenuTrigger } from '@angular/material/menu'; import { MatSidenavModule } from '@angular/material/sidenav'; import { MatTab, MatTabsModule } from '@angular/material/tabs'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MatTreeNestedDataSource, MatTreeModule } from '@angular/material/tree'; import { BrowserModule, Title, DomSanitizer } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NavigationEnd, Router, RouterLink, RouterModule, RoutesRecognized } from '@angular/router'; import { ClipboardModule, ClipboardService } from 'ngx-clipboard'; import { trigger, transition, style, query, group, animate, state } from '@angular/animations'; import { map, filter, tap, startWith, catchError, take, debounceTime } from 'rxjs/operators'; import { __values, __spread, __assign, __read, __extends } from 'tslib'; import { BehaviorSubject, Subscription, forkJoin, of, throwError, Subject, from } from 'rxjs'; import { NestedTreeControl } from '@angular/cdk/tree'; import { MatInputModule } from '@angular/material/input'; import { MatFormFieldModule } from '@angular/material/form-field'; import localeZh from '@angular/common/locales/zh-Hans'; import * as pinyin_ from 'pinyin'; import pinyin___default, { } from 'pinyin'; import { AceEditorModule } from 'ng2-ace-editor'; import { v1 } from 'uuid'; import ace from 'ace-builds'; import { HttpErrorResponse, HttpEventType, HttpClient } from '@angular/common/http'; import { ViewportRuler, OverlayContainer } from '@angular/cdk/overlay'; import { Ng5SliderModule } from 'ng5-slider'; import { MatCheckboxModule as MatCheckboxModule$1 } from '@angular/material/checkbox'; import { MatExpansionModule } from '@angular/material/expansion'; import { MatProgressBarModule } from '@angular/material/progress-bar'; import { MatSelectModule as MatSelectModule$1 } from '@angular/material/select'; import { MatStepperModule } from '@angular/material/stepper'; import { MatTableModule as MatTableModule$1 } from '@angular/material/table'; import { CalendarDateFormatter, CalendarView, CalendarModule, DateAdapter } from 'angular-calendar'; import { adapterFactory } from 'angular-calendar/date-adapters/date-fns'; import { MatCardModule } from '@angular/material/card'; import { MatChipsModule as MatChipsModule$1 } from '@angular/material/chips'; import { MatGridListModule } from '@angular/material/grid-list'; import { MatTooltipModule as MatTooltipModule$1 } from '@angular/material/tooltip'; import { SelectionModel } from '@angular/cdk/collections'; import { MatSortModule } from '@angular/material/sort'; import { MatRadioModule as MatRadioModule$1 } from '@angular/material/radio'; import { MatSnackBar as MatSnackBar$1, MatSnackBarModule as MatSnackBarModule$1 } from '@angular/material/snack-bar'; import { Md5 } from 'ts-md5'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var ConfirmDialogComponent = /** @class */ (function () { function ConfirmDialogComponent(dialogRef, data) { this.dialogRef = dialogRef; this.data = data; this.hostClass = true; } /** * @return {?} */ ConfirmDialogComponent.prototype.onNoClick = /** * @return {?} */ function () { this.dialogRef.close(); }; /** * @return {?} */ ConfirmDialogComponent.prototype.ngOnInit = /** * @return {?} */ function () { this.removeView.nativeElement.parentElement.parentElement.style = 'padding:0px'; }; ConfirmDialogComponent.decorators = [ { type: Component, args: [{ selector: 'common-confirm-dialog', template: "<div #removeView class=\"\u5220\u9664\">\r\n\t<div class=\"tit\">\r\n\t\t\t<b >{{ data }}</b>\r\n\t</div>\r\n\t<div class=\"\u529F\u80FD\u6309\u94AE\">\r\n\t\t<button class=\"false-icon\" mat-button [mat-dialog-close]=\"false\">\u53D6\u6D88</button>\r\n\t\t<button class=\"true-icon\" color=\"primary\" mat-button [mat-dialog-close]=\"true\">\u786E\u5B9A</button>\r\n\t</div>\r\n</div>\r\n", styles: ["@charset \"UTF-8\";.\u5220\u9664{position:relative;display:flex;justify-content:space-between;flex-direction:column;width:100%;height:100%;box-sizing:border-box;padding:24px 24px 16px}.\u5220\u9664 b{font-size:20px}.tit{display:flex;align-items:center;box-sizing:border-box;width:100%;height:104px}.\u529F\u80FD\u6309\u94AE{width:100%;box-sizing:border-box;text-align:right}.\u529F\u80FD\u6309\u94AE .mat-button{width:64px;height:32px}.\u529F\u80FD\u6309\u94AE .true-icon{margin-left:8px}"] }] } ]; /** @nocollapse */ ConfirmDialogComponent.ctorParameters = function () { return [ { type: MatDialogRef }, { type: String, decorators: [{ type: Inject, args: [MAT_DIALOG_DATA,] }] } ]; }; ConfirmDialogComponent.propDecorators = { hostClass: [{ type: HostBinding, args: ['class.confirm-dialog-theme',] }], removeView: [{ type: ViewChild, args: ['removeView', { static: true },] }] }; return ConfirmDialogComponent; }()); if (false) { /** @type {?} */ ConfirmDialogComponent.prototype.hostClass; /** @type {?} */ ConfirmDialogComponent.prototype.removeView; /** @type {?} */ ConfirmDialogComponent.prototype.dialogRef; /** @type {?} */ ConfirmDialogComponent.prototype.data; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var ConfirmDialogModule = /** @class */ (function () { function ConfirmDialogModule() { } ConfirmDialogModule.decorators = [ { type: NgModule, args: [{ declarations: [ConfirmDialogComponent], imports: [CommonModule, MatDialogModule, MatButtonModule], exports: [ConfirmDialogComponent], entryComponents: [ConfirmDialogComponent] },] } ]; return ConfirmDialogModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var CTRL_RECORDVIEW = 'recordview'; /** @type {?} */ var CTRL_INDEX = 'index'; /** @type {?} */ var CTRL_EXPORT = 'export'; /** @type {?} */ var CTRL_LOGIN = 'login'; /** @type {?} */ var CTRL_ELEMENT = 'element'; /** @type {?} */ var CTRL_VERSION = 'version'; /** @type {?} */ var CTRL_TASK = 'task'; /** @type {?} */ var CTRL_IMPORT = 'import'; /** @type {?} */ var CTRL_USERINFO = 'userinfo'; /** @type {?} */ var CTRL_UPDATE = 'update'; /** @type {?} */ var CTRL_ROLE = 'role'; /** @type {?} */ var CTRL_USER = 'user'; /** @type {?} */ var CTRL_NOTICE = 'notice'; /** @type {?} */ var CTRL_REMOVESEL = 'removesel'; /** @type {?} */ var CTRL_DUMP_INSTITUTION = 'dumpInstitution'; /** @type {?} */ var portraitDefault = '/front/assets/userinfo/portrait_default.png'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} e * @return {?} */ function label(e) { if (e.Label) { return clearText(e.Label); } return clearText(e.Name); } var HomeTabfunctionService = /** @class */ (function () { function HomeTabfunctionService(eles) { this.eles = eles; } Object.defineProperty(HomeTabfunctionService.prototype, "category", { get: /** * @return {?} */ function () { return this.eles.currentElementListen.pipe(map((/** * @param {?} v * @return {?} */ function (v) { return (v ? clearCategory(v.element.Category).replace('/', '>') + '>' + label(v.element) : null); }))); }, enumerable: true, configurable: true }); HomeTabfunctionService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ HomeTabfunctionService.ctorParameters = function () { return [ { type: RouteElementService } ]; }; /** @nocollapse */ HomeTabfunctionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function HomeTabfunctionService_Factory() { return new HomeTabfunctionService(ɵɵinject(RouteElementService)); }, token: HomeTabfunctionService, providedIn: "root" }); return HomeTabfunctionService; }()); if (false) { /** @type {?} */ HomeTabfunctionService.prototype.eles; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var Tab = /** @class */ (function () { function Tab(state) { var e_1, _a; try { for (var _b = __values(Object.keys(state)), _c = _b.next(); !_c.done; _c = _b.next()) { var key = _c.value; this[key] = state[key]; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } this.titleObservable = new BehaviorSubject(state.title); } /** * @return {?} */ Tab.prototype.data = /** * @return {?} */ function () { return { url: this.url, key: this.key, title: this.title }; }; return Tab; }()); if (false) { /** @type {?} */ Tab.prototype.url; /** @type {?} */ Tab.prototype.key; /** @type {?} */ Tab.prototype.title; /** @type {?} */ Tab.prototype.titleObservable; } var TabsService = /** @class */ (function () { function TabsService(router, eles) { this.router = router; this.eles = eles; this.tabs = []; } // 激活一个tab,如果不存在,则新增并激活 // 激活一个tab,如果不存在,则新增并激活 /** * @param {?} data * @return {?} */ TabsService.prototype.activeTab = // 激活一个tab,如果不存在,则新增并激活 /** * @param {?} data * @return {?} */ function (data) { /** @type {?} */ var find = this.tabs.findIndex((/** * @param {?} v * @return {?} */ function (v) { return v.key === data.key; })); if (find === -1) { this.tabs.push(new Tab(data)); this._activeIndex = this.tabs.length - 1; } else { this._activeIndex = find; // 同时需要更新url和title this.tabs[this._activeIndex].url = data.url; this.tabs[this._activeIndex].title = data.title; } }; // 删除指定序号的tab,并切换激活的tab,如果只有一个tab,则不能被删除 // 返回true指示激活页已经切换 // 删除指定序号的tab,并切换激活的tab,如果只有一个tab,则不能被删除 // 返回true指示激活页已经切换 /** * @param {?} index * @return {?} */ TabsService.prototype.removeTab = // 删除指定序号的tab,并切换激活的tab,如果只有一个tab,则不能被删除 // 返回true指示激活页已经切换 /** * @param {?} index * @return {?} */ function (index) { if (this.tabs.length === 1) { return false; } /** @type {?} */ var deleteURL = this.tabs[index].url.toString(); // 如果是关闭当前页面,则会引起路由变化,所以需要在导航结束事件中删除,因为导航过程中还会进行保存 if (index === this._activeIndex) { /** @type {?} */ var sub_1 = this.router.events.subscribe((/** * @param {?} v * @return {?} */ function (v) { if (v instanceof NavigationEnd) { SimpleReuseStrategy.deleteRouteSnapshot(deleteURL); sub_1.unsubscribe(); } })); } else { SimpleReuseStrategy.deleteRouteSnapshot(deleteURL); } this.tabs.splice(index, 1); if (this._activeIndex === index) { this._activeIndex = Math.min(this.tabs.length - 1, index); return true; } if (this._activeIndex > index) { this._activeIndex--; } return false; }; // 删除所有的页,一般是logout // 删除所有的页,一般是logout /** * @return {?} */ TabsService.prototype.clear = // 删除所有的页,一般是logout /** * @return {?} */ function () { this.tabs.splice(0); this._activeIndex = undefined; SimpleReuseStrategy.clearRouteSnapshot(); }; // 关闭当前页,并自动导航到新的页 // 关闭当前页,并自动导航到新的页 /** * @return {?} */ TabsService.prototype.close = // 关闭当前页,并自动导航到新的页 /** * @return {?} */ function () { var _this = this; if (this.activeIndex >= 0) { /** @type {?} */ var idx_1 = this.activeIndex; if (this.tabs.length === 1) { this.router.navigateByUrl(this.eles.frontElementURL(this.eles.indexElementName)).then((/** * @return {?} */ function () { _this.removeTab(idx_1); })); } if (this.removeTab(idx_1)) { this.router.navigateByUrl(this.active.url, { state: this.active.data() }); } } }; Object.defineProperty(TabsService.prototype, "active", { get: /** * @return {?} */ function () { if (this._activeIndex >= 0) { return this.tabs[this._activeIndex]; } return undefined; }, enumerable: true, configurable: true }); Object.defineProperty(TabsService.prototype, "activeIndex", { get: /** * @return {?} */ function () { return this._activeIndex; }, set: /** * @param {?} val * @return {?} */ function (val) { this._activeIndex = val; }, enumerable: true, configurable: true }); TabsService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ TabsService.ctorParameters = function () { return [ { type: Router }, { type: ElementsService } ]; }; /** @nocollapse */ TabsService.ngInjectableDef = ɵɵdefineInjectable({ factory: function TabsService_Factory() { return new TabsService(ɵɵinject(Router), ɵɵinject(ElementsService)); }, token: TabsService, providedIn: "root" }); return TabsService; }()); if (false) { /** @type {?} */ TabsService.prototype.tabs; /** @type {?} */ TabsService.prototype._activeIndex; /** * @type {?} * @private */ TabsService.prototype.router; /** * @type {?} * @private */ TabsService.prototype.eles; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var HomeComponent = /** @class */ (function () { function HomeComponent(routerEle, eles, tabFun, tabs) { var _this = this; this.routerEle = routerEle; this.eles = eles; this.tabFun = tabFun; this.tabs = tabs; this.hostClass = true; this.subs = []; this.copystate = false; this.subs.push(this.routerEle.currentElementListen .pipe(filter((/** * @param {?} ele * @return {?} */ function (ele) { return ele && ele.element && ele.element.Controller !== CTRL_LOGIN; }))) .subscribe((/** * @param {?} ele * @return {?} */ function (ele) { /** @type {?} */ var state = (/** @type {?} */ (ele.state)); if (!state) { /** @type {?} */ var key = ele.url; /** @type {?} */ var arr = key.split('/'); // 功能类的,需要去除子路由作为key,防止出现多余的tab if (!ele.element.Bill && arr.length > 5) { key = arr.slice(0, 5).join('/'); // 需要处理query /** @type {?} */ var queryArr = arr[arr.length - 1].split('?'); if (queryArr.length > 1) { key += '?' + queryArr[1]; } } state = { url: ele.urlObj, key: key, title: ele.element.title() }; } _this.tabs.activeTab(state); }))); this.category = this.tabFun.category; } /** * @return {?} */ HomeComponent.prototype.ngOnInit = /** * @return {?} */ function () { }; /** * @return {?} */ HomeComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.subs.forEach((/** * @param {?} v * @return {?} */ function (v) { return v.unsubscribe(); })); }; HomeComponent.decorators = [ { type: Component, args: [{ selector: 'common-home', template: "<div class=\"home-container-nav\">\r\n\t<common-home-nav></common-home-nav>\r\n</div>\r\n<div class=\"home-container-content\">\r\n\t<div class=\"tab-all\">\r\n\t\t<app-router-tab #tabNav class=\"tabNav\">\r\n\t\t\t<app-router-tab-item\r\n\t\t\t\t*ngFor=\"let tab of tabs.tabs; let index = index\"\r\n\t\t\t\t[routerLink]=\"tab.url\" class=\"tabA\"\r\n\t\t\t\tlabel=\"{{ tab.titleObservable | async }}\">\r\n\t\t\t</app-router-tab-item>\r\n\t\t</app-router-tab>\r\n\t\t<div class=\"tab-nav-right\">\r\n\t\t\t<button mat-icon-button ngxClipboard [cbContent]=\"category | async\"\r\n\t\t\t\t(mousemove)=\"copystate = true\" (mouseout)=\"copystate = false\">\r\n\t\t\t\t<mat-icon class=\"\u590D\u5236\u56FE\u6807\" [class.\u590D\u5236\u60AC\u6D6E]=\"copystate\"\r\n\t\t\t\t\taria-label=\"\u590D\u5236\u7C7B\u522B\" svgIcon=\"content_copy\"></mat-icon>\r\n\t\t\t</button>\r\n\t\t\t<button mat-stroked-button class=\"\u8BED\u8A00\">Eng</button>\r\n\t\t</div>\r\n\t\t<div class=\"\u590D\u5236\u8DEF\u5F84\" [class.\u590D\u5236\u60AC\u6D6E\u72B6\u6001]=\"!copystate\">\r\n\t\t\t<span class=\"\u7C7B\u522B\">{{ category | async }}</span>\r\n\t\t</div>\r\n\t</div>\r\n\r\n\t<div class=\"content-home\" [@routerTransition]=\"tabs.activeIndex\">\r\n\t\t<core-router-outlet #outlet=\"coreRouterOutlet\"></core-router-outlet>\r\n\t</div>\r\n</div>", animations: [ trigger('routerTransition', [ transition(':enter, * => -1', []), transition(':increment', [ style({ position: 'relative', overflow: 'hidden' }), query(':enter, :leave', style({ position: 'absolute', width: '100%', height: '100%' }), { optional: true }), group([ query(':enter', [ style({ transform: 'translateX(-100%)' }), animate('0.5s ease-in-out', style({ transform: 'translateX(0%)' })) ], { optional: true }), query(':leave', [ style({ transform: 'translateX(0%)' }), animate('0.5s ease-in-out', style({ transform: 'translateX(100%)' })) ], { optional: true }) ]) ]), transition(':decrement', [ style({ position: 'relative', overflow: 'hidden' }), query(':enter, :leave', style({ position: 'absolute', width: '100%', height: '100%' }), { optional: true }), group([ query(':enter', [ style({ transform: 'translateX(100%)' }), animate('0.5s ease-in-out', style({ transform: 'translateX(0%)' })) ], { optional: true }), query(':leave', [ style({ transform: 'translateX(0%)' }), animate('0.5s ease-in-out', style({ transform: 'translateX(-100%)' })) ], { optional: true }) ]) ]) ]) ], styles: ["@charset \"UTF-8\";:host{width:100%;height:100%;padding:0;margin:0;display:flex;align-items:stretch}.home-container-nav{flex-shrink:0;z-index:10}.home-container-content{height:100%;display:flex;flex-direction:column;width:10%;flex-grow:1;flex-shrink:1}.home-container-content .tab-all{display:flex;height:30px}.home-container-content .tab-all .tabNav{width:10%;flex-grow:1;flex-shrink:1}.home-container-content .tab-all .tab-nav-right{height:30px;line-height:30px;font-size:12px;position:relative;display:block}.home-container-content .tab-all .tab-nav-right button{width:24px;height:24px;line-height:24px}.home-container-content .tab-all .tab-nav-right button .\u590D\u5236\u56FE\u6807{width:16px;height:16px;margin-bottom:6px}.home-container-content .tab-all .tab-nav-right .\u8BED\u8A00{font-size:12px;height:24px;width:64px;margin:0 8px;padding:0;line-height:20px;text-align:center}.home-container-content .\u590D\u5236\u8DEF\u5F84{height:32px;position:absolute;right:0;top:30px;font-size:12px;color:#fff;line-height:32px;border-radius:4px;padding:0 8px;z-index:9;text-align:center;background-color:rgba(0,0,0,.6);box-shadow:0 4px 8px 0 rgba(0,0,0,.14)}.home-container-content .\u590D\u5236\u60AC\u6D6E\u72B6\u6001{display:none}.home-container-content .content-home{width:100%;height:10%;box-sizing:border-box;flex-grow:1;flex-shrink:1}"] }] } ]; /** @nocollapse */ HomeComponent.ctorParameters = function () { return [ { type: RouteElementService }, { type: RouteElementService }, { type: HomeTabfunctionService }, { type: TabsService } ]; }; HomeComponent.propDecorators = { hostClass: [{ type: HostBinding, args: ['class.c-home',] }], tabNavs: [{ type: ViewChild, args: ['tabNav', { static: true },] }] }; return HomeComponent; }()); if (false) { /** @type {?} */ HomeComponent.prototype.hostClass; /** @type {?} */ HomeComponent.prototype.subs; /** @type {?} */ HomeComponent.prototype.tabNavs; /** @type {?} */ HomeComponent.prototype.category; /** @type {?} */ HomeComponent.prototype.copystate; /** * @type {?} * @private */ HomeComponent.prototype.routerEle; /** @type {?} */ HomeComponent.prototype.eles; /** * @type {?} * @private */ HomeComponent.prototype.tabFun; /** @type {?} */ HomeComponent.prototype.tabs; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} val * @return {?} */ function convertBoolean(val) { return val === 'true'; } var MainNavService = /** @class */ (function () { function MainNavService() { this._navMin = new BehaviorSubject(convertBoolean(localStorage.getItem('main-nav-min'))); this.navMin = this._navMin.pipe(tap((/** * @param {?} v * @return {?} */ function (v) { localStorage.setItem('main-nav-min', v ? 'true' : 'false'); }))); } /** * @param {?} val * @return {?} */ MainNavService.prototype.setNavMin = /** * @param {?} val * @return {?} */ function (val) { this._navMin.next(val); }; /** * @return {?} */ MainNavService.prototype.getCurrent = /** * @return {?} */ function () { return this._navMin.getValue(); }; MainNavService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ MainNavService.ngInjectableDef = ɵɵdefineInjectable({ factory: function MainNavService_Factory() { return new MainNavService(); }, token: MainNavService, providedIn: "root" }); return MainNavService; }()); if (false) { /** * @type {?} * @private */ MainNavService.prototype._navMin; /** @type {?} */ MainNavService.prototype.navMin; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NavtreeService = /** @class */ (function () { // get data(): NavItem[] { // console.log(this.dataChange.value); // return this.dataChange.value; // } function NavtreeService(eles, project) { this.eles = eles; this.project = project; this.root = { children: [] }; // dataChange = new BehaviorSubject<NavItem[]>([]); this.icons = ['security', 'dns', 'gamepad']; // 图标 // this.initialize(); this.init(); for (var i = 0; i < Math.min(this.root.children.length, this.icons.length); i++) { this.root.children[i].iconName = this.icons[i]; } } /** * @return {?} */ NavtreeService.prototype.init = /** * @return {?} */ function () { var _this = this; // 设置项目图标 if (this.project.categoryIcons && this.project.categoryIcons.length > 0) { this.icons = this.project.categoryIcons; } // 如果已经初始化过,则跳出 if (this.root.children.length > 0) { return; } this.eles.getElesAsArray().forEach((/** * @param {?} element * @return {?} */ function (element) { // 后端api或者子级工作元素的,不需要加入到node列表中 if (!element.NotMenu) { _this.addElement(element, _this.root, element.Category.split('/'), 0, null, element.Icon); } })); // console.log(this.root.children[0].iconName); // console.log(this.root); }; /** * @private * @param {?} str * @return {?} */ NavtreeService.prototype.clearText = /** * @private * @param {?} str * @return {?} */ function (str) { if (str.search(/[0-9]{2}\./) > -1) { return str.substr(3); } return str; }; // 采用插入排序方法逐条插入 // 采用插入排序方法逐条插入 /** * @private * @param {?} ele * @param {?} parent * @param {?} paths * @param {?} level * @param {?} parents * @param {?} iconName * @return {?} */ NavtreeService.prototype.addElement = // 采用插入排序方法逐条插入 /** * @private * @param {?} ele * @param {?} parent * @param {?} paths * @param {?} level * @param {?} parents * @param {?} iconName * @return {?} */ function (ele, parent, paths, level, parents, iconName) { if (paths.length === 0) { // 实际插入的菜单项,也需要排序 /** @type {?} */ var idx = parent.children.findIndex((/** * @param {?} item * @return {?} */ function (item) { return (ele.Label || ele.Name).localeCompare(item.fullTitle || item.name) <= 0; })); /** @type {?} */ var node = { name: ele.Name, fullTitle: ele.Label, title: this.clearText(ele.Label || ele.Name), url: this.eles.frontElementURL(ele.Name, decodeURI(ele.URL)), level: level, parent: parents, iconName: iconName }; if (idx === -1) { parent.children.push(node); } else { parent.children.splice(idx, 0, node); } return; } /** @type {?} */ var findIdx = parent.children.findIndex((/** * @param {?} item * @return {?} */ function (item) { return paths[0].localeCompare(item.name) <= 0; })); /** @type {?} */ var categoryNode; if (findIdx !== -1 && parent.children[findIdx].name === paths[0]) { categoryNode = parent.children[findIdx]; } else { categoryNode = { name: paths[0], fullTitle: paths[0], title: this.clearText(paths[0]), level: level, parent: parents, iconName: iconName, children: [] }; // 如果找不到,则说明比里面任何一个都大,则是追加到最后一个 if (findIdx === -1) { parent.children.push(categoryNode); } else { parent.children.splice(findIdx, 0, categoryNode); } } this.addElement(ele, categoryNode, paths.slice(1), level + 1, categoryNode, iconName); }; NavtreeService.decorators = [ { type: Injectable } ]; /** @nocollapse */ NavtreeService.ctorParameters = function () { return [ { type: ElementsService }, { type: ProjectService } ]; }; return NavtreeService; }()); if (false) { /** @type {?} */ NavtreeService.prototype.root; /** @type {?} */ NavtreeService.prototype.icons; /** * @type {?} * @private */ NavtreeService.prototype.eles; /** * @type {?} * @private */ NavtreeService.prototype.project; } var NavHome = /** @class */ (function () { function NavHome(current, database, prj) { this.current = current; this.database = database; this.prj = prj; this.chatMessages = []; this.unread = null; // 未读信息数 // 未读信息数 this.openNodeCurrent = []; this.activeNode = []; this.subs = []; } /** * @param {?} node * @return {?} */ NavHome.prototype.recursionFun = /** * @param {?} node * @return {?} */ function (node) { if (node.level <= 0) { return this.openNodeCurrent.push(node); } if (node.level >= 1) { this.openNodeCurrent.push(node); this.recursionFun(node.parent); } }; /** * @param {?} node * @return {?} */ NavHome.prototype.recursionFuns = /** * @param {?} node * @return {?} */ function (node) { if (node.level <= 0) { return this.activeNode.push(node); } if (node.level >= 1) { this.activeNode.push(node); this.recursionFuns(node.parent); } }; /** * @param {?} node * @return {?} */ NavHome.prototype.gradually = /** * @param {?} node * @return {?} */ function (node) { if (this.activeNode.length !== 0) { this.activeNode.splice(0, this.activeNode.length); } this.recursionFuns(node); }; /** * @param {?} node * @return {?} */ NavHome.prototype.openNode = /** * @param {?} node * @return {?} */ function (node) { /** @type {?} */ var openboolean = this.openNodeCurrent.includes(node); if (this.openNodeCurrent.length !== 0) { this.openNodeCurrent.splice(0, this.openNodeCurrent.length); } if (openboolean) { if (node.level >= 1) { this.recursionFun(node.parent); } if (node.level === 0) { this.recursionFun(this.database.root); } } else { this.recursionFun(node); } }; /** * @return {?} */ NavHome.prototype.messages = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var chatData = JSON.parse(this.prj.loadData('chatdata')); if (chatData == null) { this.prj.saveData('chatdata', JSON.stringify(this.chatMessages)); } this.subs.push(this.current.wsChat.observable.subscribe((/** * @param {?} n * @return {?} */ function (n) { _this.chatMessages.push(n); _this.prj.saveData('chatdata', JSON.stringify(_this.chatMessages)); if (n != null) { _this.unread = _this.unread + 1; } // console.log(JSON.parse(localStorage.getItem('chatdata'))); }), (/** * @param {?} err * @return {?} */ function (err) { return console.log(err); }), (/** * @return {?} */ function () { return console.log('component'); }))); this.chatMessages = chatData; }; /** * @param {?} item * @return {?} */ NavHome.prototype.fromChildFunc = /** * @param {?} item * @return {?} */ function (item) { if (this.activeNode.length !== 0) { this.activeNode.splice(0, this.activeNode.length); } this.recursionFuns(item); if (this.openNodeCurrent.length !== 0) { this.openNodeCurrent.splice(0, this.openNodeCurrent.length); } this.recursionFun(item); }; NavHome.decorators = [ { type: Injectable } ]; /** @nocollapse */ NavHome.ctorParameters = function () { return [ { type: CurrentService }, { type: NavtreeService }, { type: ProjectService } ]; }; return NavHome; }()); if (false) { /** @type {?} */ NavHome.prototype.portraitURL; /** @type {?} */ NavHome.prototype.chatMessages; /** @type {?} */ NavHome.prototype.messageBody; /** @type {?} */ NavHome.prototype.unread; /** @type {?} */ NavHome.prototype.openNodeCurrent; /** @type {?} */ NavHome.prototype.activeNode; /** @type {?} */ NavHome.prototype.subs; /** * @type {?} * @private */ NavHome.prototype.current; /** * @type {?} * @private */ NavHome.prototype.database; /** * @type {?} * @private */ NavHome.prototype.prj; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var FileFlatNode = /** @class */ (function () { function FileFlatNode(expandable, filename, level, type) { this.expandable = expandable; this.filename = filename; this.level = level; this.type = type; } return FileFlatNode; }()); if (false) { /** @type {?} */ FileFlatNode.prototype.expandable; /** @type {?} */ FileFlatNode.prototype.filename; /** @type {?} */ FileFlatNode.prototype.level; /** @type {?} */ FileFlatNode.prototype.type; } var HomeNavComponent = /** @class */ (function () { function HomeNavComponent(nav, current, eles, database, auth, routeEle, prj, navMain, router, tabs) { var _this = this; this.nav = nav; this.current = current; this.eles = eles; this.database = database; this.auth = auth; this.routeEle = routeEle; this.prj = prj; this.navMain = navMain; this.router = router; this.tabs = tabs; // 是正常导航还是简略导航 this.isMinNav = true; // 是否打开对话框 this.isOpenDialog = false; this.navItems = []; this._getChildren = (/** * @param {?} node * @return {?} */ function (node) { return node.children; }); this.isMinNav = this.navMain.getCurrent(); this.navMain.navMin.subscribe((/** * @param {?} v * @return {?} */ function (v) { _this.switchNavToMin(v); })); this.current.change$.subscribe((/** * @param {?} v * @return {?} */ function (v) { if (v && v.HeadPortrait) { _this.nav.portraitURL = v.portraitURL; } else { _this.nav.portraitURL = portraitDefault; } })); } /** * @param {?} v * @return {?} */ HomeNavComponent.prototype.switchNavToMin = /** * @param {?} v * @return {?} */ function (v) { var _this = this; if (v === this.isMinNav) { return; } setTimeout((/** * @return {?} */ function () { _this.isMinNav = v; }), 300); if (v) { this.maxNavContainer.nativeElement.style.width = '80px'; this.maxNavContainer.nativeElement.style.transition = 'all 0.3s'; } else { this.minNavContainer.nativeElement.style.width = '240px'; this.minNavContainer.nativeElement.style.transition = 'all 0.3s'; } }; /** * @return {?} */ HomeNavComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this.nestedTreeControl = new NestedTreeControl(this._getChildren); this.nestedDataSource = new MatTreeNestedDataSource(); this.nestedDataSource.data = this.database.root.children; // this.buttonHight(); this.navItems = this.nestedDataSource.data; this.nav.subs.push(this.routeEle.currentElementListen.subscribe((/** * @param {?} e * @return {?} */ function (e) { // 偶尔会出现e未null的情况,原因未探查,等有时间再改造 if (e && e.element) { _this.currentNode = null; _this.obtainNode(e.element.Name, _this.navItems); if (_this.nav.activeNode.length !== 0 && _this.currentNode !== null) { _this.nav.activeNode.splice(0, _this.nav.activeNode.length); } if (_this.nav.openNodeCurrent.length !== 0 && _this.currentNode !== null) { _this.nav.openNodeCurrent.splice(0, _this.nav.openNodeCurrent.length); } if (_this.currentNode !== null) { _this.nav.recursionFuns(_this.currentNode); _this.nav.recursionFun(_this.currentNode); } } }))); this.nav.messages(); }; /** * @return {?} */ HomeNavComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.nav.subs.forEach((/** * @param {?} v * @return {?} */ function (v) { return v.unsubscribe(); })); }; /** * @return {?} */ HomeNavComponent.prototype.logout = /** * @return {?} */ function () { var _this = this; this.router .navigateByUrl('/login' + '/' + this.prj.apiNav()[0] + '/' + this.prj.apiNav()[1] + '/login') .then((/** * @return {?} */ function () { // 必须要在路由切换之后,因为只有切换后,才会在reuse中存在,才能clear _this.tabs.clear(); // 一定要先清除所有的tab页面,用于取消订阅curr的变化 _this.auth.logoutDefault().subscribe(); })); }; /** * @param {?} _ * @param {?} nodeData * @return {?} */ HomeNavComponent.prototype.hasNestedChild = /** * @param {?} _ * @param {?} nodeData * @return {?} */ function (_, nodeData) { return !!nodeData.children && nodeData.children.length > 0; }; // 对话框显示 // 对话框显示 /** * @return {?} */ HomeNavComponent.prototype.openDialog = // 对话框显示 /** * @return {?} */ function () { var _this = this; this.isOpenDialog = true; // this.unread = null; setTimeout((/** * @return {?} */ function () { _this.dialogScrolls(); }), 0); }; /** * @return {?} */ HomeNavComponent.prototype.closeDialog = /** * @return {?} */ function () { this.isOpenDialog = false; }; // 获取当前节点的node // 获取当前节点的node /** * @param {?} title * @param {?} navItems * @return {?} */ HomeNavComponent.prototype.obtainNode = // 获取当前节点的node /** * @param {?} title * @param {?} navItems * @return {?} */ function (title, navItems) { for (var i = 0; i <= navItems.length - 1; i++) { if (navItems[i].name === title) { this.currentNode = navItems[i]; } if (navItems[i].children !== undefined && this.currentNode == null) { this.obtainNode(title, navItems[i].children); } } }; /** * @return {?} */ HomeNavComponent.prototype.sendMessage = /** * @return {?} */ function () { var _this = this; if (this.nav.messageBody) { this.current.wsChat.next({ Creator: this.prj.Creator(), Project: this.prj.Name(), From: this.current.data.UserName, Addr: '', Time: null, Data: this.nav.messageBody }); this.nav.messageBody = ''; } setTimeout((/** * @return {?} */ function () { _this.dialogScrolls(); }), 0); }; // 输入框的回车事件 // 输入框的回车事件 /** * @param {?} e * @return {?} */ HomeNavComponent.prototype.keyDown = // 输入框的回车事件 /** * @param {?} e * @return {?} */ function (e) { /** @type {?} */ var ev = window.event || e; // 13是键盘上面固定的回车键 if (ev.keyCode === 13) { // 你要执行的方法 this.sendMessage(); } }; // 将聊天窗口滚动条滚至最下方 // 将聊天窗口滚动条滚至最下方 /** * @return {?} */ HomeNavComponent.prototype.dialogScrolls = // 将聊天窗口滚动条滚至最下方 /** * @return {?} */ function () { if (this.dialogScroll == null) { return; } this.nav.unread = null; this.dialogScroll.nativeElement.scrollTop = this.dialogScroll.nativeElement.scrollHeight; }; // 判断是否已阅读最新消息 // 判断是否已阅读最新消息 /** * @return {?} */ HomeNavComponent.prototype.isNews = // 判断是否已阅读最新消息 /** * @return {?} */ function () { /** @type {?} */ var isScrolledToBottom = this.dialogScroll.nativeElement.scrollHeight - this.dialogScroll.nativeElement.clientHeight <= this.dialogScroll.nativeElement.scrollTop + 1; if (isScrolledToBottom) { this.nav.unread = null; } }; HomeNavComponent.decorators = [ { type: Component, args: [{ selector: 'common-home-nav', template: "<div *ngIf=\"!isMinNav\" #maxNavContainer class=\"max-nav-container nav-container\">\r\n\t<div class=\"nav-top\">\r\n\t\t<div class=\"nav-title\">\r\n\t\t\t<div class=\"nav-title-logo\"><img [src]=\"prj.logoImageURL()\" /></div>\r\n\t\t\t<div class=\"nav-title-name\">\r\n\t\t\t\t<p\r\n\t\t\t\t\t[ngClass]=\"{'projectLabelMin': prj.projectLabelForShort.length>6}\">\r\n\t\t\t\t\t{{ prj.projectLabelForShort }}</p>\r\n\t\t\t\t<common-nav-selection-dept [isMinNav]=\"isMinNav\">\r\n\t\t\t\t</common-nav-selection-dept>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t\t<div (click)=\"switchNavToMin(!isMinNav)\" class=\"nav-switch\">\r\n\t\t\t<mat-icon svgIcon=\"chevron_left\"></mat-icon>\r\n\t\t</div>\r\n\t</div>\r\n\t<mat-divider class=\"nav-divider\"></mat-divider>\r\n\t<div class=\"\u5BFC\u822A\u6811\">\r\n\t\t<div class=\"slider slider-color\"></div>\r\n\t\t<mat-tree [dataSource]=\"nestedDataSource\" [treeControl]=\"nestedTreeControl\" class=\"example-tree\">\r\n\t\t\t<mat-tree-node *matTreeNodeDef=\"let node; index as i\" matTreeNodeToggle>\r\n\t\t\t\t<li (click)=\"nav.gradually(node)\" class=\"mat-tree-node\">\r\n\t\t\t\t\t<button [class.collapsed]=\"nav.activeNode.includes(node)\" [routerLink]=\"[node.url]\" mat-button\r\n\t\t\t\t\t\tclass=\"\u5BFC\u822A\u6309\u94AE\u60AC\u6D6E\u8272\">\r\n\t\t\t\t\t\t<mat-icon *ngIf=\"node.iconName\" class=\"menu-icon\" [svgIcon]=\"node.iconName\"></mat-icon>\r\n\t\t\t\t\t\t{{ node.title }}\r\n\t\t\t\t\t</button>\r\n\t\t\t\t</li>\r\n\t\t\t</mat-tree-node>\r\n\t\t\t<mat-nested-tree-node *matTreeNodeDef=\"let node; when: hasNestedChild; let i = index\" matTreeNodePadding>\r\n\t\t\t\t<div class=\"max-menu\" [class.\u5206\u652F\u80CC\u666F]=\"nav.openNodeCurrent.includes(node)\">\r\n\t\t\t\t\t<div *ngIf=\"node.level == 0\" [ngClass]=\"{\r\n\t\t\t\t\t\t\t'slider-color': nav.activeNode.includes(node),\r\n\t\t\t\t\t\t\t'max-left-slider': nav.activeNode.includes(node)\r\n\t\t\t\t\t\t}\"></div>\r\n\t\t\t\t\t<div class=\"mat-tree-node\">\r\n\t\t\t\t\t\t<button [class.collapsed]=\"nav.activeNode.includes(node)\" mat-button matTreeNodeToggle\r\n\t\t\t\t\t\t\t[attr.aria-label]=\"'toggle ' + node.title\" (click)=\"nav.openNode(node)\" class=\"\u5BFC\u822A\u6309\u94AE\u60AC\u6D6E\u8272\">\r\n\t\t\t\t\t\t\t<mat-icon *ngIf=\"node.level == 0\" svgIcon=\"{{ node.iconName }}\">\r\n\t\t\t\t\t\t\t</mat-icon>\r\n\t\t\t\t\t\t\t{{ node.title }}\r\n\t\t\t\t\t\t\t<mat-icon *ngIf=\"node.level != 0\" class=\"mat-icon-rtl-mirror\" svgIcon=\"{{\r\n\t\t\t\t\t\t\t\t\tnav.openNodeCurrent.includes(node)\r\n\t\t\t\t\t\t\t\t\t\t? 'expand_more'\r\n\t\t\t\t\t\t\t\t\t\t: 'chevron_right'\r\n\t\t\t\t\t\t\t\t}}\">\r\n\t\t\t\t\t\t\t</mat-icon>\r\n\t\t\t\t\t\t</button>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<ul [class.example-tree-invisible]=\"\r\n\t\t\t\t\t\t\t!nav.openNodeCurrent.includes(node)\r\n\t\t\t\t