refactor(components): [tree & date-picker] use public function and type (#16017)

This commit is contained in:
btea 2024-03-02 20:41:58 +08:00 committed by GitHub
parent 76b0d5fcb5
commit 6ccc8ee915
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View File

@ -593,7 +593,7 @@ const isValidValue = (date: unknown) => {
}
const formatToString = (value: Dayjs | Dayjs[]) => {
return Array.isArray(value)
return isArray(value)
? (value as Dayjs[]).map((_) => _.format(props.format))
: (value as Dayjs).format(props.format)
}

View File

@ -17,6 +17,7 @@ import type { Ref } from 'vue'
import type ElSelect from '@element-plus/components/select'
import type Node from '@element-plus/components/tree/src/model/node'
import type { TreeNodeData } from '@element-plus/components/tree/src/tree.type'
import type { TreeInstance } from '@element-plus/components/tree'
export const useTree = (
props,
@ -27,7 +28,7 @@ export const useTree = (
key,
}: {
select: Ref<InstanceType<typeof ElSelect> | undefined>
tree: Ref<InstanceType<typeof ElTree> | undefined>
tree: Ref<TreeInstance | undefined>
key: Ref<string>
}
) => {
@ -208,9 +209,7 @@ export const useTree = (
if (props.multiple) {
emit(
UPDATE_MODEL_EVENT,
cachedKeys.concat(
(tree.value as InstanceType<typeof ElTree>).getCheckedKeys(true)
)
cachedKeys.concat((tree.value as TreeInstance).getCheckedKeys(true))
)
} else {
// select first leaf node when check parent