index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="statistics-call-container layout-pd">
  3. <el-card shadow="never">
  4. <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline>
  5. <el-form-item prop="crTime">
  6. <statistical-time v-model="state.queryParams.crTime" @change="handleQuery" ref="statisticalTimeRef" :disabled="state.loading" />
  7. </el-form-item>
  8. <el-form-item label="热线号码" prop="Keyword">
  9. <el-select v-model="state.queryParams.Keyword" placeholder="请选择热线号码" clearable @change="handleQuery">
  10. <el-option v-for="item in state.callForwardingSource" :value="item.dicDataValue" :key="item.dicDataValue" :label="item.dicDataName" />
  11. </el-select>
  12. </el-form-item>
  13. <el-form-item label-width="0">
  14. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  15. <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
  16. <SvgIcon name="ele-Refresh" class="mr5" />重置
  17. </el-button>
  18. <el-button type="primary" @click="onDetail" :loading="state.loading"> <SvgIcon name="ele-List" class="mr5" /> 话务日期明细 </el-button>
  19. </el-form-item>
  20. </el-form>
  21. <el-row :gutter="20">
  22. <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  23. <v-chart class="chart" :option="option" :loading="state.loading" autoresize />
  24. </el-col>
  25. <el-col :xs="24" :sm="12" :md="12" :lg="4" :xl="4">
  26. <vxe-table
  27. border
  28. :loading="state.loading"
  29. :data="state.tableData1"
  30. :row-config="{ isCurrent: true, isHover: true }"
  31. show-footer
  32. :footer-method="footerMethod"
  33. >
  34. <vxe-column field="name" title=""></vxe-column>
  35. <vxe-column field="value" title="数量"></vxe-column>
  36. </vxe-table>
  37. </el-col>
  38. <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
  39. <v-chart class="chart1" :option="option1" :loading="state.loading" autoresize />
  40. </el-col>
  41. <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
  42. <vxe-toolbar
  43. ref="toolbarRef"
  44. :loading="state.loading"
  45. custom
  46. :refresh="{
  47. queryMethod: handleQuery,
  48. }"
  49. :tools="[{ toolRender: { name: 'exportAll' } }]"
  50. >
  51. </vxe-toolbar>
  52. <div style="max-height: 60vh" class="h100">
  53. <vxe-table
  54. border
  55. :loading="state.loading"
  56. :data="state.tableData"
  57. :column-config="{ resizable: true }"
  58. :row-config="{ isCurrent: true, isHover: true, height: 30 }"
  59. ref="tableRef"
  60. height="auto"
  61. auto-resize
  62. show-overflow
  63. id="statisticsCallIndex"
  64. :custom-config="{ storage: true }"
  65. :params="{ exportMethod: callListExport, exportParams: requestParams }"
  66. show-footer
  67. :footer-method="footerMethod1"
  68. >
  69. <vxe-column field="hourRange" title="时段" min-width="70"></vxe-column>
  70. <vxe-column field="total" title="呼入数量"></vxe-column>
  71. <vxe-column field="answered" title="接通数量"></vxe-column>
  72. <vxe-column field="hanguped" title="挂断数量"></vxe-column>
  73. </vxe-table>
  74. </div>
  75. </el-col>
  76. </el-row>
  77. </el-card>
  78. </div>
  79. </template>
  80. <script setup lang="tsx" name="statisticsCallIndex">
  81. import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
  82. import { FormInstance } from 'element-plus';
  83. import { callList, callListExport, callPeriodBase } from '@/api/statistics/call';
  84. import { defaultDate } from '@/utils/constants';
  85. import Other from '@/utils/other';
  86. import { useRouter } from 'vue-router';
  87. import XEUtils from 'xe-utils';
  88. const StatisticalTime = defineAsyncComponent(() => import('@/components/StatisticalTime/index.vue')); // 日期类型选择组件
  89. // 定义变量内容
  90. const ruleFormRef = ref<RefType>(); // 表单ref
  91. const state = reactive<any>({
  92. queryParams: {
  93. // 查询条件
  94. Keyword: null, // 关键词
  95. crTime: defaultDate, //
  96. StartTime: null,
  97. EndTime: null,
  98. },
  99. tableData: [], //表单
  100. tableData1: [],
  101. loading: false, // 加载
  102. total: 0, // 总数
  103. callForwardingSource: [],
  104. });
  105. // 计算合计
  106. const footerMethod = ({ columns, data }) => {
  107. return [
  108. columns.map((column: any, columnIndex: number) => {
  109. if (columnIndex === 0) {
  110. return '合计';
  111. }
  112. if (['value'].includes(column.property)) {
  113. return XEUtils.sum(data, column.property);
  114. }
  115. }),
  116. ];
  117. };
  118. // 计算合计
  119. const footerMethod1 = ({ columns, data }) => {
  120. return [
  121. columns.map((column: any, columnIndex: number) => {
  122. if (columnIndex === 0) {
  123. return '合计';
  124. }
  125. if (['answered', 'total', 'hanguped'].includes(column.property)) {
  126. return XEUtils.sum(data, column.property);
  127. }
  128. }),
  129. ];
  130. };
  131. /** 搜索按钮操作 */
  132. const handleQuery = () => {
  133. // state.queryParams.PageIndex = 1;
  134. queryList();
  135. };
  136. /** 获取列表 */
  137. const requestParams = ref<EmptyObjectType>({});
  138. const queryList = () => {
  139. state.loading = true;
  140. requestParams.value = Other.deepClone(state.queryParams);
  141. requestParams.value.StartTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[0];
  142. requestParams.value.EndTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[1];
  143. Reflect.deleteProperty(requestParams.value, 'crTime');
  144. callList(requestParams.value)
  145. .then((res: any) => {
  146. state.tableData = res.result;
  147. const xData = state.tableData.map((item: any) => item.hourRange);
  148. const inData = state.tableData.map((item: any) => item.total);
  149. const connectData = state.tableData.map((item: any) => item.answered);
  150. const hangupData = state.tableData.map((item: any) => item.hanguped);
  151. setOption1({
  152. xData,
  153. inData,
  154. connectData,
  155. hangupData,
  156. });
  157. const allConnectNum = state.tableData.reduce((pre: any, cur: any) => {
  158. pre += cur.answered;
  159. return pre;
  160. }, 0);
  161. const allHangupNum = state.tableData.reduce((pre: any, cur: any) => {
  162. pre += cur.hanguped;
  163. return pre;
  164. }, 0);
  165. state.tableData1 = state.tableData.length
  166. ? [
  167. { value: allConnectNum, name: '接通' },
  168. { value: allHangupNum, name: '挂断' },
  169. ]
  170. : [];
  171. const dataTable = state.tableData.length
  172. ? [
  173. { value: allConnectNum, name: '接通' },
  174. { value: allHangupNum, name: '挂断' },
  175. ]
  176. : [
  177. { value: null, name: '接通' },
  178. { value: null, name: '挂断' },
  179. ];
  180. setOption(dataTable);
  181. state.loading = false;
  182. })
  183. .catch(() => {
  184. state.loading = false;
  185. });
  186. };
  187. /** 重置按钮操作 */
  188. const statisticalTimeRef = ref<RefType>();
  189. const resetQuery = (formEl: FormInstance | undefined) => {
  190. if (!formEl) return;
  191. formEl.resetFields();
  192. statisticalTimeRef.value.reset();
  193. queryList();
  194. };
  195. const option = ref<any>({});
  196. const option1 = ref<any>({});
  197. // 呼入总体分析图
  198. const setOption = (data: any) => {
  199. option.value = {
  200. title: {
  201. text: '呼入总体分析图',
  202. left: 'center',
  203. },
  204. tooltip: {
  205. formatter: '{b0}: {c0} ({d}%)',
  206. },
  207. legend: [
  208. {
  209. left: 'left',
  210. top: '40',
  211. orient: 'vertical',
  212. data: ['接通', '挂断'],
  213. },
  214. ],
  215. grid: {
  216. containLabel: true,
  217. },
  218. series: [
  219. {
  220. type: 'pie',
  221. radius: ['0%', '40%'],
  222. label: {
  223. show: true,
  224. overflow: 'none',
  225. formatter: function (params: any) {
  226. if (params.name !== '') {
  227. return `${params.name}:${params.data.value}(${params.percent}%)`;
  228. }
  229. },
  230. },
  231. data: data,
  232. },
  233. ],
  234. };
  235. };
  236. // 呼入数量分析图
  237. const setOption1 = (data: any) => {
  238. option1.value = {
  239. title: {
  240. text: '呼入数量分析图',
  241. left: 'center',
  242. },
  243. tooltip: {
  244. trigger: 'axis',
  245. },
  246. legend: {
  247. data: ['呼入数量', '接通数量', '挂断数量'],
  248. top: 30,
  249. },
  250. grid: {
  251. left: '13%',
  252. right: '4%',
  253. top: '20%',
  254. },
  255. xAxis: {
  256. type: 'category',
  257. boundaryGap: false,
  258. data: data.xData,
  259. },
  260. yAxis: {
  261. type: 'value',
  262. },
  263. series: [
  264. {
  265. name: '呼入数量',
  266. type: 'line',
  267. data: data.inData,
  268. },
  269. {
  270. name: '接通数量',
  271. type: 'line',
  272. data: data.connectData,
  273. },
  274. {
  275. name: '挂断数量',
  276. type: 'line',
  277. data: data.hangupData,
  278. },
  279. ],
  280. };
  281. };
  282. // 获取基础信息
  283. const getBaseInfo = async () => {
  284. try {
  285. const { result } = await callPeriodBase();
  286. state.callForwardingSource = result.callForwardingSource ?? [];
  287. } catch (e) {
  288. console.log(e);
  289. }
  290. };
  291. // 话务日期明细
  292. const router = useRouter();
  293. const onDetail = () => {
  294. router.push({
  295. name: 'statisticsCallDetailIndex',
  296. });
  297. };
  298. const toolbarRef = ref<RefType>();
  299. const tableRef = ref<RefType>();
  300. onMounted(() => {
  301. queryList();
  302. if (tableRef.value && toolbarRef.value) {
  303. tableRef.value.connect(toolbarRef.value);
  304. }
  305. getBaseInfo();
  306. });
  307. </script>
  308. <style lang="scss" scoped>
  309. .chart,
  310. .chart1 {
  311. height: 60vh;
  312. margin-top: 10px;
  313. }
  314. </style>