studentRanked.vue 20 KB

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