voiceLogs.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div class="app-container">
  3. <div class="app-content">
  4. <div class="title">
  5. 通话统计
  6. </div>
  7. <el-form class="search-form" :inline="true" >
  8. <el-form-item >
  9. <el-select style="width: 220px" v-model="value" placeholder="请选择日期">
  10. <el-option
  11. v-for="item in options"
  12. :key="item.value"
  13. :label="item.label"
  14. :value="item.value">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="公司名" prop="companyId">
  19. <el-select filterable style="width: 220px" v-model="companyId" @change="companyChange" placeholder="请选择公司名" clearable size="small">
  20. <el-option
  21. v-for="item in companys"
  22. :key="item.companyId"
  23. :label="item.companyName"
  24. :value="item.companyId"
  25. />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item >
  29. <treeselect style="width: 220px" :clearable="false" v-model="deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-select filterable v-model="userIds" placeholder="请选择员工" clearable size="small">
  33. <el-option
  34. v-for="item in users"
  35. :key="item.userId"
  36. :label="item.nickName"
  37. :value="item.userId">
  38. </el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="cyan" icon="el-icon-search" @click="getVoiceLogs">搜索</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <div class="data-box">
  46. <div class="echart-box">
  47. <div id="echart-customer"></div>
  48. </div>
  49. <div class="table-box">
  50. <el-button class="export" size="small" @click="handleExport" v-hasPermi="['statistics:customer:index']">导出</el-button>
  51. <el-table
  52. :data="list"
  53. border
  54. :summary-method="getSummaries"
  55. show-summary
  56. max-height="500"
  57. style="width: 100%;">
  58. <el-table-column
  59. prop="nickName"
  60. label="员工姓名">
  61. </el-table-column>
  62. <el-table-column
  63. prop="callCount"
  64. label="拨打数">
  65. </el-table-column>
  66. <el-table-column
  67. prop="callSuccessCount"
  68. label="接通数">
  69. </el-table-column>
  70. <el-table-column
  71. prop="callRate"
  72. label="接通率(%)">
  73. </el-table-column>
  74. <el-table-column
  75. prop="times"
  76. label="通话时长(秒)">
  77. </el-table-column>
  78. <el-table-column
  79. prop="billingTime"
  80. label="消耗分钟(分)">
  81. </el-table-column>
  82. </el-table>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import { voiceLogs,exportVoiceLogs } from "@/api/company/statistics";
  90. import { getUserListByDeptId} from "@/api/company/companyUser";
  91. import echarts from 'echarts'
  92. import resize from '../../dashboard/mixins/resize'
  93. import { treeselect } from "@/api/company/companyDept";
  94. import Treeselect from "@riophae/vue-treeselect";
  95. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  96. import { getCompanyList } from "@/api/company/company";
  97. export default {
  98. name: 'Index',
  99. mixins: [resize],
  100. components: { Treeselect },
  101. watch: {
  102. // 监听deptId
  103. 'deptId': 'currDeptChange'
  104. },
  105. data() {
  106. return {
  107. companys:[],
  108. deptOptions:[],
  109. companyId:undefined,
  110. deptId:undefined,
  111. userIds:undefined,
  112. users:[],
  113. chart: null,
  114. options: [{
  115. value: '1',
  116. label: '今天'
  117. }, {
  118. value: '2',
  119. label: '昨天'
  120. }, {
  121. value: '3',
  122. label: '本周'
  123. }, {
  124. value: '4',
  125. label: '上周'
  126. }, {
  127. value: '5',
  128. label: '本月'
  129. }
  130. , {
  131. value: '6',
  132. label: '上月'
  133. }
  134. , {
  135. value: '7',
  136. label: '本季度'
  137. }
  138. , {
  139. value: '8',
  140. label: '上季度'
  141. }
  142. , {
  143. value: '9',
  144. label: '本年'
  145. }
  146. , {
  147. value: '10',
  148. label: '上年'
  149. }],
  150. value: '5',
  151. list:[],
  152. dates:[],
  153. billingTime:[],
  154. callCount:[],
  155. callSuccessCount:[],
  156. times:[]
  157. }
  158. },
  159. created() {
  160. getCompanyList().then(response => {
  161. this.companys = response.data;
  162. if(this.companys!=null&&this.companys.length>0){
  163. this.companyId=this.companys[0].companyId;
  164. this.getTreeselect();
  165. }
  166. });
  167. },
  168. methods: {
  169. companyChange(val){
  170. console.log(val);
  171. this.companyId=val;
  172. this.getTreeselect();
  173. },
  174. currDeptChange(val){
  175. console.log(val)
  176. this.deptId=val;
  177. this.getUserListByDeptId();
  178. },
  179. /** 查询部门下拉树结构 */
  180. getTreeselect() {
  181. var that=this;
  182. var param={companyId:this.companyId}
  183. treeselect(param).then((response) => {
  184. this.deptOptions = response.data;
  185. console.log(this.deptOptions)
  186. if(response.data!=null&&response.data.length>0){
  187. this.deptId=response.data[0].id;
  188. that.getVoiceLogs()
  189. }
  190. });
  191. },
  192. handleExport(){
  193. var data;
  194. if(this.userIds!=undefined){
  195. data={type:this.value,userIds:this.userIds+"",deptId:this.deptId}
  196. }
  197. else{
  198. data={type:this.value,deptId:this.deptId}
  199. }
  200. exportVoiceLogs(data).then((response) => {
  201. console.log(response)
  202. this.download(response.msg);
  203. });
  204. },
  205. getUserListByDeptId() {
  206. this.userIds=undefined;
  207. var data={deptId:this.deptId};
  208. getUserListByDeptId(data).then(response => {
  209. this.users = response.data;
  210. });
  211. },
  212. getVoiceLogs(){
  213. var data;
  214. if(this.userIds!=undefined){
  215. data={type:this.value,userIds:this.userIds+"",deptId:this.deptId}
  216. }
  217. else{
  218. data={type:this.value,deptId:this.deptId}
  219. }
  220. voiceLogs(data).then((response) => {
  221. this.list=response.list;
  222. this.dates=response.dates;
  223. this.callCount=response.callCount;
  224. this.callSuccessCount=response.callSuccessCount;
  225. this.billingTime=response.billingTime;
  226. this.times=response.times;
  227. setTimeout(() => {
  228. this.initEchart();
  229. }, 500);
  230. });
  231. },
  232. initEchart(){
  233. var option = {
  234. tooltip: {
  235. trigger: 'axis',
  236. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  237. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  238. }
  239. },
  240. legend: {
  241. data: ['通话时长', '消耗分钟','拨打数','接通数']
  242. },
  243. grid: {
  244. left: '3%',
  245. right: '4%',
  246. bottom: '3%',
  247. containLabel: true
  248. },
  249. xAxis: [
  250. {
  251. type: 'category',
  252. data: this.dates
  253. }
  254. ],
  255. yAxis: [
  256. {
  257. type: 'value',
  258. axisLabel:{
  259. formatter:'{value}个'
  260. }
  261. }
  262. ],
  263. series: [
  264. {
  265. name: '通话时长',
  266. type: 'bar',
  267. emphasis: {
  268. focus: 'series'
  269. },
  270. data: this.times
  271. },
  272. {
  273. name: '消耗分钟',
  274. type: 'bar',
  275. emphasis: {
  276. focus: 'series'
  277. },
  278. data: this.billingTime
  279. },
  280. {
  281. name: '拨打数',
  282. type: 'bar',
  283. emphasis: {
  284. focus: 'series'
  285. },
  286. data: this.callCount
  287. },
  288. {
  289. name: '接通数',
  290. type: 'bar',
  291. emphasis: {
  292. focus: 'series'
  293. },
  294. data: this.callSuccessCount
  295. }
  296. ]
  297. };
  298. this.chart=echarts.init(document.getElementById("echart-customer"));
  299. this.chart.setOption(option,true);
  300. },
  301. getSummaries(param) {
  302. const { columns, data } = param;
  303. const sums = [];
  304. columns.forEach((column, index) => {
  305. if (index === 0) {
  306. sums[index] = '总计';
  307. return;
  308. }
  309. const values = data.map(item => Number(item[column.property]));
  310. if (!values.every(value => isNaN(value))) {
  311. sums[index] = values.reduce((prev, curr) => {
  312. const value = Number(curr);
  313. if (!isNaN(value)) {
  314. return prev + curr;
  315. } else {
  316. return prev;
  317. }
  318. }, 0);
  319. sums[index] += ' ';
  320. } else {
  321. sums[index] = '';
  322. }
  323. });
  324. return sums;
  325. }
  326. }
  327. }
  328. </script>
  329. <style lang="scss" scoped>
  330. .app-container{
  331. border: 1px solid #e6e6e6;
  332. padding: 12px;
  333. .app-content{
  334. background-color: white;
  335. .title{
  336. padding: 20px 30px 0px 30px;
  337. font-size: 18px;
  338. font-weight: bold;
  339. color: black;
  340. }
  341. .search-form{
  342. margin: 20px 30px 0px 30px;
  343. }
  344. .data-box{
  345. padding: 30px;
  346. background-color: rgb(255, 255, 255);
  347. height: 100%;
  348. .echart-box{
  349. margin: 0 auto;
  350. text-align: center;
  351. }
  352. .el-select{
  353. margin: 5px 10px;
  354. }
  355. .table-box{
  356. margin-top: 15px;
  357. .export{
  358. float: right;
  359. margin: 10px 0px;
  360. }
  361. }
  362. }
  363. }
  364. }
  365. #echart-customer{
  366. width:100%;
  367. height:320px
  368. }
  369. .vue-treeselect{
  370. width: 217px;
  371. height: 36px;
  372. }
  373. </style>
  374. <style>
  375. .vue-treeselect__control{
  376. display: block;
  377. }
  378. </style>