courseDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <template>
  2. <div class="pb_content">
  3. <div class="pb_content_body" style="height: 100%">
  4. <div class="body_student">
  5. <div class="student_head">
  6. <div
  7. class="return"
  8. @click.stop="
  9. goTo(
  10. '/index?userid=' +
  11. userid +
  12. '&oid=' +
  13. oid +
  14. '&cid=' +
  15. classId +
  16. '&tType=' +
  17. tType +
  18. '&screenType=' +
  19. screenType
  20. )
  21. "
  22. >
  23. 返回
  24. <!-- <img src="../assets/icon/return.png" alt="" /> -->
  25. </div>
  26. <div class="box_course">
  27. <div class="wheel">
  28. <img
  29. style="object-fit: contain"
  30. :src="
  31. this.courseDetail.cover != null &&
  32. this.courseDetail.cover != ''
  33. ? JSON.parse(this.courseDetail.cover).length > 0
  34. ? JSON.parse(this.courseDetail.cover)[0].url
  35. : mr
  36. : mr
  37. "
  38. alt
  39. />
  40. </div>
  41. <div class="right_box">
  42. <div class="rightT">
  43. <div class="right_box_title">{{ courseDetail.title }}</div>
  44. <div class="jd">{{ chapInfo.length }}阶段</div>
  45. <div class="jd">{{ rw }}任务</div>
  46. </div>
  47. <div class="cType">
  48. <div
  49. class="all_choose"
  50. v-for="(item, index) in courseType"
  51. :key="index"
  52. >
  53. <span style="color: #6c6c6c">{{ item + ":" }}</span>
  54. <span
  55. class="type_children"
  56. v-for="(item2, index2) in courseTypeJson[item]"
  57. :key="index2"
  58. >{{ item2 }}</span
  59. >
  60. </div>
  61. </div>
  62. <div class="cType" style="font-size: 18px; color: #6c6c6c">
  63. <div>
  64. 创建者:<span style="color: #000">{{
  65. courseDetail.username
  66. }}</span>
  67. </div>
  68. <div class="Tname" v-if="Tname.length > 0">
  69. 协同人员:<span
  70. v-for="(tname, tIndex) in Tname"
  71. :key="tIndex"
  72. style="margin: 0 5px; color: #000"
  73. >{{ tname }}</span
  74. >
  75. </div>
  76. </div>
  77. <div class="people">
  78. <div class="man">
  79. <img src="../assets/people.png" alt />
  80. </div>
  81. <div class="person">
  82. {{ courseDetail.vcount != null ? courseDetail.vcount : 0 }}人
  83. </div>
  84. </div>
  85. <div class="now_study" @click="dialogVisible = true">
  86. 立即学习
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="student_body">
  92. <div class="sLeft" v-if="courseDetail.brief">
  93. <div class="courseT">项目详情</div>
  94. <div class="courseTd">{{ courseDetail.brief }}</div>
  95. </div>
  96. <div :class="courseDetail.brief != '' ? 'rightTd' : 'noBRight'">
  97. <div
  98. class="blue_box_one"
  99. v-for="(item, index) in chapInfo"
  100. :key="index"
  101. @click="addUserRate(index)"
  102. >
  103. <div>第{{ index + 1 }}阶段</div>
  104. <div :title="item.dyName">{{ item.dyName }}</div>
  105. <div>{{ item.chapterInfo[0].taskJson.length }}个任务</div>
  106. </div>
  107. </div>
  108. </div>
  109. <!-- <div
  110. style="
  111. text-align: center;
  112. padding: 30px 0 20px 0;
  113. box-sizing: border-box;
  114. "
  115. >
  116. 此处滚动加载..
  117. </div>-->
  118. <el-dialog
  119. title="阶段选择"
  120. :visible.sync="dialogVisible"
  121. :append-to-body="true"
  122. width="700px"
  123. :before-close="handleClose"
  124. class="dialog_change"
  125. >
  126. <div style="font-size: 20px">请选择阶段</div>
  127. <div
  128. style="
  129. padding: 20px 30px;
  130. display: flex;
  131. flex-direction: row;
  132. flex-wrap: wrap;
  133. "
  134. >
  135. <div
  136. class="blue_box"
  137. v-for="(item, index) in chapInfo"
  138. :key="index"
  139. @click="addUserRate(index)"
  140. >
  141. <div>第{{ index + 1 }}阶段</div>
  142. <div>{{ item.dyName }}</div>
  143. <div>{{ item.chapterInfo[0].taskJson.length }}个任务</div>
  144. </div>
  145. </div>
  146. </el-dialog>
  147. </div>
  148. </div>
  149. </div>
  150. </template>
  151. <script>
  152. export default {
  153. data() {
  154. return {
  155. choose: 0,
  156. dialogVisible: false,
  157. id: this.$route.query.courseId,
  158. userid: this.$route.query.userid,
  159. oid: this.$route.query.oid,
  160. classId: this.$route.query.cid,
  161. tType: this.$route.query.tType,
  162. screenType: this.$route.query.screenType,
  163. courseDetail: {},
  164. aStudentName: [],
  165. chapInfo: [],
  166. courseType: [],
  167. Tname: [],
  168. courseTypeJson: {},
  169. userinfo: [],
  170. mr: require("../assets/icon/wheel.png"),
  171. rw:0,
  172. };
  173. },
  174. methods: {
  175. handleClose(done) {
  176. done();
  177. },
  178. goTo(path) {
  179. this.$router.push(path);
  180. },
  181. addUserRate(i) {
  182. // var suid = this.userid;
  183. // if (
  184. // JSON.parse(this.courseDetail.course_student).indexOf(suid) == -1 &&
  185. // JSON.parse(this.courseDetail.userid) != suid
  186. // ) {
  187. // this.$message.error("你没有该权限");
  188. // return;
  189. // }
  190. // var a =
  191. // this.courseDetail.course_student != ""
  192. // ? JSON.parse(this.courseDetail.course_student)
  193. // : "";
  194. // if (this.courseDetail.userid != suid) {
  195. // if (this.userinfo.type == 2) {
  196. // if (a != "") {
  197. // if (
  198. // JSON.parse(this.courseDetail.course_student).indexOf(suid) == -1
  199. // ) {
  200. // this.$message.error("你没有该权限");
  201. // return;
  202. // }
  203. // } else {
  204. // this.$message.error("暂无项目学员,请联系老师添加项目学员!");
  205. // return;
  206. // }
  207. // }
  208. // }
  209. let params = {
  210. uid: this.userid,
  211. cid: this.id,
  212. };
  213. this.ajax
  214. .get(this.$store.state.api + "addUserR", params)
  215. .then((res) => {
  216. console.log(res.data);
  217. this.updateVc();
  218. this.goTo(
  219. "/study?type=" +
  220. i +
  221. "&courseId=" +
  222. this.id +
  223. "&userid=" +
  224. this.userid +
  225. "&oid=" +
  226. this.oid +
  227. "&cid=" +
  228. this.classId +
  229. "&tType=" +
  230. this.tType +
  231. "&screenType=" +
  232. this.screenType
  233. );
  234. })
  235. .catch((err) => {
  236. console.error(err);
  237. });
  238. },
  239. updateVc() {
  240. let params = {
  241. cid: this.id,
  242. };
  243. this.ajax
  244. .get(this.$store.state.api + "updateVc", params)
  245. .then((res) => {
  246. console.log(res.data);
  247. })
  248. .catch((err) => {
  249. console.error(err);
  250. });
  251. },
  252. getCourseDetail() {
  253. const loading = this.$loading.service({
  254. background: "rgba(255, 255, 255, 0.7)",
  255. target: document.querySelector(".student_table"),
  256. });
  257. let params = {
  258. courseId: this.id,
  259. };
  260. this.ajax
  261. .get(this.$store.state.api + "selectCourseDetail", params)
  262. .then((res) => {
  263. loading.close();
  264. // this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  265. this.courseDetail = res.data[0][0];
  266. var a = res.data[0];
  267. var b = res.data[1];
  268. var c = res.data[2];
  269. for (var i = 0; i < b.length; i++) {
  270. // if (!this.id) {
  271. // this.courseType[b[i].id] = [];
  272. // }
  273. for (var j = 0; j < a.length; j++) {
  274. if (b[i].id == a[j].pid) {
  275. if (!this.courseTypeJson[b[i].name]) {
  276. this.courseType.push(b[i].name);
  277. this.courseTypeJson[b[i].name] = [];
  278. }
  279. this.courseTypeJson[b[i].name].push(a[j].name);
  280. }
  281. }
  282. }
  283. for (var k = 0; k < c.length; k++) {
  284. this.Tname.push(c[k].name);
  285. }
  286. console.log(this.courseTypeJson.length);
  287. this.aStudentName = res.data[2];
  288. this.chapInfo = JSON.parse(this.courseDetail.chapters);
  289. for(var z = 0;z<this.chapInfo.length;z++){
  290. this.rw += this.chapInfo[z].chapterInfo[0].taskJson.length;
  291. }
  292. })
  293. .catch((err) => {
  294. loading.close();
  295. console.error(err);
  296. });
  297. },
  298. getUser() {
  299. let params = { uid: this.userid };
  300. this.ajax
  301. .get(this.$store.state.api + "getUser", params)
  302. .then((res) => {
  303. this.userinfo = res.data[0][0];
  304. })
  305. .catch((err) => {
  306. console.error(err);
  307. });
  308. },
  309. // getSName() {
  310. // let params = {
  311. // uid: JSON.stringify(this.courseDetail.course_student),
  312. // };
  313. // this.ajax
  314. // .get(this.$store.state.api + "selectSName", params)
  315. // .then((res) => {
  316. // this.aStudentName = res.data[0];
  317. // })
  318. // .catch((err) => {
  319. // console.error(err);
  320. // });
  321. // },
  322. },
  323. created() {
  324. this.getCourseDetail();
  325. this.getUser();
  326. document.scrollingElement.scrollTop = 0;
  327. // this.getSName();
  328. },
  329. };
  330. </script>
  331. <style scoped>
  332. .body_student {
  333. margin: 10px auto;
  334. width: 98%;
  335. height: 100%;
  336. }
  337. .student_head {
  338. width: 100%;
  339. background: #fff;
  340. height: 30%;
  341. position: relative;
  342. }
  343. .wheel {
  344. width: 250px;
  345. max-height: 146px;
  346. display: flex;
  347. align-items: center;
  348. }
  349. .man {
  350. width: 16px;
  351. height: 16px;
  352. }
  353. .wheel > img,
  354. .man > img {
  355. width: 100%;
  356. height: 100%;
  357. }
  358. .box_course {
  359. display: flex;
  360. padding: 25px 0 20px 60px;
  361. }
  362. .right_box {
  363. display: flex;
  364. flex-direction: column;
  365. margin-left: 30px;
  366. align-items: flex-start;
  367. }
  368. .right_box_title {
  369. font-size: 23px;
  370. }
  371. .people {
  372. display: flex;
  373. margin-top: 20px;
  374. }
  375. .person {
  376. margin-left: 10px;
  377. line-height: 18px;
  378. }
  379. .now_study {
  380. width: 150px;
  381. height: 35px;
  382. color: #fff;
  383. background: #4a9eed;
  384. text-align: center;
  385. line-height: 35px;
  386. border-radius: 5px;
  387. font-size: 13px;
  388. cursor: pointer;
  389. margin-top: 30px;
  390. }
  391. .choose_who {
  392. display: flex;
  393. margin: 15px 0 0 25px;
  394. }
  395. .who_choose {
  396. height: 28px;
  397. cursor: pointer;
  398. }
  399. .choose_who > div:nth-child(2) {
  400. margin-left: 35px;
  401. }
  402. .choose {
  403. border-bottom: 5px solid #4a9eed;
  404. color: #4a9eed;
  405. }
  406. .student_body {
  407. display: flex;
  408. }
  409. .student_body,
  410. .right {
  411. width: 100%;
  412. margin: 10px auto;
  413. min-height: 688px;
  414. }
  415. .nav {
  416. margin: auto 25px;
  417. width: 80%;
  418. padding-top: 5px;
  419. text-indent: 25px;
  420. }
  421. .pic {
  422. width: 100%;
  423. display: flex;
  424. flex-direction: row;
  425. flex-wrap: wrap;
  426. height: 100%;
  427. justify-content: space-evenly;
  428. }
  429. .Img {
  430. /*width: 30%; */
  431. width: 300px;
  432. margin: 20px 50px;
  433. margin: 20px 10px;
  434. border: 1px solid #dbdbdb;
  435. border-radius: 5px;
  436. overflow: hidden;
  437. }
  438. .Img > img {
  439. width: 100%;
  440. height: 100%;
  441. }
  442. .student_body_one,
  443. .right_one {
  444. width: 100%;
  445. margin: 0 auto;
  446. background: #fff;
  447. margin-top: 10px;
  448. min-height: 688px;
  449. }
  450. .student {
  451. width: 85%;
  452. display: flex;
  453. flex-direction: row;
  454. flex-wrap: wrap;
  455. justify-content: flex-start;
  456. margin: auto 10px;
  457. }
  458. .student > div {
  459. width: 12%;
  460. height: 35px;
  461. background: #e3759a;
  462. text-align: center;
  463. border: 1px solid #e3759a;
  464. border-radius: 5px;
  465. color: #fff;
  466. line-height: 35px;
  467. margin: 10px;
  468. }
  469. .dialog_change >>> .el-dialog {
  470. border-radius: 5px;
  471. }
  472. .dialog_change >>> .el-dialog__header {
  473. background: #303030;
  474. height: 36px;
  475. line-height: 36px;
  476. padding-left: 10px;
  477. padding: 0px 10px 0px;
  478. }
  479. .dialog_change >>> .el-dialog__headerbtn {
  480. top: 10px !important;
  481. right: 10px !important;
  482. }
  483. .dialog_change >>> .el-dialog__title {
  484. color: #fff;
  485. font-size: 14px;
  486. line-height: 5px;
  487. }
  488. .dialog_change >>> .el-dialog__body {
  489. background: #f5f5f5;
  490. }
  491. .blue_box {
  492. align-items: center;
  493. display: flex;
  494. flex-direction: column;
  495. justify-content: center;
  496. }
  497. .blue_box,
  498. .blue_box_one {
  499. width: 30%;
  500. height: 100px;
  501. text-align: center;
  502. color: #fff;
  503. background-image: linear-gradient(90deg, #477cd7, #65b9fc);
  504. border-radius: 15px;
  505. margin: 15px 0 15px 15px;
  506. cursor: pointer;
  507. }
  508. .blue_box_one {
  509. width: 200px;
  510. height: 200px;
  511. background-image: linear-gradient(90deg, #477cd7, #65b9fc);
  512. display: flex;
  513. flex-direction: column;
  514. flex-wrap: nowrap;
  515. align-items: center;
  516. justify-content: center;
  517. }
  518. .blue_box_one > div {
  519. margin: 5px 0;
  520. }
  521. .blue_box_one > div:nth-child(1) {
  522. font-size: 20px;
  523. font-weight: bold;
  524. }
  525. .blue_box > div:nth-child(2) {
  526. margin-top: 10px;
  527. }
  528. .blue_box_one > div:nth-child(2) {
  529. white-space: nowrap;
  530. text-overflow: ellipsis;
  531. overflow: hidden;
  532. word-break: break-all;
  533. width: 100%;
  534. text-align: center;
  535. max-width: calc(100% - 85px);
  536. margin: 0 auto;
  537. }
  538. .return {
  539. background: #205cc6;
  540. width: 70px;
  541. height: 30px;
  542. color: #fff;
  543. text-align: center;
  544. line-height: 32px;
  545. margin-right: 20px;
  546. cursor: pointer;
  547. border-radius: 5px;
  548. position: absolute;
  549. right: 0;
  550. top: 24px;
  551. font-size: 14px;
  552. }
  553. .return > img {
  554. width: 100%;
  555. height: 100%;
  556. }
  557. .cType {
  558. display: flex;
  559. flex-direction: row;
  560. justify-content: center;
  561. align-items: center;
  562. margin-top: 20px;
  563. }
  564. .cType > div > span {
  565. font-size: 18px;
  566. }
  567. .type_children + .type_children {
  568. margin-left: 10px;
  569. }
  570. .all_choose {
  571. margin-right: 10px;
  572. max-width: 250px;
  573. white-space: nowrap;
  574. overflow: hidden;
  575. text-overflow: ellipsis;
  576. }
  577. .rightT {
  578. display: flex;
  579. flex-direction: row;
  580. flex-wrap: nowrap;
  581. align-items: center;
  582. }
  583. .jd {
  584. background: #4a9eed;
  585. margin-left: 15px;
  586. border-radius: 10px;
  587. color: #fff;
  588. width: 70px;
  589. height: 25px;
  590. text-align: center;
  591. line-height: 25px;
  592. }
  593. .sLeft {
  594. width: 14%;
  595. margin-right: 10px;
  596. background: rgb(255, 255, 255);
  597. padding: 20px 0 0 25px;
  598. border-radius: 10px;
  599. }
  600. .courseT {
  601. border-left: 3px solid #2e66c9;
  602. padding-left: 5px;
  603. color: #2e66c9;
  604. font-weight: bold;
  605. }
  606. .courseTd {
  607. padding-top: 15px;
  608. width: 175px;
  609. height: 700px;
  610. overflow: auto;
  611. max-height: 715px;
  612. word-break: break-word;
  613. }
  614. .courseTd::-webkit-scrollbar {
  615. /*滚动条整体样式*/
  616. width: 6px;
  617. /*高宽分别对应横竖滚动条的尺寸*/
  618. height: 6px;
  619. }
  620. /*定义滚动条轨道 内阴影+圆角*/
  621. .courseTd::-webkit-scrollbar {
  622. border-radius: 10px;
  623. background-color: #eee;
  624. }
  625. /*定义滑块 内阴影+圆角*/
  626. .courseTd::-webkit-scrollbar-thumb {
  627. border-radius: 10px;
  628. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  629. background-color: rgba(0, 0, 0, 0.1);
  630. }
  631. .rightTd,
  632. .noBRight {
  633. width: 84%;
  634. background: #fff;
  635. display: flex;
  636. flex-direction: row;
  637. flex-wrap: wrap;
  638. align-content: flex-start;
  639. align-items: center;
  640. justify-content: flex-start;
  641. }
  642. .noBRight {
  643. width: 100%;
  644. }
  645. .Tname {
  646. margin-left: 40px;
  647. }
  648. </style>