telephonist.vue 7.3 KB

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