index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <div v-loading="loading" class="task-detail">
  3. <task-top :item-info="itemInfo" @viewFile="viewFile" />
  4. <div class="task-detail-main">
  5. <div class="time-type">{{ timeType }}任务 {{ name }}</div>
  6. <div class="time-interval">{{ time_space_view_txt }}</div>
  7. <div class="task-require"><span class="label">任务要求</span>{{ content }}</div>
  8. <div class="task-courseware">
  9. <span class="label">课件任务</span>
  10. <div>
  11. <el-tag
  12. v-for="item in courseware_list"
  13. :key="item.courseware_id"
  14. color="#fff"
  15. :title="item.courseware_name"
  16. @click="finishTask(item.courseware_id, item.is_finished)"
  17. >
  18. <svg-icon icon-class="courseware" /> <span>{{ item.courseware_name }}</span>
  19. <svg-icon v-if="item.is_finished === 'true'" class="check-mark" icon-class="check-mark" />
  20. </el-tag>
  21. </div>
  22. </div>
  23. <div class="accessory-list">
  24. <span class="label">文档列表</span>
  25. <div>
  26. <el-tag v-for="item in accessory_list" :key="item.file_id" color="#fff" :title="item.file_name">
  27. <span @click="viewFile(item.file_name, item.file_id)">{{ item.file_name }}</span>
  28. </el-tag>
  29. </div>
  30. </div>
  31. <!-- 完成评价 -->
  32. <template v-if="my_execute_info.is_finished === 'true'">
  33. <div class="teacher-commenting">
  34. <div class="single-line">
  35. <span class="label">作业</span>
  36. <div>
  37. <el-tag
  38. v-for="item in my_execute_info.homework_list"
  39. :key="item.file_id"
  40. color="#fff"
  41. :title="item.file_name"
  42. >
  43. <span @click="viewFile(item.file_name, item.file_id)">{{ item.file_name }}</span>
  44. </el-tag>
  45. </div>
  46. </div>
  47. <div v-if="teaching_type === 10" class="single-line">
  48. <span class="label">学员课后评价</span>
  49. <el-input v-model="my_execute_info.student_remark" disabled type="textarea" resize="none" :rows="6" />
  50. </div>
  51. <div v-if="teaching_type === 10" class="single-line">
  52. <span class="label">学员课后评分</span>
  53. <el-rate v-model="my_execute_info.student_score" disabled />
  54. </div>
  55. <div class="single-line">
  56. <span class="label">给教师留言</span>
  57. <el-input v-model="my_execute_info.student_message" disabled type="textarea" resize="none" :rows="6" />
  58. </div>
  59. <div class="single-line">
  60. <span class="label">教师点评</span>
  61. <el-rate v-model="my_execute_info.teacher_score" disabled />
  62. <span class="teacher_remark">{{ my_execute_info.teacher_remark }}</span>
  63. </div>
  64. </div>
  65. </template>
  66. <!-- 直播评价 -->
  67. <template v-else-if="teaching_type === 10">
  68. <div class="live-info">
  69. <div class="single-line">
  70. <span class="enter-live" @click="enterLive"><svg-icon icon-class="video-red" /> 点击进入直播间</span>
  71. </div>
  72. <div class="single-line">
  73. <span class="label">学员课后评价</span>
  74. <el-input v-model="student_remark" type="textarea" resize="none" :rows="6" />
  75. </div>
  76. <div class="single-line">
  77. <span class="label">学员课后评分</span>
  78. <el-rate v-model="student_score" />
  79. </div>
  80. <div class="confirm single-line">
  81. <el-button type="primary" @click="fillTaskExecuteInfo_Student_live">提交</el-button>
  82. </div>
  83. </div>
  84. </template>
  85. <template v-else>
  86. <div class="submit-homework">
  87. <span class="label">提交作业</span>
  88. <el-upload action="no" :http-request="upload" multiple :show-file-list="false">
  89. <el-button><svg-icon icon-class="upload" /> 上传文件</el-button>
  90. </el-upload>
  91. </div>
  92. <div class="file-list">
  93. <el-tag
  94. v-for="(item, i) in file_list"
  95. :key="item.file_id"
  96. color="#fff"
  97. closable
  98. :title="item.file_name"
  99. @close="deleteFile(i)"
  100. >
  101. <span>{{ item.file_name }}</span>
  102. </el-tag>
  103. </div>
  104. <div class="leave-message">
  105. <span class="label">给教师留言</span>
  106. <el-input v-model="student_message" type="textarea" resize="none" :rows="6" />
  107. </div>
  108. <div class="submit-button">
  109. <el-button type="primary" @click="fillTaskExecuteInfo_Student">完成任务</el-button>
  110. </div>
  111. </template>
  112. </div>
  113. <completion-view
  114. :task-id="id"
  115. :cur-student-id="$store.state.user.user_code"
  116. :cur-courseware-id="curCoursewareId"
  117. :dialog-visible="dialogVisible_completion"
  118. @dialogClose="dialogClose_completion"
  119. />
  120. <finish-courseware
  121. :id="id"
  122. :courseware-id="coursewareId"
  123. :dialog-visible="dialogVisible"
  124. @dialogClose="dialogClose"
  125. />
  126. <show-file
  127. ref="file"
  128. :file-name="showCurFileName"
  129. :file-id="showCurFileId"
  130. @dialogShowFileClose="dialogShowFileClose"
  131. />
  132. </div>
  133. </template>
  134. <script>
  135. import TaskTop from '../TaskTop.vue';
  136. import FinishCourseware from '@/components/course/FinishCourseware.vue';
  137. import CompletionView from '@/components/course/CompletionView.vue';
  138. import ShowFile from '@/common/show_file';
  139. import { fileUpload, FileDownload } from '@/api/app';
  140. import { CreateEnterLiveRoomSession } from '@/api/live';
  141. import { GetTaskInfo, FillMyTaskExecuteInfo_Student } from '@/api/course';
  142. import { isAllowFileType } from '@/utils/validate';
  143. export default {
  144. components: {
  145. FinishCourseware,
  146. TaskTop,
  147. CompletionView,
  148. ShowFile
  149. },
  150. data() {
  151. return {
  152. // 任务 ID
  153. id: this.$route.params.id,
  154. itemInfo: {
  155. course_name: '',
  156. cs_item_name: '',
  157. cs_item_learning_material_list: [],
  158. time_space_view_txt: ''
  159. },
  160. student_message: '',
  161. name: '',
  162. teaching_type: '',
  163. time_type: '',
  164. content: '',
  165. task_mode: '',
  166. time_space_view_txt: '',
  167. courseware_list: [],
  168. accessory_list: [],
  169. file_list: [],
  170. dialogVisible: false,
  171. coursewareId: '',
  172. curCoursewareId: '',
  173. dialogVisible_completion: false,
  174. my_execute_info: {},
  175. student_remark: '',
  176. student_score: 0,
  177. loading: false,
  178. showCurFileName: '',
  179. showCurFileId: ''
  180. };
  181. },
  182. computed: {
  183. timeType() {
  184. switch (this.time_type) {
  185. case 0:
  186. return '课前';
  187. case 1:
  188. return '课中';
  189. case 2:
  190. return '课后';
  191. default:
  192. return '';
  193. }
  194. }
  195. },
  196. created() {
  197. this.loading = true;
  198. GetTaskInfo({
  199. id: this.id,
  200. is_contain_cs_item_learning_material: true,
  201. is_contain_my_execute_info: true
  202. })
  203. .then(
  204. ({
  205. name,
  206. teaching_type,
  207. time_type,
  208. course_name,
  209. cs_item_name,
  210. courseware_list,
  211. accessory_list,
  212. cs_item_learning_material_list,
  213. task_mode,
  214. content,
  215. time_space_view_txt,
  216. my_execute_info
  217. }) => {
  218. this.itemInfo = {
  219. time_space_view_txt,
  220. course_name,
  221. cs_item_name,
  222. cs_item_learning_material_list
  223. };
  224. this.name = name;
  225. this.content = content;
  226. this.teaching_type = teaching_type;
  227. this.time_type = time_type;
  228. this.courseware_list = courseware_list;
  229. this.accessory_list = accessory_list;
  230. this.task_mode = task_mode;
  231. this.time_space_view_txt = time_space_view_txt;
  232. this.my_execute_info = my_execute_info;
  233. }
  234. )
  235. .finally(() => {
  236. this.loading = false;
  237. });
  238. },
  239. methods: {
  240. upload(file) {
  241. let fileName = file.file.name;
  242. if (!isAllowFileType(fileName)) {
  243. this.$message.warning(`文件:【${fileName}】文件类型,不允许上传`);
  244. return;
  245. }
  246. fileUpload('Open', file).then(({ file_info_list }) => {
  247. if (file_info_list.length > 0) {
  248. let { file_id, file_name, file_url } = file_info_list[0];
  249. this.file_list.push({ file_id, file_name, file_url });
  250. }
  251. });
  252. },
  253. deleteFile(i) {
  254. this.file_list.splice(i, 1);
  255. },
  256. download(FileID) {
  257. FileDownload(FileID).then(data => {
  258. console.log(data);
  259. });
  260. },
  261. viewFile(fileName, fileId) {
  262. this.showCurFileName = fileName;
  263. this.showCurFileId = fileId;
  264. this.$refs.file.showDialog();
  265. },
  266. dialogShowFileClose() {
  267. this.showCurFileName = '';
  268. this.showCurFileId = '';
  269. },
  270. fillTaskExecuteInfo_Student() {
  271. let homework_file_id_list = [];
  272. this.file_list.forEach(item => {
  273. homework_file_id_list.push(item.file_id);
  274. });
  275. FillMyTaskExecuteInfo_Student({
  276. task_id: this.id,
  277. homework_file_id_list,
  278. student_message: this.student_message,
  279. is_finished: true
  280. }).then(() => {
  281. this.$message.success('任务完成成功');
  282. this.$router.go(0);
  283. });
  284. },
  285. fillTaskExecuteInfo_Student_live() {
  286. FillMyTaskExecuteInfo_Student({
  287. task_id: this.id,
  288. is_finished: true,
  289. student_remark: this.student_remark,
  290. student_score: this.student_score
  291. }).then(() => {
  292. this.$message.success('提交成功');
  293. this.$router.go(0);
  294. });
  295. },
  296. enterLive() {
  297. CreateEnterLiveRoomSession({
  298. task_id: this.id
  299. }).then(({ live_room_sys_user_id, room_id, session_id, room_user_id }) => {
  300. this.$router.push({
  301. path: `/live/student`,
  302. query: { live_room_sys_user_id, room_id, session_id, task_id: this.id, room_user_id }
  303. });
  304. });
  305. },
  306. // 完成任务
  307. finishTask(id, is_finished) {
  308. if (this.my_execute_info.is_finished === 'true' && is_finished === 'false') {
  309. return this.$message.warning('该课件没有被完成');
  310. }
  311. if (is_finished === 'true') {
  312. this.dialogVisible_completion = true;
  313. this.curCoursewareId = id;
  314. } else {
  315. this.dialogVisible = true;
  316. this.coursewareId = id;
  317. }
  318. },
  319. dialogClose() {
  320. this.dialogVisible = false;
  321. this.coursewareId = '';
  322. },
  323. dialogClose_completion() {
  324. this.dialogVisible_completion = false;
  325. this.curCoursewareId = '';
  326. }
  327. }
  328. };
  329. </script>
  330. <style lang="scss">
  331. @import '~@/styles/mixin';
  332. $bor-color: #d9d9d9;
  333. .task-detail {
  334. @include container;
  335. min-height: calc(100vh - 130px);
  336. margin-top: 56px;
  337. .el-tag {
  338. @include el-tag;
  339. margin: 0 8px 6px 0;
  340. border-color: $bor-color;
  341. border-radius: 4px;
  342. > span {
  343. cursor: pointer;
  344. }
  345. }
  346. &-main {
  347. padding: 24px 32px;
  348. margin-top: 16px;
  349. background-color: #fff;
  350. border-radius: 8px;
  351. .time-type {
  352. font-size: 20px;
  353. font-weight: 500;
  354. }
  355. .time-interval {
  356. padding: 16px 0;
  357. color: #737373;
  358. }
  359. %submit-homework,
  360. .submit-homework {
  361. display: flex;
  362. align-items: center;
  363. padding-top: 24px;
  364. border-top: 1px solid $bor-color;
  365. }
  366. %teacher-commenting,
  367. .teacher-commenting {
  368. @extend %submit-homework;
  369. flex-direction: column;
  370. > .single-line {
  371. display: flex;
  372. width: 100%;
  373. + div {
  374. margin-top: 24px;
  375. }
  376. .teacher_remark {
  377. margin-left: 24px;
  378. }
  379. }
  380. }
  381. .live-info {
  382. @extend %teacher-commenting;
  383. .enter-live {
  384. padding: 8px 26px;
  385. color: #ff6868;
  386. cursor: pointer;
  387. border: 1px solid #ff6868;
  388. border-radius: 20px;
  389. }
  390. .confirm {
  391. padding-left: 120px;
  392. }
  393. }
  394. .file-list {
  395. padding-left: 120px;
  396. margin-bottom: 16px;
  397. > .el-tag {
  398. padding: 0 10px;
  399. color: #409eff;
  400. border-color: #d9ecff;
  401. }
  402. }
  403. .leave-message {
  404. display: flex;
  405. align-items: flex-start;
  406. .label {
  407. margin-top: 8px;
  408. }
  409. }
  410. .task-courseware .el-tag {
  411. cursor: pointer;
  412. .svg-icon {
  413. margin-right: 8px;
  414. font-size: 18px;
  415. }
  416. .check-mark {
  417. position: relative;
  418. top: 2px;
  419. right: -20px;
  420. margin-left: 12px;
  421. }
  422. }
  423. .task-require,
  424. .task-courseware,
  425. .accessory-list,
  426. .submit-homework,
  427. .leave-message,
  428. .live-info,
  429. .teacher-commenting {
  430. display: flex;
  431. margin-bottom: 16px;
  432. .label {
  433. display: inline-block;
  434. width: 120px;
  435. min-width: 120px;
  436. }
  437. }
  438. .submit-button {
  439. padding-left: 120px;
  440. }
  441. }
  442. }
  443. </style>