提交 25cdc559 编写于 作者: zcdtk's avatar zcdtk

init

流水线 #1169 已取消 ,包含阶段
# General
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
MIT License
Copyright (c) 2020 iBiz-R7前端标准模板
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
// import moment from 'moment';
import { AppCommunicationsCenter } from './app-communications-center';
/**
* 应用消息发送工具
*
* @export
* @class AccSendUtil
*/
export class AccSendUtil {
/**
* 消息发送
*
* @protected
* @memberof AccSendUtil
*/
protected acc: AppCommunicationsCenter;
/**
* Creates an instance of AccSendUtil.
* @memberof AccSendUtil
*/
constructor(acc: AppCommunicationsCenter) {
this.acc = acc;
}
/**
* 指令-更新
*
* @param {*} data
* @memberof ControlBase
*/
public update(data: any): void {
this.acc.sendMessage({
type: 'COMMAND',
subtype: 'OBJECTUPDATED',
content: data
});
}
/**
* 指令-删除
*
* @param {*} data
* @memberof ControlBase
*/
public remove(data: any): void {
this.acc.sendMessage({
type: 'COMMAND',
subtype: 'OBJECTREMOVED',
content: data
});
}
/**
* 指令-新建
*
* @param {*} data
* @memberof ControlBase
*/
public create(data: any): void {
this.acc.sendMessage({
type: 'COMMAND',
subtype: 'OBJECTCREATED',
content: data
});
}
/**
* 向console区发送消息
*
* @param {string} message 消息内容
* @param {('success' | 'error' | 'warning' | 'info')} [type='info'] 消息类型
* @param {string} [subtype] 消息子类型用于分类
* @returns {void}
* @memberof AccSendUtil
*/
public console(message: string, type: 'success' | 'error' | 'warning' | 'info' = 'info', subtype?: string): void {
if (message) {
switch (type) {
case 'success':
return this.consoleSuccess(message, subtype);
case 'error':
return this.consoleError(message, subtype);
case 'warning':
return this.consoleWarning(message, subtype);
case 'info':
return this.consoleInfo(message, subtype);
}
}
}
/**
* 发送成功消息
*
* @protected
* @param {string} message
* @memberof AccSendUtil
*/
protected consoleSuccess(message: string, subtype?: string): void {
this.acc.sendMessage({
type: 'CONSOLE',
subtype,
content: `${this.getLocalDate()} \x1b[32m${message} \x1b[0m`
});
}
/**
* 发送错误消息
*
* @protected
* @param {string} message
* @memberof AccSendUtil
*/
protected consoleError(message: string, subtype?: string): void {
this.acc.sendMessage({
type: 'CONSOLE',
subtype,
content: `${this.getLocalDate()} \x1b[31m${message} \x1b[0m`
});
}
/**
* 发送警告消息
*
* @protected
* @param {string} message
* @memberof AccSendUtil
*/
protected consoleWarning(message: string, subtype?: string): void {
this.acc.sendMessage({
type: 'CONSOLE',
subtype,
content: `${this.getLocalDate()} \x1b[33m${message} \x1b[0m`
});
}
/**
* 发送消息
*
* @protected
* @param {string} message
* @memberof AccSendUtil
*/
protected consoleInfo(message: string, subtype?: string): void {
this.acc.sendMessage({
type: 'CONSOLE',
subtype,
content: message
});
}
/**
* 获取当前时间
*
* @protected
* @returns {string}
* @memberof AccSendUtil
*/
protected getLocalDate(): string {
// return moment().format('MM-DD HH:mm:ss');
return '';
}
}
\ No newline at end of file
/**
* 全局消息
*
* @export
* @interface AppMessage
*/
export interface AppMessage {
/**
* 消息类型
*
* @type {('CONSOLE' | 'COMMAND')}
* @memberof AppMessage
*/
type: 'CONSOLE' | 'COMMAND';
/**
* 消息子类型
*
* @type {('OBJECTUPDATED' | 'OBJECTREMOVED' | 'OBJECTCREATED' | string)}
* @memberof AppMessage
*/
subtype?: 'OBJECTUPDATED' | 'OBJECTREMOVED' | 'OBJECTCREATED' | string;
/**
* 消息内容
*
* @type {*}
* @memberof AppMessage
*/
content: any;
}
\ No newline at end of file
import { Subject, Subscription } from 'rxjs';
import { Util } from '../../../../utils';
/**
*
*
* @export
* @class MessageTypeBase
*/
export class MessageTypeBase {
/**
* 数据流发射器
*
* @protected
* @type {Subject<any>}
* @memberof MessageConsole
*/
protected subject: Subject<any> = new Subject();
/**
* 本地数据发射流
*
* @protected
* @type {Subject<any>}
* @memberof MessageTypeBase
*/
protected subjectLocal: Subject<any> = new Subject();
/**
* 事件订阅缓存(避免重复订阅)
*
* @protected
* @type {Map<string, Subject<any>>}
* @memberof MessageTypeBase
*/
protected subjectMap: Map<string, Subject<any>> = new Map();
/**
* 本地消息事件订阅缓存(避免重复订阅)
*
* @protected
* @type {Map<string, Subject<any>>}
* @memberof MessageTypeBase
*/
protected subjectLocalMap: Map<string, Subject<any>> = new Map();
/**
* 缓存
*
* @protected
* @type {Map<string, Subscription>}
* @memberof MessageConsole
*/
protected map: Map<string, Subscription> = new Map();
/**
* 本地缓存
*
* @protected
* @type {Map<string, Subscription>}
* @memberof MessageTypeBase
*/
protected mapLocal: Map<string, Subscription> = new Map();
/**
* 发送消息
*
* @param {*} message
* @param {string} [type]
* @memberof MessageTypeBase
*/
public next(message: any, type?: string): void {
if (type) {
if (this.subjectMap.has(type)) {
const sub: any = this.subjectMap.get(type);
sub.next(message.content);
}
} else {
this.subject.next(message.content);
}
}
/**
* 发送本地消息
*
* @param {*} message
* @param {string} [type]
* @memberof MessageTypeBase
*/
public nextLocal(message: any, type?: string): void {
if (type) {
if (this.subjectLocalMap.has(type)) {
const sub: any = this.subjectLocalMap.get(type);
sub.next(message.content);
}
} else {
this.subjectLocal.next(message.content);
}
}
/**
* 订阅消息
*
* @param {(content: any) => void} [observer]
* @param {string} [type]
* @returns {string}
* @memberof MessageTypeBase
*/
public subscribe(observer?: (content: any) => void, type?: string): string {
const key: string = Util.createUUID();
if (type) {
let sub: any;
if (this.subjectMap.has(type)) {
sub = this.subjectMap.get(type);
} else {
sub = new Subject();
this.subjectMap.set(type, sub);
}
this.map.set(key, sub.asObservable().subscribe(observer));
} else {
this.map.set(key, this.subject.asObservable().subscribe(observer));
}
return key;
}
/**
* 订阅本地消息
*
* @param {(content: any) => void} [observer]
* @param {string} [type]
* @returns {string}
* @memberof MessageTypeBase
*/
public subscribeLocal(observer?: (content: any) => void, type?: string): string {
const key: string = Util.createUUID();
if (type) {
let sub: any;
if (this.subjectLocalMap.has(type)) {
sub = this.subjectLocalMap.get(type);
} else {
sub = new Subject();
this.subjectLocalMap.set(type, sub);
}
this.mapLocal.set(key, sub.asObservable().subscribe(observer));
} else {
this.mapLocal.set(key, this.subjectLocal.asObservable().subscribe(observer));
}
return key;
}
/**
* 取消订阅
*
* @param {string} key
* @returns {void}
* @memberof MessageConsole
*/
public unsubscribe(key: string): void {
if (this.map.has(key)) {
const sub: any = this.map.get(key);
sub.unsubscribe();
}
}
/**
* 取消订阅本地消息
*
* @param {string} key
* @memberof MessageTypeBase
*/
public unsubscribeLocal(key: string): void {
if (this.mapLocal.has(key)) {
const sub: any = this.mapLocal.get(key);
sub.unsubscribe();
}
}
}
\ No newline at end of file
import { MessageTypeBase } from '../base/message-type-base';
/**
* 更新消息
*
* @export
* @class CommandCreate
* @extends {MessageTypeBase}
*/
export class CommandCreate extends MessageTypeBase {
}
\ No newline at end of file
import { MessageTypeBase } from '../base/message-type-base';
/**
* 更新消息
*
* @export
* @class CommandRemove
* @extends {MessageTypeBase}
*/
export class CommandRemove extends MessageTypeBase {
}
\ No newline at end of file
import { MessageTypeBase } from '../base/message-type-base';
/**
* 更新消息
*
* @export
* @class CommandUpdate
* @extends {MessageTypeBase}
*/
export class CommandUpdate extends MessageTypeBase {
}
\ No newline at end of file
import { MessageTypeBase } from './base/message-type-base';
import { CommandUpdate } from './command/command-update';
import { CommandCreate } from './command/command-create';
import { CommandRemove } from './command/command-remove';
import { AppMessage } from '../interface';
/**
* 命令消息
*
* @export
* @class MessageCommand
*/
export class MessageCommand extends MessageTypeBase {
/**
* 更新消息
*
* @protected
* @type {CommandUpdate}
* @memberof MessageCommand
*/
protected $update: CommandUpdate = new CommandUpdate();
/**
* 更新消息
*
* @readonly
* @type {CommandUpdate}
* @memberof MessageCommand
*/
public get update(): CommandUpdate {
return this.$update;
}
/**
* 新建消息
*
* @protected
* @type {CommandCreate}
* @memberof MessageCommand
*/
protected $create: CommandCreate = new CommandCreate();
/**
* 新建消息
*
* @readonly
* @type {CommandCreate}
* @memberof MessageCommand
*/
public get create(): CommandCreate {
return this.$create;
}
/**
* 删除消息
*
* @protected
* @type {CommandRemove}
* @memberof MessageCommand
*/
protected $remove: CommandRemove = new CommandRemove();
/**
* CommandRemove
*
* @readonly
* @type {CommandRemove}
* @memberof MessageCommand
*/
public get remove(): CommandRemove {
return this.$remove;
}
/**
* 发送消息
*
* @param {AppMessage} message
* @memberof MessageCommand
*/
public next(message: AppMessage): void {
if (message) {
const content: any = message.content;
const deName: string = content.srfdename;
if (content && deName && !Object.is(deName, '')) {
this.subNext(message, deName);
}
this.subNext(message);
super.next(message, deName);
}
}
/**
* 发送本地消息
*
* @param {AppMessage} message
* @memberof MessageCommand
*/
public nextLocal(message: AppMessage): void {
if (message) {
const content: any = message.content;
const deName: string = content.srfdename;
if (content && deName && !Object.is(deName, '')) {
this.subNextLocal(message, deName);
}
this.subNextLocal(message);
super.nextLocal(message, deName);
}
}
/**
* 根据子类别发送消息
*
* @param {AppMessage} message
* @param {string} [type]
* @memberof MessageCommand
*/
public subNext(message: AppMessage, type?: string): void {
if (Object.is(message.subtype, 'OBJECTUPDATED')) {
this.$update.next(message, type);
}
if (Object.is(message.subtype, 'OBJECTREMOVED')) {
this.$remove.next(message, type);
}
if (Object.is(message.subtype, 'OBJECTCREATED')) {
this.$create.next(message, type);
}
}
/**
* 根据子类别发送本地消息
*
* @param {AppMessage} message
* @param {string} [type]
* @memberof MessageCommand
*/
public subNextLocal(message: AppMessage, type?: string): void {
if (Object.is(message.subtype, 'OBJECTUPDATED')) {
this.$update.nextLocal(message, type);
}
if (Object.is(message.subtype, 'OBJECTREMOVED')) {
this.$remove.nextLocal(message, type);
}
if (Object.is(message.subtype, 'OBJECTCREATED')) {
this.$create.nextLocal(message, type);
}
}
/**
* 取消订阅
*
* @param {string} key
* @memberof MessageCommand
*/
public unsubscribe(key: string): void {
super.unsubscribe(key);
this.$create.unsubscribe(key);
this.$remove.unsubscribe(key);
this.$update.unsubscribe(key)
}
/**
* 取消本地订阅
*
* @param {string} key
* @memberof MessageCommand
*/
public unsubscribeLocal(key: string): void {
super.unsubscribeLocal(key);
this.$create.unsubscribeLocal(key);
this.$remove.unsubscribeLocal(key);
this.$update.unsubscribeLocal(key)
}
}
\ No newline at end of file
import { MessageTypeBase } from './base/message-type-base';
/**
* 控制台消息
*
* @export
* @class MessageConsole
*/
export class MessageConsole extends MessageTypeBase {
/**
* 发送消息
*
* @param {*} message
* @param {string} [type]
* @memberof MessageTypeBase
*/
public next(message: any, type?: string): void {
if (type) {
if (this.subjectMap.has(type)) {
const sub: any = this.subjectMap.get(type);
sub.next(message);
} else { }
} else {
this.subject.next(message);
}
}
/**
* 发送本地消息
*
* @param {*} message
* @param {string} [type]
* @memberof MessageConsole
*/
public nextLocal(message: any, type?: string): void {
if (type) {
if (this.subjectLocalMap.has(type)) {
const sub: any = this.subjectLocalMap.get(type);
sub.next(message);
} else { }
} else {
this.subjectLocal.next(message);
}
}
}
\ No newline at end of file
import { AccMessageBase } from './base/acc-message-base';
/**
*
*
* @export
* @class AccCentralMessage
* @extends {AccMessageBase}
*/
export class AccCentralMessage extends AccMessageBase {
}
\ No newline at end of file
import { AccMessageBase } from './base/acc-message-base';
/**
*
*
* @export
* @class AccCurrentMessage
* @extends {AccMessageBase}
*/
export class AccCurrentMessage extends AccMessageBase {
}
\ No newline at end of file
import { AccMessageBase } from './base/acc-message-base';
/**
*
*
* @export
* @class AccSystemMessage
* @extends {AccMessageBase}
*/
export class AccSystemMessage extends AccMessageBase {
}
\ No newline at end of file
import { Subject, Subscription } from 'rxjs';
import { Util } from '../../../../utils';
import { MessageConsole } from '../../message-type/message-console';
import { MessageCommand } from '../../message-type/message-command';
import { AppMessage } from '../../interface';
/**
* 应用中心消息
*
* @export
* @class AccMessageBase
*/
export class AccMessageBase {
/**
* 数据流发射器
*
* @protected
* @type {Subject<any>}
* @memberof MessageConsole
*/
protected subject: Subject<any> = new Subject();
/**
* 本地数据流发射器
*
* @protected
* @type {Subject<any>}
* @memberof AccMessageBase
*/
protected subjectLocal: Subject<any> = new Subject();
/**
* 订阅缓存
*
* @protected
* @type {Map<string, Subscription>}
* @memberof MessageConsole
*/
protected map: Map<string, Subscription> = new Map();
/**
* 本地订阅缓存
*
* @protected
* @type {Map<string, Subscription>}
* @memberof AccMessageBase
*/
protected mapLocal: Map<string, Subscription> = new Map();
/**
* console消息实例
*
* @protected
* @type {MessageConsole}
* @memberof AccMessageBase
*/
protected $messageConsole: MessageConsole = new MessageConsole();
/**
* console消息实例
*
* @readonly
* @type {MessageConsole}
* @memberof AccMessageBase
*/
public get console(): MessageConsole {
return this.$messageConsole;
}
/**
* command消息实例
*
* @protected
* @type {MessageCommand}
* @memberof AccMessageBase
*/
protected $messageCommand: MessageCommand = new MessageCommand();
/**
* MessageCommand
*
* @readonly
* @type {MessageCommand}
* @memberof AccMessageBase
*/
public get command(): MessageCommand {
return this.$messageCommand;
}
/**
* 发送消息数据
*
* @param {AppMessage} message
* @memberof AccMessageBase
*/
public next(message: AppMessage): void {
if (message) {
if (Object.is(message.type, 'CONSOLE')) {
this.$messageConsole.next(message);
}
if (Object.is(message.type, 'COMMAND')) {
this.$messageCommand.next(message);
}
this.subject.next(message);
}
}
/**
* 发送本地消息数据
*
* @param {AppMessage} message
* @memberof AccMessageBase
*/
public nextLocal(message: AppMessage): void {
if (message) {
if (Object.is(message.type, 'CONSOLE')) {
this.$messageConsole.nextLocal(message);
}
if (Object.is(message.type, 'COMMAND')) {
this.$messageCommand.nextLocal(message);
}
this.subjectLocal.next(message);
}
}
/**
* 订阅消息
*
* @param {(content: any) => void} [observer]
* @param {string} [type]
* @returns {string}
* @memberof MessageTypeBase
*/
public subscribe(observer?: (content: any) => void): string {
const key: string = Util.createUUID();
this.map.set(key, this.subject.asObservable().subscribe(observer));
return key;
}
/**
* 订阅本地消息
*
* @param {(content: any) => void} [observer]
* @returns {string}
* @memberof AccMessageBase
*/
public subscribeLocal(observer?: (content: any) => void): string {
const key: string = Util.createUUID();
this.mapLocal.set(key, this.subjectLocal.asObservable().subscribe(observer));
return key;
}
/**
* 取消订阅
*
* @param {string} key
* @returns {void}
* @memberof MessageConsole
*/
public unsubscribe(key: string): void {
this.$messageConsole.unsubscribe(key);
this.$messageCommand.unsubscribe(key);
if (this.map.has(key)) {
const sub: any = this.map.get(key);
sub.unsubscribe();
}
}
/**
* 取消订阅本地
*
* @param {string} key
* @memberof AccMessageBase
*/
public unsubscribeLocal(key: string): void {
this.$messageConsole.unsubscribeLocal(key);
this.$messageCommand.unsubscribeLocal(key);
if (this.mapLocal.has(key)) {
const sub: any = this.mapLocal.get(key);
sub.unsubscribe();
}
}
}
\ No newline at end of file
import { HttpResponse } from '../utils';
/**
* 代码表基类
*
* @export
* @class CodeListBase
*/
export class CodeListBase {
/**
* 代码表项主键标识
*
* @protected
* @type {string}
* @memberof CodeListBase
*/
protected idKey: string = '';
/**
* 代码表项值项标识
*
* @protected
* @type {string}
* @memberof CodeListBase
*/
protected valueKey: string = '';
/**
* 代码表项文本标识
*
* @protected
* @type {string}
* @memberof CodeListBase
*/
protected textKey: string = '';
/**
* 处理数据
*
* @protected
* @param {any[]} items
* @returns {any[]}
* @memberof CodeListBase
*/
protected doItems(items: any[]): any[] {
return items.map((item: any) => {
const data: any = {};
Object.assign(data, { id: item[this.idKey] });
Object.assign(data, { value: item[this.valueKey] });
Object.assign(data, { text: item[this.textKey] });
return data;
});;
}
/**
* 获取数据项
*
* @param {*} data
* @returns {Promise<any>}
* @memberof SysOperator
*/
public async getItems(data: any = {}): Promise<any> {
return new HttpResponse(200, []);
}
/**
* 根据实体名称获取service
*
* @protected
* @param {string} name
* @returns {Promise<any>}
* @memberof CodeListBase
*/
protected getService(name: string): Promise<any> {
return window.appEntityServiceConstructor.getService(name);
}
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 应用菜单部件服务基类
*
* @export
* @class AppMenuServiceBase
* @extends {ControlServiceBase}
*/
export class AppMenuServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { MdServiceBase } from './md-service-base';
import { HttpResponse } from '../utils';
/**
* 日历部件服务基类
*
* @export
* @class CalendarServiceBase
* @extends {MdServiceBase}
*/
export class CalendarServiceBase extends MdServiceBase {
/**
* 事件配置集合
*
* @protected
* @type {any[]}
* @memberof CalendarServiceBase
*/
protected eventsConfig: any = {};
/**
* 加载实体数据集
*
* @protected
* @param {string} action
* @param {*} context
* @param {*} data
* @param {string} calendarItem
* @param {string} [serviceName]
* @returns {Promise<any[]>}
* @memberof CalendarServiceBase
*/
protected async loadDEDataSet(action: string, context: any, data: any, calendarItem: string, serviceName?: string): Promise<any[]> {
if (serviceName) {
const service: any = await this.getService(serviceName);
const response: HttpResponse = await service[action](context, data);
if (response.isError()) {
return Promise.reject(response);
}
return this.formatItem(response, calendarItem);
}
const response: HttpResponse = await this.service[action](context, data);
if (response.isError()) {
return Promise.reject(response);
}
return this.formatItem(response, calendarItem);
}
/**
* 格式化数据项
*
* @protected
* @param {*} response
* @param {string} type
* @returns {any[]}
* @memberof CalendarServiceBase
*/
protected formatItem(response: any, type: string): any[] {
if (response.data) {
response.data.forEach((item: any) => {
item.color = this.eventsConfig[type].color;
item.textColor = this.eventsConfig[type].textColor;
item.itemType = this.eventsConfig[type].itemType;
});
}
this.model.itemType = this.eventsConfig[type].itemType;
response = this.handleResponse(type, response);
return response.data.records;
}
/**
* 处理response
*
* @param {string} action
* @param {*} response
* @memberof CalendarServiceBase
*/
public handleResponse(action: string, response: any): any {
return new HttpResponse(response.status, this.handleResponseData(action, response.data));
}
}
\ No newline at end of file
import { MdServiceBase } from './md-service-base';
/**
* 表格部件服务基类
*
* @export
* @class ChartServiceBase
* @extends {ControlServiceBase}
*/
export class ChartServiceBase extends MdServiceBase {
}
\ No newline at end of file
此差异已折叠。
import { ControlServiceBase } from './control-service-base';
/**
* 数据看板部件服务基类
*
* @export
* @class DashboardServiceBase
* @extends {ControlServiceBase}
*/
export class DashboardServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { Util, HttpResponse } from '../utils';
import { ControlServiceBase } from './control-service-base';
/**
* 数据视图部件服务基类
*
* @export
* @class DataViewServiceBase
* @extends {ControlServiceBase}
*/
export class DataViewServiceBase extends ControlServiceBase {
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isLoading]
* @returns {Promise<HttpResponse>}
* @memberof DataViewServiceBase
*/
public async search(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
await this.onBeforeAction(action, context, data, isLoading);
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
response = await this.service.FetchDefault(context, data);
}
if (!response.isError()) {
response = this.handleResponse(action, response);
}
await this.onAfterAction(action, context, response);
return response;
}
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 数据关系分页部件服务基类
*
* @export
* @class DrBarServiceBase
* @extends {ControlServiceBase}
*/
export class DrBarServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 数据关系分页部件服务基类
*
* @export
* @class DrTabServiceBase
* @extends {ControlServiceBase}
*/
export class DrTabServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
import { HttpResponse, Util } from '../utils';
/**
* 表单部件服务基类
*
* @export
* @class FormServiceBase
* @extends {ControlServiceBase}
*/
export class FormServiceBase extends ControlServiceBase {
/**
* 处理数据
*
* @protected
* @param {HttpResponse} res
* @returns {Promise<any[]>}
* @memberof GridServiceBase
*/
protected async doItems(res: HttpResponse): Promise<any[]> {
if (res.status === 200) {
return [res.data];
}
return [];
}
/**
* 启动工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isLoading]
* @returns {Promise<HttpResponse>}
* @memberof FormServiceBase
*/
public async wfstart(action: string, context: any = {}, data: any = {}, isLoading: boolean): Promise<HttpResponse> {
await this.onBeforeAction(action, context, data, isLoading);
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
response = await this.service.Create(context, data);
}
if (!response.isError()) {
response = this.handleResponse(action, response);
}
await this.onAfterAction(action, context, response);
return response;
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isLoading]
* @returns {Promise<HttpResponse>}
* @memberof FormServiceBase
*/
public async wfsubmit(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
await this.onBeforeAction(action, context, data, isLoading);
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
response = await this.service.Create(context, data);
}
if (!response.isError()) {
response = this.handleResponse(action, response);
}
await this.onAfterAction(action, context, response);
return response;
}
/**
* 处理返回数据
*
* @param {string} action
* @param {*} [data={}]
* @param {boolean} [isCreate]
* @returns {*}
* @memberof FormServiceBase
*/
public handleResponseData(action: string, data: any = {}, isCreate?: boolean): any {
if (!this.model || !Util.isFunction(this.model.getDataItems)) {
return data;
}
const item: any = {};
const dataItems: any[] = this.model.getDataItems();
dataItems.forEach(dataitem => {
let val = data.hasOwnProperty(dataitem.prop) ? data[dataitem.prop] : null;
if (!val) {
val = data.hasOwnProperty(dataitem.name) ? data[dataitem.name] : null;
}
if ((isCreate === undefined || isCreate === null) && Object.is(dataitem.dataType, 'GUID') && Object.is(dataitem.name, 'srfkey') && (val && !Object.is(val, ''))) {
isCreate = true;
}
item[dataitem.name] = val;
});
if (isCreate) {
if (!item.srfuf) {
Object.assign(item, { srfuf: '0' });
}
} else {
if (!item.srfuf) {
Object.assign(item, { srfuf: '1' });
}
}
Object.assign(data, item);
return data;
}
}
\ No newline at end of file
import { MdServiceBase } from './md-service-base';
/**
* 表格部件服务基类
*
* @export
* @class GridServiceBase
* @extends {ControlServiceBase}
*/
export class GridServiceBase extends MdServiceBase {
}
\ No newline at end of file
import { MdServiceBase } from './md-service-base';
/**
* 列表部件服务基类
*
* @export
* @class ListServiceBase
* @extends {ControlServiceBase}
*/
export class ListServiceBase extends MdServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
import { Util, HttpResponse } from '../utils';
/**
* 多数据部件服务基类
*
* @export
* @class MdServiceBase
* @extends {ControlServiceBase}
*/
export class MdServiceBase extends ControlServiceBase {
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isLoading]
* @returns {Promise<HttpResponse>}
* @memberof MdServiceBase
*/
public async search(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
await this.onBeforeAction(action, context, data, isLoading);
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
response = await this.service.FetchDefault(context, data);
}
if (!response.isError()) {
response = this.handleResponse(action, response);
}
await this.onAfterAction(action, context, response);
return response;
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isLoading]
* @returns {Promise<HttpResponse>}
* @memberof MdServiceBase
*/
public async loadDraft(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
const response: any = await super.loadDraft(action, context, data, isLoading);
// 处理返回数据,补充判断标识
if (response.data) {
Object.assign(response.data, { srfuf: '0' });
}
return response;
}
/**
* 处理response
*
* @param {string} action
* @param {*} response
* @memberof MdServiceBase
*/
public handleResponse(action: string, response: any): any {
const result = {};
if (response.status) {
Object.assign(result, { status: response.status });
}
if (response.headers) {
if (response.headers['x-page']) {
Object.assign(result, { page: Number(response.headers['x-page']) });
}
if (response.headers['x-per-page']) {
Object.assign(result, { size: Number(response.headers['x-per-page']) });
}
if (response.headers['x-total']) {
Object.assign(result, { total: Number(response.headers['x-total']) });
}
}
Object.assign(result, this.handleResponseData(action, response.data));
return new HttpResponse(response.status, result);
}
/**
* 处理数据
*
* @param {string} action 行为名称
* @param {*} [data]
* @returns
* @memberof MdServiceBase
*/
public handleResponseData(action: string, data: any) {
if (!this.model || !Util.isFunction(this.model.getDataItems)) {
return { records: data };
}
const result: any = {};
const dataItems: any[] = this.model.getDataItems();
const tempData: any = data;
if (!tempData) {
Object.assign(result, { records: tempData });
} else if (tempData instanceof Array) {
if (tempData.length > 0) {
tempData.forEach((item: any) => {
dataItems.forEach(dataitem => {
let val = item.hasOwnProperty(dataitem.prop) ? item[dataitem.prop] : null;
if (!val) {
val = item.hasOwnProperty(dataitem.name) ? item[dataitem.name] : null;
}
item[dataitem.name] = val;
});
});
Object.assign(result, { records: tempData });
} else {
Object.assign(result, { records: [] });
}
} else {
dataItems.forEach(dataitem => {
let val = tempData.hasOwnProperty(dataitem.prop) ? tempData[dataitem.prop] : null;
if (!val) {
val = tempData.hasOwnProperty(dataitem.name) ? tempData[dataitem.name] : null;
}
tempData[dataitem.name] = val;
});
Object.assign(result, { records: tempData });
}
return result;
}
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 多编辑视图面板部件服务基类
*
* @export
* @class MultiEditViewPanelServiceBase
* @extends {ControlServiceBase}
*/
export class MultiEditViewPanelServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 面板部件服务基类
*
* @export
* @class PanelServiceBase
* @extends {ControlServiceBase}
*/
export class PanelServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 选择视图面板部件服务基类
*
* @export
* @class PickupViewPanelServiceBase
* @extends {ControlServiceBase}
*/
export class PickupViewPanelServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 门户部件服务基类
*
* @export
* @class PortletServiceBase
* @extends {ControlServiceBase}
*/
export class PortletServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { FormServiceBase } from './form-service-base';
/**
* 搜索表单部件服务基类
*
* @export
* @class SearchFormServiceBase
* @extends {ControlServiceBase}
*/
export class SearchFormServiceBase extends FormServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 分页导航部件服务基类
*
* @export
* @class TabExpServiceBase
* @extends {ControlServiceBase}
*/
export class TabExpServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
*分页视图面板部件服务基类
*
* @export
* @class TabViewPanelServiceBase
* @extends {ControlServiceBase}
*/
export class TabViewPanelServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 树视图导航栏部件服务基类
*
* @export
* @class TreeExpBarServiceBase
* @extends {ControlServiceBase}
*/
export class TreeExpBarServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 树部件服务基类
*
* @export
* @class TreeViewServiceBase
* @extends {ControlServiceBase}
*/
export class TreeViewServiceBase extends ControlServiceBase {
/**
* 默认节点分隔符
*
* @protected
* @type {string}
* @memberof TreeViewServiceBase
*/
protected TREENODE_SEPARATOR: string = ';';
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
/**
* 流程导航栏部件服务基类
*
* @export
* @class WFExpBarServiceBase
* @extends {ControlServiceBase}
*/
export class WFExpBarServiceBase extends ControlServiceBase {
}
\ No newline at end of file
import { ControlServiceBase } from './control-service-base';
import { Util, HttpResponse } from '../utils';
/**
* 向导面板部件服务基类
*
* @export
* @class WizardPanelServiceBase
* @extends {ControlServiceBase}
*/
export class WizardPanelServiceBase extends ControlServiceBase {
/**
* 初始化向导
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isLoading]
* @returns {Promise<HttpResponse>}
* @memberof WizardPanelServiceBase
*/
public async init(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
await this.onBeforeAction(action, context, data, isLoading);
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
response = await this.service.Create(context, data);
}
if (!response.isError()) {
response = this.handleResponse(action, response);
}
await this.onAfterAction(action, context, response);
return response;
}
/**
* 向导结束
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isLoading]
* @returns {Promise<HttpResponse>}
* @memberof WizardPanelServiceBase
*/
public async finish(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
await this.onBeforeAction(action, context, data, isLoading);
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
response = await this.service.Update(context, data);
}
if (!response.isError()) {
response = this.handleResponse(action, response);
}
await this.onAfterAction(action, context, response);
return response;
}
}
\ No newline at end of file
/**
* 计数器服务基类
*
* @export
* @class CounterServiceBase
*/
export class CounterServiceBase {
/**
* 当前计数器数据对象
*
* @memberof CounterServiceBase
*/
public counterData: any = {};
/**
* 定时器实例
*
* @type {*}
* @memberof CounterServiceBase
*/
public timer: any;
/**
* Creates an instance of CounterServiceBase.
* @memberof CounterServiceBase
*/
constructor() {
this.initCounterData();
this.timer = setInterval(() => {
this.fetchCounterData();
}, 60000);
}
/**
* 初始化计数器
*
* @protected
* @memberof CounterServiceBase
*/
protected initCounterData(): void {
this.fetchCounterData();
}
/**
* 查询数据
*
* @protected
* @returns {Promise<any>}
* @memberof CounterServiceBase
*/
protected async fetchCounterData(): Promise<any> {
for (let i: number = 0; i < 10; i++) {
this.counterData['item' + i] = Math.floor(Math.random() * 10);
}
}
/**
* 刷新数据
*
* @protected
* @returns {Promise<any>}
* @memberof CounterServiceBase
*/
protected refreshData(): Promise<any> {
return this.fetchCounterData();
}
/**
* 定时器销毁
*
* @memberof CounterServiceBase
*/
public destroy(): void {
if (this.timer) {
clearInterval(this.timer);
}
}
}
\ No newline at end of file
// 导出实体服务类
export { DBService } from './service/db-service';
export { EntityLogicBase } from './service/entity-logic-base';
export { EntityServiceBase } from './service/entity-service-base';
export { IndexedDBService } from './service/indexeddb-service';
// 导出部件服务
export { ControlServiceBase } from './control-service/control-service-base';
export { FormServiceBase } from './control-service/form-service-base';
export { GridServiceBase } from './control-service/grid-service-base';
export { MdServiceBase } from './control-service/md-service-base';
export { SearchFormServiceBase } from './control-service/search-form-service-base';
export { AppMenuServiceBase } from './control-service/app-menu-service-base';
export { TabExpServiceBase } from './control-service/tab-exp-service-base';
export { DashboardServiceBase } from './control-service/dashboard-service-base';
export { MultiEditViewPanelServiceBase } from './control-service/multi-edit-view-panel-service-base';
export { TabViewPanelServiceBase } from './control-service/tab-view-panel-service-base';
export { ListServiceBase } from './control-service/list-service-base';
export { WFExpBarServiceBase } from './control-service/wf-exp-bar-service-base';
export { PortletServiceBase } from './control-service/portlef-service-base';
export { DrBarServiceBase } from './control-service/dr-bar-service-base';
export { DrTabServiceBase } from './control-service/dr-tab-service-base';
export { TreeExpBarServiceBase } from './control-service/tree-exp-bar-service-base';
export { TreeViewServiceBase } from './control-service/tree-view-service-base';
export { DataViewServiceBase } from './control-service/data-view-service-base';
export { PickupViewPanelServiceBase } from './control-service/pickup-view-panel-service-base';
export { WizardPanelServiceBase } from './control-service/wizard-panel-service-base';
export { CalendarServiceBase } from './control-service/calendar-service-base';
export { ChartServiceBase } from './control-service/chart-service-base';
// 导出界面行为服务类
export { UILogicBase } from './ui-service/ui-logic-base';
export { WFUIActionBase } from './wf-ui-service/wf-ui-action-base';
// 导出代码表服务基类
export { CodeListBase } from './code-list/code-list-base';
// 导出计数器服务基类
export { CounterServiceBase } from './counter/counter-service-base';
// 导出第三方服务
export { ThirdPartyService } from './third-party-service/ThirdPartyService';
// 导入服务
import { appEntityServiceConstructor } from '@/app-core/service/app-entity-service-constructor';
import { counterServiceConstructor } from '@/app-core/counter/counter-service-constructor';
import { AppCommunicationsCenter } from './app-service/message-center/app-communications-center';
// 全局挂载应用实体服务构造器
window['appEntityServiceConstructor'] = appEntityServiceConstructor;
// 全局挂载计数器服务构造器
window['counterServiceConstructor'] = counterServiceConstructor;
// 全局挂载应用通讯中心
window['acc'] = AppCommunicationsCenter.getInstance();
/**
* 注册组件
*/
export const iBizCore = {
install(v: any, opt: any) {
}
};
\ No newline at end of file
import { IndexedDBService } from './indexeddb-service';
/**
* 数据对象基类 前端应用实体存储主键,统一为srfSessionKey
*
* @export
* @class DBService
*/
export class DBService {
/**
* 数据库实例
*
* @protected
* @type {IDBDatabase}
* @memberof DBService
*/
protected db!: IDBDatabase;
/**
* 实体名称
*
* @protected
* @type {string}
* @memberof DBService
*/
protected entityName: string = '';
/**
* 主键标识
*
* @protected
* @type {string}
* @memberof DBService
*/
protected primaryKey: string = 'srfsessionkey';
/**
* Creates an instance of DBService.
* @param {string} entityName
* @memberof DBService
*/
constructor(entityName: string) {
this.entityName = entityName;
this.init();
}
/**
* 初始化
*
* @protected
* @memberof DBService
*/
protected init(): void {
if (IndexedDBService.getInstance().getDB()) {
this.db = IndexedDBService.getInstance().getDB();
} else {
setTimeout(() => this.init(), 10);
}
}
/**
* 新增数据
*
* @param {*} params
* @returns {Promise<boolean>}
* @memberof DBService
*/
public create(params: any): Promise<boolean> {
return new Promise((resolve) => {
try {
const t = this.getTransaction();
const store = this.getStore(t);
store.add(params);
t.oncomplete = (e) => resolve(params);
t.onerror = () => resolve(false);
} catch (error) {
console.error(error);
}
});
}
/**
* 更新数据
*
* @param {*} data
* @returns {Promise<boolean>}
* @memberof DBService
*/
public update(data: any): Promise<boolean> {
return new Promise(async (resolve) => {
try {
const t = this.getTransaction();
const store = this.getStore(t);
const item: any = await this.get(data[this.primaryKey], t, store);
if (item) {
Object.assign(item, data);
}
store.put(item);
t.oncomplete = () => resolve(true);
t.onerror = () => resolve(false);
} catch (error) {
console.error(error);
}
});
}
/**
* 获取数据
*
* @param {string} val
* @returns {Promise<any>}
* @memberof DBService
*/
public get(val: string, t: IDBTransaction = this.getTransaction(), store: IDBObjectStore = this.getStore(t)): Promise<any> {
return new Promise((resolve) => {
try {
// const index = store.index(this.primaryKey);
// request = index.get(val);
const request = store.get(val);
request.onsuccess = (e: any) => resolve(e.target.result);
request.onerror = (e: any) => resolve(e.target.result);
} catch (error) {
console.error(error);
}
});
}
/**
* 根据索引查询数据
*
* @param {string} val 索引属性值
* @param {string} indexName 索引属性
* @param {IDBTransaction} [t=this.getTransaction()]
* @param {IDBObjectStore} [store=this.getStore(t)]
* @returns {Promise<any>}
* @memberof DBService
*/
public getByIndex(val: string, indexName: string, t: IDBTransaction = this.getTransaction(), store: IDBObjectStore = this.getStore(t)): Promise<any> {
return new Promise((resolve) => {
try {
const index = store.index(indexName);
const request = index.get(val);
request.onsuccess = (e: any) => {
const item: any = e.target.result;
resolve(item.data);
}
request.onerror = (e: any) => resolve(e.target.result);
} catch (error) {
console.error(error);
}
});
}
/**
* 删除数据
*
* @param {string} val
* @param {IDBTransaction} [t=this.getTransaction()]
* @param {IDBObjectStore} [store=this.getStore(t)]
* @returns {Promise<boolean>}
* @memberof DBService
*/
public remove(val: string, t: IDBTransaction = this.getTransaction(), store: IDBObjectStore = this.getStore(t)): Promise<boolean> {
return new Promise((resolve) => {
try {
store.delete(val);
t.oncomplete = () => resolve(true);
t.onerror = () => resolve(false);
} catch (error) {
console.error(error);
}
});
}
/**
* 设置数据
*
* @param {*} params
* @returns {Promise<boolean>}
* @memberof DBService
*/
public async set(data: any): Promise<boolean> {
try {
const t = this.getTransaction();
const store = this.getStore(t);
const result: any = await this.get(data[this.primaryKey], t, store);
if (result) {
await this.remove(data[this.primaryKey], t, store);
return this.create(data);
}
return this.create(data);
} catch (error) {
console.error(error);
return false;
}
}
/**
* 获取对应事务存储对象
*
* @protected
* @param {IDBTransaction} transaction
* @returns {IDBObjectStore}
* @memberof DBService
*/
protected getStore(transaction: IDBTransaction): IDBObjectStore {
return transaction.objectStore(this.entityName);
}
/**
* 获取事务
*
* @protected
* @returns {IDBTransaction}
* @memberof DBService
*/
protected getTransaction(): IDBTransaction {
return this.db.transaction(this.entityName, 'readwrite');
}
}
\ No newline at end of file
/**
* 实体逻辑处理基类
*
* @export
* @class EntityLogicBase
*/
export class EntityLogicBase {
/**
* 获取其他实体服务
*
* @protected
* @param {string} name 实体名称
* @returns {Promise<any>}
* @memberof EntityLogicBase
*/
protected getService(name: string): Promise<any> {
return window.appEntityServiceConstructor.getService(name);
}
}
\ No newline at end of file
此差异已折叠。
/**
* IndexedDB数据库服务基类
*
* @export
* @class IndexedDBServiceBase
*/
export class IndexedDBServiceBase {
/**
* indexedDB实例
*
* @protected
* @memberof IndexedDBServiceBase
*/
protected iDB!: IDBOpenDBRequest;
/**
* 数据库实例
*
* @protected
* @type {IDBDatabase}
* @memberof IndexedDBServiceBase
*/
protected db!: IDBDatabase;
/**
* 数据库名称
*
* @protected
* @type {string}
* @memberof IndexedDBServiceBase
*/
protected dbName: string = 'AppDatabase';
/**
* 实体配置
*
* @protected
* @type {{ name: string, keyPath: string, indexNames: string[] }[]}
* @memberof IndexedDBServiceBase
*/
protected entityConfigs: { name: string, keyPath: string, indexNames?: string[] }[] = [];
/**
* Creates an instance of IndexedDBServiceBase.
* @memberof IndexedDBServiceBase
*/
protected constructor(version: string) {
this.entityConfigInit();
if (new RegExp(/-[1-9]{1}-/).test(version)) {
version = version.substring(0, 5) + '0' + version.substring(5, version.length);
}
const data = new Date(version);
this.iDB = window.indexedDB.open(this.dbName, data.getTime());
this.iDB.onsuccess = () => this.openSuccess();
this.iDB.onerror = (e: any) => this.openError(e);
this.iDB.onupgradeneeded = (e: any) => {
this.upgradeneeded(e);
}
}
/**
* 实体配置初始化
*
* @protected
* @memberof IndexedDBServiceBase
*/
protected entityConfigInit(): void { }
/**
* 数据库打开成功
*
* @protected
* @param {Event} e
* @memberof IndexedDBServiceBase
*/
protected openSuccess(): void {
this.db = this.iDB.result;
}
/**
* 数据库打开失败
*
* @protected
* @param {Event} e
* @memberof IndexedDBServiceBase
*/
protected openError(e: Event): void {
console.error('indexedDB打开失败', e);
}
/**
* 数据库升级成功
*
* @protected
* @param {Event} e
* @memberof IndexedDBServiceBase
*/
protected upgradeneeded(e: any): void {
const db: IDBDatabase = e.target.result;
this.createObjectStore(db);
}
/**
* 创建表
*
* @protected
* @param {IDBDatabase} db
* @memberof IndexedDBServiceBase
*/
protected createObjectStore(db: IDBDatabase): void {
this.entityConfigs.forEach((item) => {
if (!db.objectStoreNames.contains(item.name)) {
const store = db.createObjectStore(item.name, { keyPath: item.keyPath });
this.createIndex(store);
}
});
}
/**
* 建立索引
*
* @protected
* @param {IDBObjectStore} store
* @memberof IndexedDBServiceBase
*/
protected createIndex(store: IDBObjectStore): void { }
/**
* 删除数据库
*
* @memberof IndexedDBServiceBase
*/
public deleteDB(): void {
indexedDB.deleteDatabase(this.dbName);
}
/**
* 关闭数据库
*
* @memberof IndexedDBServiceBase
*/
public closeDB(): void {
this.db.close();
}
/**
* 获取数据库实例
*
* @returns {IDBDatabase}
* @memberof IndexedDBServiceBase
*/
public getDB(): IDBDatabase {
return this.db;
}
}
\ No newline at end of file
/**
* 应用实体服务
*
* @export
* @class ServiceConstructorBase
*/
export class ServiceConstructorBase {
/**
* 所有实体服务
*
* @protected
* @type {*}
* @memberof ServiceConstructorBase
*/
protected allService: Map<string, () => Promise<any>> = new Map();
/**
* 已加载服务缓存
*
* @protected
* @type {Map<string, any>}
* @memberof ServiceConstructorBase
*/
protected serviceCache: Map<string, any> = new Map();
/**
* Creates an instance of ServiceConstructorBase.
* @memberof ServiceConstructorBase
*/
constructor() {
this.init();
}
/**
* 初始化
*
* @protected
* @memberof ServiceConstructorBase
*/
protected init(): void { }
/**
* 加载服务实体
*
* @protected
* @param {string} serviceName
* @returns {Promise<any>}
* @memberof ServiceConstructorBase
*/
protected async loadService(serviceName: string): Promise<any> {
const service = this.allService.get(serviceName);
if (service) {
return await service();
}
}
/**
* 获取应用实体服务
*
* @param {string} name
* @returns {Promise<any>}
* @memberof ServiceConstructorBase
*/
public async getService(name: string): Promise<any> {
if (this.serviceCache.has(name)) {
return this.serviceCache.get(name);
}
const entityService: any = await this.loadService(name);
if (entityService && entityService.default) {
const instance: any = new entityService.default();
this.serviceCache.set(name, instance);
return instance;
}
}
/**
* 销毁已激活的服务
*
* @param {string} name 服务存储名称
* @memberof ServiceConstructorBase
*/
public destroyService(name: string): void {
if (name && this.allService.has(name)) {
const item: any = this.allService.get(name);
if (item && item.destroy) {
item.destroy();
}
this.allService.delete(name);
}
}
}
\ No newline at end of file
import axios from 'axios';
import * as dd from 'dingtalk-jsapi';
/**
* 钉钉服务
*
* @export
* @class DingTalkService
*/
export class DingTalkService {
/**
* 唯一实例
*
* @private
* @static
* @memberof DingTalkService
*/
private static readonly instance = new DingTalkService();
/**
* 用户信息缓存key
*
* @private
* @type {string}
* @memberof DingTalkService
*/
private readonly infoName: string = "UserInfo";
/**
* 企业corpId
*
* @private
* @type {string}
* @memberof WeChatService
*/
private readonly appId: string = "dingf89eefecd565b89cbc961a6cb783455b";
/**
* 钉钉sdk
*
* @memberof DingTalkService
*/
public readonly dd = dd;
/**
* 钉钉是否已经初始化
*
* @private
* @type {boolean}
* @memberof DingTalkService
*/
private $isInit: boolean = false;
/**
* 是否已经初始化
*
* @type {boolean}
* @memberof DingTalkService
*/
public get isInit(): boolean {
return this.$isInit;
}
/**
* Creates an instance of DingTalkService.
* @memberof DingTalkService
*/
private constructor() {
if (DingTalkService.instance) {
return DingTalkService.instance;
}
const info: string = window.navigator.userAgent.toUpperCase();
if (info.indexOf('DINGTALK') !== -1) {
dd.ready(() => {
this.$isInit = true;
});
dd.error((err: any) => {
alert(`dd加载错误:${JSON.stringify(err)}`);
});
}
}
/**
* 钉钉登录
*
* @returns {Promise<any>} 返回用户信息
* @memberof DingTalkService
*/
public async login(): Promise<any> {
const data = await this.getUserInfo();
if (!data || !data.value || Object.is(data.value, '')) {
// 获取临时登录授权码
const res: { code: string } = await dd.runtime.permission.requestAuthCode({ corpId: this.appId });
if (res && res.code) {
const userInfo = await this.get(`./dingtalk/login?code=${res.code}`);
dd.util.domainStorage.setItem({ name: this.infoName, value: userInfo });
data.value = userInfo;
}
}
return data.value;
}
/**
* 清楚登录用户信息
*
* @memberof DingTalkService
*/
public clearUserInfo(): void {
dd.util.domainStorage.removeItem({ name: this.infoName });
}
/**
* 获取用户信息
*
* @returns {Promise<any>}
* @memberof DingTalkService
*/
public getUserInfo(): Promise<any> {
return dd.util.domainStorage.getItem({ name: this.infoName });
}
/**
* 请求(需要替换为项目)
*
* @private
* @param {string} url
* @returns {Promise<any>}
* @memberof DingTalkService
*/
private async get(url: string): Promise<any> {
return new Promise((resolve) => {
axios.get(url).then((response: any) => {
resolve(response.data);
}).catch((error: any) => {
console.log('请求异常');
});
})
}
/**
* 获取实例
*
* @static
* @returns {DingTalkService}
* @memberof DingTalkService
*/
public static getInstance(): DingTalkService {
return DingTalkService.instance;
}
}
import { DingTalkService } from './DingTalkService';
import { WeChatService } from './WeChatService';
/**
* 第三方服务
*
* @export
* @class ThirdPartyService
*/
export class ThirdPartyService {
/**
* 唯一实例
*
* @private
* @static
* @type {ThirdPartyService}
* @memberof ThirdPartyService
*/
private static readonly instance: ThirdPartyService = new ThirdPartyService();
/**
* 当前搭载平台
*
* @protected
* @type {('WeChat' | 'DingTalk' | null)}
* @memberof ThirdPartyService
*/
protected platform: 'WeChat' | 'DingTalk' | null = null;
/**
* 钉钉服务
*
* @type {DingTalkService}
* @memberof ThirdPartyService
*/
public dd: DingTalkService = DingTalkService.getInstance();
/**
* 企业微信服务
*
* @type {WeChatService}
* @memberof ThirdPartyService
*/
public weChat: WeChatService = WeChatService.getInstance();
/**
* 是否已经初始化
*
* @readonly
* @type {boolean}
* @memberof ThirdPartyService
*/
public get isInit(): boolean {
return this.dd.isInit || this.weChat.isInit;
}
/**
* Creates an instance of ThirdPartyService.
* @memberof ThirdPartyService
*/
private constructor() {
if (ThirdPartyService.instance) {
return ThirdPartyService.instance;
}
const info: string = window.navigator.userAgent.toUpperCase();
if (info.indexOf('DINGTALK') !== -1) {
this.platform = 'DingTalk';
} else if (info.indexOf('WXWORK') !== -1) {
this.platform = 'WeChat';
}
}
/**
* 登录
*
* @returns {Promise<any>}
* @memberof ThirdPartyService
*/
public async login(): Promise<any> {
if (this.isDingTalk()) {
return this.dd.login();
} else if (this.isWeChat()) {
return this.weChat.login();
}
}
/**
* 清楚登录用户信息
*
* @memberof WeChatService
*/
public clearUserInfo(): void {
if (this.isDingTalk()) {
this.dd.clearUserInfo();
} else if (this.isWeChat()) {
this.weChat.clearUserInfo();
}
}
/**
* 获取用户信息
*
* @returns {*}
* @memberof WeChatService
*/
public async getUserInfo(): Promise<any> {
if (this.isDingTalk()) {
return this.dd.getUserInfo();
} else if (this.isWeChat()) {
return this.weChat.getUserInfo();
}
}
/**
* 是否为钉钉平台
*
* @returns {boolean}
* @memberof ThirdPartyService
*/
public isDingTalk(): boolean {
return Object.is(this.platform, 'DingTalk');
}
/**
* 是否为微信平台
*
* @returns {boolean}
* @memberof ThirdPartyService
*/
public isWeChat():boolean {
return Object.is(this.platform, 'WeChat');
}
/**
* 获取实例
*
* @static
* @returns {ThirdPartyService}
* @memberof ThirdPartyService
*/
public static getInstance(): ThirdPartyService {
return ThirdPartyService.instance;
}
}
\ No newline at end of file
import axios from 'axios';
/**
* 惬意微信服务
*
* @export
* @class WeChatService
*/
export class WeChatService {
/**
* 唯一实例
*
* @private
* @static
* @type {WeChatService}
* @memberof WeChatService
*/
private static readonly instance: WeChatService = new WeChatService();
/**
* 用户信息缓存key
*
* @private
* @type {string}
* @memberof WeChatService
*/
private readonly infoName: string = "UserInfo";
/**
* 企业corpId
*
* @private
* @type {string}
* @memberof WeChatService
*/
private readonly appId: string = "ww41b9cbca11ed5dbb";
/**
* 微信SDK
*
* @protected
* @type {*}
* @memberof WeChatService
*/
protected wx: any = null;
/**
* 是否初始化
*
* @protected
* @type {boolean}
* @memberof WeChatService
*/
protected $isInit: boolean = false;
public get isInit(): boolean {
return this.$isInit;
}
/**
* Creates an instance of WeChatService.
* @memberof WeChatService
*/
private constructor() {
if (WeChatService.instance) {
return WeChatService.instance;
}
this.init();
}
/**
* 初始化
*
* @protected
* @returns {Promise<void>}
* @memberof WeChatService
*/
protected async init(): Promise<void> {
const info: string = window.navigator.userAgent.toUpperCase();
if (info.indexOf('WXWORK') !== -1) {
// 企业微信js-sdk相关,暂未用到注释
// const win: any = window;
// this.wx = win.wx;
// if (this.wx) {
// const data: any = await this.get('./wechat/config?url=' + encodeURIComponent(window.location.origin));
// if (data) {
// const config = {
// beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
// appId: data.appid, // 必填,企业微信的corpID
// timestamp: data.timestamp, // 必填,生成签名的时间戳
// nonceStr: data.nonceStr, // 必填,生成签名的随机串
// signature: data.signature,// 必填,签名,见 附录-JS-SDK使用权限签名算法
// jsApiList: [] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
// }
// this.wx.config(config);
// this.wx.ready(() => {
// this.$isInit = true;
// alert('微信初始化成功');
// });
// this.wx.error((res: any) => {
// // alert('微信信息初始化失败!---' + JSON.stringify(res));
// });
// }
// }
this.$isInit = true;
}
}
/**
* 登录
*
* @returns {Promise<any>}
* @memberof WeChatService
*/
public async login(): Promise<any> {
let userInfo = this.getUserInfo();
if (!userInfo) {
const code = this.getQueryValue1('code');
if (code && !Object.is(code, '')) {
const res = await this.get(`./wechat/login?code=${code}`);
if (res) {
window.localStorage.setItem(this.infoName, res);
userInfo = res;
}
} else {
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.appId}&redirect_uri=${encodeURIComponent(window.location.href)}&response_type=code&scope=snsapi_base&state==#wechat_redirect`;
}
}
return userInfo;
}
/**
* 清楚登录用户信息
*
* @memberof WeChatService
*/
public clearUserInfo(): void {
window.localStorage.removeItem(this.infoName);
}
/**
* 获取用户信息
*
* @returns {*}
* @memberof WeChatService
*/
public getUserInfo(): any {
return window.localStorage.getItem(this.infoName);
}
/**
* 获取url参数
*
* @private
* @param {string} queryName
* @returns
* @memberof WeChatService
*/
private getQueryValue1(queryName: string) {
var reg = new RegExp("(^|&)" + queryName + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return decodeURI(r[2]);
} else {
return null;
}
}
/**
* 请求(需要替换为项目)
*
* @private
* @param {string} url
* @returns {Promise<any>}
* @memberof DingTalkService
*/
private async get(url: string): Promise<any> {
return new Promise((resolve) => {
axios.get(url).then((response: any) => {
resolve(response.data);
}).catch((error: any) => {
console.log('请求异常');
});
})
}
/**
* 获取实例
*
* @static
* @returns {WeChatService}
* @memberof WeChatService
*/
public static getInstance(): WeChatService {
return WeChatService.instance;
}
}
\ No newline at end of file
import { AppEntityServiceConstructor } from '@/app-core/service/app-entity-service-constructor';
import { CounterServiceConstructor } from '@/app-core/counter/counter-service-constructor';
import { AppCommunicationsCenter } from '../app-service/message-center/app-communications-center';
declare global {
interface Window {
appEntityServiceConstructor: AppEntityServiceConstructor,
counterServiceConstructor: CounterServiceConstructor,
acc: AppCommunicationsCenter
}
}
\ No newline at end of file
/**
* 界面逻辑处理服务基类
*
* @export
* @class UILogicBase
*/
export class UILogicBase {
}
\ No newline at end of file
import Vue from 'vue';
const isServer = Vue.prototype.$isServer;
/* istanbul ignore next */
export const on = (function() {
if (!isServer && document.addEventListener) {
return function(element: any, event: any, handler: any) {
if (element && event && handler) {
element.addEventListener(event, handler, false);
}
};
} else {
return function(element: any, event: any, handler: any) {
if (element && event && handler) {
element.attachEvent('on' + event, handler);
}
};
}
})();
/* istanbul ignore next */
export const off = (function() {
if (!isServer && document.removeEventListener) {
return function(element: any, event: any, handler: any) {
if (element && event) {
element.removeEventListener(event, handler, false);
}
};
} else {
return function(element: any, event: any, handler: any) {
if (element && event) {
element.detachEvent('on' + event, handler);
}
};
}
})();
/* istanbul ignore next */
export function hasClass(el: Element | HTMLElement, cls: string) {
if (!el || !cls) return false;
if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
if (el.classList) {
return el.classList.contains(cls);
} else {
return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
}
}
/* istanbul ignore next */
export function addClass(el: Element | HTMLElement, cls: string) {
if (!el) return;
let curClass = el.className;
const classes = (cls || '').split(' ');
for (let i = 0, j = classes.length; i < j; i++) {
const clsName = classes[i];
if (!clsName) continue;
if (el.classList) {
el.classList.add(clsName);
} else {
if (!hasClass(el, clsName)) {
curClass += ' ' + clsName;
}
}
}
if (!el.classList) {
el.className = curClass;
}
}
/* istanbul ignore next */
export function removeClass(el: Element | HTMLElement, cls: string) {
if (!el || !cls) return;
const classes = cls.split(' ');
let curClass = ' ' + el.className + ' ';
for (let i = 0, j = classes.length; i < j; i++) {
const clsName = classes[i];
if (!clsName) continue;
if (el.classList) {
el.classList.remove(clsName);
} else {
if (hasClass(el, clsName)) {
curClass = curClass.replace(' ' + clsName + ' ', ' ');
}
}
}
if (!el.classList) {
el.className = trim(curClass);
}
}
/* istanbul ignore next */
const trim = function(str: string) {
return (str || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
};
\ No newline at end of file
/**
* Http请求状态文本信息
*/
export const StatusMessage = {
200: '服务器成功返回请求的数据。',
201: '新建或修改数据成功。',
202: '一个请求已经进入后台排队(异步任务)。',
204: '删除数据成功。',
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
401: '用户没有权限(令牌、用户名、密码错误)。',
403: '用户得到授权,但是访问是被禁止的。',
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
406: '请求的格式不可得。',
410: '请求的资源被永久删除,且不会再得到的。',
422: '当创建一个对象时,发生一个验证错误。',
500: '服务器发生错误,请检查服务器。',
502: '网关错误。',
503: '服务不可用,服务器暂时过载或维护。',
504: '网关超时。',
};
/**
* 请求错误状态码文本
*/
export const ErrorMessage = {
100: '未知',
101: '请求发生错误',
5001: '数据不存在',
5002: '数据已存在,无法重复创建',
5003: '新建失败',
5004: '数据不存在,无法保存',
5005: '数据删除失败'
};
\ No newline at end of file
import { StatusMessage, ErrorMessage } from "./http-constant";
/**
* Http请求返回
*
* @export
* @class HttpResponse
*/
export class HttpResponse {
/**
* 状态
*
* @type {(200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 406 | 410 | 422 | 500 | 502 | 503 | 504)}
* @memberof HttpResponse
*/
public readonly status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 406 | 410 | 422 | 500 | 502 | 503 | 504;
/**
* 请求头
*
* @type {*}
* @memberof HttpResponse
*/
public readonly headers: any;
/**
* 状态码对应文本消息
*
* @protected
* @static
* @memberof HttpResponse
*/
protected static readonly statusMessage: any = StatusMessage;
/**
* 数据
*
* @type {*}
* @memberof HttpResponse
*/
public readonly data?: any;
/**
* 错误内容
*
* @type {{ code: HttpResponse['$errorCode'], message?: string }}
* @memberof HttpResponse
*/
public readonly error?: { code: HttpResponse['$errorCode'], message?: string } | null = null;
/**
* 错误码
*
* @protected
* @type {(-1 | 100 | 101 | 5001 | 5002 | 5003 | 5004 | 5005)} 100为通用错误码,需自定义错误消息内容。101为http请求通用错误码。
* @memberof HttpResponse
*/
protected $errorCode: -1 | 100 | 101 | 5001 | 5002 | 5003 | 5004 | 5005 = -1;
/**
* 错误状态码对应信息
*
* @protected
* @static
* @memberof HttpResponse
*/
protected static readonly errorMessage: any = ErrorMessage;
/**
* Creates an instance of HttpResponse.
* @param {HttpResponse['status']} status
* @param {HttpResponse['data']} [data=null]
* @param {HttpResponse['error']} [error=null]
* @param {*} [headers]
* @memberof HttpResponse
*/
constructor(status: HttpResponse['status'], data: HttpResponse['data'] = null, error: HttpResponse['error'] = null, headers?: any) {
this.status = status;
this.data = data;
this.error = error;
if (!this.error && this.status !== 200 && this.status !== 201 && this.status !== 204) {
this.error = { code: 101 };
}
if (this.error && !this.error.message) {
if (this.error.code === 101) {
this.error.message = HttpResponse.getStatusMessage(this.status);
} else {
this.error.message = HttpResponse.getErrorMessage(this.error.code);
}
}
this.headers = headers;
}
/**
* 获取状态码文本值
*
* @param {HttpResponse['$status']} status
* @returns {string}
* @memberof HttpResponse
*/
public static getStatusMessage(status: HttpResponse['status']): string {
return this.statusMessage[status];
}
/**
* 获取错误码文本值
*
* @param {HttpResponse['$errorCode']} code
* @returns {string}
* @memberof HttpResponse
*/
public static getErrorMessage(code: HttpResponse['$errorCode']): string {
return this.errorMessage[code];
}
/**
* 是否错误
*
* @returns {boolean}
* @memberof HttpResponse
*/
public isError(): boolean {
return this.error ? true : false;
}
}
\ No newline at end of file
import axios, { AxiosResponse } from 'axios';
import qs from 'qs';
import { HttpResponse } from './http-response';
import { Util } from '../util/util';
/**
* Http net 对象
* 调用 getInstance() 获取实例
*
* @class Http
*/
export class Http {
/**
* 唯一实例
*
* @private
* @static
* @type {Http}
* @memberof Http
*/
private static readonly instance: Http = new Http();
/**
* Creates an instance of Http.
* 私有构造,拒绝通过 new 创建对象
*
* @memberof Http
*/
constructor() {
if (Http.instance) {
return Http.instance;
}
}
/**
* 获取
*
* @param {string} url
* @param {*} [params]
* @returns {Promise<any>}
* @memberof Http
*/
public get(url: string, params?: any): Promise<any> {
if (params) {
params = this.handleRequestData(params);
if ((Object.keys(params)).length > 0) {
let tempParam: any = {};
let sort: any = null;
Object.keys(params).forEach((item: any) => {
if (params[item] || Object.is(params[item], 0)) {
if (Object.is(item, 'sort')) {
sort = params[item];
} else {
tempParam[item] = params[item];
}
}
})
url += `?${qs.stringify(tempParam)}`;
if (sort) {
url += '&sort=' + sort;
}
}
}
return new Promise((resolve: any, reject: any) => {
axios.get(url).then((response: AxiosResponse) => {
resolve(this.handelResponseResult(response));
}).catch((response: AxiosResponse) => {
reject(this.handelResponseResult(response));
});
});
}
/**
* 删除
*
* @param {string} url
* @returns {Promise<any>}
* @memberof Http
*/
public delete(url: string): Promise<any> {
return new Promise((resolve: any, reject: any) => {
axios.delete(url).then((response: AxiosResponse) => {
resolve(this.handelResponseResult(response));
}).catch((response: AxiosResponse) => {
reject(this.handelResponseResult(response));
});
});
}
/**
*
*
* @param {string} url
* @returns {Promise<any>}
* @memberof Http
*/
public head(url: string): Promise<any> {
return new Promise((resolve: any, reject: any) => {
axios.head(url).then((response: AxiosResponse) => {
resolve(this.handelResponseResult(response));
}).catch((response: AxiosResponse) => {
reject(this.handelResponseResult(response));
});
});
}
/**
*
*
* @param {string} url
* @returns {Promise<any>}
* @memberof Http
*/
public options(url: string): Promise<any> {
return new Promise((resolve: any, reject: any) => {
axios.options(url).then((response: AxiosResponse) => {
resolve(this.handelResponseResult(response));
}).catch((response: AxiosResponse) => {
reject(this.handelResponseResult(response));
});
});
}
/**
* post请求
*
* @param {string} url
* @param {*} [data]
* @returns {Promise<any>}
* @memberof Http
*/
public post(url: string, data?: any): Promise<any> {
if (data) {
data = this.handleRequestData(data);
}
return new Promise((resolve: any, reject: any) => {
axios.post(url,
data,
{ headers: { 'Content-Type': 'application/json;charset=UTF-8', 'Accept': 'application/json' } }
).then((response: AxiosResponse) => {
resolve(this.handelResponseResult(response));
}).catch((response: AxiosResponse) => {
reject(this.handelResponseResult(response));
});
});
}
/**
* 修改数据
*
* @param {string} url
* @param {*} data
* @returns {Promise<any>}
* @memberof Http
*/
public put(url: string, data: any): Promise<any> {
if (data) {
data = this.handleRequestData(data);
}
return new Promise((resolve: any, reject: any) => {
axios.put(url, data).then((response: AxiosResponse) => {
resolve(this.handelResponseResult(response));
}).catch((response: AxiosResponse) => {
reject(this.handelResponseResult(response));
});
});
}
/**
* 修改数据
*
* @param {string} url
* @param {*} data
* @returns {Promise<any>}
* @memberof Http
*/
public patch(url: string, data: any): Promise<any> {
if (data) {
data = this.handleRequestData(data);
}
return new Promise((resolve: any, reject: any) => {
axios.patch(url, data).then((response: AxiosResponse) => {
resolve(this.handelResponseResult(response));
}).catch((response: AxiosResponse) => {
reject(this.handelResponseResult(response));
});
});
}
/**
* 处理响应结果
*
* @private
* @param {*} response
* @memberof Http
*/
private handelResponseResult(response: any): HttpResponse {
if (response) {
if (response.status === 200) {
return new HttpResponse(200, response.data, undefined, response.headers);
}
return new HttpResponse(response.status, response.data, { code: 101, message: HttpResponse.getStatusMessage(response.status) }, response.headers)
}
return new HttpResponse(500, null, { code: 100, message: '请求发生异常,无返回结果!' }, response.headers);
}
/**
* 处理请求数据
*
* @private
* @param data
* @memberof Http
*/
private handleRequestData(data: any) {
data = Util.deepCopy(data);
if (data.srfsessionkey) {
delete data.srfsessionkey;
}
if (data.srfsessionid) {
delete data.srfsessionid;
}
return data;
}
/**
* 获取 Http 单例对象
*
* @static
* @returns {Http}
* @memberof Http
*/
public static getInstance(): Http {
return this.instance;
}
}
\ No newline at end of file
export { Util } from './util/util';
export { Verify } from './verify/verify';
export { XMLWriter } from './xml-writer/xml-writer';
export { Http } from './http/http';
export { Loading } from './loading/loading';
export { HttpResponse } from './http/http-response';
\ No newline at end of file
/**
* 全局加载动画工具类
*
* @export
* @class Loading
*/
export class Loading {
/**
* 加载个数计数
*
* @protected
* @type {number}
* @memberof DragDesignBase
*/
protected static loadingCount: number = 0;
/**
* 显示加载动画
*
* @static
* @param {string} [message='加载中']
* @memberof Loading
*/
public static show(message: string = '加载中'): void {
if (this.loadingCount === 0) {
console.warn('需自行实现加载动画开启功能');
}
this.loadingCount++;
}
/**
* 隐藏加载动画
*
* @memberof DragDesignBase
*/
public static hidden(): void {
this.loadingCount--;
if (this.loadingCount < 0) {
this.loadingCount = 0;
}
if (this.loadingCount === 0) {
setTimeout(() => {
console.warn('需自行实现加载动画关闭功能');
}, 50);
}
}
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
/**
* 工作流界面行为服务基类
*
* @export
* @class WFUIActionBase
*/
export class WFUIActionBase {
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册