feat: 计划列表

This commit is contained in:
yangzhe 2025-04-15 09:59:44 +08:00
parent e3fd78a618
commit 1059a1f3b7
1 changed files with 60 additions and 16 deletions

View File

@ -30,7 +30,7 @@
@click="switchTab('completed')" @click="switchTab('completed')"
> >
<view class="label">已完成计划</view> <view class="label">已完成计划</view>
<view class="count">12</view> <view class="count">{{ completedPlanList.length }}</view>
</view> </view>
<view <view
class="tab-item" class="tab-item"
@ -38,7 +38,7 @@
@click="switchTab('incomplete')" @click="switchTab('incomplete')"
> >
<view class="label">未完成计划</view> <view class="label">未完成计划</view>
<view class="count">12</view> <view class="count">{{ incompletePlanList.length }}</view>
</view> </view>
</view> </view>
@ -63,7 +63,13 @@
</view> </view>
</view> </view>
</view> --> </view> -->
<view class="plan-item" v-for="(item, index) in planList" :key="index"> <view
class="plan-item"
v-for="(item, index) in activeTab === 'completed'
? completedPlanList
: incompletePlanList"
:key="index"
>
<view class="plan-header"> <view class="plan-header">
<image <image
src="/static/images/icon-date.png" src="/static/images/icon-date.png"
@ -83,12 +89,20 @@
</view> </view>
</view> </view>
</view> </view>
<u-empty
v-if="
!loading &&
((activeTab === 'completed' && completedPlanList.length === 0) ||
(activeTab === 'incomplete' && incompletePlanList.length === 0))
"
mode="list"
></u-empty>
</view> </view>
<!-- :max-date="maxDate" -->
<u-calendar <u-calendar
v-model="showCalendar" v-model="showCalendar"
mode="range" mode="range"
:max-date="maxDate"
@change="changeDate" @change="changeDate"
></u-calendar> ></u-calendar>
</view> </view>
@ -102,27 +116,31 @@ import { getDateDiff } from "@/utils/utils";
export default { export default {
data() { data() {
const todayStr = GetNowTime(new Date());
return { return {
activeTab: "completed", activeTab: "completed",
maxDate: "2049-12-31", // maxDate: "2049-12-31", //
showCalendar: false, showCalendar: false,
// //
params: { params: {
// '0 1 2' // "Item1.IsCompleted": 1, // '0 1 2' 0 1 2
"Item1.IsCompleted": 0, dateBegin: todayStr,
dateBegin: GetNowTime(new Date()), dateEnd: todayStr,
dateEnd: GetNowTime(new Date()),
}, },
// //
planList: [], completedPlanList: [],
incompletePlanList: [],
loading: false, //
}; };
}, },
onShow() { onShow() {
this.getPlanList(); //
this.fetchAllPlanLists();
}, },
methods: { methods: {
getDateDiff, getDateDiff,
@ -137,15 +155,38 @@ export default {
changeDate(e) { changeDate(e) {
this.params.dateBegin = e.startDate; this.params.dateBegin = e.startDate;
this.params.dateEnd = e.endDate; this.params.dateEnd = e.endDate;
this.getPlanList(); //
this.fetchAllPlanLists();
}, },
// //
async getPlanList() { async fetchAllPlanLists() {
const res = await GetPlanList(this.params); 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(); //
}
},
async fetchListData(status) {
const requestParams = {
...this.params,
"Item1.IsCompleted": status, // 0 1 2
};
const res = await GetPlanList(requestParams);
if (res.succeed) { if (res.succeed) {
this.planList = res.data; if (status === 1) {
this.completedPlanList = res.data || [];
} else {
this.incompletePlanList = res.data || [];
}
} }
}, },
}, },
@ -153,6 +194,9 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
page {
background: #f7f8fc !important;
}
.content { .content {
// height: 100vh; // height: 100vh;
padding-bottom: 100rpx; padding-bottom: 100rpx;