Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
19f25baf
Commit
19f25baf
authored
Jul 28, 2021
by
好多大米
Committed by
GitHub
Jul 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cascader: fix emitPath (#21185)
parent
f1252dcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
13 deletions
+25
-13
packages/cascader-panel/src/cascader-panel.vue
packages/cascader-panel/src/cascader-panel.vue
+11
-3
packages/cascader-panel/src/store.js
packages/cascader-panel/src/store.js
+3
-7
packages/cascader/src/cascader.vue
packages/cascader/src/cascader.vue
+11
-3
No files found.
packages/cascader-panel/src/cascader-panel.vue
View file @
19f25baf
...
...
@@ -157,7 +157,7 @@ export default {
},
mounted
()
{
if
(
!
isEmpty
(
this
.
value
))
{
if
(
!
this
.
isEmptyValue
(
this
.
value
))
{
this
.
syncCheckedValue
();
}
},
...
...
@@ -195,13 +195,21 @@ export default {
node
.
syncCheckState
(
this
.
checkedValue
);
});
},
isEmptyValue
(
val
)
{
const
{
multiple
,
config
}
=
this
;
const
{
emitPath
}
=
config
;
if
(
multiple
||
emitPath
)
{
return
isEmpty
(
val
);
}
return
false
;
},
syncActivePath
()
{
const
{
store
,
multiple
,
activePath
,
checkedValue
}
=
this
;
if
(
!
isEmpty
(
activePath
))
{
const
nodes
=
activePath
.
map
(
node
=>
this
.
getNodeByValue
(
node
.
getValue
()));
this
.
expandNodes
(
nodes
);
}
else
if
(
!
isEmpty
(
checkedValue
))
{
}
else
if
(
!
this
.
isEmptyValue
(
checkedValue
))
{
const
value
=
multiple
?
checkedValue
[
0
]
:
checkedValue
;
const
checkedNode
=
this
.
getNodeByValue
(
value
)
||
{};
const
nodes
=
(
checkedNode
.
pathNodes
||
[]).
slice
(
0
,
-
1
);
...
...
@@ -361,7 +369,7 @@ export default {
const
nodes
=
this
.
getFlattedNodes
(
leafOnly
);
return
nodes
.
filter
(
node
=>
node
.
checked
);
}
else
{
return
isEmpty
(
checkedValue
)
return
this
.
isEmptyValue
(
checkedValue
)
?
[]
:
[
this
.
getNodeByValue
(
checkedValue
)];
}
...
...
packages/cascader-panel/src/store.js
View file @
19f25baf
...
...
@@ -51,12 +51,8 @@ export default class Store {
}
getNodeByValue
(
value
)
{
if
(
value
)
{
const
nodes
=
this
.
getFlattedNodes
(
false
,
!
this
.
config
.
lazy
)
.
filter
(
node
=>
(
valueEquals
(
node
.
path
,
value
)
||
node
.
value
===
value
));
return
nodes
&&
nodes
.
length
?
nodes
[
0
]
:
null
;
}
return
null
;
const
nodes
=
this
.
getFlattedNodes
(
false
,
!
this
.
config
.
lazy
)
.
filter
(
node
=>
(
valueEquals
(
node
.
path
,
value
)
||
node
.
value
===
value
));
return
nodes
&&
nodes
.
length
?
nodes
[
0
]
:
null
;
}
}
packages/cascader/src/cascader.vue
View file @
19f25baf
...
...
@@ -231,7 +231,7 @@ export default {
data
()
{
return
{
dropDownVisible
:
false
,
checkedValue
:
this
.
value
||
null
,
checkedValue
:
this
.
value
,
inputHover
:
false
,
inputValue
:
null
,
presentText
:
null
,
...
...
@@ -350,7 +350,7 @@ export default {
this
.
inputInitialHeight
=
input
.
$el
.
offsetHeight
||
InputSizeMap
[
this
.
realSize
]
||
40
;
}
if
(
!
isEmpty
(
this
.
value
))
{
if
(
!
this
.
isEmptyValue
(
this
.
value
))
{
this
.
computePresentContent
();
}
...
...
@@ -485,9 +485,17 @@ export default {
}
});
},
isEmptyValue
(
val
)
{
const
{
multiple
}
=
this
;
const
{
emitPath
}
=
this
.
panel
.
config
;
if
(
multiple
||
emitPath
)
{
return
isEmpty
(
val
);
}
return
false
;
},
computePresentText
()
{
const
{
checkedValue
,
config
}
=
this
;
if
(
!
isEmpty
(
checkedValue
))
{
if
(
!
this
.
isEmptyValue
(
checkedValue
))
{
const
node
=
this
.
panel
.
getNodeByValue
(
checkedValue
);
if
(
node
&&
(
config
.
checkStrictly
||
node
.
isLeaf
))
{
this
.
presentText
=
node
.
getText
(
this
.
showAllLevels
,
this
.
separator
);
...
...
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