course.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <template>
  2. <div class="pb_content" style="height: auto">
  3. <div class="pb_head top">
  4. <span>项目管理</span>
  5. <div class="student_button">
  6. <el-button
  7. type="primary"
  8. class="bgColor"
  9. @click="goTo('/course/addCourse?userid=' + userid + '&oid=' + oid)"
  10. >添加项目</el-button>
  11. </div>
  12. </div>
  13. <div class="pb_content_body" style="height: 100%">
  14. <div class="student_head">
  15. <div class="choose">
  16. <div class="student_search">
  17. <span>课程筛选</span>
  18. <el-select v-model="groupA" @change="search">
  19. <el-option value="0" label="我的课程"></el-option>
  20. <el-option value="1" label="他人课程"></el-option>
  21. </el-select>
  22. </div>
  23. <div class="all_choose" v-for="(item, index) in CourseType[0]" :key="index">
  24. <span>{{ item.name }}</span>
  25. <el-select v-model="courseTypeId[item.id]" placeholder="请选择" @change="getTypeName">
  26. <el-option label="全部" value="1">全部</el-option>
  27. <el-option
  28. v-for="item1 in CourseTypeJson[item.id]"
  29. :key="item1.id"
  30. :label="item1.name"
  31. :value="item1.id"
  32. ></el-option>
  33. </el-select>
  34. </div>
  35. <div @click="clear" class="clear">重置</div>
  36. </div>
  37. <div class="student_right">
  38. <div class="head_left">
  39. <el-input v-model="courseName" class="student_input" placeholder="请输入课程名称"></el-input>
  40. <el-button class="course_button" @click="searchCourse">查询</el-button>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="student_table">
  45. <div class="course_box">
  46. <div class="out_box" v-for="(item, index) in course" :key="index">
  47. <div class="tup">
  48. <img
  49. :src="
  50. item.cover != null && item.cover != ''
  51. ? JSON.parse(item.cover).length > 0
  52. ? JSON.parse(item.cover)[0].url
  53. : mr
  54. : mr
  55. "
  56. alt
  57. />
  58. </div>
  59. <div class="bottom_box">
  60. <div>{{ item.title }}</div>
  61. <div class="kc_t" v-if="groupA == '1'">创建老师:{{ item.uname }}</div>
  62. <div class="kc_time">{{ item.time }}</div>
  63. </div>
  64. <div class="three_bottom">
  65. <div @click="jump(item.courseId)">开始教学</div>
  66. <div
  67. v-if="groupA == '0'"
  68. @click="
  69. goTo(
  70. '/course/addCourse?cid=' +
  71. item.courseId +
  72. '&userid=' +
  73. userid +
  74. '&oid=' +
  75. oid
  76. )
  77. "
  78. >修改</div>
  79. <div
  80. @click="
  81. goTo(
  82. '/works?cid=' +
  83. item.courseId +
  84. '&userid=' +
  85. userid +
  86. '&oid=' +
  87. oid
  88. )
  89. "
  90. >作业</div>
  91. <div @click="checkProblem(item)">提问</div>
  92. <div @click="deleteCourse(item.courseId)">删除</div>
  93. </div>
  94. </div>
  95. <div class="course_empty" v-if="course.length == 0">暂无数据</div>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="student_page">
  100. <el-pagination
  101. background
  102. layout="prev, pager, next"
  103. :page-size="10"
  104. :total="total"
  105. v-if="page && course.length"
  106. style="padding-bottom: 20px"
  107. @current-change="handleCurrentChange"
  108. ></el-pagination>
  109. </div>
  110. <el-dialog :visible.sync="dialogVisible1" size="tiny">
  111. <img width="100%" :src="dialogImageUrl" alt />
  112. </el-dialog>
  113. <el-dialog
  114. title="查看提问"
  115. :visible.sync="dialogVisible"
  116. :append-to-body="true"
  117. width="750px"
  118. :before-close="handleClose"
  119. class="dialog_diy"
  120. >
  121. <div>
  122. <div class="a_addBox">
  123. <CourseProblem :problemCourse="problemCourse"></CourseProblem>
  124. </div>
  125. </div>
  126. <span slot="footer" class="dialog-footer">
  127. <el-button @click="dialogVisible = false">关 闭</el-button>
  128. </span>
  129. </el-dialog>
  130. </div>
  131. </template>
  132. <script>
  133. import "../../common/aws-sdk-2.235.1.min";
  134. import EditorBar from "../../components/tools/wangEnduit";
  135. import CourseProblem from "./components/courseProblem";
  136. export default {
  137. components: { EditorBar,CourseProblem },
  138. data() {
  139. return {
  140. itemCount: 1,
  141. courseTitle: "",
  142. courseText: "",
  143. courseTime: "",
  144. isLoading: false,
  145. fileList: [],
  146. fileList1: [],
  147. homeworkList: [{ name: "" }],
  148. formLabelWidth: "100px",
  149. dialogVisible: false,
  150. dialogVisible1: false,
  151. dialogImageUrl: "",
  152. group: "",
  153. userid: this.$route.query.userid,
  154. oid: this.$route.query.oid,
  155. Juri: "",
  156. groupList: [],
  157. JuriList: [],
  158. page: 1,
  159. total: 0,
  160. tableData: [],
  161. now: "",
  162. courseDetail: {},
  163. addCourse: {},
  164. groupA: "0",
  165. classX: "",
  166. course: [],
  167. courseName: "",
  168. mr: require("../../assets/icon/kc1.png"),
  169. CourseType: [],
  170. CourseTypeJson: {},
  171. courseTypeId: {},
  172. courseTypeSon: [],
  173. isChoose: 0,
  174. problemCourse: null, //查看提问的课程
  175. };
  176. },
  177. methods: {
  178. change(val) {
  179. console.log(val);
  180. },
  181. addHomeworkBox() {
  182. this.homeworkList.push({ name: "" });
  183. this.itemCount++;
  184. },
  185. reduceHomeworkBox() {
  186. var a = this.homeworkList;
  187. a.splice(a.length - 1);
  188. this.itemCount--;
  189. },
  190. goTo(path) {
  191. this.$router.push(path);
  192. },
  193. tableRowClassName({ row, rowIndex }) {
  194. if ((rowIndex + 1) % 2 === 0) {
  195. return "even_row";
  196. } else {
  197. return "";
  198. }
  199. },
  200. jump(cid) {
  201. // window.open(
  202. // "//pbl.cocorobo.cn/pbl-student-table/dist/#/courseDetail?courseId=" +
  203. // cid +
  204. // "&userid=" +
  205. // this.userid
  206. // );
  207. window.parent.postMessage({ cid: cid, type: "1" }, "*");
  208. },
  209. handle_remove(file, fileList) {
  210. var _tmp = this.fileList;
  211. for (var i = 0, len = _tmp.length; i < len; i++) {
  212. if (_tmp[i].uid == file.uid) {
  213. _tmp.splice(i, 1);
  214. break;
  215. }
  216. this.fileList = _tmp;
  217. }
  218. },
  219. handle_remove1(file, fileList) {
  220. var _tmp = this.fileList1;
  221. for (var i = 0, len = _tmp.length; i < len; i++) {
  222. if (_tmp[i].uid == file.uid) {
  223. _tmp.splice(i, 1);
  224. break;
  225. }
  226. this.fileList1 = _tmp;
  227. }
  228. },
  229. handleCurrentChange(val) {
  230. // console.log(`当前页: ${val}`);
  231. this.page = val;
  232. this.getCourse();
  233. },
  234. init() {},
  235. handleClose(done) {
  236. done();
  237. },
  238. handleRemove(file, fileList) {
  239. console.log(file, fileList);
  240. },
  241. handlePictureCardPreview(file) {
  242. this.dialogImageUrl = file.url;
  243. this.dialogVisible1 = true;
  244. },
  245. onExceed() {
  246. this.$message.error("课程海报仅支持上传一张,请删除后再进行上传");
  247. },
  248. //uuid生成
  249. guid() {
  250. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (
  251. c
  252. ) {
  253. var r = (Math.random() * 16) | 0,
  254. v = c == "x" ? r : (r & 0x3) | 0x8;
  255. return v.toString(16);
  256. });
  257. },
  258. time() {
  259. if (!this.now) {
  260. this.now = new Date().getTime();
  261. return true;
  262. } else {
  263. let time = new Date().getTime();
  264. if (time - this.now > 3000) {
  265. this.now = time;
  266. return true;
  267. } else {
  268. return false;
  269. }
  270. }
  271. },
  272. searchCourse() {
  273. this.page = 1;
  274. this.getCourse();
  275. },
  276. clear() {
  277. for (var i = 0; i < this.CourseType[0].length; i++) {
  278. this.courseTypeId[this.CourseType[0][i].id] = "";
  279. }
  280. this.getCourse();
  281. },
  282. getCourse() {
  283. const loading = this.openLoading(
  284. document.querySelector(".student_table")
  285. );
  286. var typeE = [];
  287. var typea, typeb, typec, typed;
  288. if (this.isChoose == 1) {
  289. for (var i = 0; i < this.CourseType[0].length; i++) {
  290. if (this.courseTypeId[this.CourseType[0][i].id] == "1") {
  291. typeE.push(this.CourseType[0][i].id);
  292. } else if (this.courseTypeId[this.CourseType[0][i].id] != "") {
  293. if (this.CourseType[0][i].name == "年级") {
  294. typea = this.courseTypeId[this.CourseType[0][i].id];
  295. } else if (this.CourseType[0][i].name == "专栏") {
  296. typeb = this.courseTypeId[this.CourseType[0][i].id];
  297. } else if (this.CourseType[0][i].name == "新技能") {
  298. typec = this.courseTypeId[this.CourseType[0][i].id];
  299. } else if (this.CourseType[0][i].name == "学科") {
  300. typed = this.courseTypeId[this.CourseType[0][i].id];
  301. }
  302. this.courseTypeSon.push(
  303. this.courseTypeId[this.CourseType[0][i].id]
  304. );
  305. }
  306. }
  307. }
  308. this.isLoading = true;
  309. let params = {
  310. type: this.groupA,
  311. uid: this.userid,
  312. oid: this.oid,
  313. typea: typea != undefined ? typea : "",
  314. typeb: typeb != undefined ? typeb : "",
  315. typec: typec != undefined ? typec : "",
  316. typed: typed != undefined ? typed : "",
  317. typeE: typeE.join(","),
  318. cu: "",
  319. cn: this.courseName,
  320. page: this.page,
  321. };
  322. this.ajax
  323. .get(this.$store.state.api + "selectCourseNew", params)
  324. .then((res) => {
  325. loading.close();
  326. this.isLoading = false;
  327. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  328. this.course = res.data[0];
  329. })
  330. .catch((err) => {
  331. console.error(err);
  332. });
  333. },
  334. getTypeName() {
  335. this.$forceUpdate();
  336. this.page = 1;
  337. this.isChoose = 1;
  338. this.getCourse();
  339. },
  340. // searchCourse() {
  341. // this.isLoading = true;
  342. // let params = {
  343. // cu: "",
  344. // cn: this.courseName,
  345. // page: this.page,
  346. // };
  347. // this.ajax
  348. // .get(this.$store.state.api + "searchCourse", params)
  349. // .then((res) => {
  350. // this.isLoading = false;
  351. // this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  352. // this.course = res.data[0];
  353. // })
  354. // .catch((err) => {
  355. // this.isLoading = false;
  356. // console.error(err);
  357. // });
  358. // },
  359. deleteCourse(cid) {
  360. const loading = this.openLoading(
  361. document.querySelector(".student_table")
  362. );
  363. this.isLoading = true;
  364. let params = {
  365. cid: cid,
  366. };
  367. this.ajax
  368. .get(this.$store.state.api + "deleteCourse", params)
  369. .then((res) => {
  370. loading.close();
  371. this.isLoading = false;
  372. this.$message.success("删除成功");
  373. this.getCourse();
  374. })
  375. .catch((err) => {
  376. console.error(err);
  377. });
  378. },
  379. selectType() {
  380. this.ajax
  381. .get(this.$store.state.api + "selectType")
  382. .then((res) => {
  383. this.CourseType = res.data;
  384. for (var i = 0; i < res.data[0].length; i++) {
  385. if (!this.cid) {
  386. this.courseTypeId[res.data[0][i].id] = "";
  387. }
  388. for (var j = 0; j < res.data[1].length; j++) {
  389. if (res.data[0][i].id == res.data[1][j].pid) {
  390. if (!this.CourseTypeJson[res.data[0][i].id]) {
  391. this.CourseTypeJson[res.data[0][i].id] = [];
  392. }
  393. this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]);
  394. }
  395. }
  396. }
  397. })
  398. .catch((err) => {
  399. console.error(err);
  400. });
  401. },
  402. search() {
  403. this.page = 1;
  404. this.getCourse();
  405. },
  406. checkProblem(res) {
  407. this.problemCourse = res;
  408. this.dialogVisible = true;
  409. },
  410. },
  411. created() {
  412. this.page = 1;
  413. this.selectType();
  414. this.getCourse();
  415. },
  416. };
  417. </script>
  418. <style scoped>
  419. .dialog_diy >>> .el-dialog__header {
  420. background: #3d67bc !important;
  421. padding: 15px 20px;
  422. }
  423. .dialog_diy >>> .el-dialog__title {
  424. color: #fff;
  425. }
  426. .dialog_diy >>> .el-dialog__headerbtn {
  427. top: 19px;
  428. }
  429. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close {
  430. color: #fff;
  431. }
  432. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close:hover {
  433. color: #fff;
  434. }
  435. .student_head >>> .el-button--primary {
  436. background-color: #2268bc;
  437. }
  438. .xls_button {
  439. font-size: 14px;
  440. cursor: pointer;
  441. text-decoration: underline;
  442. color: rgb(34, 104, 188);
  443. }
  444. .student_head {
  445. display: flex;
  446. justify-content: space-between;
  447. align-items: baseline;
  448. flex-direction: row;
  449. flex-wrap: nowrap;
  450. }
  451. .top {
  452. display: flex;
  453. justify-content: space-between;
  454. }
  455. .bgColor {
  456. background: #466b99;
  457. }
  458. .student_search {
  459. display: flex;
  460. align-items: center;
  461. width: calc(100% / 3);
  462. }
  463. .student_search span {
  464. margin: 0 10px 0 0;
  465. width: 65px;
  466. }
  467. .student_button {
  468. display: flex;
  469. overflow: hidden;
  470. height: 40px;
  471. }
  472. .upload-demo {
  473. display: flex;
  474. flex-direction: column;
  475. align-items: end;
  476. /* position: relative; */
  477. width: 100px;
  478. overflow: hidden;
  479. }
  480. .student_table {
  481. margin: 10px 0;
  482. height: 100%;
  483. overflow: auto;
  484. }
  485. .student_empty {
  486. display: flex;
  487. justify-content: center;
  488. align-items: center;
  489. }
  490. .el-table >>> .even_row {
  491. background-color: #f1f1f1;
  492. }
  493. .time {
  494. font-size: 13px;
  495. color: #999;
  496. }
  497. .course_button {
  498. padding: 10px 20px;
  499. }
  500. .course_button_box {
  501. display: flex;
  502. margin-top: 5px;
  503. justify-content: space-between;
  504. }
  505. .course_rate {
  506. margin-top: 5px;
  507. }
  508. .course_view {
  509. display: flex;
  510. align-items: center;
  511. margin: 5px 0 0 0;
  512. }
  513. .course_view i {
  514. background-image: url("../../assets/liulan.png");
  515. width: 25px;
  516. height: 25px;
  517. background-size: 100% 100%;
  518. /* margin-top: 1px; */
  519. line-height: 25px;
  520. vertical-align: text-top;
  521. background-repeat: no-repeat;
  522. }
  523. .image {
  524. width: 100%;
  525. height: 150px;
  526. display: block;
  527. }
  528. .course_box {
  529. display: flex;
  530. flex-wrap: wrap;
  531. height: 100%;
  532. min-height: 530px;
  533. }
  534. .student_page {
  535. width: 95%;
  536. margin: 0 auto;
  537. }
  538. .course_create_box {
  539. font-size: 18px;
  540. }
  541. .course_name {
  542. margin-top: 10px;
  543. }
  544. .course_name span {
  545. margin-bottom: 10px;
  546. display: block;
  547. }
  548. .homework_box {
  549. display: flex;
  550. align-items: center;
  551. flex-wrap: wrap;
  552. }
  553. .course_homework {
  554. width: 130px;
  555. display: flex;
  556. justify-content: center;
  557. flex-direction: column;
  558. align-items: center;
  559. margin: 0 10px 10px 0;
  560. }
  561. .course_type {
  562. margin-top: 10px;
  563. display: flex;
  564. }
  565. .course_type1 span {
  566. margin-bottom: 10px;
  567. display: block;
  568. }
  569. .course_type2 {
  570. margin-left: 20px;
  571. }
  572. .course_type2 span {
  573. margin-bottom: 10px;
  574. display: block;
  575. }
  576. .course_empty {
  577. color: rgb(110, 110, 110);
  578. width: 100%;
  579. height: 100%;
  580. display: flex;
  581. align-items: center;
  582. justify-content: center;
  583. }
  584. .el_cards >>> .el-card__body {
  585. height: 100%;
  586. }
  587. .courseBtnBox {
  588. display: flex;
  589. flex-direction: column;
  590. justify-content: space-between;
  591. height: calc(100% - 170px);
  592. padding: 10px;
  593. }
  594. .wordUpload {
  595. display: flex;
  596. }
  597. .wordUpload > .buttonUp {
  598. margin-right: 5px;
  599. }
  600. .out_box {
  601. display: flex;
  602. flex-direction: column;
  603. flex-wrap: nowrap;
  604. width: 250px;
  605. background: #fff;
  606. margin-left: 25px;
  607. border: 1px solid #ccc;
  608. height: fit-content;
  609. box-sizing: border-box;
  610. border-radius: 0px 0px 5px 5px;
  611. overflow: hidden;
  612. margin-bottom: 15px;
  613. }
  614. .bottom_box {
  615. display: flex;
  616. padding: 10px 0 10px 10px;
  617. flex-direction: column;
  618. box-sizing: border-box;
  619. }
  620. .bottom_box > div:nth-child(1) {
  621. width: 230px;
  622. overflow: hidden;
  623. text-overflow: ellipsis;
  624. white-space: nowrap;
  625. }
  626. .tup {
  627. width: 100%;
  628. height: 141.06px;
  629. margin: 0 auto;
  630. }
  631. .tup > img {
  632. width: 100%;
  633. height: 100%;
  634. }
  635. .kc_time {
  636. margin-top: 8px;
  637. font-size: 14px;
  638. color: #999;
  639. }
  640. .kc_t {
  641. margin-top: 5px;
  642. }
  643. .three_bottom {
  644. display: flex;
  645. flex-direction: row;
  646. justify-content: space-around;
  647. height: 40px;
  648. align-items: center;
  649. background: #f5f4f4;
  650. font-size: 14px;
  651. }
  652. .three_bottom > div {
  653. cursor: pointer;
  654. }
  655. .three_bottom > div:hover {
  656. color: #79a2ff;
  657. }
  658. .head_left {
  659. display: flex;
  660. }
  661. .student_input >>> .el-input__inner {
  662. height: 40px;
  663. width: 190px;
  664. font-size: 13px;
  665. padding: 0 10px;
  666. }
  667. .course_button {
  668. color: #fff;
  669. background: #2268bc;
  670. width: 75px;
  671. height: 40px;
  672. padding: 0 !important;
  673. font-size: 12px;
  674. line-height: 40px;
  675. }
  676. .all_choose {
  677. margin: 15px 0 10px;
  678. height: 20%;
  679. display: flex;
  680. flex-direction: row;
  681. align-items: center;
  682. width: calc(100% / 3);
  683. }
  684. .all_choose > span {
  685. width: 50px;
  686. display: block;
  687. }
  688. .choose {
  689. display: flex;
  690. flex-direction: row;
  691. flex-wrap: wrap;
  692. align-content: space-between;
  693. height: 100%;
  694. justify-content: flex-start;
  695. width: 60%;
  696. min-width: 868px;
  697. align-items: center;
  698. }
  699. .choose > div:nth-child(2) {
  700. margin-left: 1%;
  701. width: 32.33333%;
  702. }
  703. .choose > div:nth-child(4) {
  704. margin-right: 1%;
  705. width: 32.33333%;
  706. }
  707. .choose > div:nth-child(5) {
  708. margin-left: 1%;
  709. }
  710. .choose > div:nth-child(4) > span {
  711. width: 74px !important;
  712. min-width: 74px;
  713. }
  714. .choose > div:nth-child(4) >>> .el-select {
  715. width: 217.5px;
  716. min-width: 215.06px;
  717. }
  718. .clear {
  719. width: 70px;
  720. height: 35px;
  721. background: #2268bc;
  722. color: #fff;
  723. text-align: center;
  724. border-radius: 5px;
  725. line-height: 35px;
  726. cursor: pointer;
  727. margin-left: 20px;
  728. }
  729. </style>