|
|
@@ -1,9 +1,5 @@
|
|
|
<template>
|
|
|
|
|
|
- <view class="charts-box">
|
|
|
- <qiun-data-charts type="line" :opts="chartOpts" :chartData="chartData" :canvas2d="true" />
|
|
|
- </view>
|
|
|
-
|
|
|
<view class="tab-header">
|
|
|
<uni-segmented-control :current="currentTabIndex" :values="tabs" style-type="button" active-color="#BDE0FF"
|
|
|
@clickItem="switchTab" />
|
|
|
@@ -26,54 +22,6 @@
|
|
|
<uni-icons type="right" size="30" @click="plusMonth(1)"></uni-icons>
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
- <!-- 统计数据 -->
|
|
|
- <view class="stat-board">
|
|
|
- <view class="stat-board-title">打卡统计</view>
|
|
|
- <view class="stat-board-content">
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">本月需打卡</view>
|
|
|
- <view class="stat-item-value">{{ statMonth.punchInTotalCount }}次</view>
|
|
|
- </view>
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">本月已打卡</view>
|
|
|
- <view class="stat-item-value">{{ statMonth.punchInCount }}次</view>
|
|
|
- </view>
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">完成打卡</view>
|
|
|
- <view class="stat-item-value">{{ statMonth.punchInDoneCount }}次</view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="stat-board-content stat-mt16">
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">打卡率</view>
|
|
|
- <view class="stat-item-value">{{ statMonth.punchInRate }}%</view>
|
|
|
- </view>
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">完成率</view>
|
|
|
- <view class="stat-item-value">{{ statMonth.punchInDoneRate }}%</view>
|
|
|
- </view>
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">本月获取积分数</view>
|
|
|
- <view class="stat-item-value">{{ statMonth.points }}</view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
-
|
|
|
- <uni-section title="打卡日志" padding="16px" type="line">
|
|
|
- <uni-list>
|
|
|
- <uni-list-item v-for="taskHistory in statMonth.piTaskHistoryStatVOS" :key="taskHistory.punchInDate">
|
|
|
- <template v-slot:body>
|
|
|
- {{ taskHistory.punchInDate }}
|
|
|
- <span v-if="taskHistory.punchInResult == PUNCH_IN_RESULT.DONE"> 完成打卡</span>
|
|
|
- <span v-else> 未完成打卡</span>
|
|
|
- <span v-if="taskHistory.punchInMethod == PUNCH_IN_METHOD.COUNT">,打卡{{ taskHistory.countTrack }}次</span>
|
|
|
- <span v-if="taskHistory.punchInMethod == PUNCH_IN_METHOD.TIMING">,打卡时长{{ taskHistory.timeTrack }}</span>
|
|
|
- </template>
|
|
|
- </uni-list-item>
|
|
|
- </uni-list>
|
|
|
- <uni-load-more status="no-more" v-if="statMonth.piTaskHistoryStatVOS.length == 0" />
|
|
|
- </uni-section>
|
|
|
</view>
|
|
|
|
|
|
<!-- 年 -->
|
|
|
@@ -92,61 +40,66 @@
|
|
|
<uni-icons type="right" size="30" @click="plusYear(1)"></uni-icons>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ </view>
|
|
|
|
|
|
- <!-- 统计数据 -->
|
|
|
- <view class="stat-board">
|
|
|
- <view class="stat-board-title">打卡统计</view>
|
|
|
- <view class="stat-board-content">
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">全年需打卡</view>
|
|
|
- <view class="stat-item-value">{{ statYear.punchInTotalCount }}次</view>
|
|
|
- </view>
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">已打卡</view>
|
|
|
- <view class="stat-item-value">{{ statYear.punchInCount }}次</view>
|
|
|
- </view>
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">完成打卡</view>
|
|
|
- <view class="stat-item-value">{{ statYear.punchInDoneCount }}次</view>
|
|
|
- </view>
|
|
|
+ <!-- 统计数据 -->
|
|
|
+ <view class="stat-board">
|
|
|
+ <view class="stat-board-title">打卡统计</view>
|
|
|
+ <view class="stat-board-content">
|
|
|
+ <view class="stat-item">
|
|
|
+ <view class="stat-item-label">{{ currentTabIndex === 0 ? '本月' : '全年' }}需打卡</view>
|
|
|
+ <view class="stat-item-value">{{ statData.punchInTotalCount }}次</view>
|
|
|
+ </view>
|
|
|
+ <view class="stat-item">
|
|
|
+ <view class="stat-item-label">{{ currentTabIndex === 0 ? '本月' : '全年' }}已打卡</view>
|
|
|
+ <view class="stat-item-value">{{ statData.punchInCount }}次</view>
|
|
|
</view>
|
|
|
- <view class="stat-board-content stat-mt16">
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">打卡率</view>
|
|
|
- <view class="stat-item-value">{{ statYear.punchInRate }}%</view>
|
|
|
- </view>
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">完成率</view>
|
|
|
- <view class="stat-item-value">{{ statYear.punchInDoneRate }}%</view>
|
|
|
- </view>
|
|
|
- <view class="stat-item">
|
|
|
- <view class="stat-item-label">全年获取积分数</view>
|
|
|
- <view class="stat-item-value">{{ statYear.points }}</view>
|
|
|
- </view>
|
|
|
+ <view class="stat-item">
|
|
|
+ <view class="stat-item-label">完成打卡</view>
|
|
|
+ <view class="stat-item-value">{{ statData.punchInDoneCount }}次</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view class="stat-board-content stat-mt16">
|
|
|
+ <view class="stat-item">
|
|
|
+ <view class="stat-item-label">打卡率</view>
|
|
|
+ <view class="stat-item-value">{{ statData.punchInRate }}%</view>
|
|
|
+ </view>
|
|
|
+ <view class="stat-item">
|
|
|
+ <view class="stat-item-label">完成率</view>
|
|
|
+ <view class="stat-item-value">{{ statData.punchInDoneRate }}%</view>
|
|
|
+ </view>
|
|
|
+ <view class="stat-item">
|
|
|
+ <view class="stat-item-label">{{ currentTabIndex === 0 ? '本月' : '全年' }}获取积分数</view>
|
|
|
+ <view class="stat-item-value">{{ statData.points }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
|
|
|
- <uni-section title="打卡日志" padding="16px" type="line">
|
|
|
- <uni-list>
|
|
|
- <uni-list-item v-for="taskHistory in statYear.piTaskHistoryStatVOS" :key="taskHistory.punchInDate">
|
|
|
- <template v-slot:body>
|
|
|
- {{ taskHistory.punchInDate }}
|
|
|
- <span v-if="taskHistory.punchInResult == PUNCH_IN_RESULT.DONE"> 完成打卡</span>
|
|
|
- <span v-else> 未完成打卡</span>
|
|
|
- <span v-if="taskHistory.punchInMethod == PUNCH_IN_METHOD.COUNT">,打卡{{ taskHistory.countTrack }}次</span>
|
|
|
- <span v-if="taskHistory.punchInMethod == PUNCH_IN_METHOD.TIMING">,打卡时长{{ taskHistory.timeTrack }}</span>
|
|
|
- </template>
|
|
|
- </uni-list-item>
|
|
|
- </uni-list>
|
|
|
- <uni-load-more status="no-more" v-if="statYear.piTaskHistoryStatVOS.length == 0" />
|
|
|
- </uni-section>
|
|
|
+ <view class="charts-box">
|
|
|
+ <qiun-data-charts type="line" :opts="chartOpts" :chartData="statData.lineVO" :canvas2d="true"
|
|
|
+ :loadingType="chatLoadingType" canvasId="mbnxeAGxItOvNjxrYfKUKyifYeNyjLGj" />
|
|
|
</view>
|
|
|
|
|
|
+ <!-- <uni-section title="打卡日志" padding="16px" type="line">
|
|
|
+ <uni-list>
|
|
|
+ <uni-list-item v-for="taskHistory in statData.piTaskHistoryStatVOS" :key="taskHistory.punchInDate">
|
|
|
+ <template v-slot:body>
|
|
|
+ {{ taskHistory.punchInDate }}
|
|
|
+ <span v-if="taskHistory.punchInResult == PUNCH_IN_RESULT.DONE"> 完成打卡</span>
|
|
|
+ <span v-else> 未完成打卡</span>
|
|
|
+ <span v-if="taskHistory.punchInMethod == PUNCH_IN_METHOD.COUNT">,打卡{{ taskHistory.countTrack }}次</span>
|
|
|
+ <span v-if="taskHistory.punchInMethod == PUNCH_IN_METHOD.TIMING">,打卡时长{{ taskHistory.timeTrack }}</span>
|
|
|
+ </template>
|
|
|
+</uni-list-item>
|
|
|
+</uni-list>
|
|
|
+<uni-load-more status="no-more" v-if="statData.piTaskHistoryStatVOS.length == 0" />
|
|
|
+</uni-section> -->
|
|
|
+
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import { ref } from 'vue';
|
|
|
-import { onLoad, onPullDownRefresh, onShow, onReady } from '@dcloudio/uni-app';
|
|
|
+import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app';
|
|
|
import { punchInApi } from '@/apis/apis';
|
|
|
import { PUNCH_IN_RESULT, PUNCH_IN_METHOD, STAT_PERIOD } from '@/common/enums';
|
|
|
|
|
|
@@ -182,35 +135,28 @@ const currentMonth = ref('2025-04');
|
|
|
const currentYear = ref('2025');
|
|
|
|
|
|
/**
|
|
|
- * 打卡统计数据-月
|
|
|
+ * 默认统计数据(空)
|
|
|
*/
|
|
|
-const statMonth = ref({
|
|
|
+const defaultStatData = {
|
|
|
punchInTotalCount: 0,
|
|
|
punchInCount: 0,
|
|
|
punchInDoneCount: 0,
|
|
|
punchInRate: 0,
|
|
|
punchInDoneRate: 0,
|
|
|
points: 0,
|
|
|
- piTaskHistoryStatVOS: []
|
|
|
-});
|
|
|
+ piTaskHistoryStatVOS: [],
|
|
|
+ lineVO: {}
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
- * 打卡统计数据-年
|
|
|
+ * 打卡统计数据
|
|
|
*/
|
|
|
-const statYear = ref({
|
|
|
- punchInTotalCount: 0,
|
|
|
- punchInCount: 0,
|
|
|
- punchInDoneCount: 0,
|
|
|
- punchInRate: 0,
|
|
|
- punchInDoneRate: 0,
|
|
|
- points: 0,
|
|
|
- piTaskHistoryStatVOS: []
|
|
|
-});
|
|
|
+const statData = ref(defaultStatData);
|
|
|
|
|
|
/**
|
|
|
- * 图表数据
|
|
|
+ * 图表加载动画
|
|
|
*/
|
|
|
-const chartData = ref({});
|
|
|
+const chatLoadingType = ref(0);
|
|
|
|
|
|
/**
|
|
|
* 图表配置
|
|
|
@@ -218,10 +164,12 @@ const chartData = ref({});
|
|
|
const chartOpts = ref({
|
|
|
color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
|
|
|
padding: [15, 10, 0, 15],
|
|
|
- enableScroll: false,
|
|
|
+ enableScroll: true,
|
|
|
legend: {},
|
|
|
xAxis: {
|
|
|
- disableGrid: true
|
|
|
+ disableGrid: true,
|
|
|
+ scrollShow: true,
|
|
|
+ itemCount: 1
|
|
|
},
|
|
|
yAxis: {
|
|
|
gridType: "dash",
|
|
|
@@ -243,6 +191,7 @@ const chartOpts = ref({
|
|
|
const switchTab = (e) => {
|
|
|
if (currentTabIndex.value !== e.currentIndex) {
|
|
|
currentTabIndex.value = e.currentIndex
|
|
|
+ currentStatPeriod.value = e.currentIndex == 0 ? STAT_PERIOD.MONTH : STAT_PERIOD.YEAR;
|
|
|
loadData();
|
|
|
}
|
|
|
}
|
|
|
@@ -274,6 +223,8 @@ const plusMonth = (num) => {
|
|
|
let tempYear = tempDate.getFullYear();
|
|
|
let tempMonth = (tempDate.getMonth() + 1).toString().padStart(2, "0"); // 月份从0开始,+1后格式化为两位数
|
|
|
currentMonth.value = `${tempYear}-${tempMonth}`;
|
|
|
+
|
|
|
+ loadData();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -292,30 +243,15 @@ const plusYear = (num) => {
|
|
|
* 加载数据
|
|
|
*/
|
|
|
const loadData = async () => {
|
|
|
+ // chatLoadingType.value = 2;
|
|
|
let res = await punchInApi.queryStat({
|
|
|
"statPeriod": currentStatPeriod.value,
|
|
|
"statTime": currentStatPeriod.value == STAT_PERIOD.MONTH ? currentMonth.value : currentYear.value,
|
|
|
"taskId": currentTaskId.value
|
|
|
});
|
|
|
-
|
|
|
- // 没有统计数据
|
|
|
- if (!res) {
|
|
|
- res = {
|
|
|
- punchInTotalCount: 0,
|
|
|
- punchInCount: 0,
|
|
|
- punchInDoneCount: 0,
|
|
|
- punchInRate: 0,
|
|
|
- punchInDoneRate: 0,
|
|
|
- points: 0,
|
|
|
- piTaskHistoryStatVOS: []
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- if (currentStatPeriod.value == STAT_PERIOD.MONTH) {
|
|
|
- statMonth.value = res;
|
|
|
- } else {
|
|
|
- statYear.value = res;
|
|
|
- }
|
|
|
+ // chatLoadingType.value = 0;
|
|
|
+ // 统计数据为空,则使用默认数据
|
|
|
+ statData.value = res ? res : defaultStatData;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -333,34 +269,7 @@ onLoad(async (e) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-function getServerData() {
|
|
|
- //模拟从服务器获取数据时的延时
|
|
|
- setTimeout(() => {
|
|
|
- //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
|
|
|
- let res = {
|
|
|
- categories: ["2016", "2017", "2018", "2019", "2020", "2021"],
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: "目标值",
|
|
|
- data: [35, 36, 31, 33, 13, 34]
|
|
|
- },
|
|
|
- {
|
|
|
- name: "完成量",
|
|
|
- data: [18, 27, 21, 24, 6, 28]
|
|
|
- }
|
|
|
- ]
|
|
|
- };
|
|
|
- chartData.value = JSON.parse(JSON.stringify(res));
|
|
|
- }, 500);
|
|
|
-}
|
|
|
-
|
|
|
-onReady(() => {
|
|
|
-
|
|
|
-
|
|
|
-});
|
|
|
-
|
|
|
onPullDownRefresh(() => {
|
|
|
- getServerData();
|
|
|
loadData();
|
|
|
uni.stopPullDownRefresh();
|
|
|
});
|
|
|
@@ -409,14 +318,10 @@ onPullDownRefresh(() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
.charts-box {
|
|
|
- width: 50%;
|
|
|
- min-width: 375px !important;
|
|
|
+ padding: 16rpx 16rpx;
|
|
|
+ width: 100%;
|
|
|
height: 400rpx;
|
|
|
- margin-left: auto;
|
|
|
- margin-right: auto;
|
|
|
- border: 1px solid blue;
|
|
|
}
|
|
|
|
|
|
.stat-board {
|