team-new-panel.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. var TeamNewtPanel = {
  2. template: '<div>\
  3. <div class="temp-info c-f14">\
  4. <div @click="saveAsPersonTemplate" class="save-btn ml10" v-if="sendMode" style="width: 150px;">\
  5. 保存为个人模板\
  6. </div>\
  7. <div class="temp-name pl10 ptb10">\
  8. 模板名称:<input v-model="modelName" placeholder="请输入模板名称( 10字内 )" class="c-f14" maxlength="10"/>\
  9. </div>\
  10. <div class="team-name pl10 ptb10">\
  11. 所属团队:<select v-model="selectedTeam" class="c-f14" style="border:0;" @change="selectTeam">\
  12. <option value=""></option>\
  13. <option v-for="(team, i) in teams" :value="i">{{team.teamName}}</option>\
  14. </select>\
  15. </div>\
  16. <div class="label-name pl10 ptb10 list-arrow-r" :class="{\'list-arrow-r\': !labelsDropdown, \'list-arrow-d\': labelsDropdown}">\
  17. <div @click="labelsDropdown = !labelsDropdown">指导标签:{{selectedLabel && selectedLabel.name}}</div>\
  18. <ul v-show="labelsDropdown" class="c-list msg-list clearfix">\
  19. <li @click="selectLabel(label)" v-for="(label, i) in labelList" :class="{\'active-icon\': label.active}" class="c-list-li ">\
  20. <div>\
  21. <span>{{label.name}}</span>\
  22. </div>\
  23. </li>\
  24. </ul>\
  25. </div>\
  26. <div class="c-position-r">\
  27. <textarea @input="countWord" v-model="content" class="ptb10 plr10" style="border: 0;width: 100%;box-sizing: border-box;height: 180px;"></textarea>\
  28. <div class="c-t-right mr10 mb5 c-909090">{{count}}/{{words}}</div>\
  29. </div>\
  30. </div>\
  31. <div class="img-wrap mt20 c-f14">\
  32. <div>插入图片<span class="c-909090">({{imgs.length}}/9)</span></div>\
  33. <div class="clearfix">\
  34. <div class="c-position-r fl mr15 mt20" v-for="(url,i) in imgs">\
  35. <img class="upload_img" :src="url" width="65" height="65">\
  36. <div class="delete-icon" @click="removeImg(url,i)"><img src="../../../images/delete_icon.png" width="18"></div>\
  37. </div>\
  38. <img-upload @uploaded="imgUploaded" v-show="imgs.length<9"></img-upload>\
  39. </div>\
  40. </div>\
  41. <div class="foot-btns">\
  42. <a class="preview-btn c-t-center mr15" @click="preview">\
  43. 预览\
  44. </a>\
  45. <a class="send-btn c-t-center" @click="save" v-show="!sendMode">\
  46. 保存\
  47. </a>\
  48. <a class="send-btn c-t-center" @click="sendTeamTemplate" v-show="sendMode">\
  49. 发送\
  50. </a>\
  51. </div>\
  52. </div>',
  53. props: [],
  54. data: function() {
  55. return {
  56. words: 1000,
  57. count: 0,
  58. content: "",
  59. modelName: "",
  60. imgs: [],
  61. modelCode: "",
  62. teamId: "",
  63. teamTemplateCode: "",
  64. teams: [],
  65. labelsDropdown: false,
  66. selectedLabel: null,
  67. labelList: [],
  68. selectedTeam: "",
  69. sendMode: false // 根据url中是否携带patient来判断是否是"发送"模式
  70. }
  71. },
  72. computed: {
  73. },
  74. created: function() {
  75. var vm = this
  76. vm.findDoctorLeaderTeam().then(function(res) {
  77. vm.teams = res.teamList
  78. })
  79. },
  80. mounted: function() {
  81. EventBus.$emit('active-nav-tab', 1)
  82. },
  83. methods: {
  84. countWord: function() {
  85. if(this.content.length <= this.words) {
  86. this.count = this.content.length
  87. } else {
  88. this.content = this.content.slice(0, this.words)
  89. }
  90. },
  91. findDoctorLeaderTeam: function() {
  92. return guidanceAPI.findDoctorLeaderTeam()
  93. },
  94. selectTeam: function() {
  95. var vm = this
  96. if(vm.selectedTeam !== '') {
  97. vm.teamId = vm.teams[vm.selectedTeam].teamId
  98. vm.findAllLabelList()
  99. }
  100. },
  101. findAllLabelList: function() {
  102. var vm = this
  103. return guidanceAPI.findAllLabelList({
  104. teamId: vm.teamId
  105. }).then(function(res) {
  106. var selected = null
  107. var label = vm.selectedLabel? vm.selectedLabel.name: '未分组'
  108. selected = _.filter(res.data, function(o) {
  109. return o.name == label
  110. })
  111. if(selected[0]) {
  112. selected[0].active = true
  113. vm.selectedLabel = selected[0]
  114. }
  115. vm.labelList = res.data
  116. }).catch(function(e){
  117. console.error(e)
  118. })
  119. },
  120. selectLabel: function(label) {
  121. var vm = this
  122. vm.selectedLabel && (vm.selectedLabel.active = false)
  123. label.active = true
  124. vm.selectedLabel = label
  125. vm.labelsDropdown = false
  126. },
  127. imgUploaded: function(url) {
  128. var vm = this
  129. vm.imgs.push(httpRequest.getImgUrl(url))
  130. },
  131. removeImg: function(url, idx) {
  132. var vm = this
  133. vm.imgs.splice(idx, 1)
  134. },
  135. save: function() {
  136. var vm = this
  137. if(!vm.modelName) {
  138. toastr && toastr.error("模板名称不能为空")
  139. return
  140. }
  141. if(vm.selectedTeam === '') {
  142. toastr && toastr.error("请选择所属团队")
  143. return
  144. }
  145. if(!vm.content) {
  146. toastr && toastr.error("模板内容不能为空")
  147. return
  148. }
  149. var param = {
  150. content: vm.content,
  151. title: vm.modelName,
  152. images: vm.imgs.join(','),
  153. teamInfo: vm.teams&&JSON.stringify(vm.teams)||""
  154. }
  155. if(vm.selectedLabel && vm.selectedLabel.code) {
  156. param.labelCode = vm.selectedLabel.code
  157. }
  158. guidanceAPI.saveTeamGuidance(param).then(function(res) {
  159. if(res.status == 200) {
  160. toastr && toastr.success("保存成功")
  161. EventBus.$emit('refresh-team-panel')
  162. }
  163. }).catch(function(e) {
  164. console.error(e)
  165. })
  166. },
  167. saveAsPersonTemplate: function() {
  168. var vm = this
  169. if(!vm.modelName) {
  170. toastr && toastr.error("模板名称不能为空")
  171. return
  172. }
  173. if(!vm.content) {
  174. toastr && toastr.error("模板内容不能为空")
  175. return
  176. }
  177. var param = {
  178. content: vm.content,
  179. modelName: vm.modelName
  180. }
  181. var img = vm.imgs.join(',').trim()
  182. if(img) {
  183. param.imagesUrl = img
  184. }
  185. guidanceAPI.newTemplate(param).then(function(res) {
  186. if(res.status == 200) {
  187. toastr && toastr.success("保存成功")
  188. EventBus.$emit('refresh-person-panel')
  189. } else {
  190. toastr && toastr.error(res.msg)
  191. }
  192. }).catch(function(e) {
  193. console.error(e)
  194. })
  195. },
  196. sendTeamTemplate: function() {
  197. var vm = this
  198. if(!vm.modelName) {
  199. toastr && toastr.error("模板名称不能为空")
  200. return
  201. }
  202. if(!vm.content) {
  203. toastr && toastr.error("模板内容不能为空")
  204. return
  205. }
  206. var team = _.filter(vm.teams, function(o) {
  207. return o.teamId == vm.teamId
  208. })
  209. if(!team.length) {
  210. // 匹配不了说明医生修改了指导所属的 团队,并且入口团队并不在选中的列表中。则默认选择选中团队中的第一个团队来发送
  211. team = [vm.teams[0]]
  212. }
  213. var d = dialog({
  214. width: 350,
  215. content: '发出后无法变更,是否确认发送给居民?',
  216. okValue: '继续发送',
  217. ok: function () {
  218. guidanceAPI.sendTemplate( {
  219. patient: storage.patient,
  220. content: vm.content,
  221. guidanceCode: vm.teamTemplateCode,
  222. images: vm.imgs.join(','),
  223. teamId: JSON.stringify(team)
  224. }).then(function(res) {
  225. toastr && toastr.success("发送成功")
  226. }).catch(function(e) {
  227. console.error(e)
  228. })
  229. },
  230. cancelValue: '取消',
  231. cancel: function () {}
  232. });
  233. d.showModal();
  234. },
  235. preview: function() {
  236. var vm = this
  237. var query = {
  238. modelCode: vm.modelCode,
  239. patient: storage.patient||"",
  240. timestemp: $.now()
  241. }
  242. this.$router.push({path:'/preview-panel',query:query})
  243. }
  244. },
  245. watch: {
  246. '$route': function (to, from) {
  247. var vm = this
  248. if(to.path == "/preview-panel") {
  249. EventBus.$emit('preview-template', {
  250. content: vm.content,
  251. modelName: vm.modelName,
  252. imgs: vm.imgs
  253. })
  254. }
  255. },
  256. 'content': function(v) {
  257. this.countWord()
  258. }
  259. }
  260. }