appoint-time.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Vue.component('appoint-time', {
  2. template: '<div><div class="c-f16 c-border-b pb5">就诊时间</div>\
  3. <ul class="clearfix">\
  4. <li class="h28 mr10" v-for="(list, index) in visittime">\
  5. <a class="h28" v-show="judge ? timeIndex != index : index != visitindex" href="javascript:void(0)" title="切换日期" @click="changeTime(index)">{{handteTime(list)}}</a>\
  6. <a class="h28 active" v-show="judge ? timeIndex == index : index == visitindex">{{handteTime(list)}}</a>\
  7. </li>\
  8. </ul>\
  9. </div>',
  10. props: ["visittime", "visitindex"],
  11. data: function() {
  12. return {
  13. judge: false,
  14. timeIndex: null
  15. }
  16. },
  17. mounted: function() {
  18. },
  19. methods: {
  20. changeTime: function(index) {
  21. this.timeIndex = index
  22. this.judge = true
  23. this.$emit("changetime", this.visittime[index])
  24. },
  25. handteTime: function(data) {
  26. var dateTime = data.date+"";
  27. var date= dateTime.split(" ")[0];
  28. var week = getWeek(date);
  29. var riqi = date.split("/");
  30. riqi = this.add0(riqi[1]) + "月" + this.add0(riqi[2]) + "日";
  31. var isMo = data.time;
  32. if(isMo =="a"){
  33. isMo ="上午";
  34. }else{
  35. isMo ="下午";
  36. }
  37. return " " + riqi + " " + week + isMo + " "
  38. },
  39. add0: function(num) {
  40. if(num < 10) {
  41. return '0' + num
  42. } else {
  43. return num
  44. }
  45. }
  46. }
  47. })