增加页面滚动初始位置
This commit is contained in:
parent
988a14ada7
commit
566c94f356
|
|
@ -20,28 +20,41 @@
|
||||||
@maskClick="maskClick"
|
@maskClick="maskClick"
|
||||||
@change="onChangeDate"
|
@change="onChangeDate"
|
||||||
placeholder="选择日期范围"
|
placeholder="选择日期范围"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
</uni-row>
|
</uni-row>
|
||||||
<uni-row :gutter="24" class="search-form">
|
<uni-row :gutter="24" class="search-form">
|
||||||
<uni-col :span="18">
|
<uni-col :span="18">
|
||||||
<view>
|
<view>
|
||||||
<uni-easyinput placeholder="请输入内容" v-model="queryParams.keyWord"/>
|
<uni-easyinput placeholder="请输入内容" v-model="queryParams.keyWord" />
|
||||||
</view>
|
</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
<view class="search" @click="getTableList(true)">搜索</view>
|
<view class="search" @click="getTableList(true)">搜索</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
</uni-row>
|
</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">
|
||||||
<div class="title-left">
|
<div class="title-left">
|
||||||
<span class="code">{{ item.code }}</span>
|
<span class="code">{{ item.code }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span :class="['status', active == 1 ? 'pending' : 'completed']">
|
<span :class="['status', active == 1 ? 'pending' : 'completed']">
|
||||||
{{active == 1 ? '未完成' : '已完成'}}
|
{{ active == 1 ? '未完成' : '已完成' }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
|
|
@ -63,12 +76,12 @@
|
||||||
<div class="cont">{{ item.purchaseMaNumber }}</div>
|
<div class="cont">{{ item.purchaseMaNumber }}</div>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
</uni-row>
|
</uni-row>
|
||||||
<uni-row :gutter="24">
|
<uni-row :gutter="24">
|
||||||
<uni-col :span="6">验收数量:</uni-col>
|
<uni-col :span="6">验收数量:</uni-col>
|
||||||
<uni-col :span="18">
|
<uni-col :span="18">
|
||||||
<div class="cont">{{ item.checkMaNumber }}</div>
|
<div class="cont">{{ item.checkMaNumber }}</div>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
</uni-row>
|
</uni-row>
|
||||||
</div>
|
</div>
|
||||||
<div class="loading-text">
|
<div class="loading-text">
|
||||||
{{ finish ? '没有更多数据了~' : '正在加载...' }}
|
{{ finish ? '没有更多数据了~' : '正在加载...' }}
|
||||||
|
|
@ -78,31 +91,31 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||||
import { getPurchaseList } from '../../../services/purchase.js'
|
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'
|
import { debounce } from 'lodash-es'
|
||||||
const active = ref(1)
|
const active = ref(1)
|
||||||
const tableList = ref([])
|
const tableList = ref([])
|
||||||
const total = ref(0) //数据总量
|
const total = ref(0) //数据总量
|
||||||
// 查询参数
|
// 查询参数
|
||||||
const queryParams = ref({
|
const queryParams = ref({
|
||||||
startTime: '', // 开始时间
|
startTime: '', // 开始时间
|
||||||
endTime: '', // 结束时间
|
endTime: '', // 结束时间
|
||||||
keyWord: '', // 关键字
|
keyWord: '', // 关键字
|
||||||
taskStage: 2, // 验收
|
taskStage: 2, // 验收
|
||||||
isFinish: '0', // 未完成
|
isFinish: '0', // 未完成
|
||||||
pageNum:1,
|
pageNum: 1,
|
||||||
pageSize:5,
|
pageSize: 5,
|
||||||
})
|
})
|
||||||
// 获列表数据
|
// 获列表数据
|
||||||
const getTableList = async (isTap = false) => {
|
const getTableList = async (isTap = false) => {
|
||||||
console.log(queryParams.value)
|
console.log(queryParams.value)
|
||||||
try {
|
try {
|
||||||
const { data: res } = await getPurchaseList(queryParams.value)
|
const { data: res } = await getPurchaseList(queryParams.value)
|
||||||
console.log('res列表数据', res)
|
console.log('res列表数据', res)
|
||||||
// 更新总数
|
// 更新总数
|
||||||
total.value = res.total
|
total.value = res.total
|
||||||
// 处理数据
|
// 处理数据
|
||||||
if (isTap) {
|
if (isTap) {
|
||||||
// 点击搜索时,直接替换数据
|
// 点击搜索时,直接替换数据
|
||||||
|
|
@ -144,15 +157,15 @@ const changeTab = (index) => {
|
||||||
queryParams.value.keyWord = ''
|
queryParams.value.keyWord = ''
|
||||||
queryParams.value.startTime = ''
|
queryParams.value.startTime = ''
|
||||||
queryParams.value.endTime = ''
|
queryParams.value.endTime = ''
|
||||||
|
|
||||||
if (index == 1) {
|
if (index == 1) {
|
||||||
queryParams.value.isFinish = '0'
|
queryParams.value.isFinish = '0'
|
||||||
}
|
}
|
||||||
if (index == 2) {
|
if (index == 2) {
|
||||||
queryParams.value.isFinish = '1'
|
queryParams.value.isFinish = '1'
|
||||||
}
|
}
|
||||||
// 重置列表数据
|
// 重置列表数据
|
||||||
tableList.value = []
|
tableList.value = []
|
||||||
// 重新获取数据
|
// 重新获取数据
|
||||||
getTableList(true)
|
getTableList(true)
|
||||||
}
|
}
|
||||||
|
|
@ -169,8 +182,8 @@ const handleItem = (item) => {
|
||||||
// 是否完成
|
// 是否完成
|
||||||
const isFinished = item.taskStatusName == '已完成'
|
const isFinished = item.taskStatusName == '已完成'
|
||||||
const singLevel = {
|
const singLevel = {
|
||||||
'2': '技术科',
|
2: '技术科',
|
||||||
'3': '库管班',
|
3: '库管班',
|
||||||
}
|
}
|
||||||
const deptName = uni.getStorageSync('deptName')
|
const deptName = uni.getStorageSync('deptName')
|
||||||
if (!deptName.includes(singLevel[item.signLevel]) && !isFinished) {
|
if (!deptName.includes(singLevel[item.signLevel]) && !isFinished) {
|
||||||
|
|
@ -180,11 +193,26 @@ const handleItem = (item) => {
|
||||||
})
|
})
|
||||||
return
|
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) => {
|
onShow((options) => {
|
||||||
getTableList(true)
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
@ -219,7 +247,7 @@ onShow((options) => {
|
||||||
&.active {
|
&.active {
|
||||||
color: #3784fb;
|
color: #3784fb;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|
||||||
.second-active & {
|
.second-active & {
|
||||||
color: #fa8c16;
|
color: #fa8c16;
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +261,7 @@ onShow((options) => {
|
||||||
margin-top: 12rpx;
|
margin-top: 12rpx;
|
||||||
border-radius: 6rpx;
|
border-radius: 6rpx;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
.second-active & {
|
.second-active & {
|
||||||
background: #fa8c16;
|
background: #fa8c16;
|
||||||
}
|
}
|
||||||
|
|
@ -263,55 +291,55 @@ onShow((options) => {
|
||||||
box-shadow: 0 0 0 2rpx rgba(55, 132, 251, 0.1);
|
box-shadow: 0 0 0 2rpx rgba(55, 132, 251, 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:deep(.uni-date) {
|
:deep(.uni-date) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.uni-date-x {
|
.uni-date-x {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-date-editor--x {
|
.uni-date-editor--x {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-date-range--x {
|
.uni-date-range--x {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.uni-date-range--x-input {
|
.uni-date-range--x-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 0 24rpx;
|
padding: 0 24rpx;
|
||||||
|
|
||||||
.uni-date-range--x-text {
|
.uni-date-range--x-text {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #262626;
|
color: #262626;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-date-x--border {
|
.uni-date-x--border {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 2rpx solid #e8e8e8;
|
border: 2rpx solid #e8e8e8;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
background-color: #f7f8fa;
|
background-color: #f7f8fa;
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
&:focus-within {
|
&:focus-within {
|
||||||
border-color: #3784fb;
|
border-color: #3784fb;
|
||||||
box-shadow: 0 0 0 2rpx rgba(55, 132, 251, 0.1);
|
box-shadow: 0 0 0 2rpx rgba(55, 132, 251, 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.uni-date-editor) {
|
:deep(.uni-date-editor) {
|
||||||
.uni-date-range {
|
.uni-date-range {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.uni-date-range--text {
|
.uni-date-range--text {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
@ -342,7 +370,7 @@ onShow((options) => {
|
||||||
|
|
||||||
.scroll-container {
|
.scroll-container {
|
||||||
padding: 0 2rpx;
|
padding: 0 2rpx;
|
||||||
|
|
||||||
.table-list-item {
|
.table-list-item {
|
||||||
margin: 24rpx 0;
|
margin: 24rpx 0;
|
||||||
padding: 32rpx;
|
padding: 32rpx;
|
||||||
|
|
@ -362,7 +390,7 @@ onShow((options) => {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
|
|
||||||
.title-left {
|
.title-left {
|
||||||
.code {
|
.code {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
|
|
@ -371,18 +399,18 @@ onShow((options) => {
|
||||||
letter-spacing: 1rpx;
|
letter-spacing: 1rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
span.status {
|
span.status {
|
||||||
padding: 8rpx 28rpx;
|
padding: 8rpx 28rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|
||||||
&.completed {
|
&.completed {
|
||||||
background-color: rgba(82, 196, 26, 0.1);
|
background-color: rgba(82, 196, 26, 0.1);
|
||||||
color: #52c41a;
|
color: #52c41a;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.pending {
|
&.pending {
|
||||||
background-color: rgba(250, 140, 22, 0.1);
|
background-color: rgba(250, 140, 22, 0.1);
|
||||||
color: #fa8c16;
|
color: #fa8c16;
|
||||||
|
|
@ -393,7 +421,8 @@ onShow((options) => {
|
||||||
.line {
|
.line {
|
||||||
margin: 24rpx 0;
|
margin: 24rpx 0;
|
||||||
height: 2rpx;
|
height: 2rpx;
|
||||||
background: linear-gradient(90deg,
|
background: linear-gradient(
|
||||||
|
90deg,
|
||||||
rgba(232, 232, 232, 0) 0%,
|
rgba(232, 232, 232, 0) 0%,
|
||||||
rgba(232, 232, 232, 1) 50%,
|
rgba(232, 232, 232, 1) 50%,
|
||||||
rgba(232, 232, 232, 0) 100%
|
rgba(232, 232, 232, 0) 100%
|
||||||
|
|
@ -402,7 +431,7 @@ onShow((options) => {
|
||||||
|
|
||||||
:deep(.uni-row) {
|
:deep(.uni-row) {
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
|
|
||||||
.uni-col-6 {
|
.uni-col-6 {
|
||||||
color: #8c8c8c;
|
color: #8c8c8c;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue