UNPKG

ng-yunzai-mobile

Version:

1. 适配yunzai_uni_app_x

1,613 lines (1,599 loc) 414 kB
import { NgModule, InjectionToken, Injectable, Inject, ɵɵdefineInjectable, ɵɵinject, inject, Directive, ViewContainerRef, TemplateRef, Input, Component, CUSTOM_ELEMENTS_SCHEMA, EventEmitter, Output, Injector, INJECTOR, APP_INITIALIZER } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RouterModule, ActivatedRoute, Router } from '@angular/router'; import { NgZorroAntdMobileModule, ModalService, ToastService } from 'ng-zorro-antd-mobile'; import { MatDialogModule } from '@angular/material'; import { PinchZoomModule } from 'ngx-pinch-zoom'; import { ImageCropperModule } from 'ngx-image-cropper'; import { DragDropModule } from '@angular/cdk/drag-drop'; import { BehaviorSubject, from, of, throwError } from 'rxjs'; import { share, map, mergeMap, catchError } from 'rxjs/operators'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { HttpClient, HttpResponseBase, HttpErrorResponse } from '@angular/common/http'; import { DomSanitizer, Title } from '@angular/platform-browser'; import { __awaiter } from 'tslib'; import imageCompression from 'browser-image-compression'; /** * @fileoverview added by tsickle * Generated from: shared.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class SharedModule { } SharedModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, RouterModule, FormsModule, NgZorroAntdMobileModule, MatDialogModule, PinchZoomModule, ImageCropperModule, DragDropModule ], exports: [ CommonModule, RouterModule, FormsModule, NgZorroAntdMobileModule, MatDialogModule, PinchZoomModule, ImageCropperModule, DragDropModule ] },] } ]; /** * @fileoverview added by tsickle * Generated from: user/user.store.interface.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const DA_STORE_USER = new InjectionToken('AUTH_STORE_USER'); /** * @record */ function UserStore() { } if (false) { /** * @param {?} key * @return {?} */ UserStore.prototype.get = function (key) { }; /** * @param {?} key * @param {?} value * @return {?} */ UserStore.prototype.set = function (key, value) { }; /** * @param {?} key * @return {?} */ UserStore.prototype.remove = function (key) { }; } /** * @fileoverview added by tsickle * Generated from: client/base.client.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const BASE_CLIENT = new InjectionToken('BASE_CLIENT'); /** * @record */ function BaseClient() { } if (false) { /** @type {?|undefined} */ BaseClient.prototype.gateway; /** @type {?|undefined} */ BaseClient.prototype.ignores; /** @type {?|undefined} */ BaseClient.prototype.dev; /** @type {?|undefined} */ BaseClient.prototype.wechat; /** @type {?|undefined} */ BaseClient.prototype.wechatMicro; /** @type {?|undefined} */ BaseClient.prototype.android; /** @type {?|undefined} */ BaseClient.prototype.browser; /** @type {?|undefined} */ BaseClient.prototype.ios; /** @type {?|undefined} */ BaseClient.prototype.yunzaiIm; /** @type {?|undefined} */ BaseClient.prototype.yunzaiOaUniAppX; /** @type {?|undefined} */ BaseClient.prototype.dingtalk; /** @type {?|undefined} */ BaseClient.prototype.openDev; /** @type {?|undefined} */ BaseClient.prototype.alwaysBrowser; /** @type {?} */ BaseClient.prototype.mobileVersion; } /** * @fileoverview added by tsickle * Generated from: token/istore.interface.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const DA_STORE_TOKEN = new InjectionToken('AUTH_STORE_TOKEN'); /** * @record */ function IStore() { } if (false) { /** * @param {?} key * @return {?} */ IStore.prototype.get = function (key) { }; /** * @param {?} key * @param {?} value * @return {?} */ IStore.prototype.set = function (key, value) { }; /** * @param {?} key * @return {?} */ IStore.prototype.remove = function (key) { }; } /** * @fileoverview added by tsickle * Generated from: token/token.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const STORE_KEY = 'token'; class TokenService { /** * @param {?} store */ constructor(store) { this.store = store; this.change$ = new BehaviorSubject(null); } /** * @param {?} data * @return {?} */ set(data) { this.change$.next(data); return this.store.set(STORE_KEY, data); } /** * @template T * @param {?=} type * @return {?} */ get(type) { /** @type {?} */ const data = this.store.get(STORE_KEY); return type ? ((/** @type {?} */ (Object.assign(new type(), data)))) : ((/** @type {?} */ (data))); } /** * @return {?} */ clear() { this.change$.next(null); this.store.remove(STORE_KEY); } /** * @return {?} */ change() { return this.change$.pipe(share()); } } TokenService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ TokenService.ctorParameters = () => [ { type: undefined, decorators: [{ type: Inject, args: [DA_STORE_TOKEN,] }] } ]; /** @nocollapse */ TokenService.ngInjectableDef = ɵɵdefineInjectable({ factory: function TokenService_Factory() { return new TokenService(ɵɵinject(DA_STORE_TOKEN)); }, token: TokenService, providedIn: "root" }); if (false) { /** * @type {?} * @private */ TokenService.prototype.change$; /** * @type {?} * @private */ TokenService.prototype.store; } /** * @fileoverview added by tsickle * Generated from: token/token.interface.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const DA_SERVICE_TOKEN = new InjectionToken('DA_SERVICE_TOKEN', { providedIn: 'root', factory: DA_SERVICE_TOKEN_FACTORY, }); /** * @return {?} */ function DA_SERVICE_TOKEN_FACTORY() { return new TokenService(inject(DA_STORE_TOKEN)); } /** * @record */ function ITokenService() { } if (false) { /** * @param {?} data * @return {?} */ ITokenService.prototype.set = function (data) { }; /** * @param {?=} type * @return {?} */ ITokenService.prototype.get = function (type) { }; /** * @template T * @param {?=} type * @return {?} */ ITokenService.prototype.get = function (type) { }; /** * @return {?} */ ITokenService.prototype.clear = function () { }; /** * @return {?} */ ITokenService.prototype.change = function () { }; } /** * @fileoverview added by tsickle * Generated from: user/user.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const STORE_KEY$1 = 'user'; class UserService { /** * @param {?} store * @param {?} client * @param {?} tokenService */ constructor(store, client, tokenService) { this.store = store; this.client = client; this.tokenService = tokenService; this.change$ = new BehaviorSubject(null); } /** * @param {?} data * @return {?} */ set(data) { this.change$.next(data); return this.store.set(STORE_KEY$1, data); } /** * @template T * @param {?=} type * @return {?} */ get(type) { /** @type {?} */ const data = this.store.get(STORE_KEY$1); return type ? ((/** @type {?} */ (Object.assign(new type(), data)))) : ((/** @type {?} */ (data))); } /** * @return {?} */ clear() { this.change$.next(null); this.store.remove(STORE_KEY$1); } /** * @return {?} */ change() { return this.change$.pipe(share()); } /** * @return {?} */ logout() { this.tokenService.set(null); this.tokenService.clear(); window.location.href = `${this.client.gateway}/cas-proxy/app/logout`; } /** * @return {?} */ getConfig() { if (this.get().menu) { return JSON.parse(this.get().menu[0].attribute); } else { return null; } } /** * @return {?} */ getMenus() { return this.get().menu || []; } /** * @param {?} menus * @param {?} systemCode * @return {?} */ findMenuBySystemCode(menus, systemCode) { /** @type {?} */ let targetMenu = menus.find((/** * @param {?} item * @return {?} */ item => item.systemCode === systemCode)); if (targetMenu != null) { return targetMenu; } for (let i = 0; i < menus.length; i++) { /** @type {?} */ const menu = menus[i]; /** @type {?} */ let targetSubMenu = this.findMenuBySystemCode(menu.children || [], systemCode); if (targetSubMenu != null) { return targetSubMenu; } } return null; } } UserService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ UserService.ctorParameters = () => [ { type: undefined, decorators: [{ type: Inject, args: [DA_STORE_USER,] }] }, { type: undefined, decorators: [{ type: Inject, args: [BASE_CLIENT,] }] }, { type: TokenService, decorators: [{ type: Inject, args: [DA_SERVICE_TOKEN,] }] } ]; /** @nocollapse */ UserService.ngInjectableDef = ɵɵdefineInjectable({ factory: function UserService_Factory() { return new UserService(ɵɵinject(DA_STORE_USER), ɵɵinject(BASE_CLIENT), ɵɵinject(DA_SERVICE_TOKEN)); }, token: UserService, providedIn: "root" }); if (false) { /** * @type {?} * @private */ UserService.prototype.change$; /** * @type {?} * @private */ UserService.prototype.store; /** * @type {?} * @private */ UserService.prototype.client; /** * @type {?} * @private */ UserService.prototype.tokenService; } /** * @fileoverview added by tsickle * Generated from: acl/acl.directive.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class AclDirective { /** * @param {?} user * @param {?} viewContainer * @param {?} templateRef */ constructor(user, viewContainer, templateRef) { this.user = user; this.viewContainer = viewContainer; this.templateRef = templateRef; } /** * @param {?} acl * @return {?} */ set condition(acl) { // 系统代码 /** @type {?} */ const systemCode = acl[0]; // 路由 /** @type {?} */ const elementRoute = acl[1]; // 元素key /** @type {?} */ const elementKey = acl[2]; /** @type {?} */ const tempArray = []; // tslint:disable-next-line: prefer-const /** @type {?} */ let hasElement = false; // 过滤菜单通过 系统代码 路由 this.filterMenuByAcl(this.filterSystemSider(systemCode), tempArray, elementRoute); tempArray.forEach((/** * @param {?} menu * @return {?} */ (menu) => { if (menu.menuAuths.includes(elementKey)) { hasElement = true; } })); if (hasElement) { this.viewContainer.createEmbeddedView(this.templateRef); } else { this.viewContainer.clear(); } } /** * @param {?} systemcode * @return {?} */ filterSystemSider(systemcode) { return this.user.get().menu.filter((/** * @param {?} menu * @return {?} */ (menu) => { return menu.systemCode === systemcode; })); } /** * @param {?} menus * @param {?} tempArray * @param {?} elementRoute * @return {?} */ filterMenuByAcl(menus, tempArray, elementRoute) { menus.forEach((/** * @param {?} menu * @return {?} */ (menu) => { if (menu.children.length > 0) { this.filterMenuByAcl(menu.children, tempArray, elementRoute); } else { if (menu.link === elementRoute) { tempArray.push(menu); } } })); } } AclDirective.decorators = [ { type: Directive, args: [{ // tslint:disable-next-line: directive-selector selector: '[acl]' },] } ]; /** @nocollapse */ AclDirective.ctorParameters = () => [ { type: UserService }, { type: ViewContainerRef }, { type: TemplateRef } ]; AclDirective.propDecorators = { condition: [{ type: Input, args: ['acl',] }] }; if (false) { /** * @type {?} * @private */ AclDirective.prototype.user; /** * @type {?} * @private */ AclDirective.prototype.viewContainer; /** * @type {?} * @private */ AclDirective.prototype.templateRef; } /** * @fileoverview added by tsickle * Generated from: acl/acl.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const COMPONENTS = [ AclDirective, ]; class AclModule { } AclModule.decorators = [ { type: NgModule, args: [{ declarations: [ ...COMPONENTS, ], imports: [ SharedModule ], exports: [ ...COMPONENTS ] },] } ]; /** * @fileoverview added by tsickle * Generated from: token/memory.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class MemoryStore { constructor() { this.cache = {}; } /** * @param {?} key * @return {?} */ get(key) { return this.cache[key] || (/** @type {?} */ ({})); } /** * @param {?} key * @param {?} value * @return {?} */ set(key, value) { this.cache[key] = value; return true; } /** * @param {?} key * @return {?} */ remove(key) { this.cache[key] = null; } } if (false) { /** * @type {?} * @private */ MemoryStore.prototype.cache; } /** * @fileoverview added by tsickle * Generated from: user/user.memory.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class MemoryUserStore { constructor() { this.cache = {}; } /** * @param {?} key * @return {?} */ get(key) { return this.cache[key] || (/** @type {?} */ ({})); } /** * @param {?} key * @param {?} value * @return {?} */ set(key, value) { this.cache[key] = value; return true; } /** * @param {?} key * @return {?} */ remove(key) { this.cache[key] = null; } } if (false) { /** * @type {?} * @private */ MemoryUserStore.prototype.cache; } /** * @fileoverview added by tsickle * Generated from: select-contacts/yz-select-contacts/dept.interface.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function DeptInterface() { } if (false) { /** @type {?|undefined} */ DeptInterface.prototype.title; /** @type {?|undefined} */ DeptInterface.prototype.key; /** @type {?|undefined} */ DeptInterface.prototype.value; /** @type {?|undefined} */ DeptInterface.prototype.icon; /** @type {?|undefined} */ DeptInterface.prototype.selected; /** @type {?|undefined} */ DeptInterface.prototype.expanded; /** @type {?|undefined} */ DeptInterface.prototype.children; } /** * @record */ function BaseUserInterface() { } if (false) { /** @type {?|undefined} */ BaseUserInterface.prototype.checked; /** @type {?|undefined} */ BaseUserInterface.prototype.disabled; /** @type {?|undefined} */ BaseUserInterface.prototype.userId; /** @type {?|undefined} */ BaseUserInterface.prototype.account; /** @type {?|undefined} */ BaseUserInterface.prototype.password; /** @type {?|undefined} */ BaseUserInterface.prototype.realName; /** @type {?|undefined} */ BaseUserInterface.prototype.header; /** @type {?|undefined} */ BaseUserInterface.prototype.userType; /** @type {?|undefined} */ BaseUserInterface.prototype.userCode; /** @type {?|undefined} */ BaseUserInterface.prototype.sex; /** @type {?|undefined} */ BaseUserInterface.prototype.email; /** @type {?|undefined} */ BaseUserInterface.prototype.mobile; /** @type {?|undefined} */ BaseUserInterface.prototype.officePhone; /** @type {?|undefined} */ BaseUserInterface.prototype.readNumber; /** @type {?|undefined} */ BaseUserInterface.prototype.status; /** @type {?|undefined} */ BaseUserInterface.prototype.displayIndex; /** @type {?|undefined} */ BaseUserInterface.prototype.idCard; /** @type {?|undefined} */ BaseUserInterface.prototype.lastDate; /** @type {?|undefined} */ BaseUserInterface.prototype.operUser; /** @type {?|undefined} */ BaseUserInterface.prototype.twoPassword; /** @type {?|undefined} */ BaseUserInterface.prototype.lastLoginTime; /** @type {?|undefined} */ BaseUserInterface.prototype.remark; /** @type {?|undefined} */ BaseUserInterface.prototype.errorCount; /** @type {?|undefined} */ BaseUserInterface.prototype.question; /** @type {?|undefined} */ BaseUserInterface.prototype.answer; /** @type {?|undefined} */ BaseUserInterface.prototype.theme; /** @type {?|undefined} */ BaseUserInterface.prototype.roles; /** @type {?|undefined} */ BaseUserInterface.prototype.roleIdList; /** @type {?} */ BaseUserInterface.prototype.rolesData; /** @type {?|undefined} */ BaseUserInterface.prototype.dept; /** @type {?|undefined} */ BaseUserInterface.prototype.deptId; /** @type {?|undefined} */ BaseUserInterface.prototype.isDelete; /** @type {?|undefined} */ BaseUserInterface.prototype.avatarId; /** @type {?|undefined} */ BaseUserInterface.prototype.bgimgId; /** @type {?|undefined} */ BaseUserInterface.prototype.profile; /** @type {?|undefined} */ BaseUserInterface.prototype.passwordStrength; /** @type {?|undefined} */ BaseUserInterface.prototype.lastLoginIp; } /** * @record */ function BaseUserDept() { } if (false) { /** @type {?|undefined} */ BaseUserDept.prototype.deptId; /** @type {?|undefined} */ BaseUserDept.prototype.deptName; /** @type {?|undefined} */ BaseUserDept.prototype.deptType; /** @type {?|undefined} */ BaseUserDept.prototype.deptComment; /** @type {?|undefined} */ BaseUserDept.prototype.leaf; /** @type {?|undefined} */ BaseUserDept.prototype.displayIndex; /** @type {?|undefined} */ BaseUserDept.prototype.deptCode; /** @type {?|undefined} */ BaseUserDept.prototype.status; /** @type {?|undefined} */ BaseUserDept.prototype.children; /** @type {?|undefined} */ BaseUserDept.prototype.pid; /** @type {?|undefined} */ BaseUserDept.prototype.expand; /** @type {?|undefined} */ BaseUserDept.prototype.createdDate; } // 组件参数 class ComponentOption { constructor() { this.includeClass = true; // 是否包含班级(普通部门+系部+班级),true:普通部门+系部+班级,false:普通部门+系部,默认为true // 是否包含班级(普通部门+系部+班级),true:普通部门+系部+班级,false:普通部门+系部,默认为true this.includeHisClass = true; // 是否包含历史班级,默认为true,只在includeClass=true时起作用 // 是否包含历史班级,默认为true,只在includeClass=true时起作用 this.count = 0; // 最多人数限制,默认不限制 // 最多人数限制,默认不限制 this.defaultContacts = []; // 默认已被选择的人员 // 默认已被选择的人员 this.onlyStudent = false; // 部门树只选学生(系部+班级) // 部门树只选学生(系部+班级) this.userTypes = null; // 人员类型,多个类型以逗号隔开。当按部门查询且只选学生(onlyStudent = true)时默认为“2,3”,更改不起作用,其他情况下无默认值可做修改; } } if (false) { /** @type {?} */ ComponentOption.prototype.includeClass; /** @type {?} */ ComponentOption.prototype.includeHisClass; /** @type {?} */ ComponentOption.prototype.count; /** @type {?} */ ComponentOption.prototype.defaultContacts; /** @type {?} */ ComponentOption.prototype.onlyStudent; /** @type {?} */ ComponentOption.prototype.userTypes; } /** * @fileoverview added by tsickle * Generated from: select-contacts/yz-select-contacts/yz-select-contacts.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class YzSelectContactsService { /** * @param {?} dialog * @param {?} client * @param {?} http * @param {?} tokenService */ constructor(dialog, client, http, tokenService) { this.dialog = dialog; this.client = client; this.http = http; this.tokenService = tokenService; } /** * 选择人员 * @param {?} option * @return {?} */ choosePeople(option) { if (this.tokenService.get().accessToken) { /** @type {?} */ const dialogRef = this.dialog.open(YzSelectContactsComponent, { panelClass: 'yz-select-contacts-panel', closeOnNavigation: true, data: { includeClass: option.includeClass == undefined ? true : option.includeClass, includeHisClass: option.includeHisClass == undefined ? true : option.includeHisClass, count: option.count == undefined ? 0 : option.count, defaultContacts: option.defaultContacts == undefined ? [] : option.defaultContacts, onlyStudent: option.onlyStudent == undefined ? false : option.onlyStudent, userTypes: option.userTypes == undefined ? null : option.userTypes } }); dialogRef.afterClosed().subscribe((/** * @param {?} result * @return {?} */ result => { if (option.onOk) { option.onOk(result ? result : []); } })); } else { alert('无法获取Token,请刷新!'); } } /** * 查询部门树 * @param {?} includeClass 是否包含班级 * @param {?} includeHisClass 是否包含历史班级,只在includeClass=true时起作用 * @return {?} */ getDeptTree(includeClass, includeHisClass) { /** @type {?} */ let url = `${this.client.gateway}/auth/baseDepartMent/tree`; if (includeClass) { if (includeHisClass) { url = url + `?includeClass=true&includeHisClass=true`; } else { url = url + `?includeClass=true&includeHisClass=false`; } } else { url = url + `?includeClass=false`; } return this.http.get(url).pipe(map((/** * @param {?} response * @return {?} */ (response) => { return response.data ? response.data : []; }))); } /** * 查询部门树->只选学生(系部+班级) * @param {?} gradeId 年级id * @param {?} includeClass * @param {?} includeHisClass * @return {?} */ getDeptTreeOnlyStu(gradeId, includeClass, includeHisClass) { /** @type {?} */ let url; if (gradeId) { url = `${this.client.gateway}/auth/baseDepartMent/tree?gradeId=${gradeId}&deptTypes=2,class`; if (includeClass) { if (includeHisClass) { url = url + `&includeClass=true&includeHisClass=true`; } else { url = url + `&includeClass=true&includeHisClass=false`; } } else { url = url + `&includeClass=false`; } } else { url = `${this.client.gateway}/auth/baseDepartMent/tree?deptTypes=2,class`; if (includeClass) { if (includeHisClass) { url = url + `&includeClass=true&includeHisClass=true`; } else { url = url + `&includeClass=true&includeHisClass=false`; } } else { url = url + `&includeClass=false`; } } return this.http.get(url).pipe(map((/** * @param {?} response * @return {?} */ (response) => { return response.data ? response.data : []; }))); } /** * 查询人员列表 * @param {?} pageNum 当前页面 * @param {?} pageSize 每页条数 * @param {?} realName 姓名 * @param {?} deptId 部门id * @param {?} userTypes 用户类型1,2,3,4逗号拼接:查询普通部门的用户(不包括学生)传“1,4”;查询学生用户传“2,3”;查询所有用户不传 * @return {?} */ getBaseUser(pageNum, pageSize, realName, deptId, userTypes) { return this.http.post(`${this.client.gateway}/auth/baseUser/queryListForPage`, { "pageNum": pageNum, "pageSize": pageSize, "pageParam": { "realName": realName, "deptId": deptId, "userTypes": userTypes } }).pipe(map((/** * @param {?} response * @return {?} */ (response) => { return response ? response : null; }))); } /** * 查询人员信息 * @param {?} userIds * @return {?} */ getUserByUserIds(userIds) { return this.http.post(`${this.client.gateway}/auth/baseUser/users`, { userIds: userIds }).pipe(map((/** * @param {?} response * @return {?} */ (response) => { return response.data ? response.data : []; }))); } /** * 查询年级 * @return {?} */ getGrade() { return this.http.get(`${this.client.gateway}/auth/gradeYear/queryListForPage`).pipe(map((/** * @param {?} response * @return {?} */ (response) => { return response.data ? response.data : []; }))); } } YzSelectContactsService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ YzSelectContactsService.ctorParameters = () => [ { type: MatDialog }, { type: undefined, decorators: [{ type: Inject, args: [BASE_CLIENT,] }] }, { type: HttpClient }, { type: TokenService } ]; /** @nocollapse */ YzSelectContactsService.ngInjectableDef = ɵɵdefineInjectable({ factory: function YzSelectContactsService_Factory() { return new YzSelectContactsService(ɵɵinject(MatDialog), ɵɵinject(BASE_CLIENT), ɵɵinject(HttpClient), ɵɵinject(TokenService)); }, token: YzSelectContactsService, providedIn: "root" }); if (false) { /** @type {?} */ YzSelectContactsService.prototype.dialog; /** * @type {?} * @private */ YzSelectContactsService.prototype.client; /** * @type {?} * @private */ YzSelectContactsService.prototype.http; /** * @type {?} * @private */ YzSelectContactsService.prototype.tokenService; } /** * @fileoverview added by tsickle * Generated from: select-contacts/yz-select-contacts/yz-select-contacts.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class YzSelectContactsComponent { /** * @param {?} dialogRef * @param {?} _modal * @param {?} yzContactsService * @param {?} data */ constructor(dialogRef, _modal, yzContactsService, data) { this.dialogRef = dialogRef; this._modal = _modal; this.yzContactsService = yzContactsService; this.data = data; this.modalRefCpt = []; this.subscribed = []; this.dtPullToRefreshStyle = { height: window.innerHeight - 44 - 51 + 'px' }; // 总部门数据 this.deptNodes = []; // 页面展示的部门数据 this.deptList = []; // 面包屑 this.deptBarList = []; // 页面加载中 this.pageLoading = false; // 人员列表参数 this.baseUserParams = { total: 0, pageSize: 20, pageNum: 1, deptId: null, realName: null, userTypes: null }; // 人员数据 this.baseUserList = []; // 是否全选人员 this.allUserCheck = false; // 已选择的联系人 this.selectedContacts = []; // 年级数据 this.gradeList = []; this.gradeParams = []; } /** * @return {?} */ ngOnInit() { if (this.data.onlyStudent === true) { this.baseUserParams.userTypes = '2,3'; this.dtPullToRefreshStyle = { height: window.innerHeight - 44 - 51 - 44 + 'px' }; this.initDeptOnlyStu(); this.queryGrade(); } else { this.baseUserParams.userTypes = this.data.userTypes; this.dtPullToRefreshStyle = { height: window.innerHeight - 44 - 51 + 'px' }; this.initDept(); } } // 查询部门树 /** * @return {?} */ initDept() { this.deptList = []; this.deptNodes = []; this.pageLoading = true; /** @type {?} */ const $temp = this.yzContactsService.getDeptTree(this.data.includeClass, this.data.includeHisClass).subscribe((/** * @param {?} dept * @return {?} */ (dept) => { this.pageLoading = false; this.deptNodes = dept; this.deptList = JSON.parse(JSON.stringify(this.deptNodes)); this.queryDefaultContact(); this.blDeptTree(this.deptList); this.blDeptTree(this.deptNodes); this.subscribed.push($temp); }), (/** * @return {?} */ () => { this.pageLoading = false; })); } // 查询部门->只选学生 /** * @return {?} */ initDeptOnlyStu() { this.deptList = []; this.deptNodes = []; this.pageLoading = true; /** @type {?} */ let gradeId = null; if (this.gradeParams.length > 0) { gradeId = this.gradeParams[0].value; } /** @type {?} */ const $temp = this.yzContactsService.getDeptTreeOnlyStu(gradeId, this.data.includeClass, this.data.includeHisClass).subscribe((/** * @param {?} dept * @return {?} */ (dept) => { this.pageLoading = false; this.deptNodes = dept; this.deptList = JSON.parse(JSON.stringify(this.deptNodes)); this.queryDefaultContact(); this.blDeptTree(this.deptList); this.blDeptTree(this.deptNodes); this.subscribed.push($temp); }), (/** * @return {?} */ () => { this.pageLoading = false; })); } // 查询年级 /** * @return {?} */ queryGrade() { this.gradeList = []; this.pageLoading = true; /** @type {?} */ const $temp = this.yzContactsService.getGrade().subscribe((/** * @param {?} data * @return {?} */ (data) => { this.pageLoading = false; this.gradeList = []; data.forEach((/** * @param {?} item * @return {?} */ (item) => { if (item.enable !== 0 && item.enable !== null) { this.gradeList.push({ value: item.openId, label: item.name }); } })); this.gradeList.unshift({ value: null, label: '全部' }); this.subscribed.push($temp); }), (/** * @return {?} */ () => { this.pageLoading = false; this.gradeList.unshift({ value: null, label: '全部' }); })); } // 遍历部门树,确定叶子节点 /** * @param {?} tree * @return {?} */ blDeptTree(tree) { if (tree && tree.length && tree.length > 0) { tree.forEach((/** * @param {?} item * @return {?} */ (item) => { item.expanded = true; if (item.children === null || item.children.length === 0) { item['isLeaf'] = true; } else { item['isLeaf'] = false; } this.blDeptTree(item.children); })); } } // 查询默认已被选择人员的信息 /** * @return {?} */ queryDefaultContact() { if (this.data.defaultContacts && this.data.defaultContacts.length > 0) { /** @type {?} */ const userIdsArray = []; this.data.defaultContacts.forEach((/** * @param {?} item * @return {?} */ (item) => { if (item.userId) { userIdsArray.push(item.userId); } })); this.pageLoading = true; /** @type {?} */ const $temp = this.yzContactsService.getUserByUserIds(userIdsArray).subscribe((/** * @param {?} data * @return {?} */ (data) => { this.pageLoading = false; this.selectedContacts = data; this.queryBaseUser(); this.subscribed.push($temp); }), (/** * @return {?} */ () => { this.pageLoading = false; })); } else { this.queryBaseUser(); } } // 查询人员列表 /** * @return {?} */ queryBaseUser() { this.pageLoading = true; /** @type {?} */ const $temp = this.yzContactsService.getBaseUser(this.baseUserParams.pageNum, this.baseUserParams.pageSize, this.baseUserParams.realName, this.baseUserParams.deptId, this.baseUserParams.userTypes).subscribe((/** * @param {?} data * @return {?} */ (data) => { this.pageLoading = false; this.baseUserParams.total = data.total; this.baseUserList.push(...data.list); this.baseUserList.forEach((/** * @param {?} item * @return {?} */ (item) => { item['checked'] = false; item['disabled'] = false; if (!item.dept) { item.dept = { deptName: '暂无部门' }; } if (!item.realName) { item.realName = '暂无姓名'; } if (!item.userCode) { item.realName = '暂无学/工号'; } if (!item.roles) { item.roles = []; item.rolesData = '暂无角色'; } else { /** @type {?} */ const roleArray = []; item.roles.forEach((/** * @param {?} value * @return {?} */ (value) => { roleArray.push(value.roleName); })); item.rolesData = roleArray.toString(); } this.selectedContacts.forEach((/** * @param {?} value * @return {?} */ (value) => { if (value.userId === item.userId) { item['checked'] = true; } })); })); this.isMaxCount(); this.subscribed.push($temp); }), (/** * @return {?} */ () => { this.pageLoading = false; })); } // 刷新回调函数 /** * @return {?} */ pullToRefresh() { if (this.baseUserList.length < this.baseUserParams.total) { this.baseUserParams.pageNum++; this.queryBaseUser(); } } // 根据用户姓名即时搜索人员 /** * @return {?} */ queryUserByRealName() { this.baseUserParams.pageNum = 1; this.baseUserList = []; this.queryBaseUser(); } // 取消——根据用户姓名即时搜索人员 /** * @return {?} */ cancelQueUserByRealName() { this.baseUserParams.realName = null; this.baseUserParams.pageNum = 1; this.baseUserList = []; this.queryBaseUser(); } // 查询全部人员 /** * @return {?} */ viewAllList() { this.deptList = JSON.parse(JSON.stringify(this.deptNodes)); this.deptBarList = []; this.baseUserParams.deptId = ''; this.baseUserParams.pageNum = 1; this.baseUserList = []; this.queryBaseUser(); } // 顶部面包屑查看部门详细 /** * @param {?} item * @param {?} index * @return {?} */ deptBarviewList(item, index) { if (index != this.deptBarList.length - 1) { this.deptList = item.children; this.deptBarList.length = index + 1; this.baseUserParams.deptId = item.key; this.baseUserParams.pageNum = 1; this.baseUserList = []; this.queryBaseUser(); } } // 查看子部门 -> 查询当前部门人员 /** * @param {?} item * @return {?} */ viewDeptChildrenList(item) { if (item.isLeaf) { // 是叶子节点,无子部门 this.deptList = []; } else { this.deptList = item.children; } this.deptBarList.push(item); this.baseUserParams.deptId = item.key; this.baseUserParams.pageNum = 1; this.baseUserList = []; this.queryBaseUser(); } // 人员选择变化的回调 /** * @param {?} $event * @return {?} */ userCheckedChange($event) { if ($event.checked) { // 选中 this.allUserCheck = this.baseUserList.every((/** * @param {?} item * @return {?} */ (item) => { return item.checked === true; })); } else { // 取消 // 取消 /** @type {?} */ let itemIndex = 0; this.selectedContacts.forEach((/** * @param {?} value * @param {?} index * @return {?} */ (value, index) => { if (value.userId === $event.value) { itemIndex = index; } })); this.deleteContact($event.value, itemIndex); } this.addBaseUser(); } // 将人员列表中选中项添加至已选择的人员列表中 /** * @return {?} */ addBaseUser() { this.baseUserList.forEach((/** * @param {?} item * @return {?} */ (item) => { /** @type {?} */ const hasThisMen = this.selectedContacts.some((/** * @param {?} value * @return {?} */ (value) => { return value.userId === item.userId; })); if (item.checked && !hasThisMen) { this.selectedContacts.push(item); } })); this.isMaxCount(); } // 人数选择达到最大值 /** * @return {?} */ isMaxCount() { if (this.data.count > 0 && this.selectedContacts.length >= this.data.count) { this.selectedContacts.length = this.data.count; this.baseUserList.forEach((/** * @param {?} item * @return {?} */ (item) => { /** @type {?} */ const hasThisUser = this.selectedContacts.some((/** * @param {?} value * @return {?} */ (value) => { return item.userId === value.userId; })); if (!hasThisUser) { item.checked = false; item.disabled = true; } })); } else { this.baseUserList.forEach((/** * @param {?} item * @return {?} */ (item) => { item.disabled = false; })); } if (this.baseUserList.length == 0) { this.allUserCheck = false; } else { this.allUserCheck = this.baseUserList.every((/** * @param {?} item * @return {?} */ (item) => { return item.checked === true; })); } } // 删除联系人 /** * @param {?} id * @param {?} index * @return {?} */ deleteContact(id, index) { this.selectedContacts.splice(index, 1); this.baseUserList.forEach((/** * @param {?} item * @return {?} */ (item) => { if (item.userId === id) { item.checked = false; } })); if (this.baseUserList.length == 0) { this.allUserCheck = false; } else { this.allUserCheck = this.baseUserList.every((/** * @param {?} item * @return {?} */ (item) => { return item.checked === true; })); } } // 全选 /** * @return {?} */ allSelect() { this.allUserCheck = true; this.baseUserList.forEach((/** * @param {?} item * @return {?} */ (item) => { item.checked = true; })); this.addBaseUser(); } // 取消全选 /** * @return {?} */ cancelAllSelect() { this.allUserCheck = false; this.baseUserList.forEach((/** * @param {?} item * @return {?} */ (item) => { /** @type {?} */ let itemIndex = 0; this.selectedContacts.forEach((/** * @param {?} value * @param {?} index * @return {?} */ (value, index) => { if (value.userId === item.userId) { itemIndex = index; } })); this.deleteContact(item.userId, itemIndex); })); } // 切换年级 /** * @param {?} $event * @return {?} */ onChangeGrade($event) { if ($event && $event.length && $event.length > 0) { this.gradeParams = $event; } else { this.gradeParams = [{ value: null, label: '全部' }]; } this.deptBarList = []; this.baseUserParams.deptId = ''; this.baseUserParams.pageNum = 1; this.baseUserList = []; this.initDeptOnlyStu(); } // 点“完成”按钮,完成人员选择 /** * @return {?} */ confirmSelect() { this.dialogRef.close(this.selectedContacts); } /** * @return {?} */ ngOnDestroy() { this.subscribed.forEach((/** * @param {?} sub * @return {?} */ (sub) => { sub.unsubscribe(); })); this.modalRefCpt.forEach((/** * @param {?} ref * @return {?} */ (ref) => { ref.destroy(); })); } } YzSelectContactsComponent.decorators = [ { type: Component, args: [{ selector: 'yz-select-contacts', template: "<yz-loading-mask *ngIf=\"pageLoading\"></yz-loading-mask>\r\n<div class=\"yz-select-contacts\">\r\n <div class=\"yz-select-contacts-search\">\r\n <SearchBar [placeholder]=\"'\u8BF7\u8F93\u5165\u59D3\u540D\u2026\u2026'\"\r\n [(ngModel)]=\"baseUserParams.realName\"\r\n (onSubmit)=\"queryUserByRealName()\"\r\n (onCancel)=\"cancelQueUserByRealName()\"\r\n (onClear)=\"cancelQueUserByRealName()\"></SearchBar>\r\n </div>\r\n <div class=\"yz-select-contacts-grade\" *ngIf=\"data.onlyStudent\">\r\n <List [className]=\"'yz-select-contact-list'\">\r\n <ListItem\r\n Picker\r\n [extra]=\"gradeParams.length>0?gradeParams[0].label:'\u8BF7\u9009\u62E9\u5E74\u7EA7\u2026\u2026'\"\r\n [arrow]=\"'horizontal'\"\r\n [data]=\"gradeList\"\r\n [(ngModel)]=\"gradeParams\"\r\n (ngModelChange)=\"onChangeGrade($event)\">\r\n \u5E74\u7EA7\uFF1A\r\n </ListItem>\r\n </List>\r\n </div>\r\n\r\n\r\n <PullToRefresh [ngStyle]=\"dtPullToRefreshStyle\"\r\n [direction]=\"'up'\"\r\n (onRefresh)=\"pullToRefresh()\"\r\n >\r\n <div class=\"yz-select-contact-dept-bar\">\r\n <a (click)=\"viewAllList()\">\u5168\u90E8</a>\r\n <ng-container *ngFor=\"let item of deptBarList;let i=index;\">\r\n <a (click)=\"deptBarviewList(item, i)\">>{{item?.title}}</a>\r\n </ng-container>\r\n </div>\r\n\r\n <!--\u90E8\u95E8-->\r\n <List [className]=\"'yz-select-contact-list'\" *ngIf=\"deptList.length>0\">\r\n <ListItem multipleLine [arrow]=\"'horizontal'\"\r\n [thumb]=\"'./assets/imgs/icon_dept.png'\"\r\n *ngFor=\"let item of deptList\"\r\n (onClick)=\"viewDeptChildrenList(item)\">\r\n {{item?.title || '--'}}\r\n </ListItem>\r\n </List>\r\n\r\n <!--\u4EBA\u5458-->\r\n <List [className]=\"'contact-list'\" *ngIf=\"baseUserList.length>0\">\r\n <CheckboxItem\r\n *ngFor=\"let item of baseUserList\"\r\n [name]=\"item.realName\"\r\n [value]=\"item.userId\"\r\n [(ngModel)]=\"item.checked\"\r\n [disabled]=\"item.disabled\"\r\n (onChange)=\"userCheckedChange($event)\"\r\n >\r\n {{ item.realName }}<small *ngIf=\"item?.userCode\">({{item.userCode}})</small>\r\n </CheckboxItem>\r\n </List>\r\n </PullToRefresh>\r\n\r\n\r\n <div class=\"yz-select-contacts-btn\">\r\n <div class=\"count-box\">\u5DF2\u9009\u62E9\uFF1A{{selectedContacts.length}} \u4EBA</div>\r\n <div Button [type]=\"'primary'\" [size]=\"'small'\" [inline]=\"true\" (onClick)=\"confirmSelect()\">\u5B8C\u6210<