add.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="add">
  3. <u-navbar title="添加排班" :background="background" :border-bottom='false'></u-navbar>
  4. <view class="form">
  5. <view class="item">
  6. <view class="label">
  7. 排班日期
  8. </view>
  9. <view class="right">
  10. {{details.day}}
  11. </view>
  12. </view>
  13. <view class="item" v-if="details.time_id!=0">
  14. <view class="label">
  15. 排班时间
  16. </view>
  17. <view class="right">
  18. {{details.start_time}}--{{details.end_time}}
  19. </view>
  20. </view>
  21. <view class="item" v-if="details.time_id==0">
  22. <view class="label">
  23. 排班时间
  24. </view>
  25. <view class="right">
  26. <picker mode="selector" :range="time_set" :value="index"
  27. :range-key="'range'" @change="bindTimeChange">
  28. <view class="uni-input">{{index ? time_set[index].range : '请选择时间段'}}</view>
  29. </picker>
  30. </view>
  31. </view>
  32. <view class="save" @click="add">
  33. 确认添加
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. background: 'rgba(255,255,255,0)',
  43. details: '',
  44. time_set: '', //时间段
  45. index: '',
  46. }
  47. },
  48. onLoad(options) {
  49. if(this.is_weixin()){
  50. this.navTitle()
  51. }
  52. this.details = options
  53. this.getTimeSet()
  54. },
  55. methods: {
  56. //判断是否是微信
  57. is_weixin() {
  58. let ua = navigator.userAgent.toLowerCase();
  59. return ua.indexOf('micromessenger') != -1;
  60. },
  61. navTitle() {
  62. let navTitle = document.getElementsByTagName('uni-page-head');
  63. navTitle[0].style.display = 'none'
  64. },
  65. //选择时间段
  66. bindTimeChange(e) {
  67. let index = e.detail.value
  68. console.log(e.detail.value, '-------------')
  69. this.index = index
  70. this.details.time_id = this.time_set[index].id
  71. this.details.start_time=this.time_set[index].start_time
  72. this.details.end_time=this.time_set[index].end_time
  73. console.log(this.range,'++++++++++++++++++++++')
  74. },
  75. //时间段配置
  76. getTimeSet() {
  77. this.$u.get('/mentor/time').then(res => {
  78. console.log(res, '--------')
  79. let list = res.data.list
  80. list.map(item => {
  81. item.range = item.start_time + '-' + item.end_time
  82. })
  83. this.time_set = list
  84. })
  85. },
  86. //添加
  87. add() {
  88. let data = {
  89. status: 1,
  90. teacher_id: this.$store.state.vuex_user.type_id,
  91. day: this.details.day,
  92. time_ids: this.details.time_id
  93. }
  94. this.$u.post('/mentor/scheduling', data).then(res => {
  95. console.log(res, '添加排班')
  96. if (res.code == 200) {
  97. uni.showToast({
  98. title: res.message,
  99. icon: 'none'
  100. })
  101. setTimeout(function() {
  102. uni.navigateBack()
  103. }, 2000);
  104. } else {
  105. }
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .add {
  113. height: 100%;
  114. background-image: url(../../static/images/add-bg.png);
  115. background-size: 100%;
  116. background-repeat: no-repeat;
  117. .form {
  118. margin: 0 28px;
  119. // background-color: #18B566;
  120. margin-top: 190px;
  121. .item {
  122. padding: 18px 20px;
  123. background-color: rgba(237, 244, 228, 1);
  124. opacity: 1;
  125. border-radius: 8px;
  126. display: flex;
  127. align-items: center;
  128. margin-bottom: 15px;
  129. .label {
  130. font-size: 16px;
  131. font-family: PingFang SC;
  132. font-weight: bold;
  133. line-height: 20px;
  134. color: #282828;
  135. opacity: 1;
  136. }
  137. .right {
  138. text-align: right;
  139. flex: 1;
  140. font-size: 12px;
  141. font-family: PingFang SC;
  142. font-weight: 400;
  143. line-height: 20px;
  144. color: #282828;
  145. opacity: 0.42;
  146. .no {
  147. font-size: 12px;
  148. font-family: PingFang SC;
  149. font-weight: 400;
  150. line-height: 20px;
  151. color: #282828;
  152. opacity: 0.42;
  153. }
  154. }
  155. }
  156. .save {
  157. height: 56px;
  158. background: #3B7653;
  159. opacity: 1;
  160. border-radius: 8px;
  161. line-height: 56px;
  162. text-align: center;
  163. font-size: 18px;
  164. margin-top: 63px;
  165. font-family: PingFang SC;
  166. font-weight: bold;
  167. color: #FFFFFF;
  168. opacity: 1;
  169. }
  170. }
  171. }
  172. </style>