temp-send-panel.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. var httpData = GetRequest()
  2. console.log('httpDatahttpDatahttpData', httpData)
  3. var docInfo = JSON.parse(window.localStorage.getItem("wlyyAgent"));
  4. var previewLayerIndex;
  5. function closeGuidancePreview(){
  6. layer.close(previewLayerIndex)
  7. }
  8. var TempSendPanel = {
  9. template: '<div class="template-wrap">\
  10. <div style="height: 34px;" >\
  11. 指导模板\
  12. </div>\
  13. <div class="temp-info c-f14">\
  14. <div class="temp-name pl10 ptb10">\
  15. 模板名称:<input v-model="modelName" placeholder="请输入模板名称( 10字内 )" disabled class="c-f14" />\
  16. </div>\
  17. <div class="c-position-r">\
  18. <textarea @input="countWord" v-model="content" class="ptb10 plr10" disabled style="border: 0;width: 100%;box-sizing: border-box;height: 180px;"></textarea>\
  19. <div class="c-t-right mr10 mb5 c-909090">{{count}}/{{words}}</div>\
  20. </div>\
  21. </div>\
  22. <div v-if="imgs.length>0" class="img-wrap mt20 c-f14">\
  23. <div>插入图片<span class="c-909090">({{imgs.length}}/9)</span></div>\
  24. <div class="img-items mt10">\
  25. <img v-for="(v,i) in imgs" src="v" />\
  26. </div>\
  27. </div>\
  28. <div class="foot-btns mt20">\
  29. <a class="preview-btn c-t-center mr15" @click="preViewTemplate">\
  30. 预览\
  31. </a>\
  32. <a class="send-btn c-t-center" @click="sendTemplate">\
  33. 发送\
  34. </a>\
  35. </div>\
  36. </div>',
  37. props: [],
  38. data: function() {
  39. return {
  40. words: 1000,
  41. count: 0,
  42. modelName: '',
  43. content: '',
  44. modelCode: '',
  45. imgs: [],
  46. curTemplate: undefined,
  47. previewLayerIndex: undefined,
  48. planDetaiId: httpData['planDetaiId']
  49. }
  50. },
  51. watch: {
  52. content: function(){
  53. this.countWord()
  54. }
  55. },
  56. mounted: function(){
  57. var vm = this
  58. EventBus.$on('active-template', function(o){
  59. vm.modelCode = o.code
  60. vm.selectGuidances()
  61. })
  62. },
  63. destroyed: function(){
  64. },
  65. methods: {
  66. countWord: function() {
  67. if(this.content.length <= this.words) {
  68. this.count = this.content.length
  69. } else {
  70. this.content = this.content.slice(0, this.words)
  71. }
  72. },
  73. selectGuidances: function(){
  74. var vm=this;
  75. var params={
  76. type: '',
  77. id: vm.modelCode,
  78. title: '',
  79. page: 1,
  80. pagesize: 1
  81. }
  82. rehaAPI.selectGuidances(params).then(function(res){
  83. if(res.status==200){
  84. if(res.data && res.data.length) {
  85. var data = res.data[0]
  86. vm.curTemplate = data
  87. vm.content = data.content
  88. vm.modelName = data.title
  89. // vm.imgs = _.map(data.imagesUrls, function(s) {
  90. // return httpRequest.getImgUrl(s)
  91. // })
  92. }
  93. } else {
  94. layer.msg(res.msg,{icon:5});
  95. }
  96. })
  97. },
  98. preViewTemplate: function(){
  99. var vm = this
  100. previewLayerIndex = layer.open({
  101. type: 2,
  102. area: ['380px', '600px'],
  103. shade: 0.5,
  104. title: '预览',
  105. fixed: true, //不固定
  106. maxmin: true,
  107. closeBtn:1,
  108. shift: 5,
  109. shadeClose: false, //点击遮罩关闭层
  110. content: '../../rehabilitation/html/rehabilitation_guidance_preview.html?modelCode='+vm.modelCode
  111. });
  112. },
  113. sendTemplate: function() {
  114. var vm = this
  115. if(!vm.modelName) {
  116. toastr && toastr.error("模板名称不能为空")
  117. return
  118. }
  119. if(!vm.content) {
  120. toastr && toastr.error("模板内容不能为空")
  121. return
  122. }
  123. layer.confirm('发出后无法变更,是否确认发送给居民?', { btn: ['继续发送', '取消'], title: "提示" }, function () {
  124. var loading = layer.load(0, {shade: false})
  125. var params = [{
  126. patient: httpData['patient'],
  127. article: vm.modelCode,
  128. doctor: docInfo.uid,
  129. attachedContent: vm.content,
  130. attachedTitle: vm.modelName,
  131. relationCode: vm.planDetaiId //业务关联
  132. }]
  133. rehaAPI.sendGuidance({
  134. json: JSON.stringify(params),
  135. planId: httpData['planId']
  136. }).then(function(res) {
  137. layer.close(loading)
  138. if(res.status == 200){
  139. // 确认完成康复指导
  140. window.parent.closeKFZDlayer(vm.planDetaiId)
  141. layer.msg('发送成功', {
  142. icon: 1
  143. })
  144. } else {
  145. layer.msg(res.msg, {
  146. icon: 5
  147. })
  148. }
  149. }).catch(function(e) {
  150. console.error(e)
  151. })
  152. })
  153. }
  154. }
  155. }