studentRankedChange.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view class="">
  3. <view style="margin-bottom: 32rpx;" class="">
  4. <topBtn :list="btnList" :active.sync='reActive' />
  5. </view>
  6. <view v-if="reActive == 1" @click="openPop"
  7. style="box-sizing: border-box;padding: 0 32rpx;margin-bottom: 32rpx;" class="btn-roll">
  8. 排位调整
  9. </view>
  10. <view class="" v-if="reActive == 0" @click="show_classes=true" style="width: auto;">
  11. <view class="ui-p">
  12. <view class="visit-item">
  13. <view class="visit-item-left">
  14. 选择班级
  15. </view>
  16. <view class="btn-roll ui-plr" style="width: auto;" v-if="chooseClassName">
  17. {{ chooseClassName }}
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="" v-if="reActive==0">
  23. <view class="ranked" v-if="chooseClassName">
  24. <view v-for="(item,index) in list" :key="index" class="ranked-item">
  25. <view @click="reActive == 1 ?itemClick(item1):Comment(item1)" v-for="(item1,index1) in item.nodes"
  26. :key="item1.id" class="ranked-item-tr">
  27. <!-- <image style="width: 90rpx;height: 90rpx;" src="@/static/image/female.png" mode=""></image> -->
  28. <view :class="active.indexOf(item1.id) == -1 ? '' :'active'" style="width: 90%;text-align: center;background-color: #fff;
  29. border-radius: 5px;">
  30. {{item1.title}}
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="platform" v-if="chooseClassName">
  36. <view class="ranked-radio">
  37. </view>
  38. <view class="platform-text">
  39. 讲台
  40. </view>
  41. <view class="platform-color">
  42. </view>
  43. </view>
  44. </view>
  45. <view class="" v-else>
  46. <view class="ranked" >
  47. <view v-for="(item,index) in selfClassList" :key="index" class="ranked-item">
  48. <view @click="reActive == 1 ?itemClick(item1):Comment(item1)" v-for="(item1,index1) in item.nodes"
  49. :key="item1.id" class="ranked-item-tr">
  50. <!-- <image style="width: 90rpx;height: 90rpx;" src="@/static/image/female.png" mode=""></image> -->
  51. <view :class="active.indexOf(item1.id) == -1 ? '' :'active'" style="width: 90%;text-align: center;background-color: #fff;
  52. border-radius: 5px;">
  53. {{item1.title}}
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="platform" >
  59. <view class="ranked-radio">
  60. </view>
  61. <view class="platform-text">
  62. 讲台
  63. </view>
  64. <view class="platform-color">
  65. </view>
  66. </view>
  67. </view>
  68. <uni-popup ref="popup" background-color="transparent">
  69. <view style="padding: 0;" class="popup-content"
  70. :class="{ 'popup-height': type === 'left' || type === 'right' }">
  71. <StuDraggable @change='change' :list.sync='selfClassList' />
  72. </view>
  73. </uni-popup>
  74. <uni-popup @change="popChange" ref="CommentPopup" background-color="transparent">
  75. <view style="padding: 32rpx;width: 700rpx;" class="popup-content"
  76. :class="{ 'popup-height': type === 'left' || type === 'right' }">
  77. <view class="pop-title">
  78. <image style="width: 40rpx;height: 40rpx;margin-right: 10rpx;" src="@/static/image/icon.png"
  79. mode=""></image> {{info.title}}
  80. </view>
  81. <view style="margin-top: 32rpx;" class="">
  82. <Tag @click='CommentOn' :list='tagList' />
  83. </view>
  84. </view>
  85. </uni-popup>
  86. <u-picker :show="show_classes" @confirm="doChooseClass" :columns="teachList" keyName="class_name" @cancel="show_classes=false"></u-picker>
  87. <view class="">
  88. <view @click="loginOut()" class="form-btn-content">
  89. 退出登录
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. import topBtn from '@/components/topBtn.vue'
  96. import StuDraggable from './stuDraggable.vue'
  97. import Tag from './tag.vue'
  98. import { getStuSchoolIdByStuClassId } from "@/common/api/stu.js"
  99. export default {
  100. components: {
  101. topBtn,
  102. StuDraggable,
  103. Tag
  104. },
  105. data() {
  106. return {
  107. show_classes : false,
  108. id: 1,
  109. info: {},
  110. type: 'center',
  111. btnList: ['学生评分', '坐位调整'],
  112. reActive: 0,
  113. active: [],
  114. activeList: [],
  115. tagList: [],
  116. list: [],
  117. teachList :[],
  118. chooseClassName : '',
  119. chooseClassId : '',
  120. selfClassList : [],
  121. notSelfClass : true,
  122. }
  123. },
  124. mounted() {
  125. // this.id = this.$route.query.id
  126. this.id=this.$store.state.teacherInfo.selfclass.id
  127. // this.getStudent()
  128. this.getClassroomList()
  129. },
  130. methods: {
  131. loginOut(){
  132. uni.setStorageSync("token",'')
  133. uni.navigateTo({
  134. url: "/pages/login/login"
  135. })
  136. },
  137. doChooseClass(val){
  138. console.log(val,"val");
  139. this.chooseClassId=val.value[0].id
  140. this.chooseClassName=val.value[0].class_name
  141. this.getStudent()
  142. this.show_classes=false
  143. },
  144. getClassroomList(){
  145. let teacher_id=this.$store.state.teacherInfo.id
  146. this.$api.sendRequest({
  147. url: `/mobile/teacher/teachClasses`,
  148. method: "post",
  149. data: {
  150. teacher_id : teacher_id
  151. },
  152. success: res => {
  153. this.teachList.push(res.data)
  154. console.log(this.teachList);
  155. }
  156. })
  157. },
  158. itemClick(item) {
  159. let val = this.active.indexOf(item.id)
  160. if (val == -1) {
  161. this.active.push(item.id)
  162. this.activeList.push(item)
  163. } else {
  164. this.active.splice(val, 1)
  165. this.activeList.splice(val, 1)
  166. }
  167. if (this.active.length == 2) {
  168. this.selfClassList.forEach((item2, index2) => {
  169. item2.nodes.forEach((item1, index1) => {
  170. let indexVal = this.active.indexOf(item1.id)
  171. if (indexVal != -1) {
  172. this.activeList.forEach(item3 => {
  173. if (item3.id != item1.id) {
  174. item2.nodes.splice(index1, 1, item3)
  175. }
  176. })
  177. }
  178. })
  179. })
  180. this.activeList = []
  181. this.active = []
  182. let info = {
  183. classroom_id: this.id,
  184. seat_list: this.selfClassList
  185. }
  186. this.$api.sendRequest({
  187. url: `/mobile/saveSeat`,
  188. method: "PUT",
  189. data: info,
  190. success: res => {
  191. uni.showToast({
  192. title: res.msg,
  193. })
  194. }
  195. })
  196. }
  197. },
  198. openPop() {
  199. if(!this.notSelfClass){
  200. this.type = 'center'
  201. this.$refs.popup.open('center')
  202. }
  203. },
  204. Comment(item) {
  205. console.log(item,"sgism");
  206. //item的id是studentClass的id,需要转换成stu_school_id传到
  207. this.$api.sendRequest({
  208. url: getStuSchoolIdByStuClassId,
  209. data : {
  210. stu_class_id : item.id
  211. },
  212. success: res => {
  213. console.log(res,"resrrrrr");
  214. let stu_school_id=res.data.stu_school_id
  215. uni.navigateTo({
  216. url: "/pages/studentTab/studentTab?stu_school_id="+stu_school_id
  217. })
  218. }
  219. })
  220. },
  221. popChange(val) {
  222. if (!val.show) {
  223. this.tagList.forEach(item => {
  224. item.show = false
  225. })
  226. }
  227. },
  228. getStudent() {
  229. this.$api.sendRequest({
  230. url: `/mobile/getSeat?classroom_id=${this.chooseClassId}`,
  231. success: res => {
  232. this.list = res.data
  233. }
  234. })
  235. },
  236. change(list) {
  237. console.log("组件传的数据",list);
  238. this.selfClassList = list
  239. let info = {
  240. classroom_id: this.id,
  241. seat_list: this.selfClassList
  242. }
  243. this.$api.sendRequest({
  244. url: `/mobile/saveSeat`,
  245. method: "PUT",
  246. data: info,
  247. success: res => {
  248. uni.showToast({
  249. title: res.msg,
  250. })
  251. }
  252. })
  253. },
  254. getTagList() {
  255. this.$api.sendRequest({
  256. url: `/mobile/student/tabs?id=${this.info.id}`,
  257. success: res => {
  258. res.data.forEach(item => {
  259. item.show = false
  260. })
  261. this.tagList = res.data
  262. }
  263. })
  264. },
  265. CommentOn(item, score) {
  266. let info = {
  267. id: this.info.id,
  268. tab_id: item.tab_id,
  269. score: score
  270. }
  271. this.$api.sendRequest({
  272. url: `/mobile/student/eval`,
  273. data: info,
  274. success: res => {
  275. uni.showToast({
  276. title: `${this.info.title} ${item.tab_name} ${item.type == 1 ? '+':'-'} ${score}分`,
  277. icon: 'none'
  278. })
  279. this.$refs.CommentPopup.close()
  280. }
  281. })
  282. }
  283. },
  284. watch: {
  285. reActive(newVal) {
  286. this.active = []
  287. this.activeList = []
  288. console.log(newVal);
  289. if(newVal==1){
  290. console.log(this.$store.state.teacherInfo.selfclass,"this.$store.state.teacherInfo.selfclass");
  291. if(this.$store.state.teacherInfo.selfclass){
  292. let classroom_id=this.$store.state.teacherInfo.selfclass.id
  293. // let classroom_id=1
  294. this.$api.sendRequest({
  295. url: `/mobile/getSeat?classroom_id=${classroom_id}`,
  296. success: res => {
  297. console.log(res.data);
  298. this.selfClassList = res.data
  299. this.notSelfClass=false
  300. }
  301. })
  302. }else{
  303. this.selfClassList=[]
  304. uni.showToast({
  305. icon: "none",
  306. title: "您不是班主任"
  307. })
  308. }
  309. }
  310. }
  311. },
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. .form-btn-content {
  316. width: 30%;
  317. background: #05cca1;
  318. height: 72rpx;
  319. border-radius: 36rpx;
  320. color: #fff;
  321. font-size: 32rpx;
  322. text-align: center;
  323. line-height: 72rpx;
  324. margin: 0 auto;
  325. position: fixed;
  326. bottom: 40rpx;
  327. left: 35%;
  328. }
  329. .platform {
  330. display: flex;
  331. justify-content: center;
  332. align-items: center;
  333. position: relative;
  334. height: 30rpx;
  335. margin-top: 60rpx;
  336. .platform-color {
  337. position: absolute;
  338. left: 0;
  339. top: 0;
  340. height: 60rpx;
  341. background-color: rgba(5, 204, 161, 1);
  342. width: 10rpx;
  343. }
  344. .platform-text {
  345. text-align: center;
  346. width: 60%;
  347. margin-top: 40rpx;
  348. }
  349. }
  350. .pop-title {
  351. border-bottom: 1px solid #f2f2f2;
  352. font-size: 36rpx;
  353. padding-bottom: 20rpx;
  354. display: flex;
  355. align-items: center;
  356. }
  357. .popup-content {
  358. border-radius: 10px;
  359. box-sizing: border-box;
  360. padding: 0 32rpx;
  361. }
  362. .btn-roll {
  363. background-color: #fff;
  364. border-radius: 25rpx;
  365. width: 190rpx;
  366. color: #666;
  367. height: 60rpx;
  368. line-height: 60rpx;
  369. text-align: center;
  370. margin-left: 32rpx;
  371. }
  372. .ranked {
  373. width: 100%;
  374. text-align: center;
  375. font-size: 10px;
  376. box-sizing: border-box;
  377. display: flex;
  378. .ranked-item {
  379. flex: 1;
  380. box-sizing: border-box;
  381. .ranked-item-tr {
  382. margin-bottom: 16rpx;
  383. border-radius: 5px;
  384. box-sizing: border-box;
  385. width: 100%;
  386. display: flex;
  387. justify-content: center;
  388. }
  389. .ranked-item-tr:last-child {
  390. margin-bottom: 0;
  391. }
  392. .active {
  393. border: 1px solid #ccc !important;
  394. background-color: rgba(5, 204, 161, 1) !important;
  395. color: #fff !important;
  396. box-sizing: border-box;
  397. }
  398. }
  399. .ranked-item:nth-child(2n) {
  400. border-right: 1px solid #ccc;
  401. }
  402. .ranked-item:last-child {
  403. border-right: 0;
  404. }
  405. }
  406. .ranked-radio {
  407. width: 100px;
  408. position: absolute;
  409. left: 50%;
  410. transform: translate(-50%);
  411. top: 0rpx;
  412. border-bottom: 3px solid rgba(5, 204, 161, 1);
  413. border-radius: 50% 50% 0 0;
  414. }
  415. .visit-item {
  416. display: flex;
  417. align-items: center;
  418. .visit-item-left {
  419. width: 120rpx;
  420. color: #666;
  421. }
  422. }
  423. </style>