server-items-detail.js 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. var currentGMT=new Date();//当前时间GMT
  2. function showSuccessMessage(msg) {
  3. layer.msg(msg, {
  4. icon: 1
  5. })
  6. }
  7. function showSuccessMessage(msg) {
  8. layer.msg(msg, {
  9. icon: 1
  10. })
  11. }
  12. function showErrorMessage(msg) {
  13. layer.msg(msg, {
  14. icon: 5
  15. })
  16. }
  17. function showWarningMessage(msg) {
  18. layer.msg(msg, {
  19. icon: 2
  20. })
  21. }
  22. function showInfoMessage(msg) {
  23. layer.msg(msg, {
  24. icon: 6
  25. })
  26. }
  27. var previewLayerIndex, followupLayerIndex, KFZDlayerIndex;
  28. function closeFollowUpLayer(planDetaiId, relationCode, flag){
  29. _vm.closeAllLayer('创建随访计划', planDetaiId, 6, relationCode, flag)
  30. }
  31. function closeKFZDlayer(planDetaiId){
  32. _vm.closeAllLayer('发送康复指导', planDetaiId, 5)
  33. }
  34. var _vm
  35. Vue.component('server-items-detail', {
  36. template: '<div class="p15 ui-grid ui-grid-vertical" style="height:calc(100%);position: relative;">\
  37. <div class="icon-group">\
  38. <i class="icon-edit el-icon-edit-outline mr15" @click="goToEditConfig"></i>\
  39. <i class="icon-close el-icon-close" @click="onClose"></i>\
  40. </div>\
  41. <div class="c-t-center c-f18 c-333 mt15">服务内容-{{service.title}}</div>\
  42. <div class="c-t-center c-f17 c-666 mt10">{{patientname}}患者{{service.title}}计划</div>\
  43. <div class="c-333 ptb10 c-f17 mt10">指导留言</div>\
  44. <div @click="zdly(service)">\
  45. <div class="c-f14 c-666" v-if="!message.isImg" >{{message.content}}</div>\
  46. <div class="mt10" v-else><img :src="message.content" @click.stop="previewImg(message.content)" style="width:60px;height:60px;" :data-preview-src="message.content" data-preview-group="1"/></div>\
  47. </div>\
  48. <div v-if="islimit" class="mtb10 ui-grid">\
  49. <div class="ui-col-1">\
  50. <i class="icon icon-prev icon-20" @click="preMonth"></i>\
  51. <span class="currentDay">{{currentDay}}</span>\
  52. <i class="icon icon-next icon-20" @click="nextMonth"></i></span>\
  53. </div>\
  54. <div class="pull-right switch-list" style="text-align:center">\
  55. <span class="rili" :class="{active:(tabStatus==1)}" @click="tabStatus=1"><i class="icon icon-rili icon-20"></i></span>\
  56. <span class="shijianzhou" :class="{active:(tabStatus==2)}" @click="tabStatus=2"><i class="icon icon-liebiao icon-20"></i></span>\
  57. </div>\
  58. </div>\
  59. <div v-if="islimit&&tabStatus==1" class="ui-col-1" style="overflow: hidden; overflow-y: scroll;">\
  60. <div class="calendar-week">\
  61. <div class="flex-box text-center">\
  62. <div class="flex-box-item">周一</div>\
  63. <div class="flex-box-item">周二</div>\
  64. <div class="flex-box-item">周三</div>\
  65. <div class="flex-box-item">周四</div>\
  66. <div class="flex-box-item">周五</div>\
  67. <div class="flex-box-item">周六</div>\
  68. <div class="flex-box-item">周日</div>\
  69. </div>\
  70. </div>\
  71. <div class="calendar-days">\
  72. <div v-for="items in calendarData" class="flex-box">\
  73. <div class="calendar-day" v-for="item in items" @click="viewDetail(item.planDetailIds)" :is-future="item.future">\
  74. <span class="day-number">{{item.day}}</span>\
  75. <div class="task-icon">\
  76. <i v-if="item.myTaskFlag" class="icon icon-flag icon-20"></i>\
  77. <i v-if="item.finishFlag" class="icon icon-check"></i>\
  78. </div>\
  79. <div class="coloured-box">\
  80. <span v-if="item.specialist" class="coloured-ribbon coloured-ribbon-blue">专<br />科</span>\
  81. <span v-if="item.family" class="coloured-ribbon coloured-ribbon-green">家<br />医</span>\
  82. </div>\
  83. <div class="progress-box">\
  84. <div class="progress" :style="{opacity:item.specialist?\'1\':\'0\'}">\
  85. <span>{{(item.specialist && item.specialist.finish)}}/{{(item.specialist && item.specialist.all)}}</span>\
  86. <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" :style="{width: (item.specialist?(item.specialist.finish/item.specialist.all):0)*100+\'%\'}"></div>\
  87. </div>\
  88. <div class="progress" :style="{opacity:item.family?\'1\':\'0\'}">\
  89. <span>{{(item.family && item.family.finish)}}/{{(item.family && item.family.all)}}</span>\
  90. <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" :style="{width: (item.family?(item.family.finish/item.family.all):0)*100+\'%\'}"></div>\
  91. </div>\
  92. <p v-if="!item.noService" class="mb0 f12" :class="{\'visibility-hide\':!curTask}" style="line-height: 1;">{{curTaskName || \'&emsp;\'}}</p>\
  93. </div>\
  94. <p v-if="item.noService" class="no-server">无服务项</p>\
  95. </div>\
  96. </div>\
  97. </div>\
  98. </div>\
  99. <div v-show="tabStatus==2" class="ui-col-1 mt10" style="overflow-y: auto">\
  100. <div class="time-axis">\
  101. <div>\
  102. <table class="table">\
  103. <tr>\
  104. <th style="padding-right: 50px;text-align: right;">时间</th>\
  105. <th>项目</th>\
  106. <th>执行人员</th>\
  107. <th>执行地点</th>\
  108. <th class="text-center">相关记录</th>\
  109. <th class="text-center">状态</th>\
  110. </tr>\
  111. <tr v-for="item in timeAxisData" :is-future="item.future">\
  112. <td class="time text-right time-box">\
  113. <p class="mb5">{{item.date}}</p>\
  114. <p class="mb0">{{item.time}}</p>\
  115. <span class="cur-status">{{item.html}}</span>\
  116. </td>\
  117. <td class="project-name mw400">\
  118. <p class="mt10">{{item.name}}</p>\
  119. <p class="ellipsis mb0">{{item.content}}</p>\
  120. </td>\
  121. <td class="executor">{{item.doctorName}}</td>\
  122. <td class="place-of-execution">{{item.hospitalName}}</td>\
  123. <td class="view-task" @click="onViewDetail(item,1)">查看</td>\
  124. <td class="task-status" :class="item.future==-1?\'c-ff3b30\':(item.status==0?\'c-666\':\'\')">{{item.status==0?\'未完成\':(item.status==1?\'已完成\':\'已预约\')}}</td>\
  125. </tr>\
  126. <tr v-if="!timeAxisData.length">\
  127. <td colspan="6" class="f16 ptb10 text-center">\
  128. <img src="../../../images/wushuju_img.png" class="mt50"/>\
  129. <p class="c-666">暂无数据</p>\
  130. </td>\
  131. </tr>\
  132. </table>\
  133. </div>\
  134. </div>\
  135. </div>\
  136. <div v-if="docInfo.doctorType==1" class="c-t-center mt15">\
  137. <button v-if="!islimit&&service.executeDoctorCode!=docInfo.uid" class="btn btn-12b7f5" @click="zdly(service)">指导留言</button>\
  138. </div>\
  139. <div v-else-if="!islimit" class="c-t-center mt15">\
  140. <button v-if="service.isMyTask" class="btn btn-12b7f5" @click="zdly(service)">查看留言</button>\
  141. <button v-if="service.isMyTask&&service.type==\'1\'" class="btn btn-yuyue" @click="addCompleteRecord()">添加完成记录</button>\
  142. <button v-if="service.isMyTask&&service.type==\'4\'" class="btn btn-yuyue" @click="sendSpecialistWeixinMessage(planDetaiId,4)">发送提醒</button>\
  143. <button v-if="service.isMyTask&&service.type==\'5\'" class="btn btn-yuyue" @click="kfzd()">发送康复指导</button>\
  144. <button v-if="service.isMyTask&&service.type==\'6\'" class="btn btn-yuyue" @click="sfjh()">创建随访计划</button>\
  145. <button v-if="service.isMyTask&&service.type==\'7\'" class="btn btn-yuyue" @click="sendSpecialistWeixinMessage(planDetaiId,7)">发送提醒</button>\
  146. <button v-if="service.isMyTask&&service.type==\'7\'" class="btn btn-12b7f5" @click="qwapp">代预约</button>\
  147. </div>\
  148. <div id="completeRecord" style="display: none; padding: 15px 15px 0;">\
  149. <div class="note-info pt10">\
  150. <p class="f14 c-333">服务完成笔记</p>\
  151. <textarea class="form-control" style="resize: none;" rows="4" placeholder="可备注您的服务记录" v-model="node"></textarea>\
  152. </div>\
  153. <div class="note-info ptb10">\
  154. <p class="f14 c-333">相关记录</p>\
  155. <ul class="upload-box">\
  156. <li class="flex-box" v-for="(img,index) in upImgs">\
  157. <div class="upload-img-box">\
  158. <img :src="img.baseUrl" @click="previewImg(img.baseUrl)"/>\
  159. </div>\
  160. <a class="delete-img" @click="deleteImg(index)">&times;</a>\
  161. </li>\
  162. <li class="flex-box" v-if="upImgs.length<5">\
  163. <span class="add-img">+</span>\
  164. <input type="file" @change="upLoadImgToBase64" class="upload-img" />\
  165. </li>\
  166. </ul>\
  167. </div>\
  168. </div>\
  169. </div>',
  170. props: ['patientname','patientcode', 'planid', 'plandetailid'],
  171. data: function() {
  172. return {
  173. ynow: currentGMT.getFullYear(),//年份
  174. mnow: currentGMT.getMonth(),//月份(比实际少一个月---0开始至11)
  175. dnow: currentGMT.getDate(),//当前日
  176. currentDay:null,//带中文格式的当前年月
  177. calendarData:[],//日历数据
  178. timeAxisData: [], //时间轴数据
  179. tabStatus: 1,
  180. title: '',
  181. docInfo: JSON.parse(window.localStorage.getItem('wlyyAgent')),
  182. upImgs: [],
  183. upImgArr: [],
  184. imgData: {
  185. accept: 'image/gif, image/jpeg, image/png, image/jpg',
  186. },
  187. node: '',
  188. layerIndex: undefined,
  189. planDetaiId:'',
  190. service:{
  191. relationRecordImg:{},
  192. messageList:{},
  193. },
  194. message:{isImg:false,content:""},
  195. islimit: false
  196. }
  197. },
  198. watch:{
  199. tabStatus:function(){
  200. if(this.islimit){
  201. this.goToLoadData(true);
  202. }
  203. }
  204. },
  205. mounted: function() {
  206. _vm = this
  207. this.initData()
  208. },
  209. methods: {
  210. initData: function(){
  211. var vm = this
  212. this.planDetaiId = this.plandetailid
  213. this.getServiceItem()
  214. },
  215. getServiceItem: function() {
  216. var vm = this;
  217. var loadding = top.layer.load(0, {
  218. shade: false
  219. }); //0代表加载的风格,支持0-2
  220. rehaAPI.serviceItem({
  221. planDetailId: vm.planDetaiId
  222. }).then(function(res) {
  223. top.layer.close(loadding);
  224. if(res.status == 200) {
  225. vm.service = res.data;
  226. var isZK=vm.docInfo.doctorType==1?true:false;
  227. vm.service.isZK=isZK;
  228. if(vm.service.isMyTask==1){//执行者
  229. vm.service.isCK=true;//无法显示按钮
  230. if(vm.docInfo.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  231. vm.service.isCK=false;
  232. vm.service.isCreate=true;
  233. }
  234. }else{
  235. if(vm.docInfo.uid==vm.service.specialistDoctorCode){//说明我自己是创建者
  236. vm.service.isCreate=true;
  237. }
  238. }
  239. if(vm.service.frequencyCode){
  240. vm.islimit = true
  241. vm.goToLoadData(true)
  242. vm.monDetail()
  243. } else {
  244. vm.islimit = false
  245. vm.tabStatus = 2
  246. vm.selectByPlanDetaiId()
  247. }
  248. vm.selectByGuidance()
  249. vm.$forceUpdate()
  250. } else {
  251. showErrorMessage(res.msg)
  252. }
  253. })
  254. },
  255. // 获取康复计划服务项的指导留言
  256. selectByGuidance: function(){
  257. var vm = this
  258. var params = {
  259. planId: vm.planid,
  260. itemCode: vm.service.type
  261. }
  262. rehaAPI.selectByGuidance(params).then(function(res){
  263. if(res.status==200){
  264. var messageIndex = _.findIndex(res.data, {doctor_type: 1});
  265. if(messageIndex>-1){
  266. var message = res.data[messageIndex]
  267. var contentType = message.content_type
  268. if(contentType==2||contentType==9){
  269. vm.message.isImg = true
  270. }
  271. vm.message.content = vm.getContent(message.content,message.content_type)
  272. }else{
  273. vm.message.content = "无"
  274. }
  275. } else {
  276. showErrorMessage(res.msg)
  277. }
  278. })
  279. },
  280. goToEditConfig: function(){
  281. var vm = this
  282. location.href = "../../recover/html/new_recover.html?patient=" + vm.patientcode + '&isEditConfig=true&planId='+vm.planid+'&planDetailId='+vm.planDetaiId
  283. },
  284. closeAllLayer: function(name, planDetaiId, type, relationCode, flag){
  285. if(name=='预览康复指导'){
  286. layer.close()
  287. } else if(name=='创建随访计划'){
  288. this.saveRehabilitationOperateRecord(planDetaiId, type, relationCode, flag)
  289. layer.close(followupLayerIndex)
  290. } else if(name=='发送康复指导'){
  291. this.saveRehabilitationOperateRecord(planDetaiId, type)
  292. layer.close(KFZDlayerIndex)
  293. }
  294. },
  295. // 提醒患者 num 1康复指导2康复下转3复诊提醒4上门服务提醒5家签提醒
  296. sendSpecialistWeixinMessage: function(planDetaiId, type){
  297. var vm = this
  298. var text = ''
  299. var patientName = vm.patientname
  300. var patientCode = vm.patientcode
  301. if(type==4){ // 上门服务
  302. text = '请问您是否确认提醒'+patientName+'居民预约上门护理服务?'
  303. } else if(type==7){ // 康复复诊
  304. text = '请问您是否确认提醒'+patientName+'居民进行复诊?'
  305. }
  306. var current=layer.confirm(text, {
  307. btn: ['确定', '取消'],
  308. title: "提示"
  309. }, function (index) {
  310. var _type = type == 4? 4:type==7?3:''
  311. var loading = layer.load(0, {shade: false})
  312. var params = {
  313. patient: patientCode,
  314. doctor: vm.docInfo.uid,
  315. type: _type,
  316. relationCode: planDetaiId,
  317. planId: vm.planid
  318. }
  319. rehaAPI.sendSpecialistWeixinMessage(params).then(function(res){
  320. layer.close(loading)
  321. if(res.status == 200){
  322. showSuccessMessage('提交成功!')
  323. if(_type==3 || _type==4){ // 提醒患者后,即认为是已完成
  324. vm.saveRehabilitationOperateRecord(planDetaiId, type)
  325. }
  326. } else {
  327. showErrorMessage(res.msg)
  328. }
  329. })
  330. layer.close(current); //再执行关闭
  331. })
  332. },
  333. // 添加完成记录
  334. addCompleteRecord: function(){
  335. var vm = this
  336. var detailId = this.planDetaiId
  337. var type = vm.service.type
  338. $("#completeRecord").css('display','block')
  339. this.layerIndex = layer.open({
  340. type: 1,
  341. area: ['500px', '450px'],
  342. shade: 0.5,
  343. title: '添加完成记录',
  344. btn: ['确定', '关闭'], //只是为了演示
  345. shadeClose: false, //点击遮罩关闭层
  346. content: $("#completeRecord"),
  347. yes: function(){
  348. vm.saveRehabilitationOperateRecord(detailId, 1)
  349. layer.close(vm.layerIndex)
  350. },
  351. });
  352. },
  353. monDetail:function(){
  354. this.currentDay = this.ynow + '年'+ (this.mnow + 1) +'月';
  355. },
  356. is_leap:function(year) { //判断是否为闰年
  357. return (year%100==0?res=(year%400==0?1:0):res=(year%4==0?1:0));
  358. },
  359. preMonth:function(){ //上一个月
  360. if(this.mnow<=0){
  361. this.mnow=11;
  362. this.ynow=this.ynow-1;
  363. }else{
  364. this.mnow--;
  365. }
  366. this.monDetail();
  367. this.goToLoadData(true);
  368. },
  369. getPreMouth:function(){
  370. var pMnow,pYnow;
  371. if(this.mnow<=0){
  372. pMnow=11;
  373. pYnow=this.ynow-1;
  374. }else{
  375. pMnow=this.mnow-1;
  376. pYnow=this.ynow;
  377. }
  378. var m_days=new Array(31,(28+this.is_leap(pYnow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  379. return {
  380. days:m_days[pMnow],
  381. date:pYnow+'-'+(++pMnow>=10?pMnow:"0"+pMnow)
  382. }
  383. },
  384. nextMonth:function(){ //下一个月
  385. if(this.mnow>=11){
  386. this.mnow=0;
  387. this.ynow=this.ynow+1;
  388. }else{
  389. this.mnow++;
  390. }
  391. this.monDetail();
  392. this.goToLoadData(true);
  393. },
  394. getNextMouth:function(){
  395. var nMnow,nYnow;
  396. if(this.mnow>=11){
  397. nMnow=0;
  398. nYnow=this.ynow+1;
  399. }else{
  400. nMnow=this.mnow+1;
  401. nYnow=this.ynow;
  402. }
  403. var m_days=new Array(31,(28+this.is_leap(nYnow)),31,30,31,01,31,31,30,31,30,31); //每个月的天数
  404. return {
  405. days:m_days[nMnow],
  406. date:nYnow+'-'+(++nMnow>=10?nMnow:"0"+nMnow)
  407. }
  408. },
  409. goToLoadData:function(flag){//flag是否更新数据
  410. this.tabStatus==1 && (!this.calendarData.length || flag) && this.calendar();
  411. this.tabStatus==2 && (!this.timeAxisData.length || flag) && this.timeAxis();
  412. },
  413. calendar:function(){
  414. var nlstr = new Date(this.ynow,this.mnow,1); //当月第一天
  415. var firstday = nlstr.getDay()-1;//第一天星期几,默认是周日 我们改成周一
  416. firstday=firstday==-1?6:firstday;//如果是-1,说明当月的第一天是周日
  417. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  418. var tr_str=Math.ceil((m_days[this.mnow] + firstday)/7); //当前月天数+第一天是星期几的数值 获得 表格行数
  419. var c_days=m_days[this.mnow];//当前月份的天数
  420. var p_arr=this.getPreMouth();
  421. var n_arr=this.getNextMouth();
  422. var i,k,idx,date_str;
  423. var dataArr=[];//天数/年月
  424. for(i=0;i<tr_str;i++) { //表格的行
  425. for(k=0;k<7;k++) { //表格每行的单元格
  426. idx=i*7+k; //单元格自然序列号
  427. date_str=idx-firstday+1; //计算日期
  428. var __ym;
  429. if(date_str<=0){//过滤无效日期(小于等于零的、大于月总天数的)
  430. date_str=date_str+p_arr['days'];//当前日期+上个月的天数就是上个月的日期
  431. __ym=p_arr['date'];
  432. }else if(date_str>c_days){
  433. date_str=date_str-c_days;//下个月的日期就是这个月的天数-当月的天数
  434. __ym=n_arr['date'];
  435. }else{
  436. __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  437. }
  438. dataArr.push({
  439. day:date_str,
  440. date:__ym
  441. });
  442. }
  443. }
  444. this.__Data=dataArr;
  445. this.calenderPlanDetail();
  446. },
  447. // 日历有计划数据处理
  448. planHandleData: function(data, day, mounth) {
  449. var item = data;
  450. item.day = day;
  451. if(mounth) {item.mounth = mounth}
  452. var finishFlag=false
  453. var sFlag=false;
  454. var fFlag=false;
  455. if(item.specialist){
  456. if(item.specialist.all==item.specialist.finish){
  457. sFlag=true;
  458. }
  459. }else{
  460. sFlag = true;
  461. }
  462. if(item.family){
  463. if(item.family.all==item.family.finish){
  464. fFlag = true;
  465. }
  466. }else{
  467. fFlag = true;
  468. }
  469. finishFlag = sFlag && fFlag;
  470. item.finishFlag=finishFlag;
  471. return item
  472. },
  473. calenderPlanDetail:function(){
  474. var vm=this;
  475. var __days=vm.__Data;
  476. var lastDay=(__days.concat()).pop().day;
  477. lastDay=lastDay>9?lastDay:'0'+lastDay;
  478. if(vm.searchTask || vm.status || vm.status == 0) {
  479. vm.isFastSearch = true
  480. } else {
  481. vm.isFastSearch = false
  482. }
  483. var params={
  484. executeStartTime: vm.isFastSearch ? '' : __days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  485. executeEndTime: vm.isFastSearch ? '' : (__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  486. planId:vm.planid,//计划id
  487. searchTask: vm.service.type,//快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  488. status: null,//任务状态(0未完成,1已完成,2已预约)
  489. }
  490. rehaAPI.calendarPlanDetail(params).then(function(res){
  491. vm.curTask=vm.searchTask;
  492. vm.curTaskName=vm.searchTaskName;
  493. vm.calendarData=[];
  494. var list = [];
  495. if(res.status==200){
  496. var data=res.data
  497. // 快速查找
  498. if(vm.isFastSearch) {
  499. vm.searchData = []
  500. var searchData0 = [],
  501. searchData1 = [],
  502. searchData2 = [];
  503. for(var setM = 1; setM <= 12; setM++) {
  504. var _setM = setM > 9 ? setM : '0' + setM,
  505. _setY = new Date().getFullYear();
  506. var data0 = [],
  507. data1 = [],
  508. data2 = [];
  509. for(var i in data) {
  510. var getY = i.split("-")[0],
  511. getM = i.split("-")[1],
  512. getD = i.split("-")[2];
  513. // 去年
  514. if(_setY - 1 == getY && _setM == getM) {
  515. var item = vm.planHandleData(data[i], getD, getM)
  516. data0.push(item)
  517. data.length && data.splice(i,1);
  518. } else if(_setY == getY && _setM == getM) { // 今年
  519. var item = vm.planHandleData(data[i], getD, getM)
  520. data1.push(item)
  521. data.length && data.splice(i,1);
  522. } else if(_setY + 1 == getY && _setM == getM) { // 明年
  523. var item = vm.planHandleData(data[i], getD, getM)
  524. data2.push(item)
  525. data.length && data.splice(i,1);
  526. }
  527. }
  528. if(data0.length) {
  529. var dataSort = vm.daysSort(data0)
  530. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  531. for(var i = 0; i < 7 - addlen; i++) {
  532. dataSort.push({
  533. noService:true
  534. })
  535. }
  536. searchData0.push(dataSort)
  537. }
  538. if(data1.length) {
  539. var dataSort = vm.daysSort(data1)
  540. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  541. for(var i = 0; i < 7 - addlen; i++) {
  542. dataSort.push({
  543. noService:true
  544. })
  545. }
  546. searchData1.push(dataSort)
  547. }
  548. if(data2.length) {
  549. var dataSort = vm.daysSort(data2)
  550. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  551. for(var i = 0; i < 7 - addlen; i++) {
  552. dataSort.push({
  553. noService:true
  554. })
  555. }
  556. searchData2.push(dataSort)
  557. }
  558. }
  559. if(searchData0.length) {vm.searchData.push(searchData0)}
  560. if(searchData1.length) {vm.searchData.push(searchData1)}
  561. if(searchData2.length) {vm.searchData.push(searchData2)}
  562. return false;
  563. }
  564. // 正常日历
  565. var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0));
  566. for(var i in __days){
  567. var _key=__days[i].date+'-'+(__days[i].day>9?__days[i].day:'0'+__days[i].day);
  568. var item={
  569. noService:true,
  570. day:__days[i].day
  571. };
  572. for(var j in data){
  573. if(_key==j){
  574. item = vm.planHandleData(data[j], __days[i].day)
  575. data.length && data.splice(j,1);
  576. break;
  577. }
  578. }
  579. var thatTime=+new Date(_key)-8*60*60*1000;
  580. var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  581. item.future=future;
  582. list.push(item);
  583. // vm.calendarData.push(item);
  584. }
  585. vm.calendarData = _.chunk(list, 7)
  586. }
  587. })
  588. },
  589. //时间轴请求
  590. timeAxis:function(){
  591. var m_days=new Array(31,(28+this.is_leap(this.ynow)),31,30,31,30,31,31,30,31,30,31); //每个月的天数
  592. var c_days=m_days[this.mnow];//当前月份的天数
  593. var __ym=this.ynow+'-'+(this.mnow>=9?"":"0")+(this.mnow+1);
  594. var dataArr=[];//天数/年月
  595. for(;c_days>0;c_days--){
  596. dataArr.push({
  597. day:c_days,
  598. date:__ym
  599. });
  600. }
  601. this.__xData=dataArr;
  602. this.calendarPlanDetailList();
  603. },
  604. //限频次 时间轴请求
  605. calendarPlanDetailList:function(){
  606. var vm=this;
  607. var __days=vm.__xData;
  608. var lastDay=(__days.concat()).pop().day;
  609. lastDay=lastDay>9?lastDay:'0'+lastDay;
  610. var params={
  611. executeEndTime:__days[0].date+'-'+__days[0].day+' 00:00:00',//日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  612. executeStartTime:(__days.concat()).pop().date+'-'+lastDay+' 23:59:59',//日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  613. planId:vm.planid,//计划id
  614. searchTask:vm.service.type, // 服务项
  615. status: null, //任务状态(0未完成,1已完成,2已预约)
  616. }
  617. rehaAPI.calendarPlanDetailList(params).then(function(res){
  618. if(res.status==200){
  619. // var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  620. var list=_.map(res.data||{},function(o){
  621. // var _time=o.executeTime.split(' ');
  622. // var thatTime=+new Date(_time[0]);
  623. // var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  624. // (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  625. // var _html=o.status==2?'预':(future==-1?'逾':'');
  626. // _html=future==1?'今':_html;
  627. // if(_html=='预') future=3;
  628. var _time=o.executeTime.split(' ');
  629. var _html = ''
  630. var d = new Date(o.execute_time);
  631. if(d.format("yyyy-MM-dd") == new Date().format("yyyy-MM-dd")) {
  632. o.firstSort = '1'
  633. future = 1
  634. _html = '今'
  635. if(o.status) {
  636. o.secondSort = '2'
  637. } else {
  638. o.secondSort = '1'
  639. }
  640. } else if(d > new Date()) {
  641. o.firstSort = '3'
  642. future = 2
  643. if(o.status) {
  644. o.secondSort = '2'
  645. } else {
  646. o.secondSort = '1'
  647. }
  648. } else {
  649. o.firstSort = '2'
  650. future = 0
  651. if(o.status == 0) {
  652. future = -1
  653. _html = '逾'
  654. o.secondSort = '1'
  655. } else {
  656. o.secondSort = '2'
  657. }
  658. }
  659. o.html=_html
  660. o.date=_time[0];
  661. o.time=_time[1];
  662. o.future=future;
  663. o.doctorName = o.doctor_name
  664. o.hospitalName = o.hospital_name
  665. return o;
  666. })||[];
  667. var nowTime = new Date().getTime()
  668. vm.timeAxisData = _.sortBy(list, function(o) {
  669. return o.firstSort + o.secondSort + (nowTime/o.execute_time)
  670. });
  671. } else {
  672. showErrorMessage(res.msg)
  673. }
  674. })
  675. },
  676. //不限频次 时间轴请求
  677. selectByPlanDetaiId: function(){
  678. var vm = this
  679. var params = {
  680. planId: this.planid,
  681. code: vm.service.type,
  682. page: 1,
  683. pagesize: 10000
  684. }
  685. rehaAPI.selectByPlanDetaiId(params).then(function(res){
  686. if(res.status==200){
  687. var list=_.map(res.data.list||{},function(o){
  688. var _time=o.completeTime.split(' ');
  689. var _html = ''
  690. var d = new Date(o.completeTime);
  691. if(d.format("yyyy-MM-dd") == new Date().format("yyyy-MM-dd")) {
  692. o.firstSort = '1'
  693. future = 1
  694. _html = '今'
  695. if(o.status) {
  696. o.secondSort = '2'
  697. } else {
  698. o.secondSort = '1'
  699. }
  700. } else if(d > new Date()) {
  701. o.firstSort = '3'
  702. future = 2
  703. if(o.status) {
  704. o.secondSort = '2'
  705. } else {
  706. o.secondSort = '1'
  707. }
  708. } else {
  709. o.firstSort = '2'
  710. future = 0
  711. if(o.status == 0) {
  712. future = -1
  713. _html = '逾'
  714. o.secondSort = '1'
  715. } else {
  716. o.secondSort = '2'
  717. }
  718. }
  719. o.html=_html
  720. o.date=_time[0];
  721. o.time=_time[1];
  722. o.future=future;
  723. o.hospitalName = o.hosiptalName
  724. return o;
  725. })||[];
  726. var nowTime = new Date().getTime()
  727. vm.timeAxisData = _.sortBy(list, function(o) {
  728. return o.firstSort + o.secondSort + (nowTime/o.execute_time)
  729. });
  730. } else {
  731. showErrorMessage(res.msg)
  732. }
  733. })
  734. },
  735. zdly: function(data) {
  736. var vm = this
  737. var otherCode, otherName;
  738. var planDetailId = vm.plandetailid;
  739. if(vm.docInfo.doctorType == 1) {
  740. otherCode = data.familyDoctorCode;
  741. otherName = data.familyDoctorName;
  742. } else {
  743. otherCode = data.specialistDoctorCode;
  744. otherName = data.specialistDoctorName;
  745. }
  746. top.layer.open({
  747. type: 2,
  748. area: ['660px', '600px'],
  749. shade: 0.5,
  750. title: '指导留言',
  751. fixed: true, //不固定
  752. maxmin: true,
  753. closeBtn: 1,
  754. shift: 5,
  755. shadeClose: false, //点击遮罩关闭层
  756. content: '../../consulting/html/consulting.html?otherCode=' + otherCode + '&otherName=' + encodeURI(otherName) + '&planDetailId=' + planDetailId,
  757. end: function() { // 未点击确定按钮,点击关闭按钮      
  758. vm.initData()   
  759. }
  760. });
  761. },
  762. //康复指导
  763. kfzd:function(){
  764. var vm=this
  765. KFZDlayerIndex = layer.open({
  766. type: 2,
  767. // offset: ['100px'], //右下角弹出
  768. area: ['660px', '650px'],
  769. shade: 0.5,
  770. title: '康复指导',
  771. fixed: true, //不固定
  772. maxmin: true,
  773. closeBtn: 1,
  774. shift: 5,
  775. shadeClose: false, //点击遮罩关闭层
  776. content:'../../rehabilitation/html/rehabilitation_guidance.html?patient='+vm.patientcode+'&planDetaiId='+vm.planDetaiId+'&planId='+vm.planid,
  777. end: function() { // 未点击确定按钮,点击关闭按钮
  778. vm.initData()   
  779. }
  780. });
  781. },
  782. // 康复随访计划
  783. sfjh: function(){
  784. var vm=this
  785. followupLayerIndex = layer.open({
  786. type: 2,
  787. // offset: ['100px'], //右下角弹出
  788. area: ['660px', '650px'],
  789. shade: 0.5,
  790. title: '随访计划',
  791. fixed: true, //不固定
  792. maxmin: true,
  793. closeBtn: 1,
  794. shift: 5,
  795. shadeClose: false, //点击遮罩关闭层
  796. content:'../../followup/html/followup_newplan.html?patient='+vm.patientcode+'&planDetaiId='+vm.planDetaiId+'&planId='+vm.planid,
  797. end: function() { // 未点击确定按钮,点击关闭按钮
  798. vm.initData()    
  799. }
  800. });
  801. },
  802. upLoadImgToBase64: function() {
  803. var vm = this;
  804. var img1 = event.target.files[0];
  805. var reader = new FileReader();
  806. var type = img1.type; //文件的类型,判断是否是图片
  807. var size = img1.size; //文件的大小,判断图片的大小
  808. if(this.imgData.accept.indexOf(type) == -1) {
  809. alert('请选择我们支持的图片格式!');
  810. return false;
  811. }
  812. if(size > 3145728) {
  813. alert('请选择3M以内的图片!');
  814. return false;
  815. }
  816. reader.readAsDataURL(img1);
  817. reader.onload = function(e) {
  818. vm.upImgs.push({
  819. baseUrl: e.target.result
  820. });
  821. vm.upImgArr.push(img1);
  822. vm.uploadImg(vm.upImgArr);
  823. }
  824. },
  825. //上传图片
  826. uploadImg: function(data) {
  827. var vm = this;
  828. var len = data.length;
  829. if(len==0) {
  830. return
  831. } else {
  832. var file = data[len - 1];
  833. var formData = new FormData();
  834. formData.append('file', file);
  835. rehaAPI.upload(formData).then(function(res) {
  836. if(res.status == 200) {
  837. vm.upImgs[len - 1].img = res.data;
  838. data.pop();
  839. vm.$forceUpdate()
  840. vm.uploadImg(data);
  841. } else {
  842. layer.msg(res.msg, {
  843. icon: 5
  844. });
  845. }
  846. })
  847. }
  848. },
  849. saveRehabilitationOperateRecord:function(planDetailId, type, relationCode, flag){
  850. var vm=this
  851. var patientName = vm.patientname
  852. var patientCode = vm.patientcode
  853. var _image = [];
  854. for(var i in vm.upImgs) {
  855. _image.push(vm.upImgs[i].img);
  856. }
  857. var params={
  858. rehabilitationDetailId: planDetailId,
  859. node: vm.node||'',
  860. patientCode: patientCode,
  861. doctorCode: vm.docInfo.uid,
  862. relationRecordType: type,
  863. relationRecordCode: '',
  864. relationRecordImg: '',
  865. status: flag&&flag==2?1:0, // 改记录的状态
  866. relationCode: relationCode, //业务id
  867. flag: flag,//标记(1随访2临时随访)
  868. }
  869. rehaAPI.saveRehabilitationOperateRecord({dataJson:JSON.stringify(params)}).then(function(res){
  870. if(res.status==200){
  871. if(type==1){
  872. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  873. }else if(type==6){
  874. vm.updateRelationCodeByDetailId(planDetailId, relationCode)
  875. } else {
  876. vm.updateNoteAndImageRehabilitationOperate(planDetailId)
  877. }
  878. }else {
  879. showErrorMessage(res.msg)
  880. }
  881. })
  882. },
  883. updateNoteAndImageRehabilitationOperate: function(planDetailId, relationCode) {
  884. var vm = this;
  885. var _image = [];
  886. for(var i in vm.upImgs) {
  887. _image.push(vm.upImgs[i].img);
  888. }
  889. var params = {
  890. planDetailId: planDetailId,
  891. node: vm.node||'',
  892. image: JSON.stringify(_image)||''
  893. }
  894. if(relationCode){
  895. params['relationCode'] = relationCode
  896. }
  897. var loadding = top.layer.load(0, {
  898. shade: false
  899. }); //0代表加载的风格,支持0-2
  900. rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res) {
  901. top.layer.close(loadding);
  902. if(res.status == 200) {
  903. vm.initData()
  904. }else {
  905. showErrorMessage(res.msg)
  906. }
  907. })
  908. },
  909. onViewDetail: function(item, type){
  910. var planids, recordId;
  911. if(this.islimit){
  912. planids = item.id
  913. } else {
  914. planids = item.id
  915. recordId = item.recordId
  916. }
  917. this.viewDetail(planids,type, recordId)
  918. },
  919. viewDetail:function(planids,type, recordId){
  920. var vm=this;
  921. if(!planids){
  922. layer.msg('无服务项',{icon:5})
  923. return ;
  924. }
  925. if(type==1){ // 单个服务项
  926. var s = '../../rehabilitation/html/guide_the_message.html?planid='+planids+'&oprateType=1'+'&pId='+vm.planid+'&patient='+vm.patientcode+'&patientName='+vm.patientname
  927. if(recordId){
  928. s += '&recordId='+ recordId
  929. }
  930. layer.open({
  931. type: 2,
  932. area: ['800px', '700px'],
  933. shade: 0.5,
  934. title: '服务项目内容',
  935. fixed: true, //不固定
  936. maxmin: true,
  937. closeBtn:1,
  938. shift: 5,
  939. shadeClose: false, //点击遮罩关闭层
  940. content: s,
  941. end:function(){ // 未点击确定按钮,点击关闭按钮
  942.     vm.initData(); // 刷新
  943.   }
  944. });
  945. return ;
  946. }
  947. layer.open({ // 康复计划的所有服务项
  948. type: 2,
  949. area: ['800px', '700px'],
  950. shade: 0.5,
  951. title: '服务项目内容',
  952. fixed: true, //不固定
  953. maxmin: true,
  954. closeBtn:1,
  955. shift: 5,
  956. shadeClose: false, //点击遮罩关闭层
  957. content: '../../rehabilitation/html/service_item_content.html?planids='+planids+'&planId='+vm.planid+'&patient='+vm.patientcode+'&patientName='+vm.patientname,
  958. end:function(){
  959. vm.initData();
  960. }
  961. });
  962. },
  963. onClose: function(){
  964. this.$emit('onclose')
  965. },
  966. qwapp:function(){
  967. layer.msg('请前往app处理',{icon:5});
  968. },
  969. getContent: function(value,type) {
  970. var res=value;
  971. if(type==2 || type==9){
  972. res = "<img src='"+httpRequest.getImgUrl(res)+"' width='100px'>";
  973. }else if(type==3){
  974. res = '【语音】';
  975. }else if(type==19){
  976. res = '【聊天记录】';
  977. }else if(type==12){
  978. res = '【视频】';
  979. }
  980. return res;
  981. },
  982. previewImg: function(url){
  983. imgShow("#outerdiv", "#innerdiv", "#bigimg", url);
  984. }
  985. }
  986. })
  987. function imgShow(outerdiv, innerdiv, bigimg, _this){
  988. var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
  989. $(bigimg).attr("src", src);//设置#bigimg元素的src属性
  990. /*获取当前点击图片的真实大小,并显示弹出层及大图*/
  991. $("<img/>").attr("src", src).load(function(){
  992. var windowW = $(window).width();//获取当前窗口宽度
  993. var windowH = $(window).height();//获取当前窗口高度
  994. var realWidth = this.width;//获取图片真实宽度
  995. var realHeight = this.height;//获取图片真实高度
  996. var imgWidth, imgHeight;
  997. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  998. if(realHeight>windowH*scale) {//判断图片高度
  999. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  1000. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  1001. if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
  1002. imgWidth = windowW*scale;//再对宽度进行缩放
  1003. }
  1004. } else if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度
  1005. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  1006. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  1007. } else {//如果图片真实高度和宽度都符合要求,高宽不变
  1008. imgWidth = realWidth;
  1009. imgHeight = realHeight;
  1010. }
  1011. $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
  1012. var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
  1013. var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
  1014. $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
  1015. $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
  1016. });
  1017. $(outerdiv).click(function(){//再次点击淡出消失弹出层
  1018. $(this).fadeOut("fast");
  1019. });
  1020. }