index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <!-- 给魏演示使用 2023-20-16 -->
  3. <div class="AbstractProgram">
  4. <br />
  5. <el-breadcrumb separator-class="el-icon-arrow-right">
  6. <el-breadcrumb-item>稿前校对统计</el-breadcrumb-item>
  7. </el-breadcrumb>
  8. <br />
  9. <el-card class="box-card">
  10. <el-form
  11. :model="form"
  12. size="small"
  13. :inline="true"
  14. label-width="120px"
  15. class="demo-form-inline"
  16. >
  17. <el-form-item label="日期">
  18. <el-date-picker
  19. v-model="form.time"
  20. type="datetimerange"
  21. value-format="YYYY-MM-DD HH:mm:ss"
  22. start-placeholder="开始时间"
  23. end-placeholder="结束时间"
  24. :disabled-date="disabledDate"
  25. placeholder="日期"
  26. >
  27. </el-date-picker>
  28. </el-form-item>
  29. <el-form-item label="关键词">
  30. <el-input v-model="form.keyword" placeholder="检索关键词" clearable />
  31. </el-form-item>
  32. <el-form-item style="float: right">
  33. <el-button type="primary" @click="onSubmit" :loading="load">
  34. 查询
  35. </el-button>
  36. <!-- <el-button type="primary" @click="onExport" :loading="load">
  37. 导出
  38. </el-button> -->
  39. </el-form-item>
  40. </el-form>
  41. </el-card>
  42. <br />
  43. <el-card>
  44. <div id="echartsEle"></div>
  45. <br />
  46. <el-table
  47. :data="tableData"
  48. style="width: 100%"
  49. :header-cell-style="{ backgroundColor: '#f4f5f7', color: '#606266' }"
  50. >
  51. <el-table-column
  52. show-overflow-tooltip
  53. align="center"
  54. prop="displayName"
  55. label="用户名称"
  56. />
  57. <el-table-column
  58. show-overflow-tooltip
  59. align="center"
  60. prop="createTime"
  61. label="校对时间"
  62. />
  63. <el-table-column
  64. show-overflow-tooltip
  65. align="center"
  66. prop="textLength"
  67. label="校对字数"
  68. />
  69. </el-table>
  70. <br />
  71. <el-pagination
  72. @current-change="change"
  73. background
  74. :default-current-page="page"
  75. layout="prev, pager, next"
  76. :total="total"
  77. />
  78. </el-card>
  79. </div>
  80. </template>
  81. <script>
  82. // @ is an alias to /src
  83. import { getYoumeiList, getYoumeiProportion } from '@/api/newMdeiaApi';
  84. import dayjs from 'dayjs';
  85. // import config from "@/config/index";
  86. import * as echarts from 'echarts/core';
  87. import { PieChart } from 'echarts/charts';
  88. import {
  89. TitleComponent,
  90. TooltipComponent,
  91. GridComponent,
  92. ToolboxComponent,
  93. LegendComponent,
  94. } from 'echarts/components';
  95. import { CanvasRenderer } from 'echarts/renderers';
  96. echarts.use([
  97. TitleComponent,
  98. TooltipComponent,
  99. GridComponent,
  100. PieChart,
  101. CanvasRenderer,
  102. ToolboxComponent,
  103. LegendComponent,
  104. ]);
  105. let T = undefined;
  106. export default {
  107. name: 'Proofread',
  108. data() {
  109. return {
  110. page: 1,
  111. size: 10,
  112. total: 0,
  113. load: false,
  114. tableData: [],
  115. form: {
  116. keyword: '',
  117. time: [],
  118. },
  119. myChart: undefined,
  120. };
  121. },
  122. mounted() {
  123. let h = Date.now();
  124. h = h - 86400000;
  125. const Time = dayjs(h);
  126. const time1 = Time.format('YYYY-MM-DD') + ' 00:00:00';
  127. const time2 = Time.format('YYYY-MM-DD') + ' 23:59:59';
  128. this.form = {
  129. keyword: '',
  130. time: [time1, time2],
  131. };
  132. this.getDate();
  133. this.getEcharts();
  134. },
  135. computed: {},
  136. methods: {
  137. getDate() {
  138. if (T) window.clearTimeout(T);
  139. T = setTimeout(() => {
  140. this.load = true;
  141. if (T) window.clearTimeout(T);
  142. }, 200);
  143. getYoumeiList({
  144. page: this.page,
  145. size: this.size,
  146. keyword: this.form.keyword,
  147. startTime: this.form.time[0],
  148. endTime: this.form.time[1],
  149. })
  150. .then(r => {
  151. if (T) window.clearTimeout(T);
  152. this.load = false;
  153. this.total = r.total || 0;
  154. this.tableData = r.records || [];
  155. })
  156. .catch(() => {
  157. if (T) window.clearTimeout(T);
  158. this.tableData = [];
  159. this.load = false;
  160. });
  161. },
  162. getEcharts() {
  163. getYoumeiProportion({
  164. keyword: this.form.keyword,
  165. startTime: this.form.time[0],
  166. endTime: this.form.time[1],
  167. }).then(r => {
  168. const li = r || [];
  169. const ele = document.getElementById('echartsEle');
  170. !this.myChart && (this.myChart = echarts.init(ele));
  171. this.myChart.resize({
  172. height: 400,
  173. });
  174. this.myChart.setOption({
  175. legend: {
  176. top: 'bottom',
  177. },
  178. title: {
  179. text: '调用次数占比',
  180. },
  181. series: [
  182. {
  183. type: 'pie',
  184. radius: [50, 120],
  185. center: ['50%', '50%'],
  186. data: li.map(v=>{
  187. return {
  188. name: v.userId,
  189. value: v.count
  190. }
  191. }),
  192. },
  193. ],
  194. });
  195. });
  196. },
  197. disabledDate(time) {
  198. return time.getTime() > Date.now();
  199. },
  200. change(page) {
  201. this.page = page;
  202. this.getDate();
  203. },
  204. onSubmit() {
  205. this.page = 1;
  206. this.getDate();
  207. this.getEcharts();
  208. },
  209. onExport() {},
  210. },
  211. components: {},
  212. };
  213. </script>
  214. <style>
  215. .AbstractProgram {
  216. padding: 1em;
  217. }
  218. .el-pagination .btn-next .el-icon,
  219. .el-pagination .btn-prev .el-icon {
  220. margin: 0 auto;
  221. }
  222. #echartsEle {
  223. width: 100%;
  224. max-width: 800px;
  225. min-width: 400px;
  226. margin: 0 auto;
  227. }
  228. </style>