Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
50c942ef
提交
50c942ef
authored
7月 21, 2020
作者:
徐立
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复bug
上级
4adc8e52
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
152 行增加
和
82 行删除
+152
-82
ChildForm.jsx
one_stop_public/libs/ChildForm.jsx
+152
-82
没有找到文件。
one_stop_public/libs/ChildForm.jsx
浏览文件 @
50c942ef
import
React
from
'react'
import
React
from
'react'
;
import
{
Button
,
Row
,
Col
,
message
}
from
'antd'
;
import
ZdyTable
from
'../Table'
import
ZdyTable
from
'../Table'
;
import
UUID
from
'react-native-uuid'
;
import
{
Card
,
WingBlank
}
from
'antd-mobile'
;
export
default
class
ChildForm
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
)
super
(
props
);
const
value
=
props
.
value
||
{};
this
.
state
=
value
this
.
state
=
value
;
}
triggerChange
=
(
changedValue
)
=>
{
triggerChange
=
changedValue
=>
{
// Should provide an event to pass value to Form.
const
onChange
=
this
.
props
.
onChange
;
if
(
onChange
)
{
onChange
(
Object
.
assign
({},
this
.
state
,
changedValue
));
}
}
};
componentWillReceiveProps
(
nextProps
)
{
// Should be a controlled component.
if
(
'value'
in
nextProps
)
{
const
value
=
nextProps
.
value
;
this
.
state
=
value
this
.
state
=
value
;
}
}
componentDidMount
=
()
=>
{
if
(
Object
.
keys
(
this
.
state
).
length
==
0
&&
this
.
props
.
isEdit
)
{
if
(
this
.
props
.
num
!=
null
&&
this
.
props
.
num
>
0
)
{
const
objs
=
this
.
state
const
objs
=
this
.
state
;
if
(
this
.
props
.
min
!=
null
&&
this
.
props
.
min
>
this
.
props
.
num
)
{
for
(
var
i
=
0
;
i
<
this
.
props
.
min
;
i
++
)
{
objs
[
"id_"
+
UUID
.
v4
().
replace
(
/-/g
,
"2"
)]
=
{}
objs
[
'id_'
+
UUID
.
v4
().
replace
(
/-/g
,
'2'
)]
=
{};
}
}
else
{
for
(
var
i
=
0
;
i
<
this
.
props
.
num
;
i
++
)
{
objs
[
"id_"
+
UUID
.
v4
().
replace
(
/-/g
,
"2"
)]
=
{}
objs
[
'id_'
+
UUID
.
v4
().
replace
(
/-/g
,
'2'
)]
=
{};
}
}
...
...
@@ -47,114 +44,170 @@ export default class ChildForm extends React.Component {
this
.
setState
({
...
objs
});
}
this
.
triggerChange
({
...
objs
});
}
}
}
delete
=
(
uuid
)
=>
{
const
objs
=
this
.
state
const
{
json
:
{
numCode
},
form
,
base52
}
=
this
.
props
};
delete
=
uuid
=>
{
const
objs
=
this
.
state
;
const
{
json
:
{
numCode
},
form
,
base52
,
}
=
this
.
props
;
if
(
this
.
props
.
min
!=
null
&&
Object
.
keys
(
objs
).
length
-
1
<
this
.
props
.
min
)
{
message
.
error
(
"不能小于最小限制"
)
message
.
error
(
'不能小于最小限制'
);
return
return
;
}
delete
objs
[
uuid
]
delete
objs
[
uuid
];
if
(
!
(
'value'
in
this
.
props
))
{
this
.
setState
({
...
objs
});
}
this
.
triggerChange
({
...
objs
});
if
(
numCode
!=
null
)
{
this
.
props
.
form
.
setFieldsValue
({
[
numCode
]:
Object
.
keys
(
objs
).
length
})
}
this
.
props
.
form
.
setFieldsValue
({
[
numCode
]:
Object
.
keys
(
objs
).
length
});
}
};
add
=
()
=>
{
const
objs
=
this
.
state
const
{
json
:
{
numCode
},
form
,
base52
}
=
this
.
props
const
objs
=
this
.
state
;
const
{
json
:
{
numCode
},
form
,
base52
,
}
=
this
.
props
;
if
(
this
.
props
.
max
!=
null
&&
Object
.
keys
(
objs
).
length
+
1
>
this
.
props
.
max
)
{
message
.
error
(
"不能大于最大限制"
)
message
.
error
(
'不能大于最大限制'
);
return
return
;
}
objs
[
"id_"
+
UUID
.
v4
().
replace
(
/-/g
,
"2"
)]
=
{}
objs
[
'id_'
+
UUID
.
v4
().
replace
(
/-/g
,
'2'
)]
=
{};
if
(
!
(
'value'
in
this
.
props
))
{
this
.
setState
({
...
objs
});
}
this
.
triggerChange
({
...
objs
});
if
(
numCode
!=
null
)
{
this
.
props
.
form
.
setFieldsValue
({
[
numCode
]:
Object
.
keys
(
objs
).
length
})
}
this
.
props
.
form
.
setFieldsValue
({
[
numCode
]:
Object
.
keys
(
objs
).
length
});
}
};
render
()
{
const
objs
=
this
.
state
;
const
{
form
,
mapData
,
sqlData
,
defaultValues
,
datas
,
base52
,
isEdit
,
addName
,
deleteName
,
obj
,
isMobile
,
json
,
modalInit
,
isPreview
}
=
this
.
props
const
span
=
json
.
span
||
24
const
gutter
=
json
.
gutter
!=
null
?
json
.
gutter
:
0
const
rights
=
this
.
props
.
rights
const
{
form
,
mapData
,
sqlData
,
defaultValues
,
datas
,
base52
,
isEdit
,
addName
,
deleteName
,
obj
,
isMobile
,
json
,
modalInit
,
isPreview
,
}
=
this
.
props
;
const
span
=
json
.
span
||
24
;
const
gutter
=
json
.
gutter
!=
null
?
json
.
gutter
:
0
;
const
rights
=
this
.
props
.
rights
;
if
(
datas
==
null
)
{
return
(<
div
>
还没有配置子表单key
</
div
>)
return
<
div
>
还没有配置子表单key
</
div
>;
}
if
(
isMobile
)
{
return
(
<
WingBlank
size=
"lg"
>
{
Object
.
keys
(
objs
).
length
>
1
||
rights
.
includes
(
"add"
)
?
<
Card
>
{
Object
.
keys
(
objs
).
length
>
1
||
rights
.
includes
(
'add'
)
?
(
<
Card
>
<
Card
.
Body
style=
{
{
minHeight
:
10
}
}
>
{
Object
.
keys
(
objs
).
map
((
r
)
=>
{
if
(
r
==
""
)
{
return
""
{
Object
.
keys
(
objs
).
map
(
r
=>
{
if
(
r
==
''
)
{
return
''
;
}
return
<
Row
key=
{
r
}
gutter=
{
gutter
}
><
Col
span=
{
isEdit
?
24
:
span
}
>
<
ZdyTable
key=
{
r
}
modalInit=
{
modalInit
}
formCode=
{
this
.
props
.
formCode
}
return
(
<
Row
key=
{
r
}
gutter=
{
gutter
}
>
<
Col
style=
{
{
zIndex
:
55
,
}
}
span=
{
isEdit
?
24
:
span
}
>
<
ZdyTable
key=
{
r
}
modalInit=
{
modalInit
}
formCode=
{
this
.
props
.
formCode
}
formId=
{
this
.
props
.
formId
}
isPreview=
{
isPreview
}
formConfig=
{
datas
}
get=
'mobile'
fatherCode=
{
base52
}
isEdit=
{
isEdit
}
index=
{
r
}
obj=
{
objs
[
r
]
}
fatherObj=
{
this
.
props
.
fatherObj
}
init=
{
objs
}
isChild=
{
true
}
form=
{
form
}
mapData=
{
mapData
}
sqlData=
{
sqlData
}
{
...
datas
}
defaultValues=
{
defaultValues
}
/>
formConfig=
{
datas
}
get=
"mobile"
fatherCode=
{
base52
}
isEdit=
{
isEdit
}
index=
{
r
}
obj=
{
objs
[
r
]
}
fatherObj=
{
this
.
props
.
fatherObj
}
init=
{
objs
}
isChild=
{
true
}
form=
{
form
}
mapData=
{
mapData
}
sqlData=
{
sqlData
}
{
...
datas
}
defaultValues=
{
defaultValues
}
/>
</
Col
>
{
rights
.
includes
(
'delete'
)
&&
isEdit
?
(
<
Col
style=
{
{
textAlign
:
'right'
}
}
>
<
Button
type=
"danger"
size=
"small"
onClick=
{
this
.
delete
.
bind
(
this
,
r
)
}
>
{
deleteName
||
'删除'
}{
' '
}
</
Button
>
{
' '
}
</
Col
>
{
rights
.
includes
(
"delete"
)
&&
isEdit
?
<
Col
style=
{
{
textAlign
:
"right"
}
}
><
Button
type=
'danger'
size=
"small"
onClick=
{
this
.
delete
.
bind
(
this
,
r
)
}
>
{
deleteName
||
"删除"
}
</
Button
>
</
Col
>:
''
}
)
:
(
''
)
}
</
Row
>
);
})
}
{
rights
.
includes
(
"add"
)
?
<
Row
>
<
Col
style=
{
{
textAlign
:
"center"
}
}
><
Button
type=
"primary"
size=
"small"
style=
{
{
margin
:
"auto"
}
}
onClick=
{
this
.
add
}
>
{
addName
||
"新增"
}
</
Button
>
</
Col
>
</
Row
>
:
""
}
{
rights
.
includes
(
'add'
)
?
(
<
Row
>
<
Col
style=
{
{
textAlign
:
'center'
}
}
>
<
Button
type=
"primary"
size=
"small"
style=
{
{
margin
:
'auto'
}
}
onClick=
{
this
.
add
}
>
{
addName
||
'新增'
}
</
Button
>
{
' '
}
</
Col
>
</
Row
>
)
:
(
''
)
}
</
Card
.
Body
>
</
Card
>
:
""
}
</
Card
>
)
:
(
''
)
}
</
WingBlank
>
)
);
}
return
(
<
div
style=
{
{
width
:
"100%"
}
}
>
<
div
style=
{
{
width
:
'100%'
}
}
>
<
Row
gutter=
{
gutter
}
>
{
Object
.
keys
(
objs
).
map
((
r
)
=>
{
if
(
r
==
""
)
{
return
""
{
Object
.
keys
(
objs
).
map
(
r
=>
{
if
(
r
==
''
)
{
return
''
;
}
return
<
Col
span=
{
span
}
>
return
(
<
Col
span=
{
span
}
>
<
ZdyTable
modalInit=
{
modalInit
}
formConfig=
{
datas
}
...
...
@@ -167,17 +220,21 @@ export default class ChildForm extends React.Component {
formCode=
{
this
.
props
.
formCode
}
formId=
{
this
.
props
.
formId
}
fatherObj=
{
this
.
props
.
fatherObj
}
init=
{
objs
}
isChild=
{
true
}
init=
{
objs
}
isChild=
{
true
}
get=
"web"
form=
{
form
}
mapData=
{
mapData
}
sqlData=
{
sqlData
}
{
...
datas
}
defaultValues=
{
defaultValues
}
/>
defaultValues=
{
defaultValues
}
/>
{
rights
.
includes
(
"delete"
)
&&
isEdit
?
<
Button
size=
"small"
{
rights
.
includes
(
'delete'
)
&&
isEdit
?
(
<
Button
size=
"small"
style=
{
{
position
:
"absolute"
,
position
:
'absolute'
,
left
:
' 95%'
,
top
:
'10px'
,
transform
:
'translateY(-50%)'
,
...
...
@@ -185,19 +242,32 @@ export default class ChildForm extends React.Component {
height
:
'13px'
,
width
:
'13px'
,
padding
:
0
,
lineHeight
:
'10px'
lineHeight
:
'10px'
,
}
}
type=
'danger'
onClick=
{
this
.
delete
.
bind
(
this
,
r
)
}
>
{
deleteName
||
"-"
}
</
Button
>
:
""
}
type=
"danger"
onClick=
{
this
.
delete
.
bind
(
this
,
r
)
}
>
{
deleteName
||
'-'
}
</
Button
>
)
:
(
''
)
}
</
Col
>
);
})
}
</
Row
>
{
rights
.
includes
(
"add"
)
&&
isEdit
?
<
Row
><
Col
span=
{
24
}
style=
{
{
textAlign
:
"center"
}
}
><
Button
style=
{
{
margin
:
"auto"
}
}
type=
'primary'
onClick=
{
this
.
add
}
size=
"small"
>
{
addName
||
"新增"
}
</
Button
></
Col
>
</
Row
>
:
""
}
{
rights
.
includes
(
'add'
)
&&
isEdit
?
(
<
Row
>
<
Col
span=
{
24
}
style=
{
{
textAlign
:
'center'
}
}
>
<
Button
style=
{
{
margin
:
'auto'
}
}
type=
"primary"
onClick=
{
this
.
add
}
size=
"small"
>
{
addName
||
'新增'
}
</
Button
>
</
Col
>
{
' '
}
</
Row
>
)
:
(
''
)
}
</
div
>
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论