Commit 0bc12a6d authored by lvshibao's avatar lvshibao

check页面修改

parent 8e80658b
from django.db.models import Q
from inspect_report.models import Team, Country
from inspect_report.models import Team, Country, Seat
def get_team_names(city_id, country_id, team_id=None):
......@@ -21,9 +21,22 @@ def get_team_names(city_id, country_id, team_id=None):
return team_names
def get_country_names(city_id):
def get_agent_name(city_id, country_id, team_id, agent_name):
if agent_name is not None and agent_name != '':
return [agent_name]
elif team_id is not None and team_id != '':
return Seat.objects.filter(team_id=team_id).values_list('code')
elif country_id is not None and country_id != '':
team_ids = Team.objects.filter(country_id=country_id).values_list('id')
return Seat.objects.filter(team_id__in=team_ids).values_list('code')
elif city_id is not None and city_id != '':
city = Country.objects.filter(id=city_id).first()
if city.parent is None:
return None
return []
else:
return city.name
country_id_list = Country.objects.filter(Q(parent=city_id) | Q(id=city_id)).values_list('id')
return Team.objects.filter(country_id__in=country_id_list).values_list('code')
else:
return []
......@@ -5,8 +5,8 @@ from rest_framework.decorators import action
from rest_framework.request import Request
from before_request import before_request
from inspect_report.agency import get_team_names
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round, Seat
from inspect_report.agency import get_team_names, get_agent_name
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round, Seat, Country
import json
from datetime import datetime, timedelta
from config.config import TABLE_PRE, name_list
......@@ -251,13 +251,17 @@ class DataApi(viewsets.ViewSet):
:param req:
:return:
"""
task_id = req.GET.get('task', '')
city_id = req.GET.get('city', '')
country_id = req.GET.get('country', '')
team_id = req.GET.get('team', '')
agent_name = req.GET.get('agentName', '')
start_date = req.GET.get('start_date', (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d'))
end_date = req.GET.get('end_date', datetime.now().strftime('%Y-%m-%d'))
task_condition = {'hasCheck': 1, 'createdAt__gte': start_date, 'createdAt__lt': end_date + ' 23:59:59'}
if task_id:
task_condition['name__startswith'] = task_id
if city_id:
city = Country.objects.filter(id=city_id).first()
if city.parent is not None:
task_condition['name__startswith'] = city.name
tasks = Tasks.objects.filter(**task_condition).values('id', 'name', 'sessionCollectionId')
task_dict = {}
task_name_dict = {}
......@@ -267,13 +271,16 @@ class DataApi(viewsets.ViewSet):
task_dict[t['sessionCollectionId']].append(t['id'])
else:
task_dict[t['sessionCollectionId']] = [t['id'], ]
agent_names = get_agent_name(city_id, country_id, team_id, agent_name)
return_data = []
for k, v in task_dict.items():
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'taskId__in': v}
if agent_name:
session_condition['agentName'] = agent_name
if len(agent_names) > 0:
session_condition['agentName__in'] = agent_names
checks = tn.objects.filter(**session_condition).values('id', 'createdAt', 'agentName', 'extra', 'taskId',
'remainTime', 'startTime', 'closeTime',
'scoreItemRecord', 'sessionId')
......
......@@ -7,7 +7,7 @@ from rest_framework.request import Request
from rest_framework.response import Response
from before_request import before_request
from inspect_report.agency import get_team_names, get_country_names
from inspect_report.agency import get_team_names, get_agent_name
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round, Team, Country, Seat
import json
from datetime import datetime, timedelta
......@@ -330,17 +330,20 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
username = req.data.get('username', '')
task_id = req.data.get('task', '')
city_id = req.data.get('city', '')
country_id = req.data.get('country', '')
team_id = req.data.get('team', '')
agent_name = req.data.get('agentName', '')
page = req.data.get('page', '1')
page_size = req.data.get('page_size', '10')
task_condition = req.data.get('at_condition', {})
task_condition['hasCheck'] = 1
if task_id:
task_condition['name__startswith'] = task_id
if username in name_list:
task_condition['name__startswith'] = username
if city_id:
city = Country.objects.filter(id=city_id).first()
if city.parent is not None:
task_condition['name__startswith'] = city.name
tasks = Tasks.objects.filter(**task_condition).values('id', 'name', 'sessionCollectionId')
task_dict = {}
task_name_dict = {}
......@@ -352,13 +355,21 @@ class TasksApi(viewsets.ViewSet):
task_dict[t['sessionCollectionId']] = [t['id'], ]
return_data = []
total_count = 0
agent_names = get_agent_name(city_id, country_id, team_id, agent_name)
seat_code_name_lists = Seat.objects.filter(code__in=agent_names).values('code', 'name')
seat_code_name_dict = dict()
for seat_code_name in seat_code_name_lists:
seat_code_name_dict[seat_code_name['code']] = seat_code_name['name']
for k, v in task_dict.items():
# session_collection = t.sessionCollectionId
table_name = TABLE_PRE + k
tn = CheckSession.set_table(table_name)
session_condition = {'taskId__in': v}
if agent_name:
session_condition['agentName'] = agent_name
if len(agent_names) > 0:
session_condition['agentName__in'] = agent_names
checks = tn.objects.filter(**session_condition).values('id', 'createdAt', 'agentName', 'extra', 'taskId',
'remainTime', 'startTime', 'closeTime',
'scoreItemRecord', 'sessionId')
......@@ -383,7 +394,9 @@ class TasksApi(viewsets.ViewSet):
remain = int(close - start)
f_name = extra['filename'] if extra and 'filename' in extra.keys() else ''
detail = {'id': check['id'], 'sessionId': check['sessionId'], 'createdAt': check['createdAt'],
'area': t_name.split('_')[0], 'agentName': check['agentName'], 'filename': f_name,
'area': t_name.split('_')[0],
'seatName': seat_code_name_dict.get(check['agentName'], check['agentName']),
'agentName': check['agentName'], 'filename': f_name,
'remainTime': remain, 'sessionCollectionId': k, 'taskId': check['taskId']}
rule_detail = {'fwyy': 15, 'kcb': 5, 'jsy': 3, 'fwtd': 5, 'yssb': 5, 'jysb': 5, 'yycl': 10,
'ywcc': 10, 'yyjlz': 10, 'fwjs': 10, 'wtgbj': 2, 'cgjxxhs': 20, 'wgzlf': 100, 'mgc': 100}
......
......@@ -120,34 +120,60 @@
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']">
</el-date-picker>
<el-select v-if="sel_is_show == true" v-model="taskvalue" filterable placeholder="请选择" @change="changeTask">
<el-select v-model="cityvalue" filterable placeholder="请选择市" @change="changeCity">
<el-option
v-for="item in taskList"
v-for="item in cityList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-select v-model="takevalue" filterable placeholder="请选择" @change='changeTake'>
<el-select v-if="country_show == true" v-model="countryvalue" filterable placeholder="请选择县" @change="changeCountry">
<el-option
label="全部县"
value="">
</el-option>
<el-option
v-for="item in countryList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-select v-model="teamvalue" v-if="team_show == true" filterable placeholder="请选择团队" @change="changeTeam">
<el-option
label="全部团队"
value="">
</el-option>
<el-option
v-for="item in teamList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-select v-if="seat_show == true" v-model="seatvalue" filterable placeholder="请选择坐席" @change='changeSeat'>
<el-option
label="全部坐席"
value="">
</el-option>
<el-option
v-for="item in takeList"
:key="item.agentName"
:label="item.agentName"
:value="item.agentName">
v-for="item in seatList"
:key="item.code"
:label="item.name"
:value="item.code">
</el-option>
</el-select>
<el-button type='primary' size='mini' style='height:30px;' @click='loadData()'>
导出数据
</el-button>
<form ref="loadModal" :action="`${BASEURL}api/v1/data/seat_check_export/`" method="get">
<input type="hidden" name="city" :value="cityvalue">
<input type="hidden" name="country" :value="countryvalue">
<input type="hidden" name="team" :value="teamvalue">
<input type="hidden" name="seat" :value="seatvalue">
<input type="hidden" name="start_date" :value="start_date">
<input type="hidden" name="end_date" :value="end_date">
<input type="hidden" name="task" :value="taskvalue">
<input type="hidden" name="agentName" :value="takevalue">
</form>
</div>
......@@ -175,6 +201,11 @@
prop="area"
label="地市"
width="60"> </el-table-column>
<el-table-column
prop="seatName"
label="坐席名称"
width="180">
</el-table-column>
<el-table-column
prop="agentName"
label="坐席工号"
......
......@@ -4,10 +4,19 @@ new Vue({
return {
ss:'sas',
dateTime: '',
taskList:[],
cityList:[],
countryList:[],
teamList: [],
seatList: [],
isscrollTop: false,
country_show: false,
team_show: true,
seat_show: false,
cityvalue: '',
scrollTop: 0,
taskvalue: '',
countryvalue: '',
teamvalue: '',
seatvalue: '',
dateRange:[new Date(), new Date()],
start_date: '',
sortObj:{
......@@ -74,54 +83,102 @@ new Vue({
this.$refs.loadModal.submit();
this.$message('文件下载中请稍后...');
},
changeRange(dateRange){
changeRange(dateRange) {
console.log(dateRange);
this.start_date = dateRange[0];
this.end_date = dateRange[1];
this.seatvalue = null;
this.currentPage = 1;
this.getTake();
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.teamvalue, this.start_date, this.end_date, this.seatvalue); // 获取统计数据
},
changeTask(msg){
this.taskvalue = msg;
changeCity(msg) {
console.log(msg);
this.currentPage = 1;
this.cityvalue = msg;
this.countryvalue = '';
this.teamvalue = '';
this.seatvalue = null;
this.getCountry();
this.getTeam();
this.getTake();
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.teamvalue, this.start_date, this.end_date, this.seatvalue); // 获取统计数据
},
changeTake(msg){
this.takevalue = msg;
changeCountry(msg) {
this.countryvalue = msg;
this.teamvalue = '';
this.seatvalue = null;
this.getTeam();
this.getTake();
this.currentPage = 1;
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.teamvalue, this.start_date, this.end_date, this.seatvalue); // 获取统计数据
},
changeTeam(msg) {
this.currentPage = 1;
this.teamvalue = msg;
this.seatvalue = null;
this.getTake();
this.getRule(this.cityvalue, this.countryvalue, this.teamvalue, this.start_date, this.end_date, this.seatvalue); // 获取统计数据
console.log(msg);
},
changeSeat(msg) {
this.currentPage = 1;
this.seatvalue = msg;
this.getRule(this.cityvalue, this.countryvalue, this.teamvalue,this.start_date,this.end_date,this.seatvalue); // 获取统计数据
console.log(msg);
},
getTeam() {
let that = this;
RquestsGet('api/v1/agency/team/?country_id=' + this.countryvalue + '&city_id=' + this.cityvalue).then(data => {
//console.log(data);
if (data.code != 0) {
that.$message('服务器错误')
} else {
that.teamList = data.data.team_list;
if (that.teamList.length > 0) {
that.team_show = true;
} else {
that.team_show = false;
};
}
})
},
getTask(){
getCity(){
let that = this;
that.taskList = [
{id:'',name:'全省'},
{id:'合肥',name:'合肥'},
{id:'芜湖',name:'芜湖'},
{id:'蚌埠',name:'蚌埠'},
{id:'淮南',name:'淮南'},
{id:'马鞍山',name:'马鞍山'},
{id:'淮北',name:'淮北'},
{id:'铜陵',name:'铜陵'},
{id:'安庆',name:'安庆'},
{id:'黄山',name:'黄山'},
{id:'滁州',name:'滁州'},
{id:'阜阳',name:'阜阳'},
{id:'亳州',name:'亳州'},
{id:'宿州',name:'宿州'},
{id:'六安',name:'六安'},
{id:'宣城',name:'宣城'},
{id:'巢湖',name:'巢湖'},
{id:'池州',name:'池州'},
{id:'安徽省营业部',name:'安徽省营业部'},
];
},
getRule(task,start_date,end_date,agentName){
var request = new XMLHttpRequest();
let uri = window_url + 'api/v1/agency/city/';
request.open('GET', uri, false);
request.send(null);
if (request.status === 200) {
data = JSON.parse(request.response);
console.log(data.code);
if(data.code != 0){
that.$message('服务器错误');
} else {
that.cityList = data.data.city_list;
that.countryList = data.data.country_list;
if (that.countryList.length > 0) {
that.country_show = true;
} else {
that.country_show = false;
};
that.cityvalue = data.data.city_id;
console.log(that.cityvalue);
that.init_simple = true;
}
} else {
that.$message('服务器错误');
}
},
getRule(city, country, team, start_date,end_date,agentName){
let that = this;
let page = this.currentPage;
let page_size = this.pagesize;
this.$loading({text:'数据加载中...'});
RquestsPost('api/v1/tasks/seat_check/',{task,start_date,end_date,agentName,page,page_size}).then(data => {
RquestsPost('api/v1/tasks/seat_check/',{city, country, team,start_date,end_date,agentName,page,page_size}).then(data => {
that.$loading().close();
if(data.code != 0){
......@@ -136,24 +193,22 @@ new Vue({
}
})
},
getTake(){
getTake() {
let that = this;
RquestsGet('api/v1/tasks/seat/?task=' + that.taskvalue+'&start_date='+this.start_date+'&end_date='+this.end_date).then(data => {
//RquestsGet('api/v1/tasks/seat/?task=' + that.taskvalue).then(data => {
RquestsGet('api/v1/tasks/seat/?city=' + that.cityvalue + '&country=' + that.countryvalue + '&team=' + that.teamvalue + '&start_date=' + this.start_date + '&end_date=' + this.end_date).then(data => {
//console.log(data);
if(data.code != 0){
if (data.code != 0) {
//that.takeList = [{agentName:'全部坐席'}]
}else{
that.takeList = data.data;
}
if (name_list.indexOf(data.username) !== -1) {
that.sel_is_show = false;
that.taskvalue = data.username;
} else {
that.sel_is_show = true;
that.seatList = data.data;
if (that.seatList.length > 0) {
that.seat_show = true;
} else {
that.seat_show = false;
};
}
})
},
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
......@@ -213,9 +268,10 @@ new Vue({
this.dateRange = [new Date(new Date()-24*60*60*1000), new Date()];
this.start_date = this.dateFormat(new Date(new Date()-24*60*60*1000));
this.end_date = this.dateFormat(new Date());
this.getTask(); // 获取任务
this.getCity(); // 获取任务
this.getTeam();
this.getTake(); // 获取坐席
this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, this.teamvalue,this.start_date,this.end_date,this.seatvalue); // 获取统计数据
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment