|
@@ -189,9 +189,9 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, computed, onMounted } from 'vue'
|
|
|
|
|
|
|
+import { ref, onMounted } from 'vue'
|
|
|
import { onReachBottom } from '@dcloudio/uni-app'
|
|
import { onReachBottom } from '@dcloudio/uni-app'
|
|
|
-import { getDailyStatList, getMonthlyStatList } from '../../api/stat.js'
|
|
|
|
|
|
|
+import { getDailyStatList, getMonthlyStatList, getDailyStatAggregate } from '../../api/stat.js'
|
|
|
import { getStationList } from '../../api/station.js'
|
|
import { getStationList } from '../../api/station.js'
|
|
|
import { formatTime, showToast, formatAmount } from '../../utils/index.js'
|
|
import { formatTime, showToast, formatAmount } from '../../utils/index.js'
|
|
|
import { loadDicts } from '../../utils/dict.js'
|
|
import { loadDicts } from '../../utils/dict.js'
|
|
@@ -212,14 +212,45 @@ const selectedStationName = ref('')
|
|
|
const showDetail = ref(false)
|
|
const showDetail = ref(false)
|
|
|
const detailItem = ref(null)
|
|
const detailItem = ref(null)
|
|
|
|
|
|
|
|
-const summary = computed(() => {
|
|
|
|
|
- const totalIncome = list.value.reduce((sum, item) => sum + (item.totalIncome || 0), 0)
|
|
|
|
|
- const totalConsumption = list.value.reduce((sum, item) => sum + (item.consumption || 0), 0)
|
|
|
|
|
- const totalOrders = list.value.reduce((sum, item) => sum + (item.ordersCount || 0), 0)
|
|
|
|
|
- const totalRegistrations = list.value.reduce((sum, item) => sum + (item.registrations || 0), 0)
|
|
|
|
|
- const totalActiveUsers = list.value.reduce((sum, item) => sum + (item.activeUserCount || 0), 0)
|
|
|
|
|
- return { totalIncome, totalConsumption, totalOrders, totalRegistrations, totalActiveUsers }
|
|
|
|
|
|
|
+const summary = ref({
|
|
|
|
|
+ totalIncome: 0,
|
|
|
|
|
+ totalConsumption: 0,
|
|
|
|
|
+ totalOrders: 0,
|
|
|
|
|
+ totalRegistrations: 0,
|
|
|
|
|
+ totalActiveUsers: 0
|
|
|
})
|
|
})
|
|
|
|
|
+const summaryLoading = ref(false)
|
|
|
|
|
+
|
|
|
|
|
+const loadSummary = async () => {
|
|
|
|
|
+ if (activeTab.value !== 0) {
|
|
|
|
|
+ // 月统计暂不走聚合接口
|
|
|
|
|
+ summary.value = { totalIncome: 0, totalConsumption: 0, totalOrders: 0, totalRegistrations: 0, totalActiveUsers: 0 }
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ summaryLoading.value = true
|
|
|
|
|
+ try {
|
|
|
|
|
+ const params = {}
|
|
|
|
|
+ if (selectedStationId.value) params.stationId = selectedStationId.value
|
|
|
|
|
+ if (filterKey.value) {
|
|
|
|
|
+ params.startDate = filterKey.value
|
|
|
|
|
+ params.endDate = filterKey.value
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await getDailyStatAggregate(params)
|
|
|
|
|
+ if (res && res.code === 200 && res.data) {
|
|
|
|
|
+ summary.value = {
|
|
|
|
|
+ totalIncome: res.data.totalIncome || 0,
|
|
|
|
|
+ totalConsumption: res.data.totalConsumption || 0,
|
|
|
|
|
+ totalOrders: res.data.ordersCount || 0,
|
|
|
|
|
+ totalRegistrations: res.data.registrations || 0,
|
|
|
|
|
+ totalActiveUsers: res.data.activeUserCount || 0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('加载汇总数据失败:', e)
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ summaryLoading.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const loadStations = async () => {
|
|
const loadStations = async () => {
|
|
|
try {
|
|
try {
|
|
@@ -295,6 +326,7 @@ const loadData = async (isLoadMore = false) => {
|
|
|
} else {
|
|
} else {
|
|
|
list.value = records
|
|
list.value = records
|
|
|
page.value = 2
|
|
page.value = 2
|
|
|
|
|
+ loadSummary()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|