分析按时间段查询
This commit is contained in:
parent
925cf5fbd7
commit
596293d45a
|
@ -15,31 +15,35 @@ export function searchCandidates(data) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAdmindata1() {
|
export function getAdmindata1(query) {
|
||||||
//各管理员录入学员数
|
//各管理员录入学员数
|
||||||
return request({
|
return request({
|
||||||
url: '/analyse/admindata1/',
|
url: '/analyse/admindata1/',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCompanydis() {
|
export function getCompanydis(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/analyse/companydis/',
|
url: '/analyse/companydis/',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConsumerdis() {
|
export function getConsumerdis(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/analyse/consumerdis/',
|
url: '/analyse/consumerdis/',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMonitest() {
|
export function getMonitest(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/analyse/monitest/',
|
url: '/analyse/monitest/',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
params: query
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -1,68 +1,106 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-card>
|
<div style="margin-bottom: 2px">
|
||||||
<bar-chart :chartData="admindata1" />
|
<el-date-picker
|
||||||
</el-card>
|
v-model="daterange"
|
||||||
<el-row :gutter="6" style="margin-top:6px">
|
type="daterange"
|
||||||
<el-col :xs="24" :md="12">
|
range-separator="至"
|
||||||
<el-card>
|
start-placeholder="开始日期"
|
||||||
<china-map :chartData="companydis" />
|
end-placeholder="结束日期"
|
||||||
</el-card>
|
value-format="yyyy-MM-dd"
|
||||||
</el-col>
|
:picker-options="pickerOptions"
|
||||||
<el-col :xs="24" :md="12">
|
>
|
||||||
<el-card>
|
</el-date-picker>
|
||||||
<china-map :chartData="consumerdis" />
|
<el-button type="primary" icon="el-icon-query" @click="handleFilter"
|
||||||
</el-card>
|
>确定</el-button
|
||||||
</el-col>
|
>
|
||||||
</el-row>
|
|
||||||
<el-card style="margin-top:6px">
|
|
||||||
<line-chart :chartData="monidata" />
|
|
||||||
</el-card>
|
|
||||||
</div>
|
</div>
|
||||||
|
<el-card>
|
||||||
|
<bar-chart :chartData="admindata1" />
|
||||||
|
</el-card>
|
||||||
|
<el-row :gutter="6" style="margin-top: 6px">
|
||||||
|
<el-col :xs="24" :md="12">
|
||||||
|
<el-card>
|
||||||
|
<china-map :chartData="companydis" />
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :md="12">
|
||||||
|
<el-card>
|
||||||
|
<china-map :chartData="consumerdis" />
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-card style="margin-top: 6px">
|
||||||
|
<line-chart :chartData="monidata" />
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import BarChart from '../components/BarChart'
|
import BarChart from "../components/BarChart";
|
||||||
import ChinaMap from '../components/ChinaMap'
|
import ChinaMap from "../components/ChinaMap";
|
||||||
import LineChart from '../components/LineChart'
|
import LineChart from "../components/LineChart";
|
||||||
import { getAdmindata1, getCompanydis, getConsumerdis, getMonitest } from '@/api/analyse'
|
import {
|
||||||
|
getAdmindata1,
|
||||||
|
getCompanydis,
|
||||||
|
getConsumerdis,
|
||||||
|
getMonitest,
|
||||||
|
} from "@/api/analyse";
|
||||||
|
import { option } from 'runjs';
|
||||||
export default {
|
export default {
|
||||||
components:{BarChart, ChinaMap, LineChart},
|
components: { BarChart, ChinaMap, LineChart },
|
||||||
data(){
|
data() {
|
||||||
return {
|
return {
|
||||||
admindata1:{},
|
admindata1: {},
|
||||||
companydis:{},
|
companydis: {},
|
||||||
consumerdis:{},
|
consumerdis: {},
|
||||||
monidata:{}
|
monidata: {},
|
||||||
}
|
daterange: [],
|
||||||
|
query: { datestart: null, dateend: null },
|
||||||
|
pickerOptions: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.initquery();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initquery() {
|
||||||
|
let date = new Date();
|
||||||
|
this.query.datestart = date.getFullYear() + "-01-01";
|
||||||
|
this.query.dateend = date.getFullYear() + 1 + "-01-01";
|
||||||
|
this.daterange = [this.query.datestart, this.query.dateend];
|
||||||
|
this.getadmindata1(this.query);
|
||||||
|
this.getcompanydis(this.query);
|
||||||
|
this.getconsumerdis(this.query);
|
||||||
|
this.getmonitest(this.query);
|
||||||
},
|
},
|
||||||
created(){
|
handleFilter() {
|
||||||
this.getadmindata1()
|
this.query.datestart = this.daterange[0];
|
||||||
this.getcompanydis()
|
this.query.dateend = this.daterange[1];
|
||||||
this.getconsumerdis()
|
this.getadmindata1(this.query);
|
||||||
this.getmonitest()
|
this.getcompanydis(this.query);
|
||||||
|
this.getconsumerdis(this.query);
|
||||||
|
this.getmonitest(this.query);
|
||||||
},
|
},
|
||||||
methods:{
|
getadmindata1(query) {
|
||||||
getadmindata1(){
|
getAdmindata1(query).then((res) => {
|
||||||
getAdmindata1().then(res=>{
|
this.admindata1 = res.data;
|
||||||
this.admindata1 = res.data
|
});
|
||||||
})
|
},
|
||||||
},
|
getcompanydis(query) {
|
||||||
getcompanydis(){
|
getCompanydis(query).then((res) => {
|
||||||
getCompanydis().then(res=>{
|
this.companydis = res.data;
|
||||||
this.companydis = res.data
|
});
|
||||||
})
|
},
|
||||||
},
|
getconsumerdis(query) {
|
||||||
getconsumerdis(){
|
getConsumerdis(query).then((res) => {
|
||||||
getConsumerdis().then(res=>{
|
this.consumerdis = res.data;
|
||||||
this.consumerdis = res.data
|
});
|
||||||
})
|
},
|
||||||
},
|
getmonitest(query) {
|
||||||
getmonitest(){
|
getMonitest(query).then((res) => {
|
||||||
getMonitest().then(res=>{
|
this.monidata = res.data;
|
||||||
this.monidata = res.data
|
});
|
||||||
})
|
},
|
||||||
}
|
},
|
||||||
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
|
@ -32,8 +32,9 @@ class Admindata1(APIView):
|
||||||
各管理员录入学员数-柱状图
|
各管理员录入学员数-柱状图
|
||||||
"""
|
"""
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
|
queryset = UserProfile.objects.filter(is_delete=False)
|
||||||
ret = {'x':{'name':'管理员', 'data':[]}, 's':[{'name':'学员数', 'data':[]}], 't':'各管理员录入学员数'}
|
ret = {'x':{'name':'管理员', 'data':[]}, 's':[{'name':'学员数', 'data':[]}], 't':'各管理员录入学员数'}
|
||||||
tmp = UserProfile.objects.filter(is_delete=False).annotate(total=Count('consumer_create_admin')).order_by('-total').values('username', 'total')
|
tmp = queryset.annotate(total=Count('consumer_create_admin')).order_by('-total').values('username', 'total')
|
||||||
for i in tmp:
|
for i in tmp:
|
||||||
ret['x']['data'].append(i['username'])
|
ret['x']['data'].append(i['username'])
|
||||||
ret['s'][0]['data'].append(i['total'])
|
ret['s'][0]['data'].append(i['total'])
|
||||||
|
@ -47,8 +48,10 @@ class Monitest(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
ret = {'x':{'name':'月份', 'data':[]}, 's':[{'name':'模考数', 'data':[]}], 't':'趋势图', 'l':['模考数']}
|
ret = {'x':{'name':'月份', 'data':[]}, 's':[{'name':'模考数', 'data':[]}], 't':'趋势图', 'l':['模考数']}
|
||||||
# ret = {'x':{'name':'月份', 'data':[]}, 's':[{'name':'自助模考', 'data':[]}, {'name':'押卷模考', 'data':[]}], 't':'模考次数趋势图', 'l':['自助模考', '押卷模考']}
|
# ret = {'x':{'name':'月份', 'data':[]}, 's':[{'name':'自助模考', 'data':[]}, {'name':'押卷模考', 'data':[]}], 't':'模考次数趋势图', 'l':['自助模考', '押卷模考']}
|
||||||
tmp = ExamTest.objects.exclude(consumer__create_admin__isnull=True)\
|
queryset = ExamTest.objects.exclude(consumer__create_admin__isnull=True)
|
||||||
.annotate(create_month=ExtractMonth('create_time'), create_year=ExtractYear('create_time'))\
|
queryset = queryset.filter(create_time__gte = request.query_params.get('datestart')) if request.query_params.get('datestart', None) else queryset
|
||||||
|
queryset = queryset.filter(create_time__lte = request.query_params.get('dateend')) if request.query_params.get('dateend', None) else queryset
|
||||||
|
tmp = queryset.annotate(create_month=ExtractMonth('create_time'), create_year=ExtractYear('create_time'))\
|
||||||
.values('create_month', 'create_year').order_by('create_year', 'create_month').annotate(total=Count('create_month'))
|
.values('create_month', 'create_year').order_by('create_year', 'create_month').annotate(total=Count('create_month'))
|
||||||
for i in tmp:
|
for i in tmp:
|
||||||
# if str(i['create_year'])+'年'+str(i['create_month'])+'月' not in ret['x']['data']:
|
# if str(i['create_year'])+'年'+str(i['create_month'])+'月' not in ret['x']['data']:
|
||||||
|
@ -101,7 +104,10 @@ class Companydis(APIView):
|
||||||
"""
|
"""
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
ret = {'s':[], 't':'单位分布', 'max':800, 'min':0}
|
ret = {'s':[], 't':'单位分布', 'max':800, 'min':0}
|
||||||
tmp = Company.objects.exclude(geo__pname__isnull=True).values('geo__pname').annotate(total=Count('geo__pname'))
|
queryset = Company.objects.exclude(geo__pname__isnull=True)
|
||||||
|
queryset = queryset.filter(create_time__gte = request.query_params.get('datestart')) if request.query_params.get('datestart', None) else queryset
|
||||||
|
queryset = queryset.filter(create_time__lte = request.query_params.get('dateend')) if request.query_params.get('dateend', None) else queryset
|
||||||
|
tmp = queryset.values('geo__pname').annotate(total=Count('geo__pname'))
|
||||||
for i in tmp:
|
for i in tmp:
|
||||||
if i['geo__pname'] in nameMap:
|
if i['geo__pname'] in nameMap:
|
||||||
ret['s'].append({'name':nameMap[i['geo__pname']], 'value':i['total']})
|
ret['s'].append({'name':nameMap[i['geo__pname']], 'value':i['total']})
|
||||||
|
@ -113,11 +119,15 @@ class Consumerdis(APIView):
|
||||||
"""
|
"""
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
ret = {'s':[], 't':'学员分布', 'max':3000, 'min':0}
|
ret = {'s':[], 't':'学员分布', 'max':3000, 'min':0}
|
||||||
tmp = Consumer.objects.exclude(company__geo__pname__isnull=True).values('company__geo__pname').annotate(total=Count('company__geo__pname'))
|
queryset = Consumer.objects.exclude(company__geo__pname__isnull=True)
|
||||||
|
queryset = queryset.filter(create_time__gte = request.query_params.get('datestart')) if request.query_params.get('datestart', None) else queryset
|
||||||
|
queryset = queryset.filter(create_time__lte = request.query_params.get('dateend')) if request.query_params.get('dateend', None) else queryset
|
||||||
|
tmp = queryset.values('company__geo__pname').annotate(total=Count('company__geo__pname'))
|
||||||
for i in tmp:
|
for i in tmp:
|
||||||
if i['company__geo__pname'] in nameMap:
|
if i['company__geo__pname'] in nameMap:
|
||||||
ret['s'].append({'name':nameMap[i['company__geo__pname']], 'value':i['total']})
|
ret['s'].append({'name':nameMap[i['company__geo__pname']], 'value':i['total']})
|
||||||
return Response(ret)
|
return Response(ret)
|
||||||
|
|
||||||
class Quota(APIView):
|
class Quota(APIView):
|
||||||
'''
|
'''
|
||||||
获取考试名额
|
获取考试名额
|
||||||
|
|
Loading…
Reference in New Issue