doctor-select.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Vue.component('doctor-select', {
  2. template:
  3. '<div><div class="c-f16 c-border-b pb5 mb20 lh20" style="margin-bottom:15px">医生列表<input class="h34 ml30 bd1 inp_border" v-model="keyword" @click="selDoc" @input="selDoc" placeholder="输入医生姓名"/></div>\
  4. <ul class="pd0" v-show="!iswuhaoyuan">\
  5. <li class="clearfix pt10 pb10 bd1 disbox mb20" v-for="(doctor, index) in doctorList" v-show="!doctor.isShow">\
  6. <div class="fl w200 mt10 mb10">\
  7. <h3 class="c-f20 mb10">{{doctor.name}}<span class="c-f16 ml20">{{doctor.title}}</span></h3>\
  8. <p class="c-f16 h24 mb10">诊查费:<span class="fc-red">{{doctor.fee ? doctor.fee : handleFee(doctortime[index])}}</span>元</p>\
  9. <p class="over-scroll lh20">{{doctor.introduce}}</p>\
  10. </div>\
  11. <ul class="fl w500 mb0 ml10 pd0 pt20">\
  12. <li class="fl li-time" v-for="(list, ind) in doctortime[index]">\
  13. <a v-show="list.status == 1" class="bgc-fff" title="选择日期" @click="seldetailTime(list, index, ind)">{{handteTime(list)}}<span class="bgc-12b7f5">{{add0(list.max - list.used)}}</span></a>\
  14. <a v-show="list.status == 2" class="bgc-d7dce6 fc-fff">{{handteTime(list)}}<span class="bgc-c3c8d2">满</span></a>\
  15. <a v-show="list.status == 0" class="bgc-d7dce6 fc-fff">{{handteTime(list)}}<span class="bgc-c3c8d2">停</span></a>\
  16. </li>\
  17. </ul>\
  18. </li>\
  19. </ul>\
  20. <div class="pt60" v-show="iswuhaoyuan"><img class="setauto" width="250px" src="../../img/wuhaoyuan_img.png" alt="无号源" /></div>\
  21. </div>',
  22. props: ['doctors', 'doctortime', 'iswuhaoyuan'],
  23. data: function () {
  24. return {
  25. keyword: '',
  26. doctorList: [],
  27. docName: [],
  28. selIndex: []
  29. }
  30. },
  31. mounted: function () {},
  32. methods: {
  33. seldetailTime: function (list, index, ind) {
  34. $.extend(list, { 'index': index, 'ind': ind })
  35. this.$emit('seldetail', list)
  36. },
  37. handteTime: function (data) {
  38. var dateTime = data.date + ''
  39. var date = dateTime.split(' ')[0]
  40. var week = getWeek(date)
  41. var riqi = date.split('/')
  42. riqi = this.add0(riqi[1]) + '-' + this.add0(riqi[2])
  43. var isMo = data.time
  44. if (isMo == 'a') {
  45. isMo = '上午'
  46. } else {
  47. isMo = '下午'
  48. }
  49. return ' ' + riqi + ' ' + week + isMo + ' '
  50. },
  51. add0: function (num) {
  52. if (num < 10) {
  53. return '0' + num
  54. } else {
  55. return num
  56. }
  57. },
  58. selDoc: function () {
  59. var len = this.doctorList.length
  60. if (this.keyword.length < 1) {
  61. for (var i = 0; i < len; i++) {
  62. this.$set(this.doctorList, i, $.extend({}, this.doctorList[i], { 'isShow': false }))
  63. }
  64. return
  65. }
  66. var reg = new RegExp(this.keyword)
  67. for (var i = 0; i < len; i++) {
  68. if (this.docName[i].match(reg)) {
  69. this.$set(this.doctorList, i, $.extend({}, this.doctorList[i], { 'isShow': false }))
  70. } else {
  71. this.$set(this.doctorList, i, $.extend({}, this.doctorList[i], { 'isShow': true }))
  72. }
  73. }
  74. },
  75. handleFee: function (arr) {
  76. if (arr && arr.length > 0) {
  77. return arr[0].fee
  78. } else {
  79. return ''
  80. }
  81. }
  82. },
  83. watch: {
  84. doctors: function (list) {
  85. this.doctorList = list
  86. for (var i = 0, len = list.length; i < len; i++) {
  87. this.docName[i] = list[i].name
  88. }
  89. }
  90. }
  91. })