studentRanked.vue 21 KB

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