guide_the_message.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. var httpData = GetRequest();
  2. var docInfo = JSON.parse(window.localStorage.getItem('docInfo'));
  3. var previewLayerIndex, followupLayerIndex, KFZDlayerIndex;
  4. function closeGuidancePreview(){
  5. layer.close(previewLayerIndex)
  6. }
  7. function closeFollowUpLayer(planDetaiId, relationCode){
  8. top.rehabilitationGuideVue.updateNoteAndImageRehabilitationOperate(planDetaiId, relationCode)
  9. layer.close(followupLayerIndex)
  10. }
  11. function closeKFZDlayer(planDetaiId){
  12. top.rehabilitationGuideVue.saveRehabilitationOperateRecord(planDetaiId, 5)
  13. layer.close(KFZDlayerIndex)
  14. }
  15. function showSuccessMessage(msg) {
  16. layer.msg(msg, {
  17. icon: 1
  18. })
  19. }
  20. function showErrorMessage(msg) {
  21. layer.msg(msg, {
  22. icon: 5
  23. })
  24. }
  25. top.rehabilitationGuideVue = new Vue({
  26. el: "#app",
  27. data: {
  28. imgData: {
  29. accept: 'image/gif, image/jpeg, image/png, image/jpg',
  30. },
  31. isCollapse: false,
  32. upImgs: [],
  33. upImgArr: [],
  34. planid: httpData['planid'],
  35. service: {
  36. relationRecordImg:{},
  37. messageList:{},
  38. },
  39. pId: httpData['pId'],
  40. oprateType: httpData['oprateType'], // oprateType 1 查看单个服务项
  41. patient: httpData['patient'],
  42. layerIndex: undefined
  43. },
  44. mounted: function() {
  45. this.getServiceItem();
  46. },
  47. methods: {
  48. // 提醒患者 num 1康复指导2康复下转3复诊提醒4上门服务提醒5家签提醒
  49. sendSpecialistWeixinMessage: function(type){
  50. var vm = this
  51. var _type = type == 4? 4:type==7?3:''
  52. var loading = layer.load(0, {shade: false})
  53. var params = {
  54. patient: vm.patient,
  55. doctor: docInfo.code,
  56. type: _type,
  57. relationCode: vm.planid,
  58. planId: vm.pId
  59. }
  60. rehaAPI.sendSpecialistWeixinMessage(params).then(function(res){
  61. layer.close(loading)
  62. if(res.status == 200){
  63. showSuccessMessage('提交成功!')
  64. if(_type == 3 || _type == 4){ // 提醒患者后,即认为是已完成
  65. vm.saveRehabilitationOperateRecord(vm.planid, type)
  66. }
  67. } else {
  68. showErrorMessage(res.msg)
  69. }
  70. })
  71. },
  72. //健康指导
  73. kfzd:function(){
  74. var vm=this
  75. KFZDlayerIndex = layer.open({
  76. type: 2,
  77. // offset: ['100px'], //右下角弹出
  78. area: ['80%', '650px'],
  79. shade: 0.5,
  80. title: '康复指导',
  81. fixed: true, //不固定
  82. maxmin: true,
  83. closeBtn: 1,
  84. shift: 5,
  85. shadeClose: false, //点击遮罩关闭层
  86. content:'../../rehabilitation/html/rehabilitation_guidance.html?patient='+vm.patient+'&planDetaiId='+vm.planid+'&planId='+vm.pId,
  87. end: function() { // 未点击确定按钮,点击关闭按钮
  88. this.getServiceItem();   
  89. }
  90. });
  91. },
  92. // 康复随访计划
  93. sfjh: function(planDetaiId){
  94. var vm=this
  95. followupLayerIndex = layer.open({
  96. type: 2,
  97. // offset: ['100px'], //右下角弹出
  98. area: ['80%', '650px'],
  99. shade: 0.5,
  100. title: '随访计划',
  101. fixed: true, //不固定
  102. maxmin: true,
  103. closeBtn: 1,
  104. shift: 5,
  105. shadeClose: false, //点击遮罩关闭层
  106. content:'../../followup/html/followup_newplan.html?patient='+vm.patient+'&planDetaiId='+planDetaiId+'&planId='+vm.pId,
  107. end: function() { // 未点击确定按钮,点击关闭按钮
  108. this.getServiceItem();    
  109. }
  110. });
  111. },
  112. zwkf: function() {
  113. top.layer.msg('此功能暂未开放', {
  114. icon: 1
  115. });
  116. },
  117. jkjy: function(patient, planId) {
  118. var vm = this
  119. top.layer.open({
  120. type: 2,
  121. // offset: ['100px'], //右下角弹出
  122. area: ['80%', '648px'],
  123. shade: 0.5,
  124. title: '健康教育',
  125. fixed: true, //不固定
  126. maxmin: true,
  127. closeBtn: 1,
  128. shift: 5,
  129. shadeClose: false, //点击遮罩关闭层
  130. content: '../../article/html/article.html?code=' + patient + '&planId=' + planId + '&isReha=true'
  131. });
  132. },
  133. // 健康指导
  134. jkzd: function(planId,patient) {
  135. var vm = this
  136. top.layer.open({
  137. type: 2,
  138. // offset: ['100px'], //右下角弹出
  139. area: ['80%', '648px'],
  140. shade: 0.5,
  141. title: '健康教育',
  142. fixed: true, //不固定
  143. maxmin: true,
  144. closeBtn: 1,
  145. shift: 5,
  146. shadeClose: false, //点击遮罩关闭层
  147. content: '../../guidance/html/index.html#/person-edit-panel?patient=' + patient + '&planId=' + planId
  148. });
  149. },
  150. qwapp: function() {
  151. top.layer.msg('请前往app处理', {
  152. icon: 5
  153. });
  154. },
  155. viewGuidance: function(o){
  156. var vm = this
  157. previewLayerIndex = layer.open({
  158. type: 2,
  159. area: ['380px', '600px'],
  160. shade: 0.5,
  161. title: '预览',
  162. fixed: true, //不固定
  163. maxmin: true,
  164. closeBtn:1,
  165. shift: 5,
  166. shadeClose: false, //点击遮罩关闭层
  167. content: '../../rehabilitation/html/rehabilitation_guidance_preview.html?modelCode='+o.article
  168. });
  169. },
  170. getServiceItem: function() {
  171. var vm = this;
  172. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  173. var loadding = top.layer.load(0, {
  174. shade: false
  175. }); //0代表加载的风格,支持0-2
  176. rehaAPI.serviceItem({
  177. planDetailId: vm.planid
  178. }).then(function(res) {
  179. top.layer.close(loadding);
  180. if(res.status == 200) {
  181. vm.service = res.data;
  182. var isZK=loginDoctor.doctorType==1?true:false;
  183. vm.service.isZK=isZK;
  184. if(vm.service.isMyTask==1){//执行者
  185. vm.service.isCK=true;//无法显示按钮
  186. if(loginDoctor.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  187. vm.service.isCK=false;
  188. vm.service.isCreate=true;
  189. }
  190. }else{
  191. if(loginDoctor.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  192. vm.service.isCreate=true;
  193. }
  194. }
  195. if(vm.service.type == 4 || vm.service.type == 5 || vm.service.type == 7){
  196. vm.getRelationRecord(vm.service.type, vm.planid).then(function(result){
  197. if(result.status == 200){
  198. vm.service.relationList = result.data&&result.data.length>0?result.data:undefined
  199. vm.$forceUpdate()
  200. }
  201. })
  202. }
  203. } else {
  204. top.layer.msg(res.msg, {
  205. icon: 5
  206. });
  207. }
  208. if(vm.service.status==1){
  209. var index = top.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  210. top.layer.title('服务记录详情', index) //再改变当前层的标题
  211. }
  212. })
  213. },
  214. getRelationRecord: function(type, planDetaiId){
  215. // 1.电话短信 2.康复咨询 3.远程监控检测 4.上门服务 5.康复指导 6 康复随访 7.复诊)
  216. var vm = this
  217. var url=''
  218. if(type==5){
  219. url='doctor/specialist/rehabilitation/selectByRelationCode'
  220. }else if(type==7){
  221. url='third/guahao/selectByRelationCode'
  222. }else if(type==4){
  223. url="/doctor/specialist/rehabilitation/selectRelationCode"
  224. }
  225. var vm = this
  226. var params = {
  227. relationCode: planDetaiId
  228. }
  229. return httpRequest.get(url, {data: params})
  230. },
  231. zdly: function(data) {
  232. var vm = this
  233. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  234. var otherCode, otherName;
  235. var planDetailId = data.planDetaiId;
  236. if(loginDoctor.doctorType == 1) {
  237. otherCode = data.familyDoctorCode;
  238. otherName = data.familyDoctorName;
  239. } else {
  240. otherCode = data.specialistDoctorCode;
  241. otherName = data.specialistDoctorName;
  242. }
  243. top.layer.open({
  244. type: 2,
  245. // offset: ['100px'], //右下角弹出
  246. area: ['80%', '600px'],
  247. shade: 0.5,
  248. title: '指导留言',
  249. fixed: true, //不固定
  250. maxmin: true,
  251. closeBtn: 1,
  252. shift: 5,
  253. shadeClose: false, //点击遮罩关闭层
  254. content: '../../consulting/html/consulting.html?otherCode=' + otherCode + '&otherName=' + encodeURI(otherName) + '&planDetailId=' + planDetailId,
  255. end: function() { // 未点击确定按钮,点击关闭按钮
  256.       
  257. vm.getServiceItem();    
  258. }
  259. });
  260. },
  261. deleteImg: function(idx) {
  262. console.log(idx)
  263. this.upImgs.splice(idx, 1)
  264. },
  265. chakan: function() {
  266. this.isCollapse = !this.isCollapse;
  267. },
  268. upLoadImgToBase64: function() {
  269. var vm = this;
  270. var img1 = event.target.files[0];
  271. var reader = new FileReader();
  272. var type = img1.type; //文件的类型,判断是否是图片
  273. var size = img1.size; //文件的大小,判断图片的大小
  274. if(this.imgData.accept.indexOf(type) == -1) {
  275. alert('请选择我们支持的图片格式!');
  276. return false;
  277. }
  278. if(size > 3145728) {
  279. alert('请选择3M以内的图片!');
  280. return false;
  281. }
  282. reader.readAsDataURL(img1);
  283. reader.onload = function(e) {
  284. vm.upImgs.push({
  285. baseUrl: e.target.result
  286. });
  287. vm.upImgArr.push(img1);
  288. console.log('e', e, 'vm.upImgs', vm.upImgs, 'vm.upImgArr', vm.upImgArr)
  289. // vm.uploadImg(vm.upImgArr);
  290. }
  291. },
  292. qrwc: function(patient,type) {
  293. var vm = this;
  294. vm.saveRehabilitationOperateRecord(vm.planid,type);
  295. },
  296. saveRehabilitationOperateRecord:function(planDetailId,type){
  297. var vm=this, _type;
  298. if(type==1){
  299. _type = 8 // 上传附件
  300. } else {
  301. _type = type
  302. }
  303. var params={
  304. rehabilitationDetailId: vm.planid,
  305. node: null,
  306. patientCode: vm.patient,
  307. doctorCode: docInfo.code,
  308. relationRecordType: _type,
  309. relationRecordCode: '',
  310. relationRecordImg: null,
  311. status: 0
  312. }
  313. rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){
  314. if(res.status==200){
  315. if(type==1){
  316. vm.uploadImg(vm.upImgArr);
  317. } else {
  318. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  319. }
  320. } else {
  321. layer.msg(res.msg, {
  322. icon: 5
  323. });
  324. }
  325. })
  326. },
  327. //上传图片
  328. uploadImg: function(data) {
  329. var vm = this;
  330. var len = data.length;
  331. if(len==0) {
  332. vm.updateNoteAndImageRehabilitationOperate(vm.planid)
  333. } else {
  334. var file = data[len - 1];
  335. var formData = new FormData();
  336. formData.append('file', file);
  337. rehaAPI.upload(formData).then(function(res) {
  338. if(res.status == 200) {
  339. vm.upImgs[len - 1].img = res.data;
  340. data.pop();
  341. vm.$forceUpdate()
  342. vm.uploadImg(data);
  343. } else {
  344. layer.msg(res.msg, {
  345. icon: 5
  346. });
  347. }
  348. })
  349. }
  350. },
  351. updateNoteAndImageRehabilitationOperate: function(planDetailId, relationCode) {
  352. var vm = this;
  353. var _image = [];
  354. $.each(vm.upImgs, function(index, obj){
  355. _image.push(obj.img);
  356. })
  357. var params = {
  358. planDetailId: planDetailId,
  359. node: vm.service&&vm.service.node?vm.service.node:null,
  360. image:JSON.stringify(_image)||''
  361. }
  362. if(relationCode){
  363. params['relationCode'] = relationCode
  364. }
  365. var loadding = top.layer.load(0, {
  366. shade: false
  367. }); //0代表加载的风格,支持0-2
  368. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) {
  369. top.layer.close(loadding);
  370. if(res.status == 200) {
  371. vm.getServiceItem();
  372. top.rehabilitationVue.refresh()
  373. }
  374. })
  375. },
  376. viewDetial:function(type,code){
  377. var vm=this;
  378. if(type == 3) {
  379. top.layer.msg('客户端暂不支持查询健康指导记录');
  380. } else if(type==4){
  381. top.layer.msg('客户端暂不支持查询随访记录');
  382. }else{
  383. top.layer.open({
  384. type: 2,
  385. // offset: ['100px'], //右下角弹出
  386. area: ['80%', '600px'],
  387. shade: 0.5,
  388. title: '指导教育',
  389. fixed: true, //不固定
  390. maxmin: true,
  391. closeBtn: 1,
  392. shift: 5,
  393. shadeClose: false, //点击遮罩关闭层
  394. content: '../../article/html/article-info.html?articleId=' + code,
  395. end: function() { // 未点击确定按钮,点击关闭按钮
  396. vm.getServiceItem();    
  397. }
  398. });
  399. }
  400. },
  401. getContent: function(value,type) {
  402. var res=value;
  403. if(type==2 || type==9){
  404. res = "<img src='"+httpRequest.getImgUrl(res)+"'>";
  405. }else if(type==3){
  406. res = '【语音】';
  407. }else if(type==19){
  408. res = '【聊天记录】';
  409. }else if(type==12){
  410. res = '【视频】';
  411. }
  412. return res;
  413. }
  414. },
  415. filters: {
  416. formatDate: function(value, format) {
  417. if(!value) return;
  418. var fmt = format || "yyyy-MM-dd hh:mm";
  419. var date = new Date(value);
  420. if(/(y+)/.test(fmt)) {
  421. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  422. }
  423. let o = {
  424. 'M+': date.getMonth() + 1,
  425. 'd+': date.getDate(),
  426. 'h+': date.getHours(),
  427. 'm+': date.getMinutes(),
  428. 's+': date.getSeconds()
  429. };
  430. for(let k in o) {
  431. if(new RegExp(`(${k})`).test(fmt)) {
  432. let str = o[k] + '';
  433. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
  434. }
  435. }
  436. return fmt;
  437. },
  438. getImgUrl: function(value) {
  439. var url = httpRequest.getImgUrl(value);
  440. return url;
  441. }
  442. }
  443. })
  444. $("body").on('click','img',function(){
  445. var _this = $(this);//将当前的img元素作为_this传入函数
  446. imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  447. });
  448. function imgShow(outerdiv, innerdiv, bigimg, _this){
  449. var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  450. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  451. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  452. $("<img/>").attr("src", src).load(function(){
  453. var windowW = $(window).width();//获取当前窗口宽度
  454. var windowH = $(window).height();//获取当前窗口高度
  455. var realWidth = this.width;//获取图片真实宽度
  456. var realHeight = this.height;//获取图片真实高度
  457. var imgWidth, imgHeight;
  458. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  459. if(realHeight>windowH*scale) {//判断图片高度
  460. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  461. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  462. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  463. imgWidth = windowW*scale;//再对宽度进行缩放
  464. }
  465. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  466. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  467. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  468. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  469. imgWidth = realWidth;
  470. imgHeight = realHeight;
  471. }
  472. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  473. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  474. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  475. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  476. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  477. });
  478. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  479. $(this).fadeOut("fast");
  480. });
  481. }