server-items-detail.js 32 KB

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