Commit 363da0c6 authored by lvshibao's avatar lvshibao

seat页面修改

parent 787a5de8
......@@ -125,22 +125,22 @@ class DataApi(viewsets.ViewSet):
return response
@action(['get'], detail=False)
@before_request
def seat_rule_export(self, req: Request):
"""
坐席违规分析-按照得分-导出
:param req:
:return:
"""
task_id = req.GET.get('task', '')
agent_name = req.GET.get('agentName', '')
city_id = req.GET.get('city', None)
country_id = req.GET.get('country', None)
agent_name = req.GET.get('seat', '')
sort = req.GET.get('sort', 'des')
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'))
q_start_date = datetime.strptime(start_date, '%Y-%m-%d').date()
q_end_date = (datetime.strptime(end_date, '%Y-%m-%d') + + timedelta(days=1)).date()
task_condition = {'create_date__gte': q_start_date, 'create_date__lt': q_end_date}
if task_id:
task_condition['task'] = task_id
task_condition = req.data.get('date_condition', '')
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':
......@@ -153,19 +153,27 @@ class DataApi(viewsets.ViewSet):
.values('agentName').annotate(remainTime=Sum('remainTime'), validate_session=Sum('validate_session'),
total_session=Sum('total_session')).order_by('validate_session')
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)}
return_data.append(detail)
agent_name_set.add(s['agentName'])
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]['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]['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'])
response = HttpResponse(content_type='text/csv')
file_name = '坐席违规_' + datetime.now().strftime('%Y%m%d%H%M%S') + '.csv'
response['Content-Type'] = 'application/octet-stream'
......
......@@ -62,8 +62,9 @@
<form ref="loadModal" :action="`${BASEURL}api/v1/data/seat_rule_export/`" method="get">
<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">
<input type="hidden" name="city" :value="cityvalue">
<input type="hidden" name="country" :value="countryvalue">
<input type="hidden" name="seat" :value="seatvalue">
<input type="hidden" name="sort" :value="sortObj.sort">
</form>
</div>
......@@ -77,7 +78,12 @@
style="width: 100%">
<el-table-column
prop="agentName"
label="坐席"
label="坐席id"
width="180"
>
<el-table-column
prop="seatName"
label="坐席姓名"
width="180"
>
</el-table-column>
......
......@@ -76,6 +76,7 @@ new Vue({
changeRange(dateRange) {
this.start_date = dateRange[0];
this.end_date = dateRange[1];
this.seatvalue = null;
this.page = 1;
this.getTake();
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue, this.page, this.page_size); // 获取统计数据
......
......@@ -36,21 +36,32 @@ new Vue({
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.start_date, this.end_date, this.seatvalue); // 获取统计数据
},
changeTask(msg) {
changeCity(msg) {
console.log(msg);
this.currentPage = 1;
this.taskvalue = msg;
this.cityvalue = msg;
this.countryvalue = '';
this.seatvalue = null;
this.getCountry();
this.getTake();
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); // 获取统计数据
},
changeTake(msg) {
changeCountry(msg) {
this.countryvalue = msg;
this.seatvalue = null;
this.getTake();
this.currentPage = 1;
this.takevalue = msg;
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); // 获取统计数据
},
changeSeat(msg) {
this.currentPage = 1;
this.seatvalue = msg;
this.getRule(this.cityvalue, this.countryvalue, this.start_date, this.end_date, this.seatvalue); // 获取统计数据
console.log(msg);
},
getCity(){
......@@ -114,7 +125,7 @@ new Vue({
name: item.prop,
sort: order
}
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); // 获取统计数据
},
getRule(city, country, start_date, end_date, agentName) {
let that = this;
......@@ -150,7 +161,7 @@ new Vue({
CurrentChange(page) {
this.currentPage = page;
//this.tableData = this.basearr.concat(this.allData.slice((page-1)*this.pagesize,page*this.pagesize));
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); // 获取统计数据
//that.allData = data.data;
},
dateFormat(date) {
......
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