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

239 lines
5.7 KiB

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