date-time-pick.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view class="date-pick-select">
  3. <date-time-picker
  4. :fields="fields"
  5. :start="startTime"
  6. :end="endTime"
  7. :defaultValue="defaultValue"
  8. @change="bindChange">
  9. <image class="date-icon" src="/static/date-icon.png"></image>
  10. </date-time-picker>
  11. </view>
  12. </template>
  13. <script>
  14. /**
  15. * 日期时间选择器(单个)
  16. */
  17. import DateTimePicker from '@/components/date-time-picker/date-time-picker.vue';
  18. export default {
  19. components: {DateTimePicker},
  20. props: {
  21. label: {
  22. type: String,
  23. default: ''
  24. },
  25. // 时间选择器的粒度 有效值:year | month | day | hour | minute
  26. fields: {
  27. type: String,
  28. default: 'minute'
  29. },
  30. // 允许选中的最小值
  31. startTime: {
  32. type: String,
  33. default: ''
  34. },
  35. // 允许选中的最大值
  36. endTime: {
  37. type: String,
  38. default: ''
  39. },
  40. // 选中的时间
  41. defaultValue: {
  42. type: String,
  43. default: ''
  44. },
  45. // 占位符
  46. placeholder: {
  47. type: String,
  48. default: '日期时间'
  49. },
  50. },
  51. methods: {
  52. bindChange(dateObj){
  53. this.$emit('change', dateObj)
  54. }
  55. }
  56. };
  57. </script>
  58. <style lang="less">
  59. .date-pick-select {
  60. display: flex;
  61. align-items: center;
  62. justify-content: space-between;
  63. min-width: 203.12rpx;
  64. height: 25rpx;
  65. border: 0.78rpx solid #E1E4ED;
  66. border-radius: 3.12rpx;
  67. .uni-input {
  68. min-width: 101.56rpx;
  69. font-size: 12.5rpx;
  70. color: #2E2F33;
  71. }
  72. .date-icon {
  73. margin-left: 7.81rpx;
  74. width: 10.93rpx;
  75. height: 10.93rpx;
  76. }
  77. }
  78. </style>