studentRanked.vue 21 KB

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