parent
2269ec7fbd
commit
3d0c56f73c
@ -0,0 +1,268 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="统计时间" prop="btyCoresProduceDate">
|
||||
<el-date-picker
|
||||
v-model="btyCoresProduceDate"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="站点" prop="btyNo">
|
||||
<el-select v-model="queryParams.stationNos" placeholder="请选择" multiple clearable>
|
||||
<el-option
|
||||
v-for="(item, index) in stationinfoList"
|
||||
:key="index"
|
||||
:label="item.stationName"
|
||||
:value="item.stationNo"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select
|
||||
v-model="queryParams.type"
|
||||
placeholder="请选择时间类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.STATISTICAL_TIME_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button @click="getList"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
<!-- echarts -->
|
||||
<ContentWrap>
|
||||
<!-- <div id="powerChangingTimesStatistics" :style="{ width: '100%', height: '400px' }"></div> -->
|
||||
<!-- 折线图 -->
|
||||
<Echart :height="400" :options="eChartOptions" />
|
||||
</ContentWrap>
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list2"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
:header-cell-style="{
|
||||
backgroundColor: '#eff4fa'
|
||||
}"
|
||||
>
|
||||
<el-table-column label="序号" type="index" align="center" width="80" />
|
||||
<el-table-column label="换电站编码" align="center" prop="stationNo" />
|
||||
<el-table-column label="换电站名称" align="center" prop="stationName" />
|
||||
<el-table-column label="时间" align="center" prop="time" />
|
||||
<!-- <el-table-column label="统计" align="center" prop="count" /> -->
|
||||
<el-table-column label="换电营收(分)" align="center" prop="swapRevenue" />
|
||||
<!-- <el-table-column label="充电营收" align="center" prop="chargeRevenue" /> -->
|
||||
<!-- <el-table-column label="失败统计" align="center" prop="loseCount" /> -->
|
||||
</el-table>
|
||||
<!-- <Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/> -->
|
||||
</ContentWrap>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { EChartsOption } from 'echarts'
|
||||
import { StationInfoApi, StationInfoVO } from '@/api/share/stationinfo'
|
||||
import { swapRevenueCountApi, swapRevenueCountVO } from '@/api/system/statisticsManagement/stationRevenueStatistics'
|
||||
import * as TradeStatisticsApi from '@/api/mall/statistics/member'
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
/** 电池基础信息 列表 */
|
||||
defineOptions({ name: 'BatteryInfo' })
|
||||
|
||||
/** 详情操作 */
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const list2 = ref([])
|
||||
// 列表的总页数
|
||||
const total = ref(0)
|
||||
|
||||
const queryParams = reactive({
|
||||
type: 3,
|
||||
stationNos: [],
|
||||
startTime: null,
|
||||
endTime: null
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const btyCoresProduceDate = ref([])
|
||||
// 获取列表数据
|
||||
|
||||
const getlist2 = async () => {
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
let params={...queryParams}
|
||||
params.stationNo=queryParams.stationNos
|
||||
const data = await swapRevenueCountApi.outChargeCountInfo(params)
|
||||
list2.value = data
|
||||
// console.log(list2.value,"zzzzzzzzzz")
|
||||
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
const stationinfoList = ref([])
|
||||
const getStationList = async () => {
|
||||
try {
|
||||
const data = await StationInfoApi.getStationInfoList()
|
||||
// console.log(data, 'data')
|
||||
stationinfoList.value = data
|
||||
let array = []
|
||||
for (let item of data) {
|
||||
array.push(item.stationNo)
|
||||
}
|
||||
queryParams.stationNos = array
|
||||
getList()
|
||||
queryParams.stationNos = []
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
const convertToTimestamp = (timeString) => {
|
||||
// 创建一个 Date 对象
|
||||
const date = new Date(timeString)
|
||||
|
||||
// 检查日期是否有效
|
||||
if (isNaN(date.getTime())) {
|
||||
throw new Error('无效的时间字符串')
|
||||
}
|
||||
|
||||
// 返回时间戳
|
||||
return date.getTime()
|
||||
}
|
||||
|
||||
const getList = async () => {
|
||||
if (btyCoresProduceDate.value.length > 0) {
|
||||
queryParams.startTime = convertToTimestamp(btyCoresProduceDate.value[0])
|
||||
queryParams.endTime = convertToTimestamp(btyCoresProduceDate.value[1])
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
getlist2()
|
||||
const data = await TradeStatisticsApi.getOutChargeCountElectric(queryParams)
|
||||
// console.log(data, 'data')
|
||||
eChartOptions.series = []
|
||||
eChartOptions.legend.data = []
|
||||
let x_data = []
|
||||
let legend_data = []
|
||||
let finall_array_success = new Array(queryParams.stationNos.length).fill([])
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
x_data.push(data[i].xname)
|
||||
let itme_array_success = []
|
||||
for (var j = 0; j < data[i].list.length; j++) {
|
||||
if (i == 0) {
|
||||
legend_data.push(data[i].list[j].stationName)
|
||||
}
|
||||
itme_array_success.push(data[i].list[j].electricQuantityCount)
|
||||
}
|
||||
finall_array_success[i] = itme_array_success
|
||||
}
|
||||
finall_array_success = splitArrayBySubarrayLength(finall_array_success)
|
||||
|
||||
eChartOptions.legend.data = legend_data
|
||||
eChartOptions.xAxis.data = x_data
|
||||
for (let item in finall_array_success) {
|
||||
eChartOptions.series.push({
|
||||
name: legend_data[item],
|
||||
type: 'bar',
|
||||
smooth: true,
|
||||
data: finall_array_success[item]
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
const splitArrayBySubarrayLength = (arr) => {
|
||||
// 确保每个子数组长度相同
|
||||
if (arr.some((subArr) => subArr.length !== arr[0].length)) {
|
||||
throw new Error('Subarrays must have the same length.')
|
||||
}
|
||||
|
||||
const length = arr[0].length
|
||||
const result = Array.from({ length }, () => [])
|
||||
|
||||
arr.forEach((subArr) => {
|
||||
subArr.forEach((item, index) => {
|
||||
result[index].push(item)
|
||||
})
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// ==========================
|
||||
|
||||
onMounted(() => {
|
||||
getStationList()
|
||||
})
|
||||
|
||||
const eChartOptions = reactive<EChartsOption>({
|
||||
title: {
|
||||
text: '站营收统计'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
legend: {
|
||||
data: [],
|
||||
left: 'center'
|
||||
},
|
||||
series: [
|
||||
// {
|
||||
// data: data1,
|
||||
// type: 'line',
|
||||
// smooth: true,
|
||||
// name: '内乡站'
|
||||
// },
|
||||
]
|
||||
}) as EChartsOption
|
||||
|
||||
// ==========================
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
// queryFormRef.value.resetFields()
|
||||
queryParams.type= 3
|
||||
queryParams.stationNos=[]
|
||||
btyCoresProduceDate.value=[]
|
||||
queryParams.startTime=null
|
||||
queryParams.endTime=null
|
||||
getList()
|
||||
}
|
||||
</script>
|
@ -0,0 +1,269 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="统计时间" prop="btyCoresProduceDate">
|
||||
<el-date-picker
|
||||
v-model="btyCoresProduceDate"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="站点" prop="btyNo">
|
||||
<el-select v-model="queryParams.stationNos" placeholder="请选择" multiple clearable>
|
||||
<el-option
|
||||
v-for="(item, index) in stationinfoList"
|
||||
:key="index"
|
||||
:label="item.stationName"
|
||||
:value="item.stationNo"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select
|
||||
v-model="queryParams.type"
|
||||
placeholder="请选择时间类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.STATISTICAL_TIME_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button @click="getList"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
<!-- echarts -->
|
||||
<ContentWrap>
|
||||
<!-- <div id="powerChangingTimesStatistics" :style="{ width: '100%', height: '400px' }"></div> -->
|
||||
<!-- 折线图 -->
|
||||
<Echart :height="400" :options="eChartOptions" />
|
||||
</ContentWrap>
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list2"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
:header-cell-style="{
|
||||
backgroundColor: '#eff4fa'
|
||||
}"
|
||||
>
|
||||
<el-table-column label="序号" type="index" align="center" width="80" />
|
||||
<el-table-column label="换电站编码" align="center" prop="stationNo" />
|
||||
<el-table-column label="换电站名称" align="center" prop="stationName" />
|
||||
<el-table-column label="时间" align="center" prop="time" />
|
||||
<!-- <el-table-column label="统计" align="center" prop="count" /> -->
|
||||
<el-table-column label="换电营收(分)" align="center" prop="swapRevenue" />
|
||||
<!-- <el-table-column label="充电营收" align="center" prop="chargeRevenue" /> -->
|
||||
<!-- <el-table-column label="失败统计" align="center" prop="loseCount" /> -->
|
||||
</el-table>
|
||||
<!-- <Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/> -->
|
||||
</ContentWrap>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { EChartsOption } from 'echarts'
|
||||
import { StationInfoApi, StationInfoVO } from '@/api/share/stationinfo'
|
||||
import { swapRevenueCountApi, swapRevenueCountVO } from '@/api/system/statisticsManagement/stationRevenueStatistics'
|
||||
import * as TradeStatisticsApi from '@/api/mall/statistics/member'
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
/** 电池基础信息 列表 */
|
||||
defineOptions({ name: 'BatteryInfo' })
|
||||
|
||||
/** 详情操作 */
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const list2 = ref([])
|
||||
// 列表的总页数
|
||||
const total = ref(0)
|
||||
|
||||
const queryParams = reactive({
|
||||
type: 3,
|
||||
stationNos: [],
|
||||
startTime: null,
|
||||
endTime: null
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const btyCoresProduceDate = ref([])
|
||||
// 获取列表数据
|
||||
|
||||
const getlist2 = async () => {
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
let params={...queryParams}
|
||||
params.stationNo=queryParams.stationNos
|
||||
const data = await swapRevenueCountApi.outChargeRevenueCountInfo(params)
|
||||
list2.value = data
|
||||
// console.log(list2.value,"zzzzzzzzzz")
|
||||
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
const stationinfoList = ref([])
|
||||
const getStationList = async () => {
|
||||
try {
|
||||
const data = await StationInfoApi.getStationInfoList()
|
||||
// console.log(data, 'data')
|
||||
stationinfoList.value = data
|
||||
let array = []
|
||||
for (let item of data) {
|
||||
array.push(item.stationNo)
|
||||
}
|
||||
queryParams.stationNos = array
|
||||
getList()
|
||||
queryParams.stationNos = []
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
const convertToTimestamp = (timeString) => {
|
||||
// 创建一个 Date 对象
|
||||
const date = new Date(timeString)
|
||||
|
||||
// 检查日期是否有效
|
||||
if (isNaN(date.getTime())) {
|
||||
throw new Error('无效的时间字符串')
|
||||
}
|
||||
|
||||
// 返回时间戳
|
||||
return date.getTime()
|
||||
}
|
||||
|
||||
const getList = async () => {
|
||||
if (btyCoresProduceDate.value.length > 0) {
|
||||
queryParams.startTime = convertToTimestamp(btyCoresProduceDate.value[0])
|
||||
queryParams.endTime = convertToTimestamp(btyCoresProduceDate.value[1])
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
getlist2()
|
||||
const data = await TradeStatisticsApi.getOutTotalrevenue(queryParams)
|
||||
// console.log(data, 'data')
|
||||
eChartOptions.series = []
|
||||
eChartOptions.legend.data = []
|
||||
let x_data = []
|
||||
let legend_data = []
|
||||
let finall_array_success = new Array(queryParams.stationNos.length).fill([])
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
x_data.push(data[i].xname)
|
||||
let itme_array_success = []
|
||||
for (var j = 0; j < data[i].list.length; j++) {
|
||||
if (i == 0) {
|
||||
legend_data.push(data[i].list[j].stationName)
|
||||
}
|
||||
itme_array_success.push(data[i].list[j].swapRevenue)
|
||||
}
|
||||
finall_array_success[i] = itme_array_success
|
||||
}
|
||||
finall_array_success = splitArrayBySubarrayLength(finall_array_success)
|
||||
|
||||
eChartOptions.legend.data = legend_data
|
||||
eChartOptions.xAxis.data = x_data
|
||||
for (let item in finall_array_success) {
|
||||
eChartOptions.series.push({
|
||||
name: legend_data[item],
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
data: finall_array_success[item]
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
const splitArrayBySubarrayLength = (arr) => {
|
||||
// 确保每个子数组长度相同
|
||||
if (arr.some((subArr) => subArr.length !== arr[0].length)) {
|
||||
throw new Error('Subarrays must have the same length.')
|
||||
}
|
||||
|
||||
const length = arr[0].length
|
||||
const result = Array.from({ length }, () => [])
|
||||
|
||||
arr.forEach((subArr) => {
|
||||
subArr.forEach((item, index) => {
|
||||
result[index].push(item)
|
||||
})
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// ==========================
|
||||
|
||||
onMounted(() => {
|
||||
getStationList()
|
||||
})
|
||||
|
||||
const eChartOptions = reactive<EChartsOption>({
|
||||
title: {
|
||||
text: '站营收统计'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
legend: {
|
||||
data: [],
|
||||
left: 'center'
|
||||
},
|
||||
series: [
|
||||
// {
|
||||
// data: data1,
|
||||
// type: 'line',
|
||||
// smooth: true,
|
||||
// name: '内乡站'
|
||||
// },
|
||||
]
|
||||
}) as EChartsOption
|
||||
|
||||
// ==========================
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
// queryFormRef.value.resetFields()
|
||||
queryParams.type= 3
|
||||
queryParams.stationNos=[]
|
||||
btyCoresProduceDate.value=[]
|
||||
queryParams.startTime=null
|
||||
queryParams.endTime=null
|
||||
getList()
|
||||
}
|
||||
</script>
|
||||
|
@ -0,0 +1,274 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="统计时间" prop="btyCoresProduceDate">
|
||||
<el-date-picker
|
||||
v-model="btyCoresProduceDate"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="站点" prop="btyNo">
|
||||
<el-select v-model="queryParams.stationNos" placeholder="请选择" multiple clearable>
|
||||
<el-option
|
||||
v-for="(item, index) in stationinfoList"
|
||||
:key="index"
|
||||
:label="item.stationName"
|
||||
:value="item.stationNo"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select
|
||||
v-model="queryParams.type"
|
||||
placeholder="请选择时间类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.STATISTICAL_TIME_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button @click="getList"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
<!-- echarts -->
|
||||
<ContentWrap>
|
||||
<!-- <div id="powerChangingTimesStatistics" :style="{ width: '100%', height: '400px' }"></div> -->
|
||||
<!-- 折线图 -->
|
||||
<Echart :height="400" :options="eChartOptions" />
|
||||
</ContentWrap>
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list2"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
:header-cell-style="{
|
||||
backgroundColor: '#eff4fa'
|
||||
}"
|
||||
>
|
||||
<el-table-column label="序号" type="index" align="center" width="80" />
|
||||
<el-table-column label="换电站编码" align="center" prop="stationNo" />
|
||||
<el-table-column label="换电站名称" align="center" prop="stationName" />
|
||||
<el-table-column label="时间" align="center" prop="time" />
|
||||
<!-- <el-table-column label="统计" align="center" prop="count" />
|
||||
<el-table-column label="换电营收" align="center" prop="swapRevenue" />
|
||||
<el-table-column label="充电营收" align="center" prop="chargeRevenue" />
|
||||
<el-table-column label="失败统计" align="center" prop="loseCount" /> -->
|
||||
<el-table-column label="充电次数" align="center" prop="chargeQuantity" />
|
||||
<el-table-column label="充电时长(min)" align="center" prop="chargeTime" />
|
||||
</el-table>
|
||||
<!-- <Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/> -->
|
||||
</ContentWrap>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { EChartsOption } from 'echarts'
|
||||
import { StationInfoApi, StationInfoVO } from '@/api/share/stationinfo'
|
||||
import { chargeCountApi, chargeCountVO } from '@/api/system/statisticsManagement/stationChargingTimesStatistics'
|
||||
import * as TradeStatisticsApi from '@/api/mall/statistics/member'
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
/** 电池基础信息 列表 */
|
||||
defineOptions({ name: 'BatteryInfo' })
|
||||
|
||||
/** 详情操作 */
|
||||
const loading = ref(false) // 列表的加载中
|
||||
|
||||
// 列表的总页数
|
||||
|
||||
const total = ref(0)
|
||||
const list2 = ref([])
|
||||
const queryParams = reactive({
|
||||
type: 3,
|
||||
stationNos: [],
|
||||
startTime: null,
|
||||
endTime: null
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const btyCoresProduceDate = ref([])
|
||||
|
||||
|
||||
const convertToTimestamp = (timeString) => {
|
||||
// 创建一个 Date 对象
|
||||
const date = new Date(timeString)
|
||||
|
||||
// 检查日期是否有效
|
||||
if (isNaN(date.getTime())) {
|
||||
throw new Error('无效的时间字符串')
|
||||
}
|
||||
|
||||
// 返回时间戳
|
||||
return date.getTime()
|
||||
}
|
||||
|
||||
// 获取列表
|
||||
|
||||
const getlist2 = async () => {
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
let params={...queryParams}
|
||||
params.stationNo=queryParams.stationNos
|
||||
const data = await chargeCountApi.outChargeCountInfo(params)
|
||||
list2.value = data
|
||||
// console.log(list2.value,"zzzzzzzzzz")
|
||||
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const getList = async () => {
|
||||
if (btyCoresProduceDate.value.length > 0) {
|
||||
queryParams.startTime = convertToTimestamp(btyCoresProduceDate.value[0])
|
||||
queryParams.endTime = convertToTimestamp(btyCoresProduceDate.value[1])
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
getlist2()
|
||||
const data = await TradeStatisticsApi.getTotalOutchargeCount(queryParams)
|
||||
// console.log(data, 'data')
|
||||
eChartOptions.series = []
|
||||
eChartOptions.legend.data = []
|
||||
let x_data = []
|
||||
let legend_data = []
|
||||
let finall_array_success = new Array(queryParams.stationNos.length).fill([])
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
x_data.push(data[i].xname)
|
||||
let itme_array_success = []
|
||||
for (var j = 0; j < data[i].list.length; j++) {
|
||||
if (i == 0) {
|
||||
legend_data.push(data[i].list[j].stationName)
|
||||
}
|
||||
itme_array_success.push(data[i].list[j].outChargeCount)
|
||||
|
||||
}
|
||||
finall_array_success[i] = itme_array_success
|
||||
}
|
||||
finall_array_success = splitArrayBySubarrayLength(finall_array_success)
|
||||
|
||||
eChartOptions.legend.data = legend_data
|
||||
eChartOptions.xAxis.data = x_data
|
||||
for (let item in finall_array_success) {
|
||||
eChartOptions.series.push({
|
||||
name: legend_data[item],
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
data: finall_array_success[item]
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================
|
||||
|
||||
const splitArrayBySubarrayLength = (arr) => {
|
||||
// 确保每个子数组长度相同
|
||||
if (arr.some((subArr) => subArr.length !== arr[0].length)) {
|
||||
throw new Error('Subarrays must have the same length.')
|
||||
}
|
||||
|
||||
const length = arr[0].length
|
||||
const result = Array.from({ length }, () => [])
|
||||
|
||||
arr.forEach((subArr) => {
|
||||
subArr.forEach((item, index) => {
|
||||
result[index].push(item)
|
||||
})
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
const stationinfoList = ref([])
|
||||
const getStationList = async () => {
|
||||
try {
|
||||
const data = await StationInfoApi.getStationInfoList()
|
||||
// console.log(data, 'data')
|
||||
stationinfoList.value = data
|
||||
let array = []
|
||||
for (let item of data) {
|
||||
array.push(item.stationNo)
|
||||
}
|
||||
queryParams.stationNos = array
|
||||
getList()
|
||||
queryParams.stationNos = []
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getStationList()
|
||||
})
|
||||
|
||||
const eChartOptions = reactive<EChartsOption>({
|
||||
title: {
|
||||
text: '站外充电次数统计'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
legend: {
|
||||
data: [],
|
||||
left: 'center'
|
||||
},
|
||||
series: [
|
||||
// {
|
||||
// data: data1,
|
||||
// type: 'line',
|
||||
// smooth: true,
|
||||
// name: '内乡站'
|
||||
// }
|
||||
]
|
||||
}) as EChartsOption
|
||||
|
||||
// ==========================
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
// queryFormRef.value.resetFields()
|
||||
}
|
||||
queryParams.type= 3
|
||||
queryParams.stationNos=[]
|
||||
btyCoresProduceDate.value=[]
|
||||
queryParams.startTime=null
|
||||
queryParams.endTime=null
|
||||
getList()
|
||||
</script>
|
||||
|
Loading…
Reference in new issue