person-panel.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. Vue.component('person-panel', {
  2. template: '<div class="ml20 mr20"">\
  3. <div class="search-warp">\
  4. <input class="inp-search" placeholder="查找模板" v-model="filter" @input="debounceTempList"/>\
  5. </div>\
  6. <div ref="innerPanel" style="overflow-y: auto;">\
  7. <div class="list-arrow-r temp-item" v-for="(o, i) in items">\
  8. <div @click="showDetail(o)" :class="{\'active\': o == activetemplate}" class="item-header c-nowrap">\
  9. <span class="c-nowrap">{{o.modelName}}</span>\
  10. </div>\
  11. </div>\
  12. </div>\
  13. <div>\
  14. </div>\
  15. </div>',
  16. props: ["activetemplate"],
  17. data: function() {
  18. return {
  19. filter: "",
  20. pagesize: 20,
  21. pageNo: 1,
  22. throttled: null,
  23. items: []
  24. }
  25. },
  26. created: function() {
  27. var vm = this
  28. EventBus.$on('refresh-person-panel',function() {
  29. vm.pageNo = 1
  30. vm.items = []
  31. vm.guidanceTempList()
  32. })
  33. },
  34. mounted: function() {
  35. var vm = this
  36. var el = vm.$refs.innerPanel
  37. $(el).height($(window).height() - 140)
  38. window.addEventListener('resize', _.debounce(function() {
  39. $(el).height($(window).height() - 140)
  40. }, 300))
  41. el.onscroll = function() {
  42. var scrollHeight = el.scrollHeight;
  43. var scrollTop = el.scrollTop;
  44. var clientHeight = el.clientHeight;
  45. if (scrollHeight - clientHeight == scrollTop) {
  46. vm.guidanceTempList()
  47. }
  48. };
  49. vm.guidanceTempList()
  50. },
  51. methods: {
  52. debounceTempList: _.debounce(function() {
  53. var vm = this
  54. vm.pageNo = 1
  55. vm.items = []
  56. this.guidanceTempList()
  57. }, 500, false),
  58. guidanceTempList: function() {
  59. var vm = this
  60. guidanceAPI.guidanceTempList( {
  61. type: 2, //模板类型 1:系统 2:自定义 为空:所有
  62. pageNo: vm.pageNo,
  63. pageSize: vm.pagesize,
  64. filter: vm.filter
  65. }).then(function(res) {
  66. if(res.data && res.data.length) {
  67. vm.pageNo++;
  68. vm.items = vm.items.concat(res.data)
  69. }
  70. })
  71. },
  72. showDetail: function(o) {
  73. var vm = this
  74. EventBus.$emit('active-template', o)
  75. var query = {
  76. modelCode: o.code,
  77. patient: storage.patient||"",
  78. timestemp: $.now()
  79. }
  80. vm.$router.push({path:'/person-edit-panel',query:query})
  81. }
  82. }
  83. })