mind.vue 4.1 KB

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