studentRanked.vue 21 KB

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