Skip to content

Commit

Permalink
releases 4.3.14
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 3, 2024
1 parent c61806e commit c534016
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-pc-ui",
"version": "4.3.13",
"version": "4.3.14",
"description": "A vue based PC component library",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down Expand Up @@ -63,7 +63,7 @@
"vue": "3.5.5",
"vue-i18n": "^9.13.1",
"vue-router": "^4.3.2",
"vxe-table": "^4.9.11"
"vxe-table": "^4.9.13"
},
"vetur": {
"tags": "helper/vetur/tags.json",
Expand Down
102 changes: 93 additions & 9 deletions packages/tree/src/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ export default defineComponent({
emit('update:checkNodeKey', value)
}

const setRadioNode = (node: any, checked: boolean) => {
const setRadioNode = (node: any) => {
if (node) {
reactData.selectRadioKey = checked ? getNodeId(node) : null
reactData.selectRadioKey = getNodeId(node)
}
return nextTick()
}
Expand Down Expand Up @@ -370,19 +370,82 @@ export default defineComponent({

const treeMethods: TreeMethods = {
dispatchEvent,
clearCurrentNode () {
reactData.currentNode = null
return nextTick()
},
getCurrentNodeId () {
const { currentNode } = reactData
if (currentNode) {
return getNodeId(currentNode)
}
return null
},
getCurrentNode () {
const { currentNode, nodeMaps } = reactData
if (currentNode) {
const nodeItem = nodeMaps[currentNode]
if (nodeItem) {
return nodeItem.item
}
}
return null
},
setCurrentNodeId (nodeKey) {
const { nodeMaps } = reactData
const nodeItem = nodeMaps[nodeKey]
reactData.currentNode = nodeItem ? nodeItem.item : null
return nextTick()
},
setCurrentNode (node) {
reactData.currentNode = node
return nextTick()
},
clearRadioNode () {
reactData.selectRadioKey = null
return nextTick()
},
getRadioNodeId () {
return reactData.selectRadioKey || null
},
getRadioNode () {
const { selectRadioKey, nodeMaps } = reactData
if (selectRadioKey) {
const nodeItem = nodeMaps[selectRadioKey]
if (nodeItem) {
return nodeItem.item
}
}
return null
},
setRadioNodeId (nodeKey) {
reactData.selectRadioKey = nodeKey
return nextTick()
},
setRadioNode,
setCheckboxNode,
setCheckboxByNodeId,
getCheckboxNodeIds () {
const { selectCheckboxMaps } = reactData
return Object.keys(selectCheckboxMaps)
},
getCheckboxNodes () {
const { nodeMaps, selectCheckboxMaps } = reactData
const list: any[] = []
XEUtils.each(selectCheckboxMaps, (item, nodeid) => {
const nodeItem = nodeMaps[nodeid]
if (nodeItem) {
list.push(nodeItem.item)
}
})
return list
},
clearCheckboxNode () {
reactData.selectCheckboxMaps = {}
return nextTick()
},
setAllCheckboxNode (checked) {
const selectMaps: Record<string, boolean> = Object.assign({}, reactData.selectCheckboxMaps)
const selectMaps: Record<string, boolean> = {}
const childrenField = computeChildrenField.value
if (checked) {
XEUtils.eachTree(reactData.treeList, (node) => {
Expand Down Expand Up @@ -416,6 +479,21 @@ export default defineComponent({
}
return nextTick()
},
getExpandNodeIds () {
const { treeExpandedMaps } = reactData
return Object.keys(treeExpandedMaps)
},
getExpandNodes () {
const { nodeMaps, treeExpandedMaps } = reactData
const list: any[] = []
XEUtils.each(treeExpandedMaps, (item, nodeid) => {
const nodeItem = nodeMaps[nodeid]
if (nodeItem) {
list.push(nodeItem.item)
}
})
return list
},
setExpandNode (nodes, expanded) {
const expandedMaps: Record<string, boolean> = Object.assign({}, reactData.treeExpandedMaps)
if (nodes) {
Expand Down Expand Up @@ -457,13 +535,19 @@ export default defineComponent({
}
return nextTick()
},
setAllExpandNode () {
const expandedMaps: Record<string, boolean> = Object.assign({}, reactData.treeExpandedMaps)
setAllExpandNode (expanded) {
const expandedMaps: Record<string, boolean> = {}
const childrenField = computeChildrenField.value
XEUtils.eachTree(reactData.treeList, (node) => {
const nodeid = getNodeId(node)
expandedMaps[nodeid] = true
}, { children: childrenField })
if (expanded) {
XEUtils.eachTree(reactData.treeList, (node) => {
const childList: any[] = XEUtils.get(node, childrenField)
const hasChild = childList && childList.length
if (hasChild) {
const nodeid = getNodeId(node)
expandedMaps[nodeid] = true
}
}, { children: childrenField })
}
reactData.treeExpandedMaps = expandedMaps
return nextTick()
},
Expand Down
16 changes: 14 additions & 2 deletions types/components/tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DefineVxeComponentApp, DefineVxeComponentOptions, DefineVxeComponentIns
export declare const VxeTree: DefineVxeComponentApp<VxeTreeProps, VxeTreeEventProps, VxeTreeSlots>
export type VxeTreeComponent = DefineVxeComponentOptions<VxeTreeProps, VxeTreeEventProps>

export type VxeTreeInstance = DefineVxeComponentInstance<VxeTreeProps, VxeTreeConstructor>
export type VxeTreeInstance<D = any> = DefineVxeComponentInstance<VxeTreeProps<D>, VxeTreeConstructor<D>>

export interface VxeTreeConstructor<D = any> extends VxeComponentBaseOptions, VxeTreeMethods<D> {
props: VxeTreeProps
Expand Down Expand Up @@ -176,8 +176,18 @@ export interface TreeInternalData {

export interface TreeMethods<D = any> {
dispatchEvent(type: ValueOf<VxeTreeEmits>, params: Record<string, any>, evnt: Event | null): void
getCurrentNodeId(): string | number | null
getCurrentNode(): any | null
clearCurrentNode(): Promise<any>
setCurrentNodeId(nodeKey: string | number): Promise<any>
setCurrentNode(node: any): Promise<any>
getRadioNodeId(): string | number | null
getRadioNode(): any | null
clearRadioNode(): Promise<any>
setRadioNode(node: any, checked: boolean): Promise<any>
setRadioNodeId(nodeKey: string | number): Promise<any>
setRadioNode(node: any): Promise<any>
getCheckboxNodeIds(): (string | number)[]
getCheckboxNodes(): D[]
clearCheckboxNode(): Promise<any>
setAllCheckboxNode(checked: boolean): Promise<any>
setCheckboxNode(nodeList: any | any[], checked: boolean): Promise<any>
Expand All @@ -193,6 +203,8 @@ export interface TreeMethods<D = any> {
toggleExpandByNodeId(nodeKeys: any | any[]): Promise<any>
toggleExpandNode(nodeList: any | any[]): Promise<any>
setAllExpandNode(expanded: boolean): Promise<any>
getExpandNodeIds(): (string | number)[]
getExpandNodes(): D[]
reloadExpandNode(node: any): Promise<any>
clearExpandLoaded(node: any): Promise<any>
loadChildrenNode(node: any, childRecords: any[]): Promise<any>
Expand Down

0 comments on commit c534016

Please sign in to comment.