guide_the_message.js 15 KB

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