Commit 0bc12a6d authored by lvshibao's avatar lvshibao

check页面修改

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