index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div class="body1">
  3. <!-- 课程数据 -->
  4. <div class="left">
  5. <div class="top">
  6. <div class="titleBox">
  7. <div class="title">授课频次</div>
  8. </div>
  9. <div class="dataBox">
  10. <div class="teafre">
  11. <div class="teaLeft">
  12. <div>累计授课次数</div>
  13. <div>{{ wCount }}</div>
  14. </div>
  15. <div class="teaLeft teaRigth">
  16. <div>相对增幅百分比</div>
  17. <div>{{ reInc }}%</div>
  18. </div>
  19. </div>
  20. <TeaFre
  21. style="height: calc(100% - 62px)"
  22. :monthArray="groupedArrayByMonth"
  23. ></TeaFre>
  24. </div>
  25. </div>
  26. <div class="bottom">
  27. <div class="titleBox">
  28. <div class="title">工具使用</div>
  29. </div>
  30. <div class="dataBox">
  31. <ToolUse style="height: calc(100% - 40px)"></ToolUse>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="center">
  36. <div class="top">
  37. <div class="titleBox">
  38. <div class="title">课程数量</div>
  39. </div>
  40. <div class="dataBox middleBox">
  41. <div class="halfBox">
  42. <div class="teafre">
  43. <div class="teaMiddle cNum">
  44. <div>课程总数</div>
  45. <div>{{ cCount }}</div>
  46. </div>
  47. <div class="teaMiddle tNum">
  48. <div>类别总数</div>
  49. <div>8412</div>
  50. </div>
  51. <div class="teaMiddle tSum">
  52. <div>类别平均</div>
  53. <div>3021</div>
  54. </div>
  55. </div>
  56. <CateRank
  57. style="height: calc(100% - 72px); margin-top: 10px"
  58. ></CateRank>
  59. </div>
  60. <div class="halfBox middleBox" style="align-items: flex-start">
  61. <WorkNum style="height: calc(100% - 40px)"></WorkNum>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="bottom">
  66. <div class="titleBox">
  67. <div class="title">课程时间分布</div>
  68. </div>
  69. <div class="dataBox">
  70. <CourseTime style="height: calc(100% - 40px)"></CourseTime>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="right">
  75. <div class="top">
  76. <div class="titleBox">
  77. <div class="title">课程分析</div>
  78. </div>
  79. <div class="dataBox">
  80. <CourseAna style="height: calc(100% - 40px)"></CourseAna>
  81. </div>
  82. </div>
  83. <div class="bottom">
  84. <div class="titleBox">
  85. <div class="title">授课时长</div>
  86. </div>
  87. <div class="dataBox">
  88. <div class="teafre">
  89. <div class="teaLeft">
  90. <div>累计时长</div>
  91. <div>15624小时</div>
  92. </div>
  93. <div class="teaLeft teaRigth">
  94. <div>学生在线平均时长</div>
  95. <div>268小时</div>
  96. </div>
  97. </div>
  98. <WorkTime style="height: calc(100% - 62px)"></WorkTime>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </template>
  104. <script>
  105. import TeaFre from "./chartList/teaFre.vue";
  106. import ToolUse from "./chartList/toolUse.vue";
  107. import CateRank from "./chartList/cateRank.vue";
  108. import WorkNum from "./chartList/workNum.vue";
  109. import CourseTime from "./chartList/courseTime.vue";
  110. import CourseAna from "./chartList/courseAna.vue";
  111. import WorkTime from "./chartList/workTime.vue";
  112. export default {
  113. components: {
  114. TeaFre,
  115. ToolUse,
  116. CateRank,
  117. WorkNum,
  118. CourseTime,
  119. CourseAna,
  120. WorkTime,
  121. },
  122. props: {
  123. oid: {
  124. type: String,
  125. },
  126. },
  127. data() {
  128. return {
  129. isLoading: false,
  130. wCount: 0,
  131. cCount: 0,
  132. groupedArrayByMonth: [],
  133. reInc: 0,
  134. };
  135. },
  136. mounted() {
  137. this.getData();
  138. },
  139. methods: {
  140. getData() {
  141. this.isLoading = true;
  142. let params = [
  143. {
  144. oid: this.oid,
  145. },
  146. ];
  147. this.ajax
  148. .post(this.$store.state.api + "selectDataBoardCourse", params)
  149. .then((res) => {
  150. this.isLoading = false;
  151. this.wCount = res.data[0].length;
  152. this.cCount = res.data[1].length;
  153. var workArray = res.data[0];
  154. let workList = [];
  155. //将数据根据time里面的月份分成多个数组
  156. var groupedArrayByMonth = [];
  157. const date = new Date();
  158. var Month = date.getMonth() + 1;
  159. var Year = date.getFullYear();
  160. for (var i = Month; i > Month - 6; i--) {
  161. if (i <= 0) {
  162. groupedArrayByMonth.push({
  163. Year: Year - 1,
  164. Month: 12 + i,
  165. course: 0,
  166. });
  167. } else {
  168. groupedArrayByMonth.push({
  169. Month: i,
  170. Year: Year,
  171. course: 0,
  172. });
  173. }
  174. }
  175. groupedArrayByMonth = groupedArrayByMonth.reverse();
  176. for (var i = 0; i < workArray.length; i++) {
  177. let _date = new Date(workArray[i].time);
  178. var _month = _date.getMonth() + 1;
  179. var _year = _date.getFullYear();
  180. for (var j = 0; j < groupedArrayByMonth.length; j++) {
  181. if (
  182. _month == groupedArrayByMonth[j].Month &&
  183. _year == groupedArrayByMonth[j].Year
  184. ) {
  185. groupedArrayByMonth[j].course++;
  186. break;
  187. }
  188. }
  189. }
  190. this.reInc = (
  191. (groupedArrayByMonth[groupedArrayByMonth.length - 1].course /
  192. groupedArrayByMonth[groupedArrayByMonth.length - 2].course) *
  193. 100
  194. ).toFixed(1);
  195. this.groupedArrayByMonth = groupedArrayByMonth;
  196. })
  197. .catch((err) => {
  198. this.isLoading = false;
  199. console.error(err);
  200. });
  201. },
  202. format(percentage) {
  203. return percentage;
  204. },
  205. },
  206. };
  207. </script>
  208. <style scoped>
  209. .body1 {
  210. width: 100%;
  211. height: 100%;
  212. display: flex;
  213. padding: 20px;
  214. box-sizing: border-box;
  215. overflow: hidden;
  216. }
  217. .left {
  218. width: calc(100% / 4 * 1);
  219. height: 100%;
  220. }
  221. .left > .top {
  222. width: 100%;
  223. height: calc(100% / 2 - 10px);
  224. background: #fff;
  225. border-radius: 5px;
  226. margin: 0 0 20px 0;
  227. }
  228. .left > .bottom {
  229. width: 100%;
  230. height: calc(100% / 2 - 10px);
  231. background: #fff;
  232. border-radius: 5px;
  233. }
  234. .center {
  235. width: calc(100% / 4 * 2 - 40px);
  236. height: 100%;
  237. margin: 0 20px;
  238. }
  239. .center > .top {
  240. width: 100%;
  241. height: calc(100% / 5 * 3 - 10px);
  242. background: #fff;
  243. border-radius: 5px;
  244. margin: 0 0 20px 0;
  245. }
  246. .center > .bottom {
  247. width: 100%;
  248. height: calc(100% / 5 * 2 - 10px);
  249. background: #fff;
  250. border-radius: 5px;
  251. }
  252. .right {
  253. width: calc(100% / 4 * 1);
  254. height: 100%;
  255. }
  256. .right > .top {
  257. width: 100%;
  258. height: calc(100% / 2 - 10px);
  259. background: #fff;
  260. border-radius: 16px;
  261. margin: 0 0 20px 0;
  262. }
  263. .right > .bottom {
  264. width: 100%;
  265. height: calc(100% / 2 - 10px);
  266. background: #fff;
  267. border-radius: 5px;
  268. }
  269. .titleBox {
  270. height: 40px;
  271. display: flex;
  272. align-items: center;
  273. padding: 0 15px;
  274. width: 100%;
  275. }
  276. .dataBox {
  277. height: calc(100% - 40px);
  278. width: 100%;
  279. }
  280. .middleBox {
  281. display: flex;
  282. flex-direction: row;
  283. flex-wrap: nowrap;
  284. align-items: flex-start;
  285. }
  286. .title {
  287. font-weight: bold;
  288. color: #060e17;
  289. font-size: 18px;
  290. }
  291. .teafre {
  292. display: flex;
  293. flex-direction: row;
  294. flex-wrap: nowrap;
  295. align-items: center;
  296. width: 100%;
  297. justify-content: space-evenly;
  298. }
  299. .teaLeft,
  300. .teaMiddle {
  301. width: calc(100% / 2 - 10px);
  302. height: 60px;
  303. border-radius: 8px;
  304. /* border: 1px solid #e0eafb; */
  305. display: flex;
  306. flex-direction: column;
  307. align-items: flex-start;
  308. justify-content: center;
  309. padding: 0 10px;
  310. margin: 0 10px;
  311. }
  312. .teaMiddle {
  313. width: calc(100% / 3 - 10px);
  314. }
  315. .teaLeft {
  316. width: 95%;
  317. background: linear-gradient(
  318. 180deg,
  319. rgba(224, 234, 251, 0.2) 0%,
  320. rgba(54, 130, 252, 0.3) 100%
  321. );
  322. }
  323. .teaRigth {
  324. background: linear-gradient(
  325. 180deg,
  326. rgb(211, 246, 228, 0.2) 0%,
  327. rgb(23, 196, 105, 0.3) 100%
  328. ) !important;
  329. }
  330. .cNum {
  331. background: linear-gradient(
  332. 180deg,
  333. rgb(125, 227, 174, 0.2) 0%,
  334. rgb(23, 196, 105, 0.3) 100%
  335. ) !important;
  336. }
  337. .tNum {
  338. background: linear-gradient(
  339. 180deg,
  340. rgb(174, 204, 254, 0.2) 0%,
  341. rgb(54, 129, 252, 0.3) 100%
  342. ) !important;
  343. }
  344. .tSum {
  345. background: linear-gradient(
  346. 180deg,
  347. rgb(125, 227, 174, 0.2) 0%,
  348. rgb(23, 196, 105, 0.3) 100%
  349. ) !important;
  350. }
  351. .teaLeft > div:first-child,
  352. .teaMiddle > div:first-child {
  353. font-size: 12px;
  354. font-weight: 400;
  355. color: #565e6a;
  356. }
  357. .teaLeft > div:last-child,
  358. .teaMiddle > div:last-child {
  359. font-size: 22px;
  360. font-weight: bold;
  361. color: #060e17;
  362. }
  363. .halfBox {
  364. width: 50%;
  365. height: 100%;
  366. }
  367. </style>