增加统计
parent
c24c563858
commit
065abec30d
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API\Admin\YeWu;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class AppointmentTypeController extends Controller
|
||||||
|
{
|
||||||
|
//各种预约方式数量统计
|
||||||
|
public function countAppointmentType(){
|
||||||
|
$searchInfo = request('searchInfo');
|
||||||
|
$list = DB::table('s_list');
|
||||||
|
if(isset($searchInfo['dateRange'])){
|
||||||
|
$list=$list->whereBetween('s_list.reservation_date', $searchInfo['dateRange']);
|
||||||
|
}
|
||||||
|
$list=$list
|
||||||
|
->where(['s_list.list_status' => 2, 's_list.is_del' => 0, 's_list.is_nullify' => 0])
|
||||||
|
->select('appointment_type_id', 's_appointment_type.name', DB::raw('count(*) as count'))
|
||||||
|
->leftJoin('s_appointment_type', 's_list.appointment_type_id', '=', 's_appointment_type.id')
|
||||||
|
->groupBy('appointment_type_id', 's_appointment_type.name') // 添加 s_appointment_type.name 到 groupBy
|
||||||
|
->get();
|
||||||
|
|
||||||
|
//按月统计
|
||||||
|
$monthList = DB::table('s_list');
|
||||||
|
if(isset($searchInfo['dateRange'])){
|
||||||
|
$monthList=$monthList->whereBetween('s_list.reservation_date', $searchInfo['dateRange']);
|
||||||
|
}
|
||||||
|
$monthList=$monthList
|
||||||
|
->where(['s_list.list_status' => 2,'s_list.is_del' => 0,'s_list.is_nullify' => 0])
|
||||||
|
->select(DB::raw('DATE_FORMAT(s_list.reservation_date, "%Y-%m") as month'), DB::raw('count(*) as count'))
|
||||||
|
->groupBy('month')->get();
|
||||||
|
return \Yz::Return(true, '操作成功', ['list'=>$list,'monthList'=>$monthList]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
<template>
|
||||||
|
<div class="head">
|
||||||
|
<el-row>
|
||||||
|
<el-form-item>
|
||||||
|
<el-date-picker style="margin-left: 8px; width: 300px" v-model="searchInfo.dateRange"
|
||||||
|
type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间"
|
||||||
|
value-format="YYYY-MM-DD" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-button @click="countAppointmentTypeFunc()" style="margin-left: 10px;">搜索</el-button>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
<div v-if="monthNameList.length>0" id="MonthCount" class="MonthCount"></div>
|
||||||
|
<el-table :data="tableData" style="width: 100%;" row-key="id" v-loading="loading">
|
||||||
|
<el-table-column prop="name" label="方式" />
|
||||||
|
<el-table-column prop="count" label="数量" />
|
||||||
|
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
onMounted,computed, nextTick
|
||||||
|
} from 'vue'
|
||||||
|
import * as echarts from 'echarts';
|
||||||
|
import {
|
||||||
|
countAppointmentType,GetServiceDateTime,
|
||||||
|
} from '@/api/api.js'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
const groupList_new = computed(() => {
|
||||||
|
return groupList.value.filter(item => (item.id ==2));
|
||||||
|
});
|
||||||
|
let loading=ref(false);
|
||||||
|
let searchInfo=ref({
|
||||||
|
name:''
|
||||||
|
})
|
||||||
|
let Info=ref({
|
||||||
|
id:null,
|
||||||
|
name:'',
|
||||||
|
status:1
|
||||||
|
})
|
||||||
|
|
||||||
|
let dialogVisible=ref(false);
|
||||||
|
|
||||||
|
//获取设备list
|
||||||
|
let tableData = ref([])
|
||||||
|
let monthData=ref();
|
||||||
|
let currentPage = ref(1) //当前页码
|
||||||
|
let pageSize = ref(15) //每页数量
|
||||||
|
let total = 0 //总数量
|
||||||
|
//获取服务器时间
|
||||||
|
const GetServiceDate = () => {
|
||||||
|
GetServiceDateTime().then(res => {
|
||||||
|
if (res.status) {
|
||||||
|
let datetime = res.data.datetime.substr(0, 10)
|
||||||
|
searchInfo.value.dateRange = [datetime, datetime]
|
||||||
|
countAppointmentTypeFunc()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
let monthNameList=ref([]);
|
||||||
|
let monthCountList=ref([]);
|
||||||
|
const countAppointmentTypeFunc=()=>{
|
||||||
|
loading.value = true
|
||||||
|
countAppointmentType({searchInfo:searchInfo.value}).then(res => {
|
||||||
|
loading.value = false
|
||||||
|
if (res.status) {
|
||||||
|
tableData.value=res.data.list
|
||||||
|
monthData.value=res.data.monthList
|
||||||
|
monthNameList.value=[];
|
||||||
|
monthCountList.value=[];
|
||||||
|
monthData.value.forEach((v,i)=>{
|
||||||
|
monthNameList.value.push(v.month)
|
||||||
|
monthCountList.value.push(v.count)
|
||||||
|
})
|
||||||
|
if(monthNameList.value.length>0){
|
||||||
|
nextTick(()=>{
|
||||||
|
DrawMonth()
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const DrawMonth=()=>{
|
||||||
|
var ChartMonthCount = echarts.init(document.getElementById('MonthCount'));
|
||||||
|
// 绘制图表
|
||||||
|
ChartMonthCount.setOption({
|
||||||
|
title: {
|
||||||
|
text: searchInfo.value.dateRange[0]+'~'+searchInfo.value.dateRange[1]+'预约量统计(月)'
|
||||||
|
},
|
||||||
|
tooltip: {},
|
||||||
|
xAxis: {
|
||||||
|
data: monthNameList.value
|
||||||
|
},
|
||||||
|
yAxis: {},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '数量',
|
||||||
|
type: 'bar',
|
||||||
|
data:monthCountList.value
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(()=>{
|
||||||
|
GetServiceDate()
|
||||||
|
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.page {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.MonthCount{
|
||||||
|
height: 400px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,144 @@
|
|||||||
|
<template>
|
||||||
|
<div class="head">
|
||||||
|
<el-row>
|
||||||
|
<el-form-item>
|
||||||
|
<el-date-picker style="margin-left: 8px; width: 300px" v-model="searchInfo.dateRange"
|
||||||
|
type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间"
|
||||||
|
value-format="YYYY-MM-DD" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-button @click="CountMakeListFunc()" style="margin-left: 10px;">搜索</el-button>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
<div v-if="KaiDanCount>0" id="MonthCount" class="MonthCount"></div>
|
||||||
|
<el-table :data="tableData" style="width: 100%;" row-key="id" v-loading="loading">
|
||||||
|
<el-table-column prop="month" label="月份" />
|
||||||
|
<el-table-column prop="count" label="开单数量" />
|
||||||
|
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
onMounted,computed, nextTick
|
||||||
|
} from 'vue'
|
||||||
|
import * as echarts from 'echarts';
|
||||||
|
import {
|
||||||
|
CountMakeList,GetServiceDateTime,
|
||||||
|
} from '@/api/api.js'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
const groupList_new = computed(() => {
|
||||||
|
return groupList.value.filter(item => (item.id ==2));
|
||||||
|
});
|
||||||
|
let loading=ref(false);
|
||||||
|
let searchInfo=ref({
|
||||||
|
name:''
|
||||||
|
})
|
||||||
|
let Info=ref({
|
||||||
|
id:null,
|
||||||
|
name:'',
|
||||||
|
status:1
|
||||||
|
})
|
||||||
|
|
||||||
|
let dialogVisible=ref(false);
|
||||||
|
|
||||||
|
//获取设备list
|
||||||
|
let tableData = ref([])
|
||||||
|
let monthData=ref();
|
||||||
|
let currentPage = ref(1) //当前页码
|
||||||
|
let pageSize = ref(15) //每页数量
|
||||||
|
let total = 0 //总数量
|
||||||
|
//获取服务器时间
|
||||||
|
const GetServiceDate = () => {
|
||||||
|
GetServiceDateTime().then(res => {
|
||||||
|
if (res.status) {
|
||||||
|
let datetime = res.data.datetime.substr(0, 10)
|
||||||
|
searchInfo.value.dateRange = [datetime, datetime]
|
||||||
|
CountMakeListFunc()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
let AppointmentCount=ref(0);
|
||||||
|
let KaiDanCount=ref(0);
|
||||||
|
const CountMakeListFunc=()=>{
|
||||||
|
loading.value = true
|
||||||
|
CountMakeList({searchInfo:searchInfo.value}).then(res => {
|
||||||
|
loading.value = false
|
||||||
|
if (res.status) {
|
||||||
|
tableData.value=res.data.MonthCountList
|
||||||
|
KaiDanCount.value=res.data.Count
|
||||||
|
AppointmentCount.value=res.data.AppointmentCount
|
||||||
|
|
||||||
|
if(KaiDanCount.value>0){
|
||||||
|
nextTick(()=>{
|
||||||
|
DrawMonth()
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const DrawMonth=()=>{
|
||||||
|
var ChartMonthCount = echarts.init(document.getElementById('MonthCount'));
|
||||||
|
// 绘制图表
|
||||||
|
ChartMonthCount.setOption({
|
||||||
|
title: {
|
||||||
|
text: searchInfo.value.dateRange[0]+'~'+searchInfo.value.dateRange[1]+'开单检查量比',
|
||||||
|
subtext: '开单总量 '+ KaiDanCount.value,
|
||||||
|
left: 'center'
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'item'
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
orient: 'vertical',
|
||||||
|
left: 'left'
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: 'Access From',
|
||||||
|
type: 'pie',
|
||||||
|
radius: '50%',
|
||||||
|
data: [
|
||||||
|
{ value: KaiDanCount.value-AppointmentCount.value, name: '未预约' },
|
||||||
|
{ value: AppointmentCount.value, name: '已预约' },
|
||||||
|
|
||||||
|
],
|
||||||
|
emphasis: {
|
||||||
|
itemStyle: {
|
||||||
|
shadowBlur: 10,
|
||||||
|
shadowOffsetX: 0,
|
||||||
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(()=>{
|
||||||
|
GetServiceDate()
|
||||||
|
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.page {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.MonthCount{
|
||||||
|
height: 400px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue