studentRanked.vue 21 KB

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