team-panel.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Vue.component('team-panel', {
  2. template: '<div class="team-panel 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\': !o.dropdown, \'list-arrow-d\': o.dropdown}" class="temp-item" v-for="(o, i) in items">\
  8. <div @click="selectTeam(o)" class="item-header c-nowrap">\
  9. <span class="c-nowrap">{{o.teamName}} ({{o.amount}})</span>\
  10. </div>\
  11. <div v-show="o.dropdown">\
  12. <div class="ml30 dropdown-item" v-for="(v, j) in o.items" :class="{\'list-arrow-r\': !v.dropdown, \'list-arrow-d\': v.dropdown}">\
  13. <div @click="seletGroup(v)" >{{v.name}}</div>\
  14. <div v-show="v.dropdown">\
  15. <div @click="showDetail(t,o)" class="ml30 dropdown-item" v-for="(t, j) in v.items">\
  16. <span :class="{\'active\': t == activetemplate}" class="c-nowrap item-header">{{t.title}}</span>\
  17. <span style="position: absolute;right:24px;">\
  18. <img src="../../../images/shiyongren_icon.png" width="14"/>\
  19. {{t.useTimes}}\
  20. </span>\
  21. </div>\
  22. </div>\
  23. </div>\
  24. </div>\
  25. </div>\
  26. </div>\
  27. <div>\
  28. </div>\
  29. </div>',
  30. props: ['activetemplate'],
  31. data: function() {
  32. return {
  33. activeTeam: null,
  34. filter: "",
  35. pagesize: 20,
  36. pageNo: 1,
  37. throttled: null,
  38. items: [],
  39. activeItem: null
  40. }
  41. },
  42. created: function() {
  43. var vm = this
  44. EventBus.$on('refresh-team-panel',function() {
  45. EventBus.$emit('active-nav-tab', 1)
  46. vm.debounceTempList()
  47. })
  48. },
  49. mounted: function() {
  50. var vm = this
  51. var el = vm.$refs.innerPanel
  52. $(el).height($(window).height() - 140)
  53. window.addEventListener('resize', _.debounce(function() {
  54. $(el).height($(window).height() - 140)
  55. }, 300))
  56. vm.getDoctorTeams()
  57. },
  58. methods: {
  59. debounceTempList: _.debounce(function() {
  60. var vm = this
  61. vm.pageNo = 1
  62. this.getTeamGuidanceListByLabelWithFilter()
  63. }, 500, false),
  64. getTeamGuidanceListByLabelWithFilter: function() {
  65. var vm = this
  66. guidanceAPI.getTeamGuidanceListByLabelWithFilter({
  67. teamId: vm.activeTeam.teamId,
  68. filter: vm.filter
  69. }).then(function(res) {
  70. var data = res.data
  71. if(data) {
  72. vm.activeTeam.items = _.map(_.keys(data), function(k) {
  73. return {
  74. name: k,
  75. dropdown: true,
  76. code: data[k]&&data[k][0].labelCode,
  77. teamId: vm.activeTeam.teamId,
  78. items: data[k]
  79. }
  80. })
  81. }
  82. })
  83. },
  84. getDoctorTeams: function() {
  85. var vm = this
  86. guidanceAPI.getDoctorTeams({
  87. }).then(function(res) {
  88. vm.items = res.teamList
  89. vm.$nextTick(function() {
  90. if(vm.items && vm.items.length) {
  91. vm.activeTeam = vm.items[0]
  92. $('.team-panel .temp-item').eq(0).find('.item-header').click()
  93. }
  94. })
  95. })
  96. },
  97. selectTeam: function(o) {
  98. var vm = this
  99. o.dropdown=!o.dropdown
  100. if(o.teamName !== vm.activeTeam.teamName) {
  101. vm.filter = ""
  102. vm.activeTeam.dropdown = false
  103. }
  104. vm.activeTeam = o
  105. if(!o.items || o.items.length) {
  106. guidanceAPI.findAllListByPage({
  107. teamId: o.teamId,
  108. pageNo: 1,
  109. pageSize: 1000
  110. }).then(function(res) {
  111. Vue.set(o, 'items', res.data);
  112. })
  113. }
  114. },
  115. seletGroup: function(v) {
  116. var vm = this
  117. Vue.set(v, 'dropdown', !v.dropdown);
  118. if(!v.items || !v.items.length) {
  119. guidanceAPI.getTeamGuidanceLabelList({
  120. teamId: vm.activeTeam.teamId,
  121. pageNo: 1,
  122. pageSize: 1000,
  123. labelCode: v.code
  124. }).then(function(res) {
  125. Vue.set(v, 'items', res.data);
  126. })
  127. }
  128. },
  129. showDetail: function(o,t) {
  130. var vm = this
  131. EventBus.$emit('active-template', o)
  132. var query = {
  133. teamId: t.teamId,
  134. teamTemplateCode: o.teamTemplateCode,
  135. modelCode: vm.modelCode,
  136. patient: storage.patient||"",
  137. timestemp: $.now()
  138. }
  139. vm.$router.push({path:'/team-edit-panel',query:query})
  140. }
  141. }
  142. })