studentRanked.vue 20 KB

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