UiDateTime.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <el-row class="form-group">
  3. <el-col style="min-height:50px;padding-top:10px;" :span="3">
  4. <label style="margin-left:10px;vertical-align: middle;" class="control-label">{{label ? label : 'Date-Time'}}</label>
  5. </el-col>
  6. <el-col :span="14" style="min-height:50px;padding-top:5px;">
  7. <el-date-picker class="date-time-J"
  8. v-model="valueD"
  9. type="datetime"
  10. :readonly="readonly ? true : false"
  11. :disable="disable ? true : false"
  12. :editable="editable ? true : false"
  13. :size="size ? size : 'large'"
  14. :placeholder="placeholder ? placeholder : '选择日期时间'"
  15. align="left"
  16. :format="format ? format : 'yyyy-MM-dd HH:mm'"
  17. :picker-options="pickerOptions1"
  18. @change="dateTimeChange">
  19. </el-date-picker>
  20. <input type="hidden" class="ui-date-time" :name="name ? name : 'date_time'" :value="valueD" style="width:0;height:0.5px;border: 0 solid rgba(255,255,255,0)" />
  21. </el-col>
  22. <el-col :span="7">
  23. <div class="classJs">
  24. <div v-if="tips">
  25. <span class="red">*</span>&ensp;{{tips}}
  26. </div>
  27. </div>
  28. </el-col>
  29. </el-row>
  30. </template>
  31. <script>
  32. export default {
  33. props: ['label','name','value','readonly','disable','editable','size','format','placeholder','tips'],
  34. data() {
  35. return {
  36. valueD: this._props.value ? this._props.value : '',
  37. pickerOptions1: {
  38. shortcuts: [
  39. {
  40. text: '一周后',
  41. onClick(picker) {
  42. const date = new Date();
  43. date.setTime(date.getTime() + 3600 * 1000 * 24 * 7);
  44. picker.$emit('pick', date);
  45. }
  46. },
  47. {
  48. text: '明天',
  49. onClick(picker) {
  50. const date = new Date();
  51. date.setTime(date.getTime() + 3600 * 1000 * 24);
  52. picker.$emit('pick', date);
  53. }
  54. },
  55. {
  56. text: '今天',
  57. onClick(picker) {
  58. picker.$emit('pick', new Date());
  59. }
  60. },
  61. {
  62. text: '昨天',
  63. onClick(picker) {
  64. const date = new Date();
  65. date.setTime(date.getTime() - 3600 * 1000 * 24);
  66. picker.$emit('pick', date);
  67. }
  68. },
  69. {
  70. text: '一周前',
  71. onClick(picker) {
  72. const date = new Date();
  73. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
  74. picker.$emit('pick', date);
  75. }
  76. }]
  77. }
  78. };
  79. },
  80. mounted() {
  81. },
  82. methods: {
  83. dateTimeChange (value) {
  84. this.valueD = value;
  85. }
  86. }
  87. }
  88. </script>
  89. <style scoped>
  90. .classJs {
  91. margin-left: 10px;
  92. vertical-align: middle;
  93. height:42px;
  94. line-height:42px;
  95. }
  96. .red{
  97. color: red;
  98. }
  99. </style>