Commit 1a1b1120 authored by lvshibao's avatar lvshibao

rule页面修改

parent a2b72d45
......@@ -3,18 +3,21 @@ from django.db.models import Q
from inspect_report.models import Team, Country
def get_team_names(city_id, country_id):
# # 获取坐席团队关系
team_names = list()
if city_id and country_id:
team_names = Team.objects.filter(country_id=country_id).values_list('name')
elif city_id and (country_id is None or country_id == ''):
city = Country.objects.filter(id=city_id).first()
if city.parent is None:
team_names = Team.objects.filter().values_list('name')
else:
country_id_list = Country.objects.filter(Q(parent=city_id) | Q(id=city_id)).values_list('id')
team_names = Team.objects.filter(country_id__in=country_id_list).values_list('name')
def get_team_names(city_id, country_id, team_id=None):
if team_id is not None and team_id != '':
team_names = Team.objects.filter(id=team_id).values_list('name')
else:
# # 获取坐席团队关系
team_names = list()
if city_id and country_id:
team_names = Team.objects.filter(country_id=country_id).values_list('name')
elif city_id and (country_id is None or country_id == ''):
city = Country.objects.filter(id=city_id).first()
if city.parent is None:
team_names = Team.objects.filter().values_list('name')
else:
country_id_list = Country.objects.filter(Q(parent=city_id) | Q(id=city_id)).values_list('id')
team_names = Team.objects.filter(country_id__in=country_id_list).values_list('name')
return team_names
......
......@@ -77,3 +77,25 @@ class AgencyApi(viewsets.ViewSet):
return Response({'code': 0, 'msg': 'success', 'data': {'country_list': country_list}})
else:
return Response({'code': -1, 'msg': '未找到对应的县市'})
@action(['get'], detail=False)
def team(self, req: Request):
"""
查询任务列表
:param req:
:return:
"""
city_id = req.GET.get('city_id', '')
country_id = req.GET.get('country_id', '')
team_list = list()
top = Country.objects.filter(id=city_id).first()
if top is not None:
if top.parent is None:
pass
elif country_id is None or country_id == '':
team_list = Team.objects.filter(country_id=city_id).values('id', 'name')
else:
team_list = Team.objects.filter(country_id=country_id).values('id', 'name')
return Response({'code': 0, 'msg': 'success', 'data': {'team_list': team_list}})
else:
return Response({'code': -1, 'msg': '未找到对应的县市'})
......@@ -76,9 +76,10 @@ class DataApi(viewsets.ViewSet):
"""
city_id = req.GET.get('city', None)
country_id = req.GET.get('country', None)
team_id = req.GET.get('country', None)
task_condition = req.data.get('date_condition', {})
team_names = get_team_names(city_id, country_id)
team_names = get_team_names(city_id, country_id, team_id)
task_condition['task__in'] = team_names
......
......@@ -466,8 +466,9 @@ class TasksApi(viewsets.ViewSet):
city_id = req.data.get('city', None)
country_id = req.data.get('country', None)
team_id = req.data.get('team', None)
team_names = get_team_names(city_id, country_id)
team_names = get_team_names(city_id, country_id, team_id)
task_condition = req.data.get('date_condition', {})
......@@ -509,6 +510,7 @@ class TasksApi(viewsets.ViewSet):
"""
city_id = req.data.get('city', None)
country_id = req.data.get('country', None)
team_id = req.data.get('team', None)
tables = req.data.get('tables', '')
rule_name = req.data.get('rule', '')
page = req.data.get('page', '1')
......@@ -520,7 +522,7 @@ class TasksApi(viewsets.ViewSet):
session_condition = req.data.get('date_condition', {})
session_condition['rule'] = rule_name
session_condition['sessionCollectionId__in'] = table_list
session_condition['task__in'] = get_team_names(city_id, country_id)
session_condition['task__in'] = get_team_names(city_id, country_id, team_id)
checks = RulesStat.objects.filter(**session_condition).values('agentName', 'customName', 'remainTime', 'score',
'sessionCollectionId', 'sessionId', 'taskId')
paginator = Paginator(checks, page_size)
......
......@@ -107,12 +107,25 @@
: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-button type='primary' size='mini' style='height:30px;' @click='loadData()'>
导出数据
</el-button>
<form ref="loadModal" :action="`${BASEURL}api/v1/data/static_rule_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="start_date" :value="start_date">
<input type="hidden" name="end_date" :value="end_date">
</form>
......
......@@ -6,9 +6,12 @@ new Vue({
dateTime: '',
cityList:[],
countryList:[],
teamList:[],
cityvalue: null,
countryvalue: null,
teamvalue: null,
country_show: false,
team_show: true,
start_date: '',
isscrollTop: false,
currentPage:1,
......@@ -58,14 +61,40 @@ new Vue({
console.log(msg);
this.cityvalue = msg;
this.countryvalue = null;
this.getCountry(this.cityvalue);
this.getRule(this.cityvalue,this.countryvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
this.teamvalue = null;
this.getCountry();
this.getTeam();
this.getRule(this.cityvalue,this.countryvalue,this.teamvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
},
changeCountry(msg){
console.log(msg);
this.countryvalue = msg;
this.getRule(this.cityvalue,this.countryvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
this.teamvalue = null;
this.getTeam();
this.getRule(this.cityvalue,this.countryvalue,this.teamvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
},
changeTeam(msg){
console.log(msg);
this.teamvalue = msg;
this.getRule(this.cityvalue,this.countryvalue,this.teamvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
},
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;
};
}
})
},
getCountry() {
let that = this;
RquestsGet('api/v1/agency/country/?city_id=' + this.cityvalue).then(data => {
......@@ -111,15 +140,6 @@ new Vue({
} else {
that.$message('服务器错误');
}
//RquestsGet('api/v1/tasks/obtain/').then(data => {
// //console.log(data);
// if(data.code != 0){
// that.taskList = [{id:'',name:'全部任务'}];
// }else{
// that.taskList = [{id:'',name:'全部任务'}].concat(data.data);
// that.getTake()
// }
//})
},
CurrentChange(page){
this.currentPage = page;
......@@ -128,13 +148,13 @@ new Vue({
this.poppage = page;
this.getDetail(this.cityvalue,this.countryvalue,this.start_date,this.end_date,this.poptables,this.poprule, this.poppage, this.poppagesize);
},
getRule(city,country,start_date,end_date,agentName){
getRule(city,country,team,start_date,end_date,agentName){
let that = this;
console.log(start_date,end_date);
let arr = [];
this.$loading({text:'数据加载中...'});
RquestsPost('api/v1/tasks/static_rule/',{city,country,end_date,start_date,agentName}).then(data => {
RquestsPost('api/v1/tasks/static_rule/',{city,country,team,end_date,start_date,agentName}).then(data => {
console.log(data.data);
if(data.code != 0){
that.$message(data.msg);
......@@ -189,15 +209,15 @@ new Vue({
this.popcurrentPage = 1;
this.poppage = 1;
//this.taskvalue = tableData.area;
this.getDetail(this.cityvalue,this.countryvalue,this.start_date,this.end_date,this.poptables,this.poprule, this.poppage, this.poppagesize);
this.getDetail(this.cityvalue,this.countryvalue,this.teamvalue,this.start_date,this.end_date,this.poptables,this.poprule, this.poppage, this.poppagesize);
},
getDetail(city,country,start_date,end_date, tables, rule, page, page_size){
getDetail(city,country,team,start_date,end_date, tables, rule, page, page_size){
//this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
let that = this;
this.$loading({text:'数据加载中...'});
this.poploading = true;
RquestsPost('api/v1/tasks/rule_detail/',{city,country,end_date,start_date,tables,rule,page,page_size}).then(data => {
RquestsPost('api/v1/tasks/rule_detail/',{city,country,team,end_date,start_date,tables,rule,page,page_size}).then(data => {
console.log(data.data);
this.$loading().close();
this.dialogTableVisible = true;
......@@ -251,9 +271,10 @@ new Vue({
this.start_date = this.dateFormat(new Date(new Date()-24*60*60*1000));
this.end_date = this.dateFormat(new Date());
this.getCity(); // 获取任务
this.getTeam();
//this.getTake(); // 获取坐席
this.getRule(this.cityvalue,this.countryvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
this.getRule(this.cityvalue,this.countryvalue,this.teamvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
}
},
......
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