From 00a7a61df86db969f2ba61c508d02ba4709ce3d4 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期五, 05 六月 2026 10:09:06 +0800
Subject: [PATCH] 改bug
---
admin/src/views/index.vue | 84 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 76 insertions(+), 8 deletions(-)
diff --git a/admin/src/views/index.vue b/admin/src/views/index.vue
index f1c26ab..5bc5a82 100644
--- a/admin/src/views/index.vue
+++ b/admin/src/views/index.vue
@@ -9,7 +9,9 @@
<el-button :type="currentDateType === 2 ? 'primary' : 'default'" @click="onDateTypeChange(2)">杩�30鏃�</el-button>
<el-button :type="currentDateType === 3 ? 'primary' : 'default'" @click="onDateTypeChange(3)">鍗婂勾</el-button>
<el-button :type="currentDateType === 4 ? 'primary' : 'default'" @click="onDateTypeChange(4)">涓�骞�</el-button>
+ <el-button :type="currentDateType === 5 ? 'primary' : 'default'" @click="onDateTypeChange(5)">鑷畾涔�</el-button>
</el-button-group>
+ <el-date-picker v-if="currentDateType === 5" v-model="customDateRange" type="daterange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡" value-format="yyyy-MM-dd" style="margin-left: 10px;" :picker-options="customDatePickerOptions" clearable></el-date-picker>
<el-select v-model="currentShopId" filterable placeholder="璇烽�夋嫨瀵勫瓨鐐�" style="width: 200px; margin: 0 10px;">
<el-option
v-for="shop in shopList"
@@ -153,6 +155,7 @@
:value="month"
></el-option>
</el-select>
+ <el-button type="success" size="mini" @click="exportRevenueTrend">瀵煎嚭</el-button>
</div>
</div>
<div class="chart-content">
@@ -166,7 +169,7 @@
<div class="chart-header">
<span class="chart-title">骞冲彴璐㈠姟鎬昏</span>
<div class="filter-group">
- <el-date-picker type="daterange" range-separator="鑷�" start-placeholder="寮�濮嬫湀浠�" end-placeholder="缁撴潫鏈堜唤" v-model="financeDateRange" value-format="yyyy-MM" style="margin-right: 10px" :picker-options="financePickerOptions" clearable></el-date-picker>
+ <el-date-picker type="monthrange" range-separator="鑷�" start-placeholder="寮�濮嬫湀浠�" end-placeholder="缁撴潫鏈堜唤" v-model="financeDateRange" value-format="yyyy-MM" style="margin-right: 10px" :picker-options="financePickerOptions" clearable></el-date-picker>
<el-button type="primary" size="mini" @click="getFinanceOverviewData">鏌ヨ</el-button>
<el-button size="mini" @click="resetFinanceDate">閲嶇疆</el-button>
<el-button type="success" size="mini" @click="exportFinanceData">瀵煎嚭</el-button>
@@ -210,7 +213,7 @@
<!-- 涓氱哗鎺掑悕鍒嗘瀽 -->
<div class="charts-row" style="margin-top: 20px; margin-bottom: 0;">
- <div class="chart-card" style="width: calc(50% - 20px);">
+ <div class="chart-card">
<div class="chart-header">
<span class="chart-title">闂ㄥ簵涓氱哗TOP10</span>
</div>
@@ -226,8 +229,10 @@
</el-table>
</div>
</div>
+ </div>
- <div class="chart-card" style="width: calc(50% - 20px);">
+ <div class="charts-row" style="margin-top: 20px; margin-bottom: 0;">
+ <div class="chart-card">
<div class="chart-header">
<span class="chart-title">鍙告満涓氱哗TOP10</span>
</div>
@@ -248,7 +253,7 @@
</template>
<script>
-import { overview, memberTrend, orderTrend, revenueTrend, financeOverview, exportExcel, luggageTypeExport, shopTop, driverTop } from '@/api/business/dataBoard'
+import { overview, memberTrend, orderTrend, revenueTrend, financeOverview, exportExcel, luggageTypeExport, shopTop, driverTop, revenueTrendExport } from '@/api/business/dataBoard'
import { fetchList } from '@/api/business/shopInfo'
import * as echarts from 'echarts'
@@ -316,6 +321,26 @@
},
financeMinDate: null,
financeList: [],
+ customDateRange: null,
+ customDatePickerOptions: {
+ disabledDate: (time) => {
+ if (time.getTime() > Date.now()) {
+ return true
+ }
+ return false
+ },
+ onPick: ({ maxDate, minDate }) => {
+ if (maxDate) {
+ const oneYear = 365 * 24 * 60 * 60 * 1000
+ const diff = maxDate.getTime() - minDate.getTime()
+ if (diff > oneYear) {
+ this.$nextTick(() => {
+ this.customDateRange = [minDate, new Date(minDate.getTime() + oneYear)]
+ })
+ }
+ }
+ }
+ },
storeTopList: [],
driverTopList: [
{ driverName: '寮犱紵澶�', phone: '18356981111', totalOrder: '100', totalIncome: '90720.00', driverShare: '90720.00', refundCount: '100', deductionTotal: '90720.00' },
@@ -372,8 +397,48 @@
}
},
methods: {
+ async exportRevenueTrend() {
+ try {
+ const params = {}
+ if (this.revenueMonth) {
+ params.month = `${this.revenueYear}-${String(this.revenueMonth).padStart(2, '0')}`
+ } else {
+ params.year = this.revenueYear
+ }
+ const response = await revenueTrendExport(params)
+
+ // 鍒涘缓涓嬭浇閾炬帴
+ const blob = new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
+ const url = window.URL.createObjectURL(blob)
+ const link = document.createElement('a')
+ link.href = url
+
+ let fileName
+ if (this.revenueMonth) {
+ fileName = `琛屾潕瀵勫瓨闂ㄥ簵${this.revenueYear}骞�${String(this.revenueMonth).padStart(2, '0')}鏈堟棩.xlsx`
+ } else {
+ fileName = `琛屾潕瀵勫瓨闂ㄥ簵${this.revenueYear}骞存湀.xlsx`
+ }
+
+ link.setAttribute('download', fileName)
+ document.body.appendChild(link)
+ link.click()
+ document.body.removeChild(link)
+ window.URL.revokeObjectURL(url)
+
+ this.$message.success('瀵煎嚭鎴愬姛')
+ } catch (error) {
+ console.error('瀵煎嚭琛屾潕绫诲瀷鏁版嵁澶辫触:', error)
+ this.$message.error('瀵煎嚭澶辫触锛岃绋嶅悗閲嶈瘯')
+ }
+ },
async getOverviewData(dateType = 0, shopId = null) {
- const response = await overview({ dateType, shopId })
+ const params = { dateType, shopId }
+ if (dateType === 5 && this.customDateRange && this.customDateRange.length === 2) {
+ params.startDate = this.customDateRange[0]
+ params.endDate = this.customDateRange[1]
+ }
+ const response = await overview(params)
this.overviewData = response || null
this.$nextTick(() => {
this.renderPieChart()
@@ -381,7 +446,9 @@
},
onDateTypeChange(dateType) {
this.currentDateType = dateType
- this.getOverviewData(dateType, this.currentShopId)
+ if (dateType !== 5) {
+ this.getOverviewData(dateType, this.currentShopId)
+ }
},
onSearch() {
this.getOverviewData(this.currentDateType, this.currentShopId)
@@ -389,6 +456,7 @@
onReset() {
this.currentDateType = 0
this.currentShopId = null
+ this.customDateRange = null
this.getOverviewData(0, null)
},
async getShopList() {
@@ -421,7 +489,7 @@
tooltip: {
trigger: 'item',
formatter: (params) => {
- return `${params.name}<br/>琛屾潕鏁�: ${params.data.luggageCount}`
+ return `${params.name}<br/>琛屾潕鏁�: ${params.data.luggageCount}<br/>璁㈠崟鏁�: ${params.data.value}`
}
},
series: [
@@ -438,7 +506,7 @@
label: {
show: true,
position: 'outside',
- formatter: '{b}'
+ formatter: '{b} {d}%'
},
emphasis: {
label: {
--
Gitblit v1.9.3