bonus-material-app/src/pages/new-purchase/accept/index.vue

376 lines
11 KiB
Vue
Raw Normal View History

2024-11-18 09:05:38 +08:00
<template>
<!-- 新购验收 -->
<view class="accept page-common">
<view class="complete-btn">
2024-12-17 19:55:21 +08:00
<view class="btn first-active" @click="changeTab(1)">
2024-12-20 18:38:54 +08:00
<span :class="{ active: active == 1 }">未完成</span>
2024-11-18 09:05:38 +08:00
<div v-if="active == 1" class="bt-line"></div>
</view>
2024-12-17 19:55:21 +08:00
<view class="btn second-active" style="margin-left: 120rpx" @click="changeTab(2)">
2024-12-20 18:38:54 +08:00
<span :class="{ active: active == 2 }">已完成</span>
2024-11-18 09:05:38 +08:00
<div v-if="active == 2" class="bt-line"></div>
</view>
</view>
<uni-row :gutter="24" class="search-form">
2024-12-17 19:55:21 +08:00
<uni-col :span="24">
2024-11-18 09:05:38 +08:00
<view>
<uni-datetime-picker
2024-12-10 10:36:55 +08:00
v-model="dateArray"
type="daterange"
2024-11-18 09:05:38 +08:00
@maskClick="maskClick"
2024-12-10 10:36:55 +08:00
@change="onChangeDate"
placeholder="选择日期范围"
/>
2024-11-18 09:05:38 +08:00
</view>
2024-12-10 10:36:55 +08:00
</uni-col>
</uni-row>
<uni-row :gutter="24" class="search-form">
<uni-col :span="18">
2024-11-18 09:05:38 +08:00
<view>
2024-12-10 10:36:55 +08:00
<uni-easyinput placeholder="请输入内容" v-model="queryParams.keyWord"/>
2024-11-18 09:05:38 +08:00
</view>
</uni-col>
2024-12-10 10:36:55 +08:00
<uni-col :span="6">
<view class="search" @click="getTableList(true)">搜索</view>
2024-11-18 09:05:38 +08:00
</uni-col>
</uni-row>
2024-12-10 10:36:55 +08:00
<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)">
<div class="title">
2024-12-17 19:55:21 +08:00
<div class="title-left">
<span class="code">{{ item.code }}</span>
</div>
2024-12-20 18:38:54 +08:00
<span :class="['status', active == 1 ? 'pending' : 'completed']">
{{active == 1 ? '未完成' : '已完成'}}
2024-12-17 19:55:21 +08:00
</span>
2024-12-10 10:36:55 +08:00
</div>
<div class="line"></div>
<uni-row :gutter="24">
<uni-col :span="6">到货时间</uni-col>
2024-12-17 19:55:21 +08:00
<uni-col :span="18">
<div class="cont">{{ item.arrivalTime }}</div>
</uni-col>
2024-12-10 10:36:55 +08:00
</uni-row>
<uni-row :gutter="24">
<uni-col :span="6">采购物资</uni-col>
2024-12-17 19:55:21 +08:00
<uni-col :span="18">
<div class="cont">{{ item.purchaseMaTypeName }}</div>
</uni-col>
2024-12-10 10:36:55 +08:00
</uni-row>
<uni-row :gutter="24">
<uni-col :span="6">到货数量</uni-col>
2024-12-17 19:55:21 +08:00
<uni-col :span="18">
<div class="cont">{{ item.purchaseMaNumber }}</div>
</uni-col>
2024-12-10 10:36:55 +08:00
</uni-row>
<uni-row :gutter="24">
<uni-col :span="6">验收数量</uni-col>
<uni-col :span="18">
<div class="cont">{{ item.checkMaNumber }}</div>
</uni-col>
</uni-row>
2024-11-18 09:05:38 +08:00
</div>
2024-12-10 10:36:55 +08:00
<div class="loading-text">
{{ finish ? '没有更多数据了~' : '正在加载...' }}
</div>
</scroll-view>
2024-11-18 09:05:38 +08:00
</view>
</template>
<script setup>
2024-12-10 10:36:55 +08:00
import { ref, computed } from 'vue'
2024-11-19 10:32:24 +08:00
import { getPurchaseList } from '../../../services/purchase.js'
2024-11-18 16:52:12 +08:00
import { onLoad } from '@dcloudio/uni-app'
2024-12-10 10:36:55 +08:00
import { debounce } from 'lodash-es'
2024-11-18 09:05:38 +08:00
const active = ref(1)
2024-11-18 16:52:12 +08:00
const tableList = ref([])
2024-12-24 18:29:52 +08:00
const total = ref(0) //数据总量
2024-12-10 10:36:55 +08:00
// 查询参数
const queryParams = ref({
startTime: '', // 开始时间
endTime: '', // 结束时间
keyWord: '', // 关键字
2024-12-24 18:29:52 +08:00
taskStage: 2, // 验收
isFinish: '0', // 未完成
2024-12-10 10:36:55 +08:00
pageNum:1,
pageSize:5,
})
2024-12-17 19:55:21 +08:00
// 获列表数据
2024-12-10 10:36:55 +08:00
const getTableList = async (isTap = false) => {
2024-12-24 18:29:52 +08:00
console.log(queryParams.value)
try {
const { data: res } = await getPurchaseList(queryParams.value)
2024-12-31 15:37:54 +08:00
console.log('res列表数据', res)
2024-12-17 19:55:21 +08:00
// 更新总数
2024-12-31 15:37:54 +08:00
total.value = res.total
2024-12-17 19:55:21 +08:00
// 处理数据
if (isTap) {
// 点击搜索时,直接替换数据
tableList.value = res.rows || []
// 重置页码
queryParams.value.pageNum = 1
2024-12-10 10:36:55 +08:00
} else {
2024-12-17 19:55:21 +08:00
// 下拉加载时,追加数据
if (res.rows && res.rows.length > 0) {
tableList.value = [...tableList.value, ...res.rows]
}
}
} catch (error) {
console.error('获取列表数据失败:', error)
// 发生错误时重置数据
if (isTap) {
tableList.value = []
2024-12-10 10:36:55 +08:00
}
}
2024-11-18 16:52:12 +08:00
}
2024-12-10 10:36:55 +08:00
// 滚动触底事件
const onScrollTolower = debounce(() => {
console.log('触底事件')
2024-12-17 19:55:21 +08:00
// 判断是否还有更多数据
if (tableList.value.length < total.value) {
2024-12-10 10:36:55 +08:00
queryParams.value.pageNum++
2024-12-17 19:55:21 +08:00
getTableList(false)
2024-12-10 10:36:55 +08:00
}
}, 500)
// 判断数据是否加载完毕
const finish = computed(() => {
if (total.value === tableList.value.length) return true
})
2024-11-18 09:05:38 +08:00
const changeTab = (index) => {
active.value = index
2024-12-17 19:55:21 +08:00
// 重置查询参数
queryParams.value.pageNum = 1
queryParams.value.keyWord = ''
queryParams.value.startTime = ''
queryParams.value.endTime = ''
2024-12-31 15:37:54 +08:00
if (index == 1) {
2024-12-24 18:29:52 +08:00
queryParams.value.isFinish = '0'
2024-12-31 15:37:54 +08:00
}
if (index == 2) {
2024-12-24 18:29:52 +08:00
queryParams.value.isFinish = '1'
2024-11-19 10:32:24 +08:00
}
2024-12-31 15:37:54 +08:00
// 重置列表数据
tableList.value = []
2024-12-17 19:55:21 +08:00
// 重新获取数据
getTableList(true)
2024-11-18 09:05:38 +08:00
}
2024-12-10 10:36:55 +08:00
// 日期 change 事件
const onChangeDate = (val) => {
const [val_1, val_2] = val
queryParams.value.startTime = val_1
queryParams.value.endTime = val_2
}
//日期选择
2024-11-18 09:05:38 +08:00
const maskClick = () => {}
const handleItem = (item) => {
console.log('🚀 ~ handleItem ~ item:', item)
2024-11-18 18:26:53 +08:00
uni.navigateTo({ url: `/pages/new-purchase/accept/acceptDetails?id=${item.id}&taskId=${item.taskId}` })
2024-11-18 09:05:38 +08:00
}
2024-11-19 10:32:24 +08:00
onLoad((options) => {
2024-12-10 10:36:55 +08:00
getTableList(true)
2024-11-18 16:52:12 +08:00
})
2024-11-18 09:05:38 +08:00
</script>
<style lang="scss" scoped>
.accept {
height: 100%;
word-break: break-all;
2024-12-17 19:55:21 +08:00
background-color: #f7f8fa;
padding: 24rpx;
2024-11-18 09:05:38 +08:00
.complete-btn {
display: flex;
2024-12-17 19:55:21 +08:00
padding: 28rpx 24rpx;
justify-content: center;
background: #fff;
border-radius: 20rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
2024-11-18 09:05:38 +08:00
.btn {
display: flex;
flex-direction: column;
align-items: center;
2024-12-17 19:55:21 +08:00
padding: 0 60rpx;
position: relative;
transition: all 0.3s ease;
span {
font-size: 32rpx;
color: #8c8c8c;
font-weight: 500;
&.active {
color: #3784fb;
font-weight: 600;
.second-active & {
color: #fa8c16;
}
}
}
.bt-line {
width: 32rpx;
height: 6rpx;
background: #3784fb;
margin-top: 12rpx;
border-radius: 6rpx;
transition: all 0.3s ease;
.second-active & {
background: #fa8c16;
}
}
2024-11-18 09:05:38 +08:00
}
}
.search-form {
display: flex;
align-items: center;
2024-12-17 19:55:21 +08:00
background: #fff;
padding: 24rpx;
border-radius: 20rpx;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
:deep(.uni-easyinput__content),
:deep(.uni-date-editor) {
background-color: #f7f8fa;
border: 2rpx solid #e8e8e8;
border-radius: 12rpx;
height: 80rpx;
transition: all 0.3s ease;
&:focus-within {
border-color: #3784fb;
box-shadow: 0 0 0 2rpx rgba(55, 132, 251, 0.1);
}
}
:deep(.uni-date-editor) {
.uni-date-range {
display: flex;
align-items: center;
width: 100%;
.uni-date-range--text {
width: 50%;
text-align: center;
color: #333;
}
}
}
2024-11-18 09:05:38 +08:00
}
.search {
2024-12-17 19:55:21 +08:00
height: 80rpx;
background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%);
2024-11-18 09:05:38 +08:00
text-align: center;
2024-12-17 19:55:21 +08:00
line-height: 80rpx;
2024-11-18 09:05:38 +08:00
color: #fff;
2024-12-17 19:55:21 +08:00
border-radius: 12rpx;
font-size: 28rpx;
font-weight: 600;
box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
transition: all 0.3s ease;
&:active {
transform: translateY(2rpx);
opacity: 0.9;
}
2024-11-18 09:05:38 +08:00
}
}
2024-12-17 19:55:21 +08:00
2024-12-10 10:36:55 +08:00
.scroll-container {
2024-12-17 19:55:21 +08:00
padding: 0 2rpx;
.table-list-item {
margin: 24rpx 0;
padding: 32rpx;
background-color: #fff;
min-height: 300rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
transition: all 0.3s ease;
&:active {
transform: scale(0.985);
background-color: #fafbfc;
}
.title {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
.title-left {
.code {
font-size: 32rpx;
font-weight: 600;
color: #3784fb;
letter-spacing: 1rpx;
}
2024-12-10 10:36:55 +08:00
}
2024-12-17 19:55:21 +08:00
span.status {
padding: 8rpx 28rpx;
border-radius: 8rpx;
font-size: 26rpx;
font-weight: 600;
&.completed {
background-color: rgba(82, 196, 26, 0.1);
color: #52c41a;
}
&.pending {
background-color: rgba(250, 140, 22, 0.1);
color: #fa8c16;
}
2024-12-10 10:36:55 +08:00
}
2024-12-17 19:55:21 +08:00
}
.line {
margin: 24rpx 0;
height: 2rpx;
background: linear-gradient(90deg,
rgba(232, 232, 232, 0) 0%,
rgba(232, 232, 232, 1) 50%,
rgba(232, 232, 232, 0) 100%
);
}
:deep(.uni-row) {
margin-bottom: 20rpx;
.uni-col-6 {
color: #8c8c8c;
font-size: 28rpx;
font-weight: 500;
2024-12-10 10:36:55 +08:00
}
}
2024-12-17 19:55:21 +08:00
.cont {
display: flex;
justify-content: flex-end;
line-height: 1.8;
color: #262626;
font-size: 28rpx;
font-weight: 500;
}
}
2024-12-10 10:36:55 +08:00
}
2024-12-17 19:55:21 +08:00
2024-12-10 10:36:55 +08:00
.loading-text {
text-align: center;
2024-12-17 19:55:21 +08:00
font-size: 26rpx;
color: #8c8c8c;
padding: 32rpx 0;
letter-spacing: 1rpx;
2024-11-18 09:05:38 +08:00
}
</style>