temp-send-panel.js 5.6 KB

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