mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
feat: ✨select-picker组件增加open、close事件 (#395)
This commit is contained in:
parent
519d17235b
commit
9237a04bcb
@ -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
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user