studentRanked.vue 21 KB

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