dmCalendarPickerView.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <dm-pop-view ref='popView' title="选择时段" :isShowConfirm="true" :maskTapHide='maskTapHide' @confirm="confirmAction">
  3. <view class="content">
  4. <uni-calendar
  5. :insert="true"
  6. :lunar="true"
  7. :range = "true"
  8. :startDate = "afterDate"
  9. :end-date="nowDate"
  10. @change="change"
  11. />
  12. </view>
  13. </dm-pop-view>
  14. </template>
  15. <script>
  16. import dmPopView from './dmPopView.vue'
  17. import uniCalendar from '../uni-calendar/uni-calendar.vue'
  18. import moment from '../../static/moment.min.js'
  19. export default {
  20. props: {
  21. maskTapHide: {
  22. type: Boolean,
  23. default: true
  24. },
  25. dataList: Array,
  26. },
  27. data() {
  28. return {
  29. nowDate:'',
  30. afterDate:'',
  31. startDate: '',
  32. endDate: ''
  33. }
  34. },
  35. created() {
  36. // this.nowDate = moment('2020-08-20').day(5).format("YYYY-MM-DD");
  37. // this.afterDate = moment('2020-08-20').day(-5).format('YYYY-MM-DD');
  38. // // console.log("日期1", this.nowDate, this.afterDate);
  39. },
  40. mounted() {
  41. // 控制只能选择之前90天
  42. // this.nowDate = moment('2020-08-20').day(5).format("YYYY-MM-DD");
  43. // this.afterDate = moment('2020-08-20').day(-5).format('YYYY-MM-DD');
  44. // // console.log("日期2", this.nowDate, this.afterDate);
  45. },
  46. methods: {
  47. show() {
  48. this.$refs.popView.show()
  49. },
  50. confirmAction() {
  51. if(this.startDate=="" || this.endDate==""){
  52. return uni.showToast({
  53. icon:'none',
  54. title:'请选择时间范围'
  55. });
  56. }
  57. const param = {
  58. startDate:this.startDate,
  59. endDate:this.endDate
  60. }
  61. this.$emit('confirmSelDate',param)
  62. },
  63. change(e) {
  64. // console.log(e);
  65. this.startDate = e.range.before;
  66. this.endDate = e.range.after;
  67. }
  68. },
  69. components: {
  70. dmPopView,
  71. uniCalendar
  72. }
  73. }
  74. </script>
  75. <style scoped lang="scss">
  76. .content {
  77. width: 100%;
  78. height: 776rpx;
  79. font-family: Verdana;
  80. padding-bottom: 100rpx;
  81. .list-content {
  82. margin-top: 20rpx;
  83. border-radius: 20rpx;
  84. background-color: #FFFFFF;
  85. margin-left: 20rpx;
  86. width: 670rpx;
  87. display: flex;
  88. flex-direction: column;
  89. padding: 30rpx 20rpx;
  90. .list-title {
  91. color: #333333;
  92. font-size: 28rpx;
  93. font-weight: bold;
  94. }
  95. .list-content-detail {
  96. margin-top: 14rpx;
  97. color: #333333;
  98. font-size: 24rpx;
  99. line-height: 46rpx;
  100. }
  101. }
  102. }
  103. </style>