template-items.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. width: 300,
  113. content: '确定删除该模板?',
  114. okValue: '确认',
  115. ok: function () {
  116. vm.loading.showModal()
  117. rehaAPI.deleteTemplate({
  118. templateId: vm.templateId
  119. }).then(function(res) {
  120. vm.loading.close()
  121. if(res.status == 200) {
  122. toastr && toastr.success("删除成功")
  123. } else {
  124. toastr && toastr.error(res.msg)
  125. }
  126. EventBus.$emit("refresh-index")
  127. vm.$router.replace("/")
  128. }).catch(function(e) {
  129. vm.loading.close()
  130. console.error(e)
  131. })
  132. },
  133. cancelValue: '取消',
  134. cancel: function () {}
  135. });
  136. d.showModal();
  137. },
  138. toDetail: function(o) {
  139. var vm = this
  140. vm.item = o
  141. vm.$router.push({
  142. path:"/template-item-detail",
  143. query: {
  144. templateId: vm.templateId,
  145. itemId: o.id
  146. }
  147. })
  148. }
  149. },
  150. // watch: {
  151. // '$route': function (to, from) {
  152. // var vm = this
  153. //// if(to.path == "/template-item-detail" && (from.path != "/template-item-detail" || from.path == "/")) {
  154. //// EventBus.$emit("show-item-detail", vm.item)
  155. //// }
  156. // if(to.path == "/template-item-detail") {
  157. // EventBus.$emit("show-item-detail", vm.item)
  158. // }
  159. // }
  160. // }
  161. }