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

调整服务基类

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