feat: select-picker组件增加open、close事件 (#395)

This commit is contained in:
kqswzhyb 2024-07-03 22:37:14 +08:00 committed by GitHub
parent 519d17235b
commit 9237a04bcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -377,6 +377,8 @@ function handleConfirm({ value, selectedItems }) {
| confirm | 点击确认时触发 | event.detail = { value, selectedItems }, checkbox 类型时 value 和 selectedItems 为数组radio 类型为非数组 | - |
| change | picker 内选项更改时触发 | `{ value }`, checkbox 类型时 value 为数组radio 类型为非数组 | - |
| cancel | 点击关闭按钮或者蒙层时触发 | - | - |
| close | 弹窗关闭时触发 | - | 1.2.29 |
| open | 弹窗打开时触发 | - | 1.2.29 |
## Methods

View File

@ -126,7 +126,7 @@ import { selectPickerProps, type SelectPickerExpose } from './types'
const { translate } = useTranslate('select-picker')
const props = defineProps(selectPickerProps)
const emit = defineEmits(['change', 'cancel', 'confirm', 'update:modelValue'])
const emit = defineEmits(['change', 'cancel', 'confirm', 'update:modelValue','open','close'])
const pickerShow = ref<boolean>(false)
const selectList = ref<Array<number | boolean | string> | number | boolean | string>([])
@ -330,6 +330,7 @@ function close() {
selectList.value = valueFormat(lastSelectList.value)
}
emit('cancel')
emit('close')
}
function open() {
@ -337,12 +338,14 @@ function open() {
selectList.value = valueFormat(props.modelValue)
pickerShow.value = true
isConfirm.value = false
emit('open')
}
function onConfirm() {
if (props.loading) {
pickerShow.value = false
emit('confirm')
emit('close')
return
}
if (props.beforeConfirm) {
@ -371,6 +374,7 @@ function handleConfirm() {
value: lastSelectList.value,
selectedItems
})
emit('close')
}
function getFilterText(label: string, filterVal: string) {