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
964eb5ad
Commit
964eb5ad
authored
Feb 04, 2017
by
baiyaaaaa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add international
parent
254fc6a2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
37 deletions
+78
-37
packages/cascader/src/main.vue
packages/cascader/src/main.vue
+17
-7
packages/cascader/src/menu.vue
packages/cascader/src/menu.vue
+43
-30
packages/theme-default/src/cascader.css
packages/theme-default/src/cascader.css
+10
-0
src/locale/lang/en.js
src/locale/lang/en.js
+4
-0
src/locale/lang/zh-CN.js
src/locale/lang/zh-CN.js
+4
-0
No files found.
packages/cascader/src/main.vue
View file @
964eb5ad
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
v-clickoutside="handleClickoutside"
v-clickoutside="handleClickoutside"
>
>
<el-input
<el-input
ref=
"input"
:readonly=
"!filterable"
:readonly=
"!filterable"
:placeholder=
"displayValue ? undefined : placeholder"
:placeholder=
"displayValue ? undefined : placeholder"
v-model=
"inputValue"
v-model=
"inputValue"
...
@@ -49,6 +50,7 @@ import ElInput from 'element-ui/packages/input';
...
@@ -49,6 +50,7 @@ import ElInput from 'element-ui/packages/input';
import
Popper
from
'
element-ui/src/utils/vue-popper
'
;
import
Popper
from
'
element-ui/src/utils/vue-popper
'
;
import
Clickoutside
from
'
element-ui/src/utils/clickoutside
'
;
import
Clickoutside
from
'
element-ui/src/utils/clickoutside
'
;
import
emitter
from
'
element-ui/src/mixins/emitter
'
;
import
emitter
from
'
element-ui/src/mixins/emitter
'
;
import
Locale
from
'
element-ui/src/mixins/locale
'
;
const
popperMixin
=
{
const
popperMixin
=
{
props
:
{
props
:
{
...
@@ -71,7 +73,7 @@ export default {
...
@@ -71,7 +73,7 @@ export default {
directives
:
{
Clickoutside
},
directives
:
{
Clickoutside
},
mixins
:
[
popperMixin
,
emitter
],
mixins
:
[
popperMixin
,
emitter
,
Locale
],
components
:
{
components
:
{
ElInput
ElInput
...
@@ -146,6 +148,9 @@ export default {
...
@@ -146,6 +148,9 @@ export default {
this
.
menu
.
visible
=
true
;
this
.
menu
.
visible
=
true
;
this
.
menu
.
$on
(
'
pick
'
,
this
.
handlePick
);
this
.
menu
.
$on
(
'
pick
'
,
this
.
handlePick
);
this
.
updatePopper
();
this
.
updatePopper
();
this
.
$nextTick
(
_
=>
{
this
.
menu
.
inputWidth
=
this
.
$refs
.
input
.
$el
.
offsetWidth
-
2
;
});
},
},
hideMenu
()
{
hideMenu
()
{
this
.
menu
.
visible
=
false
;
this
.
menu
.
visible
=
false
;
...
@@ -172,18 +177,24 @@ export default {
...
@@ -172,18 +177,24 @@ export default {
});
});
if
(
filteredFlatOptions
.
length
>
0
)
{
if
(
filteredFlatOptions
.
length
>
0
)
{
this
.
menu
.
o
ptions
=
filteredFlatOptions
.
map
(
optionStack
=>
{
filteredFlatO
ptions
=
filteredFlatOptions
.
map
(
optionStack
=>
{
return
{
return
{
__IS__FLAT__OPTIONS
:
true
,
__IS__FLAT__OPTIONS
:
true
,
value
:
optionStack
.
map
(
item
=>
item
.
value
),
value
:
optionStack
.
map
(
item
=>
item
.
value
),
label
:
this
.
render
RenderFilteredOption
(
value
,
optionStack
)
label
:
this
.
render
FilteredOptionLabel
(
value
,
optionStack
)
};
};
});
});
}
else
{
}
else
{
return
[{
label
:
'
not found content
'
,
value
:
''
,
disabled
:
true
}];
filteredFlatOptions
=
[{
__IS__FLAT__OPTIONS
:
true
,
label
:
this
.
t
(
'
el.cascader.noMatch
'
),
value
:
''
,
disabled
:
true
}];
}
}
this
.
menu
.
options
=
filteredFlatOptions
;
},
},
render
RenderFilteredOption
(
inputValue
,
optionsStack
)
{
render
FilteredOptionLabel
(
inputValue
,
optionsStack
)
{
return
optionsStack
.
map
(({
label
},
index
)
=>
{
return
optionsStack
.
map
(({
label
},
index
)
=>
{
const
node
=
label
.
indexOf
(
inputValue
)
>
-
1
?
this
.
highlightKeyword
(
label
,
inputValue
)
:
label
;
const
node
=
label
.
indexOf
(
inputValue
)
>
-
1
?
this
.
highlightKeyword
(
label
,
inputValue
)
:
label
;
return
index
===
0
?
node
:
[
'
/
'
,
node
];
return
index
===
0
?
node
:
[
'
/
'
,
node
];
...
@@ -203,8 +214,7 @@ export default {
...
@@ -203,8 +214,7 @@ export default {
const
optionsStack
=
ancestor
.
concat
(
option
);
const
optionsStack
=
ancestor
.
concat
(
option
);
if
(
!
option
.
children
)
{
if
(
!
option
.
children
)
{
flatOptions
.
push
(
optionsStack
);
flatOptions
.
push
(
optionsStack
);
}
}
else
{
if
(
option
.
children
)
{
flatOptions
=
flatOptions
.
concat
(
this
.
flattenOptions
(
option
.
children
,
optionsStack
));
flatOptions
=
flatOptions
.
concat
(
this
.
flattenOptions
(
option
.
children
,
optionsStack
));
}
}
});
});
...
...
packages/cascader/src/menu.vue
View file @
964eb5ad
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
data
()
{
data
()
{
return
{
return
{
inputWidth
:
0
,
options
:
[],
options
:
[],
visible
:
false
,
visible
:
false
,
activeValue
:
[],
activeValue
:
[],
...
@@ -56,34 +57,19 @@
...
@@ -56,34 +57,19 @@
},
},
methods
:
{
methods
:
{
selectItem
(
item
,
menuIndex
)
{
select
(
item
,
menuIndex
)
{
const
len
=
this
.
activeOptions
.
length
;
const
closeMenu
=
!
item
.
children
;
if
(
item
.
__IS__FLAT__OPTIONS
)
{
if
(
item
.
__IS__FLAT__OPTIONS
)
{
this
.
activeValue
.
splice
(
menuIndex
,
len
,
...
item
.
value
)
;
this
.
activeValue
=
item
.
value
;
}
else
{
}
else
{
this
.
activeValue
.
splice
(
menuIndex
,
len
,
item
.
value
);
this
.
activeValue
.
splice
(
menuIndex
,
1
,
item
.
value
);
}
if
(
this
.
changeOnSelect
)
{
this
.
$emit
(
'
pick
'
,
this
.
activeValue
,
closeMenu
);
}
}
this
.
$emit
(
'
pick
'
,
this
.
activeValue
);
},
},
expand
Item
(
item
,
menuIndex
)
{
active
Item
(
item
,
menuIndex
)
{
const
len
=
this
.
activeOptions
.
length
;
const
len
=
this
.
activeOptions
.
length
;
if
(
item
.
children
)
{
this
.
activeValue
.
splice
(
menuIndex
,
len
,
item
.
value
);
this
.
activeValue
.
splice
(
menuIndex
,
len
,
item
.
value
);
this
.
activeOptions
.
splice
(
menuIndex
+
1
,
len
,
item
.
children
);
this
.
activeOptions
.
splice
(
menuIndex
+
1
,
len
,
item
.
children
);
if
(
this
.
changeOnSelect
)
this
.
$emit
(
'
pick
'
,
this
.
activeValue
,
false
);
}
},
handleItemClick
(
item
,
menuIndex
)
{
this
.
expandItem
(
item
,
menuIndex
);
this
.
selectItem
(
item
,
menuIndex
);
if
(
!
item
.
children
&&
!
this
.
changeOnSelect
)
{
this
.
$emit
(
'
pick
'
,
this
.
activeValue
);
}
}
}
},
},
...
@@ -96,17 +82,24 @@
...
@@ -96,17 +82,24 @@
popperClass
popperClass
}
=
this
;
}
=
this
;
const
menus
=
this
.
_l
(
activeOptions
,
(
menu
,
index
)
=>
{
const
menus
=
this
.
_l
(
activeOptions
,
(
menu
,
menuIndex
)
=>
{
let
isFlat
=
false
;
const
items
=
this
.
_l
(
menu
,
item
=>
{
const
items
=
this
.
_l
(
menu
,
item
=>
{
const
events
=
{
const
events
=
{
on
:
{}
on
:
{}
};
};
if
(
item
.
__IS__FLAT__OPTIONS
)
isFlat
=
true
;
if
(
!
item
.
disabled
)
{
if
(
!
item
.
disabled
)
{
if
(
expandTrigger
===
'
click
'
||
!
item
.
children
)
{
if
(
item
.
children
)
{
events
.
on
[
'
click
'
]
=
()
=>
{
this
.
handleItemClick
(
item
,
index
);
};
let
triggerEvent
=
{
click
:
'
click
'
,
hover
:
'
mouseenter
'
}[
expandTrigger
];
events
.
on
[
triggerEvent
]
=
()
=>
{
this
.
activeItem
(
item
,
menuIndex
);
};
}
else
{
}
else
{
events
.
on
[
'
mouseenter
'
]
=
()
=>
{
this
.
expandItem
(
item
,
i
ndex
);
};
events
.
on
.
click
=
()
=>
{
this
.
select
(
item
,
menuI
ndex
);
};
}
}
}
}
...
@@ -115,7 +108,7 @@
...
@@ -115,7 +108,7 @@
class
=
{{
class
=
{{
'
el-cascader-menu__item
'
:
true
,
'
el-cascader-menu__item
'
:
true
,
'
el-cascader-menu__item--extensible
'
:
item
.
children
,
'
el-cascader-menu__item--extensible
'
:
item
.
children
,
'
is-active
'
:
item
.
value
===
activeValue
[
i
ndex
],
'
is-active
'
:
item
.
value
===
activeValue
[
menuI
ndex
],
'
is-disabled
'
:
item
.
disabled
'
is-disabled
'
:
item
.
disabled
}}
}}
{...
events
}
{...
events
}
...
@@ -124,11 +117,31 @@
...
@@ -124,11 +117,31 @@
<
/li
>
<
/li
>
);
);
});
});
return
<
ul
class
=
"
el-cascader-menu
"
>
{
items
}
<
/ul>
;
let
menuStyle
=
{};
if
(
isFlat
)
{
menuStyle
.
width
=
this
.
inputWidth
+
'
px
'
;
}
return
(
<
ul
class
=
{{
'
el-cascader-menu
'
:
true
,
'
el-cascader-menu--flexible
'
:
isFlat
}}
style
=
{
menuStyle
}
>
{
items
}
<
/ul
>
);
});
});
return
(
return
(
<
transition
name
=
"
el-zoom-in-top
"
>
<
transition
name
=
"
el-zoom-in-top
"
>
<
div
class
=
{[
'
el-cascader-menus
'
,
popperClass
]}
v
-
show
=
{
visible
}
>
<
div
v
-
show
=
{
visible
}
class
=
{[
'
el-cascader-menus
'
,
popperClass
]}
>
{
menus
}
{
menus
}
<
/div
>
<
/div
>
<
/transition
>
<
/transition
>
...
...
packages/theme-default/src/cascader.css
View file @
964eb5ad
...
@@ -150,5 +150,15 @@
...
@@ -150,5 +150,15 @@
}
}
}
}
}
}
@m
flexible
{
height
:
auto
;
max-height
:
180px
;
overflow
:
auto
;
.el-cascader-menu__item
{
overflow
:
visible
;
}
}
}
}
}
}
src/locale/lang/en.js
View file @
964eb5ad
...
@@ -56,6 +56,10 @@ export default {
...
@@ -56,6 +56,10 @@ export default {
noData
:
'
No data
'
,
noData
:
'
No data
'
,
placeholder
:
'
Select
'
placeholder
:
'
Select
'
},
},
cascader
:
{
noMatch
:
'
No matching data
'
,
placeholder
:
'
Select
'
},
pagination
:
{
pagination
:
{
goto
:
'
Go to
'
,
goto
:
'
Go to
'
,
pagesize
:
'
/page
'
,
pagesize
:
'
/page
'
,
...
...
src/locale/lang/zh-CN.js
View file @
964eb5ad
...
@@ -56,6 +56,10 @@ export default {
...
@@ -56,6 +56,10 @@ export default {
noData
:
'
无数据
'
,
noData
:
'
无数据
'
,
placeholder
:
'
请选择
'
placeholder
:
'
请选择
'
},
},
cascader
:
{
noMatch
:
'
无匹配数据
'
,
placeholder
:
'
请选择
'
},
pagination
:
{
pagination
:
{
goto
:
'
前往
'
,
goto
:
'
前往
'
,
pagesize
:
'
条/页
'
,
pagesize
:
'
条/页
'
,
...
...
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