bookTime.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <zj-page-layout :hasFooter="true">
  4. <view class="all-container">
  5. <view class="date-conteiner mt30">
  6. <view class="item">
  7. <view class="label"><text>*</text>选择时间</view>
  8. <view class="picker" @tap="isShowDatePicker = true">
  9. <text class="value" v-if="date">{{date}}</text>
  10. <text class="placeholder" v-else>请选择</text>
  11. <text class="iconfont icon-jinru"></text>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="mt30 remark-container">
  16. <view class="common-title">备注信息</view>
  17. <u--textarea v-model="remarkVal" placeholder="请输入备注内容" fixed border="none" height="120"></u--textarea>
  18. </view>
  19. </view>
  20. <template slot="footer">
  21. <view class="footer-btn-group">
  22. <u-button text="确定" type="primary" size="large" @click="submitData"></u-button>
  23. </view>
  24. </template>
  25. <u-datetime-picker
  26. :show="isShowDatePicker"
  27. v-model="datePickerValue"
  28. mode="date"
  29. :formatter="formatter"
  30. @cancel="isShowDatePicker = false"
  31. @close="isShowDatePicker = false"
  32. @confirm="confirmDate"
  33. :minDate="minDate"
  34. ></u-datetime-picker>
  35. </zj-page-layout>
  36. <!-- #endif -->
  37. <!-- #ifndef H5 -->
  38. <web-view :src="webViewHref(`/packageWorkorder/pages/bookTime`, pam, crossPagePam)" @message="crossPage.$listener"></web-view>
  39. <!-- #endif -->
  40. </template>
  41. <script>
  42. // #ifdef H5
  43. export default {
  44. data() {
  45. return {
  46. id: null,
  47. type: 1, // 1=预约,2=改约
  48. date: '',
  49. datePickerValue: Number(new Date()),
  50. minDate: Number(new Date()),
  51. isShowDatePicker: false,
  52. remarkVal: '', // 备注值
  53. }
  54. },
  55. onLoad({type, id}) {
  56. this.type = type || 1;
  57. this.id = id;
  58. uni.setNavigationBarTitle({
  59.  title: this.type == '1' ? '预约' : '改约'
  60. })
  61. },
  62. methods: {
  63. formatter(type, value) {
  64. if (type === 'year') {
  65. return `${value}年`
  66. }
  67. if (type === 'month') {
  68. return `${value}月`
  69. }
  70. if (type === 'day') {
  71. return `${value}日`
  72. }
  73. return value
  74. },
  75. confirmDate(e) {
  76. this.isShowDatePicker = false;
  77. let time = new Date(e.value);
  78. let y = time.getFullYear();
  79. let m = (time.getMonth()+1) < 10 ? '0' + (time.getMonth()+1) : time.getMonth()+1;
  80. let d = (time.getDate()) < 10 ? '0' + (time.getDate()) : time.getDate();
  81. let hh = (time.getHours()) < 10 ? '0' + (time.getHours()) : time.getHours();
  82. let mm = (time.getMinutes()) < 10 ? '0' + (time.getMinutes()) : time.getMinutes();
  83. let ss = (time.getSeconds()) < 10 ? '0' + (time.getSeconds()) : time.getSeconds();
  84. this.date = `${y}-${m}-${d}`;
  85. },
  86. // 提交
  87. submitData() {
  88. if (!this.date) return this.$toast('请选择改约时间');
  89. this.$api.post('/changeOrder/changeAppointmentTime', {
  90. id: this.id,
  91. appointmentTime: this.date + ' 00:00:00',
  92. appointmentEndTime: this.date + ' 23:59:59',
  93. remark: this.remarkVal,
  94. }).then((res) => {
  95. this.$successToast('改约成功');
  96. this.crossPage.$emit('refreshUserWorkorderList', '');
  97. this.crossPage.$emit('refreshUserWorkorderDetail', '');
  98. setTimeout(() => {
  99. this.$navToPage({
  100. delta: 1
  101. }, 'navigateBack')
  102. }, 500)
  103. });
  104. },
  105. },
  106. }
  107. // #endif
  108. // #ifndef H5
  109. export default {
  110. data() {
  111. return {
  112. pam: {},
  113. }
  114. },
  115. onLoad(pam) {
  116. this.pam = pam;
  117. }
  118. }
  119. // #endif
  120. </script>
  121. <style lang="scss" scoped>
  122. .all-container {
  123. padding-bottom: 30rpx;
  124. }
  125. .common-title {
  126. font-size: 32rpx;
  127. padding: 30rpx 0;
  128. text {
  129. color: $minor-color;
  130. }
  131. }
  132. .date-conteiner {
  133. background: #ffffff;
  134. padding: 30rpx 30rpx;
  135. .item {
  136. display: flex;
  137. align-items: center;
  138. justify-content: space-between;
  139. height: 50rpx;
  140. .label {
  141. margin-right: 30rpx;
  142. text {
  143. color: $error-color;
  144. }
  145. }
  146. .picker {
  147. .placeholder {
  148. color: $sec-font;
  149. }
  150. .iconfont {
  151. margin-left: 12rpx;
  152. color: $sec-font;
  153. }
  154. }
  155. }
  156. }
  157. .remark-container {
  158. padding: 1rpx 30rpx 30rpx;
  159. background: #ffffff;
  160. ::v-deep .u-textarea {
  161. background: #f4f5f9;
  162. }
  163. }
  164. </style>