下拉选不收回

This commit is contained in:
hongchao 2025-09-17 21:16:50 +08:00
parent dfcd7d8678
commit d1831e7428
2 changed files with 21 additions and 6 deletions

View File

@ -115,6 +115,7 @@
:localdata="codeRange" :localdata="codeRange"
@change="changeCode" @change="changeCode"
@click="handleMaCode" @click="handleMaCode"
:keepOpen="true"
></uni-data-select> ></uni-data-select>
</uni-col> </uni-col>
</uni-row> </uni-row>
@ -820,4 +821,4 @@ const ocrClick = () => {
} }
} }
} }
</style> </style>

View File

@ -37,7 +37,7 @@
/> />
</view> </view>
<view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" /> <view class="uni-select--mask" v-if="showSelector" @click="closeSelector" />
<view class="uni-select__selector" :style="getOffsetByPlacement" v-if="showSelector"> <view class="uni-select__selector" :style="getOffsetByPlacement" v-if="showSelector">
<view <view
:class="placement == 'bottom' ? 'uni-popper__arrow_bottom' : 'uni-popper__arrow_top'" :class="placement == 'bottom' ? 'uni-popper__arrow_bottom' : 'uni-popper__arrow_top'"
@ -137,6 +137,10 @@ export default {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
keepOpen: {
type: Boolean,
default: false,
},
}, },
data() { data() {
return { return {
@ -244,8 +248,11 @@ export default {
}, },
change(item) { change(item) {
if (!item.disable) { if (!item.disable) {
this.showSelector = false // keepOpenfalse
this.showInput = false if (!this.keepOpen) {
this.showSelector = false
this.showInput = false
}
this.searchValue = '' this.searchValue = ''
this.current = this.formatItemName(item) this.current = this.formatItemName(item)
this.emit(item.value) this.emit(item.value)
@ -263,13 +270,20 @@ export default {
this.showSelector = true this.showSelector = true
this.searchValue = '' this.searchValue = ''
}, },
closeSelector() {
//
this.showInput = false
this.showSelector = false
},
onSearchInput(val) { onSearchInput(val) {
this.searchValue = val this.searchValue = val
}, },
onInputBlur() { onInputBlur() {
// blur // blur
setTimeout(() => { setTimeout(() => {
if (this.showSelector) { // keepOpenfalse
if (this.showSelector && !this.keepOpen) {
this.showInput = false this.showInput = false
this.showSelector = false this.showSelector = false
} }
@ -447,4 +461,4 @@ export default {
display: none; display: none;
} }
} }
</style> </style>