TaskList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div class="tasks">
  3. <div class="tasks-left">
  4. <!-- 菜单 -->
  5. <main-menu cur-tab="TaskList" />
  6. <!-- 日历 -->
  7. <monthly-calendar
  8. ref="calendar"
  9. :date-stamp="dateStamp"
  10. @changeTimeUnit="changeTimeUnit"
  11. @changeDate="changeDate"
  12. />
  13. <!-- 通知 -->
  14. <div class="notice">
  15. <div class="notice-title">
  16. <svg-icon icon-class="task-notification" class-name="svg-normal" />
  17. <span>{{ $t('Key291') }}</span>
  18. <span class="notice-title-link" @click="goPersonal">
  19. {{ $t('Key110') }}
  20. <i class="el-icon-arrow-right" />
  21. </span>
  22. </div>
  23. <!-- 通知列表 -->
  24. <div class="notice-container">
  25. <ul>
  26. <li v-for="{ id, is_read, content, send_time, source_entity_id, message_type } in message_list" :key="id">
  27. <span class="is-read" v-text="is_read === 'false' ? 'new' : ''" />
  28. <span
  29. class="notice-content"
  30. :style="{
  31. color: is_read === 'true' ? '#8c8c8c' : '#000',
  32. cursor: message_type === 201 ? 'text' : 'pointer'
  33. }"
  34. :title="content"
  35. @click="readMyMessage(id, source_entity_id, message_type)"
  36. >
  37. {{ content }}
  38. </span>
  39. <span class="send-time">{{ send_time }}</span>
  40. </li>
  41. </ul>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="tasks-right">
  46. <div class="task-title">
  47. <svg-icon icon-class="task-list" class-name="svg-normal" /><span class="task-title-name">
  48. {{ $t('Key278') }}
  49. </span>
  50. <div class="curricula-type">
  51. <span
  52. v-for="{ constant, name } in taskTimeList"
  53. :key="constant"
  54. :class="['curricula-type-item', timeType === constant ? 'active' : '']"
  55. @click="changeTaskTime(constant)"
  56. >
  57. {{ $t(name) }}
  58. </span>
  59. </div>
  60. <span class="select-prefix">
  61. <svg-icon icon-class="schedule" class-name="svg-normal" />
  62. </span>
  63. <el-select v-model="course_id" class="select-course" @change="changeCourse">
  64. <el-option :label="$t('Key110')" value="" />
  65. <el-option v-for="{ id, name } in course_list" :key="id" :label="name" :value="id" />
  66. </el-select>
  67. </div>
  68. <div class="task-container">
  69. <ul v-for="({ task_list, date_stamp }, i) in task_group_list" :key="i" class="task-list">
  70. <li v-if="time_unit === 'MONTH'" class="date-stamp">
  71. {{ date_stamp }}
  72. </li>
  73. <li
  74. v-for="{
  75. id,
  76. cs_item_name,
  77. time_type,
  78. course_id: cid,
  79. course_name,
  80. teaching_type,
  81. time_space_view_txt,
  82. name
  83. } in task_list"
  84. :key="id"
  85. class="task-item"
  86. :style="getItemStyle(cid)"
  87. @click="taskLink_outside(id)"
  88. >
  89. <div class="task-item-top">
  90. <svg-icon icon-class="arrival" :style="{ color: colorMatching[i % 7].main }" />
  91. <span class="cs-item-name">
  92. {{ cs_item_name }} - {{ name }}
  93. <span v-if="teaching_type === 10" class="enter-live" @click.stop="taskLink(teaching_type, id)">
  94. {{ $t('Key616') }} >
  95. </span>
  96. </span>
  97. <span
  98. class="task-button"
  99. :style="{ 'background-color': buttonColorList.get(time_type) }"
  100. @click.stop="taskLink(teaching_type, id)"
  101. >
  102. {{ $t(getTimeTypeName(time_type)) }}{{ $t('Key289') }}
  103. </span>
  104. </div>
  105. <div class="task-item-bottom">
  106. <div>
  107. {{ course_name }}
  108. </div>
  109. <div class="time-txt">
  110. {{ time_space_view_txt }}
  111. </div>
  112. </div>
  113. </li>
  114. </ul>
  115. </div>
  116. </div>
  117. </div>
  118. </template>
  119. <script>
  120. import MainMenu from './components/MainMenu.vue';
  121. import { PageQueryMyMessageList, GetMyTaskList } from '@/api/table';
  122. import { CreateEnterLiveRoomSession } from '@/api/live';
  123. import { ReadMyMessage, GetMyBookBuyStatus_CurTaskCoursewareBook } from '@/api/user';
  124. import { colorMatching, buttonColorList } from './data';
  125. import { taskTimeList } from '@/common/data';
  126. import { GetMyCourseList_TaskBelong } from '@/api/list';
  127. import MonthlyCalendar from './components/MonthlyCalendar.vue';
  128. export default {
  129. name: 'TaskList',
  130. components: {
  131. MonthlyCalendar,
  132. MainMenu
  133. },
  134. data() {
  135. const date = this.$route.query.dateStamp;
  136. return {
  137. dateStamp: date ? new Date(date) : undefined,
  138. colorMatching,
  139. buttonColorList,
  140. taskTimeList,
  141. course_id: '',
  142. selected: '',
  143. timeType: -1,
  144. task_group_list: [],
  145. message_list: [],
  146. course_list: [],
  147. // 课程 id 列表,用于颜色显示
  148. courseIdList: []
  149. };
  150. },
  151. computed: {
  152. time_unit() {
  153. return this.$refs.calendar.time_unit;
  154. }
  155. },
  156. created() {
  157. PageQueryMyMessageList({
  158. read_status: -1,
  159. message_type: -1,
  160. page_capacity: 5,
  161. cur_page: 1
  162. }).then(({ message_list }) => {
  163. this.message_list = message_list;
  164. });
  165. },
  166. mounted() {
  167. this.init();
  168. },
  169. methods: {
  170. getTimeTypeName(type) {
  171. if (type === 0) return 'Key292';
  172. if (type === 1) return 'Key293';
  173. if (type === 2) return 'Key294';
  174. return '';
  175. },
  176. getMyCourseList_TaskBelong() {
  177. const { curYear, curMonth, focusDate } = this.$refs.calendar;
  178. GetMyCourseList_TaskBelong({
  179. time_unit: this.time_unit,
  180. date_stamp: `${curYear}-${curMonth}-${focusDate}`,
  181. month_stamp: `${curYear}-${curMonth}`
  182. }).then(({ course_list }) => {
  183. this.course_list = course_list;
  184. });
  185. },
  186. getMyTaskList() {
  187. const { curYear, curMonth, focusDate } = this.$refs.calendar;
  188. GetMyTaskList({
  189. time_unit: this.time_unit,
  190. date_stamp: `${curYear}-${curMonth}-${focusDate}`,
  191. month_stamp: `${curYear}-${curMonth}`,
  192. time_type: this.timeType,
  193. course_id: this.course_id
  194. }).then(({ task_group_list }) => {
  195. this.task_group_list = task_group_list;
  196. });
  197. },
  198. // 改变任务时间类型
  199. changeTaskTime(constant) {
  200. this.timeType = constant;
  201. this.getMyTaskList();
  202. },
  203. changeTimeUnit() {
  204. this.init();
  205. },
  206. changeDate() {
  207. this.init();
  208. },
  209. init() {
  210. this.course_id = '';
  211. this.getMyTaskList();
  212. this.getMyCourseList_TaskBelong();
  213. },
  214. changeCourse() {
  215. this.getMyTaskList();
  216. },
  217. taskLink(type, task_id) {
  218. const userType = this.$store.state.user.user_type;
  219. GetMyBookBuyStatus_CurTaskCoursewareBook({ task_id }).then(({ is_buy_all }) => {
  220. if (is_buy_all === 'false' && userType === 'STUDENT') {
  221. return this.$message.warning(this.$i18n.t('Key635'));
  222. }
  223. if (type === 10) {
  224. CreateEnterLiveRoomSession({
  225. task_id
  226. }).then(({ live_room_sys_user_id, room_id, session_id, room_user_id }) => {
  227. this.$router.push({
  228. path: `/live/${userType === 'TEACHER' ? 'teacher' : 'student'}`,
  229. query: { live_room_sys_user_id, room_id, session_id, task_id, room_user_id }
  230. });
  231. });
  232. } else {
  233. this.$router.push(`/task_detail/${userType === 'STUDENT' ? 'student' : 'teacher'}/${task_id}`);
  234. }
  235. });
  236. },
  237. taskLink_outside(task_id) {
  238. GetMyBookBuyStatus_CurTaskCoursewareBook({ task_id }).then(({ is_buy_all }) => {
  239. const userType = this.$store.state.user.user_type;
  240. if (is_buy_all === 'false' && userType === 'STUDENT') {
  241. return this.$message.warning(this.$i18n.t('Key635'));
  242. }
  243. this.$router.push(`/task_detail/${userType === 'STUDENT' ? 'student' : 'teacher'}/${task_id}`);
  244. });
  245. },
  246. readMyMessage(id, source_entity_id, message_type) {
  247. if (message_type === 201) return;
  248. ReadMyMessage({ id }).then(() => {
  249. this.taskLink_outside(source_entity_id);
  250. });
  251. },
  252. getItemStyle(id) {
  253. if (!this.courseIdList.includes(id)) {
  254. this.courseIdList.push(id);
  255. }
  256. const i = this.courseIdList.indexOf(id) % 7;
  257. return {
  258. 'background-color': colorMatching[i].background,
  259. color: colorMatching[i].main,
  260. border: `1px solid ${colorMatching[i].border}`
  261. };
  262. },
  263. goPersonal() {
  264. window.location.href = `/GCLS-Personal/#/EnterSys`;
  265. }
  266. }
  267. };
  268. </script>
  269. <style lang="scss" scoped>
  270. .tasks {
  271. display: flex;
  272. &-left {
  273. width: 392px;
  274. margin-right: 16px;
  275. // 日历
  276. .monthly-calendar {
  277. min-height: 498px;
  278. padding: 32px;
  279. margin-bottom: 16px;
  280. background-color: #fff;
  281. border-radius: 8px;
  282. }
  283. .notice {
  284. height: calc(100vh - 705px);
  285. min-height: 424px;
  286. padding: 32px;
  287. line-height: 1.5;
  288. background: #fff;
  289. border-radius: 8px;
  290. &-title {
  291. display: flex;
  292. align-items: center;
  293. justify-content: space-between;
  294. cursor: pointer;
  295. > span:first-of-type {
  296. flex: 1;
  297. padding-left: 8px;
  298. }
  299. &-link {
  300. color: #bababa;
  301. }
  302. }
  303. &-container {
  304. height: 100%;
  305. overflow: auto;
  306. ul {
  307. margin-top: 16px;
  308. li {
  309. display: flex;
  310. padding: 8px 0;
  311. &:not(:first-child) {
  312. border-top: 1px solid $border-color;
  313. }
  314. .is-read {
  315. min-width: 48px;
  316. color: $basic-color;
  317. }
  318. .notice-content {
  319. position: relative;
  320. width: 230px;
  321. max-height: 3em;
  322. margin-right: 16px;
  323. overflow: hidden;
  324. word-break: break-all;
  325. // 多行文本隐藏
  326. &::after {
  327. position: absolute;
  328. top: 1.2em;
  329. right: 0;
  330. padding-left: 40px;
  331. font-size: 18px;
  332. content: '...';
  333. background: linear-gradient(to right, transparent, #fff 55%);
  334. }
  335. }
  336. .send-time {
  337. color: #8c8c8c;
  338. }
  339. }
  340. }
  341. }
  342. }
  343. }
  344. &-right {
  345. width: 802px;
  346. min-height: calc(100vh - 119px);
  347. padding: 16px 24px;
  348. background-color: #fff;
  349. border-radius: 8px;
  350. .task-title {
  351. display: flex;
  352. align-items: center;
  353. padding-bottom: 16px;
  354. border-bottom: 1px solid #d9d9d9;
  355. &-name {
  356. margin-left: 8px;
  357. font-weight: 600;
  358. }
  359. .curricula-type {
  360. display: flex;
  361. align-items: center;
  362. height: 40px;
  363. margin: 0 16px;
  364. color: #8c8c8c;
  365. background-color: $bac-color;
  366. border: 1px solid $border-color;
  367. border-radius: 8px;
  368. &-item {
  369. height: 100%;
  370. padding: 8px;
  371. line-height: 24px;
  372. cursor: pointer;
  373. &.active {
  374. color: #000;
  375. background-color: #fff;
  376. border-radius: 8px;
  377. box-shadow: 0 2px 4px $border-color;
  378. }
  379. }
  380. }
  381. .select-prefix {
  382. height: 40px;
  383. padding: 6px;
  384. margin-right: -1px;
  385. border: 1px solid $border-color;
  386. border-radius: 8px 0 0 8px;
  387. }
  388. .el-select {
  389. flex: 1;
  390. }
  391. }
  392. .task-container {
  393. min-height: calc(100% - 50px);
  394. .task-list {
  395. li.date-stamp {
  396. margin-top: 16px;
  397. margin-bottom: -8px;
  398. font-weight: 700;
  399. }
  400. .task-item {
  401. padding: 16px 24px;
  402. margin-top: 16px;
  403. cursor: pointer;
  404. border-radius: 8px;
  405. &-top {
  406. display: flex;
  407. margin-bottom: 8px;
  408. .cs-item-name {
  409. flex: 1;
  410. margin-left: 10px;
  411. .enter-live {
  412. margin-left: 12px;
  413. color: #808080;
  414. }
  415. }
  416. .task-button {
  417. padding: 4px 8px;
  418. color: #fff;
  419. border-radius: 8px;
  420. }
  421. }
  422. &-bottom {
  423. font-size: 14px;
  424. color: #808080;
  425. .time-txt {
  426. margin-top: 8px;
  427. color: #000;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. }
  434. }
  435. </style>
  436. <style lang="scss">
  437. .tasks {
  438. .el-select.select-course {
  439. .el-input__inner {
  440. border-top-left-radius: 0;
  441. border-bottom-left-radius: 0;
  442. }
  443. }
  444. }
  445. </style>