subscribeInfo.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="content">
  3. <u-form :model="subscribelForm" ref="subscribelForm" label-width="140">
  4. <u-form-item label="学生姓名" prop="studentName">
  5. <u-input v-model="subscribelForm.studentName" disabled />
  6. </u-form-item>
  7. <!-- <u-form-item label="家长姓名" prop="fatherName" required>
  8. <u-input v-model="subscribelForm.fatherName" placeholder="请输入家长姓名" />
  9. </u-form-item> -->
  10. <u-form-item label="学生性别" prop="sex">
  11. <u-input v-model="subscribelForm.sex" disabled />
  12. </u-form-item>
  13. <u-form-item label="学生年龄" prop="age">
  14. <u-input v-model="subscribelForm.age" disabled />
  15. </u-form-item>
  16. <u-form-item label="学生班级" prop="name">
  17. <u-input v-model="subscribelForm.name" placeholder="请输入学生班级" type="select" @click="handleClassInfoShow" />
  18. </u-form-item>
  19. <!-- <u-form-item label="学生生日" prop="birthday" required>
  20. <u-input v-model="subscribelForm.birthday" placeholder="请选择学生生日" :select-open="birthdayShow" type="select" @click="birthdayShow = true" />
  21. </u-form-item> -->
  22. <!-- <u-form-item label="手机号码" prop="phone" required>
  23. <u-input v-model="subscribelForm.phone" type="number" placeholder="请输入手机号码" />
  24. </u-form-item> -->
  25. <!-- <u-form-item label="体验日期" placeholder="请选择体验日期" prop="experience">
  26. <u-input v-model="subscribelForm.experience" :select-open="experienceShow" type="select" @click="experienceShow = true" />
  27. </u-form-item> -->
  28. <u-form-item label="上课教练" placeholder="请选择上课教练" prop="coachName">
  29. <u-input v-model="subscribelForm.coachName" type="select" @click="handleCoachListShow" />
  30. </u-form-item>
  31. </u-form>
  32. <!-- 性别 -->
  33. <!-- <u-action-sheet :list="sexList" v-model="sexShow" @click="setSex"></u-action-sheet> -->
  34. <!-- 班级 -->
  35. <u-action-sheet :list="classList" v-model="classShow" @click="HandleChooseClassClick"></u-action-sheet>
  36. <!-- 教练 -->
  37. <u-action-sheet :list="coachList" v-model="coachShow" @click="HandleChooseCoachClick"></u-action-sheet>
  38. <!-- 学生生日 -->
  39. <u-picker v-model="birthdayShow" mode="time" :params="params" @confirm="setBirthday"></u-picker>
  40. <!-- 体验日期 -->
  41. <u-calendar v-model="experienceShow" mode="date" :active-bg-color="mainColor" btn-type="error" availableText="有课"
  42. :available="availableList" @change="setExperience" max-date="2300-12-31"></u-calendar>
  43. <view class="handle-fix-box">
  44. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm">确认到场体验</u-button>
  45. </view>
  46. <u-top-tips ref="uTips"></u-top-tips>
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. mapGetters
  52. } from 'vuex'
  53. const NET = require('@/utils/request')
  54. const API = require('@/config/api')
  55. export default {
  56. computed: {
  57. ...mapGetters([
  58. 'mainColor',
  59. 'customStyle',
  60. ])
  61. },
  62. data() {
  63. return {
  64. // 场馆id
  65. venueId: null,
  66. subscribelForm: {
  67. studentId: '',
  68. studentName: '',
  69. sex: '',
  70. age: '',
  71. classId: '',
  72. name: '',
  73. coachId: '',
  74. coachName: '',
  75. // 预约id
  76. subscribeId: ''
  77. },
  78. sexShow: false,
  79. sexList: [{
  80. text: '男'
  81. },
  82. {
  83. text: '女'
  84. }
  85. ],
  86. birthdayShow: false,
  87. params: {
  88. year: true,
  89. month: true,
  90. day: true,
  91. hour: false,
  92. minute: false,
  93. second: false
  94. },
  95. experienceShow: false,
  96. availableList: [],
  97. classShow: false,
  98. classList: [],
  99. coachShow: false,
  100. coachList: [],
  101. }
  102. },
  103. onLoad(options) {
  104. const item = JSON.parse(decodeURIComponent(options.item));
  105. this.venueId = options.venueId
  106. this.subscribelForm = { ...item, id: item.classId, sex:item.sex == 1 ? '男' : '女' }
  107. console.log(this.subscribelForm);
  108. },
  109. onReady() {
  110. this.$refs.subscribelForm.setRules(this.rules);
  111. },
  112. methods: {
  113. // 显示班级列表
  114. handleClassInfoShow() {
  115. this.classShow = true
  116. this.getClassFromVenue(this.venueId)
  117. },
  118. // 获取班级列表
  119. getClassFromVenue(id) {
  120. NET.request(API.getClassListByVenueId, {id}, 'POST').then(res => {
  121. if(res.status === 10000) {
  122. this.classList = res.data.map( item => { return { id: item.id, text: item.name } })
  123. this.subscribelForm.coachId = ''
  124. this.subscribelForm.coachName = ''
  125. } else {
  126. this.$refs.uTips.show({
  127. title: res.message,
  128. type: 'error',
  129. })
  130. }
  131. })
  132. },
  133. // 选择班级
  134. HandleChooseClassClick(index) {
  135. this.subscribelForm.classId = this.classList[index].id
  136. this.subscribelForm.name = this.classList[index].text
  137. },
  138. // 显示教练列表
  139. handleCoachListShow() {
  140. this.coachShow = true
  141. // 教练列表
  142. NET.request(API.getCoachList, {venueId: this.venueId, classId: this.subscribelForm.id }, 'POST').then(res=> {
  143. if(res.status == 10000) {
  144. this.coachList = res.data.map( item => { return { id: item.coachId, text: item.nickname }})
  145. } else {
  146. this.$refs.uTips.show({
  147. title: res.message,
  148. type: 'error',
  149. })
  150. }
  151. })
  152. },
  153. // 选择教练
  154. HandleChooseCoachClick(index) {
  155. this.subscribelForm.coachId = this.coachList[index].id
  156. this.subscribelForm.coachName = this.coachList[index].text
  157. },
  158. // 设置性别
  159. setSex(index) {
  160. this.subscribelForm.sex = this.sexList[index].text
  161. },
  162. // 设置生日
  163. setBirthday(object) {
  164. this.subscribelForm.birthday = object.year + '-' + object.month + '-' + object.day
  165. },
  166. // 设置体验日期
  167. setExperience(object) {
  168. let date = object.year + '-' + object.month + '-' + object.day
  169. if (this.availableList.filter(site => site == date).length) {
  170. this.subscribelForm.experience = date
  171. } else {
  172. this.subscribelForm.experience = ''
  173. this.$refs.uTips.show({
  174. title: '请选择可用日期',
  175. type: 'error',
  176. })
  177. }
  178. },
  179. // 提交表单
  180. submitForm() {
  181. if(!this.subscribelForm.coachId) {
  182. this.$refs.uTips.show({
  183. title: '请选择教练',
  184. type: 'warning',
  185. })
  186. return
  187. }
  188. this.$refs.subscribelForm.validate(valid => {
  189. if (valid) {
  190. const data = {
  191. id: parseInt(this.subscribelForm.subscribeId),
  192. classId: parseInt(this.subscribelForm.classId),
  193. studentId: parseInt(this.subscribelForm.studentId),
  194. coachId: parseInt(this.subscribelForm.coachId)
  195. }
  196. NET.request(API.updateAppointment, data, 'POST').then(res => {
  197. if(res.status == 10000) {
  198. this.$refs.uTips.show({
  199. title: '保存成功',
  200. type: 'success',
  201. })
  202. setTimeout(() => {
  203. uni.navigateBack()
  204. }, 1000)
  205. } else {
  206. this.$refs.uTips.show({
  207. title: res.message,
  208. type: 'warning',
  209. })
  210. }
  211. }).catch(error => {
  212. this.$refs.uTips.show({
  213. title: error.message,
  214. type: 'warning',
  215. })
  216. })
  217. }
  218. });
  219. },
  220. },
  221. }
  222. </script>
  223. <style>
  224. page {
  225. width: 100%;
  226. height: 100%;
  227. position: relative;
  228. }
  229. </style>
  230. <style lang="scss" scoped>
  231. @import "@/static/css/themes.scss";
  232. .content {
  233. width: 100%;
  234. float: left;
  235. padding: 0 15px 60px 15px;
  236. box-sizing: border-box;
  237. }
  238. </style>