template-items.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. var TemplateItems = {
  2. template: '<div style="height: 100%;">\
  3. <div class="title-name c-f16">\
  4. <span class="c-vam">{{name}}</span>\
  5. </div>\
  6. <div v-show="!items.length" class="c-t-center" style="margin-top: 200px;">\
  7. <img src="../../../images/fanhui_icon.png" class="c-vam"/>请在左侧“服务项”列表中选择\
  8. </div>\
  9. <div class="template-items" v-show="items.length">\
  10. <div class="item-card ptb10 plr15 mt10" v-for="(o, i) in items" @click="toDetail(o)">\
  11. <div class="c-nowrap">{{o.specialistServiceItemDO.title}}</div>\
  12. <div class="c-row c-f14 mt5">\
  13. <div class="c-50">\
  14. <span class="c-909090">医&emsp;&emsp;院:</span>\
  15. <span>{{o.hospitalName}}</span>\
  16. </div>\
  17. <div class="c-50">\
  18. <span class="c-909090">执行人员:</span>\
  19. <span class="c-909090">待选择</span>\
  20. </div>\
  21. </div>\
  22. <div class="c-row c-f14 mt5">\
  23. <div class="c-50">\
  24. <span class="c-909090">计划时间:</span>\
  25. <span class="c-909090">待选择</span>\
  26. </div>\
  27. <div class="c-50">\
  28. <span class="c-909090">费&emsp;&emsp;用:</span>\
  29. <span>{{o.expense}}元</span>\
  30. </div>\
  31. </div>\
  32. <img src="../../../images/qingchu_icon.png" class="item-delete-btn" @click.stop="deleteItem(o, i)"/>\
  33. </div>\
  34. </div>\
  35. <div class="foot-btns">\
  36. <a class="delete-btn c-t-center mr50" @click="deleteTemplate">\
  37. 删除模板\
  38. </a>\
  39. <a class="save-btn c-t-center" @click="saveTemplate">\
  40. 保存模板\
  41. </a>\
  42. </div>\
  43. </div>',
  44. props: [],
  45. data: function() {
  46. return {
  47. name: '',
  48. items: [],
  49. isNew: null,
  50. templateId: "",
  51. item: null
  52. }
  53. },
  54. beforeRouteEnter: function (to, from, next) {
  55. next(function(vm) {
  56. var query = vm.$route.query
  57. vm.name = query.name || '模板未命名',
  58. vm.templateId = query.templateId
  59. if(from.path != "/template-item-detail" || from.path == "/") {
  60. vm.items = []
  61. }
  62. if(vm.isNew == true || vm.isNew === "true") {
  63. vm.isNew = true
  64. } else {
  65. vm.isNew = false
  66. }
  67. })
  68. },
  69. created: function() {
  70. var vm = this
  71. EventBus.$on("add-template-item", function(o) {
  72. vm.items.push(o)
  73. })
  74. },
  75. mounted: function() {
  76. var vm = this
  77. },
  78. methods: {
  79. deleteItem: function(o, i) {
  80. var vm = this
  81. o.enable = true
  82. vm.items.splice(i, 1)
  83. },
  84. saveTemplate: function() {
  85. var vm = this
  86. vm.loading.showModal()
  87. rehaAPI.createTemplateDetail({
  88. doctor: storage.docInfo.code,
  89. json: JSON.stringify({
  90. templateId: vm.templateId,
  91. hospitalServiceItemId: _.pluck(vm.items, 'id').join(',')
  92. }),
  93. type: vm.isNew?"create":"edit"
  94. }).then(function(res) {
  95. if(res.status == 200) {
  96. vm.loading.close()
  97. toastr && toastr.success("保存成功")
  98. EventBus.$emit("refresh-index")
  99. vm.$router.replace("/")
  100. } else {
  101. vm.loading.close()
  102. toastr && toastr.error(res.msg)
  103. }
  104. }).catch(function(e) {
  105. vm.loading.close()
  106. console.error(e)
  107. })
  108. },
  109. deleteTemplate: function() {
  110. var vm = this
  111. var d = dialog({
  112. content: '确定删除该模板?',
  113. okValue: '确认',
  114. ok: function () {
  115. vm.loading.showModal()
  116. rehaAPI.deleteTemplate({
  117. templateId: vm.templateId
  118. }).then(function(res) {
  119. vm.loading.close()
  120. toastr && toastr.success("删除成功")
  121. EventBus.$emit("refresh-index")
  122. vm.$router.replace("/")
  123. }).catch(function(e) {
  124. vm.loading.close()
  125. console.error(e)
  126. })
  127. },
  128. cancelValue: '取消',
  129. cancel: function () {}
  130. });
  131. d.showModal();
  132. },
  133. toDetail: function(o) {
  134. var vm = this
  135. vm.item = o
  136. vm.$router.push({
  137. path:"/template-item-detail",
  138. query: {
  139. templateId: vm.templateId,
  140. itemId: o.id
  141. }
  142. })
  143. }
  144. },
  145. // watch: {
  146. // '$route': function (to, from) {
  147. // var vm = this
  148. //// if(to.path == "/template-item-detail" && (from.path != "/template-item-detail" || from.path == "/")) {
  149. //// EventBus.$emit("show-item-detail", vm.item)
  150. //// }
  151. // if(to.path == "/template-item-detail") {
  152. // EventBus.$emit("show-item-detail", vm.item)
  153. // }
  154. // }
  155. // }
  156. }