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

150 lines
3.6 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <view class="popupCon">
  3. <view class="popTab">
  4. <view class="tabItem" :class="{active: currentPopTab==1}" @click="changePopTab(1)">月份选择</view>
  5. <view class="tabItem" :class="{active: currentPopTab==2}" @click="changePopTab(2)">自定义时间</view>
  6. </view>
  7. <view class="timer">
  8. <view class="tabCon" v-if="currentPopTab==1">
  9. <view class="dateBtn" @click="showDatePickerFn(1)" :class="{hui: !date1}">{{ date1 }}</view>
  10. <!-- <u-datetime-picker-my
  11. :show="show"
  12. v-model="value1"
  13. mode="year-month"
  14. :showToolbar="false"
  15. :visibleItemCount="4"
  16. @confirm="confirm"
  17. ></u-datetime-picker-my> -->
  18. </view>
  19. <view class="tabCon" v-else>
  20. <view class="dateBtn" :class="{hui: !date2}" @click="showDatePickerFn(2)">{{ date2 }}</view>
  21. <view class="to"></view>
  22. <view class="dateBtn" :class="{hui: !date3}" @click="showDatePickerFn(3)">{{ date3 }}</view>
  23. </view>
  24. <view class="btnBg" @click="selectDateClick">确定</view>
  25. <!-- <u-picker-my></u-picker-my> -->
  26. </view>
  27. <u-datetime-picker
  28. :show="showDatePicker"
  29. v-model="value1"
  30. mode="year-month"
  31. :visibleItemCount="4"
  32. :closeOnClickOverlay="false"
  33. @confirm="confirmDatePicker"
  34. ></u-datetime-picker>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. currentPopTab: 1,
  42. showDatePicker: false,
  43. value1: '',
  44. currentBtnDate: '',
  45. date1: '',
  46. date2: '',
  47. date3: '',
  48. }
  49. },
  50. methods: {
  51. changePopTab(num) {
  52. this.currentPopTab = num
  53. },
  54. // 1打开时间选择器
  55. showDatePickerFn(num) {
  56. this.showDate = false
  57. this.showDatePicker = true
  58. this.currentBtnDate = num
  59. },
  60. // 2选择时间选择器里的时间
  61. confirmDatePicker(val) {
  62. this.showDatePicker = false
  63. let date = uni.$u.date(val.value, 'yyyy-mm-dd')
  64. if(this.currentBtnDate==1) {
  65. date = uni.$u.date(val.value, 'yyyy-mm')
  66. }
  67. this['date'+this.currentBtnDate] = date
  68. this.$emit('confirmDatePicker')
  69. },
  70. // 3确定筛选时间
  71. selectDateClick() {
  72. let obj = {
  73. date1: this.date1,
  74. date2: this.date2,
  75. date3: this.date3,
  76. }
  77. if(this.currentPopTab==2) {
  78. if(!this.date2) return this.$u.toast('请选择开始时间')
  79. if(!this.date3) return this.$u.toast('请选择结束时间')
  80. if(new Date(this.date2)*1>new Date(this.date3)*1) return this.$u.toast('开始时间不能大于结束时间')
  81. delete obj.date1
  82. }else {
  83. if(!this.date1) return this.$u.toast('请选择时间')
  84. delete obj.date2
  85. delete obj.date3
  86. }
  87. this.$emit('selectDateClick', obj)
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .popupCon {
  94. height: 430rpx;
  95. .popTab {
  96. display: flex;
  97. padding: 40rpx 32rpx;
  98. .tabItem {
  99. font-size: 32rpx;
  100. color: #333;
  101. margin-right: 60rpx;
  102. &.active {
  103. color: $themC;
  104. position: relative;
  105. &::before {
  106. content: '';
  107. position: absolute;
  108. bottom: -20rpx;
  109. left: 50%;
  110. transform: translateX(-50%);
  111. width: 128rpx;
  112. height: 4rpx;
  113. background: #1989FA;
  114. border-radius: 3rpx;
  115. }
  116. }
  117. }
  118. }
  119. .tabCon {
  120. display: flex;
  121. align-items: center;
  122. padding-left: 32rpx;
  123. padding-top: 20rpx;
  124. .dateBtn {
  125. width: 280rpx;
  126. height: 80rpx;
  127. border-radius: 10rpx;
  128. border: 2rpx solid #1989FA;
  129. line-height: 80rpx;
  130. text-align: center;
  131. color: $themC;
  132. font-size: 32rpx;
  133. &.hui {
  134. border: 2rpx solid #E8E9EC;
  135. }
  136. }
  137. .to {
  138. font-size: 32rpx;
  139. margin: 0 40rpx;
  140. }
  141. }
  142. .btnBg {
  143. width: 396rpx;
  144. margin: 34rpx auto 42rpx auto;
  145. }
  146. }
  147. </style>