CreateTask.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <template>
  2. <div class="task">
  3. <step-bar :step-number="2" />
  4. <!-- 课程基本信息 -->
  5. <div class="task-course-info">
  6. <div class="cover"><el-image fit="contain" :src="picture_url" alt="封面" /></div>
  7. <div class="info">
  8. <div class="name">{{ name }}</div>
  9. <div class="date">{{ begin_date }}<span>-</span>{{ end_date }}</div>
  10. </div>
  11. </div>
  12. <!-- 按钮 -->
  13. <div class="task-button">
  14. <el-button class="prev-step" @click="preStep"><i class="el-icon-back" />选择教材</el-button>
  15. <el-button><router-link to="/create_course">关闭</router-link></el-button>
  16. </div>
  17. <!-- 任务课节 -->
  18. <div class="task-item">
  19. <!-- 课节列表 -->
  20. <div class="task-item-list">
  21. <template v-if="cs_item_list.length > 0">
  22. <div
  23. v-for="item in cs_item_list"
  24. :key="item.id"
  25. :class="['task-item-list-title', { selected: item.id === curItemID }]"
  26. @click="curItemID = item.id"
  27. >
  28. <span>{{ item.name }}</span>
  29. <!-- 课节下拉框 -->
  30. <el-dropdown placement="bottom" trigger="click" @command="handleCSItem">
  31. <i class="el-icon-more"></i>
  32. <el-dropdown-menu slot="dropdown">
  33. <el-dropdown-item class="dropdown-menu" :command="{ id: item.id, type: 'edit' }">
  34. <span>编辑</span><svg-icon icon-class="edit" />
  35. </el-dropdown-item>
  36. <el-dropdown-item class="dropdown-menu" :command="{ id: item.id, type: 'delete ' }">
  37. <span>删除</span><svg-icon icon-class="delete" />
  38. </el-dropdown-item>
  39. </el-dropdown-menu>
  40. </el-dropdown>
  41. </div>
  42. </template>
  43. <div v-else class="task-item-list-title">新课节</div>
  44. <el-button class="create-item selected" type="primary" @click="dialogVisible = true">
  45. <svg-icon icon-class="create-white" /> 创建新课节
  46. </el-button>
  47. </div>
  48. <!-- 课节信息 -->
  49. <div class="task-item-container">
  50. <div class="item-info">
  51. <div class="title">课节信息</div>
  52. <div class="item-info-name">
  53. <div>课节名称</div>
  54. <el-input v-model="itemInfoBox.name" readonly />
  55. </div>
  56. <div class="item-info-date">
  57. <div>时间</div>
  58. <el-date-picker
  59. v-model="itemInfoBox.date"
  60. readonly
  61. type="datetimerange"
  62. range-separator="~"
  63. value-format="yyyy-MM-dd HH:mm:ss"
  64. unlink-panels
  65. />
  66. </div>
  67. </div>
  68. <div class="item-task">
  69. <div class="title">
  70. <span class="number-tag">{{ taskLength }}</span>
  71. <span>课节任务</span>
  72. </div>
  73. <div class="item-task-pre task-container">
  74. <!-- 课前任务 -->
  75. <div class="item-task-pre-title">
  76. <span class="number-tag pre">{{ itemInfoBox.pre_task_list.length }}</span>
  77. <span>课前任务</span>
  78. </div>
  79. <div class="item-task-pre-list item-task-list">
  80. <el-card v-for="(item, i) in itemInfoBox.pre_task_list" :key="item.id">
  81. <el-collapse>
  82. <el-collapse-item>
  83. <template slot="title">
  84. <div class="card-title">
  85. <div class="name">{{ i + 1 }}. {{ item.name }}</div>
  86. <div class="info">
  87. {{ item.time_space_view_txt }}
  88. <!-- 任务下拉框 -->
  89. <el-dropdown placement="bottom" @command="handleTask">
  90. <i class="el-icon-more"></i>
  91. <el-dropdown-menu slot="dropdown">
  92. <el-dropdown-item
  93. class="dropdown-menu"
  94. :command="{ id: item.id, type: 'edit', time_type: 0 }"
  95. >
  96. <span>编辑</span><svg-icon icon-class="edit" />
  97. </el-dropdown-item>
  98. </el-dropdown-menu>
  99. </el-dropdown>
  100. </div>
  101. </div>
  102. </template>
  103. <div class="task-info">
  104. <div>
  105. <span class="label">要求</span>
  106. <div>{{ item.content }}</div>
  107. </div>
  108. <div>
  109. <span class="label">课件</span>
  110. <div>
  111. <el-tag
  112. v-for="li in item.courseware_list"
  113. :key="li.courseware_id"
  114. color="#fff"
  115. >
  116. {{ li.courseware_name }}
  117. </el-tag>
  118. </div>
  119. </div>
  120. <div>
  121. <span class="label">其他文件</span>
  122. <div>
  123. <el-tag v-for="li in item.accessory_list" :key="li.file_id" color="#fff">
  124. <a target="_blank" :href="li.file_url">
  125. {{ li.file_name }} {{ li.file_url }}
  126. </a>
  127. </el-tag>
  128. </div>
  129. </div>
  130. </div>
  131. </el-collapse-item>
  132. </el-collapse>
  133. </el-card>
  134. <el-button @click="newTask(0)"><i class="el-icon-plus" /> 新建任务</el-button>
  135. </div>
  136. </div>
  137. <!-- 课中任务 -->
  138. <div class="item-task-mid task-container">
  139. <div class="item-task-mid-title">
  140. <span class="number-tag mid">{{ itemInfoBox.mid_task_list.length }}</span>
  141. <span>课中任务</span>
  142. </div>
  143. <div class="item-task-mid-list item-task-list">
  144. <el-card v-for="(item, i) in itemInfoBox.mid_task_list" :key="item.id">
  145. <el-collapse>
  146. <el-collapse-item>
  147. <template slot="title">
  148. <div class="card-title">
  149. <div class="name">
  150. {{ itemInfoBox.pre_task_list.length + i + 1 }}. {{ item.name }}
  151. </div>
  152. <div class="info">
  153. {{ item.time_space_view_txt }}
  154. <el-dropdown placement="bottom" @command="handleTask">
  155. <i class="el-icon-more"></i>
  156. <el-dropdown-menu slot="dropdown">
  157. <el-dropdown-item
  158. class="dropdown-menu"
  159. :command="{ id: item.id, type: 'edit', time_type: 1 }"
  160. >
  161. <span>编辑</span><svg-icon icon-class="edit" />
  162. </el-dropdown-item>
  163. </el-dropdown-menu>
  164. </el-dropdown>
  165. </div>
  166. </div>
  167. </template>
  168. <div class="task-info">
  169. <div>
  170. <span class="label">要求</span>
  171. <div>{{ item.content }}</div>
  172. </div>
  173. <div>
  174. <span class="label">课件</span>
  175. <div>
  176. <el-tag
  177. v-for="li in item.courseware_list"
  178. :key="li.courseware_id"
  179. color="#fff"
  180. >
  181. {{ li.courseware_name }}
  182. </el-tag>
  183. </div>
  184. </div>
  185. <div>
  186. <span class="label">其他文件</span>
  187. <div>
  188. <el-tag v-for="li in item.accessory_list" :key="li.file_id" color="#fff">
  189. <a target="_blank" :href="li.file_url">
  190. {{ li.file_name }} {{ li.file_url }}
  191. </a>
  192. </el-tag>
  193. </div>
  194. </div>
  195. </div>
  196. </el-collapse-item>
  197. </el-collapse>
  198. </el-card>
  199. <el-button @click="newTask(1)"><i class="el-icon-plus" /> 新建任务</el-button>
  200. </div>
  201. </div>
  202. <!-- 课后任务 -->
  203. <div class="item-task-after task-container">
  204. <div class="item-task-after-title">
  205. <span class="number-tag after">{{ itemInfoBox.after_task_list.length }}</span>
  206. <span>课后任务</span>
  207. </div>
  208. <div class="item-task-after-list item-task-list">
  209. <el-card v-for="(item, i) in itemInfoBox.after_task_list" :key="item.id">
  210. <el-collapse>
  211. <el-collapse-item>
  212. <template slot="title">
  213. <div class="card-title">
  214. <div class="name">
  215. {{
  216. itemInfoBox.pre_task_list.length +
  217. itemInfoBox.mid_task_list.length +
  218. i +
  219. 1
  220. }}. {{ item.name }}
  221. </div>
  222. <div class="info">
  223. {{ item.time_space_view_txt }}
  224. <el-dropdown placement="bottom" @command="handleTask">
  225. <i class="el-icon-more"></i>
  226. <el-dropdown-menu slot="dropdown">
  227. <el-dropdown-item
  228. class="dropdown-menu"
  229. :command="{ id: item.id, type: 'edit', time_type: 2 }"
  230. >
  231. <span>编辑</span><svg-icon icon-class="edit" />
  232. </el-dropdown-item>
  233. </el-dropdown-menu>
  234. </el-dropdown>
  235. </div>
  236. </div>
  237. </template>
  238. <div class="task-info">
  239. <div>
  240. <span class="label">要求</span>
  241. <div>{{ item.content }}</div>
  242. </div>
  243. <div>
  244. <span class="label">课件</span>
  245. <div>
  246. <el-tag
  247. v-for="li in item.courseware_list"
  248. :key="li.courseware_id"
  249. color="#fff"
  250. >
  251. {{ li.courseware_name }}
  252. </el-tag>
  253. </div>
  254. </div>
  255. <div>
  256. <span class="label">其他文件</span>
  257. <div>
  258. <el-tag v-for="li in item.accessory_list" :key="li.file_id" color="#fff">
  259. <a target="_blank" :href="li.file_url">
  260. {{ li.file_name }} {{ li.file_url }}
  261. </a>
  262. </el-tag>
  263. </div>
  264. </div>
  265. </div>
  266. </el-collapse-item>
  267. </el-collapse>
  268. </el-card>
  269. <el-button @click="newTask(2)"><i class="el-icon-plus" /> 新建任务</el-button>
  270. </div>
  271. </div>
  272. </div>
  273. <div class="learning-materials">
  274. <div class="title">学习资料</div>
  275. <div>
  276. <el-button><svg-icon icon-class="upload" /> 上传文件</el-button>
  277. </div>
  278. </div>
  279. </div>
  280. </div>
  281. <!-- 课节弹出页 -->
  282. <add-item
  283. :id="itemId"
  284. :course-id="id"
  285. :type="type"
  286. :dialog-visible="dialogVisible"
  287. @dialogClose="dialogClose"
  288. @dialogConfirm="dialogConfirm"
  289. />
  290. </div>
  291. </template>
  292. <script>
  293. import StepBar from '@/components/StepBar';
  294. import AddItem from './AddItem.vue';
  295. import { GetCourseInfo_ContainCSItem, GetCSItemInfoBox, DeleteCSItem } from '@/api/course';
  296. export default {
  297. name: 'CreateTask',
  298. components: {
  299. StepBar,
  300. AddItem
  301. },
  302. data() {
  303. return {
  304. id: this.$route.params.id,
  305. name: '',
  306. picture_url: '',
  307. begin_date: '',
  308. end_date: '',
  309. cs_item_list: [],
  310. curItemID: '',
  311. dialogVisible: false,
  312. type: 'add',
  313. itemId: '',
  314. itemInfoBox: {
  315. name: '',
  316. date: [],
  317. pre_task_list: [],
  318. mid_task_list: [],
  319. after_task_list: [],
  320. learning_material_list: []
  321. }
  322. };
  323. },
  324. computed: {
  325. taskLength: function () {
  326. return (
  327. this.itemInfoBox.pre_task_list.length +
  328. this.itemInfoBox.mid_task_list.length +
  329. this.itemInfoBox.after_task_list.length
  330. );
  331. }
  332. },
  333. watch: {
  334. curItemID: function () {
  335. this.getCSItemInfoBox();
  336. }
  337. },
  338. created() {
  339. this.getCourseInfo();
  340. },
  341. methods: {
  342. getCourseInfo() {
  343. GetCourseInfo_ContainCSItem({ id: this.id }).then(
  344. ({ name, picture_url, begin_date, end_date, cs_item_list }) => {
  345. this.name = name;
  346. this.picture_url = picture_url;
  347. this.begin_date = begin_date;
  348. this.end_date = end_date;
  349. this.cs_item_list = cs_item_list;
  350. if (cs_item_list.length > 0) {
  351. this.curItemID = cs_item_list[cs_item_list.length - 1].id;
  352. }
  353. }
  354. );
  355. },
  356. preStep() {
  357. this.$router.push({ path: `/create_course_step_table/select_book/${this.id}` });
  358. },
  359. // 课节处理
  360. handleCSItem({ id, type }) {
  361. if (type === 'delete') {
  362. this.$confirm('您确定要删除该课节吗?', '提示', {
  363. confirmButtonText: '确定',
  364. cancelButtonText: '取消',
  365. type: 'warning'
  366. }).then(() => {
  367. DeleteCSItem({ id }).then(() => {
  368. this.$message.success('删除课节成功!');
  369. this.getCourseInfo();
  370. });
  371. });
  372. }
  373. if (type === 'edit') {
  374. this.dialogVisible = true;
  375. this.itemId = id;
  376. this.type = 'edit';
  377. }
  378. },
  379. dialogConfirm(type) {
  380. this.dialogVisible = false;
  381. this.type = 'add';
  382. if (type === 'add') {
  383. this.getCourseInfo();
  384. } else {
  385. this.getCSItemInfoBox();
  386. }
  387. },
  388. dialogClose() {
  389. this.dialogVisible = false;
  390. this.type = 'add';
  391. },
  392. getCSItemInfoBox() {
  393. GetCSItemInfoBox({ id: this.curItemID }).then(
  394. ({ name, begin_time, end_time, pre_task_list, mid_task_list, after_task_list }) => {
  395. this.itemInfoBox.name = name;
  396. this.itemInfoBox.date = [begin_time, end_time];
  397. this.itemInfoBox.pre_task_list = pre_task_list;
  398. this.itemInfoBox.mid_task_list = mid_task_list;
  399. this.itemInfoBox.after_task_list = after_task_list;
  400. }
  401. );
  402. },
  403. // 任务处理
  404. newTask(time_type) {
  405. if (!this.curItemID) {
  406. this.$message.warning('请先创建新课节');
  407. return;
  408. }
  409. this.$router.push({
  410. path: `/create_course_step_table/new_task/${time_type}/${this.id}/${this.curItemID}`
  411. });
  412. },
  413. handleTask({ id, type, time_type }) {
  414. if (type === 'edit') {
  415. this.$router.push({
  416. path: `/create_course_step_table/new_task/${time_type}/${this.id}/${this.curItemID}`,
  417. query: {
  418. task_id: id
  419. }
  420. });
  421. }
  422. }
  423. }
  424. };
  425. </script>
  426. <style lang="scss">
  427. @import '~@/styles/mixin.scss';
  428. .task {
  429. @include container;
  430. margin-top: $step-h;
  431. // 上部的课程信息
  432. &-course-info {
  433. display: flex;
  434. width: 100%;
  435. height: 120px;
  436. background-color: #fff;
  437. border-radius: 8px;
  438. .cover {
  439. width: 192px;
  440. height: 100%;
  441. border-right: 1px solid #e5e5e5;
  442. .el-image {
  443. width: 100%;
  444. height: 100%;
  445. }
  446. }
  447. .info {
  448. padding: 26px 32px;
  449. .name {
  450. font-size: 24px;
  451. }
  452. .date {
  453. color: #6b6b6b;
  454. font-size: 14px;
  455. margin-top: 16px;
  456. span {
  457. margin: 0 24px;
  458. }
  459. }
  460. }
  461. }
  462. // 中间的按钮
  463. &-button {
  464. margin: 16px 0;
  465. display: flex;
  466. justify-content: flex-end;
  467. .el-button + .el-button {
  468. margin-left: 16px;
  469. }
  470. .prev-step .el-icon-back {
  471. margin-right: 12px;
  472. }
  473. .preserve .svg-icon {
  474. margin-right: 8px;
  475. }
  476. }
  477. // 下部的课节
  478. &-item {
  479. display: flex;
  480. align-items: stretch;
  481. border-radius: 8px;
  482. &-list {
  483. flex: 3;
  484. background-color: #eee;
  485. &-title {
  486. display: flex;
  487. justify-content: space-between;
  488. padding: 16px 24px;
  489. height: 56px;
  490. line-height: 24px;
  491. background-color: #eee;
  492. cursor: pointer;
  493. &.selected {
  494. background-color: #fff;
  495. }
  496. }
  497. .create-item {
  498. margin: 24px;
  499. font-size: 16px;
  500. padding: 11px 20px;
  501. width: calc(100% - 48px);
  502. }
  503. }
  504. &-container {
  505. flex: 7;
  506. background-color: #fff;
  507. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  508. .learning-materials {
  509. padding: 24px 32px;
  510. .title {
  511. font-size: 18px;
  512. font-weight: 700;
  513. margin-bottom: 24px;
  514. }
  515. }
  516. .item-info {
  517. @extend .learning-materials;
  518. border-bottom: 1px solid #d9d9d9;
  519. &-name,
  520. &-date {
  521. display: flex;
  522. margin-top: 16px;
  523. > :first-child {
  524. width: 110px;
  525. min-width: 120px;
  526. line-height: 40px;
  527. }
  528. .el-input {
  529. width: 600px;
  530. }
  531. }
  532. }
  533. // 课节任务
  534. .item-task {
  535. @extend .learning-materials;
  536. border-bottom: 1px solid #d9d9d9;
  537. .title {
  538. margin-bottom: 24px;
  539. }
  540. .number-tag {
  541. display: inline-block;
  542. vertical-align: bottom;
  543. line-height: 0;
  544. padding: 12px 9px;
  545. margin-right: 8px;
  546. font-size: 12px;
  547. background-color: #000;
  548. color: #fff;
  549. border-radius: 50%;
  550. }
  551. .task-container {
  552. .number-tag {
  553. padding: 10px 7px;
  554. }
  555. .item-task-list {
  556. .el-card {
  557. border-radius: 8px;
  558. margin-bottom: 16px;
  559. .card-title {
  560. display: flex;
  561. justify-content: space-between;
  562. width: 100%;
  563. .name {
  564. font-weight: 600;
  565. }
  566. .info {
  567. color: #929292;
  568. .el-dropdown {
  569. margin-left: 16px;
  570. }
  571. }
  572. }
  573. }
  574. .el-card,
  575. .el-collapse-item__wrap {
  576. background-color: #f7f7f7;
  577. .el-collapse-item__content {
  578. padding: 15px 24px 9px;
  579. background-color: #fff;
  580. color: #000;
  581. .task-info > div {
  582. display: flex;
  583. align-items: center;
  584. padding: 8px 0;
  585. span.label {
  586. width: 80px;
  587. min-width: 80px;
  588. margin-right: 16px;
  589. }
  590. .el-tag {
  591. max-width: 275px;
  592. border-color: #dbdbdb;
  593. margin-right: 16px;
  594. color: #000;
  595. overflow: hidden;
  596. text-overflow: ellipsis;
  597. white-space: nowrap;
  598. }
  599. }
  600. }
  601. }
  602. .el-card.is-always-shadow,
  603. .el-card.is-hover-shadow:focus,
  604. .el-card.is-hover-shadow:hover {
  605. box-shadow: 0 0;
  606. }
  607. .el-card__body {
  608. padding: 0;
  609. background-color: #f7f7f7;
  610. .el-collapse-item__header {
  611. height: 22px;
  612. line-height: 22px;
  613. background-color: #f9f9f9;
  614. border-bottom-width: 0;
  615. .el-collapse-item__arrow {
  616. display: none;
  617. }
  618. &.focusing:focus:not(:hover) {
  619. color: #000;
  620. }
  621. }
  622. .el-collapse-item > div:first-child {
  623. background-color: #f9f9f9;
  624. border-bottom: 1px solid #e7e7e7;
  625. padding: 10px 20px;
  626. }
  627. }
  628. }
  629. }
  630. // 课前任务
  631. &-pre {
  632. &-title {
  633. .pre {
  634. background-color: #4a99ea;
  635. }
  636. }
  637. &-list {
  638. margin: 16px 9px;
  639. border-left: 2px solid #4a99ea;
  640. padding-left: 19px;
  641. }
  642. }
  643. // 课中任务
  644. &-mid {
  645. &-title {
  646. .mid {
  647. background-color: $basicColor;
  648. }
  649. }
  650. &-list {
  651. margin: 16px 9px;
  652. border-left: 2px solid $basicColor;
  653. padding-left: 19px;
  654. }
  655. }
  656. // 课后任务
  657. &-after {
  658. &-title {
  659. .after {
  660. background-color: #2ece5b;
  661. }
  662. }
  663. &-list {
  664. margin: 16px 9px;
  665. border-left: 2px solid #2ece5b;
  666. padding-left: 19px;
  667. }
  668. }
  669. }
  670. }
  671. }
  672. }
  673. .el-dropdown-menu {
  674. padding: 1px;
  675. .dropdown-menu {
  676. width: 128px;
  677. display: flex;
  678. justify-content: space-between;
  679. align-items: center;
  680. }
  681. }
  682. </style>