template-list.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. var docInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  2. var TemplateList = {
  3. template: '<div>\
  4. <div class="title-name c-f16">\
  5. <span class="c-vam">模板库</span>\
  6. </div>\
  7. <ul>\
  8. <li v-for="(o,i) in items" class="temp-item c-nowrap c-t-center" @click="showTemplateDetail(o)">{{o.title}}</li>\
  9. <li class="temp-item c-nowrap c-t-center add" @click="newTemplate">添加新模板</li>\
  10. </ul>\
  11. </div>',
  12. props: [],
  13. data: function() {
  14. return {
  15. items: []
  16. }
  17. },
  18. created: function() {
  19. var vm = this
  20. vm.findTemplateList()
  21. EventBus.$on("refresh-index",function() {
  22. vm.findTemplateList()
  23. })
  24. },
  25. mounted: function() {
  26. var vm = this
  27. },
  28. methods: {
  29. findTemplateList: function() {
  30. var vm = this
  31. rehaAPI.findTemplateList({
  32. doctor: storage.docInfo.uid
  33. }).then(function(res) {
  34. vm.items = res.data
  35. })
  36. },
  37. showTemplateDetail: function(o) {
  38. var vm = this
  39. vm.$router.push({
  40. path:'/template-items',
  41. query: {
  42. name: o.title,
  43. isNew: false,
  44. templateId: o.id
  45. }
  46. })
  47. },
  48. newTemplate: function() {
  49. var vm = this
  50. vm.$router.push('/new-template-form')
  51. }
  52. }
  53. }