Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
c8e48f99
提交
c8e48f99
编写于
12月 29, 2021
作者:
WodahsOrez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update: 表单部件服务
上级
67c0d6a9
变更
7
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
133 行增加
和
29 行删除
+133
-29
form-control.ts
...rc/ibiz-core/modules/widgets/form-control/form-control.ts
+106
-21
control-vo-base.ts
...pps}}/src/ibiz-core/runtime/control-vo/control-vo-base.ts
+15
-0
control-service-base.ts
...ibiz-core/service/control-service/control-service-base.ts
+1
-1
entity-service.ts
...p_{{apps}}/src/ibiz-core/service/entity/entity-service.ts
+3
-0
{{appEntities}}-service-base.ts.hbs
...ntity/{{appEntities}}/{{appEntities}}-service-base.ts.hbs
+0
-0
{{appEntities}}-service.ts.hbs
...ice/entity/{{appEntities}}/{{appEntities}}-service.ts.hbs
+0
-0
{{ctrls@FORM}}-form-service.ts.hbs
...}}/{{ctrls@FORM}}-form/{{ctrls@FORM}}-form-service.ts.hbs
+8
-7
未找到文件。
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/ibiz-core/modules/widgets/form-control/form-control.ts
浏览文件 @
c8e48f99
...
@@ -40,14 +40,10 @@ export class FormControl extends MainControl {
...
@@ -40,14 +40,10 @@ export class FormControl extends MainControl {
*
*
* @param {string} action 调用的表单行为方法
* @param {string} action 调用的表单行为方法
*/
*/
public
afterFormLoad
(
action
:
string
){
public
afterFormLoad
(
action
:
string
)
{
// 改变context当前实体主键,并抛出抽屉脏值的事件
// 改变context当前实体主键,并抛出抽屉脏值的事件
// TODO 设置表单项启用(如果可以响应式变化则不用处理)
// TODO 设置表单项启用(如果可以响应式变化则不用处理)
// 新建默认值和更新默认值
// 新建默认值和更新默认值
// TODO 动态控制逻辑
// TODO 动态控制逻辑
}
}
...
@@ -82,16 +78,23 @@ export class FormControl extends MainControl {
...
@@ -82,16 +78,23 @@ export class FormControl extends MainControl {
let
_viewParams
=
deepCopy
(
viewParams
);
let
_viewParams
=
deepCopy
(
viewParams
);
// 发起请求处理与解析请求
// 发起请求处理与解析请求
const
response
=
await
controlService
.
get
(
loadAction
,
_context
,
{
viewParams
:
_viewParams
},
showBusyIndicator
);
const
response
=
await
controlService
.
get
(
_context
,
{
viewParams
:
_viewParams
},
{
action
:
loadAction
,
isLoading
:
showBusyIndicator
,
},
);
if
(
!
response
.
status
||
response
.
status
!==
200
)
{
if
(
!
response
.
status
||
response
.
status
!==
200
)
{
return
;
return
;
}
}
// 请求后处理
// 请求后处理
this
.
controlState
.
data
=
response
.
data
;
this
.
controlState
.
data
=
response
.
data
;
}
catch
(
error
)
{
}
catch
(
error
)
{
// todo 错误异常处理
// TODO 错误异常处理
console
.
log
(
error
);
}
}
};
};
...
@@ -136,10 +139,10 @@ export class FormControl extends MainControl {
...
@@ -136,10 +139,10 @@ export class FormControl extends MainControl {
// TODO 值规则校验处理
// TODO 值规则校验处理
// 判断实体行为
// 判断实体行为
const
{
updateAction
,
createAction
}
=
this
.
controlState
.
controlAction
;
const
{
updateAction
,
createAction
}
=
this
.
controlState
.
controlAction
;
const
saveAction
:
any
=
data
.
srfuf
==
'1'
?
updateAction
:
createAction
;
const
saveAction
:
any
=
data
.
srfuf
==
'1'
?
updateAction
:
createAction
;
const
saveFunName
=
data
.
srfuf
==
'1'
?
'update'
:
'create'
;
if
(
!
saveAction
)
{
if
(
!
saveAction
)
{
return
;
return
;
}
}
...
@@ -147,13 +150,23 @@ export class FormControl extends MainControl {
...
@@ -147,13 +150,23 @@ export class FormControl extends MainControl {
// 处理请求参数
// 处理请求参数
let
_context
=
deepCopy
(
context
);
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
let
_viewParams
=
deepCopy
(
viewParams
);
const
arg
:
any
=
{
...
opt
};
Object
.
assign
(
arg
,
data
.
getDo
());
Object
.
assign
(
arg
,
{
viewParams
:
_viewParams
});
// TODO 关系界面保存通知处理,做成异步。
// TODO 关系界面保存通知处理,做成异步。
// TODO 拷贝相关。
// TODO 拷贝相关。
// 发起请求处理与解析请求
// 发起请求处理与解析请求
const
response
=
await
controlService
.
get
(
saveAction
,
_context
,
{
viewParams
:
_viewParams
},
showBusyIndicator
);
const
response
=
await
controlService
[
saveFunName
](
_context
,
arg
,
{
action
:
saveAction
,
isLoading
:
showBusyIndicator
,
},
);
if
(
!
response
.
status
||
response
.
status
!==
200
)
{
if
(
!
response
.
status
||
response
.
status
!==
200
)
{
// TODO 统一Error格式
// TODO 统一Error格式
return
;
return
;
...
@@ -163,9 +176,9 @@ export class FormControl extends MainControl {
...
@@ -163,9 +176,9 @@ export class FormControl extends MainControl {
this
.
controlState
.
data
=
response
.
data
;
this
.
controlState
.
data
=
response
.
data
;
// TODO 表单onFormLoad
// TODO 表单onFormLoad
}
catch
(
error
)
{
}
catch
(
error
)
{
// TODO 错误异常处理
// TODO 错误异常处理
console
.
log
(
error
);
}
}
};
};
...
@@ -187,6 +200,78 @@ export class FormControl extends MainControl {
...
@@ -187,6 +200,78 @@ export class FormControl extends MainControl {
};
};
}
}
/**
* @description 使用加载功能模块
* @param {FormControlProps} props 传入的props
* @return {*}
* @memberof FormControl
*/
public
useRemove
(
props
:
FormControlProps
)
{
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
/**
* 删除行为
*
* @param [opt={}]
* @return {*}
*/
const
remove
=
async
(
opt
:
any
=
{})
=>
{
try
{
// 获取需要的状态变量
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
}
=
this
.
controlState
;
// 判断实体行为
const
removeAction
=
this
.
controlState
.
controlAction
.
removeAction
;
if
(
!
removeAction
)
{
return
;
}
// 处理请求参数
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
const
arg
:
any
=
opt
[
0
];
Object
.
assign
(
arg
,
{
viewParams
:
_viewParams
},);
// 发起请求处理与解析请求
const
response
=
await
controlService
.
remove
(
_context
,
arg
,
{
action
:
removeAction
,
isLoading
:
showBusyIndicator
},
);
if
(
!
response
.
status
||
response
.
status
!==
200
)
{
return
;
}
// 请求后处理
this
.
controlState
.
data
=
response
.
data
;
}
catch
(
error
)
{
// TODO 错误异常处理
console
.
log
(
error
);
}
};
// 订阅viewSubject,监听load行为
if
(
viewSubject
)
{
let
subscription
=
viewSubject
.
subscribe
(({
tag
,
action
,
data
}:
IActionParam
)
=>
{
if
(
Object
.
is
(
controlName
,
tag
)
&&
Object
.
is
(
'load'
,
action
))
{
remove
(
data
);
}
});
// 部件卸载时退订viewSubject
onUnmounted
(()
=>
{
subscription
.
unsubscribe
();
});
}
return
{
remove
:
remove
,
};
}
/**
/**
* @description 处理编辑器事件
* @description 处理编辑器事件
* @param {IActionParam} actionParam 行为参数
* @param {IActionParam} actionParam 行为参数
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/ibiz-core/runtime/control-vo/control-vo-base.ts
浏览文件 @
c8e48f99
...
@@ -12,6 +12,21 @@ export class ControlVOBase {
...
@@ -12,6 +12,21 @@ export class ControlVOBase {
*/
*/
public
$ownKeys
:
string
[]
=
[];
public
$ownKeys
:
string
[]
=
[];
/**
* "0"是新建数据,"1"是已存在的数据
*/
get
srfuf
(){
if
(
this
.
$DO
.
srfuf
){
return
this
.
$DO
.
srfuf
}
else
{
return
this
.
srfkey
?
"1"
:
"0"
}
}
set
srfuf
(
value
:
any
){
this
.
$DO
.
srfuf
=
value
;
}
/**
/**
* 用后台数据对象创建部件数据对象
* 用后台数据对象创建部件数据对象
* @param data 后台数据
* @param data 后台数据
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/ibiz-core/service/control-service/control-service-base.ts
浏览文件 @
c8e48f99
...
@@ -18,7 +18,7 @@ export class ControlServiceBase {
...
@@ -18,7 +18,7 @@ export class ControlServiceBase {
* @param [opts={}]
* @param [opts={}]
*/
*/
public
handleResponse
(
response
:
any
,
opts
:
any
=
{})
{
public
handleResponse
(
response
:
any
,
opts
:
any
=
{})
{
//
todo srfuf判断
//
TODO 转化代码表
return
response
;
return
response
;
}
}
}
}
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/ibiz-core/service/entity/entity-service.ts
浏览文件 @
c8e48f99
...
@@ -6,6 +6,8 @@ import { Http } from '@ibiz-core';
...
@@ -6,6 +6,8 @@ import { Http } from '@ibiz-core';
*/
*/
export
class
EntityService
{
export
class
EntityService
{
[
key
:
string
]:
any
;
constructor
(
opts
?:
any
)
{
constructor
(
opts
?:
any
)
{
}
}
...
@@ -14,4 +16,5 @@ export class EntityService{
...
@@ -14,4 +16,5 @@ export class EntityService{
// TODO
// TODO
public
GET
(){}
public
GET
(){}
}
}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/service/{{appEntities}}/{{appEntities}}-service-base.ts.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/service/
entity/
{{appEntities}}/{{appEntities}}-service-base.ts.hbs
浏览文件 @
c8e48f99
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/service/{{appEntities}}/{{appEntities}}-service.ts.hbs
→
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/service/
entity/
{{appEntities}}/{{appEntities}}-service.ts.hbs
浏览文件 @
c8e48f99
文件已移动
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/widgets/{{appEntities}}/{{ctrls@FORM}}-form/{{ctrls@FORM}}-form-service.ts.hbs
浏览文件 @
c8e48f99
import { ControlServiceBase, hasFunction } from '@ibiz-core';
import { ControlServiceBase, hasFunction } from '@ibiz-core';
import { createUUID } from 'qx-util';
import { createUUID } from 'qx-util';
import {
{{
pascalCase
ctrl
.
psAppDataEntity
.
codeName
}}
Service } from '@service/
{{
spinalCase
ctrl
.
psAppDataEntity
.
codeName
}}
/
{{
spinalCase
ctrl
.
psAppDataEntity
.
codeName
}}
-service';
import {
{{
pascalCase
ctrl
.
psAppDataEntity
.
codeName
}}
Service } from '@service/
entity/
{{
spinalCase
ctrl
.
psAppDataEntity
.
codeName
}}
/
{{
spinalCase
ctrl
.
psAppDataEntity
.
codeName
}}
-service';
import { ControlVO } from './
{{
spinalCase
ctrl
.
codeName
}}
-form-config';
import { ControlVO } from './
{{
spinalCase
ctrl
.
codeName
}}
-form-config';
export class ControlService extends ControlServiceBase {
export class ControlService extends ControlServiceBase {
...
@@ -22,9 +22,10 @@ export class ControlService extends ControlServiceBase {
...
@@ -22,9 +22,10 @@ export class ControlService extends ControlServiceBase {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
// todo主键
// todo主键
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GetDraft';
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GetDraft';
const response = await this.entityService[
opts.
action](Context, Data, opts.isLoading);
const response = await this.entityService[action](Context, Data, opts.isLoading);
// this.setRemoteCopyData(response);
// this.setRemoteCopyData(response);
response.data = new ControlVO(response.data);
response.data = new ControlVO(response.data);
response.data.srfuf = "0";
return this.handleResponse(response, opts);
return this.handleResponse(response, opts);
}
}
...
@@ -39,7 +40,7 @@ export class ControlService extends ControlServiceBase {
...
@@ -39,7 +40,7 @@ export class ControlService extends ControlServiceBase {
public async get(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise
<any>
{
public async get(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise
<any>
{
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GET';
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GET';
const response = await this.entityService[
opts.
action](Context, Data, opts.isLoading);
const response = await this.entityService[action](Context, Data, opts.isLoading);
// this.setRemoteCopyData(response);
// this.setRemoteCopyData(response);
response.data = new ControlVO(response.data);
response.data = new ControlVO(response.data);
return this.handleResponse(response, opts);
return this.handleResponse(response, opts);
...
@@ -56,7 +57,7 @@ export class ControlService extends ControlServiceBase {
...
@@ -56,7 +57,7 @@ export class ControlService extends ControlServiceBase {
public async create(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise
<any>
{
public async create(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise
<any>
{
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Create';
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Create';
const response = await this.entityService[
opts.
action](Context, Data, opts.isLoading);
const response = await this.entityService[action](Context, Data, opts.isLoading);
response.data = new ControlVO(response.data);
response.data = new ControlVO(response.data);
return this.handleResponse(response, opts);
return this.handleResponse(response, opts);
}
}
...
@@ -69,10 +70,10 @@ export class ControlService extends ControlServiceBase {
...
@@ -69,10 +70,10 @@ export class ControlService extends ControlServiceBase {
* @param opts
* @param opts
* @return {*}
* @return {*}
*/
*/
public async
delet
e(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise
<any>
{
public async
remov
e(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise
<any>
{
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Remove';
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Remove';
const response = await this.entityService[
opts.
action](Context, Data, opts.isLoading);
const response = await this.entityService[action](Context, Data, opts.isLoading);
response.data = new ControlVO(response.data);
response.data = new ControlVO(response.data);
return this.handleResponse(response, opts);
return this.handleResponse(response, opts);
}
}
...
@@ -88,7 +89,7 @@ export class ControlService extends ControlServiceBase {
...
@@ -88,7 +89,7 @@ export class ControlService extends ControlServiceBase {
public async update(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise
<any>
{
public async update(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise
<any>
{
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Update';
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Update';
const response = await this.entityService[
opts.
action](Context, Data, opts.isLoading);
const response = await this.entityService[action](Context, Data, opts.isLoading);
response.data = new ControlVO(response.data);
response.data = new ControlVO(response.data);
return this.handleResponse(response, opts);
return this.handleResponse(response, opts);
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录