service_item_content.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. !function(){
  2. var httpData=GetRequest();
  3. var userInfo = JSON.parse(window.localStorage.getItem(httpRequest.agentName));
  4. new Vue({
  5. el:"#app",
  6. data:{
  7. planids:httpData['planids'],
  8. serviceData:[
  9. {
  10. relationRecordImg:{},
  11. messageList:{}
  12. }
  13. ],
  14. isCollapse :false,
  15. collapseIndex:0,
  16. qrCode:'',
  17. qrModal:false,
  18. },
  19. mounted:function(){
  20. this.getServiceItemList();
  21. },
  22. methods:{
  23. viewDetial:function(type,code){
  24. var vm=this;
  25. if(type==3||type==4){
  26. top.layer.msg('客户端暂不支持查询随访记录');
  27. }else{
  28. top.layer.open({
  29. type: 2,
  30. // offset: ['100px'], //右下角弹出
  31. area: ['80%', '600px'],
  32. shade: 0.5,
  33. title: '指导教育',
  34. fixed: true, //不固定
  35. maxmin: true,
  36. closeBtn: 1,
  37. shift: 5,
  38. shadeClose: false, //点击遮罩关闭层
  39. content: '../../article/html/article-info.html?articleId=' + code,
  40. end: function() { // 未点击确定按钮,点击关闭按钮
  41. vm.getServiceItem();    
  42. }
  43. });
  44. }
  45. },
  46. chakan:function(){
  47. this.isCollapse=!this.isCollapse;
  48. },
  49. changeCollapseIndex:function(idx){
  50. this.collapseIndex=idx;
  51. },
  52. qwapp:function(){
  53. layer.msg('请前往app处理',{icon:5});
  54. },
  55. //获取服务列表
  56. getServiceItemList:function(){
  57. var vm=this;
  58. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent') || '{}');
  59. var loadding = layer.load(0, {shade: false}); //0代表加载的风格,支持0-2
  60. rehaAPI.serviceItemList({planDetailIds:vm.planids}).then(function(res){
  61. layer.close(loadding);
  62. if(res.status==200){
  63. var isZK=loginDoctor.doctorType==1?true:false;
  64. vm.serviceData=_.map(res.data||{},function(o){
  65. o.isZK=isZK;
  66. if(o.isMyTask==1){//执行者
  67. o.isCK=true;//无法显示按钮
  68. if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者
  69. o.isCK=false;
  70. o.isCreate=true;
  71. }
  72. }else{
  73. if(loginDoctor.uid==o.specialistDoctorCode){//说明我自己是创建者
  74. o.isCreate=true;
  75. }
  76. }
  77. console.log(o)
  78. return o
  79. })
  80. }else{
  81. layer.msg(res.msg,{icon:5});
  82. }
  83. })
  84. },
  85. //健康教育
  86. jkjy:function(patient,planId){
  87. var vm=this
  88. layer.open({
  89. type: 2,
  90. area: ['88%', '600px'],
  91. shade: 0.5,
  92. title: '健康教育',
  93. fixed: true, //不固定
  94. maxmin: true,
  95. closeBtn: 1,
  96. shift: 5,
  97. shadeClose: false, //点击遮罩关闭层
  98. content: '../../article/html/article.html?code='+patient+'&planId='+planId+'&isReha=true',
  99. end: function() { // 未点击确定按钮,点击关闭按钮
  100. vm.getServiceItemList();    
  101. }
  102. });
  103. },
  104. // 健康指导
  105. jkzd:function(planId,patient){
  106. var vm=this
  107. layer.open({
  108. type: 2,
  109. // offset: ['100px'], //右下角弹出
  110. area: ['80%', '600px'],
  111. shade: 0.5,
  112. title: '健康指导',
  113. fixed: true, //不固定
  114. maxmin: true,
  115. closeBtn: 1,
  116. shift: 5,
  117. shadeClose: false, //点击遮罩关闭层
  118. content:'../../guidance/html/index.html#/person-edit-panel?patient='+patient+'&planId='+planId,
  119. end: function() { // 未点击确定按钮,点击关闭按钮
  120. vm.getServiceItemList();    
  121. }
  122. });
  123. },
  124. // 暂未开放
  125. zwkf:function(){
  126. layer.msg('此功能暂未开放',{icon:1});
  127. },
  128. goToFinish:function(planid){
  129. var vm=this;
  130. layer.open({
  131. type: 2,
  132. // offset: ['100px'], //右下角弹出
  133. area: ['80%', '600px'],
  134. shade: 0.5,
  135. title: '完成项目确认',
  136. fixed: true, //不固定
  137. maxmin: true,
  138. closeBtn:1,
  139. shift: 5,
  140. shadeClose: false, //点击遮罩关闭层
  141. content: '../../rehabilitation/html/guide_the_message.html?planid='+planid,
  142. end: function() { // 未点击确定按钮,点击关闭按钮
  143. vm.getServiceItemList();    
  144. }
  145. });
  146. },
  147. fwm:function(planid,patient){
  148. this.loadSocket(planid,patient);
  149. },
  150. zdly:function(data){
  151. var vm = this
  152. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  153. var otherCode,otherName;
  154. var planDetailId='';
  155. if(data.specialistDoctorCode==data.executeDoctorCode){
  156. layer.msg('无法与自己聊天',{icon:5});
  157. return ;
  158. }
  159. if(data.isMyTask==1){
  160. otherCode=data.specialistDoctorCode;
  161. otherName=data.specialistDoctorName;
  162. }else{
  163. planDetailId=data.planDetaiId;
  164. otherCode=data.executeDoctorCode;
  165. otherName=data.executeDoctorCode;
  166. }
  167. layer.open({
  168. type: 2,
  169. // offset: ['100px'], //右下角弹出
  170. area: ['80%', '600px'],
  171. shade: 0.5,
  172. title: '指导留言',
  173. fixed: true, //不固定
  174. maxmin: true,
  175. closeBtn:1,
  176. shift: 5,
  177. shadeClose: false, //点击遮罩关闭层
  178. content: '../../consulting/html/consulting.html?otherCode='+otherCode+'&otherName='+encodeURI(otherName)+'&planDetailId='+planDetailId,
  179. end:function(){ // 未点击确定按钮,点击关闭按钮
  180.       vm.getServiceItemList();
  181.     }
  182. });
  183. },
  184. loadSocket:function(planid,patient){
  185. var vm=this;
  186. var imurl=httpRequest.socketUrl;
  187. jQuery.getScript(imurl+"/socket.io/socket.io.js").done(function() {
  188. var socket = io.connect(imurl);
  189. var sessionId = 'system';
  190. socket.emit('login', {userId: userInfo.uid, password: userInfo.uid,sessionId:sessionId,clientType:"doctor"});
  191. socket.on('message', function (data) {
  192. console.log(data);
  193. if(data.type==1){
  194. vm.goToFinish(planid);
  195. }
  196. });
  197. socket.on('error', function (data) {
  198. console.log(data);
  199. });
  200. socket.on('ack', function (data) {
  201. console.log(data);
  202. vm.getQRCode(planid);
  203. });
  204. function getLocalTime(nS) {
  205. return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
  206. }
  207. })
  208. .fail(function() {
  209. layer.msg('服务码创建失败',{icon:5});
  210. });
  211. },
  212. getQRCode:function(planid){
  213. var vm=this;
  214. var loginDoctor = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  215. var params={
  216. planDetailId:planid,
  217. doctorCode: loginDoctor.uid
  218. }
  219. rehaAPI.createServiceQrCode(params).then(function(res){
  220. console.log(res);
  221. if(res.status==200){
  222. vm.qrCode=res.data;
  223. setTimeout(function(){
  224. vm.qrModal=true;
  225. },100)
  226. }else{
  227. layer.msg('服务码获取失败',{icon:5});
  228. }
  229. })
  230. }
  231. },
  232. filters:{
  233. formatDate:function(value, format) {
  234. if(!value) return ;
  235. var fmt=format || "yyyy-MM-dd hh:mm";
  236. var date = new Date(value);
  237. if (/(y+)/.test(fmt)) {
  238. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  239. }
  240. let o = {
  241. 'M+': date.getMonth() + 1,
  242. 'd+': date.getDate(),
  243. 'h+': date.getHours(),
  244. 'm+': date.getMinutes(),
  245. 's+': date.getSeconds()
  246. };
  247. for (let k in o) {
  248. if (new RegExp(`(${k})`).test(fmt)) {
  249. let str = o[k] + '';
  250. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
  251. }
  252. }
  253. return fmt;
  254. },
  255. getImgUrl: function(value) {
  256. var url = httpRequest.getImgUrl(value);
  257. return url;
  258. }
  259. }
  260. })
  261. $("body").on('click','img',function(){
  262. var _this = $(this);//将当前的img元素作为_this传入函数
  263. imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
  264. });
  265. function imgShow(outerdiv, innerdiv, bigimg, _this){
  266. var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  267. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  268. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  269. $("<img/>").attr("src", src).load(function(){
  270. var windowW = $(window).width();//获取当前窗口宽度
  271. var windowH = $(window).height();//获取当前窗口高度
  272. var realWidth = this.width;//获取图片真实宽度
  273. var realHeight = this.height;//获取图片真实高度
  274. var imgWidth, imgHeight;
  275. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  276. if(realHeight>windowH*scale) {//判断图片高度
  277. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  278. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  279. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  280. imgWidth = windowW*scale;//再对宽度进行缩放
  281. }
  282. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  283. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  284. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  285. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  286. imgWidth = realWidth;
  287. imgHeight = realHeight;
  288. }
  289. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  290. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  291. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  292. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  293. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  294. });
  295. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  296. $(this).fadeOut("fast");
  297. });
  298. }
  299. }();