| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <script src="Script/Common/huayi.load.js"></script>
- <script src="Script/Common/huayi.config.js"></script>
- <title>通话时长</title>
- <link rel="stylesheet" href="./js/layui/css/layui.css" />
- <link rel="stylesheet" href="js/select2/css/select2.min.css" />
- <link rel="stylesheet" href="./css/init.css" />
- <link rel="stylesheet" href="css/Table/table1.css" />
- <style>
- .th-top {
- background: #f3f3f4;
- height: 60px;
- padding: 10px 20px;
- }
-
- .topCon {
- float: right;
- margin-right: 20px;
- }
-
- .th-content h2 {
- font-size: 22px;
- }
-
- .th-content {
- width: 90%;
- margin: 0 auto;
- margin-top: 20px;
- }
-
- .th-table {
- display: none;
- }
- </style>
- </head>
- <body class="gray-bg" style="background: #fefefe;">
- <div class="thTime">
- <div class="daoHang clearfix">
- <div class="dhLeft">
- <sapn><i class="syIcon"></i>位置:
- <a id="ReIndex" href="javaScript:;">首页</a>>
- <a href="javaScript:;">报表分析</a>>
- <a href="javaScript:;">话务运营分析</a>>
- <a href="" class="nowPosition">通话时长统计</a>
- </sapn>
- </div>
- <div class="dhRight">
- <a href="#" title="刷新"><i class="fa fa-refresh"></i></a>
- </div>
- </div>
- <div class="th-top clearfix">
- <div class="topCon">
- <div class="form-inline th-bar clearfix">
- <div class="time-box form-group">
- <i class="tub fa fa-calendar"></i>
- <input class="form-control" type="text" id="startTime" placeholder="请选择起止时间" style="width: 245px;">
- </div>
- <!--<div class="time-box form-group">
- 部门:
- <select id="bumen">
- <option value="">请选择</option>
- </select>
- </div>-->
- <div class="form-group tool_bars pull-right">
- <button class="btns sear">搜索</button>
- <a class="btns export">导出</a>
- </div>
- </div>
- </div>
- </div>
- <ul class="nav nav-tabs th-tab">
- <li role="presentation" class="active">
- <a href="javascript:;">图形</a>
- </li>
- <li role="presentation">
- <a href="javascript:;">表格</a>
- </li>
- </ul>
- <div class="th-content">
- <div class="th-tu" style="width: 100%;">
- <h2 style="text-align: center;">服务热线坐席通话时长统计</h2>
- <div id="tabtu" style="width: 100%; height: 500px;"></div>
- </div>
- <div class="th-table">
- <h2 style="text-align: center;">热线坐席通话时长统计</h2>
- <table class="layui-hide" id="t_callTotal"></table>
- </div>
- </div>
- </div>
- <script src="./js/layui/layui.js"></script>
- <script src="./js/select2/js/select2.min.js"></script>
- <script src="./js/echarts.common.min.js"></script>
- <script>
- var token = $.cookie("token");
- var myChartp;
- var endtime = ''; //结束时间
- var stime = ''; //开始时间
- var tabIndex = 0;
- $(document).ready(function() {
- layui.use('laydate', function() {
- var laydate = layui.laydate;
- //日期
- laydate.render({
- elem: '#startTime',
- range: '~',
- //value: stime + ' ~ ' + endtime,
- theme: '#1ab394',
- calendar: 'true'
- });
- });
-
- //helper.getDropList.getDept($('#bumen'));//获取部门
- //tab切换
- $('.th-tab li').click(function() {
- $(this).addClass('active')
- .siblings().removeClass('active');
- tabIndex = $(this).index();
- $('.th-content >div').eq(tabIndex).show()
- .siblings().hide();
- loadDatas();
- });
- //搜索事件
- $(".sear").click(function() {
- stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
- endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
- loadDatas();
- });
- //按enter搜索
- document.onkeydown = function (e) { // 回车提交表单
- var theEvent = window.event || e;
- var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
- if (code == 13) {
- stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
- endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
- loadDatas();
- }
- }
- //导出功能
- $('.export').click(function() {
- stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
- endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
- dcexcel(this);
- });
- myChartp = echarts.init(document.getElementById('tabtu'));
- myChartp.clear();
- myChartp.showLoading();
- var option = {
- tooltip: {
- trigger: 'axis',
- },
- legend: {
- data: [],
- bottom: 40,
- padding: 5,
- },
- grid: {
- bottom: 180
- },
- dataZoom: [{ // 这个dataZoom组件,默认控制x轴。
- type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
- xAxisIndex: 0,
- start: 0, // 左边在 0% 的位置。
- end: 100, // 右边在 100% 的位置。
- bottom: 100,
- },
- ],
- xAxis: [{
- type: 'category',
- data: [],
- axisPointer: {
- type: ''
- },
- axisLabel: {
- interval: 0,
- rotate: 40
- }
- }],
- yAxis: [{
- type: 'value',
- name: '通话次数(次)',
- nameLocation: 'end',
- axisLabel: {
- formatter: '{value} '
- }
- },
- {
- type: 'value',
- name: '通话时长(s)',
- nameLocation: 'end',
- axisLabel: {
- formatter: '{value} '
- }
- }
- ],
- series: [{
- type: 'bar',
- name: '呼入次数',
- data: []
- }, {
- type: 'line',
- name: '呼入时长',
- yAxisIndex: 1,
- data: []
- },
- {
- type: 'bar',
- name: '呼出次数',
- data: []
- }, {
- type: 'line',
- name: '呼出时长',
- yAxisIndex: 1,
- data: []
- }, {
- type: 'bar',
- name: '呼出未接通次数',
- data: []
- }, {
- type: 'line',
- name: '振铃时长',
- yAxisIndex: 1,
- data: []
- },
- {
- type: 'line',
- name: '通话总时长',
- yAxisIndex: 1,
- data: []
- },
- {
- type: 'line',
- name: '平均通话时长',
- yAxisIndex: 1,
- data: []
- }
- ],
- //color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f', '#cddc39', '#ff5722', '#e91e63', '#673ab7', '#61a0a8', '#bda29a']
- color: ['#74dbc6', '#d9c228', '#a1ef9f', '#66d1e8', '#8565e3', '#f8a6ad', '#e45764', '#bbb1f3', '#32a1e8', '#32da62']
- };
- // 使用刚指定的配置项和数据显示图表。
- myChartp.setOption(option);
- loadDatas();
- });
- //加载表格
- function getTableDataList() {
- var loadindex = layer.load();
- layui.use('table', function() {
- var table = layui.table;
- //方法级渲染
- table.render({
- elem: '#t_callTotal',
- url: huayi.config.callcenter_url + "TalkTime/GetDataList",
- method: 'get', //如果无需自定义HTTP类型,可不加该参数
- skin: 'row', //line (行边框风格) row (列边框风格) nob (无边框风格)
- even: true, //开启隔行背景
- size: 'lg', //sm,lg尺寸的表格
- where: {
- stime: stime,
- endtime: endtime,
- //dpt: $('#bumen').val(),
- token: token
- }, //如果无需传递额外参数,可不加该参数
- //request: {}, //如果无需自定义请求参数,可不加该参数
- response: {
- statusName: 'state', //数据状态的字段名称,默认:code
- statusCode: 'success', //成功的状态码,默认:0
- msgName: 'message', //状态信息的字段名称,默认:msg
- //countName: 'total', //数据总数的字段名称,默认:count
- //dataName: 'rows', //数据列表的字段名称,默认:data
- }, //如果无需自定义数据响应名称,可不加该参数
- cols: [
- [{
- field: '坐席名称',
- title: '坐席名称',
- align: 'center',
- fixed: true,
- width: 150,
- }, {
- field: '呼入次数',
- title: '呼入次数',
- align: 'center',
- sort: true,
- width: '',
- },
- {
- field: '呼入时长',
- title: '呼入时长',
- align: 'center',
- width: '',
- },
- {
- field: '呼出次数',
- title: '呼出次数',
- align: 'center',
- width: '',
- },
- {
- field: '呼出时长',
- title: '呼出时长',
- align: 'center',
- width: '',
- },
- {
- field: '呼出未接通次数',
- title: '呼出未接通次数',
- align: 'center',
- width: '',
- },
- {
- field: '振铃时长',
- title: '振铃时长',
- align: 'center',
- width: '',
- },
- {
- field: '通话总时长',
- title: '通话总时长',
- align: 'center',
- templet: '<div><span class="color_73926">{{d.通话总时长}}</span></div>',
- width: '',
- },
- {
- field: '平均通话总时长',
- title: '平均通话总时长',
- align: 'center',
- fixed: 'right',
- // sort: true, //这里有排序bug
- width: 150,
- },
- ]
- ],
- height: 'full-230',
- done:function(){
- layer.close(loadindex);
- }
- });
- });
- }
- //获取图形数据
- function getDataLists() {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "TalkTime/GetDataList",
- async: true,
- dataType: 'json',
- data: {
- stime: stime,
- endtime: endtime,
- dpt: $('#bumen').val(),
- token: token,
- },
- success: function(data) {
- }
- })
- .then(function(data) {
- $('.thTable tbody').html('');
- myChartp.hideLoading();
- if(data.state.toLowerCase() == "success") {
- var tbodyCon = data.data;
- // 填入数据
- if(tbodyCon) {
- myChartp.setOption({
- xAxis: {
- data: (function() {
- var res = [];
- for(var i = 0; i < tbodyCon.length; i++) {
- res.push(tbodyCon[i].坐席名称);
- }
- return res;
- })(),
- },
- series: (function() {
- var formatterArr = function(tarr, prames) {
- var newArr = [];
- $.each(tarr, function(i, v) {
- $.each(v, function(j, k) {
- if(j == prames) {
- newArr.push(k);
- }
- });
- });
- return {
- name: prames,
- data: newArr
- };
- }
- return [formatterArr(tbodyCon, "呼入次数"), formatterArr(tbodyCon, "呼入时长"),
- formatterArr(tbodyCon, "呼出次数"), formatterArr(tbodyCon, "呼出时长"), formatterArr(tbodyCon, "呼出未接通次数"),
- formatterArr(tbodyCon, "振铃时长"), formatterArr(tbodyCon, "通话总时长"),
- formatterArr(tbodyCon, "平均通话总时长")
- ]
- })(),
- });
- } else {
- $('#tabtu').html('<p class="text-center">暂无数据</p>');
- }
- } else {
- $('#tabtu').html('<p class="text-center">暂无数据</p>');
- }
- });
- }
- //获取图形legend
- function getColumnList() {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "TalkTime/GetColumnList",
- async: false,
- dataType: 'json',
- data: {
- token: token
- },
- success: function(data) {
- if(data.state.toLowerCase() == "success") {
- var con = data.data;
- if(con) {
- myChartp.setOption({
- legend: {
- data: con,
- },
- });
- }
- }
- }
- });
- }
- //导出
- function dcexcel(obj) {
- var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + token;
- url += "&stime=" + stime + "&endtime=" + endtime;//+ "&dpt=" + $('#bumen').val();
- obj.href = url;
- }
- function loadDatas() {
- if(tabIndex == 0) {
- getDataLists(); //加载图形
- getColumnList(); //获取图形legend
- } else if(tabIndex == 1) {
- getTableDataList(); //加载表格
- }
- }
- </script>
- </body>
- </html>
|