subscribeInfo.vue 8.8 KB

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