guide_the_message.js 15 KB

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