Dater.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. export default {
  2. props:{
  3. date:{
  4. type:Object,
  5. default(){
  6. return {
  7. year:0,
  8. month:0,
  9. day:0,
  10. hour:0,
  11. minute:0,
  12. second:0
  13. }
  14. }
  15. },
  16. anotherDate:{
  17. type:Object,
  18. default(){
  19. return {
  20. year:0,
  21. month:0,
  22. day:0,
  23. hour:0,
  24. minute:0,
  25. second:0
  26. }
  27. }
  28. },
  29. options:{
  30. type:Array,
  31. default(){
  32. return []
  33. }
  34. },
  35. },
  36. data(){
  37. return {
  38. option:''
  39. }
  40. },
  41. methods:{
  42. setOption(visible){
  43. if(!visible)this.$refs.anotherDateYear.focus()
  44. },
  45. calculate(){
  46. return new Promise(
  47. (resolve, reject)=>{
  48. setTimeout(()=>{
  49. this.calculateAsync();
  50. resolve();
  51. },100)
  52. }
  53. )
  54. },
  55. calculateAsync(){
  56. this.$emit('calculate',this.date,this.anotherDate,this.option,this)
  57. },
  58. focus(name){
  59. name=name||'dateYear';
  60. this.$refs[name].focus();
  61. },
  62. log(){
  63. console.log.apply(this,arguments)
  64. }
  65. }
  66. }