Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
6c8a509b
提交
6c8a509b
编写于
1月 10, 2022
作者:
Shine-zwj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update:更新表单
上级
78687765
变更
10
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
401 行增加
和
15 行删除
+401
-15
form-details-model.hbs
...ources/templ/r7/@macro/form-detail/form-details-model.hbs
+27
-0
form-control-state.ts
...c/core/modules/widgets/form-control/form-control-state.ts
+7
-0
form-control.ts
...s}}/src/core/modules/widgets/form-control/form-control.ts
+192
-13
grid-control.ts
...s}}/src/core/modules/widgets/grid-control/grid-control.ts
+0
-1
main-control-state.ts
...c/core/modules/widgets/main-control/main-control-state.ts
+14
-0
edit-form-service.ts
...s}}/src/core/service/control-service/edit-form-service.ts
+29
-0
data-types.ts
...ces/templ/r7/app_{{apps}}/src/core/utils/ui/data-types.ts
+99
-0
index.ts
...esources/templ/r7/app_{{apps}}/src/core/utils/ui/index.ts
+2
-1
util.ts
...in/resources/templ/r7/app_{{apps}}/src/core/utils/util.ts
+30
-0
{{ctrls@FORM}}-form-config.ts.hbs
...s}}/{{ctrls@FORM}}-form/{{ctrls@FORM}}-form-config.ts.hbs
+1
-0
未找到文件。
modules/ibizlab-generator-core/src/main/resources/templ/r7/@macro/form-detail/form-details-model.hbs
浏览文件 @
6c8a509b
...
...
@@ -11,6 +11,33 @@
dataType: '
{{
formDetail
.
dataType
}}
',
required:
{{#if
formDetail
.
allowEmpty
}}
false
{{else}}
true
{{/if}}
,
enableCond:
{{
formDetail
.
enableCond
}}
,
{{#if
formDetail
.
psDEFormItemUpdate
}}
formItemUpdate: {
{{#if
formDetail
.
psDEFormItemUpdate
.
customCode
}}
customCode:
{{
formDetail
.
psDEFormItemUpdate
.
customCode
}}
,
scriptCode: "
{{
formDetail
.
psDEFormItemUpdate
.
scriptCode
}}
",
{{else}}
showBusyIndicator: "
{{
formDetail
.
psDEFormItemUpdate
.
showBusyIndicator
}}
",
appDEMethod: "
{{
formDetail
.
psDEFormItemUpdate
.
psAppDEMethod
}}
",
updateDetails: [
{{#
each
formDetail
.
psDEFormItemUpdate
.
psDEFIUpdateDetails
as
|
updateDetails
|
}}
"
{{
updateDetails
.
codeName
}}
",
{{/
each
}}
],
{{/if}}
},
{{/if}}
{{#if
formDetail
.
createDVT
}}
createDVT: "
{{
formDetail
.
createDVT
}}
",
createDV: "
{{
formDetail
.
createDV
}}
",
{{/if}}
{{#if
formDetail
.
updateDVT
}}
updateDVT: "
{{
formDetail
.
updateDVT
}}
",
updateDV: "
{{
formDetail
.
updateDV
}}
",
{{/if}}
{{#if
formDetail
.
psAppDEField
}}
valueFormat: '
{{
formDetail
.
psAppDEField
.
valueFormat
}}
',
{{/if}}
{{#if
formDetail
.
resetItemName
}}
resetItemName: '
{{
formDetail
.
resetItemName
}}
',
{{/if}}
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/modules/widgets/form-control/form-control-state.ts
浏览文件 @
6c8a509b
...
...
@@ -35,4 +35,11 @@ export interface FormControlState extends MainControlState {
* @memberof FormControlState
*/
rules
:
IParam
;
/**
* @description 支持自动保存
* @type {boolean}
* @memberof FormControlState
*/
enableAutoSave
:
boolean
;
}
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/modules/widgets/form-control/form-control.ts
浏览文件 @
6c8a509b
import
{
deepCopy
,
FormControlProps
,
FormControlState
,
IActionParam
,
IParam
,
MainControl
,
UIUtil
,
verifyValue
}
from
'@core'
;
import
{
DataTypes
,
dateFormat
,
deepCopy
,
FormControlProps
,
FormControlState
,
IActionParam
,
IParam
,
MainControl
,
UIUtil
,
verifyValue
}
from
'@core'
;
/**
* @description 表单部件
...
...
@@ -57,7 +57,7 @@ export class FormControl extends MainControl {
public
formDataChange
(
name
:
string
,
value
:
any
)
{
this
.
controlState
.
data
[
name
]
=
value
;
this
.
resetFormData
(
name
);
// TODO 表单项更新
this
.
formItemUpdate
(
name
);
this
.
formDynamicLogic
(
name
);
// TODO 自动保存(可以单独做一个逻辑块,监听data的变化)
}
...
...
@@ -79,6 +79,40 @@ export class FormControl extends MainControl {
})
}
/**
* @description 表单项更新
* @param {string} name 表单项名称
* @memberof FormControl
*/
public
async
formItemUpdate
(
name
:
string
)
{
const
{
detailsModel
,
context
,
viewParams
,
controlService
}
=
this
.
controlState
;
const
{
data
}
=
toRefs
(
this
.
controlState
);
if
(
detailsModel
[
name
]
&&
detailsModel
[
name
].
formItemUpdate
)
{
const
formItemUpdate
=
detailsModel
[
name
].
formItemUpdate
;
if
(
formItemUpdate
.
customCode
)
{
if
(
formItemUpdate
.
scriptCode
)
{
eval
(
formItemUpdate
.
scriptCode
);
}
}
else
{
const
arg
=
Object
.
assign
(
deepCopy
(
viewParams
),
data
.
value
);
const
tempContext
=
deepCopy
(
context
);
const
response
=
await
controlService
.
frontLogic
(
tempContext
,
{
viewParams
:
arg
},
{
action
:
formItemUpdate
.
appDEMethod
,
isLoading
:
formItemUpdate
.
showBusyIndicator
},
);
if
(
response
.
status
&&
response
.
status
==
200
)
{
formItemUpdate
.
updateDetails
?.
forEach
((
detailsName
:
string
)
=>
{
if
(
data
.
value
.
hasOwnProperty
(
detailsName
))
{
data
.
value
[
detailsName
]
=
response
.
data
[
detailsName
];
}
})
this
.
afterFormAction
(
'formItemUpdate'
);
}
}
}
}
/**
* @description 表单动态逻辑
* @param {string} name 表单项名称
...
...
@@ -155,19 +189,11 @@ export class FormControl extends MainControl {
break
;
case
1
:
// 新建
if
(
Object
.
is
(
data
.
srfuf
,
'0'
))
{
item
.
disabled
=
true
;
}
else
{
item
.
disabled
=
false
;
}
item
.
disabled
=
data
.
srfuf
!=
0
;
break
;
case
2
:
// 更新
if
(
Object
.
is
(
data
.
srfuf
,
'1'
))
{
item
.
disabled
=
true
;
}
else
{
item
.
disabled
=
false
;
}
item
.
disabled
=
data
.
srfuf
!=
1
;
break
;
case
3
:
// 启用
...
...
@@ -210,7 +236,160 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
public
setDefaultValue
(
action
:
string
)
{
// TODO 新建默认值和更新默认值
switch
(
action
)
{
case
'loadDraft'
:
this
.
setCreateDefault
();
break
;
case
'load'
:
this
.
setUpdateDefault
();
break
;
}
}
/**
* @description 设置新建默认值
* @memberof FormControl
*/
public
setCreateDefault
()
{
const
{
detailsModel
,
context
,
viewParams
,
controlService
}
=
this
.
controlState
;
const
{
data
}
=
toRefs
(
this
.
controlState
);
Object
.
values
(
detailsModel
).
forEach
((
detail
:
IParam
)
=>
{
if
(
Object
.
is
(
detail
.
detailType
,
'FORMITEM'
))
{
if
((
detail
.
createDV
||
detail
.
createDVT
)
&&
data
.
value
.
hasOwnProperty
(
detail
.
codeName
))
{
switch
(
detail
.
createDVT
)
{
case
'CONTEXT'
:
data
.
value
[
detail
.
codeName
]
=
viewParams
[
detail
.
createDV
];
break
;
case
'SESSION'
:
data
.
value
[
detail
.
codeName
]
=
context
[
detail
.
createDV
];
break
;
case
'APPDATA'
:
data
.
value
[
detail
.
codeName
]
=
context
[
detail
.
createDV
];
break
;
case
'OPERATORNAME'
:
data
.
value
[
detail
.
codeName
]
=
context
[
'srfusername'
];
break
;
case
'OPERATOR'
:
data
.
value
[
detail
.
codeName
]
=
context
[
'srfuserid'
];
break
;
case
'CURTIME'
:
data
.
value
[
detail
.
codeName
]
=
dateFormat
(
new
Date
(),
detail
.
valueFormat
);
break
;
case
'PARAM'
:
data
.
value
[
detail
.
codeName
]
=
controlService
.
getRemoteCopyData
()?.[
detail
.
codeName
]
||
null
;
break
;
default
:
data
.
value
[
detail
.
codeName
]
=
DataTypes
.
isNumber
(
detail
.
dataType
)
?
Number
(
detail
?.
createDV
)
:
detail
?.
createDV
;
break
;
}
}
}
})
}
/**
* @description 设置更新默认值
* @memberof FormControl
*/
public
setUpdateDefault
()
{
const
{
detailsModel
,
context
,
viewParams
,
controlService
}
=
this
.
controlState
;
const
{
data
}
=
toRefs
(
this
.
controlState
);
Object
.
values
(
detailsModel
).
forEach
((
detail
:
IParam
)
=>
{
if
(
Object
.
is
(
detail
.
detailType
,
'FORMITEM'
))
{
if
((
detail
.
updateDV
||
detail
.
updateDVT
)
&&
data
.
value
.
hasOwnProperty
(
detail
.
codeName
))
{
switch
(
detail
.
updateDVT
)
{
case
'CONTEXT'
:
data
.
value
[
detail
.
codeName
]
=
viewParams
[
detail
.
updateDV
];
break
;
case
'SESSION'
:
data
.
value
[
detail
.
codeName
]
=
context
[
detail
.
updateDV
];
break
;
case
'APPDATA'
:
data
.
value
[
detail
.
codeName
]
=
context
[
detail
.
updateDV
];
break
;
case
'OPERATORNAME'
:
data
.
value
[
detail
.
codeName
]
=
context
[
'srfusername'
];
break
;
case
'OPERATOR'
:
data
.
value
[
detail
.
codeName
]
=
context
[
'srfuserid'
];
break
;
case
'CURTIME'
:
data
.
value
[
detail
.
codeName
]
=
dateFormat
(
new
Date
(),
detail
.
valueFormat
);
break
;
case
'PARAM'
:
data
.
value
[
detail
.
codeName
]
=
controlService
.
getRemoteCopyData
()?.[
detail
.
codeName
]
||
null
;
break
;
default
:
data
.
value
[
detail
.
codeName
]
=
DataTypes
.
isNumber
(
detail
.
dataType
)
?
Number
(
detail
.
updateDV
)
:
detail
.
updateDV
;
break
;
}
}
}
})
}
/**
* @description 使用加载草稿功能模块
* @param {FormControlProps} props 传入的props
* @return {*}
* @memberof FormControl
*/
public
useLoadDraft
(
props
:
FormControlProps
)
{
const
{
viewSubject
,
controlName
}
=
this
.
controlState
;
/**
* 加载行为
*
* @param [opt={}]
* @return {*}
*/
const
loadDraft
=
async
(
opt
:
any
=
{})
=>
{
try
{
const
{
controlService
,
context
,
viewParams
,
showBusyIndicator
,
controlAction
,
appDeKeyFieldName
}
=
this
.
controlState
;
const
{
data
}
=
toRefs
(
this
.
controlState
);
if
(
!
controlAction
.
loadDraftAction
)
{
return
;
}
// 处理请求参数
let
_context
=
deepCopy
(
context
);
let
_viewParams
=
deepCopy
(
viewParams
);
// 发起请求处理与解析请求
const
response
=
await
controlService
.
loadDraft
(
_context
,
{
viewParams
:
_viewParams
},
{
action
:
controlAction
.
loadDraftAction
,
isLoading
:
showBusyIndicator
},
);
if
(
response
.
status
&&
response
.
status
==
200
)
{
if
(
appDeKeyFieldName
&&
response
.
data
[
appDeKeyFieldName
])
{
response
.
data
[
appDeKeyFieldName
]
=
null
;
}
data
.
value
=
response
.
data
;
this
.
afterFormAction
(
'loadDraft'
);
}
}
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
(
'loadDraft'
,
action
))
{
loadDraft
(
data
);
}
});
// 部件卸载时退订viewSubject
onUnmounted
(()
=>
{
subscription
.
unsubscribe
();
});
}
return
{
load
:
loadDraft
,
};
}
/**
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/modules/widgets/grid-control/grid-control.ts
浏览文件 @
6c8a509b
...
...
@@ -314,7 +314,6 @@ export class GridControl extends MainControl {
}
});
_columnsModel
.
forEach
((
column
:
IParam
)
=>
{
console
.
log
(
this
.
getAggValue
(
dataAgg
,
column
));
aggData
.
push
(
this
.
getAggValue
(
dataAgg
,
column
))
});
}
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/modules/widgets/main-control/main-control-state.ts
浏览文件 @
6c8a509b
...
...
@@ -42,4 +42,18 @@ export interface MainControlState extends ControlStateBase {
* @memberof MainControlState
*/
appDeCodeName
:
string
;
/**
* @description 应用实体主键属性codeName
* @type {string}
* @memberof MainControlState
*/
appDeKeyFieldName
:
string
;
/**
* @description 应用实体主信息属性codeName
* @type {string}
* @memberof MainControlState
*/
appDeMajorFieldName
:
string
;
}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/service/control-service/edit-form-service.ts
浏览文件 @
6c8a509b
...
...
@@ -96,4 +96,33 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase
response
.
data
=
this
.
newControlVO
(
response
.
data
);
return
this
.
handleResponse
(
response
,
opts
);
}
/**
* 前台逻辑
*
* @param [context={}] 上下文参数
* @param [data={}] 视图参数
* @param opts
* @return {*}
*/
public
async
frontLogic
(
context
:
any
,
data
:
any
,
opts
:
{
action
:
string
;
isLoading
?:
boolean
}):
Promise
<
any
>
{
let
_entityService
:
any
=
this
.
entityService
;
const
{
context
:
Context
,
data
:
Data
}
=
this
.
handleRequestData
(
context
,
data
,
opts
);
if
(
hasFunction
(
_entityService
,
opts
.
action
))
{
const
response
=
await
_entityService
[
opts
.
action
](
Context
,
Data
,
opts
.
isLoading
);
response
.
data
=
this
.
newControlVO
(
response
.
data
);
return
this
.
handleResponse
(
response
,
opts
);
}
else
{
return
}
}
/**
* @description 获取远端数据
* @return {*}
* @memberof EditFormService
*/
public
getRemoteCopyData
()
{
// return this.remoteCopyData;
}
}
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/utils/ui/data-types.ts
0 → 100644
浏览文件 @
6c8a509b
/**
* 数据类型
*
*/
export
class
DataTypes
{
static
readonly
DataTypes
:
any
=
{
UNKNOWN
:
0
,
//
BIGINT
:
1
,
BINARY
:
2
,
BIT
:
3
,
CHAR
:
4
,
DATETIME
:
5
,
DECIMAL
:
6
,
FLOAT
:
7
,
IMAGE
:
8
,
INT
:
9
,
MONEY
:
10
,
NCHAR
:
11
,
NTEXT
:
12
,
NVARCHAR
:
13
,
NUMERIC
:
14
,
REAL
:
15
,
SMALLDATETIME
:
16
,
SMALLINT
:
17
,
SMALLMONEY
:
18
,
SQL_VARIANT
:
19
,
SYSNAME
:
20
,
TEXT
:
21
,
TIMESTAMP
:
22
,
TINYINT
:
23
,
VARBINARY
:
24
,
VARCHAR
:
25
,
UNIQUEIDENTIFIER
:
26
,
DATE
:
27
,
// 纯日期型
TIME
:
28
,
// 纯时间
BIGDECIMAL
:
29
,
// 大数值
}
/**
* @description 是否忽略大小写
* @protected
* @static
* @param {string} value
* @param {string} value2
* @return {*}
* @memberof DataTypes
*/
protected
static
equalsIgnoreCase
(
value
:
string
,
value2
:
string
){
return
value
.
toLocaleLowerCase
()
==
value2
.
toLocaleLowerCase
();
}
/**
* @description 字符串转数值
* @static
* @param {string} strValue
* @return {*} {number}
* @memberof DataTypes
*/
public
static
fromString
(
strValue
:
string
):
number
{
let
result
=
this
.
DataTypes
[
strValue
.
toUpperCase
()];
return
result
||
this
.
DataTypes
.
VARCHAR
;
}
/**
* @description 是否为number类型
* @static
* @param {string} strValue
* @return {*} {boolean}
* @memberof DataTypes
*/
public
static
isNumber
(
strValue
:
string
):
boolean
{
const
numberTypes
:
any
[]
=
[
'BIGINT'
,
'BINARY'
,
'DECIMAL'
,
'FLOAT'
,
'INT'
,
'MONEY'
,
'NUMERIC'
,
'REAL'
,
'SMALLINT'
,
'SMALLMONEY'
,
'TINYINT'
,
'VARBINARY'
];
if
(
numberTypes
.
indexOf
(
strValue
)
!==
-
1
){
return
true
;
}
else
{
return
false
}
}
/**
* @description 获取字符串名称
* @static
* @param {number} nDataType
* @return {*}
* @memberof DataTypes
*/
public
static
toString
(
nDataType
:
number
)
{
let
result
=
'VARCHAR'
;
for
(
let
key
in
this
.
DataTypes
){
if
(
nDataType
==
this
.
DataTypes
[
key
]){
result
=
key
;
break
;
}
}
return
result
;
}
}
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/utils/ui/index.ts
浏览文件 @
6c8a509b
...
...
@@ -2,4 +2,5 @@ export { RouteUtil } from './route-util';
export
{
UIUtil
}
from
'./ui-util'
;
export
{
UIActionUtil
}
from
'./uiaction-util'
;
export
{
ViewUtil
}
from
'./view-util'
;
export
{
AppUtil
}
from
'./app-util'
;
\ No newline at end of file
export
{
AppUtil
}
from
'./app-util'
;
export
{
DataTypes
}
from
'./data-types'
;
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/utils/util.ts
浏览文件 @
6c8a509b
...
...
@@ -10,6 +10,36 @@ export function deepCopy(data: Record<any, any>): Record<any, any>{
return
clone
(
data
)
}
/**
* @description 日期格式化
* @export
* @param {*} date 日期对象
* @param {string} [fmt='YYYY-MM-DD HH:mm:ss'] 格式化
* @return {*} {string}
*/
export
function
dateFormat
(
date
:
any
,
fmt
:
string
=
'YYYY-MM-DD HH:mm:ss'
):
string
{
let
ret
;
const
opt
:
any
=
{
'Y+'
:
date
.
getFullYear
().
toString
(),
// 年
'M+'
:
(
date
.
getMonth
()
+
1
).
toString
(),
// 月
'd+'
:
date
.
getDate
().
toString
(),
// 日
'D+'
:
date
.
getDate
().
toString
(),
// 日
'H+'
:
date
.
getHours
().
toString
(),
// 时
'h+'
:
date
.
getHours
().
toString
(),
// 时
'm+'
:
date
.
getMinutes
().
toString
(),
// 分
's+'
:
date
.
getSeconds
().
toString
(),
// 秒
'S+'
:
date
.
getSeconds
().
toString
()
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for
(
let
k
in
opt
)
{
ret
=
new
RegExp
(
'('
+
k
+
')'
).
exec
(
fmt
);
if
(
ret
)
{
fmt
=
fmt
.
replace
(
ret
[
1
],
ret
[
1
].
length
==
1
?
opt
[
k
]
:
opt
[
k
].
padStart
(
ret
[
1
].
length
,
'0'
));
}
}
return
fmt
;
}
/**
* @description 除undefined,null,NaN以外都为true
* @export
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/widgets/{{appEntities}}/{{ctrls@FORM}}-form/{{ctrls@FORM}}-form-config.ts.hbs
浏览文件 @
6c8a509b
...
...
@@ -52,6 +52,7 @@ export const CtrlConfig = {
controlName: '
{{
ctrl
.
name
}}
',
controlService: new EditFormService
<ControlVO>
(ControlVO, new
{{
pascalCase
ctrl
.
psAppDataEntity
.
codeName
}}
Service() ),
data: new ControlVO({}),
enableAutoSave:
{{
ctrl
.
enableAutoSave
}}
,
detailsModel: {
{{#
each
ctrl
.
psDEFormPages
as
|
FormPage
|
}}
{{>
(
lookup
'FORMDETAILSMODEL'
)
items
=
FormPage
.
psDEFormDetails
}}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录