height.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="mind">
  3. <picker range-key="dictLabel" :disabled="daflag||studentlist.length<1" :range="studentlist" :value="nameidx" @change="bindDateChangea">
  4. <view class="flexc mibox mb20">
  5. <view class="tit" style="margin-bottom: 0;">人员</view>
  6. <view class="f15 flex1 txr co16" v-if="name" >{{name}}</view>
  7. <view class="f15 flex1 txr coa" v-else >请选择人员</view>
  8. <image :src="rimg" class="rimg"></image>
  9. </view>
  10. </picker>
  11. <view class='mibox flexc'>
  12. <view class="tit">身高</view>
  13. <input placeholder="请输入身高" v-model="height" type="number"/>
  14. <view class="f16 co16 ml6">cm</view>
  15. </view>
  16. <view class='mibox flexc'>
  17. <view class="tit">体重</view>
  18. <input placeholder="请输入身高" v-model="weight" type="number"/>
  19. <view class="f16 co16 ml6">kg</view>
  20. </view>
  21. <view class="rebtn mt30" @click="getSubmit">确认</view>
  22. </view>
  23. </template>
  24. <script>
  25. // import tabSearch from "@/components/toptab/search.vue"
  26. import {getDictionaryFn} from '@/api/mine/register.js'
  27. import {getliveAddFn} from "@/api/mine/files.js"
  28. export default {
  29. data(){
  30. return{
  31. rimg:require("@/mine/static/score/rimg.png"),
  32. autoHeight:true,
  33. height:'',
  34. weight:'',
  35. datainfo:{
  36. },
  37. roles:'',
  38. studentlist:[],
  39. name:'',
  40. nameidx:0,
  41. studentId:'',
  42. daflag:false,//档案修改
  43. }
  44. },
  45. onLoad: function(e) {
  46. if(e.type&&e.type=='daup'){
  47. this.name=e.name;
  48. this.studentId=e.id;
  49. this.daflag=true;
  50. }else{
  51. //家长
  52. var roles=this.$store.state.user.choseroles;
  53. var newArr=this.$store.state.user.student;
  54. if(newArr&&newArr.length){
  55. if(newArr&&newArr.length>1){
  56. this.studentlist = newArr.map(v => {
  57. return {
  58. dictLabel:v.studentName,
  59. dictValue: v.id,
  60. }
  61. })
  62. }else{
  63. // 一个娃
  64. this.name=newArr[0].studentName
  65. this.studentId=newArr[0].id
  66. }
  67. }
  68. }
  69. },
  70. methods:{
  71. bindDateChangea(e){
  72. var idx=e.detail.value
  73. this.name=this.studentlist[idx].dictLabel
  74. this.studentId=this.studentlist[idx].dictValue
  75. },
  76. getSubmit(){
  77. // 学生 id
  78. var that=this;
  79. var roles=this.$store.state.user.choseroles;
  80. if(!this.studentId){
  81. this.$toast('请选择人员')
  82. return
  83. }
  84. if(!this.height&&!this.weight){
  85. this.$toast('请至少输入身高或体重')
  86. return
  87. }
  88. // 走修改
  89. var params={
  90. studentId:this.studentId,
  91. }
  92. if(this.height){
  93. params.height=this.height
  94. }
  95. if(this.weight){
  96. params.weight=this.weight
  97. }
  98. if(roles=='teacher'){
  99. params.createType='2'
  100. }else if(roles=='parents'){
  101. params.createType='1'
  102. }
  103. getliveAddFn(params).then(res => {
  104. if (res.code == 200) {
  105. that.$toast('新增成功')
  106. setTimeout(function() {
  107. if(that.daflag){
  108. uni.$emit('refreshdalist');
  109. uni.redirectTo({
  110. url:'/mine/pages/files/heightlist?type=da&id='+that.studentId+'&name='+that.name
  111. })
  112. }else{
  113. uni.$emit('refreshlivelist');
  114. uni.navigateBack({
  115. delta:1
  116. })
  117. }
  118. }, 1500)
  119. } else {
  120. this.$toast(res.msg)
  121. }
  122. })
  123. },
  124. },
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .mind{
  129. min-height: 100vh;background: #ffffff;padding: 80rpx 60rpx;
  130. .mibox{
  131. .tit{font-size: 32rpx;font-weight: 500;color: #161616;margin-bottom: 40rpx;}
  132. textarea{border: 2rpx solid #FFB132;border-radius: 20rpx;width: 100%;min-height: 230rpx;padding:32rpx;box-sizing: border-box;}
  133. .rimg{width: 14rpx;height: 24rpx;flex: 0 0 auto;margin-left: 12rpx;}
  134. input{flex: 1;text-align: right;}
  135. }
  136. }
  137. </style>