InspectionCleaning/pages/index/planList.vue

331 lines
8.1 KiB
Vue
Raw Normal View History

2025-04-07 09:30:11 +08:00
<template>
<view class="content">
<u-navbar
:is-back="false"
title="计划列表"
2025-04-08 13:33:16 +08:00
title-color="black"
2025-04-07 09:30:11 +08:00
:background="{ backgroundColor: '#F7F8FC' }"
:border-bottom="false"
>
2025-04-08 13:33:16 +08:00
<view slot="right">
<image
src="/static/images/icon-date.png"
mode="scaleToFill"
style="width: 40rpx; height: 40rpx; margin-right: 32rpx"
2025-04-08 15:56:13 +08:00
@click="toggleDate"
2025-04-08 13:33:16 +08:00
/>
</view>
2025-04-07 09:30:11 +08:00
</u-navbar>
2025-04-08 15:06:27 +08:00
<view
class="selectTab"
2025-04-08 15:11:01 +08:00
:class="{
'tab-completed': activeTab === 'completed',
'tab-incomplete': activeTab === 'incomplete',
2025-04-08 15:06:27 +08:00
}"
>
2025-04-08 13:33:16 +08:00
<view
class="tab-item"
:class="{ active: activeTab === 'completed' }"
@click="switchTab('completed')"
>
2025-04-07 09:30:11 +08:00
<view class="label">已完成计划</view>
2025-04-15 09:59:44 +08:00
<view class="count">{{ completedPlanList.length }}</view>
2025-04-07 09:30:11 +08:00
</view>
2025-04-08 13:33:16 +08:00
<view
class="tab-item"
:class="{ active: activeTab === 'incomplete' }"
@click="switchTab('incomplete')"
>
2025-04-07 09:30:11 +08:00
<view class="label">未完成计划</view>
2025-04-15 09:59:44 +08:00
<view class="count">{{ incompletePlanList.length }}</view>
2025-04-07 09:30:11 +08:00
</view>
</view>
2025-04-08 13:33:16 +08:00
<view class="planList" :class="{ activeList: activeTab === 'incomplete' }">
2025-04-09 15:05:52 +08:00
<!-- <view class="plan-item">
2025-04-08 13:33:16 +08:00
<view class="plan-header">
2025-04-08 15:56:13 +08:00
<image
src="/static/images/icon-date.png"
mode="scaleToFill"
style="width: 40rpx; height: 40rpx"
/>
2025-04-07 09:30:11 +08:00
<view class="date">05-21</view>
2025-04-08 13:33:16 +08:00
<view>1天前</view>
2025-04-07 09:30:11 +08:00
</view>
2025-04-08 13:33:16 +08:00
<view class="plan-content">
<view class="plan-content-top">
<view class="place">校门A区教学楼</view>
<u-tag text="9:00~12:00" type="info" border-color="transparent" />
</view>
<view class="plan-content-main">
北大门右侧操场跑道/南广场升旗台/A区第二食堂3楼
</view>
2025-04-07 09:30:11 +08:00
</view>
2025-04-09 15:05:52 +08:00
</view> -->
2025-04-15 09:59:44 +08:00
<view
class="plan-item"
v-for="(item, index) in activeTab === 'completed'
? completedPlanList
: incompletePlanList"
:key="index"
>
2025-04-08 13:33:16 +08:00
<view class="plan-header">
2025-04-08 15:56:13 +08:00
<image
src="/static/images/icon-date.png"
mode="scaleToFill"
style="width: 40rpx; height: 40rpx"
/>
2025-04-09 15:05:52 +08:00
<view class="date">{{ item.date }}</view>
<view>{{ item.date ? getDateDiff(item.date) : "-" }}</view>
2025-04-08 13:33:16 +08:00
</view>
<view class="plan-content">
<view class="plan-content-top">
2025-04-09 15:05:52 +08:00
<view class="place">{{ item.name }}</view>
2025-04-08 13:33:16 +08:00
<u-tag text="9:00~12:00" type="info" border-color="transparent" />
</view>
<view class="plan-content-main">
2025-04-09 15:05:52 +08:00
{{ item.areas }}
2025-04-08 13:33:16 +08:00
</view>
2025-04-07 09:30:11 +08:00
</view>
</view>
2025-04-15 09:59:44 +08:00
<u-empty
v-if="
!loading &&
((activeTab === 'completed' && completedPlanList.length === 0) ||
(activeTab === 'incomplete' && incompletePlanList.length === 0))
"
mode="list"
></u-empty>
2025-04-07 09:30:11 +08:00
</view>
2025-04-09 14:20:34 +08:00
2025-04-15 09:59:44 +08:00
<!-- :max-date="maxDate" -->
2025-04-09 14:20:34 +08:00
<u-calendar
v-model="showCalendar"
mode="range"
@change="changeDate"
></u-calendar>
2025-04-15 10:07:11 +08:00
<u-tabbar :list="vuex_tabbar"></u-tabbar>
2025-04-07 09:30:11 +08:00
</view>
</template>
<script>
2025-04-09 13:44:35 +08:00
import { GetPlanList } from "@/api/apiList";
2025-04-09 15:05:52 +08:00
import { GetNowTime } from "@/utils/common";
import { getDateDiff } from "@/utils/utils";
2025-04-07 09:30:11 +08:00
export default {
data() {
2025-04-15 09:59:44 +08:00
const todayStr = GetNowTime(new Date());
2025-04-08 13:33:16 +08:00
return {
activeTab: "completed",
2025-04-08 15:56:13 +08:00
2025-04-15 09:59:44 +08:00
// maxDate: "2049-12-31", // 默认最大日期为当天
2025-04-08 15:56:13 +08:00
showCalendar: false,
2025-04-09 15:05:52 +08:00
// 请求参数
params: {
2025-04-15 09:59:44 +08:00
// "Item1.IsCompleted": 1, // '0 1 2' 0未完成 1已完成 2不用管
dateBegin: todayStr,
dateEnd: todayStr,
2025-04-09 15:05:52 +08:00
},
// 计划列表
2025-04-15 09:59:44 +08:00
completedPlanList: [],
incompletePlanList: [],
loading: false, // 添加加载状态
2025-04-08 13:33:16 +08:00
};
2025-04-07 09:30:11 +08:00
},
2025-04-10 16:29:39 +08:00
onShow() {
2025-04-15 09:59:44 +08:00
// 页面每次展示时都获取所有列表
this.fetchAllPlanLists();
2025-04-09 15:05:52 +08:00
},
2025-04-08 13:33:16 +08:00
methods: {
2025-04-09 15:05:52 +08:00
getDateDiff,
2025-04-08 15:56:13 +08:00
toggleDate() {
this.showCalendar = !this.showCalendar;
},
2025-04-08 13:33:16 +08:00
switchTab(tab) {
this.activeTab = tab;
},
2025-04-08 15:56:13 +08:00
changeDate(e) {
2025-04-09 15:05:52 +08:00
this.params.dateBegin = e.startDate;
this.params.dateEnd = e.endDate;
2025-04-15 09:59:44 +08:00
// 日期更改后,重新获取所有列表
this.fetchAllPlanLists();
},
// 统一获取所有列表数据
async fetchAllPlanLists() {
if (this.loading) return; // 防止重复加载
this.loading = true;
uni.showLoading({ title: "加载中..." }); // 显示加载提示
try {
await Promise.all([this.fetchListData(1), this.fetchListData(0)]);
} catch (error) {
console.error("获取所有列表时出错:", error);
} finally {
this.loading = false;
uni.hideLoading(); // 隐藏加载提示
}
2025-04-09 15:05:52 +08:00
},
2025-04-15 09:59:44 +08:00
async fetchListData(status) {
const requestParams = {
...this.params,
"Item1.IsCompleted": status, // 0未完成 1已完成 2不用管
};
2025-04-09 13:44:35 +08:00
2025-04-15 09:59:44 +08:00
const res = await GetPlanList(requestParams);
2025-04-09 15:05:52 +08:00
if (res.succeed) {
2025-04-15 09:59:44 +08:00
if (status === 1) {
this.completedPlanList = res.data || [];
} else {
this.incompletePlanList = res.data || [];
}
2025-04-09 15:05:52 +08:00
}
2025-04-08 15:56:13 +08:00
},
2025-04-08 13:33:16 +08:00
},
2025-04-07 09:30:11 +08:00
};
</script>
<style lang="scss" scoped>
2025-04-15 09:59:44 +08:00
page {
background: #f7f8fc !important;
}
2025-04-07 09:30:11 +08:00
.content {
2025-04-09 15:05:52 +08:00
// height: 100vh;
padding-bottom: 100rpx;
2025-04-07 09:30:11 +08:00
background: #f7f8fc;
2025-04-08 13:33:16 +08:00
.selectTab {
2025-04-07 09:30:11 +08:00
display: flex;
2025-04-08 15:06:27 +08:00
// background: url("@/static/images/plan-tab2.png") no-repeat 0 0;
background-size: 100% 100%;
2025-04-08 15:11:01 +08:00
background-repeat: no-repeat;
background-position: 0 0;
transition: opacity 0.3s ease;
2025-04-08 13:33:16 +08:00
border-radius: 16rpx;
2025-04-08 15:06:27 +08:00
padding: 32rpx 0;
2025-04-08 13:33:16 +08:00
margin: 0 32rpx 32rpx;
.tab-item {
flex: 1;
text-align: center;
position: relative;
transition: all 0.3s;
position: relative;
2025-04-08 15:56:13 +08:00
z-index: 1;
2025-04-08 13:33:16 +08:00
.label {
2025-04-07 09:30:11 +08:00
font-size: 28rpx;
2025-04-08 13:33:16 +08:00
color: rgba(255, 255, 255, 0.8);
margin-bottom: 8rpx;
2025-04-07 09:30:11 +08:00
}
2025-04-08 13:33:16 +08:00
.count {
font-size: 36rpx;
color: #ffffff;
font-weight: 500;
}
&.active {
.label {
color: #ffffff;
font-weight: 500;
}
2025-04-08 15:06:27 +08:00
// &::after {
// content: "";
// position: absolute;
// bottom: -46rpx;
// left: 50%;
// transform: translateX(-50%) rotate(45deg);
// width: 32rpx;
// height: 32rpx;
// background: #383edd;
// border-radius: 10rpx;
// z-index: 1;
// }
2025-04-08 13:33:16 +08:00
2025-04-08 15:06:27 +08:00
// &::before {
// content: "";
// position: absolute;
// bottom: -34rpx;
// left: 50%;
// transform: translateX(-50%);
// width: 8rpx;
// height: 8rpx;
// background: #ffffff;
// border-radius: 4rpx;
// z-index: 2;
// }
2025-04-07 09:30:11 +08:00
}
}
}
2025-04-08 15:11:01 +08:00
.tab-completed {
background-image: url("/static/images/plan-tab1.png");
}
.tab-incomplete {
background-image: url("/static/images/plan-tab2.png");
}
2025-04-07 09:30:11 +08:00
.planList {
padding: 0 32rpx;
.plan-item {
2025-04-08 13:33:16 +08:00
border-radius: 16rpx;
2025-04-07 09:30:11 +08:00
margin-top: 32rpx;
2025-04-08 13:33:16 +08:00
background: linear-gradient(
to bottom,
#edf2ff 0%,
#fafcff 30%,
#ffffff 100%
);
.plan-header {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 20rpx;
padding: 20rpx;
border-bottom: 1px solid #f2f2f2;
}
.plan-content {
padding: 20rpx;
padding-bottom: 32rpx;
&-top {
display: flex;
justify-content: space-between;
align-items: center;
.place {
font-size: 32rpx;
color: #333;
}
}
&-main {
margin-top: 32rpx;
background-color: #f3f3f3;
padding: 32rpx;
border-radius: 16rpx;
}
}
}
&.activeList {
.plan-item {
background: linear-gradient(
to bottom,
#fef7ec 0%,
#fffdfa 30%,
#ffffff 100%
);
}
2025-04-07 09:30:11 +08:00
}
}
}
</style>