courseProgress.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div v-loading="loading" class="box">
  3. <el-button type="primary" size="small" class="returnBtn" @click="retrunA()">返回</el-button>
  4. <!-- <div v-if="cPan == 2" class="noneClass">项目数据不完善,无法显示数据,请前去完善</div> -->
  5. <div class="proMan" v-if="cPan == 1">
  6. <div class="title"><img src="../../../assets/icon/task.png" alt />任务进展甘特图</div>
  7. <ganChart :Json="unitJson"></ganChart>
  8. </div>
  9. <div class="proMan">
  10. <div class="title"><img src="../../../assets/icon/tupu.png" alt />图谱</div>
  11. <graph :Json="graphJson"></graph>
  12. </div>
  13. <div class="proMan" v-if="cPan == 1">
  14. <div class="title"><img src="../../../assets/icon/proMan.png" alt />负责人看板</div>
  15. <proMan :Json="unitJson" :ManAarray="ManAarray"></proMan>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import proMan from "../components/proMan.vue"
  21. import ganChart from "../components/ganChart.vue"
  22. import graph from "../components/graph.vue"
  23. export default {
  24. components: { proMan, ganChart, graph },
  25. data() {
  26. return {
  27. cid: this.$route.query.cid,
  28. userid: this.$route.query.userid,
  29. oid: this.$route.query.oid,
  30. org: this.$route.query.org,
  31. loading: false,
  32. unitJson: {},
  33. cPan: 1,
  34. teacherJuri2: [],
  35. ManAarray: [],
  36. checkboxList3: [],
  37. courseUserid: "",
  38. graphJson: {}
  39. }
  40. },
  41. methods: {
  42. retrunA() {
  43. this.$router.go(-1)
  44. },
  45. getCourse() {
  46. let params = {
  47. cid: this.cid,
  48. };
  49. this.ajax
  50. .get(this.$store.state.api + "select_studio_course_detail", params)
  51. .then((res) => {
  52. this.unitJson = JSON.parse(res.data[0][0].chapters);
  53. this.courseUserid = res.data[0][0].userid;
  54. this.checkboxList3 = res.data[0][0].course_teacher
  55. ? res.data[0][0].course_teacher.split(",")
  56. : [];
  57. this.cPan = 1;
  58. for (var i = 0; i < this.unitJson.length; i++) {
  59. for (
  60. var j = 0;
  61. j < this.unitJson[i].chapterInfo[0].taskJson.length;
  62. j++
  63. ) {
  64. // if (
  65. // !this.unitJson[i].chapterInfo[0].taskJson[j].task
  66. // ) {
  67. // // this.$message.error("请填写任务名称");
  68. // this.cPan = 2
  69. // break;
  70. // }
  71. // if (
  72. // !this.unitJson[i].chapterInfo[0].taskJson[j].people
  73. // ) {
  74. // // this.$message.error("请填写负责人");
  75. // this.cPan = 2
  76. // break;
  77. // }
  78. // if (
  79. // !this.unitJson[i].chapterInfo[0].taskJson[j].time
  80. // ) {
  81. // // this.$message.error("请填写任务完成时间");
  82. // this.cPan = 2
  83. // break;
  84. // }
  85. if (this.unitJson[i].chapterInfo[0].taskJson[j].eList) {
  86. this.unitJson[i].chapterInfo[0].taskJson[j].eList = this.unitJson[
  87. i
  88. ].chapterInfo[0].taskJson[j].eList.filter((ele) => {
  89. return ele.value != "";
  90. });
  91. }
  92. }
  93. }
  94. this.getTeacher(res.data[0][0]);
  95. })
  96. .catch((err) => {
  97. console.error(err);
  98. });
  99. },
  100. setGraphJson(json) {
  101. let chapters = JSON.parse(json.chapters)
  102. let gjson = {
  103. rootId: 'pid',
  104. nodes: [
  105. { id: 'pid', text: '', borderWidth: -1, color: '#128cff' },
  106. ],
  107. lines: [
  108. ]
  109. }
  110. gjson.nodes[0].text = json.title
  111. for (var i = 0; i < chapters.length; i++) {
  112. let _chapter = chapters[i]
  113. gjson.nodes.push({ id: 'chap' + i, text: '阶段' + (i + 1) + '-' + _chapter.dyName, borderWidth: -1, color: '#0672e1' })
  114. gjson.lines.push({ from: 'pid', to: 'chap' + i })
  115. let tasks = _chapter.chapterInfo[0].taskJson
  116. for (var j = 0; j < tasks.length; j++) {
  117. let _task = tasks[j]
  118. gjson.nodes.push({ id: 'task' + i + '-' + j, text: '任务' + (j + 1) + '-' + _task.task, borderWidth: -1, color: '#3c59da' })
  119. gjson.lines.push({ from: 'chap' + i, to: 'task' + i + '-' + j })
  120. if (_task.people) {
  121. let _people = '负责人-' + this.getGMan(_task.people)
  122. gjson.nodes.push({ id: 'people' + i + '-' + j, text: _people, borderWidth: -1, color: '#004d9b' })
  123. gjson.lines.push({ from: 'task' + i + '-' + j, to: 'people' + i + '-' + j })
  124. if (_task.tcMember && _task.tcMember.length) {
  125. for (var tc = 0; tc < _task.tcMember.length; tc++) {
  126. let _tc = this.getGMan(_task.tcMember[tc])
  127. if (_tc) {
  128. gjson.nodes.push({ id: 'tc' + i + '-' + j + '-' + tc, text: _tc, borderWidth: -1, color: '#53c5fb' })
  129. gjson.lines.push({ from: 'people' + i + '-' + j, to: 'tc' + i + '-' + j + '-' + tc })
  130. }
  131. }
  132. }
  133. }
  134. }
  135. }
  136. this.graphJson = gjson
  137. },
  138. getGMan(people) {
  139. let _people = ''
  140. if (this.ManAarray.length) {
  141. for (var i = 0; i < this.ManAarray.length; i++) {
  142. if (this.ManAarray[i].userid == people) {
  143. _people = this.ManAarray[i].name;
  144. break;
  145. }
  146. }
  147. }
  148. return _people ? _people : '无'
  149. },
  150. getTeacher(sss) {
  151. this.ManAarray = []
  152. if (this.checkboxList3.indexOf(this.courseUserid) == -1) {
  153. this.checkboxList3.push(this.courseUserid)
  154. }
  155. let params = [{
  156. uid: this.checkboxList3.join(","),
  157. }];
  158. this.ajax
  159. .post(
  160. this.$store.state.api + "getAllUserByIdP",
  161. params
  162. )
  163. .then((res) => {
  164. let teacherJuri = res.data[0];
  165. this.ManAarray = teacherJuri;
  166. this.setGraphJson(sss)
  167. this.setMan();
  168. })
  169. .catch((err) => {
  170. console.error(err);
  171. });
  172. },
  173. setMan() {
  174. // let teacherJuri = this.teacherJuri2;
  175. // debugger
  176. // this.ManAarray = []
  177. // for (var i = 0; i < teacherJuri.length; i++) {
  178. // if (teacherJuri[i].userid == this.userid) {
  179. // this.ManAarray.push(teacherJuri[i])
  180. // } else if (this.checkboxList3.indexOf(teacherJuri[i].userid) != -1) {
  181. // this.ManAarray.push(teacherJuri[i])
  182. // }
  183. // }
  184. this.loading = false;
  185. },
  186. },
  187. mounted() {
  188. this.loading = true;
  189. this.getCourse();
  190. },
  191. }
  192. </script>
  193. <style scoped>
  194. .returnBtn {
  195. position: fixed;
  196. right: 20px;
  197. top: 15px;
  198. z-index: 99999;
  199. }
  200. .noneClass {
  201. margin-top: 10px;
  202. display: flex;
  203. justify-content: center;
  204. font-size: 20px;
  205. font-weight: 700;
  206. }
  207. .box {
  208. background: #fff;
  209. height: 100%;
  210. width: 100%;
  211. overflow: auto;
  212. }
  213. .proMan {
  214. width: 95%;
  215. margin: 0 auto;
  216. padding: 20px 0 20px;
  217. /* margin-top: 20px; */
  218. }
  219. .proMan .title {
  220. margin-bottom: 10px;
  221. display: flex;
  222. align-items: center;
  223. }
  224. .proMan .title img {
  225. margin-right: 5px;
  226. height: 17px;
  227. width: 17px;
  228. }
  229. </style>