CompleteList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <el-dialog
  3. :class="['complete-list', { 'align-left': !isAlignCenter }]"
  4. :visible="dialogVisibleComplete"
  5. :width="dialogWidth + 'px'"
  6. :modal="false"
  7. :close-on-click-modal="false"
  8. @close="dialogCompleteClose"
  9. >
  10. <div slot="title" class="dialog-header">
  11. <span class="dialog-header-title">
  12. {{ $t('Key274') }} - {{ material_type === 'COURSEWARE' ? $t('Key309') : $t('Key244') }} - {{ material_name }}
  13. </span>
  14. <span @click="isAlignCenter = !isAlignCenter">
  15. <svg-icon :icon-class="isAlignCenter ? 'align-left' : 'align-center'" />
  16. </span>
  17. </div>
  18. <div class="complete-list-top">
  19. <div class="student-list">
  20. <i class="el-icon-arrow-left" @click="listMove('left')"></i>
  21. <div ref="avatar" class="avatar-list">
  22. <div ref="list" class="avatar-list-wrapper" :style="{ 'margin-left': marginLeft + 'px' }">
  23. <span
  24. v-for="item in student_list"
  25. :key="item.student_id"
  26. :class="{ active: curStudentID === item.student_id }"
  27. >
  28. <el-avatar
  29. icon="el-icon-user"
  30. :src="item.student_image_url"
  31. @click.native="getStudentExamAnswer_FinishMaterial(item.student_id, item.student_name)"
  32. />
  33. </span>
  34. </div>
  35. </div>
  36. <i class="el-icon-arrow-right" @click="listMove('right')"></i>
  37. </div>
  38. <div v-show="isStudent" class="answer-info">
  39. <span class="current-student-name">{{ curStudentName }}:</span>
  40. <template v-if="material_type === 'COURSEWARE'">
  41. <template v-if="category !== 'NPC'">
  42. <span>{{ $t('Key320') }}</span>
  43. <span class="answer-info-duration">{{ duration }}{{ $t('Key321') }}</span>
  44. </template>
  45. <span class="answer-info-label">{{ $t('Key194') }}</span>
  46. <span class="answer-info-count-right">{{ count_right }}</span>
  47. <span class="answer-info-label">{{ $t('Key195') }}</span>
  48. <span class="answer-info-count-error">{{ count_error }}</span>
  49. </template>
  50. </div>
  51. </div>
  52. <div class="complete-list-container">
  53. <template v-if="material_type === 'COURSEWARE'">
  54. <template v-if="category === 'NPC'">
  55. <booknpc
  56. v-if="context && refresh"
  57. task-model="ANSWER"
  58. :is-show-save="false"
  59. :book-answer-content="bookAnswerContent"
  60. :context="context"
  61. :theme-color="themeColor"
  62. :preview-type="previewType"
  63. :preview-group-id="courseware_group_id_selected_info"
  64. :current-tree-i-d="material_id"
  65. :submit-cn="$store.getters.submitCn"
  66. />
  67. </template>
  68. <template v-if="category === 'NNPE'">
  69. <booknnpe
  70. v-if="context && refresh"
  71. :context="context"
  72. :theme-color="themeColor"
  73. :is-show-title="true"
  74. task-model="ANSWER"
  75. :is-show-save="false"
  76. :book-answer-content="bookAnswerContent"
  77. :preview-type="previewType"
  78. :preview-group-id="courseware_group_id_selected_info"
  79. :current-tree-i-d="material_id"
  80. />
  81. </template>
  82. <template v-if="category === 'RLC'">
  83. <bookrlc
  84. v-if="context"
  85. :context="context"
  86. :theme-color="themeColor"
  87. :book-font-size="bookFontSize"
  88. :current-tree-i-d="material_id"
  89. :preview-type="previewType"
  90. :preview-group-id="courseware_group_id_selected_info"
  91. :is-show-title="false"
  92. task-model="ANSWER"
  93. :is-show-save="false"
  94. :book-answer-content="bookAnswerContent"
  95. />
  96. </template>
  97. <template v-if="category === 'NEW'">
  98. <BookNew
  99. v-if="context"
  100. ref="book"
  101. :context="context"
  102. :current-tree-i-d="material_id"
  103. task-model="ANSWER"
  104. :is-show-save="false"
  105. :book-answer-content="bookAnswerContent"
  106. />
  107. </template>
  108. </template>
  109. <template v-else>
  110. <div v-loading="file_loading">
  111. <iframe
  112. v-if="fileUrl.length > 0"
  113. id="iframe"
  114. :src="`${$store.state.app.config.doc_preview_service_address}/onlinePreview?url=${fileUrl}`"
  115. width="100%"
  116. height="540px"
  117. ></iframe>
  118. </div>
  119. </template>
  120. </div>
  121. <div slot="footer"></div>
  122. </el-dialog>
  123. </template>
  124. <script>
  125. import { GetCurMaterialSent, GetStudentList_FinishMaterial, GetStudentExamAnswer_FinishMaterial } from '@/api/live';
  126. import { GetCoursewareContent_View, GetMaterialInfo } from '@/api/course';
  127. import { GetFileStoreInfo, getContentFile } from '@/api/app';
  128. import { encode } from 'js-base64';
  129. export default {
  130. props: {
  131. dialogVisibleComplete: {
  132. default: false,
  133. type: Boolean
  134. },
  135. taskId: {
  136. default: '',
  137. type: String
  138. },
  139. materialId: {
  140. default: '',
  141. type: String
  142. },
  143. materialType: {
  144. default: '',
  145. type: String
  146. }
  147. },
  148. data() {
  149. return {
  150. material_id: '',
  151. material_name: '',
  152. material_type: '',
  153. material_picture_url: '',
  154. previewType: 'previewCheckShow',
  155. courseware_group_id_selected_info: '[]',
  156. context: null,
  157. category: '',
  158. themeColor: '',
  159. bookFontSize: '',
  160. dialogWidth: '900',
  161. bookAnswerContent: '',
  162. duration: 0,
  163. count_not_done: 0,
  164. count_right: 0,
  165. count_error: 0,
  166. file_loading: false,
  167. fileUrl: '',
  168. file_url_https: '',
  169. student_list: [],
  170. curStudentID: '',
  171. curStudentName: '',
  172. listTimer: null,
  173. marginLeft: 0,
  174. isAlignCenter: true,
  175. text: '',
  176. refresh: true
  177. };
  178. },
  179. computed: {
  180. fileType() {
  181. return this.file_url_https.slice(this.file_url_https.lastIndexOf('.') + 1, this.file_url_https.length);
  182. },
  183. isStudent() {
  184. return this.curStudentID.length > 0;
  185. }
  186. },
  187. watch: {
  188. dialogVisibleComplete(newVal) {
  189. if (newVal && this.materialId.length === 0) {
  190. this.getCurMaterialSent();
  191. }
  192. if (newVal && this.materialId.length > 0) {
  193. this.getMaterialInfo();
  194. }
  195. // 对话框,关闭时清理
  196. if (!newVal) {
  197. clearInterval(this.listTimer);
  198. this.material_id = '';
  199. this.fileUrl = '';
  200. this.material_name = '';
  201. this.student_list = [];
  202. this.marginLeft = 0;
  203. this.context = null;
  204. this.curStudentID = '';
  205. this.bookAnswerContent = '';
  206. this.text = '';
  207. }
  208. },
  209. material_id(newVal) {
  210. if (newVal) {
  211. this.listTimer = setInterval(() => {
  212. this.getStudentList_FinishMaterial();
  213. }, 3000);
  214. if (this.material_type === 'COURSEWARE') {
  215. this.getCoursewareContent_View();
  216. } else {
  217. this.getFileStoreInfo();
  218. }
  219. }
  220. }
  221. },
  222. methods: {
  223. getCurMaterialSent() {
  224. GetCurMaterialSent({ task_id: this.taskId }).then(
  225. ({ material_id, material_name, material_type, material_picture_url, courseware_group_id_selected_info }) => {
  226. if (material_id !== undefined && material_id.length > 0) {
  227. this.material_id = material_id;
  228. this.material_name = material_name;
  229. this.material_type = material_type;
  230. this.material_picture_url = material_picture_url;
  231. this.courseware_group_id_selected_info =
  232. courseware_group_id_selected_info.length <= 0 ? '[]' : courseware_group_id_selected_info;
  233. }
  234. }
  235. );
  236. },
  237. getMaterialInfo() {
  238. GetMaterialInfo({ task_id: this.taskId, material_id: this.materialId, material_type: this.materialType }).then(
  239. ({ material_id, material_name, material_type }) => {
  240. this.material_id = material_id;
  241. this.material_name = material_name;
  242. this.material_type = material_type;
  243. }
  244. );
  245. },
  246. getStudentList_FinishMaterial() {
  247. GetStudentList_FinishMaterial({
  248. task_id: this.taskId,
  249. material_id: this.material_id,
  250. material_type: this.material_type
  251. })
  252. .then(({ student_list }) => {
  253. this.student_list = student_list;
  254. })
  255. .catch(() => {
  256. clearInterval(this.listTimer);
  257. });
  258. },
  259. getCoursewareContent_View() {
  260. GetCoursewareContent_View({ id: this.material_id }).then(
  261. ({ content, category, book_theme_color, book_font_size }) => {
  262. if (!content) {
  263. this.context = null;
  264. return;
  265. }
  266. this.category = category;
  267. if (category === 'OC' || category.length === 0 || category === 'AILP') {
  268. return this.$message.warning('该课件类型已被废弃');
  269. }
  270. if (category === 'NPC') {
  271. this.themeColor = book_theme_color;
  272. this.dialogWidth = '920';
  273. this.context = JSON.parse(content);
  274. return;
  275. }
  276. if (category === 'NNPE') {
  277. this.dialogWidth = '920';
  278. this.themeColor = book_theme_color;
  279. this.context = JSON.parse(content);
  280. return;
  281. }
  282. if (category === 'RLC') {
  283. this.dialogWidth = '920';
  284. this.themeColor = book_theme_color;
  285. this.bookFontSize = book_font_size;
  286. this.context = JSON.parse(content);
  287. return;
  288. }
  289. if (category === 'NEW') {
  290. this.context = JSON.parse(content);
  291. return;
  292. }
  293. }
  294. );
  295. },
  296. getFileStoreInfo() {
  297. GetFileStoreInfo({ file_id: this.material_id }).then(({ file_url_https }) => {
  298. this.file_url_https = file_url_https;
  299. this.fileUrl = encodeURIComponent(encode(file_url_https));
  300. this.file_loading = true;
  301. this.$nextTick(() => {
  302. document.getElementById('iframe').onload = () => {
  303. this.file_loading = false;
  304. };
  305. });
  306. });
  307. },
  308. dialogCompleteClose() {
  309. this.$emit('dialogCompleteClose');
  310. },
  311. // 下载文件zip
  312. downloadBookWriteParent(idList) {
  313. getContentFile('file_store_manager-StartCreateFileCompressPack', {
  314. file_id_list: JSON.parse(idList)
  315. }).then((res) => {
  316. const id = res.file_compress_task_id;
  317. this.bookDownTimer = setInterval(() => {
  318. this.checkTaskProgress(id);
  319. }, 2000);
  320. });
  321. },
  322. listMove(direction) {
  323. const w = this.$refs.list.clientWidth - this.$refs.avatar.clientWidth;
  324. if (w > 60) {
  325. const left = Number(this.$refs.list.style['margin-left'].slice(0, -2));
  326. let width = direction === 'right' ? left - 60 : left + 60;
  327. if (Math.abs(width) > w) width = -w;
  328. this.marginLeft = width > 0 ? 0 : width;
  329. }
  330. },
  331. getStudentExamAnswer_FinishMaterial(student_id, student_name) {
  332. GetStudentExamAnswer_FinishMaterial({
  333. task_id: this.taskId,
  334. material_id: this.material_id,
  335. material_type: this.material_type,
  336. student_id
  337. }).then(({ content, duration, count_not_done, count_right, count_error }) => {
  338. this.bookAnswerContent = content;
  339. this.duration = duration;
  340. this.count_not_done = count_not_done;
  341. this.count_right = count_right;
  342. this.count_error = count_error;
  343. this.curStudentID = '';
  344. this.refresh = false;
  345. this.$nextTick(() => {
  346. this.refresh = true;
  347. this.curStudentID = student_id;
  348. });
  349. this.curStudentName = student_name;
  350. });
  351. }
  352. }
  353. };
  354. </script>
  355. <style lang="scss">
  356. @import '~@/styles/mixin';
  357. .complete-list {
  358. @include dialog;
  359. &.align-left {
  360. .el-dialog {
  361. margin-left: 20px;
  362. }
  363. }
  364. .el-dialog__header {
  365. .dialog-header {
  366. display: flex;
  367. justify-content: space-between;
  368. padding-right: 24px;
  369. &-title {
  370. font-size: 18px;
  371. font-weight: bold;
  372. line-height: 24px;
  373. }
  374. .svg-icon {
  375. cursor: pointer;
  376. }
  377. }
  378. }
  379. &-top {
  380. .student-list {
  381. display: flex;
  382. align-items: center;
  383. justify-content: space-between;
  384. height: 66px;
  385. margin-bottom: 12px;
  386. overflow: hidden;
  387. .avatar-list {
  388. width: calc(100% - 48px);
  389. height: 100%;
  390. overflow: hidden;
  391. &-wrapper {
  392. display: inline-block;
  393. white-space: nowrap;
  394. .active {
  395. position: relative;
  396. display: inline-block;
  397. width: 58px;
  398. &::after {
  399. position: absolute;
  400. top: 58px;
  401. left: 24px;
  402. display: inline-block;
  403. width: 8px;
  404. height: 8px;
  405. content: '';
  406. background-color: #2ece5b;
  407. border-radius: 50%;
  408. }
  409. }
  410. .el-avatar {
  411. margin: 0 9px;
  412. cursor: pointer;
  413. }
  414. }
  415. }
  416. > i {
  417. margin-top: -24px;
  418. font-size: 18px;
  419. cursor: pointer;
  420. }
  421. }
  422. .answer-info {
  423. display: flex;
  424. align-items: center;
  425. margin-bottom: 12px;
  426. font-size: 16px;
  427. .current-student-name {
  428. margin-right: 24px;
  429. font-weight: 700;
  430. }
  431. &-label {
  432. margin-left: 24px;
  433. }
  434. &-duration,
  435. &-count-right,
  436. &-count-error {
  437. min-width: 60px;
  438. padding: 0 24px;
  439. text-align: center;
  440. border-right: 2px solid #dfdfdf;
  441. }
  442. &-count-error {
  443. border-right-width: 0;
  444. }
  445. }
  446. }
  447. &-container {
  448. max-height: calc(55vh - 117px);
  449. overflow: auto;
  450. .el-image {
  451. width: 100%;
  452. height: calc(100% - 4px);
  453. }
  454. .audio-file {
  455. display: flex;
  456. justify-content: center;
  457. }
  458. .video-file {
  459. display: flex;
  460. justify-content: center;
  461. height: 100%;
  462. }
  463. .text-file {
  464. height: calc(55vh - 117px);
  465. .el-textarea,
  466. textarea {
  467. height: 100%;
  468. }
  469. }
  470. }
  471. }
  472. </style>