system-panel.js 2.3 KB

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