template-list.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 class="setSelect mt20" v-if="doctorList.length>1">\
  9. <el-select v-model="teamCode" @change="changeTeam">\
  10. <el-option\
  11. v-for="item in doctorList"\
  12. :key="item.id"\
  13. :label="item.name"\
  14. :value="item.id"\
  15. >\
  16. </el-option>\
  17. </el-select>\
  18. </li>\
  19. <li v-for="(o,i) in items" class="temp-item c-nowrap c-t-center" @click="showTemplateDetail(o)">{{o.title}}</li>\
  20. <li class="temp-item c-nowrap c-t-center add" @click="newTemplate">添加新模板</li>\
  21. </ul>\
  22. </div>',
  23. props: [],
  24. data: function() {
  25. return {
  26. items: [],
  27. teamCode:'',
  28. doctorList:[]
  29. }
  30. },
  31. created: function() {
  32. var vm = this
  33. vm.getDoctorTeam().then(function(){
  34. vm.findTemplateList()
  35. EventBus.$emit('getTeamCode',{
  36. teamCode:vm.teamCode
  37. })
  38. })
  39. EventBus.$on("refresh-index",function() {
  40. vm.findTemplateList()
  41. })
  42. },
  43. mounted: function() {
  44. var vm = this
  45. },
  46. methods: {
  47. findTemplateList: function() {
  48. var vm = this
  49. rehaAPI.findTemplateList({
  50. doctor: storage.docInfo.uid,
  51. adminTeamCode:vm.teamCode
  52. }).then(function(res) {
  53. vm.items = _.filter(res.data,function(item){
  54. return item.id!='808080eb708b19a20170995c982f0014'
  55. })
  56. })
  57. },
  58. getDoctorTeam:function(){
  59. var vm=this
  60. var wlyyAgentForDoc=JSON.parse(window.localStorage.getItem('wlyyAgentForDoc'));
  61. var uid=wlyyAgentForDoc && wlyyAgentForDoc.uid;
  62. return new Promise(function(resolve, reject) {
  63. rehaAPI.getDoctorTeam(uid).then(function(res){
  64. if(res.status==200){
  65. resolve()
  66. vm.doctorList=res.data;
  67. vm.teamCode=vm.doctorList[0].id
  68. }
  69. })
  70. })
  71. },
  72. changeTeam:function(){
  73. var vm=this
  74. EventBus.$emit('getTeamCode',{
  75. teamCode:vm.teamCode
  76. })
  77. vm.findTemplateList()
  78. },
  79. showTemplateDetail: function(o) {
  80. var vm = this
  81. vm.$router.push({
  82. path:'/template-items',
  83. query: {
  84. name: o.title,
  85. isNew: false,
  86. templateId: o.id
  87. }
  88. })
  89. },
  90. newTemplate: function() {
  91. var vm = this
  92. vm.$router.push({
  93. path:'/new-template-form',
  94. query:{
  95. teamCode:vm.teamCode
  96. }
  97. })
  98. }
  99. }
  100. }