江西小程序管理端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

245 lines
5.9 KiB

1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
11 months ago
1 year ago
12 months ago
1 year ago
11 months ago
1 year ago
11 months ago
12 months ago
1 year ago
12 months ago
11 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
11 months ago
12 months ago
1 year ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="编辑排课模版"></topNavbar>
  4. <view class="pad">
  5. <view class="card">
  6. <view class="tit flex">
  7. <view class="lab">模板标题</view>
  8. <view class="inputBox my">
  9. <u--input placeholder="请输入内容" border="none" v-model="FormData.templateName" ></u--input>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="card timeCon" v-for="(item,index) in FormData.scheduleClassTemplateDetailList">
  14. <view class="deleteIcon" @click="deleteFn(item.id)" v-if="FormData.scheduleClassTemplateDetailList.length>1">
  15. <u-icon name="close-circle-fill" color="#ADADAD" size="22"></u-icon>
  16. </view>
  17. <view class="row">
  18. <view class="lab">选择时间段</view>
  19. <view class="flex">
  20. <view class="timeTag" @click="showTime(index,'startTime')">
  21. <mySelect :value="item.startTime" placeholder="开始时间"></mySelect>
  22. </view>
  23. <view class="line"></view>
  24. <view class="timeTag" @click.capture="showTime(index,'endTime')">
  25. <mySelect :value="item.endTime" placeholder="结束时间"></mySelect>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="row">
  30. <view class="lab">选择人数</view>
  31. <view class="numBox">
  32. <u-number-box v-model="item.personCount" :max="10"></u-number-box>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="add" @click="$u.throttle(addFn, 500)">
  37. <view class="addIcon">
  38. <image src="@/static/images/coach/tianjia.png" mode=""></image>
  39. </view>
  40. <view class="text">添加</view>
  41. </view>
  42. <view class="btnBg" @click="$u.debounce(scheduleTemplateUpdateFn, 500)">保存为模板</view>
  43. </view>
  44. <u-datetime-picker
  45. :show="show"
  46. mode="time"
  47. :minHour="datePicker.minHour"
  48. :maxHour="datePicker.maxHour"
  49. :minMinute="datePicker.minMinute"
  50. :maxMinute="datePicker.maxMinute"
  51. @confirm="confirmTime"
  52. @close="show=false"
  53. @cancel="show=false"
  54. :closeOnClickOverlay="true"
  55. ></u-datetime-picker>
  56. </view>
  57. </template>
  58. <script>
  59. import { getClassCreate, getClassTimeLimt, scheduleTemplateGet, scheduleTemplateUpdate } from '@/config/api.js'
  60. export default {
  61. data() {
  62. return {
  63. datePicker: {
  64. minHour: 0,
  65. maxHour: 0,
  66. maxMinute: 0,
  67. minMinute: 0
  68. },
  69. FormData: {},
  70. show: false,
  71. value1: '',
  72. tempDateObj: {},//选择日期的临时保存对象
  73. }
  74. },
  75. onLoad(options) {
  76. this.id = options.id
  77. // this.initFormData()
  78. this.scheduleTemplateGetFn()
  79. this.getClassTimeLimtFn()
  80. },
  81. methods: {
  82. closeFn(val) {
  83. console.log('val')
  84. },
  85. // 获取模版详情
  86. async scheduleTemplateGetFn() {
  87. const {data: res} = await scheduleTemplateGet({id: this.id})
  88. this.FormData = res
  89. this.$set(this.FormData, 'scheduleClassTemplateDetailList', res.detailVO)
  90. delete this.FormData.detailVO
  91. console.log(this.FormData)
  92. },
  93. // 获取最小时间段
  94. async getClassTimeLimtFn() {
  95. const {data: res} = await getClassTimeLimt({ coachId: this.vuex_coachId, })
  96. this.datePicker.minHour = res.currentClassStartTime.split(':')[0]*1
  97. this.datePicker.maxHour = res.currentClassEndTime.split(':')[0]*1
  98. console.log(this.datePicker)
  99. },
  100. // 创建模版
  101. async scheduleTemplateUpdateFn() {
  102. this.FormData.scheduleClassTemplateDetailList.forEach((item)=>{
  103. })
  104. for(let i=0; i<this.FormData.scheduleClassTemplateDetailList.length; i++) {
  105. let item = this.FormData.scheduleClassTemplateDetailList[i]
  106. if(!item.endTime||!item.startTime||!item.personCount)
  107. return this.$u.toast('请输入完整的信息')
  108. }
  109. const {data: res} = await scheduleTemplateUpdate(this.FormData)
  110. if(res) this.$u.toast('更新成功')
  111. uni.$emit('refreshMould')
  112. uni.navigateBack()
  113. // this.initFormData()
  114. },
  115. addFn() {
  116. let obj = {startTime: '',endTime: '', people: 1, id: new Date() * 1}
  117. this.FormData.scheduleClassTemplateDetailList.push(obj)
  118. },
  119. deleteFn(id) {
  120. let arr = this.FormData.scheduleClassTemplateDetailList
  121. if(arr.length==1) return
  122. let index = arr.findIndex(item=>item.id==id)
  123. if(index==-1) return
  124. arr.splice(index, 1)
  125. },
  126. confirmTime(val) {
  127. this.FormData.scheduleClassTemplateDetailList[this.tempDateObj.index][this.tempDateObj.name] = val.value
  128. console.log(val.value)
  129. this.show = false
  130. },
  131. showTime(index, name) {
  132. this.tempDateObj = {
  133. index, name
  134. }
  135. this.show = true
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .pageBgImg {
  142. .pad {
  143. .card {
  144. padding: 0 28rpx;
  145. margin-bottom: 20rpx;
  146. &.timeCon {
  147. padding: 28rpx;
  148. }
  149. .tit {
  150. height: 96rpx;
  151. background: #FFFFFF;
  152. border-radius: 16px;
  153. .lab {
  154. width: 172rpx;
  155. font-weight: 500;
  156. color: #333333;
  157. }
  158. .inputBox.my {
  159. flex: 1;
  160. }
  161. }
  162. }
  163. .card {
  164. position: relative;
  165. .deleteIcon {
  166. position: absolute;
  167. right: 20rpx;
  168. top: 20rpx
  169. }
  170. .row {
  171. padding: 12rpx 0;
  172. display: flex;
  173. align-items: center;
  174. .lab {
  175. font-size: 30rpx;
  176. width: 172rpx;
  177. flex-shrink: 0;
  178. }
  179. .flex {
  180. .timeTag {
  181. // padding: 8rpx 14rpx;
  182. background: #F8F8F8;
  183. border-radius: 34rpx;
  184. width: 150rpx;
  185. text-align: center;
  186. height: 52rpx;
  187. line-height: 52rpx;
  188. // width:fit-content;
  189. input {
  190. display: block;
  191. width: 100%;
  192. height: 100%;
  193. font-size: 26rpx;
  194. color: #333333;
  195. }
  196. }
  197. .line {
  198. width: 26rpx;
  199. height: 2rpx;
  200. background: #DADADA;
  201. margin: 0 14rpx;
  202. }
  203. }
  204. }
  205. }
  206. .add {
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. padding-top: 20rpx;
  211. .addIcon {
  212. width: 36rpx;
  213. height: 36rpx;
  214. }
  215. .text {
  216. font-size: 28rpx;
  217. color: $themC;
  218. margin-left: 10rpx;
  219. }
  220. }
  221. .btnBg {
  222. width: 396rpx;
  223. margin: 96rpx auto 20rpx auto;
  224. }
  225. }
  226. }
  227. </style>