Commit 8c2b0b3c authored by zhengjinlei's avatar zhengjinlei

客户画像页面

parent d3b2bac2
...@@ -28,7 +28,7 @@ class ProfileApi(viewsets.ViewSet): ...@@ -28,7 +28,7 @@ class ProfileApi(viewsets.ViewSet):
logger.info('[profile_labels]获取的username是: %s', username) logger.info('[profile_labels]获取的username是: %s', username)
region = username region = username
condition = {} condition = {}
if region: if region and region != '安徽picc':
condition['region'] = region condition['region'] = region
profiles = CustomProfile.objects.filter(**condition).values('phone_number', 'region', 'call_recent', profiles = CustomProfile.objects.filter(**condition).values('phone_number', 'region', 'call_recent',
'call_count', 'custom_labels') 'call_count', 'custom_labels')
......
...@@ -445,3 +445,8 @@ def check(request): ...@@ -445,3 +445,8 @@ def check(request):
@xframe_options_exempt @xframe_options_exempt
def city_score(request): def city_score(request):
return render(request, 'inspect/city_score.html') return render(request, 'inspect/city_score.html')
@xframe_options_exempt
def profile(request):
return render(request, 'inspect/profile.html')
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset='utf-8' />
<title>客户画像</title>
<!-- 引入样式 -->
<link rel="stylesheet" href="{% static "inspect/css/element.css" %}">
<!-- 引入组件库 -->
<link rel='stylesheet' type='text/css' href="{% static "inspect/css/all.css" %}">
</head>
<body style='height:100%'>
<div class='child-title'>客户画像</div>
<div class='child-main' id='childApp'>
<div style='text-align:right;' class='childTitle'>
<div class='childTitleName'>客户标签统计</div>
<el-select v-model="cityvalue" filterable placeholder="请选择市" @change="changeCity">
<el-option
v-for="item in cityList"
:key="item.id"
:label="item.name"
:value="item.name">
</el-option>
</el-select>
</div>
<div id='main' style='margin-top:20px'>
<el-table
:data="tableData"
border
height="600"
:default-sort="{prop: 'ranking', order: 'descending'}"
style="width: 100%">
<el-table-column
prop="region"
label="所属地市"
width="180"
>
</el-table-column>
<el-table-column
prop="phone_number"
label="客户手机号"
width="180"
>
</el-table-column>
<el-table-column
prop="call_recent"
label="最近通话日期"
width="200"
>
</el-table-column>
<el-table-column
prop="call_count"
label="通话次数"
width="100"
>
</el-table-column>
<el-table-column
prop="custom_labels"
label="客户标签">
</el-table-column>
</el-table>
<el-pagination
@current-change='CurrentChange'
style='margin: 0 auto;text-align:center;margin-bottom:20px;'
layout="prev, pager, next"
:hide-on-single-page="isHidePage"
background
:page-size="pagesize"
:total="total">
</el-pagination>
</div>
</div>
<script type="text/javascript">
window.onload = function(){
};
</script>
<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/http.js" %}"></script>
<script type="text/javascript" src="{% static "inspect/js/profile.js" %}"></script>
</body>
</html>
...@@ -15,7 +15,7 @@ Including another URLconf ...@@ -15,7 +15,7 @@ Including another URLconf
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path
from .api.tasksapi import rule, seat, group, score, check, city_score from .api.tasksapi import rule, seat, group, score, check, city_score, profile
from .views import stat_rules_every, stat_seats_every, stat_scores_every, stat_time_every, stat_data_every from .views import stat_rules_every, stat_seats_every, stat_scores_every, stat_time_every, stat_data_every
urlpatterns = [ urlpatterns = [
...@@ -26,6 +26,7 @@ urlpatterns = [ ...@@ -26,6 +26,7 @@ urlpatterns = [
path('inspect/score/', score), path('inspect/score/', score),
path('inspect/check/', check), path('inspect/check/', check),
path('inspect/city_score/', city_score), path('inspect/city_score/', city_score),
path('inspect/profile/', profile),
path('inspect/stat/rule/', stat_rules_every), path('inspect/stat/rule/', stat_rules_every),
path('inspect/stat/seat/', stat_seats_every), path('inspect/stat/seat/', stat_seats_every),
path('inspect/stat/score/', stat_scores_every), path('inspect/stat/score/', stat_scores_every),
......
...@@ -209,6 +209,8 @@ def save_custom_profile(task, check, name): ...@@ -209,6 +209,8 @@ def save_custom_profile(task, check, name):
if custom: if custom:
custom_name = custom[0] custom_name = custom[0]
custom_phone = custom[-1] custom_phone = custom[-1]
if custom_phone and len(custom_phone) > 11 and custom_phone.startswith('0'):
custom_phone = custom_phone[1:]
profile = CustomProfile.objects.filter(phone_number=custom_phone).first() profile = CustomProfile.objects.filter(phone_number=custom_phone).first()
team = '未找到团队' team = '未找到团队'
# team = team_seat().get(check['agentName'], '未找到团队') # team = team_seat().get(check['agentName'], '未找到团队')
......
new Vue({
el: '#childApp',
data:function(){
return {
ss:'sas',
dateTime: '',
cityList:[],
countryList:[],
teamList:[],
cityvalue: '',
countryvalue: '',
teamvalue: '',
country_show: false,
team_show: true,
start_date: '',
isscrollTop: false,
currentPage:1,
pagesize: 10,
total: 10,
poppage: 1,
poppagesize: 10,
poptotal: 10,
poprule: '',
poptables: '',
popcurrentPage: 1,
isHidePage: true,
scrollTop: 0,
end_date:'',
poploading: false,
BASEURL: window_url,
dialogTableVisible: false,
takeList:[],
dateRange:[new Date(), new Date()],
loading: true,
poptableData: [],
tableData: []
}
},
methods: {
changeCity(msg) {
console.log(msg);
this.currentPage = 1;
this.cityvalue = msg;
this.getProfile(); // 获取统计数据
},
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.cityvalue = '';
console.log(that.cityvalue);
that.init_simple = true;
}
} else {
that.$message('服务器错误');
}
},
getProfile() {
let that = this;
let page = this.currentPage;
this.$loading({text: '数据加载中...'});
RquestsGet('api/v1/profile/labels/?region=' + that.cityvalue).then(data => {
console.log(data.data);
if (data.code != 0) {
that.$message(data.msg);
if (data.msg) {
that.$message(data.msg);
} else {
that.$message('服务器错误')
}
}
this.tableData = data.data;
this.total = data.count;
this.isHidePage = !(data.data.length > 0);
if (!data.data) {
this.$loading().close();
return false;
}
//for(let key in data.data){
// arr.unshift([data.data[key],key])
//}
this.$loading().close();
})
},
CurrentChange(page) {
this.currentPage = page;
//this.tableData = this.basearr.concat(this.allData.slice((page-1)*this.pagesize,page*this.pagesize));
this.getProfile(); // 获取统计数据
//that.allData = data.data;
},
dateFormat(date) {
return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
},
init() {
this.getCity(); // 获取任务
this.getProfile(); // 获取统计数据
}
},
created() {
this.init()
},
})
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