index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <div class="train">
  3. <Header @confirmExit="getExit" :showTool="false" closeClass="close2"></Header>
  4. <div class="main">
  5. <div class="left">
  6. <div class="title">
  7. <el-input class="myInput" :prefix-icon="Search" v-model="keywords" placeholder="搜索" clearable />
  8. </div>
  9. <ul>
  10. <li v-for="(item, index) in newTaskList" :key="index" :class="{ 'current': currentTask.id == item.id }"
  11. @click="clickTask(item)">{{ item.name
  12. }}</li>
  13. </ul>
  14. </div>
  15. <div class="menu" v-if="projectList.length"
  16. :class="{ 'menu1': projectList.length <= 10, 'menu2': projectList.length > 10, 'prohibit': !currentTask.id }">
  17. <swiper :slides-per-view="5" :modules="[Grid]" :grid="{
  18. fill: projectList.length <= 10 ? 'row' : 'column',
  19. rows: 2,
  20. }" :space-between="20" :slides-per-group="10">
  21. <swiper-slide v-for="(item, index) in projectList " :key="index" @click="getOption(item)">
  22. <div class="li">
  23. <div class="pic"><img :src="'static/images/train/' + item.key + '.png'"></div>
  24. <div class="name">
  25. {{ item.name }}
  26. </div>
  27. </div>
  28. </swiper-slide>
  29. </swiper>
  30. </div>
  31. </div>
  32. <OptionWindow ref="optionWindowRef" :projectList="projectList" :parentData="currentTask" />
  33. </div>
  34. </template>
  35. <script setup name="TrainIndex" lang="ts">
  36. import { Swiper, SwiperSlide } from 'swiper/vue';
  37. import { Grid } from 'swiper/modules';
  38. import { Search } from '@element-plus/icons-vue'
  39. import 'dayjs/locale/zh-cn'
  40. import dayjs from 'dayjs'
  41. import weekOfYear from 'dayjs/plugin/weekOfYear'
  42. import 'swiper/css';
  43. import 'swiper/css/grid';
  44. dayjs.locale('zh-cn')
  45. dayjs.extend(weekOfYear)
  46. const router = useRouter();
  47. const { proxy } = getCurrentInstance() as any;
  48. const optionWindowRef = ref();
  49. const data = reactive<any>({
  50. projectList: [],
  51. timerManager: {},
  52. keywords: '',
  53. taskList: [],
  54. currentTask: {},
  55. myProject: [],
  56. });
  57. const { projectList, timerManager, keywords, taskList, currentTask, myProject } = toRefs(data);
  58. /**
  59. * 点击课程
  60. */
  61. const clickTask = (data: any) => {
  62. currentTask.value = data
  63. getProjectTaskList()
  64. };
  65. /**
  66. * 获取测试项目
  67. */
  68. const getProjectTaskList = () => {
  69. let params = {
  70. exam_type: currentTask.value.exam_type,
  71. grade: currentTask.value.grade
  72. };
  73. proxy?.$http.test.getTaskProject(params).then((res: any) => {
  74. myProject.value = res.data;
  75. getExam();
  76. });
  77. };
  78. /**
  79. * 获取测试列表
  80. */
  81. const getTaskList = () => {
  82. let today = dayjs().format('YYYY-MM-DD')
  83. let params = {
  84. start_time: today
  85. };
  86. proxy?.$http.test.getTaskList(params).then((res: any) => {
  87. taskList.value = res.data;
  88. });
  89. };
  90. /**
  91. * 获取项目
  92. */
  93. const getExam = () => {
  94. let examList: any = []
  95. myProject.value.forEach((item: any) => {
  96. item.exams.forEach((items: any) => {
  97. examList.push(items[0]);
  98. })
  99. })
  100. proxy?.$http.train.projectList().then((res: any) => {
  101. projectList.value = proxy?.$utils.getProject(res.exams).filter((item: any) => {
  102. //只显示能开的
  103. if (currentTask.value.id) {
  104. return item.area.length > 0 && examList.includes(item.key);
  105. } else {
  106. return item.area.length
  107. }
  108. });
  109. });
  110. };
  111. /**
  112. * 弹出选项窗口
  113. */
  114. const getOption = (data: any) => {
  115. if (!currentTask.value.id) {
  116. proxy?.$modal.msgWarning(`请先选择左侧测试!`);
  117. return false;
  118. }
  119. optionWindowRef.value.open(data);
  120. };
  121. /**
  122. * 清空定时任务
  123. */
  124. const getClearTimer = () => {
  125. for (let key in timerManager.value) {
  126. if (timerManager.value.hasOwnProperty(key)) {
  127. clearInterval(timerManager.value[key])
  128. timerManager.value[key] = null;
  129. }
  130. }
  131. };
  132. /**
  133. * 初始化项目
  134. */
  135. const getInitExam = () => {
  136. getExam();
  137. //定时刷新
  138. timerManager.value.exam = setInterval(() => {
  139. getExam();
  140. }, 5000)
  141. };
  142. /**
  143. * 退出
  144. */
  145. const getExit = () => {
  146. router.go(-1);
  147. };
  148. /**
  149. * 新的测试列表
  150. */
  151. const newTaskList: any = computed(() => {
  152. let list = taskList.value.filter((item: any) => {
  153. return item.name.indexOf(keywords.value) != -1
  154. })
  155. return list;
  156. });
  157. onBeforeMount(() => {
  158. getTaskList();
  159. getInitExam();
  160. })
  161. onBeforeUnmount(() => {
  162. getClearTimer();
  163. })
  164. </script>
  165. <style lang="scss" scoped>
  166. $topPadding: 5.19rem;
  167. $waiPadding: 6.51rem;
  168. .main {
  169. width: calc(100% - ($waiPadding * 2));
  170. height: 72vh;
  171. padding-top: 10rem;
  172. margin: 0 auto;
  173. display: flex;
  174. justify-content: space-between;
  175. }
  176. .left {
  177. width: calc(23.4% - 20px);
  178. height: 72vh;
  179. display: flex;
  180. flex-direction: column;
  181. overflow: hidden;
  182. .title {
  183. height: 8.3vh;
  184. width: 100%;
  185. padding: 0 8%;
  186. box-sizing: border-box;
  187. display: flex;
  188. align-items: center;
  189. background: radial-gradient(120% 126% at 5% 93%, #8EFFA9 0%, #07FFE7 100%);
  190. border-top-left-radius: 1.6rem;
  191. border-top-right-radius: 1.6rem;
  192. ::v-deep(.myInput) {
  193. width: 100%;
  194. height: 4.5vh;
  195. .el-input__wrapper {
  196. border-radius: 2vh;
  197. box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.3);
  198. }
  199. }
  200. }
  201. ul {
  202. height: 100%;
  203. overflow-y: scroll;
  204. border: 1px solid #48677E;
  205. border-bottom-left-radius: 1.6rem;
  206. border-bottom-right-radius: 1.6rem;
  207. background: linear-gradient(27deg, #092941 -82%, #2A484B 94%);
  208. li {
  209. border-bottom: 1px solid #48677E;
  210. font-size: 1.6rem;
  211. color: #ffffff;
  212. padding: 1.6vh 0 1.6vh 2rem;
  213. cursor: pointer;
  214. transition: all 0.2s;
  215. &:hover {
  216. background: rgba(255, 255, 255, 0.2);
  217. }
  218. &:last-child {
  219. border-bottom: none;
  220. }
  221. }
  222. .current {
  223. background: rgba(255, 255, 255, 0.2);
  224. }
  225. &::-webkit-scrollbar {
  226. width: 0px;
  227. }
  228. &::-webkit-scrollbar-thumb {
  229. border-width: 2px;
  230. border-radius: 4px;
  231. border-style: dashed;
  232. border-color: transparent;
  233. background-color: rgba(216, 216, 216, 0.8);
  234. background-clip: padding-box;
  235. }
  236. &::-webkit-scrollbar-button:hover {
  237. border-radius: 6px;
  238. background: rgba(216, 216, 216, 0.8);
  239. }
  240. }
  241. }
  242. .menu {
  243. width: calc(100% - 23.4%);
  244. height: 72vh;
  245. .li {
  246. // width: calc((100% / 6) - 1rem + (1rem/6));
  247. // margin-right: 1rem;
  248. // margin-bottom: 1rem;
  249. width: 100%;
  250. height: calc((72vh / 2) - 10px);
  251. padding: 2.2vh 0;
  252. border-radius: 1.6rem;
  253. box-sizing: border-box;
  254. box-shadow: inset 0px 1px 0px 2px rgba(255, 255, 255, 0.9046), inset 0px 3px 6px 0px rgba(0, 0, 0, 0.0851);
  255. display: flex;
  256. flex-wrap: wrap;
  257. justify-content: center;
  258. text-align: center;
  259. flex-shrink: 0;
  260. cursor: pointer;
  261. .name {
  262. width: 100%;
  263. font-size: 2.48rem;
  264. color: #1A293A;
  265. padding: 0.5rem 0;
  266. }
  267. .pic {
  268. width: 11.36vw;
  269. height: 11.36vw;
  270. border-radius: 50%;
  271. background: radial-gradient(78% 78% at 53% 50%, #07121A 0%, #2A4256 49%, #5180A9 100%);
  272. box-shadow: 0px 0px 2px 2px #FFFFFF;
  273. margin-bottom: 2vh;
  274. overflow: hidden;
  275. display: flex;
  276. align-items: center;
  277. justify-content: center;
  278. flex-shrink: 0;
  279. img {
  280. max-width: 88%;
  281. max-height: 88%;
  282. transition: all 1s;
  283. }
  284. }
  285. &:hover {
  286. img {
  287. transform: translateY(-0.5vw);
  288. }
  289. }
  290. }
  291. .swiper-slide {
  292. border-radius: 1.6rem;
  293. overflow: hidden;
  294. }
  295. }
  296. .menu1 {
  297. .swiper-slide {
  298. margin-bottom: 20px;
  299. .li {
  300. background: radial-gradient(96% 96% at 2% 32%, #FFFFFF 0%, #FCFDFD 54%, #E1E4E7 100%);
  301. }
  302. &:nth-child(2),
  303. &:nth-child(4),
  304. &:nth-child(6),
  305. &:nth-child(7),
  306. &:nth-child(9),
  307. &:nth-child(11) {
  308. .li {
  309. background: radial-gradient(167% 126% at 97% 6%, #35FFC6 0%, #00FFE8 100%);
  310. }
  311. }
  312. }
  313. }
  314. .menu2 {
  315. display: flex;
  316. .swiper-slide {
  317. &:nth-child(1),
  318. &:nth-child(4),
  319. &:nth-child(5),
  320. &:nth-child(8),
  321. &:nth-child(9),
  322. &:nth-child(12),
  323. &:nth-child(13),
  324. &:nth-child(16),
  325. &:nth-child(17),
  326. &:nth-child(20),
  327. &:nth-child(21),
  328. &:nth-child(24),
  329. &:nth-child(25),
  330. &:nth-child(28),
  331. &:nth-child(29),
  332. &:nth-child(32),
  333. &:nth-child(33),
  334. &:nth-child(36),
  335. &:nth-child(37),
  336. &:nth-child(40),
  337. &:nth-child(41),
  338. &:nth-child(44) {
  339. .li {
  340. background: radial-gradient(96% 96% at 2% 32%, #FFFFFF 0%, #FCFDFD 54%, #E1E4E7 100%);
  341. }
  342. }
  343. &:nth-child(2),
  344. &:nth-child(3),
  345. &:nth-child(6),
  346. &:nth-child(7),
  347. &:nth-child(10),
  348. &:nth-child(11),
  349. &:nth-child(14),
  350. &:nth-child(15),
  351. &:nth-child(18),
  352. &:nth-child(19),
  353. &:nth-child(22),
  354. &:nth-child(23),
  355. &:nth-child(26),
  356. &:nth-child(27),
  357. &:nth-child(30),
  358. &:nth-child(31),
  359. &:nth-child(34),
  360. &:nth-child(35),
  361. &:nth-child(38),
  362. &:nth-child(39),
  363. &:nth-child(42),
  364. &:nth-child(43) {
  365. .li {
  366. background: radial-gradient(167% 126% at 97% 6%, #35FFC6 0%, #00FFE8 100%);
  367. }
  368. }
  369. }
  370. }
  371. .prohibit {
  372. opacity: 0.5;
  373. }
  374. ::v-deep(.menu) {
  375. .swiper-horizontal {
  376. width: 100%;
  377. }
  378. }
  379. @media screen and (max-width: 1450px) {
  380. .menu {
  381. .li {
  382. .name {
  383. font-size: 1.8rem;
  384. }
  385. .pic {
  386. width: 10vw;
  387. height: 10vw;
  388. }
  389. }
  390. }
  391. }
  392. </style>