DashBoard.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <div class="board-container">
  3. <div class="header">
  4. <img src="../assets/logo.png" style="margin-left: 10px; margin-top: 10px;" >
  5. </div>
  6. <div class="title_info">
  7. <el-card shadow="always" style="background-color: rgb(201,235,251); border-radius: 5px;">
  8. <p class="item_name">{{ itemName }}</p>
  9. <p class="scope_cycleName">{{type}} {{ scope }} 类 {{ cycleName }} 专家评分公示</p>
  10. </el-card>
  11. </div>
  12. <div class="analysis_collect">
  13. <span class="name"><i class="el-icon-s-data"></i>评分项平均得分</span>
  14. <el-table :data="analysisData" border style="width: 100% ;" stripe highlight-current-row>
  15. <el-table-column prop="questionName" label="评分项" align="center">
  16. </el-table-column>
  17. <el-table-column prop="avgScore" label="平均得分" align="center">
  18. </el-table-column>
  19. </el-table>
  20. </div>
  21. <div class="origin_collect">
  22. <span class="name"><i class="el-icon-s-data"></i>专家评分值</span>
  23. <el-table :data="originData" border style="width: 100%" stripe highlight-current-row>
  24. <el-table-column prop="professorNo" label="专家编号" align="center">
  25. </el-table-column>
  26. <el-table-column prop="questionName" label="评分项" align="center">
  27. </el-table-column>
  28. <el-table-column prop="score" label="专家评分值" align="center">
  29. </el-table-column>
  30. <el-table-column prop="created" label="专家评分时间" align="center">
  31. </el-table-column>
  32. </el-table>
  33. </div>
  34. <div class="user_size">
  35. <span v-for="(u,index) in userSize">
  36. <i class="el-icon-s-custom" style="color: green; font-size: xx-large;"></i>
  37. </span>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import YPageListLayout from '@/components/custom/YPageListLayout'
  43. import WebSocketClient from '../utils/WebSocketClient.js'
  44. export default {
  45. name: 'Dashboard',
  46. components: {
  47. YPageListLayout,
  48. },
  49. data() {
  50. return {
  51. analysisData: [],
  52. originData: [],
  53. listLoading: false,
  54. itemName: "",
  55. scope: "",
  56. cycleName: "",
  57. type:null,
  58. messages: [],
  59. error: null,
  60. client: {
  61. messages:[
  62. {data:"*"},
  63. {userSize:0}
  64. ]
  65. },
  66. userSize:0
  67. }
  68. },
  69. watch:{
  70. client:{
  71. deep: true,
  72. handler(newValue,oldValue){
  73. let data = newValue.messages[(newValue.messages.length)-1]
  74. if (data != undefined){
  75. if (data.data !=null){
  76. this.getAnalysisList();
  77. this.getOriginList();
  78. }
  79. if (data.userSize != undefined){
  80. this.userSize = (data.userSize)-1;
  81. }
  82. }
  83. }
  84. }
  85. },
  86. mounted(){
  87. this.init();
  88. },
  89. created() {
  90. this.getAnalysisList();
  91. this.getOriginList();
  92. },
  93. methods: {
  94. init(){
  95. if (typeof(WebSocket) === "undefined"){
  96. console.log("您的浏览器不支持socket")
  97. }else{
  98. // 创建 WebSocketClient 实例并连接到服务端 API 接口
  99. this.client = new WebSocketClient('wss://kps.scdayou.com/ws/apo/ws')
  100. this.client.connect()
  101. }
  102. },
  103. getAnalysisList() {
  104. const that = this
  105. this.$api.dashboard.getAnalysisList()
  106. .then((res) => {
  107. let tScore = res.data[0].avgScore
  108. if (tScore==null){
  109. that.analysisData = null;
  110. }else{
  111. that.analysisData = res.data
  112. }
  113. setTimeout(() => {
  114. }, 200)
  115. })
  116. .catch(() => {
  117. that.listLoading = false
  118. })
  119. },
  120. getOriginList() {
  121. const that = this
  122. this.$api.dashboard.getOriginList()
  123. .then((res) => {
  124. that.itemName = res.data[0].itemName;
  125. that.scope = res.data[0].scope;
  126. that.cycleName = res.data[0].cycleName;
  127. that.type = res.data[0].type;
  128. if (res.data[0].score ==null){
  129. that.originData = null;
  130. }else{
  131. that.originData = res.data;
  132. }
  133. setTimeout(() => {
  134. }, 200)
  135. })
  136. .catch(() => {
  137. that.listLoading = false
  138. })
  139. },
  140. },
  141. destoryed() {
  142. // 在组件销毁前断开 WebSocket 连接
  143. this.client.disconnect()
  144. console.log("websocket 断开")
  145. },
  146. beforeDestory(){
  147. this.client.disconnect()
  148. console.log("websocket 断开")
  149. }
  150. }
  151. </script>
  152. <style lang="css" scoped>
  153. .header {
  154. height: 80px;
  155. padding: 0;
  156. background-color: #ffffff;
  157. vertical-align: middle;
  158. display: flex;
  159. position: relative;
  160. width: 100%;
  161. }
  162. .left {
  163. margin: 0;
  164. padding-left: 10px;
  165. width: 30%;
  166. height: 100%;
  167. }
  168. .board-container {
  169. /* display: flex;
  170. width: 100%;
  171. justify-content: center;
  172. overflow: auto; */
  173. top: -10;
  174. background-image: linear-gradient(to top, #ace0f9 0%, #ffffff 100%);
  175. height: 1200px;
  176. overflow:auto;
  177. }
  178. .item_name {
  179. font-size: xx-large;
  180. letter-spacing: 1px;
  181. font-weight: 900;
  182. }
  183. .scope_cycleName {
  184. font-size: large;
  185. letter-spacing: 1px;
  186. font-weight: bold;
  187. color: red;
  188. }
  189. .title_info {
  190. margin-top: 1%;
  191. width: 70%;
  192. margin-left: 15%;
  193. text-align: center;
  194. }
  195. .analysis_collect {
  196. margin-top: 2%;
  197. width: 70%;
  198. margin-left: 15%;
  199. }
  200. .origin_collect {
  201. margin-top: 2%;
  202. width: 70%;
  203. margin-bottom: 2%;
  204. margin-left: 15%;
  205. }
  206. .name{
  207. /* font-family: 'Courier New', Courier, monospace; */
  208. margin-bottom: 5px;
  209. letter-spacing: 1px;
  210. font-weight: bold;
  211. font-size: small;
  212. }
  213. .user_size{
  214. position:absolute;
  215. right:30px;
  216. top:1%;
  217. height: 40px;
  218. }
  219. </style>