guide_the_message.js 15 KB

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