diff --git a/src/password-input/index.js b/src/password-input/index.js index d8084d5a4..e942a2ac7 100644 --- a/src/password-input/index.js +++ b/src/password-input/index.js @@ -27,10 +27,10 @@ export default createComponent({ emits: ['focus'], setup(props, { emit }) { - function onTouchStart(event) { + const onTouchStart = (event) => { event.stopPropagation(); emit('focus', event); - } + }; return () => { const { mask, value, length, gutter, focused, errorInfo } = props; diff --git a/src/tree-select/index.js b/src/tree-select/index.js index 3ecb0a07d..1c304cfbe 100644 --- a/src/tree-select/index.js +++ b/src/tree-select/index.js @@ -44,18 +44,61 @@ export default createComponent({ ], setup(props, { emit, slots }) { - return function () { - const { items, height, activeId, selectedIcon, mainActiveIndex } = props; + const isMultiple = () => Array.isArray(props.activeId); - const selectedItem = items[+mainActiveIndex] || {}; - const subItems = selectedItem.children || []; - const isMultiple = Array.isArray(activeId); + const isActiveItem = (id) => { + return isMultiple() + ? props.activeId.indexOf(id) !== -1 + : props.activeId === id; + }; - function isActiveItem(id) { - return isMultiple ? activeId.indexOf(id) !== -1 : activeId === id; - } + const renderSubItem = (item) => { + const onClick = () => { + if (item.disabled) { + return; + } - const Navs = items.map((item) => ( + let activeId; + if (isMultiple()) { + activeId = props.activeId.slice(); + + const index = activeId.indexOf(item.id); + + if (index !== -1) { + activeId.splice(index, 1); + } else if (activeId.length < props.max) { + activeId.push(item.id); + } + } else { + activeId = item.id; + } + + emit('update:activeId', activeId); + emit('click-item', item); + }; + + return ( +