person-panel.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.throttledTempList()
  30. })
  31. },
  32. mounted: function() {
  33. var vm = this
  34. var el = vm.$refs.innerPanel
  35. $(el).height($(window).height() - 140)
  36. window.addEventListener('resize', _.debounce(function() {
  37. $(el).height($(window).height() - 140)
  38. }, 300))
  39. el.onscroll = function() {
  40. var scrollHeight = el.scrollHeight;
  41. var scrollTop = el.scrollTop;
  42. var clientHeight = el.clientHeight;
  43. if (scrollHeight - clientHeight == scrollTop) {
  44. vm.guidanceTempList()
  45. }
  46. };
  47. vm.guidanceTempList()
  48. },
  49. methods: {
  50. debounceTempList: _.debounce(function() {
  51. var vm = this
  52. vm.pageNo = 1
  53. vm.items = []
  54. this.guidanceTempList()
  55. }, 500, false),
  56. guidanceTempList: function() {
  57. var vm = this
  58. guidanceAPI.guidanceTempList( {
  59. type: 2, //模板类型 1:系统 2:自定义 为空:所有
  60. pageNo: vm.pageNo,
  61. pageSize: vm.pagesize,
  62. filter: vm.filter
  63. }).then(function(res) {
  64. if(res.data && res.data.length) {
  65. vm.pageNo++;
  66. vm.items = vm.items.concat(res.data)
  67. }
  68. })
  69. },
  70. showDetail: function(o) {
  71. var vm = this
  72. EventBus.$emit('active-template', o)
  73. var query = {
  74. modelCode: o.code,
  75. patient: storage.patient||"",
  76. timestemp: $.now()
  77. }
  78. vm.$router.push({path:'/person-edit-panel',query:query})
  79. }
  80. }
  81. })