left-bottom.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div class="left_bottom_wrap">
  3. <div class="left_number">
  4. <div>
  5. <span>登录坐席数量:</span>
  6. <CountUp :endVal="loginCount" />
  7. </div>
  8. <div>
  9. <span>呼入接通数量:</span>
  10. <CountUp :endVal="state.count.inOn" />
  11. </div>
  12. <div>
  13. <span>有效接通数量:</span>
  14. <CountUp :endVal="state.count.validOn" />
  15. </div>
  16. <div>
  17. <span>未接通数量:</span>
  18. <CountUp :endVal="state.count.inNoOn" />
  19. </div>
  20. <div>
  21. <span>呼出接通数量:</span>
  22. <CountUp :endVal="state.count.outOn" />
  23. </div>
  24. <div>
  25. <span>队列挂断数量:</span>
  26. <CountUp :endVal="state.count.inQueueNoOn" />
  27. </div>
  28. </div>
  29. <div class="right_chart">
  30. <v-chart class="chart" :option="option" />
  31. </div>
  32. </div>
  33. </template>
  34. <script setup lang="ts">
  35. import { onMounted, reactive, ref, computed, onUnmounted, watch } from "vue";
  36. import CountUp from "@/components/count-up";
  37. import signalR from "@/utils/signalR";
  38. const props = defineProps({
  39. data: {
  40. type: Array,
  41. default: () => [],
  42. },
  43. content: {
  44. type: Object,
  45. default: () => {},
  46. },
  47. });
  48. const option = ref({});
  49. const state = reactive<any>({
  50. count: {
  51. inNoOn: 0,
  52. inOn: 0,
  53. inQueueNoOn: 0,
  54. outOn: 0,
  55. validOn: 0,
  56. },
  57. });
  58. const setOption = async (newData: any) => {
  59. option.value = {
  60. tooltip: {
  61. trigger: "axis",
  62. backgroundColor: "rgba(0,0,0,.6)",
  63. borderColor: "rgba(147, 235, 248, .8)",
  64. textStyle: {
  65. color: "#FFF",
  66. },
  67. },
  68. legend: {
  69. data: ["呼入", "外呼", "外呼平均", "呼入平均"],
  70. textStyle: {
  71. color: "#fff",
  72. },
  73. top: "0",
  74. left: "80px",
  75. icon: "roundRect",
  76. itemWidth: 16,
  77. itemHeight: 16,
  78. itemGap: 20,
  79. },
  80. grid: {
  81. left: "50px",
  82. right: "10px",
  83. bottom: "30px",
  84. top: "30px",
  85. },
  86. xAxis: {
  87. data: newData.xData,
  88. axisLine: {
  89. lineStyle: {
  90. color: "#fff",
  91. },
  92. },
  93. axisTick: {
  94. show: false,
  95. },
  96. },
  97. yAxis: [
  98. {
  99. splitLine: { show: false },
  100. axisLine: {
  101. lineStyle: {
  102. color: "#fff",
  103. },
  104. },
  105. axisLabel: {
  106. formatter: "{value}",
  107. },
  108. },
  109. {
  110. splitLine: { show: false },
  111. axisLine: {
  112. lineStyle: {
  113. color: "#fff",
  114. },
  115. },
  116. axisLabel: {
  117. formatter: "{value}% ",
  118. },
  119. },
  120. ],
  121. series: [
  122. {
  123. name: "呼入",
  124. type: "line",
  125. symbol: "circle", //数据交叉点样式
  126. areaStyle: {
  127. //添加背景颜色
  128. opacity: 0.3, //透明度
  129. },
  130. itemStyle: {
  131. borderRadius: 5,
  132. },
  133. smooth: true,
  134. data: newData.inData,
  135. },
  136. {
  137. name: "外呼",
  138. type: "line",
  139. symbol: "circle", //数据交叉点样式
  140. areaStyle: {
  141. //添加背景颜色
  142. opacity: 0.3, //透明度
  143. },
  144. itemStyle: {
  145. borderRadius: 5,
  146. },
  147. smooth: true,
  148. z: -12,
  149. data: newData.outData,
  150. },
  151. {
  152. name: "呼入平均",
  153. type: "line",
  154. symbol: "circle", //数据交叉点样式
  155. areaStyle: {
  156. //添加背景颜色
  157. opacity: 0.3, //透明度
  158. },
  159. itemStyle: {
  160. borderRadius: 5,
  161. },
  162. smooth: true,
  163. z: -12,
  164. data: newData.inAverageData,
  165. },
  166. {
  167. name: "外呼平均",
  168. type: "line",
  169. symbol: "circle", //数据交叉点样式
  170. areaStyle: {
  171. //添加背景颜色
  172. opacity: 0.3, //透明度
  173. },
  174. itemStyle: {
  175. borderRadius: 5,
  176. },
  177. smooth: true,
  178. z: -12,
  179. data: newData.outAverageData,
  180. },
  181. ],
  182. };
  183. };
  184. const seatsList = ref<any>([]);
  185. // 登录坐席数量
  186. const loginCount = computed(() => {
  187. return seatsList.value.filter((item: any) => item.state !== "logout").length;
  188. });
  189. watch(
  190. () => props.content,
  191. (val: any) => {
  192. state.count = val.count[0];
  193. let data = {
  194. xData: [],
  195. inData: [],
  196. outData: [],
  197. inAverageData: [],
  198. outAverageData: [],
  199. };
  200. val.list.forEach((item: any) => {
  201. data.xData.push(item.time);
  202. data.inData.push(item.in);
  203. data.outData.push(item.out);
  204. data.inAverageData.push(item.inAverag);
  205. data.outAverageData.push(item.outAverag);
  206. });
  207. setTimeout(() => {
  208. setOption(data);
  209. }, 100);
  210. }
  211. );
  212. watch(
  213. () => props.data,
  214. (newData: any) => {
  215. seatsList.value = newData;
  216. },
  217. { immediate: true }
  218. );
  219. onMounted(() => {
  220. signalR.SR.on("SeatState", (res: any) => {
  221. const item = seatsList.value.find((item: any) => item.telNo === res.telNo);
  222. if (item) {
  223. item.state = res.state;
  224. }
  225. });
  226. signalR.SR.on("BsSeatStateDataShowArea3", (res: any) => {
  227. state.count = res[0];
  228. });
  229. signalR.SR.on("BsSeatStateDataShowArea4", (res: any) => {
  230. let data = {
  231. xData: [],
  232. inData: [],
  233. outData: [],
  234. inAverageData: [],
  235. outAverageData: [],
  236. };
  237. res.forEach((item: any) => {
  238. data.xData.push(item.time);
  239. data.inData.push(item.in);
  240. data.outData.push(item.out);
  241. data.inAverageData.push(item.inAverag);
  242. data.outAverageData.push(item.outAverag);
  243. });
  244. setTimeout(() => {
  245. setOption(data);
  246. }, 100);
  247. });
  248. });
  249. onUnmounted(() => {
  250. signalR.SR.off("SeatState");
  251. signalR.SR.off("BsSeatStateDataShowArea3");
  252. signalR.SR.off("BsSeatStateDataShowArea4");
  253. });
  254. </script>
  255. <style scoped lang="scss">
  256. .left_bottom_wrap {
  257. overflow: hidden;
  258. width: 100%;
  259. height: 100%;
  260. display: flex;
  261. font-size: var(--el-font-size-base);
  262. .left_number {
  263. margin: 20px 0;
  264. height: calc(100% - 40px);
  265. display: flex;
  266. flex-direction: column;
  267. justify-content: space-around;
  268. min-width: 130px;
  269. div {
  270. display: flex;
  271. justify-content: space-between;
  272. }
  273. }
  274. .right_chart {
  275. flex: 1;
  276. height: 100%;
  277. }
  278. }
  279. </style>