Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apollo_form_pase
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web_component
apollo_form_pase
Commits
eea939d2
Commit
eea939d2
authored
Oct 31, 2019
by
满振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改控件展示
parent
4924e20d
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
751 additions
and
9 deletions
+751
-9
behavior.js
src/behavior.js
+7
-2
index.js
src/index.js
+7
-7
index.mdx
src/index.mdx
+11
-0
index.html
src/test/index.html
+15
-0
json.js
src/test/json.js
+711
-0
No files found.
src/behavior.js
View file @
eea939d2
...
...
@@ -26,7 +26,9 @@ export const HandleClass = {
},
'changeParams'
:
{
name
:
'修改business,请求参数'
,
fun
:
({
behavior
=
{},
formData
,
componentData
,
value
},
resertValue
)
=>
{
fun
:
({
behavior
=
{},
formData
,
componentData
,
value
,
handleType
},
resertValue
)
=>
{
// handleType 为init时不处理值的问题
const
newFormData
=
formData
.
slice
();
const
targets
=
(
behavior
.
targets
||
''
).
split
(
','
);
targets
.
forEach
(
ls
=>
{
...
...
@@ -40,7 +42,10 @@ export const HandleClass = {
paramsJson
,
}
resertValue
&&
resertValue
({
key
:
ls
});
if
(
handleType
!==
'init'
)
{
obj
.
value
=
void
0
;
//将目标组件清空
}
});
return
newFormData
...
...
src/index.js
View file @
eea939d2
...
...
@@ -12,7 +12,7 @@ class HandleBehavior {
this
.
formData
.
map
(
item
=>
{
if
(
!
item
.
behaviors
||
!
Array
.
isArray
(
item
.
behaviors
)
||
item
.
behaviors
.
length
===
0
)
return
;
const
value
=
this
.
handleFormaterValue
(
item
.
value
,
item
);
this
.
handleBehavior
({
currentValue
:
value
,
componentData
:
item
})
this
.
handleBehavior
({
currentValue
:
value
,
componentData
:
item
,
handleType
:
'init'
})
})
return
this
;
}
...
...
@@ -33,28 +33,28 @@ class HandleBehavior {
/*
* 处理行为方法
*/
handleBehavior
=
({
currentValue
,
componentData
=
{},
eventType
,
formData
})
=>
{
handleBehavior
=
({
currentValue
,
componentData
=
{},
eventType
,
formData
,
handleType
})
=>
{
this
.
formData
=
formData
||
this
.
formData
;
const
value
=
this
.
handleFormaterValue
((
currentValue
||
componentData
.
value
),
componentData
);
const
events
=
componentData
.
events
||
[]
const
behaviors
=
componentData
.
behaviors
||
[];
const
changeEvents
=
eventType
?
events
.
filter
(
ls
=>
ls
.
eventValue
===
'onChange'
)
:
events
;
changeEvents
.
forEach
(
event
=>
{
this
.
onChangeBehavior
({
event
,
value
,
componentData
,
behaviors
})
this
.
onChangeBehavior
({
event
,
value
,
componentData
,
behaviors
,
handleType
})
});
}
onChangeBehavior
=
({
event
,
value
,
componentData
,
behaviors
})
=>
{
onChangeBehavior
=
({
event
,
value
,
componentData
,
behaviors
,
handleType
})
=>
{
if
(
!
event
.
behaviors
||
!
Array
.
isArray
(
event
.
behaviors
))
return
;
event
.
behaviors
.
forEach
(
item
=>
{
this
.
handleBehaviorType
({
value
,
behavior
:
item
,
componentData
,
behaviors
});
this
.
handleBehaviorType
({
value
,
behavior
:
item
,
componentData
,
behaviors
,
handleType
});
});
}
handleBehaviorType
=
({
value
,
behavior
,
behaviors
,
componentData
})
=>
{
handleBehaviorType
=
({
value
,
behavior
,
behaviors
,
componentData
,
handleType
})
=>
{
const
behaviorInstance
=
HandleClass
[
behavior
.
behaviorValue
];
if
(
!
behaviorInstance
||
!
behaviorInstance
.
fun
)
return
;
let
formData
=
this
.
formData
;
this
.
formData
=
behaviorInstance
.
fun
({
value
,
behavior
,
behaviors
,
formData
,
componentData
},
this
.
resertValueCallback
);
this
.
formData
=
behaviorInstance
.
fun
({
value
,
behavior
,
behaviors
,
formData
,
componentData
,
handleType
},
this
.
resertValueCallback
);
}
resertValueCallback
=
({
key
,
value
})
=>
{
const
componentData
=
this
.
formData
.
find
(
ls
=>
ls
.
name
===
key
)
||
{};
...
...
src/index.mdx
View file @
eea939d2
...
...
@@ -6,11 +6,22 @@ sidebar: true
---
import HandleBehavior from './';
import {data} from './test/json.js'
# Button Component
## new HandleBehavior({formData})
## instance{initBehavior(formData)}
<html>
<body>
<div>
ddd
<script>
console
.
log
(
1
)
</script>
</div>
</body>
</html>
...
...
src/test/index.html
0 → 100644
View file @
eea939d2
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<title>
Document
</title>
</head>
<body>
<script
src=
"../../dist/index.js"
>
</script>
</body>
</html>
\ No newline at end of file
src/test/json.js
0 → 100644
View file @
eea939d2
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment