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