server-items-detail.js 41 KB

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