From 0e997dbbfeacaf72e91380d035265836b8df8a7d Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期五, 13 三月 2026 16:39:34 +0800
Subject: [PATCH] 报表数据
---
admin/src/views/index.vue | 749 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 543 insertions(+), 206 deletions(-)
diff --git a/admin/src/views/index.vue b/admin/src/views/index.vue
index 883b044..aca11bf 100644
--- a/admin/src/views/index.vue
+++ b/admin/src/views/index.vue
@@ -1,39 +1,129 @@
<template>
- <div class="main_home">
- <div class="home_header">
- <div class="mb10 fs17">涓嬪崍濂斤紝{{ userInfo.realname }}</div>
- <div class="fs13">
- 浠婂ぉ鏄� {{ nowDate }} {{ nowWeek }}锛屾杩庤鍏姟杞﹂挜鍖欐櫤鑳芥煖绠$悊绯荤粺
+ <div class="main_app1">
+ <div class="main_home">
+ <div class="home_header">
+ <div class="mb10 fs17">涓嬪崍濂斤紝{{ userInfo.realname }}</div>
+ <div class="fs13">
+ 浠婂ぉ鏄� {{ nowDate }} {{ nowWeek }}锛屾杩庤鍏姟杞﹂挜鍖欐櫤鑳芥煖绠$悊绯荤粺
+ </div>
+ </div>
+ </div>
+ <div class="main_head">
+ <div class="main_head_title" >
+ <span>杞﹁締娲惧崟缁熻鎬昏(娆�)</span>
+ </div>
+ <div class="main_head_bottom">
+ <div class="main_head_item blue">
+ <span>{{info.todayTotal || 0}}</span>
+ <span>浠婃棩</span>
+ </div>
+ <div class="main_head_item red">
+ <span>{{info.yesterdayTotal || 0}}</span>
+ <span>鏄ㄦ棩</span>
+ </div>
+ <div class="main_head_item yellow">
+ <span>{{info.weekTotal || 0}}</span>
+ <span>鏈懆</span>
+ </div>
+ <div class="main_head_item orange">
+ <span>{{info.monthTotal || 0}}</span>
+ <span>鏈湀</span>
+ </div>
+ <div class="main_head_item darkBlue">
+ <span>{{info.yearTotal || 0}}</span>
+ <span>鏈勾</span>
+ </div>
+ </div>
+ </div>
+ <div class="main_content">
+ <div class="type_wrap">
+ <div class="title" style="display: flex; align-items: center; justify-content: space-between;">
+ <div style="display: flex; align-items: center;">
+ <span>鍏ㄥ勾娲捐溅鐢宠瓒嬪娍(娆�)</span>
+ </div>
+ </div>
+ <div id="echart1" ref="typeRef" v-show="info.cumulativeDataList && info.cumulativeDataList.length"></div>
+ <div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;" v-show="!info.cumulativeDataList || !info.cumulativeDataList.length">
+ <img style="width: 200px;" src="@/assets/images/default_homeimg.png" alt="">
+ </div>
+ </div>
+ </div>
+ <div class="main_table">
+ <div class="main_table_list">
+ <div class="title" style="display: flex; align-items: center; justify-content: space-between;">
+ <div style="display: flex; align-items: center;">
+ <span>鍏ュ洯杞﹁締缁熻琛�</span>
+ <el-radio-group style="margin-left: 20px;" v-model="radio" @change="changeBB">
+ <el-radio-button label="month">鏈堝害</el-radio-button>
+ <el-radio-button label="year">骞村害</el-radio-button>
+ </el-radio-group>
+ <el-date-picker
+ v-model="date1"
+ :type="radio"
+ :clearable="false"
+ @change="getReportLists()"
+ :value-format="radio === 'month' ? 'yyyy-MM' : 'yyyy'"
+ style="margin-left: 10px; width: 120px;"
+ placeholder="璇烽�夋嫨">
+ </el-date-picker>
+ </div>
+ <el-button type="primary" style="margin-left: 20px;" icon="el-icon-upload2" @click="daochu">瀵煎嚭</el-button>
+ </div>
+ <div style="width: 100%;display: flex;margin: 20px">
+ <span style="width: 100px;text-align: right;padding-right: 20px;">鎸囧畾杞﹁締</span>
+ <el-select v-model="carCodeList" filterable multiple clearable style="margin-left: 10px;width: 100%;padding-right: 20px; " @change="getReportLists" placeholder="鎸囧畾杞﹁締" >
+ <el-option v-for="item in carList" :key="item.code" :label="item.code" :value="item.code">
+ </el-option>
+ </el-select>
+ </div>
+ <div style="display: block;">
+ <template v-if="column.length > 0">
+ <el-table
+ style="width: 100%; margin-top: 15px;"
+ :data="list"
+ :header-row-style="{'background-color': '#F7F7F7'}"
+ border
+ >
+ <el-table-column :prop="item" :label="item" align="center" :fixed="index === 0 ? true : index === column.length - 1 ? 'right' : false" v-for="(item, index) in column" :key="index">
+ <template slot-scope="{row}">
+ <span v-if="row[item] && row[item] >0" class="green" style="font-weight: 600;">{{row[item]}}</span>
+ <span v-else >{{row[item]}}</span>
+ </template>
+ </el-table-column>
+ </el-table>
+ </template>
+ <div style="width: 100%;margin-top: 100px;height: 100px;display: flex;align-items: center;justify-content: center;" v-else>
+ <img style="width: 200px;" src="@/assets/images/default_homeimg.png" alt="">
+ </div>
+ </div>
</div>
</div>
</div>
</template>
<script>
+import * as echarts from 'echarts'
+import { getCarUseData, getReportList, reportExportExcel } from '@/api/business/carUseBook'
import dayjs from 'dayjs'
import { weeks } from '@/utils/config'
-const colors = ['#52a4f7', '#7678f7', '#5fc6d5']
+import { allList as carList } from '@/api/business/cars'
export default {
- components: {
- },
data () {
return {
- searchForm: {
- timeType: null,
- timeName: '鍏ㄩ儴'
- },
- colors,
+ info: { cumulativeDataList: [] },
nowDate: '',
nowWeek: '',
- headerData: {},
- headerData1: {},
- staticData0: {},
- staticData01: {},
- staticData1: {},
- staticData2: {},
- staticData3: {},
- staticData4: {},
- manningRatio: []
+ isGroupBy: 0,
+ radio: 'month',
+ value: '',
+ dateType: 'month',
+ date: '',
+ carids: [],
+ carList: [],
+ date1: '',
+ column: [],
+ list: [],
+ carCodeList: []
}
},
computed: {
@@ -41,237 +131,484 @@
return this.$store.state.userInfo
}
},
- created () {
- },
mounted () {
+ var now = new Date()
+ var year = now.getFullYear()
+ var month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`
+ this.value = `${year}-${month}`
+ this.date1 = `${year}-${month}`
this.updateDate()
- // this.initData()
+ this.getData()
+ this.loadCars()
+ this.getReportLists()
},
methods: {
+ loadCars () {
+ carList({
+ type: 0 // 鍏姟杞�
+ })
+ .then(res => {
+ this.carList = res
+ })
+ .catch(e => {
+ })
+ .finally(() => {
+ })
+ },
updateDate () {
this.nowDate = dayjs().format('YYYY骞碝鏈圖鏃�')
this.nowWeek = weeks[new Date().getDay()]
+ },
+ daochu () {
+ reportExportExcel({ dateStr: this.date1, carCodeList: this.carCodeList}).then(res => {
+ this.download(res)
+ })
+ },
+ getReportLists () {
+ this.column=[]
+ this.list=[]
+ getReportList({ dateStr: this.date1, carCodeList: this.carCodeList, type: 0 })
+ .then(res => {
+ if (res && res.length) {
+ this.column = res[0]
+ this.list = res.slice(1).map(row => {
+ const obj = {}
+ this.column.forEach((header, index) => {
+ obj[header] = row[index]
+ })
+ return obj
+ })
+ }
+ console.log(this.list)
+ })
+ },
+ changeBB () {
+ if (this.radio === 'month') {
+ const now = new Date()
+ const year = now.getFullYear()
+ const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`
+ this.date1 = `${year}-${month}`
+ } else {
+ const now = new Date()
+ const year = now.getFullYear()
+ this.date1 = `${year}`
+ }
+ this.getReportLists()
+ },
+ changeDateType () {
+ if (this.dateType === 'month') {
+ const now = new Date()
+ const year = now.getFullYear()
+ const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`
+ this.value = `${year}-${month}`
+ } else {
+ const now = new Date()
+ const year = now.getFullYear()
+ this.value = `${year}`
+ }
+ this.getReportLists()
+ },
+ // 鍩虹鏁版嵁
+ getData () {
+ getCarUseData({ }).then(res => {
+ this.info = res || {}
+ setTimeout(() => {
+ this.initType()
+ }, 1000)
+ })
+ },
+ // 鍏ㄥ勾鍏ュ洯杞﹁締瓒嬪娍
+ initType () {
+ if (!this.info.cumulativeDataList) return
+ const myChart = echarts.init(document.querySelector('#echart1'))
+ const names = this.info.cumulativeDataList.map(item => item.name)
+ const datas = this.info.cumulativeDataList.map(item => item.total)
+ const option = {
+ tooltip: {
+ trigger: 'axis',
+ axisPointer: {
+ type: 'line'
+ }
+ },
+ legend: {
+ show: false,
+ orient: 'vertical',
+ left: 'left'
+ },
+ graphic: {
+ elements: [
+ {
+ type: 'text',
+ left: 'left',
+ top: 'top',
+ style: {
+ text: '娲捐溅娆℃暟',
+ textAlign: 'center',
+ fill: '#333'
+ }
+ }
+ ]
+ },
+ grid: {
+ left: '0%',
+ right: '5%',
+ bottom: '10%',
+ top: '20%',
+ containLabel: true
+ },
+ xAxis: {
+ type: 'category',
+ data: names
+ },
+ yAxis: {
+ type: 'value',
+ axisLine: {
+ show: true
+ },
+ axisLabel: {
+ formatter: function (value) {
+ // 鍥涜垗浜斿叆鍒版渶杩戠殑鏁存暟
+ return Math.round(value)
+ }
+ }
+ },
+ series: [
+ {
+ data: datas,
+ name: '鍏ュ洯杞﹁締',
+ type: 'line',
+ areaStyle: {
+ normal: {
+ color: {
+ x: 0,
+ y: 0,
+ x2: 0,
+ y2: 1,
+ colorStops: [{
+ offset: 0,
+ color: '#207FF7' // 0% 澶勭殑棰滆壊
+ }, {
+ offset: 1,
+ color: 'rgba(255,255,255,.2)' // 100% 澶勭殑棰滆壊
+ }],
+ globalCoord: false // 缂虹渷涓� false
+ }
+ }
+ },
+ lineStyle: { // 绾挎潯鏍峰紡
+ color: {
+ type: 'linear',
+ x: 0,
+ y: 0,
+ x2: 0,
+ y2: 1,
+ colorStops: [{
+ offset: 0, color: '#207FF7' // 0% 澶勭殑棰滆壊
+ }, {
+ offset: 1, color: '#207FF7' // 100% 澶勭殑棰滆壊
+ }]
+ },
+ width: 2 // 绾挎潯绮楃粏
+ },
+ symbol: 'circle',
+ symbolSize: 10,
+ itemStyle: {
+ borderWidth: 1,
+ borderColor: '#fff',
+ color: '#207FF7'
+ },
+ smooth: false
+ }
+ ]
+ }
+ myChart.setOption(option)
+ window.addEventListener('resize', function () { // 鎵ц
+ myChart.resize()
+ })
+ myChart.resize()
}
+
}
}
</script>
<style lang="scss" scoped>
-::v-deep .el-input--small .el-input__inner {
- height: 30px !important; // 杩欓噷灏辨槸淇敼榛樿楂樺害
- width: 120px;
-}
-div {
+.main_app1 {
+ width: 100%;
+ height: calc(100% - 44px);
+ overflow-y: auto;
+ overflow-x: hidden;
+ padding: 15px;
box-sizing: border-box;
-}
-
-.home_title {
- font-weight: 600;
- font-size: 16px;
- color: #222222;
- line-height: 22px;
-}
-.mb50{
- margin-bottom: 50px;
-}
-.main {
- display: flex;
- position: relative;
- z-index: 99;
-
- .app_content {
- flex: 1;
-
- .static_card {
- height: 187px;
+ background-color: #F4F7FC;
+ .main_home {
+ background: #f4f7fc;
+ position: relative;
+ width: 100%;
+ height: 120px;
+ overflow: hidden;
+ .home_header {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 80px;
+ padding: 20px;
color: #fff;
+ background: linear-gradient(180deg, #076ae5 10%, rgba(32, 127, 247, 0) 100%);
+ }
+ }
+ .main_head {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ flex-direction: column;
+ margin-bottom: 10px;
+ background-color: #ffffff;
+ padding: 20px;
+ box-sizing: border-box;
+ .main_head_title {
+ width: 100%;
display: flex;
+ align-items: center;
+ margin-bottom: 20px;
+ span {
+ font-weight: 500;
+ font-size: 18px;
+ color: #222222;
+ margin-right: 30px;
+ }
+ }
+ .main_head_bottom {
+ width: 100%;
+ display: flex;
+ align-items: center;
justify-content: space-between;
-
- .card {
- flex: 1;
- height: 187px;
- background: linear-gradient(270deg, #29aeff 0%, #207ff7 100%);
- box-shadow: 0px 2px 10px 0px rgba(32, 127, 247, 0.4);
- border-radius: 8px;
- margin-right: 14px;
-
- &:nth-of-type(2) {
- background: linear-gradient(270deg, #8383ff 0%, #6b6eff 100%);
- }
-
- &:nth-of-type(3) {
- background: linear-gradient(270deg, #42d49d 0%, #12bb8b 100%);
- }
-
- &:nth-of-type(4) {
- margin-right: 0;
- background: linear-gradient(270deg, #c430dee3 0%, #cd04b9cf 100%);
- //linear-gradient(270deg, #de3049b8 0%, #cd0421d4 100%);
- //background: linear-gradient(270deg, #30d3de 0%, #04b7cd 100%);
- }
-
- .header {
- height: 103px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20px 20px 12px;
- border-bottom: 1px solid rgba(255, 255, 255, 0.2);
-
- img {
- width: 40px;
- height: 40px;
- }
-
- .num {
+ .blue {
+ border-left: 8px solid #12BB8B;
+ }
+ .red {
+ border-left: 8px solid #F6CF46;
+ }
+ .yellow {
+ border-left: 8px solid #5DC9FB;
+ }
+ .orange {
+ border-left: 8px solid #FF9E56;
+ }
+ .darkBlue {
+ border-left: 8px solid #6B6EFF;
+ }
+ .main_head_item {
+ width: 19%;
+ height: 112px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ box-sizing: border-box;
+ border-radius: 5px;
+ background-color: #F4F7FC;
+ span {
+ &:nth-child(1) {
font-weight: 600;
font-size: 30px;
- margin-top: 12px;
+ color: #222222;
}
- }
-
- .content {
- height: 82px;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- font-size: 13px;
- padding: 15px 20px 20px;
+ &:nth-child(2) {
+ font-weight: 400;
+ font-size: 14px;
+ color: #222222;
+ }
}
}
}
+ }
- .funcs {
- height: 149px;
+ .main_table {
+ display: flex;
+ align-items: start;
+ justify-content: space-between;
+ margin-top: 10px;
+ .main_table_list {
+ background-color: #ffffff;
padding: 20px;
- background: #fff;
- margin: 10px 0;
-
- .list {
+ box-sizing: border-box;
+ width: 100%;
+ .title {
display: flex;
- padding-top: 20px;
-
- .item {
+ align-items: center;
+ span {
+ font-weight: 500;
+ font-size: 18px;
+ color: #222222;
+ }
+ }
+ .list_wu {
+ width: 100%;
+ height: 100px;
+ line-height: 100px;
+ text-align: center;
+ font-size: 16px;
+ color: #222222;
+ }
+ .list_head {
+ width: 100%;
+ height: 50px;
+ display: flex;
+ align-items: center;
+ background-color: #F7F7F7;
+ border-left: 1px solid #DFE2E8;
+ border-top: 1px solid #DFE2E8;
+ margin-top: 15px;
+ .list_head_item {
+ flex: 1;
+ height: 100%;
display: flex;
- flex-direction: column;
align-items: center;
justify-content: center;
- margin-right: 24px;
- cursor: pointer;
-
- img {
- width: 44px;
- height: 44px;
- }
- }
- }
- }
- }
- .static_wrap {
- .wrap {
- background: #fff;
- padding: 20px 20px 10px;
- border-radius: 2px;
- border: 1px solid #eeeeee;
- height: 280px;
- flex: 1;
- margin-top: 10px;
- margin-bottom: 20px;
- &:nth-of-type(2n) {
- //margin-left: 10px;
- }
- .echart {
- width: 100%;
- height: 190px;
- position: relative;
- display: flex;
- div{
- flex: 1;
- height: 190px;
- }
- }
-
- .header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 30px;
-
- .more {
font-size: 13px;
- color: #999999;
+ color: #222222;
+ font-weight: 500;
+ border-right: 1px solid #DFE2E8;
+ }
+ }
+ .table_box {
+ width: 100%;
+ border-bottom: 1px solid #DFE2E8;
+ .list_content {
+ width: 100%;
+ height: 50px;
+ display: flex;
+ align-items: center;
+ border-left: 1px solid #DFE2E8;
+ border-top: 1px solid #DFE2E8;
+ .list_head_item {
+ flex: 1;
+ height: 100%;
+ display: flex;
+ border-right: 1px solid #DFE2E8;
+ align-items: center;
+ justify-content: center;
+ font-size: 13px;
+ color: #222222;
+ }
}
}
}
-
- .static1 {
- .content {
+ .main_table_list1 {
+ width: 30%;
+ padding: 20px;
+ box-sizing: border-box;
+ flex-shrink: 0;
+ background-color: #ffffff;
+ .title {
+ font-weight: 500;
+ font-size: 18px;
+ color: #222222;
+ }
+ .list_wu {
+ width: 100%;
+ height: 100px;
+ line-height: 100px;
+ text-align: center;
+ font-size: 16px;
+ color: #222222;
+ }
+ .list_head {
+ width: 100%;
+ height: 50px;
display: flex;
- justify-content: center;
align-items: center;
- height: 100%;
-
- .echart_wrap {
- position: relative;
-
- .pie_text {
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- z-index: 999;
+ background-color: #F7F7F7;
+ border-left: 1px solid #DFE2E8;
+ border-top: 1px solid #DFE2E8;
+ margin-top: 15px;
+ .list_head_item {
+ flex: 1.8;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 13px;
+ color: #222222;
+ font-weight: 500;
+ border-right: 1px solid #DFE2E8;
+ &:last-child {
+ flex: 1;
}
}
-
- .echart {
- width: 150px;
- height: 150px;
- }
-
- .list {
- margin-left: 36px;
-
- .item {
+ }
+ .table_box {
+ width: 100%;
+ border-bottom: 1px solid #DFE2E8;
+ .list_content {
+ width: 100%;
+ height: 50px;
+ display: flex;
+ align-items: center;
+ border-left: 1px solid #DFE2E8;
+ border-top: 1px solid #DFE2E8;
+ .list_head_item {
+ flex: 1.8;
+ height: 100%;
display: flex;
align-items: center;
- margin: 8px 0;
-
- .icon {
- width: 16px;
- height: 16px;
- border-radius: 50%;
- margin-right: 6px;
- background: linear-gradient(270deg, #29aeff 0%, #207ff7 100%);
- }
-
- .text {
- margin-right: 6px;
+ border-right: 1px solid #DFE2E8;
+ justify-content: center;
+ text-align: center;
+ font-size: 13px;
+ color: #222222;
+ &:last-child {
+ flex: 1;
}
}
}
}
}
}
-}
-.main_home {
- background: #f4f7fc;
- position: relative;
- width: 100%;
- height: 100%;
- overflow: auto;
- padding: 92px 20px 20px;
- .home_header {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 200px;
- padding: 20px;
- color: #fff;
- background: linear-gradient(180deg, #076ae5 0%, rgba(32, 127, 247, 0) 100%);
+ .main_content {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ height: 350px;
+
+ .title {
+ font-weight: 500;
+ font-size: 18px;
+ color: #222222;
+ }
+
+ .type_wrap {
+ flex: 1;
+ height: 100%;
+ background-color: #ffffff;
+ padding: 20px;
+ box-sizing: border-box;
+ /*border-right: 12px solid #f7f7f7;*/
+
+ #echart1 {
+ width: 100%;
+ height: 100%;
+ margin-top: 18px;
+ }
+ }
+
+ .dept_wrap {
+ width: 420px;
+ flex-shrink: 0;
+ height: 100%;
+ background-color: #ffffff;
+ padding: 20px;
+ box-sizing: border-box;
+ margin-left: 10px;
+ #echart_2 {
+ width: 100%;
+ height: 100%;
+ }
+ }
}
}
</style>
--
Gitblit v1.9.3