123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
- <template>
- <div class="app-container">
- <div class="app-content">
- <div class="title">
- 通话统计
- </div>
- <el-form class="search-form" :inline="true" >
- <el-form-item >
- <el-select style="width: 220px" v-model="value" placeholder="请选择日期">
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="公司名" prop="companyId">
- <el-select filterable style="width: 220px" v-model="companyId" @change="companyChange" placeholder="请选择公司名" clearable size="small">
- <el-option
- v-for="item in companys"
- :key="item.companyId"
- :label="item.companyName"
- :value="item.companyId"
- />
- </el-select>
- </el-form-item>
- <el-form-item >
- <treeselect style="width: 220px" :clearable="false" v-model="deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
- </el-form-item>
- <el-form-item>
- <el-select filterable v-model="userIds" placeholder="请选择员工" clearable size="small">
- <el-option
- v-for="item in users"
- :key="item.userId"
- :label="item.nickName"
- :value="item.userId">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="cyan" icon="el-icon-search" @click="getVoiceLogs">搜索</el-button>
- </el-form-item>
- </el-form>
- <div class="data-box">
- <div class="echart-box">
- <div id="echart-customer"></div>
- </div>
- <div class="table-box">
- <el-button class="export" size="small" @click="handleExport" v-hasPermi="['statistics:customer:index']">导出</el-button>
- <el-table
- :data="list"
- border
- :summary-method="getSummaries"
- show-summary
- max-height="500"
- style="width: 100%;">
- <el-table-column
- prop="nickName"
- label="员工姓名">
- </el-table-column>
- <el-table-column
- prop="callCount"
- label="拨打数">
- </el-table-column>
- <el-table-column
- prop="callSuccessCount"
- label="接通数">
- </el-table-column>
- <el-table-column
- prop="callRate"
- label="接通率(%)">
- </el-table-column>
- <el-table-column
- prop="times"
- label="通话时长(秒)">
- </el-table-column>
- <el-table-column
- prop="billingTime"
- label="消耗分钟(分)">
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { voiceLogs,exportVoiceLogs } from "@/api/company/statistics";
- import { getUserListByDeptId} from "@/api/company/companyUser";
- import echarts from 'echarts'
- import resize from '../../dashboard/mixins/resize'
- import { treeselect } from "@/api/company/companyDept";
- import Treeselect from "@riophae/vue-treeselect";
- import "@riophae/vue-treeselect/dist/vue-treeselect.css";
- import { getCompanyList } from "@/api/company/company";
- export default {
- name: 'Index',
- mixins: [resize],
- components: { Treeselect },
- watch: {
- // 监听deptId
- 'deptId': 'currDeptChange'
- },
- data() {
- return {
- companys:[],
- deptOptions:[],
- companyId:undefined,
- deptId:undefined,
- userIds:undefined,
- users:[],
- chart: null,
- options: [{
- value: '1',
- label: '今天'
- }, {
- value: '2',
- label: '昨天'
- }, {
- value: '3',
- label: '本周'
- }, {
- value: '4',
- label: '上周'
- }, {
- value: '5',
- label: '本月'
- }
- , {
- value: '6',
- label: '上月'
- }
- , {
- value: '7',
- label: '本季度'
- }
- , {
- value: '8',
- label: '上季度'
- }
- , {
- value: '9',
- label: '本年'
- }
- , {
- value: '10',
- label: '上年'
- }],
- value: '5',
- list:[],
- dates:[],
- billingTime:[],
- callCount:[],
- callSuccessCount:[],
- times:[]
- }
- },
- created() {
- getCompanyList().then(response => {
- this.companys = response.data;
- if(this.companys!=null&&this.companys.length>0){
- this.companyId=this.companys[0].companyId;
- this.getTreeselect();
- }
- });
- },
- methods: {
- companyChange(val){
- console.log(val);
- this.companyId=val;
- this.getTreeselect();
- },
- currDeptChange(val){
- console.log(val)
- this.deptId=val;
- this.getUserListByDeptId();
- },
- /** 查询部门下拉树结构 */
- getTreeselect() {
- var that=this;
- var param={companyId:this.companyId}
- treeselect(param).then((response) => {
- this.deptOptions = response.data;
- console.log(this.deptOptions)
- if(response.data!=null&&response.data.length>0){
- this.deptId=response.data[0].id;
- that.getVoiceLogs()
- }
- });
- },
- handleExport(){
- var data;
- if(this.userIds!=undefined){
- data={type:this.value,userIds:this.userIds+"",deptId:this.deptId}
- }
- else{
- data={type:this.value,deptId:this.deptId}
- }
- exportVoiceLogs(data).then((response) => {
- console.log(response)
- this.download(response.msg);
- });
- },
- getUserListByDeptId() {
- this.userIds=undefined;
- var data={deptId:this.deptId};
- getUserListByDeptId(data).then(response => {
- this.users = response.data;
- });
- },
- getVoiceLogs(){
- var data;
- if(this.userIds!=undefined){
- data={type:this.value,userIds:this.userIds+"",deptId:this.deptId}
- }
- else{
- data={type:this.value,deptId:this.deptId}
- }
- voiceLogs(data).then((response) => {
- this.list=response.list;
- this.dates=response.dates;
- this.callCount=response.callCount;
- this.callSuccessCount=response.callSuccessCount;
- this.billingTime=response.billingTime;
- this.times=response.times;
- setTimeout(() => {
- this.initEchart();
- }, 500);
- });
- },
- initEchart(){
- var option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: { // 坐标轴指示器,坐标轴触发有效
- type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
- }
- },
- legend: {
- data: ['通话时长', '消耗分钟','拨打数','接通数']
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: [
- {
- type: 'category',
- data: this.dates
- }
- ],
- yAxis: [
- {
- type: 'value',
- axisLabel:{
- formatter:'{value}个'
- }
- }
- ],
- series: [
- {
- name: '通话时长',
- type: 'bar',
- emphasis: {
- focus: 'series'
- },
- data: this.times
- },
- {
- name: '消耗分钟',
- type: 'bar',
- emphasis: {
- focus: 'series'
- },
- data: this.billingTime
- },
- {
- name: '拨打数',
- type: 'bar',
- emphasis: {
- focus: 'series'
- },
- data: this.callCount
- },
- {
- name: '接通数',
- type: 'bar',
- emphasis: {
- focus: 'series'
- },
- data: this.callSuccessCount
- }
- ]
- };
- this.chart=echarts.init(document.getElementById("echart-customer"));
- this.chart.setOption(option,true);
- },
- getSummaries(param) {
- const { columns, data } = param;
- const sums = [];
- columns.forEach((column, index) => {
- if (index === 0) {
- sums[index] = '总计';
- return;
- }
- const values = data.map(item => Number(item[column.property]));
- if (!values.every(value => isNaN(value))) {
- sums[index] = values.reduce((prev, curr) => {
- const value = Number(curr);
- if (!isNaN(value)) {
- return prev + curr;
- } else {
- return prev;
- }
- }, 0);
- sums[index] += ' ';
- } else {
- sums[index] = '';
- }
- });
- return sums;
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .app-container{
- border: 1px solid #e6e6e6;
- padding: 12px;
- .app-content{
- background-color: white;
- .title{
- padding: 20px 30px 0px 30px;
- font-size: 18px;
- font-weight: bold;
- color: black;
- }
- .search-form{
- margin: 20px 30px 0px 30px;
- }
- .data-box{
- padding: 30px;
- background-color: rgb(255, 255, 255);
- height: 100%;
- .echart-box{
- margin: 0 auto;
- text-align: center;
- }
- .el-select{
- margin: 5px 10px;
- }
- .table-box{
- margin-top: 15px;
- .export{
- float: right;
- margin: 10px 0px;
- }
- }
- }
- }
- }
- #echart-customer{
- width:100%;
- height:320px
- }
- .vue-treeselect{
- width: 217px;
- height: 36px;
- }
- </style>
- <style>
- .vue-treeselect__control{
- display: block;
- }
- </style>
|