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