index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div class="i_body">
  3. <div class="i_body_title">个人总览</div>
  4. <div class="i_body_panel">
  5. <div class="i_icon"><span></span></div>
  6. <div class="i_detail">
  7. <div>
  8. <span>{{ count }}</span
  9. ><span>个</span>
  10. </div>
  11. <div>观察记录总数</div>
  12. </div>
  13. </div>
  14. <div class="i_body_panel" v-for="(item, index) in typeList" :key="index">
  15. <div class="i_icon"><span></span></div>
  16. <div class="i_detail">
  17. <div>
  18. <span>{{ item.count }}</span
  19. ><span>个</span>
  20. </div>
  21. <div>{{ item.name }}记录</div>
  22. </div>
  23. </div>
  24. <!-- <div class="i_body_panel">
  25. <div class="i_icon"><span></span></div>
  26. <div class="i_detail">
  27. <div>
  28. <span>{{ count2 }}</span
  29. ><span>个</span>
  30. </div>
  31. <div>语言记录</div>
  32. </div>
  33. </div>
  34. <div class="i_body_panel">
  35. <div class="i_icon"><span></span></div>
  36. <div class="i_detail">
  37. <div>
  38. <span>{{ count3 }}</span
  39. ><span>个</span>
  40. </div>
  41. <div>社会记录</div>
  42. </div>
  43. </div>
  44. <div class="i_body_panel">
  45. <div class="i_icon"><span></span></div>
  46. <div class="i_detail">
  47. <div>
  48. <span>{{ count4 }}</span
  49. ><span>个</span>
  50. </div>
  51. <div>科学记录</div>
  52. </div>
  53. </div>
  54. <div class="i_body_panel">
  55. <div class="i_icon"><span></span></div>
  56. <div class="i_detail">
  57. <div>
  58. <span>{{ count5 }}</span
  59. ><span>个</span>
  60. </div>
  61. <div>艺术记录</div>
  62. </div>
  63. </div> -->
  64. </div>
  65. </template>
  66. <script>
  67. export default {
  68. props: {
  69. userid: {
  70. type: String
  71. },
  72. oid: {
  73. type: String
  74. },
  75. org: {
  76. type: String
  77. }
  78. },
  79. data() {
  80. return {
  81. test: [],
  82. work: [],
  83. count: 0,
  84. // count1: 0,
  85. // count2: 0,
  86. // count3: 0,
  87. // count4: 0,
  88. // count5: 0,
  89. typeList: []
  90. };
  91. },
  92. methods: {
  93. getData() {
  94. let params = {
  95. uid: this.userid,
  96. oid: this.oid,
  97. org: this.org
  98. };
  99. this.ajax
  100. .get(this.$store.state.api + "selectSRecordY", params)
  101. .then(res => {
  102. console.log("总学习记录数量", res);
  103. this.count = res.data[0].length; //总学习记录数量
  104. var data = res.data[0]; //总学习记录
  105. var ftype = res.data[1]; //公共父级分类
  106. var stype = res.data[2]; //公共子级分类
  107. var sctype = res.data[3]; //该学校子级分类
  108. var fctype = res.data[4]; //该学校父级分类
  109. var fotype = res.data[5]; //组织父级分类
  110. var sotype = res.data[6]; //组织子级分类
  111. var allfType = [];
  112. var allsType = [];
  113. if (fotype.length == 0 && sotype.length == 0) {
  114. if (fctype.length == 0 && sctype.length == 0) {
  115. for (var i = 0; i < ftype.length; i++) {
  116. allfType.push(ftype[i]);
  117. }
  118. for (var i = 0; i < stype.length; i++) {
  119. allsType.push(stype[[i]]);
  120. }
  121. } else {
  122. for (var i = 0; i < fctype.length; i++) {
  123. allfType.push(fctype[i]);
  124. }
  125. for (var i = 0; i < sctype.length; i++) {
  126. allsType.push(sctype[[i]]);
  127. }
  128. }
  129. } else {
  130. for (var i = 0; i < fotype.length; i++) {
  131. allfType.push(fotype[i]);
  132. }
  133. for (var i = 0; i < sotype.length; i++) {
  134. allsType.push(sctysotypepe[[i]]);
  135. }
  136. }
  137. var typeList = []; //记录子分类id(只有id)
  138. for (var i = 0; i < data.length; i++) {
  139. var a = data[i].type.split(",");
  140. if (a.length > 1) {
  141. for (var j = 0; j < a.length; j++) {
  142. typeList.push(a[j]);
  143. }
  144. } else {
  145. typeList.push(a[j]);
  146. }
  147. }
  148. var typeList1 = []; //记录子分类id(id,名字,pid)
  149. for (var i = 0; i < allsType.length; i++) {
  150. for (var j = 0; j < typeList.length; j++) {
  151. if (typeList[j] == allsType[i].id) {
  152. typeList1.push(allsType[i]);
  153. }
  154. }
  155. }
  156. // 是按照,上面总条数来循环下面的数据的条数的,只用父级循环,不能用子集,
  157. //不然子集的循环数据会重复,导致数据重复
  158. // console.log('allfType',allfType);
  159. // console.log('stype',stype);
  160. // 将每个大分类下的小分类数据提取出来,在大分类下创建一个child来存储
  161. allfType.forEach(e => {
  162. e.child = [];
  163. stype.forEach(i => {
  164. if (e.id == i.pid) {
  165. e.child.push(i.id);
  166. }
  167. });
  168. });
  169. // console.log("allfType1111111111", allfType);
  170. // 将数据所选的小分类变成数组
  171. data.forEach(e => {
  172. e.type = e.type.split(",");
  173. });
  174. // console.log("data", data);
  175. var ftypeList1 = [];
  176. allfType.forEach(e => {
  177. var count = 0;
  178. data.forEach(d => {
  179. let arr = [];
  180. arr = e.child.filter(value => d.type.includes(value));
  181. if (arr.length > 0) {
  182. count++;
  183. }
  184. });
  185. ftypeList1.push({
  186. id: e.id,
  187. name: e.name,
  188. count: count
  189. });
  190. });
  191. // console.log("ftypeList1", ftypeList1);
  192. // var ftypeList1 = [];
  193. // for (var i = 0; i < allfType.length; i++) {
  194. // var count = 0;
  195. // for (var j = 0; j < typeList1.length; j++) {
  196. // if (allfType[i].id == typeList1[j].pid) {
  197. // count++;
  198. // }
  199. // }
  200. // ftypeList1.push({
  201. // id: allfType[i].id,
  202. // name: allfType[i].name,
  203. // count: count,
  204. // });
  205. // }
  206. this.typeList = ftypeList1;
  207. // console.log('this.typeList',this.typeList);
  208. })
  209. .catch(err => {
  210. console.error(err);
  211. });
  212. }
  213. },
  214. mounted() {
  215. this.getData();
  216. }
  217. };
  218. </script>
  219. <style scoped>
  220. .i_body {
  221. width: 100%;
  222. height: 60%;
  223. min-height: 420px;
  224. background: #fff;
  225. border-radius: 10px;
  226. /* margin-bottom: 10px; */
  227. box-sizing: border-box;
  228. padding-bottom: 30px;
  229. overflow: auto;
  230. /* padding-bottom: 60px; */
  231. }
  232. .i_body_title {
  233. margin: 25px auto 15px;
  234. font-size: 20px;
  235. text-align: center;
  236. }
  237. .i_body_panel {
  238. width: 90%;
  239. display: flex;
  240. align-items: center;
  241. padding: 10px 15px;
  242. box-sizing: border-box;
  243. border-radius: 5px;
  244. margin: 0 auto;
  245. border: 1px solid #dbdbdb;
  246. background: rgb(252, 252, 252);
  247. }
  248. .i_body_panel + .i_body_panel {
  249. margin-top: 10px;
  250. }
  251. .i_body_panel > .i_icon {
  252. width: 40px;
  253. height: 40px;
  254. border-radius: 8px;
  255. display: flex;
  256. align-items: center;
  257. align-items: center;
  258. justify-content: center;
  259. margin-right: 10px;
  260. }
  261. .i_body_panel:nth-child(2) > .i_icon {
  262. background: rgb(54, 129, 252);
  263. }
  264. .i_body_panel:nth-child(2) > .i_icon > span {
  265. display: block;
  266. width: 20px;
  267. height: 20px;
  268. background-size: 100% 100%;
  269. background-image: url("../../../../assets/icon/studentEva/img_1.png");
  270. }
  271. .i_body_panel:nth-child(3) > .i_icon {
  272. background: rgb(23, 196, 105);
  273. }
  274. .i_body_panel:nth-child(3) > .i_icon > span {
  275. display: block;
  276. width: 20px;
  277. height: 20px;
  278. background-size: 100% 100%;
  279. background-image: url("../../../../assets/icon/studentEva/img_2.png");
  280. }
  281. .i_body_panel:nth-child(4) > .i_icon {
  282. background: rgb(230, 127, 54);
  283. }
  284. .i_body_panel:nth-child(4) > .i_icon > span {
  285. display: block;
  286. width: 20px;
  287. height: 20px;
  288. background-size: 100% 100%;
  289. background-image: url("../../../../assets/icon/studentEva/img_3.png");
  290. }
  291. .i_body_panel:nth-child(5) > .i_icon {
  292. background: rgb(54, 192, 230);
  293. }
  294. .i_body_panel:nth-child(5) > .i_icon > span {
  295. display: block;
  296. width: 20px;
  297. height: 20px;
  298. background-size: 100% 100%;
  299. background-image: url("../../../../assets/icon/studentEva/img_4.png");
  300. }
  301. .i_body_panel:nth-child(6) > .i_icon {
  302. background: rgb(54, 192, 230);
  303. }
  304. .i_body_panel:nth-child(6) > .i_icon > span {
  305. display: block;
  306. width: 20px;
  307. height: 20px;
  308. background-size: 100% 100%;
  309. background-image: url("../../../../assets/icon/studentEva/img_5.png");
  310. }
  311. .i_body_panel:nth-child(7) > .i_icon {
  312. background: rgb(54, 192, 230);
  313. }
  314. .i_body_panel:nth-child(7) > .i_icon > span {
  315. display: block;
  316. width: 20px;
  317. height: 20px;
  318. background-size: 100% 100%;
  319. background-image: url("../../../../assets/icon/studentEva/img_1.png");
  320. }
  321. .i_body_panel > .i_detail {
  322. width: clac(100% - 50px);
  323. }
  324. .i_body_panel > .i_detail > div:nth-child(1) {
  325. font-size: 12px;
  326. }
  327. .i_body_panel > .i_detail > div:nth-child(1) > span:nth-child(1) {
  328. font-size: 18px;
  329. font-weight: bold;
  330. margin-right: 5px;
  331. }
  332. .i_body_panel > .i_detail > div:nth-child(2) {
  333. color: #a1a1a1;
  334. font-size: 12px;
  335. margin-top: 0px;
  336. }
  337. </style>