heightlist.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="mind">
  3. <!-- tab栏 切孩子 -->
  4. <view class="top">
  5. <view class="top_t" @click="getTab(ite.val)" :class="[tabval==ite.val?'act':'',daflag?'top_tda':'']" v-for="(ite,idx) in studentlist" :key="idx">{{ite.tit}}<image :src="tapline" class="line"></image></view>
  6. </view>
  7. <view class="pt12">
  8. <xl-list :datype='datype' :datalist="list" :wtdt="wtdt" @getDel="getDel"></xl-list>
  9. </view>
  10. <view style="height: 100rpx;" v-if="checkPermi(['live:old:add'])&&!daflag"></view>
  11. <view class="mbtn" v-if="checkPermi(['live:old:add'])&&!daflag" @click="getAdd">更新身高体重状态</view>
  12. </view>
  13. </template>
  14. <script>
  15. import xlList from "@/mine/components/list/list.vue"
  16. import {getliveListFn,getliveDelFn} from "@/api/mine/files.js"
  17. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  18. export default {
  19. components:{
  20. xlList
  21. },
  22. data(){
  23. return{
  24. sucimg:require("@/mine/static/score/ncheck.png"),
  25. tapline:require("@/static/images/hline.png"),
  26. list:[],
  27. datype:6,
  28. pageSize: 10,
  29. pageNum: 1,
  30. reachflag: true,
  31. wtdt: '',
  32. tabval:'',
  33. actidx:-1,
  34. daflag:false,
  35. studentlist:[]
  36. }
  37. },
  38. onUnload() {
  39. uni.$off('refreshlivelist')
  40. },
  41. onReachBottom() {
  42. if (this.reachflag) {
  43. this.pageNum++
  44. this.getDataFn()
  45. }
  46. },
  47. onLoad: function(e) {
  48. uni.$on('refreshlivelist', (e) => {
  49. this.reachflag = true;
  50. this.pageNum = 1;
  51. this.list = [];
  52. this.getDataFn();
  53. })
  54. if(e.type&&e.type=='da'){
  55. this.daflag=true;
  56. this.tabval=e.id
  57. this.studentlist=[{
  58. tit:e.name,
  59. val: e.id,
  60. }]
  61. }else{
  62. var roles=this.$store.state.user.choseroles;
  63. var newArr=this.$store.state.user.student;
  64. // console.log(newArr,1)
  65. this.tabval=newArr[0].id
  66. this.studentlist = newArr.map(v => {
  67. return {
  68. tit:v.studentName,
  69. val: v.id,
  70. }
  71. })
  72. }
  73. this.getDataFn()
  74. },
  75. methods:{
  76. checkPermi,checkRole,
  77. getLook(e) {
  78. if (this.actidx == e) {
  79. this.actidx = -1
  80. } else {
  81. this.actidx = e;
  82. }
  83. },
  84. toTree2(arr){
  85. var list=this.list;
  86. let newA = JSON.parse(JSON.stringify(arr));
  87. if(list&&list.length){
  88. list.forEach(ite=>{
  89. for(var i =0;i<newA.length;i++){
  90. if(ite.ayear === newA[i].ayear&&ite.amonth === newA[i].amonth){
  91. ite.children.push(newA[i])
  92. }else{
  93. var obj={
  94. ayear:newA[i].ayear,
  95. amonth:newA[i].amonth,
  96. check:true,
  97. children:[]
  98. }
  99. obj.children.push(newA[i])
  100. list.push(obj)
  101. }
  102. }
  103. })
  104. return list
  105. }else{
  106. var newArrs = [];
  107. var larr=[]
  108. const map = new Map();
  109. newArrs = newA.filter(v => !map.has(v.ayear)&&!map.has(v.amonth) && map.set(v.ayear, 1)&& map.set(v.amonth, 1));
  110. newArrs.forEach(ite=>{
  111. var obj={
  112. ayear:ite.ayear,
  113. amonth:ite.amonth,
  114. check:true
  115. }
  116. larr.push(obj)
  117. })
  118. larr.forEach(ite=>{
  119. ite.children = newA.filter(e => {
  120. return ite.ayear === e.ayear&&ite.amonth === e.amonth
  121. })
  122. })
  123. return larr
  124. }
  125. },
  126. getAdd(){
  127. this.$tab.navigateTo(`/mine/pages/files/height`)
  128. },
  129. getTab(idx){
  130. this.tabval=idx;
  131. this.list=[];
  132. this.reachflag=true;
  133. this.pageNum=1;
  134. this.getDataFn();
  135. },
  136. getDel(id){
  137. var that=this;
  138. getliveDelFn(id).then(res=>{
  139. if (res.code == 200) {
  140. that.$toast('删除成功')
  141. setTimeout(function(){
  142. that.reachflag = true;
  143. that.pageNum = 1;
  144. that.list = [];
  145. that.getDataFn();
  146. },1500)
  147. } else {
  148. that.$toast(res.msg)
  149. }
  150. })
  151. },
  152. getDataFn(a) {
  153. var params = {
  154. pageSize: this.pageSize,
  155. pageNum: this.pageNum,
  156. studentId:this.tabval
  157. }
  158. getliveListFn(params).then(res => {
  159. if (res.code == 200) {
  160. this.total = res.total;
  161. if (res.rows.length < this.pageSize) {
  162. this.reachflag = false
  163. this.wtdt = '到底了~';
  164. } else {
  165. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -1)
  166. if (num < res.total) {
  167. this.reachflag = true
  168. this.wtdt = '上拉加载更多'
  169. } else {
  170. this.reachflag = false
  171. this.wtdt = '到底了~';
  172. }
  173. }
  174. // 数据处理
  175. var newArr=res.rows;
  176. if(newArr&&newArr.length){
  177. var timeArr=[];
  178. Object.keys(newArr).some((key) => {
  179. var time=newArr[key].createTime.split(' ');
  180. var a=time[0].split('-')
  181. newArr[key].ayear=a[0];
  182. newArr[key].amonth=a[1];
  183. })
  184. this.list=this.toTree2(newArr)
  185. }else{
  186. this.list=[]
  187. }
  188. } else {
  189. this.$toast(res.msg)
  190. }
  191. })
  192. },
  193. },
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .mind{padding: 100rpx 36rpx 0rpx;min-height: 100vh;background-color: #ffffff;box-sizing: border-box;
  198. .mbtn{position: fixed;left: 0;right: 0;bottom: 0;height: 100rpx;display: flex;align-items: center;justify-content: center;z-index: 2;background: #1f57e6;font-size: 34rpx;font-weight: 500;
  199. color: #FFFFFF;}
  200. .top{height: 96rpx;border-bottom: 2rpx solid #E5E5E5;position: fixed;top: 0;left: 0;right: 0;overflow-x: scroll;display: flex;align-items: center;z-index: 1;background-color: #ffffff;
  201. .top_t{position: relative;font-size: 30rpx;font-weight: 500;color: #AAAAAA;height: 94rpx;line-height: 94rpx;padding:0 20rpx;flex:1 0 auto;text-align: center;
  202. &.act{color: #161616;font-weight: bold;
  203. .line{display: block;}
  204. // &::after{content: '';width: 42rpx;height: 10rpx;background: #1f57e6;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -21rpx;bottom: 12rpx;}
  205. }
  206. &.top_tda{flex: 0 0 auto !important;padding: 0 40rpx;}
  207. .line{width: 40rpx;height: 12rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: 16rpx;display: none;}
  208. }
  209. }
  210. }
  211. </style>