Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7-Res
提交
b4112668
提交
b4112668
编写于
7月 23, 2020
作者:
tony001
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整数据服务基类
上级
9c309f51
变更
2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
775 行增加
和
555 行删除
+775
-555
entity-service-base.ts
src/ibiz-core/service/entity-service-base.ts
+623
-426
http.ts
src/ibiz-core/utils/http/http.ts
+152
-129
未找到文件。
src/ibiz-core/service/entity-service-base.ts
浏览文件 @
b4112668
import
{
Http
,
Util
,
HttpResponse
}
from
'../utils'
;
import
{
Store
}
from
'vuex'
;
import
{
DBService
}
from
'./db-service'
;
import
{
Http
}
from
'../utils'
;
import
CodeListService
from
"@service/app/codelist-service"
;
/**
/**
* 实体服务基类
* 实体服务基类
*
*
* @export
* @export
* @class EntityService
Base
* @class EntityService
*/
*/
export
class
EntityServiceBas
e
{
export
default
class
EntityServic
e
{
/**
/**
*
实体本地数据库
*
Vue 状态管理器
*
*
* @pr
otected
* @pr
ivate
* @type {
DBService
}
* @type {
(any | null)
}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
pr
otected
db
:
DBService
;
pr
ivate
$store
:
Store
<
any
>
|
null
=
null
;
/**
/**
*
http请求工具实例
*
获取实体数据服务
*
*
* @protected
* @protected
* @type {Http}
* @param {string} name 实体名称
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
protected
http
:
Http
=
Http
.
getInstance
();
public
getService
(
name
:
string
):
Promise
<
any
>
{
return
(
window
as
any
)[
'entityServiceRegister'
].
getService
(
name
);
}
/**
/**
*
所有从实体
*
零时储存,localStorage指向
*
*
* @p
rotected
* @p
ublic
* @type {
*
}
* @type {
(string)
}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
p
rotected
allMinorAppEntity
:
any
=
{}
;
p
ublic
tempStorage
:
any
;
/**
/**
* 当前
实体主键
标识
* 当前
DE
标识
*
*
* @p
rotected
* @p
ublic
* @type {(string)}
* @type {(string)}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
p
rotected
readonly
key
:
string
=
''
;
p
ublic
APPDEKEY
:
string
=
''
;
/**
/**
* 当前
实体名称
* 当前
APPDE标识
*
*
* @p
rotected
* @p
ublic
* @type {(string)}
* @type {(string)}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
p
rotected
readonly
dePath
:
string
=
''
;
p
ublic
APPLYDEKEY
:
string
=
''
;
/**
/**
*
实体名称
*
当前NAME
*
*
* @p
rotected
* @p
ublic
* @type {
string
}
* @type {
(string)
}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
p
rotected
readonly
deName
:
string
;
p
ublic
APPDENAME
:
string
=
''
;
/**
/**
* 当前
实体主信息标识
* 当前
主信息名
*
*
* @p
rotected
* @p
ublic
* @type {(string)}
* @type {(string)}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
p
rotected
readonly
text
:
string
=
''
;
p
ublic
APPDETEXT
:
string
=
''
;
/**
/**
*
请求根路径
*
当前系统名
*
*
* @p
rotected
* @p
ublic
* @type {
string
}
* @type {
(string)
}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
p
rotected
readonly
rootUrl
:
string
=
''
;
p
ublic
SYSTEMNAME
:
string
=
''
;
/**
/**
* 当前应用名
* 当前应用名
*
*
* @p
rotected
* @p
ublic
* @type {
string
}
* @type {
(string)
}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
p
rotected
readonly
appName
:
string
=
''
;
p
ublic
APPNAME
:
string
=
''
;
/**
/**
*
当前系统名
*
Creates an instance of EntityService.
*
*
* @protected
* @param {*} [opts={}]
* @type {string}
* @memberof EntityService
* @memberof EntityServiceBase
*/
*/
protected
readonly
systemName
:
string
=
''
;
constructor
(
opts
:
any
=
{})
{
this
.
$store
=
opts
.
$store
;
this
.
tempStorage
=
localStorage
;
this
.
initBasicData
();
}
/**
/**
* Creates an instance of EntityServiceBase.
* 获取状态管理器
* @param {string} deName
*
* @memberof EntityServiceBase
* @returns {(any | null)}
* @memberof EntityService
*/
*/
constructor
(
deName
:
string
)
{
public
getStore
():
Store
<
any
>
|
null
{
this
.
deName
=
deName
;
return
this
.
$store
;
this
.
db
=
new
DBService
(
deName
);
}
}
/**
/**
*
设置从实体本地缓存
*
获取代码表
*
*
* @protected
* @memberof EntityService
* @param {*} [context={}]
* @param {*} [data]
* @returns {Promise<void>}
* @memberof EntityServiceBase
*/
*/
protected
async
setMinorLocalCache
(
context
:
any
=
{},
data
:
any
):
Promise
<
void
>
{
public
getCodeList
(
tag
:
string
,
codelistType
:
string
,
context
:
any
=
{},
param
:
any
=
{}){
if
(
data
)
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
for
(
const
key
in
this
.
allMinorAppEntity
)
{
if
(
tag
&&
Object
.
is
(
codelistType
,
"STATIC"
)){
if
(
data
.
hasOwnProperty
(
key
)
&&
this
.
allMinorAppEntity
.
hasOwnProperty
(
key
))
{
let
returnItems
:
Array
<
any
>
=
[];
const
config
:
any
=
this
.
allMinorAppEntity
[
key
];
const
codelist
=
(
this
.
getStore
()
as
Store
<
any
>
).
getters
.
getCodeList
(
tag
);
await
this
.
setLocalCache
(
context
,
data
[
key
],
config
.
name
);
if
(
codelist
)
{
}
returnItems
=
[...
JSON
.
parse
(
JSON
.
stringify
(
codelist
.
items
))];
}
else
{
console
.
log
(
`----
${
tag
}
----代码表不存在`
);
}
resolve
(
returnItems
);
}
else
if
(
tag
&&
Object
.
is
(
codelistType
,
"DYNAMIC"
)){
let
codeListService
=
new
CodeListService
({
$store
:
this
.
$store
});
codeListService
.
getItems
(
tag
,
context
,
param
).
then
((
res
:
any
)
=>
{
resolve
(
res
);
}).
catch
((
error
:
any
)
=>
{
reject
(
`
${
tag
}
代码表不存在`
);
console
.
log
(
`----
${
tag
}
----代码表不存在`
);
});
}
}
})
}
}
/**
* 初始化基础数据
*
* @memberof EntityService
*/
public
initBasicData
(){
}
}
/**
/**
*
设置本地缓存
*
Select接口方法
*
*
* @protected
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*}
data
* @param {*}
[data={}]
* @param {
string} [entityName] 指定实体
* @param {
boolean} [isloading]
* @returns {Promise<
boolean
>}
* @returns {Promise<
any
>}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
protected
async
setLocalCache
(
context
:
any
=
{},
data
:
any
,
entityName
?:
string
):
Promise
<
boolean
>
{
public
async
Select
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
data
)
{
return
this
.
SelectTemp
(
context
,
data
,
isloading
);
if
(
entityName
)
{
const
service
:
EntityServiceBase
=
await
this
.
getService
(
entityName
);
if
(
service
)
{
return
service
.
setLocalCache
(
context
,
data
);
}
}
else
{
data
=
Util
.
deepCopy
(
data
);
return
this
.
db
.
set
({
srfsessionkey
:
context
.
srfsessionkey
,
data
});
}
}
return
false
;
}
}
/**
/**
*
获取所有从实体本地缓存数据
*
SelectTemp接口方法
*
*
* @protected
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @returns {Promise<any>}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
protected
async
getMinorLocalCache
(
context
:
any
=
{}):
Promise
<
any
>
{
public
async
SelectTemp
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
const
data
:
any
=
{};
if
(
context
.
srfsessionkey
&&
!
Object
.
is
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
),
'undefined'
)){
for
(
const
key
in
this
.
allMinorAppEntity
)
{
let
result
:
any
=
JSON
.
parse
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
)
as
any
);
if
(
this
.
allMinorAppEntity
.
hasOwnProperty
(
key
))
{
if
(
result
){
const
config
:
any
=
this
.
allMinorAppEntity
[
key
];
let
tempResult
:
any
=
result
.
filter
((
item
:
any
)
=>
{
const
results
:
any
[]
=
await
this
.
getLocalCache
(
context
,
config
.
name
);
return
Object
.
is
(
item
[
this
.
APPDEKEY
],
data
[
this
.
APPDEKEY
]);
if
(
results
)
{
})
results
.
forEach
((
item
:
any
)
=>
{
let
tempResultData
:
any
=
tempResult
.
length
>
0
?
tempResult
[
0
]:
Object
.
assign
({},
data
);
if
(
item
.
srfuf
==
0
)
{
return
{
"status"
:
200
,
"data"
:
tempResultData
};
delete
item
[
this
.
key
];
}
else
{
}
return
{
"status"
:
500
,
"data"
:
null
};
});
}
}
data
[
key
]
=
results
||
[];
}
}
}
}
return
data
;
}
/**
/**
*
获取本地缓存数据
*
CreateTemp接口方法
*
*
* @protected
* @param {*} [context={}]
* @param {*} [context={}]
* @param {string} [entityName] 指定实体
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @returns {Promise<any>}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
protected
async
getLocalCache
(
context
:
any
=
{},
entityName
?:
string
):
Promise
<
any
>
{
public
async
CreateTemp
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
entityName
)
{
if
(
context
.
srfsessionkey
&&
!
Object
.
is
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
),
'undefined'
)){
const
service
:
EntityServiceBase
=
await
this
.
getService
(
entityName
);
let
tempData
:
any
=
JSON
.
parse
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
)
as
any
);
if
(
service
)
{
data
.
srffrontuf
=
"0"
;
return
service
.
getLocalCache
(
context
);
tempData
.
push
(
data
);
}
this
.
tempStorage
.
setItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
,
JSON
.
stringify
(
tempData
));
}
else
{
return
{
"status"
:
200
,
"data"
:
data
};
const
item
:
any
=
await
this
.
db
.
get
(
context
.
srfsessionkey
);
}
else
{
if
(
item
)
{
return
{
"status"
:
200
,
"data"
:{}};
return
item
.
data
;
}
}
}
}
}
/**
/**
*
删除本地缓存
*
GetTemp接口方法
*
*
* @protected
* @param {*} [context={}]
* @param {*} [context={}]
* @returns {Promise<boolean>}
* @param {*} [data={}]
* @memberof EntityServiceBase
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
protected
async
removeLocalCache
(
context
:
any
=
{},
entityName
?:
string
):
Promise
<
boolean
>
{
public
async
GetTemp
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
entityName
)
{
if
(
context
.
srfsessionkey
&&
!
Object
.
is
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
),
'undefined'
)){
const
service
:
EntityServiceBase
=
await
this
.
getService
(
entityName
);
let
result
:
any
=
JSON
.
parse
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
)
as
any
);
if
(
service
)
{
if
(
result
){
return
service
.
removeLocalCache
(
context
);
let
tempResult
:
any
=
result
.
filter
((
item
:
any
)
=>
{
return
Object
.
is
(
item
[
this
.
APPDEKEY
],
data
[
this
.
APPDEKEY
]);
})
let
tempResultData
:
any
=
tempResult
.
length
>
0
?
tempResult
[
0
]:
Object
.
assign
({},
data
);
return
{
"status"
:
200
,
"data"
:
tempResultData
};
}
else
{
return
{
"status"
:
500
,
"data"
:
null
};
}
}
}
else
{
return
this
.
db
.
remove
(
context
.
srfsessionkey
);
}
}
return
false
;
}
}
/**
/**
*
Select
接口方法
*
Update
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
Select
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
Update
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「Select」未实现'
}
);
return
this
.
UpdateTemp
(
context
,
data
,
isloading
);
}
}
/**
/**
*
SelectTemp接口方法(暂未支持)
*
UpdateTempMajor接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
SelectTemp
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
UpdateTempMajor
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
context
.
srfsessionkey
)
{
return
this
.
Update
(
context
,
data
,
isloading
);
const
result
:
any
[]
=
await
this
.
getLocalCache
(
context
)
||
[];
if
(
result
)
{
return
new
HttpResponse
(
200
,
result
);
}
}
return
new
HttpResponse
(
500
,
null
,
{
code
:
5001
});
}
}
/**
/**
*
CreateTemp
接口方法
*
Save
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
CreateTemp
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
Save
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
data
&&
context
.
srfsessionkey
)
{
return
{
status
:
500
,
data
:
{
title
:
'失败'
,
message
:
'预置实体行为 Save 未实现'
}};
const
result
:
any
[]
=
await
this
.
getLocalCache
(
context
)
||
[];
data
.
srfuf
=
0
;
result
.
push
(
data
);
if
(
await
this
.
setLocalCache
(
context
,
result
))
{
return
new
HttpResponse
(
200
,
data
);
}
}
return
new
HttpResponse
(
500
,
null
,
{
code
:
5003
});
}
}
/**
/**
*
Get
Temp接口方法
*
Update
Temp接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
*/
* @memberof EntityService
public
async
GetTemp
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
*/
if
(
context
.
srfsessionkey
)
{
public
async
UpdateTemp
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
const
result
:
any
[]
=
await
this
.
getLocalCache
(
context
)
||
[];
if
(
context
.
srfsessionkey
&&
!
Object
.
is
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
),
'undefined'
)){
const
self
:
any
=
result
.
find
((
item
:
any
)
=>
Object
.
is
(
item
[
this
.
key
],
context
[
this
.
deName
]));
let
result
:
any
=
JSON
.
parse
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
)
as
any
);
if
(
self
)
{
let
tempData
:
Array
<
any
>
=
[];
return
new
HttpResponse
(
200
,
self
);
if
(
result
&&
result
.
length
>
0
){
result
.
forEach
((
item
:
any
)
=>
{
let
singleData
:
any
=
{};
if
(
Object
.
is
(
item
[
this
.
APPDEKEY
],
data
[
this
.
APPDEKEY
])){
Object
.
keys
(
item
).
forEach
((
field
:
any
)
=>
{
singleData
[
field
]
=
data
[
field
]?
data
[
field
]:
item
[
field
];
})
}
if
(
Object
.
keys
(
singleData
).
length
>
0
){
tempData
.
push
(
singleData
);
}
else
{
tempData
.
push
(
item
);
}
});
this
.
tempStorage
.
setItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
,
JSON
.
stringify
(
tempData
));
return
{
"status"
:
200
,
"data"
:
data
};
}
else
{
return
{
"status"
:
500
,
"data"
:
null
};
}
}
}
}
return
new
HttpResponse
(
500
,
null
,
{
code
:
5001
});
}
}
/**
/**
*
Updat
eTemp接口方法
*
Remov
eTemp接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
UpdateTemp
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
RemoveTemp
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
context
.
srfsessionkey
)
{
if
(
context
.
srfsessionkey
&&
!
Object
.
is
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
),
'undefined'
)){
const
result
:
any
[]
=
await
this
.
getLocalCache
(
context
)
||
[];
let
result
:
any
=
JSON
.
parse
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
)
as
any
);
const
num
:
number
=
result
.
findIndex
((
item
:
any
)
=>
Object
.
is
(
item
[
this
.
key
],
data
[
this
.
key
]));
if
(
result
){
if
(
num
!==
-
1
)
{
let
tempResult
:
any
=
result
.
filter
((
item
:
any
)
=>
{
result
[
num
]
=
data
;
// return !( Object.is(item[this.APPDEKEY],data[this.APPDEKEY]) && Object.is(item[this.APPDETEXT],data[this.APPDETEXT]));
if
(
await
this
.
setLocalCache
(
context
,
result
))
{
return
!
Object
.
is
(
item
[
this
.
APPDEKEY
],
data
[
this
.
APPDEKEY
]);
return
new
HttpResponse
(
200
,
data
);
})
}
this
.
tempStorage
.
setItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
,
JSON
.
stringify
(
tempResult
));
return
{
"status"
:
200
,
"data"
:
data
};
}
else
{
return
{
"status"
:
500
,
"data"
:
null
};
}
}
}
}
return
new
HttpResponse
(
500
,
null
,
{
code
:
5004
});
}
}
/**
/**
*
RemoveTemp
接口方法
*
CheckKey
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
RemoveTemp
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
CheckKey
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
context
.
srfsessionkey
)
{
if
(
context
.
srfsessionkey
&&
!
Object
.
is
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
),
'undefined'
)){
const
result
:
any
[]
=
await
this
.
getLocalCache
(
context
)
||
[];
let
result
:
any
=
JSON
.
parse
(
this
.
tempStorage
.
getItem
(
context
.
srfsessionkey
+
'_'
+
this
.
APPDENAME
)
as
any
);
const
str
:
string
=
context
[
this
.
deName
];
if
(
result
){
if
(
str
&&
!
Object
.
is
(
str
,
''
))
{
let
flag
:
boolean
=
false
;
const
keys
:
string
[]
=
str
.
split
(
';'
);
result
.
forEach
((
item
:
any
)
=>
{
keys
.
forEach
((
key
:
string
)
=>
{
if
(
Object
.
is
(
item
[
this
.
APPDEKEY
],
data
[
this
.
APPDEKEY
])){
const
num
:
number
=
result
.
findIndex
((
item
:
any
)
=>
item
[
this
.
key
]
==
key
);
flag
=
true
;
if
(
num
!==
-
1
)
{
result
.
splice
(
num
,
1
);
}
}
});
});
if
(
await
this
.
setLocalCache
(
context
,
result
))
{
return
{
"status"
:
200
,
"data"
:
flag
};
return
new
HttpResponse
(
200
,
data
);
}
else
{
return
{
"status"
:
500
,
"data"
:
null
};
}
}
}
}
}
}
return
new
HttpResponse
(
500
,
null
,
{
code
:
5005
});
/**
* GetDraft接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
public
async
GetDraft
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
GetDraftTemp
(
context
,
data
,
isloading
);
}
}
/**
/**
*
UpdateTempMajor
接口方法
*
Remove
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
UpdateTempMajor
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
Remove
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
Update
(
context
,
data
);
return
this
.
RemoveTemp
(
context
,
data
,
isloading
);
}
}
/**
/**
...
@@ -360,11 +391,12 @@ export class EntityServiceBase {
...
@@ -360,11 +391,12 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
CreateTempMajor
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
CreateTempMajor
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
Create
(
context
,
data
);
return
this
.
Create
(
context
,
data
,
isloading
);
}
}
/**
/**
...
@@ -372,11 +404,25 @@ export class EntityServiceBase {
...
@@ -372,11 +404,25 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
RemoveTempMajor
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
RemoveTempMajor
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
Remove
(
context
,
data
);
return
this
.
Remove
(
context
,
data
,
isloading
);
}
/**
* Get接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
public
async
Get
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
GetTemp
(
context
,
data
,
isloading
);
}
}
/**
/**
...
@@ -384,35 +430,38 @@ export class EntityServiceBase {
...
@@ -384,35 +430,38 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
GetDraftTempMajor
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
GetDraftTempMajor
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
GetDraft
(
context
,
data
);
return
this
.
GetDraft
(
context
,
data
,
isloading
);
}
}
/**
/**
*
GetTempMajor
接口方法
*
Create
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
GetTempMajor
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
Create
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
Get
(
context
,
data
);
return
this
.
CreateTemp
(
context
,
data
,
isloading
);
}
}
/**
/**
*
FetchTempDefault
接口方法
*
GetTempMajor
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
FetchTempDefault
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
GetTempMajor
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「FetchTempDefault」未实现'
}
);
return
this
.
Get
(
context
,
data
,
isloading
);
}
}
/**
/**
...
@@ -420,203 +469,247 @@ export class EntityServiceBase {
...
@@ -420,203 +469,247 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
GetDraftTemp
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
GetDraftTemp
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
const
tempData
=
{
srfsessionkey
:
data
.
srfsessionkey
};
let
tempData
=
{
srfsessionkey
:
context
.
srfsessionkey
};
Object
.
defineProperty
(
tempData
,
this
.
key
,
{
Object
.
defineProperty
(
tempData
,
this
.
APPDEKEY
,
{
enumerable
:
true
,
enumerable
:
true
,
value
:
data
[
this
.
key
]
value
:
data
[
this
.
APPDEKEY
]
});
});
Object
.
assign
(
data
,
tempData
);
Object
.
assign
(
data
,
tempData
);
return
new
HttpResponse
(
200
,
data
);
return
{
"status"
:
200
,
"data"
:
data
};
}
}
/**
/**
*
Update
接口方法
*
FetchDefault
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
Update
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
FetchDefault
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「Update」未实现'
})
;
return
{
status
:
500
,
data
:
{
title
:
'失败'
,
message
:
'预置实体行为 FetchDefault 未实现'
}}
;
}
}
/**
/**
*
Save
接口方法
*
FetchTempDefault
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
Save
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
FetchTempDefault
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「Save」未实现'
})
;
return
{
status
:
500
,
data
:
{
title
:
'失败'
,
message
:
'预置实体行为 FetchDefault 未实现'
}}
;
}
}
/**
/**
*
CheckKey
接口方法
*
FilterUpdate
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
CheckKey
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
FilterUpdate
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
context
.
srfsessionkey
)
{
return
this
.
Update
(
context
,
data
,
isloading
);
const
result
=
await
this
.
getLocalCache
(
context
)
if
(
result
)
{
return
new
HttpResponse
(
200
,
true
);
}
}
return
new
HttpResponse
(
200
,
false
);
}
}
/**
/**
*
GetDraft
接口方法
*
FilterSearch
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
GetDraft
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
FilterSearch
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「GetDraft」未实现'
}
);
return
this
.
FetchDefault
(
context
,
data
,
isloading
);
}
}
/**
/**
*
Remove
接口方法
*
FilterGet
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
Remove
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
FilterGet
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「Remove」未实现'
}
);
return
this
.
Get
(
context
,
data
,
isloading
);
}
}
/**
/**
*
Get
接口方法
*
FilterCreate
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
Get
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
FilterCreate
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「Get」未实现'
}
);
return
this
.
Create
(
context
,
data
,
isloading
);
}
}
/**
/**
*
Create
接口方法
*
FilterGetDraft
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
Create
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
FilterGetDraft
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「Create」未实现'
}
);
return
this
.
GetDraft
(
context
,
data
,
isloading
);
}
}
/**
/**
* F
etchDefault
接口方法
* F
ilterRemove
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
F
etchDefault
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
F
ilterRemove
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'预置实体行为「FetchDefault」未实现'
}
);
return
this
.
Remove
(
context
,
data
,
isloading
);
}
}
/**
/**
* Filter
Update
接口方法
* Filter
Fetch
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
Filter
Update
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
Filter
Fetch
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
Update
(
context
,
data
);
return
this
.
FetchDefault
(
context
,
data
,
isloading
);
}
}
/**
/**
*
FilterSearch
接口方法
*
ImportData
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
FilterSearch
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
ImportData
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
FetchDefault
(
context
,
data
);
let
_data
:
Array
<
any
>
=
[];
if
(
data
&&
data
.
importData
)
_data
=
data
.
importData
;
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/import?config=
${
data
.
name
}
`
,
_data
,
isloading
);
}
}
/**
/**
*
FilterGet
接口方法
*
createBatch
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
FilterGet
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
createBatch
(
context
:
any
=
{},
data
:
any
,
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
Get
(
context
,
data
);
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/batch`
,
data
,
isloading
);
}
}
/**
/**
*
FilterCreate
接口方法
*
saveBatch
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
FilterCreate
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
saveBatch
(
context
:
any
=
{},
data
:
any
,
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
Create
(
context
,
data
);
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/savebatch`
,
data
,
isloading
);
}
}
/**
/**
*
FilterGetDraft
接口方法
*
updateBatch
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
FilterGetDraft
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
updateBatch
(
context
:
any
=
{},
data
:
any
,
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
GetDraft
(
context
,
data
);
return
Http
.
getInstance
().
put
(
`/
${
this
.
APPDENAME
}
/batch`
,
data
,
isloading
);
}
}
/**
/**
*
FilterRemove
接口方法
*
removeBatch
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
FilterRemove
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
removeBatch
(
context
:
any
=
{},
data
:
any
,
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
Remove
(
context
,
data
);
return
Http
.
getInstance
().
delete
(
`/
${
this
.
APPDENAME
}
/batch`
,
isloading
,
data
[
this
.
APPDEKEY
]
);
}
}
/**
/**
*
FilterFetch
接口方法
*
getDataInfo
接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
public
async
getDataInfo
(
context
:
any
=
{},
data
:
any
,
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
context
[
this
.
APPLYDEKEY
]){
return
this
.
Get
(
context
,
data
,
isloading
);
}
}
/**
* getDynaModel(获取动态模型)接口方法
*
* @param {*} [context={}]
* @param {*} [data]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
FilterFetch
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
getDynaModel
(
context
:
any
=
{},
data
:
any
,
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
FetchDefault
(
context
,
data
);
if
(
data
&&
data
.
configType
&&
data
.
targetType
){
return
Http
.
getInstance
().
get
(
`/configs/
${
data
.
configType
}
/
${
data
.
targetType
}
`
);
}
}
/**
* setDynaModel(设置动态模型)接口方法
*
* @param {*} [context={}]
* @param {*} [data]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
public
async
setDynaModel
(
context
:
any
=
{},
data
:
any
,
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
data
&&
data
.
configType
&&
data
.
targetType
){
return
Http
.
getInstance
().
put
(
`/configs/
${
data
.
configType
}
/
${
data
.
targetType
}
`
,{
model
:
data
.
model
});
}
}
}
/**
/**
...
@@ -624,35 +717,50 @@ export class EntityServiceBase {
...
@@ -624,35 +717,50 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
WFStart
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
WFStart
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
,
localdata
?:
any
):
Promise
<
any
>
{
return
this
.
http
.
post
(
`/
${
this
.
dePath
}
/wfstart`
,
{
wfdata
:
data
});
if
(
localdata
&&
Object
.
keys
(
localdata
).
length
>
0
){
const
requestData
:
any
=
{};
Object
.
assign
(
requestData
,{
activedata
:
data
});
Object
.
assign
(
requestData
,
localdata
);
return
Http
.
getInstance
().
post
(
`/wfcore/
${
this
.
SYSTEMNAME
}
-app-
${
this
.
APPNAME
}
/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/process-instances`
,
requestData
,
isloading
);
}
else
{
const
requestData
:
any
=
{};
Object
.
assign
(
requestData
,{
wfdata
:
data
});
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/wfstart`
,
requestData
,
isloading
);
}
}
}
/**
/**
* WFClose接口方法
* WFClose接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
WFClose
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
WFClose
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
http
.
post
(
`/
${
this
.
dePath
}
/
${
context
[
this
.
key
]}
/wfclose`
,
data
);
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/wfclose`
,
data
,
isloading
);
}
}
/**
/**
* WFMarkRead接口方法
* WFMarkRead接口方法
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
WFMarkRead
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
WFMarkRead
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
http
.
post
(
`/
${
this
.
dePath
}
/
${
context
[
this
.
key
]}
/wfmarkread`
,
data
);
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/wfmarkread`
,
data
,
isloading
);
}
}
/**
/**
...
@@ -660,11 +768,12 @@ export class EntityServiceBase {
...
@@ -660,11 +768,12 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
WFGoto
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
WFGoto
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
http
.
post
(
`/
${
this
.
dePath
}
/
${
context
[
this
.
key
]}
/wfgoto`
,
data
);
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/wfgoto`
,
data
,
isloading
);
}
}
/**
/**
...
@@ -672,11 +781,12 @@ export class EntityServiceBase {
...
@@ -672,11 +781,12 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
WFRollback
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
WFRollback
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
http
.
post
(
`/
${
this
.
dePath
}
/
${
context
[
this
.
key
]}
/wfrollback`
,
data
);
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/wfrollback`
,
data
,
isloading
);
}
}
/**
/**
...
@@ -684,11 +794,12 @@ export class EntityServiceBase {
...
@@ -684,11 +794,12 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
WFRestart
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
WFRestart
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
http
.
post
(
`/
${
this
.
dePath
}
/
${
context
[
this
.
key
]}
/wfrestart`
,
data
);
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/wfrestart`
,
data
,
isloading
);
}
}
/**
/**
...
@@ -696,35 +807,26 @@ export class EntityServiceBase {
...
@@ -696,35 +807,26 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
WFReassign
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
WFReassign
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
this
.
http
.
post
(
`/
${
this
.
dePath
}
/
${
context
[
this
.
key
]}
/wfreassign`
,
data
);
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/wfreassign`
,
data
,
isloading
);
}
}
/**
/**
* WF
Submit接口方法
* WF
GetWorkFlow接口方法(获取工作流定义)
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @param {
*} [wfdata
]
* @param {
boolean} [isloading
]
* @returns {Promise<
HttpResponse
>}
* @returns {Promise<
any
>}
* @memberof EntityService
Base
* @memberof EntityService
*/
*/
public
async
WFSubmit
(
context
:
any
=
{},
data
:
any
=
{},
wfdata
?:
any
):
Promise
<
HttpResponse
>
{
public
async
WFGetWorkFlow
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
try
{
return
Http
.
getInstance
().
get
(
`/wfcore/
${
this
.
SYSTEMNAME
}
-app-
${
this
.
APPNAME
}
/
${
this
.
APPDENAME
}
/process-definitions`
);
let
res
:
any
;
if
(
wfdata
&&
Object
.
keys
(
wfdata
).
length
!==
0
)
{
const
_data
:
any
=
{
...{
activedata
:
data
},
...
wfdata
};
res
=
await
this
.
http
.
post
(
`/wfcore/
${
this
.
systemName
}
-app-
${
this
.
appName
}
/
${
this
.
dePath
}
/
${
data
[
this
.
key
]}
/tasks/
${
wfdata
[
'taskId'
]}
`
,
_data
);
}
else
{
res
=
await
this
.
http
.
post
(
`/
${
this
.
dePath
}
/
${
context
[
this
.
key
]}
/wfsubmit`
,
data
);
}
return
res
;
}
catch
(
res
)
{
return
new
HttpResponse
(
res
.
status
,
null
);
}
}
}
/**
/**
...
@@ -732,16 +834,12 @@ export class EntityServiceBase {
...
@@ -732,16 +834,12 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
WFGetWFStep
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
WFGetWFStep
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
try
{
return
Http
.
getInstance
().
get
(
`/wfcore/
${
this
.
SYSTEMNAME
}
-app-
${
this
.
APPNAME
}
/
${
this
.
APPDENAME
}
/process-definitions-nodes`
);
const
res
=
await
this
.
http
.
get
(
`/wfcore/
${
this
.
systemName
}
-app-
${
this
.
appName
}
/
${
this
.
dePath
}
/process-definitions-nodes`
);
return
res
;
}
catch
(
res
)
{
return
new
HttpResponse
(
res
.
status
,
null
);
}
}
}
/**
/**
...
@@ -749,16 +847,12 @@ export class EntityServiceBase {
...
@@ -749,16 +847,12 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
GetWFLink
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
GetWFLink
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
try
{
return
Http
.
getInstance
().
get
(
`/wfcore/
${
this
.
SYSTEMNAME
}
-app-
${
this
.
APPNAME
}
/
${
this
.
APPDENAME
}
/
${
context
[
this
.
APPLYDEKEY
]}
/usertasks/
${
data
[
'taskDefinitionKey'
]}
/ways`
);
const
res
=
await
this
.
http
.
get
(
`/wfcore/
${
this
.
systemName
}
-app-
${
this
.
appName
}
/
${
this
.
dePath
}
/
${
context
[
this
.
deName
]}
/usertasks/
${
data
[
'taskDefinitionKey'
]}
/ways`
);
return
res
;
}
catch
(
res
)
{
return
new
HttpResponse
(
res
.
status
,
null
);
}
}
}
/**
/**
...
@@ -766,28 +860,131 @@ export class EntityServiceBase {
...
@@ -766,28 +860,131 @@ export class EntityServiceBase {
*
*
* @param {*} [context={}]
* @param {*} [context={}]
* @param {*} [data={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @param {boolean} [isloading]
* @memberof EntityServiceBase
* @returns {Promise<any>}
* @memberof EntityService
*/
*/
public
async
GetWFHistory
(
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
HttpResponse
>
{
public
async
GetWFHistory
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
try
{
return
Http
.
getInstance
().
get
(
`/wfcore/
${
this
.
SYSTEMNAME
}
-app-
${
this
.
APPNAME
}
/
${
this
.
APPDENAME
}
/
${
context
[
this
.
APPLYDEKEY
]}
/process-instances/alls/history`
);
const
res
=
await
this
.
http
.
get
(
`/wfcore/
${
this
.
systemName
}
-app-
${
this
.
appName
}
/
${
this
.
dePath
}
/
${
context
[
this
.
deName
]}
/process-instances/alls/history`
);
}
return
res
;
}
catch
(
res
)
{
/**
return
new
HttpResponse
(
res
.
status
,
null
);
* WFSubmit接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @param {*} [localdata]
* @returns {Promise<any>}
* @memberof EntityService
*/
public
async
WFSubmit
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
,
localdata
?:
any
):
Promise
<
any
>
{
if
(
localdata
&&
Object
.
keys
(
localdata
).
length
>
0
){
const
requestData
:
any
=
{};
if
(
data
.
viewparams
){
delete
data
.
viewparams
;
}
Object
.
assign
(
requestData
,{
activedata
:
data
});
Object
.
assign
(
requestData
,
localdata
);
return
Http
.
getInstance
().
post
(
`/wfcore/
${
this
.
SYSTEMNAME
}
-app-
${
this
.
APPNAME
}
/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/tasks/
${
localdata
[
'taskId'
]}
`
,
requestData
,
isloading
);
}
else
{
const
requestData
:
any
=
{};
if
(
data
.
srfwfmemo
){
requestData
.
srfwfmemo
=
JSON
.
parse
(
JSON
.
stringify
(
data
)).
srfwfmemo
;
delete
data
.
srfwfmemo
;
}
if
(
data
.
viewparams
){
delete
data
.
viewparams
;
}
Object
.
assign
(
requestData
,{
wfdata
:
data
});
Object
.
assign
(
requestData
,{
opdata
:{
srfwfiatag
:
context
.
srfwfiatag
,
srfwfstep
:
context
.
srfwfstep
}});
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/wfsubmit`
,
requestData
,
isloading
);
}
}
}
}
/**
/**
*
获取其他实体服务
*
WFGetProxyData接口方法
*
*
* @protected
* @param {*} [context={}]
* @param {string} name 实体名称
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @returns {Promise<any>}
* @memberof EntityServiceBase
* @memberof EntityService
*/
public
async
WFGetProxyData
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
Http
.
getInstance
().
get
(
`/
${
this
.
APPDENAME
}
/
${
context
[
this
.
APPLYDEKEY
]}
/wfgetproxydata`
,
data
,
isloading
);
}
/**
* 测试数据是否在工作流中
*
* @param context
* @param data
* @param isloading
*/
public
async
testDataInWF
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
if
(
!
context
.
stateField
||
!
context
.
stateValue
)
return
false
;
if
(
context
.
stateValue
==
data
[
context
.
stateField
]){
return
true
;
}
return
false
;
}
/**
* 测试当前用户是否提交过工作流
*
* @param context
* @param data
* @param isloading
*/
public
async
testUserWFSubmit
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
true
;
}
/**
* 测试当前用户是否存在待办列表
*
* @param context
* @param data
* @param isloading
*/
public
async
testUserExistWorklist
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
const
requestData
:
any
=
{};
Object
.
assign
(
requestData
,{
wfdata
:
data
});
return
Http
.
getInstance
().
post
(
`/
${
this
.
APPDENAME
}
/
${
data
[
this
.
APPDEKEY
]}
/testuserexistworklist`
,
requestData
,
isloading
);
}
/**
* 获取所有应用数据
*
* @param context
* @param data
* @param isloading
*/
public
async
getAllApp
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
Http
.
getInstance
().
get
(
`uaa/access-center/app-switcher/default`
,
data
,
isloading
);
}
/**
* 更新已选择的应用
*
* @param context
* @param data
* @param isloading
*/
public
async
updateChooseApp
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
Http
.
getInstance
().
put
(
`uaa/access-center/app-switcher/default`
,
data
,
isloading
);
}
/**
* 修改密码
*
* @param context
* @param data
* @param isloading
*/
*/
p
rotected
getService
(
name
:
string
):
Promise
<
any
>
{
p
ublic
async
changPassword
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
return
window
.
appEntityServiceConstructor
.
getService
(
name
);
return
Http
.
getInstance
().
post
(
`v7/changepwd`
,
data
,
isloading
);
}
}
}
}
\ No newline at end of file
src/ibiz-core/utils/http/http.ts
浏览文件 @
b4112668
import
axios
,
{
AxiosResponse
}
from
'axios'
;
import
axios
,
{
AxiosResponse
}
from
'axios'
;
import
qs
from
'qs'
;
import
qs
from
'qs'
;
import
{
HttpResponse
}
from
'./http-response'
;
import
{
Util
}
from
'../util/util'
;
/**
/**
* Http net 对象
* Http net 对象
* 调用 getInstance() 获取实例
* 调用 getInstance() 获取实例
...
@@ -12,14 +9,45 @@ import { Util } from '../util/util';
...
@@ -12,14 +9,45 @@ import { Util } from '../util/util';
export
class
Http
{
export
class
Http
{
/**
/**
* 唯一实例
* 获取 Http 单例对象
*
* @static
* @returns {Http}
* @memberof Http
*/
public
static
getInstance
():
Http
{
if
(
!
Http
.
Http
)
{
Http
.
Http
=
new
Http
();
}
return
this
.
Http
;
}
/**
* 单例变量声明
*
*
* @private
* @private
* @static
* @static
* @type {Http}
* @type {Http}
* @memberof Http
* @memberof Http
*/
*/
private
static
readonly
instance
:
Http
=
new
Http
();
private
static
Http
:
Http
;
/**
* 统计加载
*
* @type {number}
* @memberof Http
*/
private
loadingCount
:
number
=
0
;
/**
* load状态管理器
*
* @private
* @type {(ElLoadingComponent | any)}
* @memberof Http
*/
private
elLoadingComponent
:
any
;
/**
/**
* Creates an instance of Http.
* Creates an instance of Http.
...
@@ -27,46 +55,86 @@ export class Http {
...
@@ -27,46 +55,86 @@ export class Http {
*
*
* @memberof Http
* @memberof Http
*/
*/
constructor
()
{
private
constructor
()
{
}
if
(
Http
.
instance
)
{
return
Http
.
instance
;
/**
* post请求
*
* @param {string} url
* @param {*} [params={}]
* @param {boolean} [isloading]
* @param {number} [serialnumber]
* @returns {Promise<any>}
* @memberof Http
*/
public
post
(
url
:
string
,
params
:
any
=
{},
isloading
?:
boolean
,
serialnumber
?:
number
):
Promise
<
any
>
{
if
(
isloading
)
{
this
.
beginLoading
();
}
}
params
=
this
.
handleRequestData
(
params
);
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
axios
({
method
:
'post'
,
url
:
url
,
data
:
params
,
headers
:
{
'Content-Type'
:
'application/json;charset=UTF-8'
,
'Accept'
:
'application/json'
},
// transformResponse: [(data: any) => {
// let _data: any = null;
// try {
// _data = JSON.parse(JSON.stringify(data));
// } catch (error) {
// }
// return _data;
// }],
}).
then
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
}).
catch
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
});
});
}
}
/**
/**
* 获取
* 获取
*
*
* @param {string} url
* @param {string} url
* @param {*} [params]
* @param {*} [params={}]
* @param {boolean} [isloading]
* @param {number} [serialnumber]
* @returns {Promise<any>}
* @returns {Promise<any>}
* @memberof Http
* @memberof Http
*/
*/
public
get
(
url
:
string
,
params
?:
any
):
Promise
<
any
>
{
public
get
(
url
:
string
,
params
:
any
=
{},
isloading
?:
boolean
,
serialnumber
?:
number
):
Promise
<
any
>
{
if
(
params
)
{
params
=
this
.
handleRequestData
(
params
);
params
=
this
.
handleRequestData
(
params
);
if
((
Object
.
keys
(
params
)).
length
>
0
)
{
if
(
params
.
srfparentdata
){
let
tempParam
:
any
=
{};
Object
.
assign
(
params
,
params
.
srfparentdata
);
let
sort
:
any
=
null
;
delete
params
.
srfparentdata
;
Object
.
keys
(
params
).
forEach
((
item
:
any
)
=>
{
}
if
(
params
[
item
]
||
Object
.
is
(
params
[
item
],
0
))
{
if
((
Object
.
keys
(
params
)).
length
>
0
){
if
(
Object
.
is
(
item
,
'sort'
))
{
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
];
sort
=
params
[
item
];
}
else
{
}
else
{
tempParam
[
item
]
=
params
[
item
];
tempParam
[
item
]
=
params
[
item
];
}
}
}
}
})
})
url
+=
`?
${
qs
.
stringify
(
tempParam
)}
`
;
url
+=
`?
${
qs
.
stringify
(
tempParam
)}
`
;
if
(
sort
)
{
if
(
sort
)
{
url
+=
'&sort='
+
sort
;
url
+=
'&sort='
+
sort
;
}
}
}
}
if
(
isloading
)
{
this
.
beginLoading
();
}
}
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
axios
.
get
(
url
).
then
((
response
:
AxiosResponse
)
=>
{
axios
.
get
(
url
).
then
((
response
:
any
)
=>
{
resolve
(
this
.
handelResponseResult
(
response
)
);
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
}).
catch
((
response
:
AxiosResponse
)
=>
{
}).
catch
((
response
:
any
)
=>
{
reject
(
this
.
handelResponseResult
(
response
)
);
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
});
});
});
});
}
}
...
@@ -75,134 +143,101 @@ export class Http {
...
@@ -75,134 +143,101 @@ export class Http {
* 删除
* 删除
*
*
* @param {string} url
* @param {string} url
* @param {boolean} [isloading]
* @param {number} [serialnumber]
* @returns {Promise<any>}
* @returns {Promise<any>}
* @memberof Http
* @memberof Http
*/
*/
public
delete
(
url
:
string
):
Promise
<
any
>
{
public
delete
(
url
:
string
,
isloading
?:
boolean
,
data
?:
any
,
serialnumber
?:
number
):
Promise
<
any
>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
if
(
isloading
)
{
axios
.
delete
(
url
).
then
((
response
:
AxiosResponse
)
=>
{
this
.
beginLoading
();
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
)
=>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
axios
.
head
(
url
).
then
((
response
:
AxiosResponse
)
=>
{
if
(
!
data
){
resolve
(
this
.
handelResponseResult
(
response
));
axios
.
delete
(
url
).
then
((
response
:
any
)
=>
{
}).
catch
((
response
:
AxiosResponse
)
=>
{
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
reject
(
this
.
handelResponseResult
(
response
));
}).
catch
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
});
});
}
else
{
axios
.
delete
(
url
,{
data
:
data
}).
then
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
}).
catch
((
response
:
any
)
=>
{
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
});
});
}
}
/**
*
*
* @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 {string} url
* @param {*} [data]
* @param {*} data
* @param {boolean} [isloading]
* @param {number} [serialnumber]
* @returns {Promise<any>}
* @returns {Promise<any>}
* @memberof Http
* @memberof Http
*/
*/
public
p
ost
(
url
:
string
,
data
?:
any
):
Promise
<
any
>
{
public
p
ut
(
url
:
string
,
data
:
any
,
isloading
?:
boolean
,
serialnumber
?:
number
):
Promise
<
any
>
{
if
(
data
)
{
if
(
isloading
)
{
data
=
this
.
handleRequestData
(
data
);
this
.
beginLoading
(
);
}
}
data
=
this
.
handleRequestData
(
data
);
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
axios
.
post
(
url
,
axios
.
put
(
url
,
data
).
then
((
response
:
any
)
=>
{
data
,
this
.
doResponseRresult
(
response
,
resolve
,
isloading
,
serialnumber
);
{
headers
:
{
'Content-Type'
:
'application/json;charset=UTF-8'
,
'Accept'
:
'application/json'
}
}
}).
catch
((
response
:
any
)
=>
{
).
then
((
response
:
AxiosResponse
)
=>
{
this
.
doResponseRresult
(
response
,
reject
,
isloading
,
serialnumber
);
resolve
(
this
.
handelResponseResult
(
response
));
}).
catch
((
response
:
AxiosResponse
)
=>
{
reject
(
this
.
handelResponseResult
(
response
));
});
});
});
});
}
}
/**
/**
*
修改数据
*
处理响应结果
*
*
* @param {string} url
* @private
* @param {*} data
* @param {*} response
* @returns {Promise<any>}
* @param {Function} funt
* @param {boolean} [isloading]
* @param {number} [serialnumber]
* @memberof Http
* @memberof Http
*/
*/
p
ublic
put
(
url
:
string
,
data
:
any
):
Promise
<
any
>
{
p
rivate
doResponseRresult
(
response
:
any
,
funt
:
Function
,
isloading
?:
boolean
,
serialnumber
?:
number
):
void
{
if
(
data
)
{
if
(
isloading
)
{
data
=
this
.
handleRequestData
(
data
);
this
.
endLoading
(
);
}
}
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
if
(
serialnumber
)
{
axios
.
put
(
url
,
data
).
then
((
response
:
AxiosResponse
)
=>
{
Object
.
assign
(
response
,
{
serialnumber
:
serialnumber
});
resolve
(
this
.
handelResponseResult
(
response
));
}
}).
catch
((
response
:
AxiosResponse
)
=>
{
funt
(
response
);
reject
(
this
.
handelResponseResult
(
response
));
});
});
}
}
/**
/**
*
修改数据
*
开始加载
*
*
* @param {string} url
* @private
* @param {*} data
* @returns {Promise<any>}
* @memberof Http
* @memberof Http
*/
*/
public
patch
(
url
:
string
,
data
:
any
):
Promise
<
any
>
{
private
beginLoading
():
void
{
if
(
data
)
{
// todo 开始加载
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
* @private
* @param {*} response
* @memberof Http
* @memberof Http
*/
*/
private
handelResponseResult
(
response
:
any
):
HttpResponse
{
private
endLoading
():
void
{
if
(
response
)
{
if
(
this
.
loadingCount
>
0
)
{
if
(
response
.
status
===
200
)
{
this
.
loadingCount
--
;
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
)
setTimeout
(()
=>
{
if
(
this
.
loadingCount
===
0
)
{
// todo 停止加载
}
}
return
new
HttpResponse
(
500
,
null
,
{
code
:
100
,
message
:
'请求发生异常,无返回结果!'
},
response
.
headers
);
},
500
);
}
}
/**
/**
...
@@ -212,26 +247,14 @@ export class Http {
...
@@ -212,26 +247,14 @@ export class Http {
* @param data
* @param data
* @memberof Http
* @memberof Http
*/
*/
private
handleRequestData
(
data
:
any
)
{
private
handleRequestData
(
data
:
any
){
data
=
Util
.
deepCopy
(
data
);
if
(
data
.
srfsessionkey
){
if
(
data
.
srfsessionkey
)
{
delete
data
.
srfsessionkey
;
delete
data
.
srfsessionkey
;
}
}
if
(
data
.
srfsessionid
)
{
if
(
data
.
srfsessionid
)
{
delete
data
.
srfsessionid
;
delete
data
.
srfsessionid
;
}
}
return
data
;
return
data
;
}
}
/**
* 获取 Http 单例对象
*
* @static
* @returns {Http}
* @memberof Http
*/
public
static
getInstance
():
Http
{
return
this
.
instance
;
}
}
}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录