device-searchbar.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (function() {
  2. Vue.component('device-searchbar', {
  3. template: '<div class="mt80 height-50 lheight-50 ml20" v-show="isShow">\
  4. <span class="fl c-f20 ml20 mr14 c-B5E1FC">居民/医生:</span>\
  5. <div class="l-text fl">\
  6. <input type="text" id="keyword" name="keyword" v-model="name" placeholder="关键字搜索" class="c-f20 f-ml10 l-text-field">\
  7. <div class="l-trigger l-trigger-search mt10" @click="search">\
  8. <div class="l-trigger-icon"></div>\
  9. </div>\
  10. </div>\
  11. </div>',
  12. props: [],
  13. data: function() {
  14. return {
  15. name: null,
  16. isShow: false
  17. }
  18. },
  19. methods: {
  20. search: function() {
  21. if(this.name) {
  22. EventBus.$emit('search-patient-info', {
  23. keyword: this.name
  24. });
  25. } else {
  26. toastr.error("请输入关键字");
  27. }
  28. }
  29. },
  30. mounted: function() {
  31. var vm = this;
  32. //数据加载完成
  33. EventBus.$on('data-load-complete', function(arg) {
  34. vm.isShow = true;
  35. });
  36. $('#keyword').bind('keyup', function(event) {
  37. if(event.keyCode == "13") { //回车执行查询
  38. vm.search();
  39. }
  40. });
  41. }
  42. })
  43. })()