telephonist.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="statistics-call-telephonist-container layout-pd">
  3. <!-- 搜索 -->
  4. <el-card shadow="never">
  5. <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline>
  6. <el-form-item label="时间段" prop="crTime">
  7. <el-date-picker
  8. v-model="state.queryParams.crTime"
  9. type="daterange"
  10. unlink-panels
  11. range-separator="至"
  12. start-placeholder="开始时间"
  13. end-placeholder="结束时间"
  14. :shortcuts="shortcuts"
  15. @change="queryList"
  16. value-format="YYYY-MM-DD"
  17. />
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button type="primary" @click="queryList" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  21. <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
  22. <SvgIcon name="ele-Refresh" class="mr5" />重置
  23. </el-button>
  24. </el-form-item>
  25. </el-form>
  26. </el-card>
  27. <el-card shadow="never">
  28. <ProTable
  29. ref="proTableRef"
  30. :columns="columns"
  31. :data="state.tableData"
  32. @updateTable="queryList"
  33. :loading="state.loading"
  34. :pagination="false"
  35. show-summary
  36. border
  37. row-key="orgId"
  38. @sort-change="sortChange"
  39. :summary-method="getSummaries"
  40. >
  41. <template #name="{ row }">
  42. <span
  43. >{{ row.name }} <span v-if="row.staffNo">({{ row.staffNo }})</span></span
  44. >
  45. </template>
  46. </ProTable>
  47. </el-card>
  48. </div>
  49. </template>
  50. <script setup lang="tsx" name="statisticsCallTelephonist">
  51. import { onMounted, reactive, ref } from 'vue';
  52. import { ElButton, FormInstance } from 'element-plus';
  53. import { throttle } from '@/utils/tools';
  54. import { callAgent } from '@/api/statistics/call';
  55. import { shortcuts } from '@/utils/constants';
  56. import dayjs from 'dayjs';
  57. import { formatDuration, formatDurationDay } from '@/utils/formatTime';
  58. const proTableRef = ref<RefType>(); // 表格ref
  59. // 表格配置项
  60. const columns = ref<any[]>([
  61. { type: 'index', fixed: 'left', width: 55, label: '序号', align: 'center' },
  62. {
  63. prop: 'name',
  64. label: '坐席工号',
  65. align: 'center',
  66. minWidth: 120,
  67. render: (scope) => (
  68. <span>
  69. {scope.row.name} {scope.row.staffNo ? <span>({scope.row.telNo})</span> : ''}{' '}
  70. </span>
  71. ),
  72. },
  73. { prop: 'inTotal', label: '呼入总量', align: 'center', sortable: 'custom', minWidth: 120 },
  74. { prop: 'inAnswered', label: '接通总量', align: 'center', sortable: 'custom', minWidth: 120 },
  75. { prop: 'inHangupImmediate', label: '呼入秒挂', align: 'center', sortable: 'custom', minWidth: 120 },
  76. { prop: 'inHanguped', label: '呼入超时未接', align: 'center', sortable: 'custom', minWidth: 140 },
  77. {
  78. prop: 'inAnsweredRate',
  79. label: '接通率',
  80. align: 'center',
  81. sortable: 'custom',
  82. render: (scope) => <span>{scope.row.inAnsweredRate}%</span>,
  83. minWidth: 120,
  84. },
  85. { prop: 'outDurationAvg', label: '呼入平均时长', align: 'center', sortable: 'custom', minWidth: 140 },
  86. { prop: 'inAvailableAnswer', label: '有效接通量', align: 'center', sortable: 'custom', minWidth: 120 },
  87. { prop: 'inHangupImmediateWhenAnswered', label: '接通秒挂', align: 'center', sortable: 'custom', minWidth: 120 },
  88. {
  89. prop: 'inAnsweredRate',
  90. label: '有效接通率',
  91. align: 'center',
  92. sortable: 'custom',
  93. render: (scope) => <span>{scope.row.inAnsweredRate}%</span>,
  94. minWidth: 120,
  95. },
  96. { prop: 'outTotal', label: '呼出总量', align: 'center', sortable: 'custom', minWidth: 120 },
  97. { prop: 'outAnswered', label: '呼出接通量', align: 'center', sortable: 'custom', minWidth: 120 },
  98. {
  99. prop: 'outAnsweredRate',
  100. label: '呼出接通率',
  101. align: 'center',
  102. render: (scope) => <span>{scope.row.outAnsweredRate}%</span>,
  103. minWidth: 120,
  104. },
  105. {
  106. prop: 'outDurationAvg',
  107. label: '呼出平均时长',
  108. align: 'center',
  109. minWidth: 140,
  110. },
  111. {
  112. prop: 'loginDuration',
  113. label: '登录时长',
  114. align: 'center',
  115. minWidth: 200,
  116. render: (scope) => <span>{formatDurationDay(scope.row.loginDuration)}</span>,
  117. },
  118. {
  119. prop: 'restDuration',
  120. label: '小休时长',
  121. align: 'center',
  122. minWidth: 200,
  123. render: (scope) => <span>{formatDurationDay(scope.row.restDuration)}</span>,
  124. },
  125. { prop: 'workRate', label: '工作效率', align: 'center', minWidth: 120, render: (scope) => <span>{scope.row.workRate}%</span> },
  126. ]);
  127. // 定义变量内容
  128. const ruleFormRef = ref<RefType>(); // 表单ref
  129. const state = reactive({
  130. queryParams: {
  131. // 查询条件
  132. PageIndex: 1,
  133. PageSize: 10,
  134. Keyword: null, // 关键词
  135. crTime: [dayjs().startOf('day').format('YYYY-MM-DD'), dayjs().endOf('day').format('YYYY-MM-DD')], // 时间默认今天开始到今天结束
  136. },
  137. tableData: [], //表单
  138. loading: false, // 加载
  139. total: 0, // 总数
  140. });
  141. /** 获取列表 */
  142. const queryList = throttle(() => {
  143. state.loading = true;
  144. let StartTime = null;
  145. let EndTime = null;
  146. if (state.queryParams?.crTime) {
  147. StartTime = state.queryParams?.crTime[0];
  148. EndTime = state.queryParams?.crTime[1];
  149. }
  150. const request = {
  151. StartTime,
  152. EndTime,
  153. SortField: state.queryParams.SortField,
  154. SortRule: state.queryParams.SortRule,
  155. };
  156. callAgent(request)
  157. .then((res: any) => {
  158. state.tableData = res.result;
  159. state.loading = false;
  160. })
  161. .catch(() => {
  162. state.loading = false;
  163. });
  164. }, 300);
  165. // 排序
  166. const sortChange = (val: any) => {
  167. state.queryParams.SortField = val.prop;
  168. // 0 升序 1 降序
  169. state.queryParams.SortRule = val.order ? (val.order == 'descending' ? 1 : 0) : null;
  170. queryList();
  171. };
  172. /** 重置按钮操作 */
  173. const resetQuery = throttle((formEl: FormInstance | undefined) => {
  174. if (!formEl) return;
  175. formEl.resetFields();
  176. queryList();
  177. }, 300);
  178. // 合计
  179. const getSummaries = (param: any) => {
  180. const { columns, data } = param;
  181. const sums: string[] = [];
  182. columns.forEach((column: { property: string }, index: number) => {
  183. if (index === 0) {
  184. sums[index] = '合计';
  185. return;
  186. }
  187. const values = data.map((item: { [x: string]: any }) => Number(item[column.property]));
  188. if (
  189. ['inAnsweredRate', 'outAnsweredRate', 'inAvailableAnswer', 'outDurationAvg', 'loginDuration', 'restDuration', 'workRate'].includes(
  190. column.property
  191. )
  192. ) {
  193. //百分比不能计算
  194. sums[index] = '';
  195. return '';
  196. } else if (!values.every((value: unknown) => Number.isNaN(value))) {
  197. sums[index] = `${values.reduce((prev: any, curr: any) => {
  198. const value = Number(curr);
  199. if (!Number.isNaN(value)) {
  200. return prev + curr;
  201. } else {
  202. return prev;
  203. }
  204. }, 0)}`;
  205. } else {
  206. sums[index] = ' ';
  207. }
  208. });
  209. return sums;
  210. /*const { columns } = param;
  211. const sums: string[] = [];
  212. columns.forEach((column: { property: string }, index: number) => {
  213. switch (column.property) {
  214. case 'name':
  215. sums[index] = state.totalCount?.name;
  216. break;
  217. case 'num':
  218. sums[index] = state.totalCount?.num;
  219. break;
  220. case 'chainNum':
  221. sums[index] = state.totalCount?.chainNum;
  222. break;
  223. case 'chainRate':
  224. sums[index] = state.totalCount?.chainRate;
  225. break;
  226. default:
  227. sums[index] = '';
  228. break;
  229. }
  230. });
  231. return sums;*/
  232. };
  233. onMounted(() => {
  234. queryList();
  235. });
  236. </script>