databoard.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. <template>
  2. <div
  3. class="pb_content"
  4. style="height: auto; width: calc(100%); margin: 0 auto;background: unset;"
  5. >
  6. <div class="bbox_serch">
  7. <el-select
  8. v-model="selectTime"
  9. placeholder="请选择"
  10. size="small"
  11. style="margin:0 10px 0 10px;"
  12. v-if="timeSort.length > 1"
  13. @change="changeTimeSort"
  14. >
  15. <el-option
  16. v-for="item in timeSort"
  17. :key="item.id"
  18. :label="item.label"
  19. :value="item.id"
  20. >
  21. </el-option>
  22. </el-select>
  23. <Cascader
  24. :options="typeInfo"
  25. v-if="typeInfo.length"
  26. @setTeacher="setTeacher"
  27. ></Cascader>
  28. </div>
  29. <div class="bbox" v-loading="tabLoading">
  30. <div class="bbox_nav">
  31. <div class="teaLis">
  32. <div
  33. class="teal"
  34. @click="cutPage(2)"
  35. :class="[pType == 2 ? 'Tbor' : '']"
  36. v-if="bArray.length"
  37. >
  38. 专任教师
  39. </div>
  40. <div
  41. class="teal"
  42. @click="cutPage(1)"
  43. :class="[pType == 1 ? 'Tbor' : '']"
  44. v-if="aArray.length"
  45. >
  46. 班主任
  47. </div>
  48. </div>
  49. <el-select
  50. v-model="checkSet"
  51. @change="setArray"
  52. style="margin-left: auto"
  53. >
  54. <el-option label="综合排序" value=""> </el-option>
  55. <el-option
  56. v-for="item in options"
  57. :key="item.value"
  58. :label="item.label"
  59. :value="item.value"
  60. >
  61. </el-option>
  62. </el-select>
  63. </div>
  64. <div class="randarZong">
  65. <radarZong
  66. :evCourseArray="zongJson"
  67. :evCourseArray2="zongJson2"
  68. v-if="checkSet"
  69. ></radarZong>
  70. <radarZong
  71. :evCourseArray="zongJson2"
  72. :evCourseArray2="{}"
  73. v-else
  74. ></radarZong>
  75. </div>
  76. <div class="randarBox">
  77. <div class="title">教师详情</div>
  78. <div
  79. class="randarTeacher"
  80. v-for="(item, index) in tableData"
  81. :key="index"
  82. >
  83. <div class="randarTitle">
  84. <span>{{ item.username }}</span>
  85. <span>{{ item.score }}</span>
  86. </div>
  87. <div class="randar">
  88. <radarTeacher
  89. :evCourseArray="zongJson2"
  90. :evCourseArray2="item.json"
  91. ></radarTeacher>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. var OpenCC = require("opencc-js");
  100. let converter = OpenCC.Converter({
  101. from: "hk",
  102. to: "cn"
  103. });
  104. import radarZong from "./dataCom/radarZong.vue";
  105. import radarTeacher from "./dataCom/radarTeacher.vue";
  106. import Cascader from "./dataCom/cascader.vue";
  107. export default {
  108. name: "testDataBoard",
  109. components: { radarZong, radarTeacher, Cascader },
  110. data() {
  111. return {
  112. userid: this.$route.query.userid, //用户id
  113. oid: this.$route.query.oid, //学校id
  114. org: this.$route.query.org, //组织id
  115. pType: 2,
  116. teacherName: "",
  117. tabLoading: false,
  118. tableData: [],
  119. zongJson: {},
  120. zongJson2: {},
  121. checkSet: "",
  122. options: [],
  123. data: [],
  124. typeInfo: [],
  125. teacherArray: [],
  126. aArray: [],
  127. bArray: [],
  128. timeSort: [],
  129. selectTime: ""
  130. };
  131. },
  132. computed: {
  133. getScore() {
  134. return item => {
  135. let score = 0;
  136. for (var i = 0; i < item.length; i++) {
  137. score += item[i].cogScore;
  138. }
  139. score = (score / item.length).toFixed(0);
  140. return score;
  141. };
  142. }
  143. },
  144. methods: {
  145. getPageBase2(type) {
  146. let params = {
  147. typ: type,
  148. org: this.org,
  149. oid: this.oid
  150. };
  151. this.ajax
  152. .get(this.$store.state.api + "selectTestExamineBase", params)
  153. .then(res => {
  154. console.log("1111111111111111111111", res.data);
  155. if (type == 1) {
  156. this.aArray = res.data[0];
  157. } else {
  158. this.bArray = res.data[0];
  159. if (!this.bArray.length) {
  160. this.cutPage(2);
  161. }
  162. }
  163. this.timeSort = res.data[0].map(item => {
  164. return {
  165. label: item.timeName,
  166. id: item.time,
  167. time: item.timeName.split("~")[0]
  168. };
  169. });
  170. if (this.timeSort.length > 0) {
  171. this.selectTime = this.timeSort[0].id;
  172. }
  173. })
  174. .catch(error => {
  175. console.log(error);
  176. });
  177. },
  178. goTo(path) {
  179. this.$router.push(path);
  180. },
  181. cutPage(type) {
  182. this.checkSet = "";
  183. this.pType = type;
  184. this.getData();
  185. },
  186. scoreChildren(children) {
  187. let score = 0;
  188. children.forEach(item => {
  189. if (item.sco2 && parseFloat(item.sco2) > 0) {
  190. score += parseFloat(item.sco2);
  191. }
  192. });
  193. return score;
  194. },
  195. getData() {
  196. this.tabLoading = true;
  197. let params = [
  198. {
  199. oid: this.oid,
  200. org: this.org,
  201. type: this.pType,
  202. tname: this.teacherName
  203. }
  204. ];
  205. // console.log(params);
  206. this.ajax
  207. .post(this.$store.state.api + "selectTestExaminePersonData2", params)
  208. .then(res => {
  209. let data = res.data[0];
  210. data.forEach(e => {
  211. e.json = JSON.parse(e.json);
  212. });
  213. if (this.selectTime && this.timeSort.length > 1) {
  214. data = data.filter(item => item.time == this.selectTime);
  215. }
  216. data.forEach(e => {
  217. e.evaSca = 0;
  218. e.cogSco = 0;
  219. e.step = 0;
  220. e.allStep = 0;
  221. e.json.forEach(i => {
  222. i.evaScore = 0; // 自评
  223. i.cogScore = 0; //考核
  224. i.score = 0; //考核
  225. i.children.forEach(k => {
  226. e.evaSca = e.evaSca + k.sco1 * 1;
  227. e.cogSco = e.cogSco + k.sco2 * 1;
  228. i.evaScore = i.evaScore + k.sco1 * 1;
  229. i.cogScore = i.cogScore + k.sco2 * 1;
  230. i.score = i.score + k.score * 1;
  231. e.allStep++;
  232. if (!!k.sco2 * 1) {
  233. e.step++;
  234. }
  235. });
  236. });
  237. });
  238. data.forEach(e => {
  239. if (e.step == e.allStep) {
  240. e.state = "已完成";
  241. } else {
  242. e.state = "未完成";
  243. }
  244. if (!e.tea) {
  245. e.tea = "";
  246. }
  247. e.evaSca = e.evaSca.toFixed(0);
  248. e.cogSco = e.cogSco.toFixed(0);
  249. });
  250. let _data = [];
  251. let zongJson = {};
  252. // zongJson.count = data.length
  253. data.forEach((e, index) => {
  254. _data[index] = {};
  255. _data[index].username = e.username;
  256. _data[index].evaSca = e.evaSca;
  257. _data[index].cogSco = e.cogSco;
  258. _data[index].json = [];
  259. e.json.forEach((i, iindex) => {
  260. if (
  261. converter(i.name) == converter("科组评价") ||
  262. converter(i.name) == converter("行政巡查")
  263. ) {
  264. return;
  265. }
  266. _data[index].json[iindex] = {};
  267. _data[index].json[iindex].name = i.name;
  268. let _evaScore = parseInt(
  269. (i.evaScore * (100 / i.score)).toFixed(0)
  270. );
  271. let _cogScore = parseInt(
  272. (i.cogScore * (100 / i.score)).toFixed(0)
  273. );
  274. _data[index].json[iindex].evaScore = _evaScore; // 自评
  275. _data[index].json[iindex].cogScore = _cogScore; // 考核
  276. zongJson[i.name] ? "" : (zongJson[i.name] = {});
  277. zongJson[i.name].evaScore
  278. ? (zongJson[i.name].evaScore += _evaScore)
  279. : (zongJson[i.name].evaScore = _evaScore);
  280. zongJson[i.name].cogScore
  281. ? (zongJson[i.name].cogScore += _cogScore)
  282. : (zongJson[i.name].cogScore = _cogScore);
  283. });
  284. });
  285. let zongArray = Object.keys(zongJson);
  286. for (var i = 0; i < zongArray.length; i++) {
  287. zongJson[zongArray[i]].evaScore = (
  288. zongJson[zongArray[i]].evaScore / data.length
  289. ).toFixed(0);
  290. zongJson[zongArray[i]].cogScore = (
  291. zongJson[zongArray[i]].cogScore / data.length
  292. ).toFixed(0);
  293. }
  294. this.tableData = _data
  295. .filter(e => {
  296. e.score = this.getScore(e.json);
  297. return e;
  298. })
  299. .sort((a, b) => b.score - a.score);
  300. console.log(this.tableData);
  301. this.zongJson = zongJson;
  302. this.zongJson2 = zongJson;
  303. console.log(zongJson);
  304. this.options = Object.keys(zongJson).map(item => {
  305. return { label: item, value: item };
  306. });
  307. this.data = data;
  308. console.log(data);
  309. this.tabLoading = false;
  310. })
  311. .catch(error => {
  312. this.tabLoading = false;
  313. console.log(error);
  314. });
  315. },
  316. setTeacher(array) {
  317. this.teacherArray = array;
  318. this.setArray();
  319. },
  320. setArray() {
  321. let checkSet = this.checkSet;
  322. let _data = [];
  323. let zongJson = {};
  324. let data = JSON.parse(JSON.stringify(this.data));
  325. if (this.teacherArray.length) {
  326. data = data.filter(e => {
  327. return this.teacherArray.includes(e.userid);
  328. });
  329. }
  330. data.forEach((e, index) => {
  331. _data[index] = {};
  332. _data[index].username = e.username;
  333. if (checkSet == "") {
  334. _data[index].evaSca = e.evaSca;
  335. _data[index].cogSco = e.cogSco;
  336. _data[index].json = [];
  337. }
  338. e.json.forEach((i, iindex) => {
  339. if (
  340. converter(i.name) == converter("科组评价") ||
  341. converter(i.name) == converter("行政巡查")
  342. ) {
  343. return;
  344. }
  345. if (checkSet == i.name) {
  346. _data[index].evaSca = i.evaScore;
  347. _data[index].cogSco = i.cogScore;
  348. _data[index].json = [];
  349. i.children.forEach((ic, icindex) => {
  350. _data[index].json[icindex] = {};
  351. _data[index].json[icindex].name = ic.name;
  352. let _evaScore = parseInt(
  353. (ic.sco1 * 1 * (100 / ic.score)).toFixed(0)
  354. );
  355. let _cogScore = parseInt(
  356. (ic.sco2 * 1 * (100 / ic.score)).toFixed(0)
  357. );
  358. _data[index].json[icindex].evaScore = _evaScore; // 自评
  359. _data[index].json[icindex].cogScore = _cogScore; // 考核
  360. zongJson[ic.name] ? "" : (zongJson[ic.name] = {});
  361. zongJson[ic.name].evaScore
  362. ? (zongJson[ic.name].evaScore += _evaScore)
  363. : (zongJson[ic.name].evaScore = _evaScore);
  364. zongJson[ic.name].cogScore
  365. ? (zongJson[ic.name].cogScore += _cogScore)
  366. : (zongJson[ic.name].cogScore = _cogScore);
  367. });
  368. } else if (checkSet == "") {
  369. _data[index].json[iindex] = {};
  370. _data[index].json[iindex].name = i.name;
  371. let _evaScore = parseInt((i.evaScore * (100 / i.score)).toFixed(0));
  372. let _cogScore = parseInt((i.cogScore * (100 / i.score)).toFixed(0));
  373. _data[index].json[iindex].evaScore = _evaScore; // 自评
  374. _data[index].json[iindex].cogScore = _cogScore; // 考核
  375. zongJson[i.name] ? "" : (zongJson[i.name] = {});
  376. zongJson[i.name].evaScore
  377. ? (zongJson[i.name].evaScore += _evaScore)
  378. : (zongJson[i.name].evaScore = _evaScore);
  379. zongJson[i.name].cogScore
  380. ? (zongJson[i.name].cogScore += _cogScore)
  381. : (zongJson[i.name].cogScore = _cogScore);
  382. }
  383. });
  384. });
  385. let zongArray = Object.keys(zongJson);
  386. for (var i = 0; i < zongArray.length; i++) {
  387. zongJson[zongArray[i]].evaScore = (
  388. zongJson[zongArray[i]].evaScore / data.length
  389. ).toFixed(0);
  390. zongJson[zongArray[i]].cogScore = (
  391. zongJson[zongArray[i]].cogScore / data.length
  392. ).toFixed(0);
  393. }
  394. this.tableData = _data
  395. .filter(e => {
  396. e.score = this.getScore(e.json);
  397. return e;
  398. })
  399. .sort((a, b) => b.score - a.score);
  400. console.log(this.tableData);
  401. this.zongJson2 = zongJson;
  402. console.log(zongJson);
  403. },
  404. //获取分类类名
  405. getTypeInfo() {
  406. this.tabLoading = true;
  407. let params = {
  408. oid: this.oid
  409. };
  410. this.ajax
  411. .get(this.$store.state.api + "selectPerInfoAllTea", params)
  412. .then(res => {
  413. this.typeInfo = res.data[0];
  414. let typeInfo = res.data[1];
  415. this.typeInfo.forEach(e => {
  416. e.child = [];
  417. e.value = "";
  418. typeInfo.forEach(i => {
  419. if (e.id == i.parentid) {
  420. e.child.push({ id: i.id, name: i.name });
  421. }
  422. });
  423. });
  424. this.getData();
  425. })
  426. .catch(err => {
  427. this.tabLoading = false;
  428. console.error(err);
  429. });
  430. },
  431. changeTimeSort() {
  432. this.cutPage(2);
  433. }
  434. },
  435. mounted() {
  436. this.getPageBase2(1);
  437. this.getPageBase2(2);
  438. this.getTypeInfo();
  439. }
  440. };
  441. </script>
  442. <style scoped>
  443. .bbox_serch {
  444. width: 100%;
  445. margin-bottom: 10px;
  446. display: flex;
  447. align-items: center;
  448. background-color: #e6eaf0;
  449. }
  450. .top {
  451. display: flex;
  452. justify-content: space-between;
  453. width: 100% !important;
  454. box-sizing: border-box;
  455. margin: 0px auto;
  456. padding: 10px 0;
  457. height: 54px;
  458. }
  459. .subClick {
  460. font-size: 16px;
  461. cursor: pointer;
  462. margin-left: 10px;
  463. /* color: #ab582f; */
  464. color: #409eff;
  465. }
  466. .sub_head {
  467. position: relative;
  468. font-size: 20px;
  469. font-weight: bold;
  470. padding: 0 15px;
  471. }
  472. .sub_head::after {
  473. content: "";
  474. width: 100%;
  475. background: #3681fc;
  476. height: 2px;
  477. position: absolute;
  478. left: 0;
  479. bottom: -8px;
  480. }
  481. .subClick {
  482. /* font-size: 16px; */
  483. font-size: 20px;
  484. cursor: pointer;
  485. /* margin-left: 17.5px; */
  486. /* color: #ab582f; */
  487. /* color: #409eff; */
  488. color: #999;
  489. padding: 0 15px;
  490. }
  491. .subClick:hover {
  492. color: #000;
  493. }
  494. .sub_head + .subClick,
  495. .subClick + .subClick,
  496. .subClick + .sub_head {
  497. margin-left: 17.5px;
  498. }
  499. .bbox {
  500. background: #fff;
  501. border-radius: 0 5px 5px 5px;
  502. padding: 15px 0;
  503. box-sizing: border-box;
  504. min-height: 900px;
  505. }
  506. .bbox_nav {
  507. display: flex;
  508. width: 100%;
  509. box-sizing: border-box;
  510. padding: 0 20px;
  511. align-items: center;
  512. }
  513. .teaLis {
  514. display: flex;
  515. }
  516. .teal {
  517. padding: 10px 20px;
  518. cursor: pointer;
  519. }
  520. .Tbor {
  521. border-bottom: 2px rgba(54, 129, 252, 1) solid;
  522. font-weight: 600;
  523. }
  524. .randarZong {
  525. max-width: 100%;
  526. width: 500px;
  527. height: 500px;
  528. margin: 0 auto;
  529. }
  530. .randarBox {
  531. padding: 20px;
  532. width: 100%;
  533. box-sizing: border-box;
  534. display: flex;
  535. flex-wrap: wrap;
  536. }
  537. .randarBox .title {
  538. width: 100%;
  539. font-size: 18px;
  540. font-weight: 700;
  541. margin-bottom: 20px;
  542. }
  543. .randarTeacher {
  544. width: calc(100% / 4 - 20px);
  545. margin-right: 20px;
  546. margin-bottom: 20px;
  547. }
  548. .randarTitle {
  549. display: flex;
  550. align-items: center;
  551. justify-content: space-between;
  552. margin-bottom: 10px;
  553. }
  554. .randarTitle > span:nth-child(1) {
  555. }
  556. .randarTitle > span:nth-child(2) {
  557. }
  558. .randar {
  559. width: calc(100%);
  560. height: 350px;
  561. border: 1px solid #e4e4e4;
  562. border-radius: 5px;
  563. }
  564. @media screen and (max-width: 1280px) {
  565. .randarTeacher {
  566. width: calc(100% / 2 - 20px);
  567. }
  568. }
  569. @media screen and (max-width: 800px) {
  570. .randarTeacher {
  571. width: calc(100%);
  572. margin-right: 0;
  573. }
  574. }
  575. </style>