index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <script setup lang="ts">
  2. import EvaluateCard from "@/views/evaluation/components/EvaluateCard.vue";
  3. import RadarChart from "@/components/Charts/RadarChart.vue";
  4. import FocusBarChart from "@/components/Charts/FocusBarChart.vue";
  5. import RelaxBarChart from "@/components/Charts/RelaxBarChart.vue";
  6. import IndicatorsBarChart from "@/components/Charts/IndicatorsBarChart.vue";
  7. import {trimInput} from "@/utils";
  8. import {ChartBtmData, ChartMidData, TopCard} from "@/api/evaluation/types";
  9. import {getEvaluationBtm, getEvaluationMid, getEvaluationStudents, getEvaluationTop} from "@/api/evaluation";
  10. import {useUserStore} from "@/store/modules/user";
  11. import {StudentList} from "@/api/student/types";
  12. defineOptions({
  13. name: "EvaluateIndex",
  14. inheritAttrs: false,
  15. });
  16. const userStore = useUserStore();
  17. /**
  18. * 数据卡片
  19. */
  20. const cardStatus = ref(false);
  21. const cards = ref<TopCard>();
  22. async function getDataCard(schoolId: number) {
  23. getEvaluationTop(schoolId)
  24. .then(({data}) => {
  25. cards.value = data;
  26. cardStatus.value = true;
  27. })
  28. .catch((error) => {
  29. cardStatus.value = true;
  30. console.log(error.message);
  31. });
  32. }
  33. /**
  34. * 学生数据
  35. */
  36. const studentSearch = ref("");
  37. const studentStatus = ref(false);
  38. const studentMessage = ref("加载中...");
  39. const studentActive = ref(0);
  40. const studentData = ref<StudentList[]>();
  41. async function getStudentData(schoolId: number) {
  42. getEvaluationStudents(schoolId, studentSearch.value)
  43. .then(({data}) => {
  44. studentData.value = <StudentList[]>data;
  45. if (data && studentData.value?.length > 0) {
  46. studentActive.value = studentData.value?.[0].id || 0;
  47. studentStatus.value = true;
  48. // 获取第一个学生图表
  49. changeStudent(studentActive.value);
  50. } else {
  51. changeStudent(0);
  52. studentStatus.value = studentSearch.value != "";
  53. studentMessage.value = "学校学生还未进行过测评,暂无测评数据!";
  54. }
  55. })
  56. .catch((error) => {
  57. changeStudent(0);
  58. studentMessage.value = error.message;
  59. studentStatus.value = studentSearch.value != "";
  60. console.log(error.message);
  61. });
  62. }
  63. function getStudentSearch() {
  64. getStudentData(userStore.schoolId);
  65. }
  66. function changeStudent(studentId: number) {
  67. studentActive.value = studentId;
  68. // 切换学生图表
  69. if (studentId > 0) {
  70. // 图表数据
  71. getMidChartData(userStore.schoolId, studentId);
  72. getBtmChartData(userStore.schoolId, studentId);
  73. } else {
  74. midStatus.value = false;
  75. btmStatus.value = false;
  76. chartStatus.value = false;
  77. }
  78. }
  79. /**
  80. * 图表数据
  81. */
  82. const chartStatus = ref(false);
  83. //中间部分图表
  84. const midStatus = ref(false);
  85. const midData = ref<ChartMidData>();
  86. // 五维雷达图1
  87. const radarMidData = ref<number[][]>();
  88. const radarMidStar = ref<number[]>();
  89. // 专注力四维柱状图
  90. const focusData = ref<number[][]>();
  91. const focusStar = ref([1, 2, 3, 4]);
  92. async function getMidChartData(schoolId: number, babyId: number) {
  93. midStatus.value = false;
  94. getEvaluationMid(schoolId, babyId)
  95. .then(({data}) => {
  96. midData.value = data;
  97. // 五维雷达图
  98. radarMidData.value = [];
  99. if (midData.value?.lastRadar[0] && midData.value?.lastRadar[0].length > 0) {
  100. radarMidData.value?.push(midData.value?.lastRadar[0] || []);
  101. radarMidStar.value = midData.value?.lastRadar[1] || [];
  102. } else {
  103. radarMidStar.value = midData.value?.firstRadar[1] || [];
  104. }
  105. radarMidData.value?.push(midData.value?.firstRadar[0] || []);
  106. // 专注力四维柱状图
  107. focusData.value = [];
  108. focusData.value?.push(midData.value?.firstColumnar || []);
  109. focusData.value?.push(midData.value?.lastColumnar || []);
  110. midStatus.value = true;
  111. chartStatus.value = true;
  112. })
  113. .catch((error) => {
  114. midStatus.value = false;
  115. console.log(error.message);
  116. });
  117. }
  118. //底部图表、
  119. const btmStatus = ref(false);
  120. const btmData = ref<ChartBtmData>();
  121. // 五维雷达图2
  122. const radarBtmData = ref<number[][]>();
  123. const radarBtmStar = ref<number[]>();
  124. // 3维放松度分析柱状图
  125. const relaxData = ref<number[][]>();
  126. // 脑电评估检测指数分析看板
  127. const indicatorsData = ref<number[][]>();
  128. async function getBtmChartData(schoolId: number, babyId: number) {
  129. btmStatus.value = false;
  130. getEvaluationBtm(schoolId, babyId)
  131. .then(({data}) => {
  132. btmData.value = data;
  133. // 五维雷达图2
  134. radarBtmData.value = [];
  135. if (btmData.value?.lastRadar[0] && btmData.value?.lastRadar[0].length > 0) {
  136. radarBtmData.value?.push(btmData.value?.lastRadar[0] || []);
  137. radarBtmStar.value = btmData.value?.lastRadar[1] || [];
  138. } else {
  139. radarBtmStar.value = btmData.value?.firstRadar[1] || [];
  140. }
  141. radarBtmData.value?.push(btmData.value?.firstRadar[0] || []);
  142. // 3维放松度分析柱状图
  143. relaxData.value = [];
  144. relaxData.value?.push(btmData.value?.firstColumn || []);
  145. relaxData.value?.push(btmData.value?.lastColumn || []);
  146. // 脑电评估检测指数分析看板
  147. indicatorsData.value = [];
  148. indicatorsData.value?.push(btmData.value?.secondColumn || []);
  149. indicatorsData.value?.push(btmData.value?.lastSecondColumn || []);
  150. btmStatus.value = true;
  151. chartStatus.value = true;
  152. })
  153. .catch((error) => {
  154. btmStatus.value = false;
  155. console.log(error.message);
  156. });
  157. }
  158. onMounted(() => {
  159. if (userStore.schoolId > 0) {
  160. // 数据卡片
  161. getDataCard(userStore.schoolId);
  162. // 获取学生
  163. getStudentData(userStore.schoolId);
  164. }
  165. });
  166. </script>
  167. <template>
  168. <div class="evaluate-container">
  169. <!-- 数据卡片 -->
  170. <!-- 数据卡片 -->
  171. <template v-if="cardStatus">
  172. <EvaluateCard
  173. :key="cards?.toString()"
  174. :focuses="cards?.brainCount || 0"
  175. :students="cards?.studentCount || 0"
  176. :trainings="cards?.eegCount || 0" />
  177. </template>
  178. <div v-if="studentStatus" class="evaluate-chart">
  179. <!-- 学生查找 -->
  180. <div class="student-search">
  181. <div class="search">
  182. <el-input
  183. v-model="studentSearch"
  184. placeholder="请输入学生名称或手机号码"
  185. size="large"
  186. @input="(value:string) => (studentSearch = trimInput(value))" />
  187. <el-button size="large" type="primary" @click="getStudentSearch()">查找</el-button>
  188. </div>
  189. <div v-if="studentData && studentData?.length > 0" class="result">
  190. <el-scrollbar height="700px">
  191. <div
  192. v-for="item in studentData"
  193. :key="item.id"
  194. class="scroll-item"
  195. :class="{active: item.id === studentActive}"
  196. @click="changeStudent(item.id)">
  197. <img src="../../assets/evaluate/default.png" alt="头像" />
  198. <p>{{ item.name }}</p>
  199. <p>{{ item.phone }}</p>
  200. </div>
  201. </el-scrollbar>
  202. </div>
  203. <div v-else class="result">
  204. <div class="empty">
  205. <img src="../../assets/empty.png" alt="数据为空" />
  206. <p>没有符合搜索条件的记录!</p>
  207. </div>
  208. </div>
  209. </div>
  210. <!-- 图表展示-->
  211. <div v-if="chartStatus" class="student-chart">
  212. <template v-if="midStatus">
  213. <div class="title">儿童脑电专注力测评数据分析</div>
  214. <el-row :gutter="10">
  215. <el-col :xs="24" :span="8">
  216. <div class="box-card">
  217. <RadarChart
  218. id="radarChart1"
  219. :key="radarMidData?.toString()"
  220. :data-sets="radarMidData"
  221. :star="radarMidStar"
  222. :tag="Boolean(true)"
  223. width="400px"
  224. height="300px"
  225. class="chart" />
  226. <div class="info">5D脑电数据模型</div>
  227. </div>
  228. </el-col>
  229. <el-col :xs="24" :span="8">
  230. <div class="box-card">
  231. <FocusBarChart
  232. id="focusBarChart1"
  233. :key="focusData?.toString()"
  234. :data-sets="focusData"
  235. :star="focusStar"
  236. width="400px"
  237. height="300px"
  238. class="chart" />
  239. <div class="info legend">
  240. 专注力四维分析
  241. <div class="tag">
  242. <span class="t1">首次检测</span>
  243. <span class="t2">最近检测</span>
  244. </div>
  245. </div>
  246. </div>
  247. </el-col>
  248. <el-col :xs="24" :span="8" />
  249. </el-row>
  250. </template>
  251. <template v-if="btmStatus">
  252. <div class="title">脑电检测分析</div>
  253. <el-row :gutter="10">
  254. <el-col :xs="24" :span="8">
  255. <div class="box-card">
  256. <RadarChart
  257. id="radarChart2"
  258. :key="radarBtmData?.toString()"
  259. :data-sets="radarBtmData"
  260. :star="radarBtmStar"
  261. :tag="Boolean(true)"
  262. width="400px"
  263. height="300px"
  264. class="chart" />
  265. <div class="info">5D脑电数据模型</div>
  266. </div>
  267. </el-col>
  268. <el-col :xs="24" :span="8">
  269. <div class="box-card">
  270. <RelaxBarChart
  271. id="relaxBarChart1"
  272. :key="relaxData?.toString()"
  273. :data-sets="relaxData"
  274. class="chart"
  275. height="300px"
  276. width="400px" />
  277. <div class="info legend">
  278. 3维放松度分析
  279. <div class="tag">
  280. <span class="t1">首次检测</span>
  281. <span class="t2">最近检测</span>
  282. </div>
  283. </div>
  284. </div>
  285. </el-col>
  286. <el-col :xs="24" :span="8">
  287. <div class="box-card">
  288. <IndicatorsBarChart
  289. id="indicatorsBarChart1"
  290. :key="indicatorsData?.toString()"
  291. :data-sets="indicatorsData"
  292. width="400px"
  293. height="300px"
  294. class="chart" />
  295. <div class="info legend">
  296. 脑电评估检测指数分析看板
  297. <div class="tag">
  298. <span class="t1">首次检测</span>
  299. <span class="t2">最近检测</span>
  300. </div>
  301. </div>
  302. </div>
  303. </el-col>
  304. </el-row>
  305. </template>
  306. </div>
  307. </div>
  308. <div v-else class="evaluate-chart empty">
  309. <img src="../../assets/empty.png" alt="数据为空" />
  310. <p>{{ studentMessage }}</p>
  311. </div>
  312. </div>
  313. </template>
  314. <style lang="scss" scoped>
  315. .evaluate-container {
  316. position: relative;
  317. padding: 30px;
  318. }
  319. .empty {
  320. padding: 135px 0;
  321. }
  322. .evaluate-chart {
  323. position: relative;
  324. box-sizing: border-box;
  325. width: 100%;
  326. min-height: 800px;
  327. padding: 0 10px 20px 386px;
  328. background: #fff;
  329. border-radius: 30px;
  330. &.empty {
  331. padding: 200px 0;
  332. }
  333. }
  334. :deep(.el-input__wrapper) {
  335. background: #fff;
  336. border-radius: 12px;
  337. box-shadow: none !important;
  338. }
  339. .student-search {
  340. position: absolute;
  341. top: 0;
  342. left: 0;
  343. box-sizing: border-box;
  344. width: 342px;
  345. height: 100%;
  346. padding-top: 34px;
  347. overflow: hidden;
  348. border: 1px solid #e6e8eb;
  349. border-radius: 30px;
  350. .el-input {
  351. width: 220px;
  352. margin: 0 10px 0 15px;
  353. border: 1px solid #e6e8eb;
  354. border-radius: 12px;
  355. }
  356. :deep(.el-input__inner) {
  357. font-size: 14px;
  358. }
  359. .el-button {
  360. padding: 0 24px;
  361. font-size: 14px;
  362. border-radius: 12px;
  363. }
  364. .result {
  365. height: 700px;
  366. margin-top: 15px;
  367. .scroll-item {
  368. position: relative;
  369. box-sizing: border-box;
  370. width: 100%;
  371. height: 70px;
  372. padding: 8px 0 0 90px;
  373. color: #23283c;
  374. cursor: pointer;
  375. &:hover {
  376. background: #e5eefe;
  377. }
  378. &.active {
  379. color: #4284f2;
  380. background: #e5eefe;
  381. }
  382. p {
  383. margin: 0;
  384. line-height: 27px;
  385. }
  386. img {
  387. position: absolute;
  388. top: 8px;
  389. left: 22px;
  390. width: 54px;
  391. height: 54px;
  392. background: #999;
  393. border: none;
  394. border-radius: 5px;
  395. }
  396. }
  397. }
  398. }
  399. .student-chart {
  400. .title {
  401. height: 54px;
  402. font-size: 18px;
  403. line-height: 54px;
  404. color: #23283c;
  405. }
  406. .box-card {
  407. box-sizing: border-box;
  408. height: 338px;
  409. overflow: hidden;
  410. background: #f3f6fd;
  411. border-radius: 20px;
  412. .info {
  413. height: 38px;
  414. font-size: 14px;
  415. line-height: 38px;
  416. color: #fff;
  417. text-align: center;
  418. background: #4284f2;
  419. &.legend {
  420. position: relative;
  421. box-sizing: border-box;
  422. padding-right: 180px;
  423. .tag {
  424. position: absolute;
  425. top: 0;
  426. right: 20px;
  427. white-space: nowrap;
  428. .t1::before,
  429. .t2::before {
  430. display: inline-block;
  431. width: 20px;
  432. height: 10px;
  433. margin: 0 4px 0 10px;
  434. content: "";
  435. }
  436. .t1::before {
  437. background: #f8b865;
  438. }
  439. .t2::before {
  440. background: #91cc75;
  441. }
  442. }
  443. }
  444. }
  445. }
  446. }
  447. .mobile {
  448. .student-search {
  449. width: 260px;
  450. .el-input {
  451. width: 140px;
  452. }
  453. }
  454. .evaluate-chart {
  455. padding-left: 270px;
  456. .el-col {
  457. margin-bottom: 10px;
  458. }
  459. }
  460. }
  461. </style>