进件代码调整,增加进件列表页面和筛选

This commit is contained in:
2026-01-12 15:33:08 +08:00
parent 684014e183
commit 1a16b0b3dd
11 changed files with 1192 additions and 324 deletions

View File

@@ -2,7 +2,9 @@
<scroll-view scroll-x="true" scroll-with-animation :scroll-left="scrollLeft" class="steps-scroll-container"
ref="scrollViewRef">
<view class="steps-content" ref="contentRef">
<view v-for="(item,index) in list" class="step-item" :key="index" :data-index="index" ref="stepItemRefs">
<view v-for="(item,index) in list" class="step-item" :key="index" :data-index="index"
:class="'step_'+index"
ref="stepItemRefs">
<view class="step-inner">
<view class="index" :class="{active:index<=cur}">
<text>{{index+1}}</text>
@@ -23,12 +25,13 @@
import {
ref,
nextTick,
getCurrentInstance
getCurrentInstance,
watch
} from 'vue';
const cur = defineModel({
default:0
})
default: 0
})
const scrollLeft = ref(0)
const scrollViewRef = ref(null)
const contentRef = ref(null) // 内容容器ref
@@ -36,60 +39,66 @@
const instance = getCurrentInstance()
function isActive(index) {
return cur.value === index
return index <= cur.value
}
// 核心:精准居中计算(基于元素相对于内容容器的偏移)
const calcScrollCenter = (index) => {
nextTick(async () => {
try {
const query = uni.createSelectorQuery().in(instance)
const calcScrollCenter = async (index) => {
try {
console.log('calcScrollCenter');
const query = uni.createSelectorQuery().in(instance)
// 1. 获取滚动容器宽度
const [scrollViewRect] = await new Promise(resolve => {
query.select('.steps-scroll-container').boundingClientRect(rect => resolve([
rect
])).exec()
})
const scrollViewWidth = scrollViewRect?.width || 0
// 1. 获取滚动容器宽度
const [scrollViewRect] = await new Promise(resolve => {
query.select('.steps-scroll-container').boundingClientRect(rect => resolve([
rect
])).exec()
})
const scrollViewWidth = scrollViewRect?.width || 0
// 2. 获取当前步骤项的布局信息
const [itemRect] = await new Promise(resolve => {
query.select(`.step_${index}`).boundingClientRect(rect =>
resolve([rect])).exec()
})
console.log('itemRect',itemRect);
// 3. 获取内容容器的布局信息
const [contentRect] = await new Promise(resolve => {
query.select('.steps-content').boundingClientRect(rect => resolve([rect]))
.exec()
})
// 2. 获取当前步骤项的布局信息
const [itemRect] = await new Promise(resolve => {
query.select(`.step-item[data-index="${index}"]`).boundingClientRect(rect =>
resolve([rect])).exec()
})
if (!itemRect || !contentRect) return
// 3. 获取内容容器的布局信息
const [contentRect] = await new Promise(resolve => {
query.select('.steps-content').boundingClientRect(rect => resolve([rect]))
.exec()
})
// 关键修正:元素相对于内容容器的左偏移(而非视口)
const itemOffsetLeft = itemRect.left - contentRect.left
// 居中公式:滚动距离 = 元素偏移 - (容器宽度/2) + (元素宽度/2)
let targetScrollLeft = itemOffsetLeft - (scrollViewWidth / 2) + (itemRect.width / 2)
if (!itemRect || !contentRect) return
// 4. 计算最大可滚动距离(边界限制)
const maxScrollLeft = Math.max(0, contentRect.width - scrollViewWidth)
// 限制滚动范围,避免超出边界
targetScrollLeft = Math.max(0, Math.min(targetScrollLeft, maxScrollLeft))
// 关键修正:元素相对于内容容器的左偏移(而非视口
const itemOffsetLeft = itemRect.left - contentRect.left
// 居中公式:滚动距离 = 元素偏移 - (容器宽度/2) + (元素宽度/2)
let targetScrollLeft = itemOffsetLeft - (scrollViewWidth / 2) + (itemRect.width / 2)
// 5. 设置滚动距离(强制整数,避免小数导致的偏移
scrollLeft.value = Math.round(targetScrollLeft)
// 4. 计算最大可滚动距离(边界限制)
const maxScrollLeft = Math.max(0, contentRect.width - scrollViewWidth)
// 限制滚动范围,避免超出边界
targetScrollLeft = Math.max(0, Math.min(targetScrollLeft, maxScrollLeft))
// 5. 设置滚动距离(强制整数,避免小数导致的偏移)
scrollLeft.value = Math.round(targetScrollLeft)
} catch (e) {
console.error('计算居中失败:', e)
}
})
console.log('scrollLeft', scrollLeft.value);
} catch (e) {
console.error('计算居中失败:', e)
}
}
const emits = defineEmits(['itemClick'])
// 点击事件
const handleClick = (index) => {
if (cur.value === index) return
if (index > cur.value) {
emits('itemClick', index)
return
}
cur.value = index
calcScrollCenter(index)
// calcScrollCenter(index)
}
// 初始化居中
@@ -97,6 +106,10 @@
calcScrollCenter(cur.value)
})
watch(() => cur.value, (newval) => {
calcScrollCenter(newval)
})
// 步骤列表
const list = ref(['基础信息', '法人信息', '营业执照信息', '门店信息', '结算信息'])
</script>