index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="container">
  3. <visitorStatistics />
  4. <div class="card">
  5. <cord-top title="留言分析" @returnWhere="getMessageAnalysis" />
  6. <div ref="messageAnalysis" style="margin-top: 20px"></div>
  7. </div>
  8. <div class="card">
  9. <cord-top title="服务申请分析" @returnWhere="getServiceRequestAnalysis" />
  10. <div ref="serviceRequestAnalysis" style="margin-top: 20px"></div>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. import cordTop from "./modules/header.vue";
  16. import visitorStatistics from "./modules/visitorStatistics";
  17. import { Line } from "@antv/g2plot";
  18. export default {
  19. components: { visitorStatistics, cordTop },
  20. data() {
  21. return {
  22. messageAnalysis: null, //留言分析
  23. serviceRequestAnalysis: null, //服务申请分析
  24. siteid: "", //站点id
  25. };
  26. },
  27. created() {
  28. this.siteid = JSON.parse(sessionStorage.getItem("active_account")).siteid;
  29. this.getMessageAnalysis();
  30. this.getServiceRequestAnalysis();
  31. },
  32. methods: {
  33. // 获取留言分析
  34. getMessageAnalysis(detail) {
  35. let content = {
  36. siteid: this.siteid,
  37. type: "近七日",
  38. };
  39. if (detail) {
  40. if (detail.type) {
  41. content.type = detail.type;
  42. } else {
  43. content.type = "";
  44. content.where = detail;
  45. }
  46. }
  47. this.$api
  48. .requested({
  49. id: 2025010310381303,
  50. content,
  51. })
  52. .then((res) => {
  53. console.log("获取留言分析", res);
  54. if (res.code != 1) return;
  55. let type = this.$t("留言量分析");
  56. let list = res.data.map((v) => {
  57. v.type = type;
  58. return v;
  59. });
  60. if (detail) {
  61. this.messageAnalysis.changeData(list);
  62. } else {
  63. this.messageAnalysis = new Line(this.$refs.messageAnalysis, {
  64. height: 300,
  65. data: list,
  66. xField: "date",
  67. scrollbar: {
  68. type: "horizontal",
  69. },
  70. seriesField: "type",
  71. yField: "count",
  72. color: "#5588F7",
  73. tooltip: {
  74. formatter: (datum) => {
  75. return {
  76. name: type,
  77. value: datum.count,
  78. };
  79. },
  80. },
  81. point: {
  82. shape: "breath-point",
  83. },
  84. });
  85. this.messageAnalysis.render();
  86. }
  87. });
  88. },
  89. // 获取服务申请分析
  90. getServiceRequestAnalysis(detail) {
  91. let content = {
  92. siteid: this.siteid,
  93. type: "近七日",
  94. };
  95. if (detail) {
  96. if (detail.type) {
  97. content.type = detail.type;
  98. } else {
  99. content.type = "";
  100. content.where = detail;
  101. }
  102. }
  103. this.$api
  104. .requested({
  105. id: 2025010310402603,
  106. content,
  107. })
  108. .then((res) => {
  109. console.log("获取申请量分析", res);
  110. if (res.code != 1) return;
  111. let type = this.$t("申请量分析");
  112. let list = res.data.map((v) => {
  113. v.type = type;
  114. return v;
  115. });
  116. if (detail) {
  117. this.serviceRequestAnalysis.changeData(list);
  118. } else {
  119. this.serviceRequestAnalysis = new Line(
  120. this.$refs.serviceRequestAnalysis,
  121. {
  122. height: 300,
  123. data: list,
  124. xField: "date",
  125. scrollbar: {
  126. type: "horizontal",
  127. },
  128. seriesField: "type",
  129. yField: "count",
  130. color: "#F29C37",
  131. tooltip: {
  132. formatter: (datum) => {
  133. return {
  134. name: type,
  135. value: datum.count,
  136. };
  137. },
  138. },
  139. point: {
  140. shape: "breath-point",
  141. },
  142. }
  143. );
  144. this.serviceRequestAnalysis.render();
  145. }
  146. });
  147. },
  148. },
  149. };
  150. </script>
  151. <style scoped>
  152. .container {
  153. padding: 20px;
  154. box-sizing: border-box;
  155. }
  156. .card {
  157. width: 100%;
  158. padding: 20px;
  159. background: #ffffff;
  160. box-shadow: 0px 1px 6px 1px rgba(0, 0, 0, 0.16);
  161. border-radius: 10px;
  162. box-sizing: border-box;
  163. margin-top: 20px;
  164. }
  165. </style>