studentRankedChange.vue 12 KB

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