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
提交
490f98a5
提交
490f98a5
编写于
7月 30, 2020
作者:
KK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
部件服务基类调整
上级
d8cc6ffa
变更
1
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
61 行增加
和
166 行删除
+61
-166
control-service-base.ts
src/ibiz-core/control-service/control-service-base.ts
+61
-166
未找到文件。
src/ibiz-core/control-service/control-service-base.ts
浏览文件 @
490f98a5
...
@@ -19,17 +19,6 @@ export class ControlServiceBase {
...
@@ -19,17 +19,6 @@ export class ControlServiceBase {
*/
*/
protected
model
:
any
=
null
;
protected
model
:
any
=
null
;
/**
* 是否正在加载状态
*
* @protected
* @type {boolean}
* @memberof ControlServiceBase
*/
protected
$isLoading
:
boolean
=
false
;
public
get
isLoading
():
boolean
{
return
this
.
$isLoading
;
}
/**
/**
* 应用实体名称
* 应用实体名称
...
@@ -109,9 +98,6 @@ export class ControlServiceBase {
...
@@ -109,9 +98,6 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
* @memberof ControlServiceBase
*/
*/
protected
async
onBeforeAction
(
action
?:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
:
boolean
=
true
):
Promise
<
any
>
{
protected
async
onBeforeAction
(
action
?:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
:
boolean
=
true
):
Promise
<
any
>
{
if
(
isLoading
)
{
// this.showLoading();
}
if
(
!
this
.
service
)
{
if
(
!
this
.
service
)
{
this
.
service
=
await
this
.
getService
(
this
.
appDEName
);
this
.
service
=
await
this
.
getService
(
this
.
appDEName
);
}
}
...
@@ -130,32 +116,6 @@ export class ControlServiceBase {
...
@@ -130,32 +116,6 @@ export class ControlServiceBase {
*/
*/
protected
async
beforeAction
(
action
?:
string
,
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
any
>
{
}
protected
async
beforeAction
(
action
?:
string
,
context
:
any
=
{},
data
:
any
=
{}):
Promise
<
any
>
{
}
/**
* 行为处理之后
*
* @protected
* @param {string} [action]
* @param {*} [context={}]
* @param {*} [response]
* @returns {Promise<any>}
* @memberof ControlServiceBase
*/
protected
async
onAfterAction
(
action
?:
string
,
context
:
any
=
{},
response
?:
any
):
Promise
<
any
>
{
// this.hiddenLoading();
this
.
afterAction
(
action
,
context
,
response
);
}
/**
* 行为处理之后
*
* @protected
* @param {string} [action]
* @param {*} [context={}]
* @param {*} [response]
* @returns {Promise<any>}
* @memberof ControlServiceBase
*/
protected
async
afterAction
(
action
?:
string
,
context
:
any
=
{},
response
?:
any
):
Promise
<
any
>
{
}
/**
/**
* 添加数据
* 添加数据
...
@@ -168,10 +128,9 @@ export class ControlServiceBase {
...
@@ -168,10 +128,9 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
* @memberof ControlServiceBase
*/
*/
public
async
add
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
public
async
add
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
let
response
:
any
;
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
try
{
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
let
response
:
HttpResponse
;
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
response
=
await
this
.
service
[
action
](
context
,
data
,
isLoading
);
response
=
await
this
.
service
[
action
](
context
,
data
,
isLoading
);
}
else
{
}
else
{
...
@@ -180,11 +139,6 @@ export class ControlServiceBase {
...
@@ -180,11 +139,6 @@ export class ControlServiceBase {
if
(
!
response
.
isError
())
{
if
(
!
response
.
isError
())
{
response
=
this
.
handleResponse
(
action
,
response
);
response
=
this
.
handleResponse
(
action
,
response
);
}
}
}
catch
(
error
)
{
console
.
error
(
error
);
}
finally
{
await
this
.
onAfterAction
(
action
,
context
,
response
);
}
return
response
;
return
response
;
}
}
...
@@ -199,10 +153,9 @@ export class ControlServiceBase {
...
@@ -199,10 +153,9 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
* @memberof ControlServiceBase
*/
*/
public
async
delete
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
public
async
delete
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
let
response
:
any
;
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
try
{
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
let
response
:
HttpResponse
;
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
response
=
await
this
.
service
[
action
](
context
,
data
,
isLoading
);
response
=
await
this
.
service
[
action
](
context
,
data
,
isLoading
);
}
else
{
}
else
{
...
@@ -211,11 +164,6 @@ export class ControlServiceBase {
...
@@ -211,11 +164,6 @@ export class ControlServiceBase {
if
(
!
response
.
isError
())
{
if
(
!
response
.
isError
())
{
response
=
this
.
handleResponse
(
action
,
response
);
response
=
this
.
handleResponse
(
action
,
response
);
}
}
}
catch
(
error
)
{
console
.
error
(
error
);
}
finally
{
await
this
.
onAfterAction
(
action
,
context
,
response
);
}
return
response
;
return
response
;
}
}
...
@@ -230,10 +178,9 @@ export class ControlServiceBase {
...
@@ -230,10 +178,9 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
* @memberof ControlServiceBase
*/
*/
public
async
update
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
public
async
update
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
let
response
:
any
;
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
try
{
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
let
response
:
HttpResponse
;
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
response
=
await
this
.
service
[
action
](
context
,
data
,
isLoading
);
response
=
await
this
.
service
[
action
](
context
,
data
,
isLoading
);
}
else
{
}
else
{
...
@@ -242,11 +189,6 @@ export class ControlServiceBase {
...
@@ -242,11 +189,6 @@ export class ControlServiceBase {
if
(
!
response
.
isError
())
{
if
(
!
response
.
isError
())
{
response
=
this
.
handleResponse
(
action
,
response
);
response
=
this
.
handleResponse
(
action
,
response
);
}
}
}
catch
(
error
){
console
.
error
(
error
)
}
finally
{
await
this
.
onAfterAction
(
action
,
context
,
response
);
}
return
response
;
return
response
;
}
}
...
@@ -261,10 +203,9 @@ export class ControlServiceBase {
...
@@ -261,10 +203,9 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
* @memberof ControlServiceBase
*/
*/
public
async
get
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
public
async
get
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
let
response
:
any
;
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
try
{
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
let
response
:
HttpResponse
;
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
response
=
await
this
.
service
[
action
](
context
,
data
,
isLoading
);
response
=
await
this
.
service
[
action
](
context
,
data
,
isLoading
);
}
else
{
}
else
{
...
@@ -273,11 +214,6 @@ export class ControlServiceBase {
...
@@ -273,11 +214,6 @@ export class ControlServiceBase {
if
(
!
response
.
isError
())
{
if
(
!
response
.
isError
())
{
response
=
this
.
handleResponse
(
action
,
response
);
response
=
this
.
handleResponse
(
action
,
response
);
}
}
}
catch
(
error
)
{
console
.
error
(
error
);
}
finally
{
await
this
.
onAfterAction
(
action
,
context
,
response
);
}
return
response
;
return
response
;
}
}
...
@@ -292,11 +228,9 @@ export class ControlServiceBase {
...
@@ -292,11 +228,9 @@ export class ControlServiceBase {
* @memberof ControlServiceBase
* @memberof ControlServiceBase
*/
*/
public
async
loadDraft
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
public
async
loadDraft
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
let
response
:
any
;
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
try
{
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
let
response
:
HttpResponse
;
let
PrimaryKey
=
Util
.
createUUID
();
let
PrimaryKey
=
Util
.
createUUID
();
//仿真主键数据
//仿真主键数据
data
[
this
.
appDeKey
]
=
PrimaryKey
;
data
[
this
.
appDeKey
]
=
PrimaryKey
;
...
@@ -311,11 +245,6 @@ export class ControlServiceBase {
...
@@ -311,11 +245,6 @@ export class ControlServiceBase {
this
.
mergeDefaults
(
response
);
this
.
mergeDefaults
(
response
);
}
}
response
.
data
[
this
.
appDeKey
]
=
PrimaryKey
;
response
.
data
[
this
.
appDeKey
]
=
PrimaryKey
;
}
catch
(
error
)
{
console
.
error
(
error
);
}
finally
{
await
this
.
onAfterAction
(
action
,
context
,
response
);
}
return
response
;
return
response
;
}
}
...
@@ -330,9 +259,7 @@ export class ControlServiceBase {
...
@@ -330,9 +259,7 @@ export class ControlServiceBase {
* @memberof EditServiceBase
* @memberof EditServiceBase
*/
*/
public
async
frontLogic
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
public
async
frontLogic
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isLoading
?:
boolean
):
Promise
<
HttpResponse
>
{
let
response
:
any
;
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
await
this
.
onBeforeAction
(
action
,
context
,
data
,
isLoading
);
try
{
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
data
=
this
.
handleRequestData
(
action
,
context
,
data
);
let
response
:
HttpResponse
;
let
response
:
HttpResponse
;
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
if
(
Util
.
isFunction
(
this
.
service
[
action
]))
{
...
@@ -343,11 +270,6 @@ export class ControlServiceBase {
...
@@ -343,11 +270,6 @@ export class ControlServiceBase {
if
(
!
response
.
isError
())
{
if
(
!
response
.
isError
())
{
response
=
this
.
handleResponse
(
action
,
response
,
true
);
response
=
this
.
handleResponse
(
action
,
response
,
true
);
}
}
}
catch
(
error
)
{
console
.
error
(
error
);
}
finally
{
await
this
.
onAfterAction
(
action
,
context
,
response
);
}
return
response
;
return
response
;
}
}
...
@@ -436,32 +358,5 @@ export class ControlServiceBase {
...
@@ -436,32 +358,5 @@ export class ControlServiceBase {
*/
*/
protected
mergeDefaults
(
response
:
any
=
{}):
void
{
}
protected
mergeDefaults
(
response
:
any
=
{}):
void
{
}
/**
* 开启加载动画
*
* @protected
* @returns {Promise<any>}
* @memberof ControlServiceBase
*/
protected
async
showLoading
():
Promise
<
any
>
{
if
(
this
.
$isLoading
===
false
)
{
this
.
$isLoading
=
true
;
Loading
.
show
();
}
}
/**
* 结束加载动画
*
* @protected
* @returns {Promise<any>}
* @memberof ControlServiceBase
*/
protected
async
hiddenLoading
():
Promise
<
any
>
{
if
(
this
.
$isLoading
===
true
)
{
Loading
.
hidden
();
this
.
$isLoading
=
false
;
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录