You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

537 lines
11 KiB

9 months ago
9 months ago
9 months ago
9 months ago
  1. <script setup>
  2. import { ref } from 'vue';
  3. import ShowApi from '../api/ShowApi';
  4. import { format } from 'date-fns';
  5. //作业展示列表
  6. const works = ref([]);
  7. function loadWorks() {
  8. ShowApi.getWorks().then(result => {
  9. works.value = result.data;
  10. console.log("+++++++++++", works.value);
  11. works.value.forEach(work => {
  12. let date = work.endData;
  13. console.log(date);
  14. work.endData = format(new Date(date), 'yyyy-MM-dd');
  15. });
  16. console.log("后", works.value);
  17. })
  18. // works.value = [
  19. // {
  20. // id:1,
  21. // name:"作业一",
  22. // endData:"2024-09-10"
  23. // },
  24. // {
  25. // id:2,
  26. // name:"作业二",
  27. // endData:"2024-09-10"
  28. // }
  29. // ]
  30. }
  31. loadWorks();
  32. //跳转写作业页面
  33. function writeWorks(id){
  34. router.push({
  35. path:'/doWork',
  36. query:{
  37. id:id,
  38. }
  39. })
  40. }
  41. </script>
  42. <template>
  43. <div class="container">
  44. <div class="works">
  45. <div class="work-header">
  46. <img class="ketangzuoye" src="http://39.101.133.168:8857/LiveActivity/img/ketangzuoye.cc888815.png">
  47. <img class="book"
  48. src="https://img.js.design/assets/img/65f9235904fb00a3ea731672.png#dcda48ae8da37daeccd6583d45c7790b">
  49. </div>
  50. <div class="work-list">
  51. <div class="list" v-for="work in works">
  52. <div class="work-item">
  53. <div class="work-name">
  54. {{ work.name }}
  55. </div>
  56. <div class="work-content">
  57. <div class="work-time">
  58. <span class="deadline">截止时间{{ work.endData }}</span>
  59. <!-- 作业提价状态 -->
  60. <div class="work-status">未提交</div>
  61. </div>
  62. <div class="work-bottem">
  63. <span class="write" @click="writeWorks(work.id)">写作业</span>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </template>
  72. <style scoped>
  73. .container {
  74. width: 27%; /* 假设桌面布局的容器宽度为 80% */
  75. margin: 0 auto; /* 居中对齐 */
  76. }
  77. body{
  78. margin: 0;
  79. }
  80. .work-name {
  81. opacity: 1;
  82. /** 文本1 */
  83. font-size: 1.5vw;
  84. font-weight: 700;
  85. letter-spacing: 0px;
  86. color: rgba(53, 56, 112, 1);
  87. text-align: left;
  88. /*左对齐*/
  89. vertical-align: top;
  90. /* 这个属性在 Flex 容器中不起作用,将被移除 */
  91. display: flex;
  92. /* 启用 Flexbox 布局 */
  93. align-items: center;
  94. /* 垂直居中 */
  95. height: 30%;
  96. /* 设置高度,根据需要调整 */
  97. width: 50%;
  98. /* 如果需要,也可以设置宽度 */
  99. }
  100. .ketangzuoye {
  101. margin-top: 2vh;
  102. margin-left: 2vw;
  103. width: 43%;
  104. }
  105. .book {
  106. float: right;
  107. margin-right: 1vw;
  108. width: 30%;
  109. }
  110. /* 手机 */
  111. @media (max-width: 768px) {
  112. .container {
  113. width: 100%;
  114. margin: auto;
  115. }
  116. .works {
  117. /* ../api/ShowApi
  118. work\src\assets\bg@3x.png */
  119. background-image: url('../assets/bg.png');
  120. background-size: 100% 100%;
  121. background-color: #8f98f6;
  122. width: 100%;
  123. min-height: 100vh;
  124. position: relative;
  125. margin: auto;
  126. }
  127. .work-list {
  128. width: 95%;
  129. display: flex;
  130. justify-content: center;
  131. align-items: center;
  132. flex-direction: column;
  133. margin: auto;
  134. }
  135. .list {
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. width: 97%;
  140. height: 16vh;
  141. opacity: 1;
  142. border-radius: 10px;
  143. background-color: rgba(255, 225, 174, 1);
  144. margin-bottom: 3%;
  145. }
  146. .work-item {
  147. width: 87%;
  148. height: 63%;
  149. padding: 10px;
  150. position: relative;
  151. background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(250, 245, 235, 1) 100%);
  152. border-radius: 10px;
  153. border-radius: 10px;
  154. }
  155. .work-name {
  156. opacity: 1;
  157. /** 文本1 */
  158. font-size: 4vw;
  159. font-weight: 700;
  160. letter-spacing: 0px;
  161. color: rgba(53, 56, 112, 1);
  162. text-align: left;
  163. /*左对齐*/
  164. vertical-align: top;
  165. /* 这个属性在 Flex 容器中不起作用,将被移除 */
  166. display: flex;
  167. /* 启用 Flexbox 布局 */
  168. align-items: center;
  169. /* 垂直居中 */
  170. height: 30%;
  171. /* 设置高度,根据需要调整 */
  172. width: 50%;
  173. /* 如果需要,也可以设置宽度 */
  174. }
  175. .work-content {
  176. width: 95%;
  177. height: 35%;
  178. position: absolute;
  179. bottom: 10%;
  180. display: flex;
  181. }
  182. .work-time {
  183. position: absolute;
  184. display: flex;
  185. width: 70%;
  186. bottom: 12%;
  187. }
  188. .deadline {
  189. color: rgba(142, 142, 142, 1);
  190. font-size: 3.6vw;
  191. opacity: 1;
  192. align-items: center;
  193. padding-top: 0.5vw;
  194. /* 水平居中 */
  195. /* justify-content: center; */
  196. }
  197. .work-status {
  198. font-size: 3.8vw;
  199. display: inline-block;
  200. background: rgba(53, 56, 112, 0.1);
  201. padding: 1% 3.5%;
  202. text-align: center;
  203. color: #353870;
  204. border-radius: 5px;
  205. opacity: 2;
  206. margin-left: 5px;
  207. }
  208. .work-bottem {
  209. display: flex;
  210. position: absolute;
  211. width: 28%;
  212. height: 70%;
  213. right: 0;
  214. bottom: 2%;
  215. opacity: 1;
  216. border-radius: 50px;
  217. background: linear-gradient(270deg, rgba(4, 15, 179, 1) 0%, rgba(120, 89, 255, 1) 100%);
  218. border: 1px solid #a5e0f3;
  219. justify-content: center;
  220. /* 水平居中 */
  221. align-items: center;
  222. /* 垂直居中 */
  223. text-align: center;
  224. /* 确保文本在其容器内居中 */
  225. }
  226. .write {
  227. opacity: 1;
  228. /** 文本1 */
  229. padding: auto;
  230. font-size: 18px;
  231. font-weight: 700;
  232. letter-spacing: 0px;
  233. line-height: 26.06px;
  234. color: rgba(255, 255, 255, 1);
  235. }
  236. }
  237. /* 平板 */
  238. @media (min-width: 768px) and (max-width:1280px) {
  239. .container {
  240. width: 100%;
  241. margin: auto;
  242. }
  243. .works {
  244. /* ../api/ShowApi
  245. work\src\assets\bg@3x.png */
  246. background-image: url('../assets/bg@2x.png');
  247. background-color: #8f98f6;
  248. width: 100%;
  249. min-height: 100vh;
  250. position: relative;
  251. margin: auto;
  252. background-size: 100% 100%;
  253. }
  254. .work-list {
  255. width: 95%;
  256. display: flex;
  257. justify-content: center;
  258. align-items: center;
  259. flex-direction: column;
  260. margin: auto;
  261. }
  262. .list {
  263. display: flex;
  264. justify-content: center;
  265. align-items: center;
  266. width: 97%;
  267. height: 17vh;
  268. opacity: 1;
  269. border-radius: 10px;
  270. background-color: rgba(255, 225, 174, 1);
  271. margin-bottom: 3%;
  272. }
  273. .work-item {
  274. width: 90%;
  275. height: 70%;
  276. padding: 10px;
  277. position: relative;
  278. background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(250, 245, 235, 1) 100%);
  279. border-radius: 10px;
  280. border-radius: 10px;
  281. }
  282. .work-name {
  283. opacity: 1;
  284. /** 文本1 */
  285. font-size: 1.875rem;
  286. font-weight: 700;
  287. letter-spacing: 0px;
  288. color: rgba(53, 56, 112, 1);
  289. text-align: left;
  290. /*左对齐*/
  291. vertical-align: top;
  292. /* 这个属性在 Flex 容器中不起作用,将被移除 */
  293. display: flex;
  294. /* 启用 Flexbox 布局 */
  295. align-items: center;
  296. /* 垂直居中 */
  297. height: 30%;
  298. /* 设置高度,根据需要调整 */
  299. width: 50%;
  300. /* 如果需要,也可以设置宽度 */
  301. }
  302. .work-content {
  303. width: 90%;
  304. height: 35%;
  305. position: absolute;
  306. bottom: 10%;
  307. display: flex;
  308. }
  309. .work-time {
  310. position: absolute;
  311. display: flex;
  312. width: 70%;
  313. bottom: 20%;
  314. }
  315. .deadline {
  316. color: rgba(142, 142, 142, 1);
  317. font-size: 14px;
  318. opacity: 1;
  319. }
  320. .work-status {
  321. display: inline-block;
  322. background: rgba(53, 56, 112, 0.1);
  323. padding: 0.5% 2%;
  324. text-align: center;
  325. color: #353870;
  326. font-size: 1rem;
  327. border-radius: 5px;
  328. opacity: 2;
  329. margin-left: 5px;
  330. }
  331. .work-bottem {
  332. display: flex;
  333. position: absolute;
  334. width: 25%;
  335. height: 70%;
  336. right: 0%;
  337. bottom: 2%;
  338. opacity: 1;
  339. border-radius: 50px;
  340. background: linear-gradient(270deg, rgba(4, 15, 179, 1) 0%, rgba(120, 89, 255, 1) 100%);
  341. border: 1px solid #a5e0f3;
  342. justify-content: center;
  343. /* 水平居中 */
  344. align-items: center;
  345. /* 垂直居中 */
  346. text-align: center;
  347. /* 确保文本在其容器内居中 */
  348. }
  349. .write {
  350. opacity: 1;
  351. /** 文本1 */
  352. padding: auto;
  353. font-size: 1.125rem;
  354. font-weight: 700;
  355. letter-spacing: 0px;
  356. line-height: 26.06px;
  357. color: rgba(255, 255, 255, 1);
  358. }
  359. }
  360. /* 电脑 */
  361. @media (min-width: 1280px) {
  362. .container {
  363. width: 27%;
  364. margin: auto;
  365. }
  366. .works {
  367. /* ../api/ShowApi
  368. work\src\assets\bg@3x.png */
  369. background-image: url('../assets/bg@3x.png');
  370. background-color: #8f98f6;
  371. width: 100%;
  372. min-height: 100vh;
  373. position: relative;
  374. margin: auto;
  375. background-size: 100% 100%;
  376. }
  377. .work-name {
  378. opacity: 1;
  379. /** 文本1 */
  380. font-size: 1.5vw;
  381. font-weight: 700;
  382. letter-spacing: 0px;
  383. color: rgba(53, 56, 112, 1);
  384. text-align: left;
  385. /*左对齐*/
  386. vertical-align: top;
  387. /* 这个属性在 Flex 容器中不起作用,将被移除 */
  388. display: flex;
  389. /* 启用 Flexbox 布局 */
  390. align-items: center;
  391. /* 垂直居中 */
  392. height: 30%;
  393. /* 设置高度,根据需要调整 */
  394. width: 70%;
  395. }
  396. .work-list {
  397. width: 95%;
  398. display: flex;
  399. justify-content: center;
  400. align-items: center;
  401. flex-direction: column;
  402. margin: auto;
  403. }
  404. .list {
  405. display: flex;
  406. justify-content: center;
  407. align-items: center;
  408. width: 97%;
  409. height: 17vh;
  410. opacity: 1;
  411. border-radius: 10px;
  412. background-color: rgba(255, 225, 174, 1);
  413. margin-bottom: 3%;
  414. }
  415. .work-item {
  416. width: 90%;
  417. height: 70%;
  418. padding: 10px;
  419. position: relative;
  420. background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(250, 245, 235, 1) 100%);
  421. border-radius: 10px;
  422. border-radius: 10px;
  423. }
  424. .work-content {
  425. width: 90%;
  426. height: 35%;
  427. position: absolute;
  428. bottom: 10%;
  429. display: flex;
  430. }
  431. .work-time {
  432. position: absolute;
  433. display: flex;
  434. width: 70%;
  435. bottom: 15%;
  436. }
  437. .deadline {
  438. color: rgba(142, 142, 142, 1);
  439. font-size: 14px;
  440. opacity: 1;
  441. align-items: center;
  442. padding-top: 0.2vw;
  443. }
  444. .work-status {
  445. display: inline-block;
  446. background: rgba(53, 56, 112, 0.1);
  447. padding: 0.5% 2%;
  448. text-align: center;
  449. color: #353870;
  450. font-size: 1rem;
  451. border-radius: 5px;
  452. opacity: 2;
  453. margin-left: 5px;
  454. }
  455. .work-bottem {
  456. cursor: pointer;
  457. display: flex;
  458. position: absolute;
  459. width: 25%;
  460. height: 70%;
  461. right: 0%;
  462. bottom: 2%;
  463. opacity: 1;
  464. border-radius: 50px;
  465. background: linear-gradient(270deg, rgba(4, 15, 179, 1) 0%, rgba(120, 89, 255, 1) 100%);
  466. border: 1px solid #a5e0f3;
  467. justify-content: center;
  468. /* 水平居中 */
  469. align-items: center;
  470. /* 垂直居中 */
  471. text-align: center;
  472. /* 确保文本在其容器内居中 */
  473. }
  474. .write {
  475. opacity: 1;
  476. /** 文本1 */
  477. padding: auto;
  478. font-size: 1.125rem;
  479. font-weight: 700;
  480. letter-spacing: 0px;
  481. line-height: 26.06px;
  482. color: rgba(255, 255, 255, 1);
  483. }
  484. }
  485. .work-list{
  486. margin-top: 12%;
  487. }
  488. </style>