提交 d04cdb6e 编写于 作者: tony001's avatar tony001

调整服务基类

上级 16103e93
import { Store } from 'vuex';
/**
* 计数器服务基类
*
......@@ -8,15 +6,6 @@ import { Store } from 'vuex';
*/
export class CounterService {
/**
* Vue 状态管理器
*
* @private
* @type {(any | null)}
* @memberof CounterService
*/
private $store: Store<any> | null = null;
/**
* Creates an instance of CounterService.
*
......@@ -24,17 +13,7 @@ export class CounterService {
* @memberof CounterService
*/
constructor(opts: any = {}) {
this.$store = opts.$store;
}
/**
* 获取状态管理器
*
* @returns {(any | null)}
* @memberof CounterService
*/
public getStore(): Store<any> | null {
return this.$store;
}
/**
......@@ -46,7 +25,7 @@ export class CounterService {
* @memberof CounterService
*/
public getService(name: string): Promise<any> {
return (window as any)['counterServiceRegister'].getService(name);
return window.counterServiceConstructor.getService(name);
}
......
import { Store } from 'vuex';
import { Http } from '../utils';
import { CodeListService } from "@/ibiz-core";
......@@ -10,15 +9,6 @@ import { CodeListService } from "@/ibiz-core";
*/
export class EntityService {
/**
* Vue 状态管理器
*
* @private
* @type {(any | null)}
* @memberof EntityService
*/
private $store: Store<any> | null = null;
/**
* 获取实体数据服务
*
......@@ -101,31 +91,20 @@ export class EntityService {
* @memberof EntityService
*/
constructor(opts: any = {}) {
this.$store = opts.$store;
this.tempStorage = localStorage;
this.initBasicData();
}
/**
* 获取状态管理器
*
* @returns {(any | null)}
* @memberof EntityService
*/
public getStore(): Store<any> | null {
return this.$store;
}
/**
* 获取代码表
*
* @memberof EntityService
*/
public getCodeList(tag:string,codelistType:string,context:any = {},param:any ={}){
public getCodeList(tag:string,codelistType:string,context:any = {},param:any ={},store:any){
return new Promise((resolve:any,reject:any) =>{
if(tag && Object.is(codelistType,"STATIC")){
let returnItems:Array<any> = [];
const codelist = (this.getStore() as Store<any>).getters.getCodeList(tag);
const codelist = store.getters.getCodeList(tag);
if (codelist) {
returnItems = [...JSON.parse(JSON.stringify(codelist.items))];
} else {
......@@ -133,7 +112,7 @@ export class EntityService {
}
resolve(returnItems);
}else if(tag && Object.is(codelistType,"DYNAMIC")){
let codeListService = new CodeListService({ $store: this.$store });
let codeListService = new CodeListService({ $store: store });
codeListService.getItems(tag,context,param).then((res:any) => {
resolve(res);
}).catch((error:any) => {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册