包装管理列表

This commit is contained in:
2026-06-11 14:11:56 +08:00
parent 06781c69e1
commit 780814bad4
9 changed files with 622 additions and 216 deletions
+14 -2
View File
@@ -22,7 +22,7 @@
</view>
<!-- 列表内容 -->
<scroll-view scroll-y="true" class="nbd-select-inner">
<scroll-view scroll-y="true" class="nbd-select-inner" :scroll-into-view="scrollIntoView">
<view class="nbd-select-inner-wrap">
<!-- 空状态 -->
<view class="nbd-select-empty" v-if="filteredList.length === 0">
@@ -30,7 +30,7 @@
</view>
<!-- 列表项 -->
<view v-for="(item, idx) in filteredList" :key="idx" class="nbd-select-item"
<view v-for="(item, idx) in filteredList" :key="idx" :id="'item-' + idx" class="nbd-select-item"
:class="{ active: isSelected(item) }" @click="handleItemClick(item)">
<text class="nbd-select-item-text">{{ item[labelKey] }}</text>
<view v-if="multiple" class="nbd-select-checkbox">
@@ -133,6 +133,7 @@
const localVisible = ref(false)
const searchKey = ref('')
const scrollIntoView = ref('')
// 当前选中的项(多选时为数组)
const selectedItems = ref(props.multiple ? (props.model || []) : (props.model || null))
@@ -150,6 +151,17 @@
if (val) {
// 打开时重置搜索
searchKey.value = ''
// 滚动到选中的项
setTimeout(() => {
if (selectedItems.value && !props.multiple) {
const index = props.list?.findIndex(item =>
item[props.valueKey] === selectedItems.value[props.valueKey]
)
if (index !== undefined && index > -1) {
scrollIntoView.value = 'item-' + index
}
}
}, 300)
}
})