TaskTop.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div class="task-detail-top">
  3. <div class="title">
  4. <span class="title-name">{{ itemInfo.course_name }}</span>
  5. <span class="title-time">{{ itemInfo.cs_item_time }}</span>
  6. </div>
  7. <div class="cs-item-box">
  8. <div class="cs_item_name">
  9. {{ itemInfo.cs_item_name }}
  10. </div>
  11. <div
  12. class="cs-status"
  13. :style="{ color: statusColor[itemInfo.finish_status].color }"
  14. v-if="itemInfo.finish_status || itemInfo.finish_status === 0"
  15. >
  16. <span class="cs-status-bg" :style="{ background: statusColor[itemInfo.finish_status].color }"></span>
  17. <span>{{ statusColor[itemInfo.finish_status].text }}</span>
  18. </div>
  19. </div>
  20. <div class="courseware-list">
  21. <template v-if="type === 'teacher'">
  22. <div class="task-name">{{ itemInfo.name }}</div>
  23. <div class="task-time">{{ itemInfo.time_space_view_txt }}</div>
  24. <div class="task-content" v-if="contentUrl">
  25. <span>{{ $t('Key371') }}</span>
  26. <!-- eslint-disable-next-line vue/no-v-html -->
  27. <span v-html="contentUrl"></span>
  28. </div>
  29. </template>
  30. <template v-if="!isExercises && itemInfo.courseware_list && itemInfo.courseware_list.length > 0">
  31. <div class="courseware-list-title">
  32. {{ $t('Key309') }}
  33. </div>
  34. <el-tag
  35. v-for="item in itemInfo.courseware_list"
  36. :key="item.courseware_id"
  37. color="#fff"
  38. :title="item.courseware_name"
  39. >
  40. <div class="courseware">
  41. <svg-icon icon-class="courseware" />
  42. <router-link
  43. target="_blank"
  44. :to="{
  45. path: `/task_detail/show_courseware/${item.courseware_id}?group_id_selected_info=${
  46. item.group_id_selected_info ? item.group_id_selected_info : '[]'
  47. }`
  48. }"
  49. class="courseware_name nowrap-ellipsis"
  50. >
  51. {{ item.courseware_name }}
  52. </router-link>
  53. </div>
  54. </el-tag>
  55. </template>
  56. </div>
  57. <div
  58. class="learning-material"
  59. v-if="itemInfo.cs_item_learning_material_list && itemInfo.cs_item_learning_material_list.length > 0"
  60. >
  61. <div class="learning-material-title">
  62. {{ isExercises && type === 'teacher' ? '练习任务' : $t('Key274') }}
  63. </div>
  64. <el-tag
  65. v-for="item in itemInfo.cs_item_learning_material_list"
  66. :key="item.file_id"
  67. color="#fff"
  68. :title="item.file_name"
  69. >
  70. <span @click="emitViewFile(item.file_name, item.file_id)">{{ item.file_name }}</span>
  71. </el-tag>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. export default {
  77. name: 'TaskTop'
  78. };
  79. </script>
  80. <script setup>
  81. import { computed } from 'vue';
  82. const props = defineProps({
  83. itemInfo: {
  84. type: Object,
  85. required: true
  86. },
  87. type: {
  88. type: String,
  89. required: true
  90. },
  91. isExercises: {
  92. type: Boolean,
  93. required: true
  94. }
  95. });
  96. let contentUrl = computed(() => {
  97. const content = props.itemInfo.content;
  98. if (!content) return '';
  99. return content.replace(
  100. new RegExp(/(https?:\/\/[\w-]+\.[\w-]+\.[\w-,@?^=%&:/~\\+#]+)/, 'g'),
  101. '<a href="$1" target="_blank">$1</a>'
  102. );
  103. });
  104. const emits = defineEmits(['viewFile']);
  105. function emitViewFile(fileName, fileId) {
  106. emits('viewFile', fileName, fileId);
  107. }
  108. const statusColor = {
  109. 0: { color: '#FF9900', text: '未开始' },
  110. 1: { color: '#3ACB85', text: '进行中' },
  111. 2: { color: '#FF1111', text: '已结束' }
  112. };
  113. </script>
  114. <style lang="scss" scoped>
  115. .task-detail-top {
  116. padding: 24px 40px;
  117. background-color: #fff;
  118. border-radius: 8px;
  119. .title {
  120. display: flex;
  121. align-items: center;
  122. justify-content: space-between;
  123. &-name {
  124. font-size: 24px;
  125. font-weight: 700;
  126. line-height: 36px;
  127. }
  128. &-time {
  129. color: #737373;
  130. }
  131. }
  132. .cs-item-box {
  133. display: flex;
  134. align-items: start;
  135. .cs-status {
  136. display: flex;
  137. column-gap: 8px;
  138. align-items: center;
  139. margin-top: 8px;
  140. font-size: 16px;
  141. font-weight: 400;
  142. line-height: 24px;
  143. &-bg {
  144. width: 8px;
  145. height: 8px;
  146. border-radius: 50%;
  147. }
  148. }
  149. }
  150. .cs_item_name {
  151. flex: 1;
  152. margin: 8px 0 24px;
  153. font-size: 16px;
  154. font-weight: 400;
  155. line-height: 24px;
  156. color: rgba(0, 0, 0, 50%);
  157. }
  158. .learning-material {
  159. margin-bottom: 16px;
  160. &-title {
  161. margin-bottom: 16px;
  162. font-size: 16px;
  163. font-weight: 400;
  164. line-height: 32px; /* 200% */
  165. color: #2c2c2c;
  166. }
  167. }
  168. .courseware-list {
  169. padding-top: 24px;
  170. margin-bottom: 16px;
  171. border-top: 1px solid #d9d9d9;
  172. .task-name {
  173. margin-bottom: 16px;
  174. font-size: 20px;
  175. font-weight: bold;
  176. line-height: 30px;
  177. }
  178. .task-time {
  179. margin-bottom: 16px;
  180. font-size: 16px;
  181. font-weight: 400;
  182. line-height: 24px; /* 150% */
  183. color: #2c2c2c;
  184. opacity: 0.5;
  185. }
  186. .task-content {
  187. display: flex;
  188. column-gap: 38px;
  189. margin-bottom: 16px;
  190. white-space: pre-wrap;
  191. :deep a {
  192. color: #18a0fb;
  193. }
  194. :first-child {
  195. min-width: 70px;
  196. font-size: 16px;
  197. font-weight: 400;
  198. line-height: 32px; /* 200% */
  199. color: #000;
  200. }
  201. :last-child {
  202. font-size: 16px;
  203. font-weight: 400;
  204. line-height: 32px; /* 200% */
  205. color: #000;
  206. word-break: break-all;
  207. }
  208. }
  209. &-title {
  210. margin-bottom: 16px;
  211. font-size: 16px;
  212. font-weight: 400;
  213. line-height: 32px; /* 200% */
  214. color: #2c2c2c;
  215. }
  216. .el-tag {
  217. cursor: pointer;
  218. .courseware {
  219. .svg-icon {
  220. margin-right: 12px;
  221. font-size: 18px;
  222. vertical-align: super;
  223. }
  224. &_name {
  225. display: inline-block;
  226. max-width: 120px;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. </style>