|
|
|
@ -6,7 +6,7 @@ |
|
|
|
<component :is="renderIcon('element Search')"></component> |
|
|
|
</template> |
|
|
|
</el-input> |
|
|
|
<span class="close" @click="closeMe('hideLeft')"> |
|
|
|
<span class="close" @click="closeMe"> |
|
|
|
<component :is="renderIcon('element Close')" /> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
@ -32,11 +32,12 @@ |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import { renderIcon } from '@/utils/webutils.js' |
|
|
|
|
|
|
|
import IWidgets from '../IWidgets.js' |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'ToolboxView', |
|
|
|
emits: ['close'], |
|
|
|
mixins: [IWidgets], |
|
|
|
data() { |
|
|
|
return { |
|
|
|
searchKeyword: '', |
|
|
|
@ -113,7 +114,6 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
renderIcon, |
|
|
|
closeMe() { |
|
|
|
this.$emit('close') |
|
|
|
}, |
|
|
|
@ -124,34 +124,34 @@ export default { |
|
|
|
console.log(key, keyPath) |
|
|
|
}, |
|
|
|
updateFilteredItemsAndExpand() { |
|
|
|
const expandedKeys = []; |
|
|
|
const expandedKeys = [] |
|
|
|
this.itemTypes.forEach(itemType => { |
|
|
|
const filteredChildren = itemType.children.filter(item => |
|
|
|
item.label.includes(this.searchKeyword) || item.name.includes(this.searchKeyword)); |
|
|
|
item.label.includes(this.searchKeyword) || item.name.includes(this.searchKeyword)) |
|
|
|
if (filteredChildren.length > 0) { |
|
|
|
expandedKeys.push(itemType.name); |
|
|
|
expandedKeys.push(itemType.name) |
|
|
|
} |
|
|
|
itemType.children = filteredChildren; |
|
|
|
}); |
|
|
|
this.defaultExpandedKeys = expandedKeys; |
|
|
|
itemType.children = filteredChildren |
|
|
|
}) |
|
|
|
this.defaultExpandedKeys = expandedKeys |
|
|
|
} |
|
|
|
}, |
|
|
|
watch:{ |
|
|
|
watch: { |
|
|
|
searchKeyword(newVal) { |
|
|
|
if (!newVal) { |
|
|
|
// 如果搜索框为空,则重置菜单状态 |
|
|
|
this.itemTypes.forEach(itemType => { |
|
|
|
itemType.children = this.originalItemTypes.find(originalItemType => originalItemType.name === itemType.name).children; |
|
|
|
}); |
|
|
|
this.defaultExpandedKeys = []; |
|
|
|
itemType.children = this.originalItemTypes.find(originalItemType => originalItemType.name === itemType.name).children |
|
|
|
}) |
|
|
|
this.defaultExpandedKeys = [] |
|
|
|
} else { |
|
|
|
this.updateFilteredItemsAndExpand(); |
|
|
|
this.updateFilteredItemsAndExpand() |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
// 保存原始的 itemTypes 用于重置 |
|
|
|
this.originalItemTypes = JSON.parse(JSON.stringify(this.itemTypes)); |
|
|
|
this.originalItemTypes = JSON.parse(JSON.stringify(this.itemTypes)) |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|