index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <!-- 学生评价 -->
  3. <div>
  4. <!-- 搜索框开始 -->
  5. <div class="search">
  6. <van-search v-model.trim="userName" placeholder="学生姓名" />
  7. </div>
  8. <div style="height: 54px;width: 100%;"></div>
  9. <!-- 模糊搜索页面 -->
  10. <div class="searchPage" v-if="searchList.length">
  11. <!-- <selects :listContent="classLists" :tit="'请选择班级'"></selects> -->
  12. <div class="students">
  13. <div class="stuBlock" v-for="(i, index) in searchList" :key="index + 'p'" @click="gotoStudentDetail2(i)">
  14. {{ i.username }}
  15. </div>
  16. </div>
  17. </div>
  18. <div>
  19. <van-tabs @change="ggg" v-if="!searchList.length" swipeable @click="spread">
  20. <van-tab v-for="(e, index) in classLists" :key="index + 't'" :name="e.id" :title="e.name">
  21. <!-- <classList :claName="i"></classList> -->
  22. <div class="students">
  23. <div class="stuBlock" v-for="(i, index) in stuList" :key="index + 'p'" @click="gotoStudentDetail(i.id, e)">
  24. {{ i.name }}
  25. </div>
  26. </div>
  27. </van-tab>
  28. </van-tabs>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import { selectClassStudent } from '@/api/eva'
  34. import { selectSerStudent } from '@/api/eva'
  35. import { select_techerAllClass } from '@/api/eva'
  36. // import classList from './components/classList.vue'
  37. // 多选框组件
  38. // import selects from './components/selects.vue'
  39. export default {
  40. // components: { selects },
  41. data() {
  42. return {
  43. // 搜索栏数据
  44. userName: '',
  45. // 班级名称数组
  46. classLists: [],
  47. // 班级学生数组
  48. stuList: [],
  49. // 搜索结果数组
  50. searchList: []
  51. }
  52. },
  53. watch: {
  54. userName(val) {
  55. // console.log(val)
  56. if (val !== '') {
  57. this.likeSearch(val)
  58. } else {
  59. this.searchList = []
  60. }
  61. }
  62. },
  63. methods: {
  64. likeSearch(e) {
  65. console.log(e)
  66. const data = {
  67. id: this.$store.state.user.userinfo.organizeid,
  68. txt: e
  69. }
  70. selectSerStudent(data).then(res => {
  71. console.log('res', res)
  72. this.searchList = res[0]
  73. if (!res[0].length) {
  74. this.searchList = [{ username: '暂时没有您想要查询的学生' }]
  75. }
  76. })
  77. },
  78. // 切换导航栏获取数据
  79. ggg(e) {
  80. // console.log('ggg', e, i)
  81. // this.claName.id = e
  82. selectClassStudent({ cid: e }).then(res => {
  83. console.log('res', res)
  84. this.stuList = res[0]
  85. })
  86. },
  87. // 班级入口跳转详情页
  88. gotoStudentDetail(e, i) {
  89. // e学生id,i班级id
  90. // return console.log(e, i)
  91. localStorage.setItem('userId', e)
  92. this.$router.push(`/studentDetail?cid=${i.id}`)
  93. // this.$router.push('/studentDetail')
  94. },
  95. // 搜索按钮跳转详情页
  96. gotoStudentDetail2(i) {
  97. localStorage.setItem('userId', i.userid)
  98. this.$router.push('/searchstuDetail')
  99. },
  100. spread(name, tit) {
  101. // console.log(5555);
  102. // return console.log('spread', name)
  103. // selectClassStudent({ cid: name }).then(res => {
  104. // console.log('res', res)
  105. // this.stuList = res[0]
  106. // })
  107. },
  108. // 获取老师所管理班级
  109. getData() {
  110. const id = this.$store.state.user.userinfo.organizeid
  111. select_techerAllClass({ cid: id }).then(res => {
  112. console.log('获取老师所管理班级学生', res)
  113. this.classLists = res[0]
  114. // 调用一次,将导航栏数据展示出来
  115. this.ggg(this.classLists[0].id)
  116. })
  117. }
  118. },
  119. mounted() {},
  120. created() {
  121. this.getData()
  122. console.log('state', this.$store.state)
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. /deep/ .van-tab {
  128. width: 100px;
  129. text-align: center;
  130. }
  131. /deep/ .van-tabs__line {
  132. width: 90px;
  133. height: 2px;
  134. flex-shrink: 0;
  135. background: #4a8efc;
  136. }
  137. /deep/ .van-tab__pane {
  138. height: calc(100vh - 150px);
  139. }
  140. .searchPage {
  141. width: 100%;
  142. box-sizing: border-box;
  143. margin-top: 20px;
  144. min-height: 300px;
  145. }
  146. .search {
  147. position: fixed;
  148. top: 0;
  149. width: 100%;
  150. // height: 54px;
  151. }
  152. .students {
  153. width: 95%;
  154. display: flex;
  155. // justify-content: space-between;
  156. flex-wrap: wrap;
  157. margin: 10px;
  158. .stuBlock {
  159. min-width: 100px;
  160. margin-top: 10px;
  161. margin-right: 15px;
  162. display: flex;
  163. box-sizing: border-box;
  164. padding: 4px 5px;
  165. justify-content: center;
  166. align-items: center;
  167. border-radius: 4px;
  168. background: #f6fafb;
  169. color: rgba(0, 0, 0, 0.9);
  170. font-family: Microsoft YaHei;
  171. font-size: 14px;
  172. font-style: normal;
  173. }
  174. }
  175. // 搜索框开始
  176. .searchBlock {
  177. width: 100%;
  178. height: 45px;
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. background-color: rgba(232, 232, 235, 1);
  183. // 搜索框结束
  184. }
  185. .claTit {
  186. margin-top: 20px;
  187. margin-left: 10px;
  188. width: 130px;
  189. height: 30px;
  190. line-height: 20px;
  191. color: rgba(16, 16, 16, 1);
  192. font-size: 14px;
  193. text-align: left;
  194. font-family: PingFangSC-regular;
  195. }
  196. </style>