timePicker.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!--
  2. * @Description: 时间选择器
  3. * @Author: kcz
  4. * @Date: 2020-01-11 17:30:48
  5. * @LastEditors: kcz
  6. * @LastEditTime: 2020-03-28 17:35:43
  7. -->
  8. <template>
  9. <a-time-picker
  10. :style="`width:${record.options.width}`"
  11. :disabled="record.options.disabled || parentDisabled"
  12. :allowClear="record.options.clearable"
  13. :placeholder="record.options.placeholder"
  14. :format="record.options.format"
  15. @change="handleSelectChange"
  16. :value="time"
  17. />
  18. </template>
  19. <script>
  20. import moment from "moment";
  21. export default {
  22. // eslint-disable-next-line vue/require-prop-types
  23. props: ["record", "value", "parentDisabled"],
  24. computed: {
  25. time() {
  26. if (!this.value) {
  27. return undefined;
  28. } else {
  29. return moment(this.value, this.record.options.format);
  30. }
  31. }
  32. },
  33. methods: {
  34. handleSelectChange(val) {
  35. let time;
  36. if (!val) {
  37. time = "";
  38. } else {
  39. time = val.format(this.record.options.format);
  40. }
  41. this.$emit("change", time);
  42. this.$emit("input", time);
  43. }
  44. }
  45. };
  46. </script>