Commit d72a8084 authored by lvshibao's avatar lvshibao

seat页面修改

parent 5f847f30
......@@ -186,17 +186,18 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
username = req.data.get('username', '')
task_id = req.data.get('task', '')
city_id = req.GET.get('city', None)
country_id = req.GET.get('country', None)
agent_name = req.data.get('agentName', '')
sort = req.data.get('sort', 'des')
page = req.data.get('page', '1')
page_size = req.data.get('page_size', '10')
task_condition = req.data.get('date_condition', {})
if task_id:
task_condition['task'] = task_id
if username in name_list:
task_condition['task'] = username
team_names = get_team_names(city_id, country_id)
task_condition['task__in'] = team_names
if agent_name:
task_condition['agentName'] = agent_name
if sort == 'des':
......@@ -217,22 +218,30 @@ class TasksApi(viewsets.ViewSet):
except EmptyPage:
seats = paginator.page(paginator.num_pages)
return_data = []
agent_name_set = set()
for s in seats:
detail = {'agentName': s['agentName'], 'validate_session': s['validate_session'],
'remainTime': s['remainTime'], 'total_session': s['total_session'],
'ratio': round(s['validate_session'] / s['total_session'], 2)}
agent_name_set.add(s['agentName'])
return_data.append(detail)
seat_code_name_lists = Seat.objects.filter(code__in=agent_name_set).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']
if sort == 'asc':
data_sort = sorted(return_data, key=lambda x: x['ratio'])
for i in range(len(data_sort)):
data_sort[i]['ranking'] = total_count - (int(page) - 1) * int(page_size) - i
data_sort[i]['ratio'] = '{0}%'.format(int(data_sort[i]['ratio'] * 100))
data_sort[i]['seatName'] = seat_code_name_dict.get(data_sort[i]['agentName'], data_sort[i]['agentName'])
else:
data_sort = sorted(return_data, key=lambda x: x['ratio'], reverse=True)
for i in range(len(data_sort)):
data_sort[i]['ranking'] = (int(page) - 1) * int(page_size) + i + 1
data_sort[i]['ratio'] = '{0}%'.format(int(data_sort[i]['ratio'] * 100))
return Response({'code': 0, 'msg': 'success', 'count': total_count, 'data': data_sort, 'username': username})
data_sort[i]['seatName'] = seat_code_name_dict.get(data_sort[i]['agentName'], data_sort[i]['agentName'])
return Response({'code': 0, 'msg': 'success', 'count': total_count, 'data': data_sort})
@action(['post'], detail=False)
@before_request
......@@ -427,13 +436,6 @@ class TasksApi(viewsets.ViewSet):
avg_score=Round(Avg('score'), 2), total_session=Sum('total_session'),
validate_num=Sum('validate_num'), validate_zero=Sum('validate_zero')) \
.order_by(sort)
agent_names = [x['agentName'] for x in rules]
seats_code_name_list = Seat.objects.filter(code__in=agent_names).values('code', 'name')
seats_code_name = dict()
for seat_code_name in seats_code_name_list:
seats_code_name[seat_code_name['code']] = seat_code_name['name']
for rule_dict in rules:
rule_dict['seatName'] = seats_code_name.get(rule_dict['agentName'], rule_dict['agentName'])
paginator = Paginator(rules, page_size)
total_count = paginator.count
try:
......@@ -443,6 +445,14 @@ class TasksApi(viewsets.ViewSet):
except EmptyPage:
seats = paginator.page(paginator.num_pages)
agent_names = [x['agentName'] for x in seats]
seats_code_name_list = Seat.objects.filter(code__in=agent_names).values('code', 'name')
seats_code_name = dict()
for seat_code_name in seats_code_name_list:
seats_code_name[seat_code_name['code']] = seat_code_name['name']
for rule_dict in seats:
rule_dict['seatName'] = seats_code_name.get(rule_dict['agentName'], rule_dict['agentName'])
return Response({'code': 0, 'msg': 'success', 'count': total_count, 'data': seats.object_list})
@action(['post'], detail=False)
......
......@@ -117,7 +117,6 @@
<script src="{% static "inspect/js/vue.min.js" %}"></script>
<script src="{% static "inspect/js/element.js" %}"></script>
<script src="{% static "inspect/js/echarts.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/config.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/http.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/seat.js" %}"></script>
......
......@@ -304,7 +304,6 @@
<script src="{% static "inspect/js/vue.min.js" %}"></script>
<script src="{% static "inspect/js/element.js" %}"></script>
<script src="{% static "inspect/js/http.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/config.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/seat_check.js" %}"></script>
</body>
</html>
......@@ -4,12 +4,14 @@ new Vue({
return {
ss: 'sas',
dateRange: [new Date(), new Date()],
taskList: [],
taskvalue: '',
cityList: [],
countryList: [],
cityvalue: '',
countryvalue: '',
start_date: '',
end_date: '',
takeList: [],
takevalue: '',
seatList: [],
seatvalue: '',
loading: true,
tableData: [],
sortObj: {
......@@ -50,48 +52,39 @@ new Vue({
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue); // 获取统计数据
console.log(msg);
},
getTask() {
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: '安徽省营业部'},
];
//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()
// }
//})
},
getCity(){
let that = this;
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;
that.cityvalue = data.data.city_id;
console.log(that.cityvalue);
that.init_simple = true;
}
} else {
that.$message('服务器错误');
}
},
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/?city=' + that.cityvalue + 'country=' + this.countryvalue + '&start_date=' + this.start_date + '&end_date=' + this.end_date).then(data => {
//console.log(data);
if (data.code != 0) {
//that.takeList = [{agentName:'全部坐席'}]
} else {
that.takeList = data.data;
that.seatList = data.data;
}
})
},
......@@ -111,13 +104,13 @@ new Vue({
}
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue); // 获取统计数据
},
getRule(task, start_date, end_date, agentName) {
getRule(city, country, start_date, end_date, agentName) {
let that = this;
let page = this.currentPage;
let arr = [];
this.$loading({text: '数据加载中...'});
let sort = this.sortObj.sort;
RquestsPost('api/v1/tasks/seat_rule/', {task, start_date, end_date, agentName, page, sort}).then(data => {
RquestsPost('api/v1/tasks/seat_rule/', {city, country, start_date, end_date, agentName, page, sort}).then(data => {
console.log(data.data);
if (data.code != 0) {
that.$message(data.msg);
......@@ -127,12 +120,6 @@ new Vue({
that.$message('服务器错误')
}
}
if (name_list.indexOf(data.username) !== -1) {
that.sel_is_show = false;
that.taskvalue = data.username;
} else {
that.sel_is_show = true;
}
this.tableData = data.data;
this.total = data.count;
this.isHidePage = !(data.data.length > 0);
......@@ -161,11 +148,11 @@ 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.getTake(); // 获取坐席
this.getCity(); // 获取任务
this.getTake(); // 获取坐席
console.log(this.dateRange);
this.getRule(this.taskvalue, this.start_date, this.end_date, this.takevalue); // 获取统计数据
this.getRule(this.cityvalue, this.countryvalue, 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