guide_the_message.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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. var params = {
  176. planDetailId: vm.planid,
  177. }
  178. if(vm.recordId){
  179. params['recordId'] = vm.recordId
  180. }
  181. rehaAPI.serviceItem(params).then(function(res) {
  182. top.layer.close(loadding);
  183. if(res.status == 200) {
  184. vm.service = res.data;
  185. var isZK=loginDoctor.doctorType==1?true:false;
  186. vm.service.isZK=isZK;
  187. if(vm.service.completeTime){
  188. var l = vm.service.completeTime.length
  189. vm.service.shortCompleteTime = vm.service.completeTime.substr(l-5, l-1)
  190. }
  191. if(vm.service.isMyTask==1){//执行者
  192. vm.service.isCK=true;//无法显示按钮
  193. if(loginDoctor.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  194. vm.service.isCK=false;
  195. vm.service.isCreate=true;
  196. }
  197. }else{
  198. if(loginDoctor.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  199. vm.service.isCreate=true;
  200. }
  201. }
  202. if(vm.service.type == 4 || vm.service.type == 5 || vm.service.type == 7){
  203. vm.getRelationRecord(vm.service.type, vm.planid).then(function(result){
  204. if(result.status == 200){
  205. vm.service.relationList = result.data&&result.data.length>0?result.data:undefined
  206. vm.$forceUpdate()
  207. }
  208. })
  209. }
  210. if(vm.service.frequencyCode){
  211. vm.islimit = true
  212. } else {
  213. vm.islimit = false
  214. }
  215. } else {
  216. top.layer.msg(res.msg, {
  217. icon: 5
  218. });
  219. }
  220. if(vm.service.status==1){
  221. var index = top.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  222. top.layer.title('服务记录详情', index) //再改变当前层的标题
  223. }
  224. })
  225. },
  226. getRelationRecord: function(type, planDetaiId){
  227. // 1.电话短信 2.康复咨询 3.远程监控检测 4.上门服务 5.康复指导 6 康复随访 7.复诊)
  228. var vm = this
  229. var url=''
  230. if(type==5){
  231. url='doctor/specialist/rehabilitation/selectByRelationCode'
  232. }else if(type==7){
  233. url='third/guahao/selectByRelationCode'
  234. }else if(type==4){
  235. url="/doctor/specialist/rehabilitation/selectRelationCode"
  236. }
  237. var vm = this
  238. var params = {
  239. relationCode: planDetaiId
  240. }
  241. return httpRequest.get(url, {data: params})
  242. },
  243. zdly: function(data) {
  244. var vm = this
  245. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  246. var otherCode, otherName;
  247. var planDetailId = data.planDetaiId;
  248. if(loginDoctor.doctorType == 1) {
  249. otherCode = data.familyDoctorCode;
  250. otherName = data.familyDoctorName;
  251. } else {
  252. otherCode = data.specialistDoctorCode;
  253. otherName = data.specialistDoctorName;
  254. }
  255. top.layer.open({
  256. type: 2,
  257. // offset: ['100px'], //右下角弹出
  258. area: ['660px', '600px'],
  259. shade: 0.5,
  260. title: '指导留言',
  261. fixed: true, //不固定
  262. maxmin: true,
  263. closeBtn: 1,
  264. shift: 5,
  265. shadeClose: false, //点击遮罩关闭层
  266. content: '../../consulting/html/consulting.html?otherCode=' + otherCode + '&otherName=' + encodeURI(otherName) + '&planDetailId=' + vm.planid,
  267. end: function() { // 未点击确定按钮,点击关闭按钮
  268.       
  269. vm.getServiceItem();    
  270. }
  271. });
  272. },
  273. deleteImg: function(idx) {
  274. console.log(idx)
  275. this.upImgs.splice(idx, 1)
  276. },
  277. chakan: function() {
  278. this.isCollapse = !this.isCollapse;
  279. },
  280. upLoadImgToBase64: function() {
  281. var vm = this;
  282. var img1 = event.target.files[0];
  283. var reader = new FileReader();
  284. var type = img1.type; //文件的类型,判断是否是图片
  285. var size = img1.size; //文件的大小,判断图片的大小
  286. if(this.imgData.accept.indexOf(type) == -1) {
  287. alert('请选择我们支持的图片格式!');
  288. return false;
  289. }
  290. if(size > 3145728) {
  291. alert('请选择3M以内的图片!');
  292. return false;
  293. }
  294. reader.readAsDataURL(img1);
  295. reader.onload = function(e) {
  296. vm.upImgs.push({
  297. baseUrl: e.target.result
  298. });
  299. vm.upImgArr.push(img1);
  300. console.log('e', e, 'vm.upImgs', vm.upImgs, 'vm.upImgArr', vm.upImgArr)
  301. // vm.uploadImg(vm.upImgArr);
  302. }
  303. },
  304. qrwc: function(patient,type) {
  305. var vm = this;
  306. vm.saveRehabilitationOperateRecord(vm.planid,type);
  307. },
  308. saveRehabilitationOperateRecord:function(planDetailId, type, relationCode){
  309. var vm=this;
  310. var params={
  311. rehabilitationDetailId: planDetailId,
  312. node: null,
  313. patientCode: vm.patient,
  314. doctorCode: docInfo.uid,
  315. relationRecordType: type,
  316. relationRecordCode: '',
  317. relationRecordImg: null,
  318. status: 0
  319. }
  320. rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){
  321. if(res.status==200){
  322. if(type==1){
  323. vm.uploadImg(vm.upImgArr);
  324. }else if(type==6){
  325. vm.updateRelationCodeByDetailId(planDetailId, relationCode)
  326. } else {
  327. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  328. }
  329. } else {
  330. layer.msg(res.msg, {
  331. icon: 5
  332. });
  333. }
  334. })
  335. },
  336. //上传图片
  337. uploadImg: function(data) {
  338. var vm = this;
  339. var len = data.length;
  340. if(len==0) {
  341. vm.updateNoteAndImageRehabilitationOperate(vm.planid)
  342. } else {
  343. var file = data[len - 1];
  344. var formData = new FormData();
  345. formData.append('file', file);
  346. rehaAPI.upload(formData).then(function(res) {
  347. if(res.status == 200) {
  348. vm.upImgs[len - 1].img = res.data;
  349. data.pop();
  350. vm.$forceUpdate()
  351. vm.uploadImg(data);
  352. } else {
  353. layer.msg(res.msg, {
  354. icon: 5
  355. });
  356. }
  357. })
  358. }
  359. },
  360. updateNoteAndImageRehabilitationOperate: function(planDetailId, relationCode) {
  361. var vm = this;
  362. var _image = [];
  363. $.each(vm.upImgs, function(index, obj){
  364. _image.push(obj.img);
  365. })
  366. var params = {
  367. planDetailId: planDetailId,
  368. node: vm.service&&vm.service.node?vm.service.node:null,
  369. image:JSON.stringify(_image)||''
  370. }
  371. if(relationCode){
  372. params['relationCode'] = relationCode
  373. }
  374. var loadding = top.layer.load(0, {
  375. shade: false
  376. }); //0代表加载的风格,支持0-2
  377. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) {
  378. top.layer.close(loadding);
  379. if(res.status == 200) {
  380. vm.getServiceItem();
  381. top.rehabilitationVue.refresh()
  382. }
  383. })
  384. },
  385. updateRelationCodeByDetailId: function(planDetailId, relationCode){
  386. var vm = this
  387. var params = {
  388. planDetailId: planDetailId,
  389. relationCode: relationCode,
  390. }
  391. rehaAPI.updateRelationCodeByDetailId(params).then(function(res) {
  392. if(res.status == 200) {
  393. vm.getServiceItem();
  394. top.rehabilitationVue.refresh()
  395. } else {
  396. showErrorMessage(res.msg)
  397. }
  398. })
  399. },
  400. viewDetial:function(type,code){
  401. var vm=this;
  402. if(type == 3) {
  403. top.layer.msg('客户端暂不支持查询健康指导记录');
  404. } else if(type==4){
  405. top.layer.msg('客户端暂不支持查询随访记录');
  406. }else{
  407. top.layer.open({
  408. type: 2,
  409. // offset: ['100px'], //右下角弹出
  410. area: ['80%', '600px'],
  411. shade: 0.5,
  412. title: '指导教育',
  413. fixed: true, //不固定
  414. maxmin: true,
  415. closeBtn: 1,
  416. shift: 5,
  417. shadeClose: false, //点击遮罩关闭层
  418. content: '../../article/html/article-info.html?articleId=' + code,
  419. end: function() { // 未点击确定按钮,点击关闭按钮
  420. vm.getServiceItem();    
  421. }
  422. });
  423. }
  424. },
  425. getContent: function(value,type) {
  426. var res=value;
  427. if(type==2 || type==9){
  428. res = "<img src='"+httpRequest.getImgUrl(res)+"'>";
  429. }else if(type==3){
  430. res = '【语音】';
  431. }else if(type==19){
  432. res = '【聊天记录】';
  433. }else if(type==12){
  434. res = '【视频】';
  435. }
  436. return res;
  437. }
  438. },
  439. filters: {
  440. formatDate: function(value, format) {
  441. if(!value) return;
  442. var fmt = format || "yyyy-MM-dd hh:mm";
  443. var date = new Date(value);
  444. if(/(y+)/.test(fmt)) {
  445. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  446. }
  447. let o = {
  448. 'M+': date.getMonth() + 1,
  449. 'd+': date.getDate(),
  450. 'h+': date.getHours(),
  451. 'm+': date.getMinutes(),
  452. 's+': date.getSeconds()
  453. };
  454. for(let k in o) {
  455. if(new RegExp(`(${k})`).test(fmt)) {
  456. let str = o[k] + '';
  457. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
  458. }
  459. }
  460. return fmt;
  461. },
  462. getImgUrl: function(value) {
  463. var url = httpRequest.getImgUrl(value);
  464. return url;
  465. }
  466. }
  467. })
  468. $("body").on('click','img',function(){
  469. var _this = $(this);//将当前的img元素作为_this传入函数
  470. imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  471. });
  472. function imgShow(outerdiv, innerdiv, bigimg, _this){
  473. var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  474. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  475. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  476. $("<img/>").attr("src", src).load(function(){
  477. var windowW = $(window).width();//获取当前窗口宽度
  478. var windowH = $(window).height();//获取当前窗口高度
  479. var realWidth = this.width;//获取图片真实宽度
  480. var realHeight = this.height;//获取图片真实高度
  481. var imgWidth, imgHeight;
  482. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  483. if(realHeight>windowH*scale) {//判断图片高度
  484. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  485. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  486. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  487. imgWidth = windowW*scale;//再对宽度进行缩放
  488. }
  489. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  490. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  491. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  492. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  493. imgWidth = realWidth;
  494. imgHeight = realHeight;
  495. }
  496. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  497. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  498. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  499. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  500. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  501. });
  502. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  503. $(this).fadeOut("fast");
  504. });
  505. }