guide_the_message.js 15 KB

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