studentRanked.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <view class="page">
  3. <view class="txt-white ui-flex-row ui-flex-align-center"
  4. style="border-bottom: 4px solid #4472C4;padding-left: 40rpx;height: 54px;width: 100%;z-index: 10;backdrop-filter: blur(4px);box-sizing: border-box;"
  5. :style="{'background-color': multiSelect ? '#4472c4' : ''}">
  6. <view class="ui-p ui-flex-row">
  7. <text class="f40">{{chooseClassName}}</text>
  8. <view class="ui-flex-row">
  9. <text class="f40 ui-ml30 ui-mr10">{{teacher.teacher_name}}</text>
  10. <!-- <u-icon name="arrow-down-fill" color="#fff"></u-icon> -->
  11. </view>
  12. </view>
  13. <view class="ui-p ui-flex ui-flex-1 ui-flex-align-center" style="justify-content: end;width: 450px;"
  14. v-if="multiSelect">
  15. <view class="ui-mr30">
  16. <text class="f32" style="#9ccbff">请点击选择学生批量点评</text>
  17. </view>
  18. <view class="ui-flex" style="width: 320px;">
  19. <el-button @click="setMulti(false)" plain text="取消选择" style="background-color: #0d4980;"
  20. class="ui-mr10">取消选择</el-button>
  21. <el-badge :value="activeList.length">
  22. <el-button type="primary" @click="commentMulti()">
  23. 批量点评
  24. </el-button>
  25. </el-badge>
  26. <el-badge :value="activeList.length" class="ui-ml30">
  27. <el-button type="primary" @click="commentAll()">
  28. 全班点评
  29. </el-button>
  30. </el-badge>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- <view class="platform" v-if="chooseClassName">
  35. <view class="platform-text txt-white">讲台</view>
  36. <view class="ranked-radio"></view>
  37. </view> -->
  38. <Draggable class="ui-flex-row ui-flex-space-around" :disabled="!seatMove" forceFallback
  39. style="padding:20rpx 0 200rpx 0;" group="ii" @end="onMoveColumnEnd" @choose="activeList = []" v-model="list"
  40. :delay="500" animation="300">
  41. <view v-for="(column, index) in list" :key="index" class="ui-flex-column" :class="{
  42. 'ui-mrr' : !!(index%2),
  43. 'ui-mll' : !(index%2)
  44. }">
  45. <!-- <view class="ui-flex-column" :class="{
  46. 'ui-mr10' : !!index%1,
  47. 'ui-ml10' : !!index%2
  48. }"> -->
  49. <view @click="toClickStu(stuItem)" v-for="stuItem in column.nodes" :key="stuItem.key"
  50. class="ui-flex-column ranked-item-tr ui-flex-align-center"
  51. :class="{
  52. active : activeList.includes(stuItem.id),
  53. 'ranked-item-hide' : !(stuItem.id || seatMove)
  54. }">
  55. <image class="stu-image" :src="getLevelIcon(stuItem)" style="width: 130rpx;height: 48rpx;"></image>
  56. <image class="stu-image" style="width: 100rpx;height: 100rpx;margin-top: -20rpx; border-radius: 300px; " :src="cartoonHeadImg ? stuItem.student_cartoon_photo : stuItem.student_photo+'?x-image-process=style/square400'" mode=""></image>
  57. <view class="stu-tag text-center ui-flex-row ui-mt10">
  58. <view class="stu-tag-add ui-flex-1">{{stuItem.plus_score_total}}</view>
  59. <view class="stu-tag-sub ui-flex-1">{{stuItem.minus_score_total}}</view>
  60. </view>
  61. <view class="txt-white f28 ui-pt10">
  62. {{stuItem.title}}
  63. </view>
  64. <u-badge absolute style="left: 10px;top: 10px;"
  65. :value="activeList.indexOf(stuItem.id) + 1"></u-badge>
  66. </view>
  67. <!-- </view> -->
  68. </view>
  69. </Draggable>
  70. <!-- 点评 -->
  71. <markScore @change='change' @close='onScoreClose' :stuList='activeList' ref="markScore"></markScore>
  72. <!-- 点评记录 -->
  73. <!-- :stuList="activeList" -->
  74. <markScoreList ref="markScoreList" :cartoonHeadImg="cartoonHeadImg" :chooseClassId="chooseClassId"></markScoreList>
  75. <!-- 随机点名 -->
  76. <randomRollCall ref="randomRollCall" :cartoonHeadImg="cartoonHeadImg" :list="studentList" @comment="randomRollComment"></randomRollCall>
  77. <!-- 计时器 -->
  78. <timerClock ref="timerClock"></timerClock>
  79. <!-- 排行榜 -->
  80. <rankList ref="rankList" :cartoonHeadImg="cartoonHeadImg" :chooseClassId="chooseClassId"></rankList>
  81. <view v-if="seatMove" class="ui-pull-bottom ui-p"
  82. style="background-color: #0000006b;backdrop-filter: blur(4px);border-top: 1px solid #616161;">
  83. <view class="ui-flex-row ui-flex-center txt-white ui-mt10 ui-mb30">
  84. 长按拖动调整整列,单选2位学生互相交换,
  85. <stuChangeExcel :stuList="list" @change="list = $event"></stuChangeExcel>
  86. </view>
  87. <view class="ui-flex-row ui-flex-center">
  88. <el-button round type="primary" @click="updateStuChange">保存座位</el-button>
  89. <el-button round type="text" @click="setSeatMove(false)">取消</el-button>
  90. </view>
  91. </view>
  92. <view v-else class="ui-pull-bottom ui-flex-row ui-p"
  93. style="background-color: #0000006b;backdrop-filter: blur(4px);border-top: 1px solid #616161;">
  94. <view class="ui-flex-1 ui-flex-row">
  95. <el-dropdown trigger="click" @command="doChooseClass">
  96. <view-btn-item title="选择班级" src="../../static/jyicon/shubao.png"></view-btn-item>
  97. <el-dropdown-menu slot="dropdown" :class="{'min-height': classesList.length >= 10}">
  98. <el-dropdown-item v-for="(item) in classesList" :key="item.id" :command="item">
  99. <text class="ui-mr10">{{item.class_name}}</text>
  100. <text v-if="item.id == chooseClassId" class="el-icon-check"></text>
  101. </el-dropdown-item>
  102. </el-dropdown-menu>
  103. </el-dropdown>
  104. <view-btn-item title="点评记录" src="../../static/jyicon/kedan.png"
  105. @click="$refs.markScoreList.open()"></view-btn-item>
  106. <view-btn-item title="切换头像" src="../../static/jyicon/chengchang.png"
  107. @click="cartoonHeadImg = !cartoonHeadImg"></view-btn-item>
  108. <view-btn-item title="座位调整" src="../../static/jyicon/xuewei.png"
  109. @click="setSeatMove(true)"></view-btn-item>
  110. <view-btn-item :title="multiSelect ? '取消多选' : '学生多选'" src="../../static/jyicon/gerenzhongxin.png"
  111. @click="setMulti(!multiSelect)"></view-btn-item>
  112. <view-btn-item title="随机点名" src="../../static/jyicon/fangfa.png"
  113. @click="$refs.randomRollCall.open()"></view-btn-item>
  114. <view-btn-item title="计时器" src="../../static/jyicon/shalou.png"
  115. @click="$refs.timerClock.open()"></view-btn-item>
  116. <view-btn-item title="撤销点评" src="../../static/jyicon/dingyue.png"
  117. :class="[lastTipBatchId ? 'bottom-btn-item' : 'bottom-btn-item-disabled']"
  118. @click="repealScore()"></view-btn-item>
  119. </view>
  120. <view class="ui-flex-row">
  121. <view-btn-item title="排行榜" src="../../static/jyicon/jiangpai.png"
  122. @click="$refs.rankList.open()"></view-btn-item>
  123. <!-- <view-btn-item title="切换老师" src="../../static/jyicon/jiangpai.png" @click="debug"></view-btn-item> -->
  124. <view-btn-item title="退出登录" src="../../static/jyicon/xiaoxi.png" @click="loginOut()"></view-btn-item>
  125. </view>
  126. </view>
  127. </view>
  128. </template>
  129. <script>
  130. import Draggable from "@/components/vuedraggable/src/vuedraggable.js";
  131. import markScore from './components/mark-score.vue'
  132. import markScoreList from './components/mark-score-list.vue'
  133. import randomRollCall from './components/random-roll-call.vue'
  134. import timerClock from './components/timer-clock.vue'
  135. import rankList from './components/rank-list.vue'
  136. import viewBtnItem from './components/view-button-item.vue'
  137. import stuChangeExcel from './components/students-change-excel.vue'
  138. import {
  139. getStuSchoolIdByStuClassId
  140. } from "@/common/api/stu.js"
  141. // const ExcelJS = require('exceljs');
  142. export default {
  143. components: {
  144. markScore,
  145. markScoreList,
  146. randomRollCall,
  147. timerClock,
  148. rankList,
  149. viewBtnItem,
  150. Draggable,
  151. stuChangeExcel,
  152. },
  153. data() {
  154. return {
  155. // show_classes: false,
  156. list: [],
  157. classesList: [],
  158. chooseClassName: '',
  159. chooseClassId: '',
  160. activeList: [],
  161. multiSelect: false,
  162. lastTipBatchId: '', // 最后点评的uuid,用于撤销,
  163. seatMove: false, //0不调整
  164. cartoonHeadImg : true,
  165. }
  166. },
  167. computed: {
  168. studentList() {
  169. let list = [];
  170. this.list.forEach(item => {
  171. item.nodes.forEach(el => {
  172. if (el.id) {
  173. list.push(el)
  174. }
  175. })
  176. })
  177. return list;
  178. },
  179. teacher() {
  180. return this.$store.state.teacherInfo || {}
  181. }
  182. },
  183. onLoad() {
  184. this.getClassroomList();
  185. let teacher_id = this.teacher.id;
  186. this.$api.sendRequest({
  187. url: `/mobile/teacher/draw`,
  188. method: "get",
  189. data: {
  190. teacher_id: teacher_id,
  191. year: 2024
  192. },
  193. success: res => {
  194. }
  195. })
  196. },
  197. methods: {
  198. debug() {
  199. console.log(this)
  200. },
  201. getLevelIcon(item) {
  202. let url = '//zhxy.obs.cn-hz1.ctyun.cn:443/static/';
  203. if (item.score_total == 0) {
  204. return url + 'tag_level/0.png'
  205. }
  206. let val = ~~((item.score_total) / 10);
  207. val = (val <= 0 ? 1 : val);
  208. val = (val >= 16 ? 16 : val);
  209. return url + 'tag_level/' + val + '.png';
  210. },
  211. // change(e) {
  212. // this.type = e == 0 ? 1 : 2
  213. // this.getTabs()
  214. // },
  215. setMulti(value) {
  216. this.multiSelect = value;
  217. this.activeList = [];
  218. },
  219. loginOut() {
  220. uni.removeStorageSync("teacherInfo")
  221. uni.removeStorageSync("token", '')
  222. uni.reLaunch({
  223. url: "/pages/login/login"
  224. })
  225. },
  226. doChooseClass(val) {
  227. uni.setStorage({
  228. key: 'lastClasses',
  229. data: val,
  230. success(e) {
  231. console.log(e)
  232. }
  233. });
  234. this.chooseClassId = val.id
  235. this.chooseClassName = val.class_name
  236. this.getStudent()
  237. // this.show_classes = false
  238. },
  239. // DelectSuccess(index) {
  240. // console.log(index);
  241. // this.getStudent()
  242. // this.getstudentTabLog()
  243. // },
  244. getClassroomList() {
  245. let teacher_id = this.teacher.id
  246. this.$api.sendRequest({
  247. url: `/mobile/teacher/teachClasses`,
  248. method: "post",
  249. data: {
  250. teacher_id: teacher_id
  251. },
  252. fali: res => {
  253. console.log(res);
  254. },
  255. success: res => {
  256. this.classesList = res.data;
  257. if (res.data.length) {
  258. let value = uni.getStorageSync('lastClasses')
  259. this.$nextTick(() => {
  260. this.doChooseClass(value || res.data[0])
  261. })
  262. }
  263. }
  264. })
  265. },
  266. // 随机点名后批量评价
  267. randomRollComment(checkList) {
  268. if (checkList.length) {
  269. this.activeList = checkList.map(item => {
  270. return item.id
  271. });
  272. this.commentMulti();
  273. }
  274. },
  275. // 多选学生点评
  276. commentMulti() {
  277. // this.stuName = this.stuNameList.toString()
  278. let title = this.activeList.map(stuId => {
  279. return this.studentList.find(el => {
  280. return el.id == stuId;
  281. }).title;
  282. }).join();
  283. if (title.length > 15) {
  284. title=title.substring(0, 15) + '...';
  285. }
  286. // this.getTabs()
  287. this.$refs.markScore.open(title);
  288. },
  289. commentAll() {
  290. this.activeList=[]
  291. let title = "全班"
  292. this.list.map(item=>{
  293. item.nodes.map(item2=>{
  294. if(item2.id){
  295. this.activeList.push(item2.id)
  296. }
  297. })
  298. })
  299. // this.$refs.markScore.open(title);
  300. },
  301. setSeatMove(value) {
  302. if (value) {
  303. this.setMulti(false);
  304. this.listCopy = uni.$u.deepClone(this.list);
  305. } else {
  306. this.list = uni.$u.deepClone(this.listCopy);
  307. }
  308. this.seatMove = value;
  309. this.activeList = [];
  310. },
  311. // 两个学生交换位置
  312. onMoveStuChange(id1, id2) {
  313. this.list.forEach(item => {
  314. item.nodes.forEach((el, index) => {
  315. if (el == this.onMoveStuChange._move1) {
  316. // console.log(1,el);
  317. this.$set(item.nodes, index, uni.$u.deepClone(this.onMoveStuChange._move2));
  318. }
  319. if (el == this.onMoveStuChange._move2) {
  320. this.$set(item.nodes, index, uni.$u.deepClone(this.onMoveStuChange._move1));
  321. }
  322. })
  323. })
  324. this.activeList = [];
  325. },
  326. onMoveColumnEnd(list) { //自动处理,无需改变
  327. // console.log(list);
  328. },
  329. // 更新座位
  330. updateStuChange() {
  331. let seat_list = this.list.map(item => {
  332. let nodesLen = item.nodes.length;
  333. return {
  334. id: item.id,
  335. title: item.title,
  336. nodes: item.nodes.filter((el, index) => {
  337. if(el.id){
  338. return true;
  339. }
  340. return index + 1 < nodesLen;
  341. }).map(el => {
  342. return {
  343. id: el.id,
  344. key: el.key,
  345. title: el.title
  346. }
  347. })
  348. }
  349. })
  350. // console.log(seat_list);
  351. // return;
  352. this.$api.sendRequest({
  353. url: `/mobile/saveSeat`,
  354. method: "PUT",
  355. data: {
  356. classroom_id: this.chooseClassId,
  357. seat_list: seat_list
  358. },
  359. success: res => {
  360. uni.showToast({
  361. title: res.msg,
  362. });
  363. this.seatMove = false;
  364. // this.setSeatMove(true);
  365. }
  366. })
  367. },
  368. // 点击学生
  369. toClickStu(item) {
  370. if(!item.id){
  371. if(!this.seatMove){
  372. return;
  373. }
  374. if(this.seatMove && this.activeList.length == 0){
  375. return;
  376. }
  377. }
  378. if (this.seatMove) { //单个换位置
  379. if (this.activeList.length == 0) {
  380. this.activeList.push(item.id);
  381. this.onMoveStuChange._move1 = item;
  382. } else {
  383. this.onMoveStuChange._move2 = item;
  384. this.onMoveStuChange(this.activeList[0], item.id);
  385. }
  386. return;
  387. }
  388. if (this.multiSelect) {
  389. let index = this.activeList.indexOf(item.id)
  390. if (index >= 0) {
  391. this.activeList.splice(index, 1);
  392. } else {
  393. this.activeList.push(item.id);
  394. }
  395. return;
  396. }
  397. this.activeList = [item.id];
  398. this.commentMulti();
  399. },
  400. // 获取学生列表
  401. getStudent() {
  402. this.$api.sendRequest({
  403. url: `/mobile/studentTab/seat`,
  404. data: {
  405. class_id: this.chooseClassId
  406. },
  407. success: res => {
  408. this.list = res.data;
  409. /* .reverse().map(item => {
  410. item.nodes = item.nodes.reverse().filter(el => {
  411. return !!el.id;
  412. })
  413. return item;
  414. }) */
  415. }
  416. })
  417. },
  418. // getTabs() {
  419. // this.$api.sendRequest({
  420. // url: `/mobile/studentTab/getStudentTabs`,
  421. // method: "post",
  422. // data: {
  423. // teacher_id: this.$store.state.teacher_id,
  424. // type: this.type
  425. // },
  426. // success: res => {
  427. // this.tabList = res.data
  428. // }
  429. // })
  430. // },
  431. onScoreClose(lastTipBatchId = false) {
  432. if (lastTipBatchId) {
  433. this.activeList = []
  434. this.multiSelect = false
  435. this.getStudent();
  436. this.lastTipBatchId = lastTipBatchId;
  437. }
  438. // this.getstudentTabLog()
  439. },
  440. repealScore() {
  441. this.$api.sendRequest({
  442. url: `/mobile/studentTab/multiDelStudentTabLog`,
  443. method: "post",
  444. data: {
  445. batch_id: this.lastTipBatchId
  446. },
  447. success: res => {
  448. this.lastTipBatchId = null;
  449. this.getStudent();
  450. }
  451. })
  452. }
  453. },
  454. }
  455. </script>
  456. <style lang="scss" scoped>
  457. .page {
  458. background-image: url('https://zhxy.obs.cn-hz1.ctyun.cn:443/static/desk_bg/class_bj.jpg');
  459. background-size: 100% 100%;
  460. height: auto;
  461. // width: 750rpx;
  462. }
  463. .platform {
  464. display: flex;
  465. justify-content: center;
  466. align-items: center;
  467. position: relative;
  468. height: 30rpx;
  469. margin-top: 60rpx;
  470. .platform-color {
  471. position: absolute;
  472. left: 0;
  473. top: 0;
  474. height: 60rpx;
  475. background-color: rgba(5, 204, 161, 1);
  476. width: 10rpx;
  477. }
  478. .platform-text {
  479. text-align: center;
  480. width: 60%;
  481. margin-bottom: 40rpx;
  482. }
  483. }
  484. .pop-title {
  485. border-bottom: 1px solid #f2f2f2;
  486. font-size: 36rpx;
  487. padding-bottom: 20rpx;
  488. display: flex;
  489. align-items: center;
  490. }
  491. .popup-content {
  492. border-radius: 10px;
  493. box-sizing: border-box;
  494. padding: 0 32rpx;
  495. }
  496. .btn-roll {
  497. background-color: #fff;
  498. border-radius: 25rpx;
  499. width: 190rpx;
  500. color: #666;
  501. height: 60rpx;
  502. line-height: 60rpx;
  503. text-align: center;
  504. margin-left: 32rpx;
  505. }
  506. .ranked {
  507. width: 100%;
  508. text-align: center;
  509. font-size: 10px;
  510. box-sizing: border-box;
  511. display: flex;
  512. padding-top: 80rpx;
  513. }
  514. .ranked-item-tr {
  515. position: relative;
  516. margin-bottom: 26rpx;
  517. padding-top: 16rpx;
  518. padding-bottom: 16rpx;
  519. border-radius: 5px;
  520. box-sizing: border-box;
  521. width: 100%;
  522. cursor: pointer;
  523. transition: 100ms;
  524. display: flex;
  525. justify-content: center;
  526. }
  527. .ranked-item-tr:hover,
  528. .active {
  529. background: #ffffff85;
  530. }
  531. .ranked-item-hide .stu-tag,
  532. .ranked-item-hide .stu-image,
  533. {
  534. opacity: 0;
  535. }
  536. .min-height {
  537. max-height: 400px;
  538. overflow-y: scroll;
  539. }
  540. .ranked-radio {
  541. width: 100px;
  542. position: absolute;
  543. left: 50%;
  544. transform: translate(-50%);
  545. bottom: 0rpx;
  546. border-bottom: 3px solid rgba(5, 204, 161, 1);
  547. border-radius: 50% 50% 0 0;
  548. }
  549. .visit-item {
  550. display: flex;
  551. align-items: center;
  552. .visit-item-left {
  553. width: 120rpx;
  554. color: #666;
  555. }
  556. }
  557. .stu-tag {
  558. width: 160rpx;
  559. margin-left: 10rpx;
  560. margin-right: 10rpx;
  561. border-radius: 15px;
  562. overflow: hidden;
  563. }
  564. .stu-tag-add {
  565. background-color: #ecf5ff;
  566. color: #3c9cff;
  567. border: 1px solid #fff;
  568. }
  569. .stu-tag-sub {
  570. background-color: #fef0f0;
  571. color: #f56c6c;
  572. border: 1px solid #fff;
  573. border-left: 0;
  574. }
  575. .ui-mrr {
  576. margin-right: 50rpx;
  577. }
  578. .ui-mll {
  579. margin-left: 50rpx;
  580. }
  581. .sortable-chosen {
  582. background-color: #fbfbfb66;
  583. border-radius: 5px;
  584. }
  585. .sortable-ghost {
  586. // margin-left : 0 !important;
  587. // margin-right : 0 !important;
  588. background-color: #fbfbfb00;
  589. }
  590. </style>