server-items-detail.js 34 KB

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