studentRanked.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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.removeStorageSync("teacherInfo")
  217. uni.removeStorageSync("token", '')
  218. uni.reLaunch({
  219. url: "/pages/login/login"
  220. })
  221. },
  222. doChooseClass(val) {
  223. uni.setStorage({
  224. key: 'lastClasses',
  225. data: val,
  226. success(e) {
  227. console.log(e)
  228. }
  229. });
  230. this.chooseClassId = val.id
  231. this.chooseClassName = val.class_name
  232. this.getStudent()
  233. // this.show_classes = false
  234. },
  235. // DelectSuccess(index) {
  236. // console.log(index);
  237. // this.getStudent()
  238. // this.getstudentTabLog()
  239. // },
  240. getClassroomList() {
  241. let teacher_id = this.teacher.id
  242. this.$api.sendRequest({
  243. url: `/mobile/teacher/teachClasses`,
  244. method: "post",
  245. data: {
  246. teacher_id: teacher_id
  247. },
  248. fali: res => {
  249. console.log(res);
  250. },
  251. success: res => {
  252. this.classesList = res.data;
  253. if (res.data.length) {
  254. let value = uni.getStorageSync('lastClasses')
  255. this.$nextTick(() => {
  256. this.doChooseClass(value || res.data[0])
  257. })
  258. }
  259. }
  260. })
  261. },
  262. // 随机点名后批量评价
  263. randomRollComment(checkList) {
  264. if (checkList.length) {
  265. this.activeList = checkList.map(item => {
  266. return item.id
  267. });
  268. this.commentMulti();
  269. }
  270. },
  271. // 多选学生点评
  272. commentMulti() {
  273. // this.stuName = this.stuNameList.toString()
  274. let title = this.activeList.map(stuId => {
  275. return this.studentList.find(el => {
  276. return el.id == stuId;
  277. }).title;
  278. }).join();
  279. if (title.length > 15) {
  280. title=title.substring(0, 15) + '...';
  281. }
  282. // this.getTabs()
  283. this.$refs.markScore.open(title);
  284. },
  285. commentAll() {
  286. this.activeList=[]
  287. let title = "全班"
  288. this.list.map(item=>{
  289. item.nodes.map(item2=>{
  290. if(item2.id){
  291. this.activeList.push(item2.id)
  292. }
  293. })
  294. })
  295. // this.$refs.markScore.open(title);
  296. },
  297. setSeatMove(value) {
  298. if (value) {
  299. this.setMulti(false);
  300. this.listCopy = uni.$u.deepClone(this.list);
  301. } else {
  302. this.list = uni.$u.deepClone(this.listCopy);
  303. }
  304. this.seatMove = value;
  305. this.activeList = [];
  306. },
  307. // 两个学生交换位置
  308. onMoveStuChange(id1, id2) {
  309. this.list.forEach(item => {
  310. item.nodes.forEach((el, index) => {
  311. if (el == this.onMoveStuChange._move1) {
  312. // console.log(1,el);
  313. this.$set(item.nodes, index, uni.$u.deepClone(this.onMoveStuChange._move2));
  314. }
  315. if (el == this.onMoveStuChange._move2) {
  316. this.$set(item.nodes, index, uni.$u.deepClone(this.onMoveStuChange._move1));
  317. }
  318. })
  319. })
  320. this.activeList = [];
  321. },
  322. onMoveColumnEnd(list) { //自动处理,无需改变
  323. // console.log(list);
  324. },
  325. // 更新座位
  326. updateStuChange() {
  327. let seat_list = this.list.map(item => {
  328. return {
  329. id: item.id,
  330. title: item.title,
  331. nodes: item.nodes.map(el => {
  332. return {
  333. id: el.id,
  334. key: el.key,
  335. title: el.title
  336. }
  337. })
  338. }
  339. })
  340. // console.log(data);
  341. this.$api.sendRequest({
  342. url: `/mobile/saveSeat`,
  343. method: "PUT",
  344. data: {
  345. classroom_id: this.chooseClassId,
  346. seat_list: seat_list
  347. },
  348. success: res => {
  349. uni.showToast({
  350. title: res.msg,
  351. });
  352. this.seatMove = false;
  353. // this.setSeatMove(true);
  354. }
  355. })
  356. },
  357. // 点击学生
  358. toClickStu(item) {
  359. if(!item.id){
  360. if(!this.seatMove){
  361. return;
  362. }
  363. if(this.seatMove && this.activeList.length == 0){
  364. return;
  365. }
  366. }
  367. if (this.seatMove) { //单个换位置
  368. if (this.activeList.length == 0) {
  369. this.activeList.push(item.id);
  370. this.onMoveStuChange._move1 = item;
  371. } else {
  372. this.onMoveStuChange._move2 = item;
  373. this.onMoveStuChange(this.activeList[0], item.id);
  374. }
  375. return;
  376. }
  377. if (this.multiSelect) {
  378. let index = this.activeList.indexOf(item.id)
  379. if (index >= 0) {
  380. this.activeList.splice(index, 1);
  381. } else {
  382. this.activeList.push(item.id);
  383. }
  384. return;
  385. }
  386. this.activeList = [item.id];
  387. this.commentMulti();
  388. },
  389. // 获取学生列表
  390. getStudent() {
  391. this.$api.sendRequest({
  392. url: `/mobile/studentTab/seat`,
  393. data: {
  394. class_id: this.chooseClassId
  395. },
  396. success: res => {
  397. this.list = res.data;
  398. /* .reverse().map(item => {
  399. item.nodes = item.nodes.reverse().filter(el => {
  400. return !!el.id;
  401. })
  402. return item;
  403. }) */
  404. }
  405. })
  406. },
  407. // getTabs() {
  408. // this.$api.sendRequest({
  409. // url: `/mobile/studentTab/getStudentTabs`,
  410. // method: "post",
  411. // data: {
  412. // teacher_id: this.$store.state.teacher_id,
  413. // type: this.type
  414. // },
  415. // success: res => {
  416. // this.tabList = res.data
  417. // }
  418. // })
  419. // },
  420. onScoreClose(lastTipBatchId = false) {
  421. if (lastTipBatchId) {
  422. this.activeList = []
  423. this.multiSelect = false
  424. this.getStudent();
  425. this.lastTipBatchId = lastTipBatchId;
  426. }
  427. // this.getstudentTabLog()
  428. },
  429. repealScore() {
  430. this.$api.sendRequest({
  431. url: `/mobile/studentTab/multiDelStudentTabLog`,
  432. method: "post",
  433. data: {
  434. batch_id: this.lastTipBatchId
  435. },
  436. success: res => {
  437. this.lastTipBatchId = null;
  438. }
  439. })
  440. }
  441. },
  442. }
  443. </script>
  444. <style lang="scss" scoped>
  445. .page {
  446. background-image: url('https://zhxy.obs.cn-hz1.ctyun.cn:443/static/desk_bg/class_bj.jpg');
  447. background-size: 100% 100%;
  448. height: auto;
  449. // width: 750rpx;
  450. }
  451. .platform {
  452. display: flex;
  453. justify-content: center;
  454. align-items: center;
  455. position: relative;
  456. height: 30rpx;
  457. margin-top: 60rpx;
  458. .platform-color {
  459. position: absolute;
  460. left: 0;
  461. top: 0;
  462. height: 60rpx;
  463. background-color: rgba(5, 204, 161, 1);
  464. width: 10rpx;
  465. }
  466. .platform-text {
  467. text-align: center;
  468. width: 60%;
  469. margin-bottom: 40rpx;
  470. }
  471. }
  472. .pop-title {
  473. border-bottom: 1px solid #f2f2f2;
  474. font-size: 36rpx;
  475. padding-bottom: 20rpx;
  476. display: flex;
  477. align-items: center;
  478. }
  479. .popup-content {
  480. border-radius: 10px;
  481. box-sizing: border-box;
  482. padding: 0 32rpx;
  483. }
  484. .btn-roll {
  485. background-color: #fff;
  486. border-radius: 25rpx;
  487. width: 190rpx;
  488. color: #666;
  489. height: 60rpx;
  490. line-height: 60rpx;
  491. text-align: center;
  492. margin-left: 32rpx;
  493. }
  494. .ranked {
  495. width: 100%;
  496. text-align: center;
  497. font-size: 10px;
  498. box-sizing: border-box;
  499. display: flex;
  500. padding-top: 80rpx;
  501. }
  502. .ranked-item-tr {
  503. position: relative;
  504. margin-bottom: 26rpx;
  505. padding-top: 16rpx;
  506. padding-bottom: 16rpx;
  507. border-radius: 5px;
  508. box-sizing: border-box;
  509. width: 100%;
  510. cursor: pointer;
  511. transition: 100ms;
  512. display: flex;
  513. justify-content: center;
  514. }
  515. .active {
  516. background: #ffffff85;
  517. }
  518. .ranked-radio {
  519. width: 100px;
  520. position: absolute;
  521. left: 50%;
  522. transform: translate(-50%);
  523. bottom: 0rpx;
  524. border-bottom: 3px solid rgba(5, 204, 161, 1);
  525. border-radius: 50% 50% 0 0;
  526. }
  527. .visit-item {
  528. display: flex;
  529. align-items: center;
  530. .visit-item-left {
  531. width: 120rpx;
  532. color: #666;
  533. }
  534. }
  535. .stu-tag {
  536. width: 160rpx;
  537. margin-left: 10rpx;
  538. margin-right: 10rpx;
  539. border-radius: 15px;
  540. overflow: hidden;
  541. }
  542. .stu-tag-add {
  543. background-color: #ecf5ff;
  544. color: #3c9cff;
  545. border: 1px solid #fff;
  546. }
  547. .stu-tag-sub {
  548. background-color: #fef0f0;
  549. color: #f56c6c;
  550. border: 1px solid #fff;
  551. border-left: 0;
  552. }
  553. .ui-mrr {
  554. margin-right: 50rpx;
  555. }
  556. .ui-mll {
  557. margin-left: 50rpx;
  558. }
  559. .sortable-chosen {
  560. background-color: #fbfbfb66;
  561. border-radius: 5px;
  562. }
  563. .sortable-ghost {
  564. // margin-left : 0 !important;
  565. // margin-right : 0 !important;
  566. background-color: #fbfbfb00;
  567. }
  568. </style>