extraLessonsForm.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="content">
  3. <u-form :model="form" ref="form" label-width="140">
  4. <u-form-item label="补课学员" prop="content" required label-position="top">
  5. <u-grid :col="3" :border="false">
  6. <u-grid-item v-for="(item, index) in userList" :key="index">
  7. <u-avatar :src="item.url" mode="circle" size="128" show-level level-icon="checkbox-mark" :level-bg-color="mainColor"></u-avatar>
  8. <view class="grid-text">{{item.name}}</view>
  9. </u-grid-item>
  10. <u-grid-item @click.native="goToSelectStudent()">
  11. <view class="slot-btn">
  12. <u-icon name="plus" size="60" color="#999999"></u-icon>
  13. </view>
  14. </u-grid-item>
  15. </u-grid>
  16. </u-form-item>
  17. <u-form-item label="补课地点" prop="address" required>
  18. <u-input v-model="form.address" placeholder="请输入补课地点" />
  19. </u-form-item>
  20. <u-form-item label="备注" prop="remark" required>
  21. <u-input v-model="form.remark" type="textarea" placeholder="请输入备注" auto-height :height="100" />
  22. </u-form-item>
  23. </u-form>
  24. <view class="handle-fix-box">
  25. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm()">提交</u-button>
  26. </view>
  27. <u-top-tips ref="uTips"></u-top-tips>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. mapGetters
  33. } from 'vuex'
  34. const NET = require('@/utils/request')
  35. const API = require('@/config/api')
  36. export default {
  37. computed: {
  38. ...mapGetters([
  39. 'mainColor',
  40. 'customStyle',
  41. ])
  42. },
  43. data() {
  44. return {
  45. userList: [],
  46. form: {
  47. address: '',
  48. remark: '',
  49. },
  50. rules: {
  51. address: [{
  52. required: true,
  53. message: '请输入补课地点',
  54. trigger: 'change'
  55. }],
  56. remark: [{
  57. required: true,
  58. message: '请输入备注',
  59. trigger: 'change'
  60. }],
  61. },
  62. }
  63. },
  64. onLoad() {},
  65. onReady() {
  66. this.$refs.form.setRules(this.rules);
  67. },
  68. onShow() {
  69. this.userList = uni.getStorageSync('extraLessonsUserList')
  70. },
  71. methods: {
  72. // 提交表单
  73. submitForm() {
  74. this.$refs.form.validate(valid => {
  75. if (valid) {
  76. NET.request(API.submitExtraLessonsForm, {
  77. ...this.form,
  78. studentIdList: this.userList.map(site => {
  79. return {
  80. id: site.id
  81. }
  82. })
  83. }, 'POST').then(res => {
  84. uni.setStorage({
  85. key: 'extraLessonsUserList',
  86. data: []
  87. })
  88. this.$refs.uTips.show({
  89. title: '提交成功',
  90. type: 'success',
  91. })
  92. setTimeout(() => {
  93. uni.navigateBack()
  94. }, 1000)
  95. }).catch(error => {
  96. this.$refs.uTips.show({
  97. title: error.message,
  98. type: 'warning',
  99. })
  100. })
  101. }
  102. });
  103. },
  104. // 跳转选择学生页面
  105. goToSelectStudent() {
  106. uni.navigateTo({
  107. url: '/pagesClass/extraLessonsStudentList'
  108. });
  109. },
  110. },
  111. }
  112. </script>
  113. <style>
  114. page {
  115. width: 100%;
  116. height: 100%;
  117. position: relative;
  118. }
  119. </style>
  120. <style lang="scss" scoped>
  121. @import "@/static/css/themes.scss";
  122. .content {
  123. width: 100%;
  124. float: left;
  125. padding: 0 15px 60px 15px;
  126. box-sizing: border-box;
  127. /deep/.u-avatar__level {
  128. left: 50%;
  129. transform: translateX(-50%);
  130. bottom: -6px !important;
  131. }
  132. .grid-text {
  133. line-height: 18px;
  134. }
  135. .slot-btn {
  136. width: 128rpx;
  137. height: 128rpx;
  138. border-radius: 50%;
  139. border: 1px solid #999999;
  140. display: flex;
  141. justify-content: center;
  142. align-items: center;
  143. }
  144. }
  145. </style>