grade.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="container">
  3. <!-- 背景图片区域 -->
  4. <img class="img_bg" src="../../static/images/center-bg.png" />
  5. <!-- input组件区域 -->
  6. <headerInput @changeInputValue="changeInputValue" />
  7. <!-- 学校年级班级区域 -->
  8. <!-- <view class="school">万载三中/{{ gradeName ? gradeName + '/' : '' }}{{ className ? className : '' }}</view> -->
  9. <view class="school">
  10. <uni-data-picker
  11. placeholder="请选择班级"
  12. popup-title="请选择班级"
  13. :clear-icon="false"
  14. :map="{ text: 'name', value: 'classId' }"
  15. :localdata="dataTree_student"
  16. v-model="classes_student"
  17. @nodeclick="clickNode"
  18. ></uni-data-picker>
  19. </view>
  20. <!-- 学生列表区域 -->
  21. <listView :list="list" :appType="appType" />
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref, nextTick } from 'vue'
  26. import { onLoad } from '@dcloudio/uni-app'
  27. import headerInput from '@/components/headerInput.vue'
  28. import listView from '@/components/listView.vue'
  29. import { myRequest } from '@/utils/api.js'
  30. import { decryptDes } from '@/utils/des.js'
  31. // 学生列表数组
  32. const list = ref([])
  33. // 年级信息
  34. const gradeName = ref('')
  35. // 班级信息
  36. const className = ref('')
  37. const appType = ref('')
  38. const dataTree_student = ref([])
  39. const classes_student = ref('')
  40. const gradeId = ref('')
  41. onLoad((options) => {
  42. appType.value = options.type || ''
  43. const manageGrade = uni.getStorageSync('userInfo').manageGrade
  44. const manageSchoolClass = uni.getStorageSync('userInfo').manageSchoolClass
  45. getManageClass(manageSchoolClass, manageGrade)
  46. })
  47. // 获取管理的班级数组
  48. const getManageClass = async (manageSchoolClass, manageGrade) => {
  49. const res = await myRequest({
  50. url: '/wanzai/api/smartUser/getManageClass',
  51. data: {
  52. manageSchoolClass,
  53. manageGrade
  54. }
  55. })
  56. // console.log(res)
  57. const result = JSON.parse(decryptDes(res.data))
  58. // console.log(result)
  59. dataTree_student.value = result
  60. classes_student.value = result[0].classId
  61. gradeId.value = result[0].gradeId
  62. getData()
  63. }
  64. // 输入框组件自定义事件
  65. const changeInputValue = (value) => {
  66. // console.log(value)
  67. // console.log(value.trim())
  68. if (value.trim()) {
  69. let temList = []
  70. list.value.forEach((ele) => {
  71. if (ele.name.indexOf(value.trim()) != -1) {
  72. temList.push(ele)
  73. }
  74. })
  75. list.value = temList
  76. } else {
  77. getData()
  78. }
  79. }
  80. const getData = async () => {
  81. const res = await myRequest({
  82. url: '/wanzai/api/wechat/queryPhoneBook',
  83. data: {
  84. id: uni.getStorageSync('userInfo').id,
  85. gradeId: gradeId.value,
  86. classId: classes_student.value
  87. }
  88. })
  89. // console.log(res)
  90. res.data.forEach((ele) => {
  91. let temlist
  92. ele.classBookList.forEach((item, index, arr) => {
  93. if (item.bookUserList.length) {
  94. // 所在年级学生的数据
  95. list.value = item.bookUserList
  96. // 班级信息
  97. className.value = arr[index].className
  98. temlist = arr
  99. }
  100. })
  101. if (ele.classBookList == temlist) {
  102. gradeName.value = ele.gradeName
  103. }
  104. })
  105. // console.log(list.vlaue)
  106. if (className.value) {
  107. uni.setNavigationBarTitle({
  108. title: gradeName.value + className.value
  109. })
  110. }
  111. }
  112. // 学生部门筛选框选择时的回调
  113. const clickNode = (e) => {
  114. // console.log(e)
  115. classes_student.value = e.classId
  116. gradeId.value = e.gradeId
  117. getData()
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .container {
  122. display: flex;
  123. flex-direction: column;
  124. padding: 0 20rpx;
  125. min-height: 100vh;
  126. background-color: #f1f6fe;
  127. // 背景图片区域样式
  128. .img_bg {
  129. position: absolute;
  130. top: -70rpx;
  131. right: 0;
  132. width: 589rpx;
  133. height: 320rpx;
  134. pointer-events: none;
  135. }
  136. // 学校名称区域样式
  137. .school {
  138. margin-top: 30rpx;
  139. color: #808080;
  140. font-size: 28rpx;
  141. }
  142. }
  143. </style>