Skip to content

Commit 9237a04

Browse files
authored
feat: ✨select-picker组件增加open、close事件 (#395)
1 parent 519d172 commit 9237a04

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/component/select-picker.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ function handleConfirm({ value, selectedItems }) {
377377
| confirm | 点击确认时触发 | event.detail = { value, selectedItems }, checkbox 类型时 value 和 selectedItems 为数组,radio 类型为非数组 | - |
378378
| change | picker 内选项更改时触发 | `{ value }`, checkbox 类型时 value 为数组,radio 类型为非数组 | - |
379379
| cancel | 点击关闭按钮或者蒙层时触发 | - | - |
380+
| close | 弹窗关闭时触发 | - | 1.2.29 |
381+
| open | 弹窗打开时触发 | - | 1.2.29 |
380382

381383
## Methods
382384

src/uni_modules/wot-design-uni/components/wd-select-picker/wd-select-picker.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ import { selectPickerProps, type SelectPickerExpose } from './types'
126126
const { translate } = useTranslate('select-picker')
127127
128128
const props = defineProps(selectPickerProps)
129-
const emit = defineEmits(['change', 'cancel', 'confirm', 'update:modelValue'])
129+
const emit = defineEmits(['change', 'cancel', 'confirm', 'update:modelValue','open','close'])
130130
131131
const pickerShow = ref<boolean>(false)
132132
const selectList = ref<Array<number | boolean | string> | number | boolean | string>([])
@@ -330,19 +330,22 @@ function close() {
330330
selectList.value = valueFormat(lastSelectList.value)
331331
}
332332
emit('cancel')
333+
emit('close')
333334
}
334335
335336
function open() {
336337
if (props.disabled || props.readonly) return
337338
selectList.value = valueFormat(props.modelValue)
338339
pickerShow.value = true
339340
isConfirm.value = false
341+
emit('open')
340342
}
341343
342344
function onConfirm() {
343345
if (props.loading) {
344346
pickerShow.value = false
345347
emit('confirm')
348+
emit('close')
346349
return
347350
}
348351
if (props.beforeConfirm) {
@@ -371,6 +374,7 @@ function handleConfirm() {
371374
value: lastSelectList.value,
372375
selectedItems
373376
})
377+
emit('close')
374378
}
375379
376380
function getFilterText(label: string, filterVal: string) {

0 commit comments

Comments
 (0)