1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import { Store } from 'vuex';
/**
* 功能服务基类
*
* @export
* @class UtilService
*/
export default class UtilService {
/**
* Vue 状态管理器
*
* @private
* @type {(any | null)}
* @memberof UtilService
*/
private $store: Store<any> | null = null;
/**
* 模型标识属性
*
* @memberof UtilService
*/
protected modelIdField: string = "";
/**
* 模型存储属性
*
* @memberof UtilService
*/
protected modelField: string = "";
/**
* 应用标识属性
*
* @memberof UtilService
*/
protected appIdField: string = "";
/**
* 用户标识属性
*
* @memberof UtilService
*/
protected userIdField: string = "";
/**
* 存储实体Name
*
* @memberof UtilService
*/
protected stoageEntityName:string ="";
/**
* 存储实体Id
*
* @memberof UtilService
*/
protected stoageEntityKey:string ="";
/**
* Creates an instance of UtilService.
*
* @param {*} [opts={}]
* @memberof UtilService
*/
constructor(opts: any = {}) {
this.$store = opts.$store;
this.initBasicParam();
}
/**
* 获取状态管理器
*
* @returns {(any | null)}
* @memberof UtilService
*/
public getStore(): Store<any> | null {
return this.$store;
}
/**
* 初始化基础参数
*
* @returns {(any | null)}
* @memberof UtilService
*/
public initBasicParam(){
console.log("UtilService初始化参数未实现");
}
/**
* 获取功能服务
*
* @protected
* @param {string} name 功能实体名称
* @returns {Promise<any>}
* @memberof UtilService
*/
public getService(name: string): Promise<any> {
return (window as any)['utilServiceRegister'].getService(name);
}
/**
* 处理请求参数
*
* @param context 应用上下文
* @param data 传入模型数据
* @param isloading 是否加载
* @memberof UtilService
*/
protected handlePreParam(context:any,data:any ={}){
let tempContext:Object = {};
let tempData:Object = {};
if(context.modelid){
Object.defineProperty(tempContext,this.modelIdField,{
value: context.modelid,
writable: true,
enumerable: true,
configurable: true
});
Object.defineProperty(tempContext,this.stoageEntityName,{
value: context.modelid,
writable: true,
enumerable: true,
configurable: true
});
Object.defineProperty(tempData,this.modelIdField,{
value: context.modelid,
writable: true,
enumerable: true,
configurable: true
});
Object.defineProperty(tempData,this.stoageEntityKey,{
value: context.modelid,
writable: true,
enumerable: true,
configurable: true
});
}
Object.defineProperty(tempData,this.modelField,{
value: data,
writable: true,
enumerable: true,
configurable: true
});
return {context:tempContext,data:tempData};
}
/**
* 获取模型数据
*
* @param context 应用上下文
* @param data 传入模型数据
* @param isloading 是否加载
* @memberof UtilService
*/
protected loadModelData(context: any = {},data: any = {}, isloading?: boolean):Promise<any>{
return Promise.resolve(null);
}
/**
* 保存模型数据
*
* @param context 应用上下文
* @param data 传入模型数据
* @param isloading 是否加载
* @memberof UtilService
*/
protected saveModelData(context: any = {},data: any = {}, isloading?: boolean):Promise<any>{
return Promise.resolve(null);
}
}