江西小程序管理端
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.

242 lines
5.8 KiB

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