Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
F
formbase
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
formexample_angular
formbase
提交
ded3dc37
提交
ded3dc37
编写于
7月 30, 2020
作者:
ibizdev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SYSTEM 发布系统代码
上级
3fc7ed66
变更
20
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
742 行增加
和
326 行删除
+742
-326
app-routing.module.ts
app_Default/src/app/app-routing.module.ts
+8
-0
app.component.html
app_Default/src/app/app.component.html
+2
-0
example-main8-edit-view.html
...mple/example-main8-edit-view/example-main8-edit-view.html
+2
-0
example-main8-edit-view.less
...mple/example-main8-edit-view/example-main8-edit-view.less
+1
-0
example-main8-edit-view.module.ts
...example-main8-edit-view/example-main8-edit-view.module.ts
+38
-0
example-main8-edit-view.ts
...apmple/example-main8-edit-view/example-main8-edit-view.ts
+22
-0
entity3-main9-edit-view.html
...ule3/entity3-main9-edit-view/entity3-main9-edit-view.html
+2
-0
entity3-main9-edit-view.less
...ule3/entity3-main9-edit-view/entity3-main9-edit-view.less
+1
-0
entity3-main9-edit-view.module.ts
...entity3-main9-edit-view/entity3-main9-edit-view.module.ts
+38
-0
entity3-main9-edit-view.ts
...odule3/entity3-main9-edit-view/entity3-main9-edit-view.ts
+22
-0
main.html
app_Default/src/widgets/entity3/main/main.html
+5
-191
main.ts
app_Default/src/widgets/entity3/main/main.ts
+3
-135
main9.html
app_Default/src/widgets/entity3/main9/main9.html
+6
-0
main9.less
app_Default/src/widgets/entity3/main9/main9.less
+19
-0
main9.module.ts
app_Default/src/widgets/entity3/main9/main9.module.ts
+36
-0
main9.ts
app_Default/src/widgets/entity3/main9/main9.ts
+238
-0
main8.html
app_Default/src/widgets/example/main8/main8.html
+6
-0
main8.less
app_Default/src/widgets/example/main8/main8.less
+19
-0
main8.module.ts
app_Default/src/widgets/example/main8/main8.module.ts
+36
-0
main8.ts
app_Default/src/widgets/example/main8/main8.ts
+238
-0
未找到文件。
app_Default/src/app/app-routing.module.ts
浏览文件 @
ded3dc37
...
...
@@ -18,6 +18,10 @@ const routes: Routes = [
path
:
'exapmple_examplemain3editview'
,
loadChildren
:
'@pages/exapmple/example-main3-edit-view/example-main3-edit-view.module#ExampleMain3EditViewModule'
},
{
path
:
'module3_entity3main9editview'
,
loadChildren
:
'@pages/module3/entity3-main9-edit-view/entity3-main9-edit-view.module#Entity3Main9EditViewModule'
},
{
path
:
'module_entityeditview'
,
loadChildren
:
'@pages/module/entity-edit-view/entity-edit-view.module#EntityEditViewModule'
...
...
@@ -66,6 +70,10 @@ const routes: Routes = [
path
:
'module2_entity2editview'
,
loadChildren
:
'@pages/module2/entity2-edit-view/entity2-edit-view.module#Entity2EditViewModule'
},
{
path
:
'exapmple_examplemain8editview'
,
loadChildren
:
'@pages/exapmple/example-main8-edit-view/example-main8-edit-view.module#ExampleMain8EditViewModule'
},
{
path
:
'exapmple_examplemain4editview'
,
loadChildren
:
'@pages/exapmple/example-main4-edit-view/example-main4-edit-view.module#ExampleMain4EditViewModule'
...
...
app_Default/src/app/app.component.html
浏览文件 @
ded3dc37
...
...
@@ -4,6 +4,7 @@
<li
nz-menu-item
(
click
)="
onClick
('
module5_entity5main5editview
')"
>
表单5
</li>
<li
nz-menu-item
(
click
)="
onClick
('
module4_entity4main7editview
')"
>
111111
</li>
<li
nz-menu-item
(
click
)="
onClick
('
exapmple_examplemain3editview
')"
>
模拟
</li>
<li
nz-menu-item
(
click
)="
onClick
('
module3_entity3main9editview
')"
>
表单9
</li>
<li
nz-menu-item
(
click
)="
onClick
('
module_entityeditview
')"
>
实体编辑视图
</li>
<li
nz-menu-item
(
click
)="
onClick
('
exapmple_exampleeditortype
')"
>
基础编辑器
</li>
<li
nz-menu-item
(
click
)="
onClick
('
exapmple_exampleeditview
')"
>
基础表单项
</li>
...
...
@@ -16,6 +17,7 @@
<li
nz-menu-item
(
click
)="
onClick
('
exapmple_exampledlfeditview
')"
>
表单项动态逻辑示例
</li>
<li
nz-menu-item
(
click
)="
onClick
('
exapmple_examplemain5editview
')"
>
表单5
</li>
<li
nz-menu-item
(
click
)="
onClick
('
module2_entity2editview
')"
>
实体2编辑视图
</li>
<li
nz-menu-item
(
click
)="
onClick
('
exapmple_examplemain8editview
')"
>
表单8
</li>
<li
nz-menu-item
(
click
)="
onClick
('
exapmple_examplemain4editview
')"
>
表单4
</li>
</ul>
</nz-sider>
...
...
app_Default/src/pages/exapmple/example-main8-edit-view/example-main8-edit-view.html
0 → 100644
浏览文件 @
ded3dc37
<div
style=
"background: #fff;height: 100%;padding: 16px;overflow: auto;"
>
<main8-form
(
dataChangeEvent
)="
onFormDataChange
($
event
)"
></main8-form></div>
\ No newline at end of file
app_Default/src/pages/exapmple/example-main8-edit-view/example-main8-edit-view.less
0 → 100644
浏览文件 @
ded3dc37
// this is less
app_Default/src/pages/exapmple/example-main8-edit-view/example-main8-edit-view.module.ts
0 → 100644
浏览文件 @
ded3dc37
import
{
NgZorroAntdModule
}
from
'ng-zorro-antd'
;
import
{
RouterModule
}
from
'@angular/router'
;
import
{
NgModule
,
CUSTOM_ELEMENTS_SCHEMA
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
EditFormModule
}
from
'@widgets/example/main8/main8.module'
;
import
{
ExampleMain8EditViewPage
}
from
'./example-main8-edit-view'
;
@
NgModule
({
imports
:
[
RouterModule
.
forChild
([
{
path
:
''
,
component
:
ExampleMain8EditViewPage
,
data
:
{
name
:
'exapmple_examplemain8editview'
}
}
])
],
exports
:
[
RouterModule
]
})
export
class
ExampleMain8EditViewRouteModule
{}
@
NgModule
({
imports
:
[
NgZorroAntdModule
,
CommonModule
,
FormsModule
,
ExampleMain8EditViewRouteModule
,
EditFormModule
,
],
schemas
:
[
CUSTOM_ELEMENTS_SCHEMA
],
declarations
:
[
ExampleMain8EditViewPage
],
entryComponents
:
[
ExampleMain8EditViewPage
],
exports
:
[
ExampleMain8EditViewPage
]
})
export
class
ExampleMain8EditViewModule
{}
app_Default/src/pages/exapmple/example-main8-edit-view/example-main8-edit-view.ts
0 → 100644
浏览文件 @
ded3dc37
import
{
Component
}
from
'@angular/core'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
@
Component
({
selector
:
'view-example-main8-edit-view'
,
templateUrl
:
'./example-main8-edit-view.html'
,
styleUrls
:
[
'./example-main8-edit-view.less'
]
})
export
class
ExampleMain8EditViewPage
{
/**
* 表单数据变化
*
* @param {*} $event
* @memberof BookTestEditViewPage
*/
public
onFormDataChange
(
$event
:
any
)
{
console
.
log
(
$event
);
}
}
app_Default/src/pages/module3/entity3-main9-edit-view/entity3-main9-edit-view.html
0 → 100644
浏览文件 @
ded3dc37
<div
style=
"background: #fff;height: 100%;padding: 16px;overflow: auto;"
>
<main9-form
(
dataChangeEvent
)="
onFormDataChange
($
event
)"
></main9-form></div>
\ No newline at end of file
app_Default/src/pages/module3/entity3-main9-edit-view/entity3-main9-edit-view.less
0 → 100644
浏览文件 @
ded3dc37
// this is less
app_Default/src/pages/module3/entity3-main9-edit-view/entity3-main9-edit-view.module.ts
0 → 100644
浏览文件 @
ded3dc37
import
{
NgZorroAntdModule
}
from
'ng-zorro-antd'
;
import
{
RouterModule
}
from
'@angular/router'
;
import
{
NgModule
,
CUSTOM_ELEMENTS_SCHEMA
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
EditFormModule
}
from
'@widgets/entity3/main9/main9.module'
;
import
{
Entity3Main9EditViewPage
}
from
'./entity3-main9-edit-view'
;
@
NgModule
({
imports
:
[
RouterModule
.
forChild
([
{
path
:
''
,
component
:
Entity3Main9EditViewPage
,
data
:
{
name
:
'module3_entity3main9editview'
}
}
])
],
exports
:
[
RouterModule
]
})
export
class
Entity3Main9EditViewRouteModule
{}
@
NgModule
({
imports
:
[
NgZorroAntdModule
,
CommonModule
,
FormsModule
,
Entity3Main9EditViewRouteModule
,
EditFormModule
,
],
schemas
:
[
CUSTOM_ELEMENTS_SCHEMA
],
declarations
:
[
Entity3Main9EditViewPage
],
entryComponents
:
[
Entity3Main9EditViewPage
],
exports
:
[
Entity3Main9EditViewPage
]
})
export
class
Entity3Main9EditViewModule
{}
app_Default/src/pages/module3/entity3-main9-edit-view/entity3-main9-edit-view.ts
0 → 100644
浏览文件 @
ded3dc37
import
{
Component
}
from
'@angular/core'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
@
Component
({
selector
:
'view-entity3-main9-edit-view'
,
templateUrl
:
'./entity3-main9-edit-view.html'
,
styleUrls
:
[
'./entity3-main9-edit-view.less'
]
})
export
class
Entity3Main9EditViewPage
{
/**
* 表单数据变化
*
* @param {*} $event
* @memberof BookTestEditViewPage
*/
public
onFormDataChange
(
$event
:
any
)
{
console
.
log
(
$event
);
}
}
app_Default/src/widgets/entity3/main/main.html
浏览文件 @
ded3dc37
此差异已折叠。
点击以展开。
app_Default/src/widgets/entity3/main/main.ts
浏览文件 @
ded3dc37
此差异已折叠。
点击以展开。
app_Default/src/widgets/entity3/main9/main9.html
0 → 100644
浏览文件 @
ded3dc37
<form
nz-form
nz-row
class=
"app-form"
>
<div
nz-row
>
<nz-tabset>
</nz-tabset>
</div>
</form>
\ No newline at end of file
app_Default/src/widgets/entity3/main9/main9.less
0 → 100644
浏览文件 @
ded3dc37
// this is less
.hidden {
display: none;
}
.app-form {
.app-form-group {
height: 100%;
/deep/ .ant-card-body {
height: calc(100% - 58px);
}
}
.no-error {
margin-bottom: 24px;
}
/deep/ .ant-tabs-tabpane {
padding: 0 16px;
}
}
\ No newline at end of file
app_Default/src/widgets/entity3/main9/main9.module.ts
0 → 100644
浏览文件 @
ded3dc37
import
{
NgZorroAntdModule
}
from
'ng-zorro-antd'
;
import
{
RouterModule
}
from
'@angular/router'
;
import
{
NgModule
,
CUSTOM_ELEMENTS_SCHEMA
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
EditForm
}
from
'./main9'
;
import
{
AppTimePickerModule
}
from
'@components/app-time-picker/app-time-picker.module'
;
import
{
AppDatePickerModule
}
from
'@components/app-date-picker/app-date-picker.module'
;
import
{
AppSelectModule
}
from
'@components/app-select/app-select.module'
;
import
{
AppRadioModule
}
from
'@components/app-radio/app-radio.module'
;
import
{
AppCheckboxListModule
}
from
'@components/app-checkbox-list/app-checkbox-list.module'
;
import
{
AppCheckboxModule
}
from
'@components/app-checkbox/app-checkbox.module'
;
import
{
AppImageUploadModule
}
from
'@components/app-image-upload/app-image-upload.module'
;
import
{
AppFileUploadModule
}
from
'@components/app-file-upload/app-file-upload.module'
;
@
NgModule
({
imports
:
[
NgZorroAntdModule
,
CommonModule
,
FormsModule
,
AppDatePickerModule
,
AppTimePickerModule
,
AppSelectModule
,
AppRadioModule
,
AppCheckboxListModule
,
AppCheckboxModule
,
AppImageUploadModule
,
AppFileUploadModule
],
schemas
:
[
CUSTOM_ELEMENTS_SCHEMA
],
declarations
:
[
EditForm
],
exports
:
[
EditForm
]
})
export
class
EditFormModule
{
}
app_Default/src/widgets/entity3/main9/main9.ts
0 → 100644
浏览文件 @
ded3dc37
import
{
Component
,
OnInit
,
Input
,
Output
,
EventEmitter
,
ViewContainerRef
,
ViewChild
,
OnDestroy
,
AfterViewInit
}
from
'@angular/core'
;
import
{
Subject
,
Subscription
}
from
'rxjs'
;
import
{
NzNotificationService
}
from
'ng-zorro-antd/notification'
;
import
{
Util
}
from
'@global/util/util'
;
import
{
NzModalService
}
from
'ng-zorro-antd/modal'
;
import
{
FormButtonModel
,
FormPageModel
,
FormItemModel
,
FormDRUIPartModel
,
FormPartModel
,
FormGroupPanelModel
,
FormIFrameModel
,
FormRowItemModel
,
FormTabPageModel
,
FormTabPanelModel
,
FormUserControlModel
}
from
'@global/model/form-detail'
;
import
{
debounceTime
,
distinctUntilChanged
}
from
'rxjs/operators'
;
@
Component
({
selector
:
'main9-form'
,
templateUrl
:
'./main9.html'
,
styleUrls
:
[
'./main9.less'
],
})
export
class
EditForm
implements
OnInit
{
constructor
(
private
$util
:
Util
)
{
}
/**
* 数据对象
*
* @type {*}
* @memberof EditForm
*/
@
Input
()
set
formData
(
val
:
any
)
{
if
(
val
)
{
this
.
data
=
JSON
.
parse
(
JSON
.
stringify
(
val
));
this
.
formLogic
(
''
,
null
,
null
);
}
}
/**
* 表单数据对象
*
* @type {*}
* @memberof EditForm
*/
public
data
:
any
=
{};
/**
* 表单数据变化
*
* @type {Subject<any>}
* @memberof EditForm
*/
public
formDataChange
:
Subject
<
any
>
=
new
Subject
<
any
>
();
/**
* 表单数据变化抛出事件
*
* @type {EventEmitter<any>}
* @memberof EditForm
*/
@
Output
()
dataChangeEvent
:
EventEmitter
<
any
>
=
new
EventEmitter
<
any
>
();
/**
* 代码表模型
*
* @type {*}
* @memberof Main9
*/
public
codelistModel
:
any
=
{
};
/**
* 属性值规则
*
* @type {*}
* @memberof Main9
*/
public
rules
:
any
=
{
srfupdatedate
:
[
{
type
:
'string'
,
message
:
'更新时间 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
'更新时间 值不能为空'
},
],
srforikey
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
srfkey
:
[
{
type
:
'string'
,
message
:
'实体3标识 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
'实体3标识 值不能为空'
},
],
srfmajortext
:
[
{
type
:
'string'
,
message
:
'实体3名称 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
'实体3名称 值不能为空'
},
],
srftempmode
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
srfuf
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
srfdeid
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
srfsourcekey
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
entity3id
:
[
{
type
:
'string'
,
message
:
'实体3标识 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
'实体3标识 值不能为空'
},
],
}
/**
* 详情模型集合
*
* @type {*}
* @memberof Main9
*/
public
detailsModel
:
any
=
{
srfupdatedate
:
new
FormItemModel
({
caption
:
'更新时间'
,
detailType
:
'FORMITEM'
,
name
:
'srfupdatedate'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srforikey
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srforikey'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfkey
:
new
FormItemModel
({
caption
:
'实体3标识'
,
detailType
:
'FORMITEM'
,
name
:
'srfkey'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfmajortext
:
new
FormItemModel
({
caption
:
'实体3名称'
,
detailType
:
'FORMITEM'
,
name
:
'srfmajortext'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srftempmode
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srftempmode'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfuf
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srfuf'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfdeid
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srfdeid'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfsourcekey
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srfsourcekey'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
entity3id
:
new
FormItemModel
({
caption
:
'实体3标识'
,
detailType
:
'FORMITEM'
,
name
:
'entity3id'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
form
:
new
FormTabPanelModel
({
caption
:
'form'
,
detailType
:
'TABPANEL'
,
name
:
'form'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
tabPages
:
[]
}),
};
/**
* 生命周期
*
* @memberof EditForm
*/
ngOnInit
():
void
{
this
.
formLogic
(
''
,
null
,
null
);
this
.
formDataChange
.
pipe
(
debounceTime
(
300
),
distinctUntilChanged
()
).
subscribe
(
data
=>
{
this
.
dataChangeEvent
.
emit
(
JSON
.
parse
(
data
.
data
));
const
field
=
data
.
field
;
if
(
field
)
{
this
.
formLogic
(
field
.
name
,
field
.
value
,
field
.
oldVal
);
this
.
validateFormItem
(
field
.
name
);
}
});
}
/**
* 表单项值变化事件
*
* @param {{name: string, value: any}} {name, value}
* @memberof EditForm
*/
public
onFormDataChange
(
name
:
string
,
value
:
any
):
void
{
if
(
Object
.
is
(
this
.
data
[
name
],
value
))
{
return
;
}
let
oldVal
:
any
=
this
.
data
[
name
];
this
.
data
[
name
]
=
value
;
this
.
formDataChange
.
next
({
data
:
JSON
.
stringify
(
this
.
data
),
field
:
{
name
:
name
,
value
:
value
,
oldVal
:
oldVal
}
});
}
/**
* 校验表单项
*
* @param {string} name
* @memberof EditForm
*/
public
validateFormItem
(
name
:
string
)
{
if
(
!
name
)
{
return
;
}
const
rule
:
any
[]
=
this
.
rules
[
name
];
let
message
=
''
;
let
status
=
''
;
const
val
:
any
=
this
.
data
[
name
];
rule
.
every
((
rule
:
any
)
=>
{
if
(
rule
.
required
&&
(
!
val
||
Object
.
is
(
val
,
''
))
)
{
message
=
rule
.
message
;
status
=
'error'
;
return
false
;
}
else
if
(
val
&&
rule
.
pattern
&&
!
rule
.
pattern
.
test
(
val
))
{
message
=
rule
.
message
;
status
=
'error'
;
return
false
;
}
return
true
;
});
this
.
detailsModel
[
name
].
error
=
message
;
this
.
detailsModel
[
name
].
validateStatus
=
status
;
}
/**
* 获取代码表集合
*
* @param {string} name
* @memberof EditForm
*/
public
getCodeList
(
name
:
string
)
{
if
(
!
name
||
!
this
.
codelistModel
[
name
])
{
return
[];
}
return
this
.
codelistModel
[
name
];
}
/**
* 表单逻辑
*
* @param {string} name
* @param {*} newVal
* @param {*} oldVal
* @memberof EditForm
*/
public
formLogic
(
name
:
string
,
newVal
:
any
,
oldVal
:
any
)
{
}
}
\ No newline at end of file
app_Default/src/widgets/example/main8/main8.html
0 → 100644
浏览文件 @
ded3dc37
<form
nz-form
nz-row
class=
"app-form"
>
<div
nz-row
>
<nz-tabset>
</nz-tabset>
</div>
</form>
\ No newline at end of file
app_Default/src/widgets/example/main8/main8.less
0 → 100644
浏览文件 @
ded3dc37
// this is less
.hidden {
display: none;
}
.app-form {
.app-form-group {
height: 100%;
/deep/ .ant-card-body {
height: calc(100% - 58px);
}
}
.no-error {
margin-bottom: 24px;
}
/deep/ .ant-tabs-tabpane {
padding: 0 16px;
}
}
\ No newline at end of file
app_Default/src/widgets/example/main8/main8.module.ts
0 → 100644
浏览文件 @
ded3dc37
import
{
NgZorroAntdModule
}
from
'ng-zorro-antd'
;
import
{
RouterModule
}
from
'@angular/router'
;
import
{
NgModule
,
CUSTOM_ELEMENTS_SCHEMA
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
EditForm
}
from
'./main8'
;
import
{
AppTimePickerModule
}
from
'@components/app-time-picker/app-time-picker.module'
;
import
{
AppDatePickerModule
}
from
'@components/app-date-picker/app-date-picker.module'
;
import
{
AppSelectModule
}
from
'@components/app-select/app-select.module'
;
import
{
AppRadioModule
}
from
'@components/app-radio/app-radio.module'
;
import
{
AppCheckboxListModule
}
from
'@components/app-checkbox-list/app-checkbox-list.module'
;
import
{
AppCheckboxModule
}
from
'@components/app-checkbox/app-checkbox.module'
;
import
{
AppImageUploadModule
}
from
'@components/app-image-upload/app-image-upload.module'
;
import
{
AppFileUploadModule
}
from
'@components/app-file-upload/app-file-upload.module'
;
@
NgModule
({
imports
:
[
NgZorroAntdModule
,
CommonModule
,
FormsModule
,
AppDatePickerModule
,
AppTimePickerModule
,
AppSelectModule
,
AppRadioModule
,
AppCheckboxListModule
,
AppCheckboxModule
,
AppImageUploadModule
,
AppFileUploadModule
],
schemas
:
[
CUSTOM_ELEMENTS_SCHEMA
],
declarations
:
[
EditForm
],
exports
:
[
EditForm
]
})
export
class
EditFormModule
{
}
app_Default/src/widgets/example/main8/main8.ts
0 → 100644
浏览文件 @
ded3dc37
import
{
Component
,
OnInit
,
Input
,
Output
,
EventEmitter
,
ViewContainerRef
,
ViewChild
,
OnDestroy
,
AfterViewInit
}
from
'@angular/core'
;
import
{
Subject
,
Subscription
}
from
'rxjs'
;
import
{
NzNotificationService
}
from
'ng-zorro-antd/notification'
;
import
{
Util
}
from
'@global/util/util'
;
import
{
NzModalService
}
from
'ng-zorro-antd/modal'
;
import
{
FormButtonModel
,
FormPageModel
,
FormItemModel
,
FormDRUIPartModel
,
FormPartModel
,
FormGroupPanelModel
,
FormIFrameModel
,
FormRowItemModel
,
FormTabPageModel
,
FormTabPanelModel
,
FormUserControlModel
}
from
'@global/model/form-detail'
;
import
{
debounceTime
,
distinctUntilChanged
}
from
'rxjs/operators'
;
@
Component
({
selector
:
'main8-form'
,
templateUrl
:
'./main8.html'
,
styleUrls
:
[
'./main8.less'
],
})
export
class
EditForm
implements
OnInit
{
constructor
(
private
$util
:
Util
)
{
}
/**
* 数据对象
*
* @type {*}
* @memberof EditForm
*/
@
Input
()
set
formData
(
val
:
any
)
{
if
(
val
)
{
this
.
data
=
JSON
.
parse
(
JSON
.
stringify
(
val
));
this
.
formLogic
(
''
,
null
,
null
);
}
}
/**
* 表单数据对象
*
* @type {*}
* @memberof EditForm
*/
public
data
:
any
=
{};
/**
* 表单数据变化
*
* @type {Subject<any>}
* @memberof EditForm
*/
public
formDataChange
:
Subject
<
any
>
=
new
Subject
<
any
>
();
/**
* 表单数据变化抛出事件
*
* @type {EventEmitter<any>}
* @memberof EditForm
*/
@
Output
()
dataChangeEvent
:
EventEmitter
<
any
>
=
new
EventEmitter
<
any
>
();
/**
* 代码表模型
*
* @type {*}
* @memberof Main8
*/
public
codelistModel
:
any
=
{
};
/**
* 属性值规则
*
* @type {*}
* @memberof Main8
*/
public
rules
:
any
=
{
srfupdatedate
:
[
{
type
:
'string'
,
message
:
'更新时间 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
'更新时间 值不能为空'
},
],
srforikey
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
srfkey
:
[
{
type
:
'string'
,
message
:
'示例标识 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
'示例标识 值不能为空'
},
],
srfmajortext
:
[
{
type
:
'string'
,
message
:
'示例名称 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
'示例名称 值不能为空'
},
],
srftempmode
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
srfuf
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
srfdeid
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
srfsourcekey
:
[
{
type
:
'string'
,
message
:
' 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
' 值不能为空'
},
],
exampleid
:
[
{
type
:
'string'
,
message
:
'示例标识 值必须为字符串类型'
},
{
required
:
false
,
type
:
'string'
,
message
:
'示例标识 值不能为空'
},
],
}
/**
* 详情模型集合
*
* @type {*}
* @memberof Main8
*/
public
detailsModel
:
any
=
{
srfupdatedate
:
new
FormItemModel
({
caption
:
'更新时间'
,
detailType
:
'FORMITEM'
,
name
:
'srfupdatedate'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srforikey
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srforikey'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfkey
:
new
FormItemModel
({
caption
:
'示例标识'
,
detailType
:
'FORMITEM'
,
name
:
'srfkey'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfmajortext
:
new
FormItemModel
({
caption
:
'示例名称'
,
detailType
:
'FORMITEM'
,
name
:
'srfmajortext'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srftempmode
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srftempmode'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfuf
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srfuf'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfdeid
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srfdeid'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
srfsourcekey
:
new
FormItemModel
({
caption
:
''
,
detailType
:
'FORMITEM'
,
name
:
'srfsourcekey'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
exampleid
:
new
FormItemModel
({
caption
:
'示例标识'
,
detailType
:
'FORMITEM'
,
name
:
'exampleid'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
disabled
:
false
,
enableCond
:
3
})
,
form
:
new
FormTabPanelModel
({
caption
:
'form'
,
detailType
:
'TABPANEL'
,
name
:
'form'
,
visible
:
true
,
isShowCaption
:
true
,
form
:
this
,
tabPages
:
[]
}),
};
/**
* 生命周期
*
* @memberof EditForm
*/
ngOnInit
():
void
{
this
.
formLogic
(
''
,
null
,
null
);
this
.
formDataChange
.
pipe
(
debounceTime
(
300
),
distinctUntilChanged
()
).
subscribe
(
data
=>
{
this
.
dataChangeEvent
.
emit
(
JSON
.
parse
(
data
.
data
));
const
field
=
data
.
field
;
if
(
field
)
{
this
.
formLogic
(
field
.
name
,
field
.
value
,
field
.
oldVal
);
this
.
validateFormItem
(
field
.
name
);
}
});
}
/**
* 表单项值变化事件
*
* @param {{name: string, value: any}} {name, value}
* @memberof EditForm
*/
public
onFormDataChange
(
name
:
string
,
value
:
any
):
void
{
if
(
Object
.
is
(
this
.
data
[
name
],
value
))
{
return
;
}
let
oldVal
:
any
=
this
.
data
[
name
];
this
.
data
[
name
]
=
value
;
this
.
formDataChange
.
next
({
data
:
JSON
.
stringify
(
this
.
data
),
field
:
{
name
:
name
,
value
:
value
,
oldVal
:
oldVal
}
});
}
/**
* 校验表单项
*
* @param {string} name
* @memberof EditForm
*/
public
validateFormItem
(
name
:
string
)
{
if
(
!
name
)
{
return
;
}
const
rule
:
any
[]
=
this
.
rules
[
name
];
let
message
=
''
;
let
status
=
''
;
const
val
:
any
=
this
.
data
[
name
];
rule
.
every
((
rule
:
any
)
=>
{
if
(
rule
.
required
&&
(
!
val
||
Object
.
is
(
val
,
''
))
)
{
message
=
rule
.
message
;
status
=
'error'
;
return
false
;
}
else
if
(
val
&&
rule
.
pattern
&&
!
rule
.
pattern
.
test
(
val
))
{
message
=
rule
.
message
;
status
=
'error'
;
return
false
;
}
return
true
;
});
this
.
detailsModel
[
name
].
error
=
message
;
this
.
detailsModel
[
name
].
validateStatus
=
status
;
}
/**
* 获取代码表集合
*
* @param {string} name
* @memberof EditForm
*/
public
getCodeList
(
name
:
string
)
{
if
(
!
name
||
!
this
.
codelistModel
[
name
])
{
return
[];
}
return
this
.
codelistModel
[
name
];
}
/**
* 表单逻辑
*
* @param {string} name
* @param {*} newVal
* @param {*} oldVal
* @memberof EditForm
*/
public
formLogic
(
name
:
string
,
newVal
:
any
,
oldVal
:
any
)
{
}
}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录