server-items-detail.js 34 KB

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