| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533 |
- mui.init({
- swipeBack: false,
- })
-
- mui.ready(function() {
- var selectType = 0
-
- // 投诉类型饼图
- const complaintPie = echarts.init(document.getElementById('complaintPie'));
- let pieOption = {
- animation: false,
- tooltip: {
- trigger: 'none'
- },
- legend: {
- show: false
- },
- series: [{
- type: 'pie',
- radius: ['30%', '60%'],
- center: ['50%', '50%'],
- data: [{
- value: 0,
- name: '破袋发霉',
- itemStyle: {
- color: '#5470c6'
- }
- },
- {
- value: 0,
- name: '杂质异物',
- itemStyle: {
- color: '#91cc75'
- }
- },
- {
- value: 0,
- name: '变质异味',
- itemStyle: {
- color: '#fac858'
- }
- }
- ],
- label: {
- show: false
- }
- }]
- };
- complaintPie.setOption(pieOption);
- let currentHighlightIndex = -1;
-
- function highlightPieSection(index, name) {
- if(currentHighlightIndex === index) {
- // 取消高亮
- pieOption.series[0].data.forEach(item => {
- item.emphasis = null;
- });
- pieOption.series[0].label.show = false;
- currentHighlightIndex = -1;
- } else {
- // 设置高亮
- pieOption.series[0].data.forEach((item, i) => {
- item.emphasis = {
- scale: i === index,
- scaleSize: 10
- };
- });
- pieOption.series[0].label = {
- show: true,
- position: 'center',
- formatter: name,
- fontSize: 16,
- color: '#333'
- };
- currentHighlightIndex = index;
- }
- complaintPie.setOption(pieOption);
- }
- // 接单率图表
- const acceptanceRate = echarts.init(document.getElementById('acceptanceRate'));
- acceptanceRate.setOption({
- animation: false,
- series: [{
- type: 'gauge',
- startAngle: 90,
- endAngle: -270,
- pointer: {
- show: false
- },
- progress: {
- show: true,
- overlap: false,
- roundCap: true,
- clip: false,
- itemStyle: {
- color: '#4F46E5'
- }
- },
- axisLine: {
- lineStyle: {
- width: 12
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false
- },
- detail: {
- valueAnimation: true,
- offsetCenter: [0, 0],
- fontSize: 12,
- formatter: '{value}%',
- color: '#333'
- },
- data: [{
- value: 0
- }]
- }]
- });
- // 完结率图表
- const completionRate = echarts.init(document.getElementById('completionRate'));
- completionRate.setOption({
- animation: false,
- series: [{
- type: 'gauge',
- startAngle: 90,
- endAngle: -270,
- pointer: {
- show: false
- },
- progress: {
- show: true,
- overlap: false,
- roundCap: true,
- clip: false,
- itemStyle: {
- color: '#4F46E5'
- }
- },
- axisLine: {
- lineStyle: {
- width: 12
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false
- },
- detail: {
- valueAnimation: true,
- offsetCenter: [0, 0],
- fontSize: 12,
- formatter: '{value}%',
- color: '#333'
- },
- data: [{
- value: 0
- }]
- }]
- });
- // 趋势线图
- const trendLine = echarts.init(document.getElementById('trendLine'));
-
- window.addEventListener('resize', function() {
- complaintPie.resize();
- acceptanceRate.resize();
- completionRate.resize();
- trendLine.resize();
- });
-
- var token = localStorage.getItem("token");
-
- function initData() {
- // 顶部统计
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + 'Business/GetComplaint',
- async: false,
- data: {
- type: selectType,
- token: token
- },
- dataType: 'json',
- success: function(data) {
-
- res = data.data;
-
- if(res.total) $('#total').text(res.total.toLocaleString());
- if(res.thiscontrast) $('#thiscontrast').text(res.thiscontrast);
- if(res.thisnumber) $('#thisnumber').text(res.thisnumber.toLocaleString());
- if(res.othercontrast) $('#othercontrast').text(res.othercontrast);
- if(res.otherthisnumber) $('#otherthisnumber').text(res.otherthisnumber.toLocaleString());
-
- // 调整箭头
- if(res.thiscontrast >= 0) {
- $('#thiscontrast_i').attr('class', 'fas fa-arrow-up mr-1')
- $('#thiscontrast_div').attr('class', 'text-green-500 text-sm mt-1')
- } else {
- $('#thiscontrast_i').attr('class', 'fas fa-arrow-down mr-1')
- $('#thiscontrast_div').attr('class', 'text-red-500 text-sm mt-1')
- }
-
- // 调整箭头
- if(res.othercontrast >= 0) {
- $('#othercontrast_i').attr('class', 'fas fa-arrow-up mr-1')
- $('#othercontrast_div').attr('class', 'text-green-500 text-sm mt-1')
- } else {
- $('#othercontrast_i').attr('class', 'fas fa-arrow-down mr-1')
- $('#othercontrast_div').attr('class', 'text-red-500 text-sm mt-1')
- }
-
- // 计算比例
- let rate = 0;
- if(res.thisnumber > 0 || res.otherthisnumber > 0) {
- rate = (res.thisnumber / (res.thisnumber + res.otherthisnumber)).toFixed(2);
- }
-
-
-
- $('#total_rate').attr('style', 'width: ' + rate * 100 + '%;')
- }
- });
-
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + 'Business/GetComplaintSituation',
- async: false,
- data: {
- type: selectType,
- token: token
- },
- dataType: 'json',
- success: function(data) {
-
- res = data.data;
- if(res.gobad) $('#gobad').text(res.gobad.toLocaleString());
- if(res.impurity) $('#impurity').text(res.impurity.toLocaleString());
- if(res.mustiness) $('#mustiness').text(res.mustiness.toLocaleString());
-
- if(res.gobadRate) $('#gobadRate').text(res.gobadRate);
- if(res.impurityRate) $('#impurityRate').text(res.impurityRate);
- if(res.mustinessRate) $('#mustinessRate').text(res.mustinessRate);
-
- if(res.gobadcontrast >= 0) {
- $('#gobadcontrast').text(res.gobadcontrast);
- $('#gobadcontrast_i').attr('class', 'fas fa-arrow-up mr-1')
- $('#gobadcontrast_span').attr('class', 'text-green-500')
- } else {
- if(res.gobadcontrast < 0) $('#gobadcontrast').text(res.gobadcontrast);
- $('#gobadcontrast_i').attr('class', 'fas fa-arrow-down mr-1')
- $('#othercontrast_div').attr('class', 'text-red-500')
- }
-
- if(res.impuritycontrast >= 0) {
- $('#impuritycontrast').text(res.impuritycontrast);
- $('#impuritycontrast_i').attr('class', 'fas fa-arrow-up mr-1')
- $('#impuritycontrast_span').attr('class', 'text-green-500')
- } else {
- if(res.impuritycontrast < 0) $('#impuritycontrast').text(res.impuritycontrast);
- $('#impuritycontrast_i').attr('class', 'fas fa-arrow-down mr-1')
- $('#impuritycontrast_div').attr('class', 'text-red-500')
- }
-
- if(res.mustinesscontrast >= 0) {
- $('#mustinesscontrast').text(res.mustinesscontrast);
- $('#mustinesscontrast_i').attr('class', 'fas fa-arrow-up mr-1')
- $('#mustinesscontrast_span').attr('class', 'text-green-500')
- } else {
- if(res.mustinesscontrast < 0) $('#mustinesscontrast').text(res.mustinesscontrast);
- $('#mustinesscontrast_i').attr('class', 'fas fa-arrow-down mr-1')
- $('#mustinesscontrast_div').attr('class', 'text-red-500')
- }
-
- // 重新加载饼图
-
- let pieOption = {
- animation: false,
- tooltip: {
- trigger: 'none'
- },
- legend: {
- show: false
- },
- series: [{
- type: 'pie',
- radius: ['30%', '60%'],
- center: ['50%', '50%'],
- data: [{
- value: res.mustiness,
- name: '破袋发霉',
- itemStyle: {
- color: '#5470c6'
- }
- },
- {
- value: res.impurity,
- name: '杂质异物',
- itemStyle: {
- color: '#91cc75'
- }
- },
- {
- value: res.gobad,
- name: '变质异味',
- itemStyle: {
- color: '#fac858'
- }
- }
- ],
- label: {
- show: false
- }
- }]
- };
- complaintPie.setOption(pieOption);
-
- }
- });
-
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + 'Business/GetComplaintCompleted',
- async: false,
- data: {
- type: selectType,
- token: token
- },
- dataType: 'json',
- success: function(data) {
-
- res = data.data;
-
- acceptanceRate.setOption({
- animation: false,
- series: [{
- type: 'gauge',
- startAngle: 90,
- endAngle: -270,
- pointer: {
- show: false
- },
- progress: {
- show: true,
- overlap: false,
- roundCap: true,
- clip: false,
- itemStyle: {
- color: '#4F46E5'
- }
- },
- axisLine: {
- lineStyle: {
- width: 12
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false
- },
- detail: {
- valueAnimation: true,
- offsetCenter: [0, 0],
- fontSize: 12,
- formatter: '{value}%',
- color: '#333'
- },
- data: [{
- value: +res.receivingrate.replace('%', '')
- }]
- }]
- });
-
- completionRate.setOption({
- animation: false,
- series: [{
- type: 'gauge',
- startAngle: 90,
- endAngle: -270,
- pointer: {
- show: false
- },
- progress: {
- show: true,
- overlap: false,
- roundCap: true,
- clip: false,
- itemStyle: {
- color: '#4F46E5'
- }
- },
- axisLine: {
- lineStyle: {
- width: 12
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- show: false
- },
- detail: {
- valueAnimation: true,
- offsetCenter: [0, 0],
- fontSize: 12,
- formatter: '{value}%',
- color: '#333'
- },
- data: [{
- value: +res.completerate.replace('%', '')
- }]
- }]
- });
- }
- });
-
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + 'Business/GetComplaintTrend',
- async: false,
- data: {
- type: selectType,
- token: token
- },
- dataType: 'json',
- success: function(data) {
-
- res = data.data;
- var times = [];
- var receivings = [];
- var completes = [];
- if(res && res.length > -1) {
- res.forEach(function(v, i) {
- times.push(v.time);
- receivings.push(v.receiving);
- completes.push(v.complete);
- });
- }
-
- trendLine.setOption({
- animation: false,
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- lineStyle: {
- width: 1,
- color: '#019680',
- },
- },
-
- },
- dataZoom: [{
- type: 'inside',
- startValue: times.length - 7 - 1,
- endValue: times.length - 1,
- // start: 0,
- // end: (5 / xData.length) * 100,
- zoomLock: true,
- }, ],
- legend: {
- data: ['接单量', '完结量']
- },
- xAxis: {
- type: 'category',
- data: times,
- axisLabel: {
- interval: 0,
- rotate: 45
- }
- },
- yAxis: {
- type: 'value'
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '15%',
- containLabel: true
- },
- series: [{
- name: '接单量',
- type: 'line',
- smooth: true,
- data: receivings,
- }, {
- name: '完结量',
- type: 'line',
- smooth: true,
- data: completes
- }]
- });
- }
- });
- }
-
- var types = ['周', '月', '年'];
-
- $('#changeBut').on('click', function() {
- console.log('changeType');
- selectType++;
- if(selectType > types.length - 1) selectType = 0;
- const typeName = types[selectType];
-
- $('[name="selectType"]').text(typeName)
-
- initData();
- })
-
- initData();
-
- })
-
- //function changeType() {
- //
- //}
|