增加页面滚动初始位置
This commit is contained in:
parent
988a14ada7
commit
566c94f356
|
|
@ -27,21 +27,34 @@
|
|||
<uni-row :gutter="24" class="search-form">
|
||||
<uni-col :span="18">
|
||||
<view>
|
||||
<uni-easyinput placeholder="请输入内容" v-model="queryParams.keyWord"/>
|
||||
<uni-easyinput placeholder="请输入内容" v-model="queryParams.keyWord" />
|
||||
</view>
|
||||
</uni-col>
|
||||
<uni-col :span="6">
|
||||
<view class="search" @click="getTableList(true)">搜索</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<scroll-view scroll-y @scrolltolower="onScrollTolower" class="scroll-container">
|
||||
<div class="table-list-item" v-for="(item, index) in tableList" :key="index" @click="handleItem(item)">
|
||||
|
||||
<scroll-view
|
||||
scroll-y
|
||||
:scroll-top="scrollTop"
|
||||
class="scroll-container"
|
||||
scroll-with-animation
|
||||
@scroll="onScrollChange"
|
||||
@scrolltolower="onScrollTolower"
|
||||
>
|
||||
<div
|
||||
class="table-list-item"
|
||||
v-for="(item, index) in tableList"
|
||||
:key="index"
|
||||
@click="handleItem(item)"
|
||||
>
|
||||
<div class="title">
|
||||
<div class="title-left">
|
||||
<span class="code">{{ item.code }}</span>
|
||||
</div>
|
||||
<span :class="['status', active == 1 ? 'pending' : 'completed']">
|
||||
{{active == 1 ? '未完成' : '已完成'}}
|
||||
{{ active == 1 ? '未完成' : '已完成' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="line"></div>
|
||||
|
|
@ -78,9 +91,9 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { getPurchaseList } from '../../../services/purchase.js'
|
||||
import { onLoad,onShow } from '@dcloudio/uni-app'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { debounce } from 'lodash-es'
|
||||
const active = ref(1)
|
||||
const tableList = ref([])
|
||||
|
|
@ -92,8 +105,8 @@ const queryParams = ref({
|
|||
keyWord: '', // 关键字
|
||||
taskStage: 2, // 验收
|
||||
isFinish: '0', // 未完成
|
||||
pageNum:1,
|
||||
pageSize:5,
|
||||
pageNum: 1,
|
||||
pageSize: 5,
|
||||
})
|
||||
// 获列表数据
|
||||
const getTableList = async (isTap = false) => {
|
||||
|
|
@ -169,8 +182,8 @@ const handleItem = (item) => {
|
|||
// 是否完成
|
||||
const isFinished = item.taskStatusName == '已完成'
|
||||
const singLevel = {
|
||||
'2': '技术科',
|
||||
'3': '库管班',
|
||||
2: '技术科',
|
||||
3: '库管班',
|
||||
}
|
||||
const deptName = uni.getStorageSync('deptName')
|
||||
if (!deptName.includes(singLevel[item.signLevel]) && !isFinished) {
|
||||
|
|
@ -180,11 +193,26 @@ const handleItem = (item) => {
|
|||
})
|
||||
return
|
||||
}
|
||||
uni.navigateTo({ url: `/pages/new-purchase/accept/acceptDetails?id=${item.id}&taskId=${item.taskId}&isFinished=${isFinished}` })
|
||||
uni.navigateTo({
|
||||
url: `/pages/new-purchase/accept/acceptDetails?id=${item.id}&taskId=${item.taskId}&isFinished=${isFinished}`,
|
||||
})
|
||||
}
|
||||
|
||||
const scrollTop = ref(0)
|
||||
onShow((options) => {
|
||||
getTableList(true)
|
||||
const savedScrollTop = uni.getStorageSync('scrollTop') || 0
|
||||
console.log('🚀 ~ onShow ~ savedScrollTop:', savedScrollTop)
|
||||
scrollTop.value = 0
|
||||
setTimeout(() => {
|
||||
scrollTop.value = savedScrollTop
|
||||
}, 500)
|
||||
})
|
||||
|
||||
// scroll容器滚动时事件
|
||||
const onScrollChange = (e) => {
|
||||
uni.setStorageSync('scrollTop', e.detail.scrollTop)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
@ -393,7 +421,8 @@ onShow((options) => {
|
|||
.line {
|
||||
margin: 24rpx 0;
|
||||
height: 2rpx;
|
||||
background: linear-gradient(90deg,
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgba(232, 232, 232, 0) 0%,
|
||||
rgba(232, 232, 232, 1) 50%,
|
||||
rgba(232, 232, 232, 0) 100%
|
||||
|
|
|
|||
Loading…
Reference in New Issue