guidance-template-panel.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. Vue.component('guidance-template-panel', {
  2. template: '<div class="ml20 mr20"">\
  3. <div ref="innerPanel" style="overflow-y: auto;">\
  4. <div class="list-arrow-r temp-item" v-for="(o, i) in items">\
  5. <div @click="showDetail(o)" :class="{\'active\': o == activetemplate}" class="item-header c-nowrap">\
  6. <span class="c-nowrap">{{o.title}}</span>\
  7. </div>\
  8. </div>\
  9. </div>\
  10. <div>\
  11. </div>\
  12. </div>',
  13. props: ["activetemplate"],
  14. data: function() {
  15. return {
  16. pagesize: 20,
  17. pageNo: 1,
  18. items: [],
  19. downListValue: '',
  20. searchKey:'',
  21. guideId: ''
  22. }
  23. },
  24. created: function() {
  25. var vm = this
  26. },
  27. mounted: function() {
  28. var vm = this
  29. var el = vm.$refs.innerPanel
  30. $(el).height($(window).height() - 140)
  31. window.addEventListener('resize', _.debounce(function() {
  32. $(el).height($(window).height() - 140)
  33. }, 300))
  34. el.onscroll = function() {
  35. var scrollHeight = el.scrollHeight;
  36. var scrollTop = el.scrollTop;
  37. var clientHeight = el.clientHeight;
  38. if (scrollHeight - clientHeight == scrollTop) {
  39. vm.selectGuidances()
  40. }
  41. };
  42. },
  43. methods: {
  44. debounceTempList: _.debounce(function(value, searchKey) {
  45. var vm = this
  46. vm.pageNo = 1
  47. vm.items = []
  48. vm.downListValue = value
  49. vm.searchKey = searchKey
  50. this.selectGuidances()
  51. }, 500, false),
  52. selectGuidances: function(){
  53. var vm=this;
  54. var params={
  55. type: vm.downListValue,
  56. id: '',
  57. title: this.searchKey,
  58. page: this.pageNo,
  59. pagesize: this.pagesize
  60. }
  61. rehaAPI.selectGuidances(params).then(function(res){
  62. if(res.status==200){
  63. if(res.data && res.data.length) {
  64. vm.pageNo++;
  65. vm.items = vm.items.concat(res.data)
  66. if(vm.items.length>0){
  67. var first = vm.items[0]
  68. EventBus.$emit('active-template', first)
  69. }
  70. }
  71. } else {
  72. layer.msg(res.msg,{icon:5});
  73. }
  74. })
  75. },
  76. showDetail: function(o) {
  77. var vm = this
  78. EventBus.$emit('active-template', o)
  79. }
  80. }
  81. })