Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
db2cd321
提交
db2cd321
编写于
12月 28, 2021
作者:
WodahsOrez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updata: 表单
上级
19a9d975
变更
8
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
217 行增加
和
55 行删除
+217
-55
CodegenConfig.java
...-core/src/main/java/cn/ibizlab/codegen/CodegenConfig.java
+1
-1
controlAction.hbs
...s/templ/r7/@macro/front-end/view/common/controlAction.hbs
+11
-0
form-control.ts
...rc/ibiz-core/modules/widgets/form-control/form-control.ts
+200
-29
{{pages@DEEDITVIEW}}-config.ts.hbs
...}/{{pages@DEEDITVIEW}}/{{pages@DEEDITVIEW}}-config.ts.hbs
+1
-18
{{pages@DEGRIDVIEW}}-config.ts.hbs
...}/{{pages@DEGRIDVIEW}}/{{pages@DEGRIDVIEW}}-config.ts.hbs
+1
-0
{{appEntities}}-service-base.ts.hbs
...rvice/{{appEntities}}/{{appEntities}}-service-base.ts.hbs
+0
-2
{{ctrls@FORM}}-form-config.ts.hbs
...s}}/{{ctrls@FORM}}-form/{{ctrls@FORM}}-form-config.ts.hbs
+2
-4
{{ctrls@FORM}}-form-service.ts.hbs
...}}/{{ctrls@FORM}}-form/{{ctrls@FORM}}-form-service.ts.hbs
+1
-1
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/CodegenConfig.java
浏览文件 @
db2cd321
...
...
@@ -122,7 +122,7 @@ public class CodegenConfig {
}
else
{
String
path
=
file
.
getPath
().
replace
(
"\\"
,
"/"
);
templateDefinitions
.
add
(
new
TemplateDefinition
(
Paths
.
get
(
"/"
,
path
.
replace
(
this
.
getTemplateDir
(),
""
)
).
toString
()));
templateDefinitions
.
add
(
new
TemplateDefinition
(
path
.
replace
(
this
.
getTemplateDir
(),
""
).
toString
()));
}
}
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/@macro/front-end/view/common/controlAction.hbs
0 → 100644
浏览文件 @
db2cd321
controlsAction:{
{{#
each
page
.
ctrls
as
|
ctrl
|
}}
{{
ctrl
.
codeName
}}
:{
loadAction: '
{{
ctrl
.
getPSControlAction
.
psAppDEMethod
.
codeName
}}
',
removeAction: '
{{
ctrl
.
removePSControlAction
.
psAppDEMethod
.
codeName
}}
',
updateAction: '
{{
ctrl
.
updatePSControlAction
.
psAppDEMethod
.
codeName
}}
',
loadDraftAction: '
{{
ctrl
.
getDraftPSControlAction
.
psAppDEMethod
.
codeName
}}
',
createAction: '
{{
ctrl
.
getDraftPSControlAction
.
psAppDEMethod
.
codeName
}}
',
},
{{/
each
}}
}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/ibiz-core/modules/widgets/form-control/form-control.ts
浏览文件 @
db2cd321
...
...
@@ -5,9 +5,9 @@ import { deepCopy, FormControlProps, FormControlState, IActionParam, MainControl
* @export
* @class FormControl
* @extends {MainControl}
* @todo 部件加载loading,能否不写在行为方法里。
*/
export
class
FormControl
extends
MainControl
{
/**
* @description 部件状态
* @type {FormControlState}
...
...
@@ -16,63 +16,231 @@ export class FormControl extends MainControl {
public
declare
controlState
:
FormControlState
;
/**
* @description 表单数据改变
* 在表单数据改变(单一属性变化)时被调用。会依次执行以下逻辑:
* 1. 重置项逻辑
* 2. 表单项更新
* 3. 动态控制逻辑
* 4. 自动保存逻辑
*
* @param {string} name 属性名称
* @param {*} value 属性值
* @memberof FormControl
*/
public
formDataChange
(
name
:
string
,
value
:
any
){
public
formDataChange
(
name
:
string
,
value
:
any
)
{
this
.
controlState
.
data
[
name
]
=
value
;
console
.
log
(
name
,
value
,
this
.
controlState
.
data
);
// TODO 重置项逻辑
// TODO 表单项更新
// TODO 动态控制逻辑
// TODO 自动保存(可以单独做一个逻辑块,监听data的变化)
}
/**
* 在表单执行某些行为能力后,表单整体数据发生改变后被调用。会依次执行以下逻辑:
* 1.
*
* @param {string} action 调用的表单行为方法
*/
public
afterFormLoad
(
action
:
string
){
// 改变context当前实体主键,并抛出抽屉脏值的事件
// TODO 设置表单项启用(如果可以响应式变化则不用处理)
// 新建默认值和更新默认值
// TODO 动态控制逻辑
}
/**
* @description 使用加载功能模块
* @param {FormControlProps} props 传入的props
* @return {*}
* @return {*}
* @memberof FormControl
*/
public
useLoad
(
props
:
FormControlProps
){
public
useLoad
(
props
:
FormControlProps
)
{
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
const
load
=
async
(
opt
:
any
=
{})
=>
{
/**
* 加载行为
*
* @param [opt={}]
* @return {*}
*/
const
load
=
async
(
opt
:
any
=
{})
=>
{
try
{
const
loadAction
=
this
.
controlState
.
controlAction
.
loadAction
;
// 获取需要的状态变量
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
}
=
this
.
controlState
;
const
dataRef
=
toRef
(
this
.
controlState
,
'data'
);
if
(
!
loadAction
){
// 判断实体行为
const
loadAction
=
this
.
controlState
.
controlAction
.
loadAction
;
if
(
!
loadAction
)
{
return
;
}
// 处理请求参数
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
const
response
=
await
controlService
.
get
(
loadAction
,
_context
,
{
viewParams
:
_viewParams
},
showBusyIndicator
);
// 发起请求处理与解析请求
const
response
=
await
controlService
.
get
(
loadAction
,
_context
,
{
viewParams
:
_viewParams
},
showBusyIndicator
);
if
(
!
response
.
status
||
response
.
status
!==
200
)
{
return
return
;
}
dataRef
.
value
=
response
.
data
;
// 请求后处理
this
.
controlState
.
data
=
response
.
data
;
}
catch
(
error
)
{
// todo 错误异常处理
}
}
};
// 订阅viewSubject,监听load行为
if
(
viewSubject
)
{
let
subscription
=
viewSubject
.
subscribe
(({
tag
,
action
,
data
}:
IActionParam
)
=>
{
if
(
Object
.
is
(
controlName
,
tag
)
&&
Object
.
is
(
"load"
,
action
)
)
{
load
(
data
)
if
(
viewSubject
)
{
let
subscription
=
viewSubject
.
subscribe
(({
tag
,
action
,
data
}:
IActionParam
)
=>
{
if
(
Object
.
is
(
controlName
,
tag
)
&&
Object
.
is
(
'load'
,
action
))
{
load
(
data
)
;
}
})
});
// 部件卸载时退订viewSubject
onUnmounted
(()
=>
{
onUnmounted
(()
=>
{
subscription
.
unsubscribe
();
})
})
;
}
return
{
load
:
load
load
:
load
,
};
}
/**
* @description 使用保存功能模块
* @param {FormControlProps} props 传入的props
* @return {*}
* @memberof FormControl
*/
public
useSave
(
props
:
FormControlProps
)
{
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
/**
* 保存行为
*
* @param [opt={}]
* @return {*}
*/
const
save
=
async
(
opt
:
any
=
{})
=>
{
try
{
// 获取需要的状态变量
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
,
data
}
=
this
.
controlState
;
// TODO 值规则校验处理
// 判断实体行为
const
{
updateAction
,
createAction
}
=
this
.
controlState
.
controlAction
;
const
saveAction
:
any
=
data
.
srfuf
==
'1'
?
updateAction
:
createAction
;
if
(
!
saveAction
)
{
return
;
}
// 处理请求参数
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
// TODO 关系界面保存通知处理,做成异步。
// TODO 拷贝相关。
// 发起请求处理与解析请求
const
response
=
await
controlService
.
get
(
saveAction
,
_context
,
{
viewParams
:
_viewParams
},
showBusyIndicator
);
if
(
!
response
.
status
||
response
.
status
!==
200
)
{
// TODO 统一Error格式
return
;
}
// 请求后处理
this
.
controlState
.
data
=
response
.
data
;
// TODO 表单onFormLoad
}
catch
(
error
)
{
// TODO 错误异常处理
}
};
/**
* @description 使用删除功能模块
* @param {FormControlProps} props 传入的props
* @return {*}
* @memberof FormControl
*/
public
useRemove
(
props
:
FormControlProps
)
{
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
/**
* 删除行为
*
* @param [opt={}]
* @return {*}
*/
const
save
=
async
(
opt
:
any
=
{})
=>
{
try
{
// 获取需要的状态变量
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
,
data
}
=
this
.
controlState
;
// TODO 值规则校验处理
// 判断实体行为存在
const
{
updateAction
,
createAction
}
=
this
.
controlState
.
controlAction
;
const
saveAction
:
any
=
data
.
srfuf
==
'1'
?
updateAction
:
createAction
;
if
(
!
saveAction
)
{
return
;
}
// 处理请求参数
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
// TODO 关系界面保存通知处理,做成异步。
// TODO 拷贝相关。
// 发起请求处理与解析请求
const
response
=
await
controlService
.
get
(
saveAction
,
_context
,
{
viewParams
:
_viewParams
},
showBusyIndicator
);
if
(
!
response
.
status
||
response
.
status
!==
200
)
{
// TODO 统一Error格式
return
;
}
// 请求后处理
this
.
controlState
.
data
=
response
.
data
;
// TODO 表单onFormLoad
}
catch
(
error
)
{
// TODO 错误异常处理
}
};
// 订阅viewSubject,监听load行为
if
(
viewSubject
)
{
let
subscription
=
viewSubject
.
subscribe
(({
tag
,
action
,
data
}:
IActionParam
)
=>
{
if
(
Object
.
is
(
controlName
,
tag
)
&&
Object
.
is
(
'save'
,
action
))
{
save
(
data
);
}
});
// 部件卸载时退订viewSubject
onUnmounted
(()
=>
{
subscription
.
unsubscribe
();
});
}
return
{
save
:
save
,
};
}
/**
...
...
@@ -83,7 +251,7 @@ export class FormControl extends MainControl {
public
handleEditorEvent
(
actionParam
:
IActionParam
)
{
const
{
tag
,
action
,
data
}
=
actionParam
;
switch
(
action
)
{
case
"valueChange"
:
case
'valueChange'
:
this
.
formDataChange
(
tag
,
data
);
break
;
default
:
...
...
@@ -95,22 +263,25 @@ export class FormControl extends MainControl {
* @description 安装部件所有功能模块的方法
* @param {FormControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @return {*}
* @memberof FormControl [emit] 事件
*/
public
moduleInstall
(
props
:
FormControlProps
,
emit
?:
Function
)
{
const
superParams
=
super
.
moduleInstall
(
props
,
emit
);
const
{
load
}
=
this
.
useLoad
(
props
)
// 表单行为能力启用
const
{
load
}
=
this
.
useLoad
(
props
);
const
{
save
}
=
this
.
useSave
(
props
);
const
handleEditorEvent
=
this
.
handleEditorEvent
.
bind
(
this
);
this
.
handleEditorEvent
=
(
actionParam
:
IActionParam
)
=>
{
handleEditorEvent
(
actionParam
)
}
handleEditorEvent
(
actionParam
)
;
}
;
return
{
...
superParams
,
state
:
this
.
controlState
,
load
,
save
,
handleEditorEvent
:
this
.
handleEditorEvent
,
};
}
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/page/{{appModules}}/{{pages@DEEDITVIEW}}/{{pages@DEEDITVIEW}}-config.ts.hbs
浏览文件 @
db2cd321
...
...
@@ -13,23 +13,6 @@ export const ViewConfig = {
]
},
{{/
eq
}}
{{#
eq
controlType
"FORM"
}}
{{
lowerCase
codeName
}}
:{
name:'
{{
name
}}
',
codeName:'
{{
codeName
}}
',
action:{
'createAction': 'Create'
}
},
{{/
eq
}}
{{/
page
.
ctrls
}}
controlsAction:{
{{#
page
.
ctrls
}}
{{#
eq
controlType
"FORM"
}}
{{
codeName
}}
:{
'loadAction': 'Get'
},
{{/
eq
}}
{{/
page
.
ctrls
}}
}
{{>
@macro
/
front-end
/
view
/
common
/
controlAction
.
hbs
}
}
};
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/page/{{appModules}}/{{pages@DEGRIDVIEW}}/{{pages@DEGRIDVIEW}}-config.ts.hbs
浏览文件 @
db2cd321
...
...
@@ -4,4 +4,5 @@ export const ViewConfig = {
viewCaption: '
{{
page
.
caption
}}
',
gridRowActiveMode:
{{
page
.
gridRowActiveMode
}}
,
rowEditState:
{{#if
page
.
enableRowEdit
}}{{
page
.
rowEditDefault
}}{{else}}
false
{{/if}}
,
{{>
@macro
/
front-end
/
view
/
common
/
controlAction
.
hbs
}}
};
\ 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
浏览文件 @
db2cd321
...
...
@@ -59,8 +59,6 @@ export class {{pascalCase appEntity.codeName}}ServiceBase extends EntityService
const res = await this.http.get(`/
{{
pluralize
appEntity
.
codeName
}}
/${encodeURIComponent(_context.
{{
lowerCase
appEntity
.
codeName
}}
)}
{{
singleAppMethod
.
requestPath
}}
`, _data);
return res;
{{/
eq
}}
}
{{/
each
}}
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/widgets/{{appEntities}}/{{ctrls@FORM}}-form/{{ctrls@FORM}}-form-config.ts.hbs
浏览文件 @
db2cd321
import { ControlVOBase } from '@ibiz-core';
import { ControlService } from './
{{
lowerCase
ctrl
.
codeNam
e
}}
-form-service';
import { ControlService } from './
{{
ctrl
.
codeName
.
lowerCas
e
}}
-form-service';
export const CtrlConfig = {
controlCodeName: '
{{
ctrl
.
codeName
}}
',
...
...
@@ -16,9 +16,7 @@ export const CtrlConfig = {
export class ControlVO extends ControlVOBase {
// 表单里映射了属性的字段
{{#
each
ctrl
.
psDEFormItems
as
|
formItem
|
}}
{{!-- // 表单formItem
{{formItem.name}}
{{formItem.id}} --}}
{{!-- TODO: 表单formItem的name拿不到 --}}
{{#
neq
formItem
.
psAppDEField
null
}}
get
{{
lowerCase
formItem
.
id
}}
() {
return this.$DO.
{{
lowerCase
formItem
.
psAppDEField
.
codeName
}}
;
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/widgets/{{appEntities}}/{{ctrls@FORM}}-form/{{ctrls@FORM}}-form-service.ts.hbs
浏览文件 @
db2cd321
...
...
@@ -29,6 +29,6 @@ export class ControlService extends ControlServiceBase {
// this.setRemoteCopyData(response);
response.data = new ControlVO(response.data);
return this.handleResponse(response, opts);
}
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录