123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- <template>
- <view class="container">
- <!-- 固定在顶部的筛选区域 -->
- <view class="filter-header">
- <view class="filter-controls">
- <view class="date-picker">
- <picker mode="date" @change="bindStartDateChange">
- <view class="date-input">
- <text>{{startDate || '请选择'}}</text>
- <uni-icons
- v-if="startDate"
- type="clear"
- size="16"
- @click="clearStartDate"
- style="margin-left: 10rpx">
- </uni-icons>
- </view>
- </picker>
- </view>
- <view class="date-picker">
- <picker mode="date" @change="bindEndDateChange">
- <view class="date-input">
- <text>{{endDate || '请选择'}}</text>
- <uni-icons
- v-if="endDate"
- type="clear"
- size="16"
- @click="clearEndDate"
- style="margin-left: 10rpx">
- </uni-icons>
- </view>
- </picker>
- </view>
- <button class="filter-btn" @click="handleSearch">查询</button>
- </view>
- </view>
- <!-- 订单列表 -->
- <scroll-view
- scroll-y
- class="list-container"
- @scrolltolower="loadMore"
- :scroll-top="scrollTop"
- >
- <u-swipe-action
- ref="swipeAction"
- >
- <view
- v-for="(item, index) in orderList"
- :key="item.id"
- class="list-item"
- >
- <u-swipe-action-item
- :options="options"
- :disabled="item.status === 2"
- @click="handleSwipeClick(item, index)"
- >
- <!-- 原有订单内容 -->
- <view class="item-header">
- <text class="order-id">订单号:{{ item.id }}</text>
- <view :class="['status-badge', getStatusClass(item.status)]">
- {{ getStatusText(item.status) }}
- </view>
- </view>
- <view class="item-content" @click="checkOrder(item)">
- <view class="info-row">
- <text class="info-label">创建时间:</text>
- <text class="info-value">{{ formatDate(item.createTime) }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">总数量:</text>
- <text class="info-value">{{ item.quantity }}条</text>
- </view>
- <view class="info-row">
- <text class="info-label">总金额:</text>
- <text class="info-value amount">¥{{ item.amount }}</text>
- </view>
- </view>
- </u-swipe-action-item>
- </view>
- </u-swipe-action>
- <!-- 加载状态提示 -->
- <view class="loading-tip">
- <text v-if="loading">加载中...</text>
- <text v-else-if="noMoreData">没有更多数据了</text>
- </view>
- </scroll-view>
- <!-- 新增按钮 -->
- <u-button class="add-btn" @click="goToAddPage" icon="plus"/>
- </view>
- </template>
- <script>
- import {
- getPageList,
- delGreenRecycling
- } from '@/api/views/recycling/index.js'
- export default {
- data() {
- return {
- options: [{
- text: '删除',
- style: {
- backgroundColor: '#FF7F50',
- color: '#fff'
- }
- }],
- moveIndex: -1,
- startDate: '',
- endDate: '',
- orderList: [],
- pageNum: 1,
- pageSize: 10,
- loading: false,
- noMoreData: false,
- scrollTop: 0,
- isSearching: false
- }
- },
- created() {
- this.fetchOrderList()
- },
- methods: {
- handleMove(index) {
- console.info('index-----', index)
- if (this.moveIndex === index) return;
- this.moveIndex = index;
- this.closeOtherActions();
- },
- closeOtherActions() {
- if (this.moveIndex !== -1) {
- const refName = 'swipeAction' + this.moveIndex;
- this.$refs[refName]?.[0]?.closeHandler();
- }
- },
- handleSwipeClick(item, index) {
- uni.showModal({
- title: '确认删除',
- content: `确定删除该回收单 ${item.id} 吗?`,
- success: (res) => {
- if (res.confirm) {
- delGreenRecycling(item.id).then(res => {
- console.info('res-----', res)
- uni.showToast({ title: res.msg, icon: 'success' });
- this.handleSearch()
- })
- }
- }
- });
- },
- clearStartDate() {
- this.startDate = '';
- // 如果需要触发change事件可以手动调用
- this.bindStartDateChange({detail: {value: ''}});
- },
- clearEndDate() {
- this.endDate = '';
- // 如果需要触发change事件可以手动调用
- this.bindEndDateChange({detail: {value: ''}});
- },
- bindStartDateChange(e) {
- this.startDate = e.detail.value
- },
- bindEndDateChange(e) {
- this.endDate = e.detail.value
- },
- checkOrder(row){
- uni.navigateTo({
- url: '/pages/views/recycling/details?id=' + row.id
- })
- },
- handleSearch() {
- this.pageNum = 1
- this.noMoreData = false
- this.isSearching = true
- this.scrollTop = 0
- this.fetchOrderList()
- },
- fetchOrderList() {
- if (this.loading || this.noMoreData) return
- this.loading = true
- let params = {
- current: this.pageNum,
- size: this.pageSize,
- startDate: this.startDate,
- endDate: this.endDate
- }
- getPageList(params).then(res => {
- if (this.isSearching) {
- this.orderList = res.data.records
- this.isSearching = false
- } else {
- this.orderList = [...this.orderList, ...res.data.records]
- }
- this.noMoreData = this.pageNum * this.pageSize >= res.data.total;
- this.pageNum++
- }).finally(() => {
- this.loading = false
- })
- },
- loadMore() {
- if (!this.loading && !this.noMoreData) {
- this.fetchOrderList()
- }
- },
- goToAddPage() {
- uni.navigateTo({
- url: '/pages/views/recycling/details'
- })
- },
- formatDate(dateStr) {
- return dateStr.replace(' ', ' ')
- },
- getStatusText(status) {
- const statusMap = {
- 0: '待审批',
- 2: '已通过',
- 1: '已拒绝'
- }
- return statusMap[status] || ''
- },
- getStatusClass(status) {
- const classMap = {
- 0: 'status-pending',
- 2: 'status-approved',
- 1: 'status-rejected'
- }
- return classMap[status] || ''
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- padding: 0;
- background-color: #f8f8f8;
- min-height: 100vh;
- position: relative;
- }
- /* 筛选区域优化 */
- .filter-header {
- position: sticky;
- top: 0;
- z-index: 100;
- background: #fff;
- padding: 15rpx 20rpx;
- border-bottom: 1rpx solid #f0f0f0;
- }
- .filter-controls {
- display: flex;
- align-items: center;
- gap: 15rpx;
- padding: 10rpx 0;
- }
- .date-picker {
- flex: 1;
- .date-input {
- background: #f8f8f8;
- border-radius: 8rpx;
- padding: 18rpx 20rpx;
- font-size: 28rpx;
- color: #333;
- text-align: center;
- }
- }
- .filter-btn {
- background: #2979ff;
- color: #fff;
- border-radius: 8rpx;
- padding: 0 30rpx;
- height: 80rpx;
- line-height: 80rpx;
- font-size: 28rpx;
- min-width: 120rpx;
- &::after {
- border: none;
- }
- }
- /* 列表区域 */
- .list-container {
- height: calc(100vh - 180rpx);
- padding: 10rpx;
- transform: translateX(15rpx); /* 强制偏移 */
- width: calc(100% - 30rpx);
- }
- .list-item {
- background-color: #fff;
- border-radius: 12rpx;
- padding: 25rpx;
- margin: 0 20rpx 20rpx 20rpx; /* 修改为四边统一间距 */
- box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
- border: 1rpx solid #f0f0f0;
- }
- .item-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- padding-bottom: 15rpx;
- border-bottom: 1rpx solid #f5f5f5;
- }
- .order-id {
- font-size: 28rpx;
- color: #666;
- }
- .status-badge {
- font-size: 24rpx;
- padding: 6rpx 16rpx;
- border-radius: 20rpx;
- &.status-pending {
- background-color: #fff8e6;
- color: #ff9900;
- }
- &.status-approved {
- background-color: #e6f7ff;
- color: #1890ff;
- }
- &.status-rejected {
- background-color: #fff1f0;
- color: #ff4d4f;
- }
- }
- .item-content {
- .info-row {
- display: flex;
- margin-bottom: 16rpx;
- font-size: 28rpx;
- &:last-child {
- margin-bottom: 0;
- }
- }
- .info-label {
- color: #999;
- width: 160rpx;
- }
- .info-value {
- color: #333;
- flex: 1;
- &.amount {
- color: #f56c6c;
- font-weight: 500;
- }
- }
- }
- .loading-tip {
- text-align: center;
- padding: 20rpx;
- font-size: 26rpx;
- color: #999;
- }
- /* 新增按钮 */
- .add-btn {
- position: fixed;
- right: 25rpx;
- bottom: 25rpx;
- width: 90rpx;
- height: 90rpx;
- background: #07C160;
- color: #fff;
- border-radius: 50%;
- display: flex;
- justify-content: center;
- align-items: center;
- box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.3);
- z-index: 99;
- font-size: 36rpx;
- font-weight: bold;
- /* 移除按钮默认样式 */
- padding: 0;
- border: none;
- outline: none;
- /* 动画效果 */
- transition: all 0.2s ease;
- &::after {
- border: none;
- }
- /* 点击反馈 */
- &:active {
- transform: scale(0.95);
- box-shadow: 0 2rpx 6rpx rgba(7, 193, 96, 0.3);
- }
- /* 图标样式 */
- .add-icon {
- margin-top: 4rpx; /* 微调+号位置 */
- }
- }
- .u-swipe-action {
- border-radius: 12rpx; /* 与列表项圆角一致 */
- overflow: hidden; /* 防止按钮溢出 */
- }
- </style>
|