rehabilitation_management.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. !(function () {
  2. var httpData = GetRequest()
  3. var currentGMT = new Date() //当前时间GMT
  4. var xuetangDuring = ['', '早餐前', '早餐后', '午餐前', '午餐后', '晚餐前', '晚餐后', '睡前']
  5. var normalLevel = [[], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4]]
  6. var docInfo = JSON.parse(localStorage.wlyyAgent)
  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. top.rehabilitationVue = new Vue({
  28. el: '#app',
  29. data: {
  30. ynow: currentGMT.getFullYear(), //年份
  31. mnow: currentGMT.getMonth(), //月份(比实际少一个月---0开始至11)
  32. dnow: currentGMT.getDate(), //当前日
  33. currentDay: null, //带中文格式的当前年月
  34. currentDayForEn: null, //不带中文格式年月日2018/10/01如果写成/的话 转换成时间戳会变成北京时间8点
  35. calendarData: [], //日历数据
  36. loginDoctor: JSON.parse(localStorage.getItem('wlyyAgent')),
  37. timeAxisData: [], //时间轴数据
  38. __Data: [], //当前的年月(日历)
  39. __xData: [], //当前的年月(时间轴)
  40. isFastSearch: false, // 是否是快速查找任务
  41. status: '', //任务状态(0未完成,1已完成,2已预约)
  42. searchTask: '', //快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
  43. searchTaskName: '全部', //快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)
  44. planId: httpData['planId'],
  45. patientCode: httpData['patientCode'],
  46. taskArr: [
  47. { code: '', name: '全部' },
  48. { code: 2, name: '康复咨询' },
  49. { code: 4, name: '上门服务' },
  50. { code: 1, name: '电话/短信关怀' },
  51. { code: 3, name: '健康监测' },
  52. { code: 5, name: '康复指导' },
  53. { code: 6, name: '康复随访' },
  54. { code: 7, name: '康复复诊' }
  55. ],
  56. statusArr: [
  57. { code: '', name: '全部' },
  58. { code: 0, name: '未完成' },
  59. { code: 1, name: '已完成' },
  60. { code: 2, name: '已预约' }
  61. ],
  62. curTask: '', //快速查找是否点击了搜索按钮
  63. curTaskName: '', //快速查找是否点击了搜索按钮
  64. tabStatus: null,
  65. planInfo: {},
  66. docList: [],
  67. diagnosisInformation: null,
  68. searchData: [], // 搜索计划安排(去年、今年、明年)
  69. medicalRecordsList: [], //病历列表
  70. limitlessItems: [],
  71. showServerItemDetail: false,
  72. serverItemInfo: undefined,
  73. islimit: false,
  74. scList: []
  75. },
  76. mounted: function () {
  77. if (!this.planId) {
  78. layer.msg('未传入计划id(planId)', { icon: 2 })
  79. } else {
  80. this.tabStatus = 1
  81. }
  82. this.planSchedule()
  83. // this.serviceDoctorList();//获取服务医生列表
  84. this.selectPlanServerDoctor() //获取服务医生列表
  85. this.bindEvents()
  86. // 获取最新的诊疗信息1条
  87. this.findDiagnosisInformationByPlanId()
  88. },
  89. methods: {
  90. gotoCheck: function () {
  91. var obj = {
  92. patientName: this.planInfo.patientName,
  93. patientCode: this.planInfo.patientCode
  94. }
  95. window.location.href = '../../jbsc/html/statistics.html?scListItem=' + encodeURIComponent(JSON.stringify(obj))
  96. },
  97. view: function (code) {
  98. var vm = this
  99. layer.open({
  100. type: 2,
  101. // offset: ['100px'], //右下角弹出
  102. area: ['568px', '100%'],
  103. shade: 0.5,
  104. title: '查看筛选结果',
  105. fixed: true, //不固定
  106. maxmin: true,
  107. closeBtn: 1,
  108. shift: 5,
  109. shadeClose: false, //点击遮罩关闭层
  110. content: '../../jbsc/html/view_screening_results.html?isView=true&resultCode=' + code
  111. })
  112. },
  113. gotoSc: function () {
  114. top.layer.open({
  115. type: 2,
  116. area: ['820px', '648px'],
  117. shade: 0.5,
  118. title: 'ASCVD风险评估',
  119. fixed: true, //不固定
  120. maxmin: true,
  121. closeBtn: 1,
  122. shift: 5,
  123. shadeClose: false, //点击遮罩关闭层
  124. content: `../../jbsc/html/questionnaire.html?fliter_code=6bcd306aaafb4e4381071346d86fadbb1&fliter_title=ASCVD风险评估&resident_code=${this.planInfo.patientCode}&resident_name=${this.planInfo.patientName}&sex=${this.planInfo.sex}&age=${this.planInfo.age}&idcard=${this.planInfo.idcard}&mobile=${this.planInfo.mobile}&surveyStatus=2&noswitch=1`
  125. })
  126. },
  127. getList: function () {
  128. var vm = this
  129. rehaAPI
  130. .getList({
  131. doctor: docInfo.code,
  132. diseaseType: vm.planInfo.disease,
  133. type: '',
  134. patientName: '',
  135. patientCode: this.patientCode,
  136. isDanger: '',
  137. pageNo: 1,
  138. pageSize: 1,
  139. filterType: 1,
  140. isAscvd: vm.planInfo.disease == '3' ? 1 : ''
  141. })
  142. .then(function (res) {
  143. vm.scList = res.data
  144. })
  145. },
  146. // 刷新
  147. refresh: function () {
  148. this.planSchedule()
  149. this.timeAxis()
  150. },
  151. // 获取服务医生列表
  152. selectPlanServerDoctor: function () {
  153. var vm = this,
  154. params = {
  155. planId: vm.planId
  156. }
  157. rehaAPI.selectPlanServerDoctor(params).then(function (res) {
  158. if (res.status == 200) {
  159. vm.docList = res.data
  160. } else {
  161. layer.msg(res.msg, { icon: 5 })
  162. }
  163. })
  164. },
  165. //获取计划表
  166. planSchedule: function () {
  167. var vm = this
  168. var params = {
  169. planId: this.planId,
  170. patientCode: this.patientCode
  171. }
  172. rehaAPI.planSchedule(params).then(function (res) {
  173. if (res.status == 200) {
  174. vm.planInfo = res.data
  175. vm.getList()
  176. vm.planInfo.tagClass = 'tag-' + res.data.healthyConditionType
  177. //patientImg:居民签名照/证件照,如果不为null的话说明居民已确认,显示康复完成明细
  178. if (vm.planInfo.status == 2 && !vm.planInfo.patientImg) {
  179. //任务全部完成时,显示完成提示框
  180. vm.showCompleteDailog()
  181. } else if (vm.planInfo.status == 2 && vm.planInfo.patientImg) {
  182. //居民已确认计划完成
  183. vm.tabStatus = 3
  184. $('#framePage').attr('src', 'stop_special_service.html?planids=' + vm.planId + '&planStatus=' + vm.planInfo.status)
  185. }
  186. vm.selectByMedicalCode(res.data.medicalRecordsCode)
  187. } else {
  188. layer.msg(res.msg, { icon: 5 })
  189. }
  190. })
  191. },
  192. // 获取住院病历
  193. selectByMedicalCode: function (medicalRecordsCode) {
  194. var vm = this
  195. var params = {
  196. medical: medicalRecordsCode
  197. }
  198. rehaAPI.selectByMedicalCode(params).then(function (res) {
  199. if (res.status == 200) {
  200. vm.medicalRecordsList = res.data
  201. } else {
  202. showErrorMessage(res.msg)
  203. }
  204. })
  205. },
  206. // 查看住院病历详情
  207. viewMedicalDetail: function (o) {
  208. var vm = this
  209. if (o.event) {
  210. var loading = layer.load(0, { shade: false })
  211. recoverAPI.getPatientAccetokenByIdcard({ idcard: vm.planInfo.idcard }).then(function (res) {
  212. layer.close(loading)
  213. if (res.status == 200) {
  214. layer.open({
  215. type: 2,
  216. area: ['75%', '650px'],
  217. shade: 0.5,
  218. title: '住院病历',
  219. closeBtn: 1,
  220. shift: 5,
  221. shadeClose: false, //点击遮罩关闭层
  222. content: httpRequest.server + 'profileweb/#/zhuyuan?patientCode=' + res.data.patientCode + '&hospital=' + docInfo.hospital + '&event=' + o.event
  223. })
  224. } else {
  225. showErrorMessage(res.msg)
  226. }
  227. })
  228. } else {
  229. layer.open({
  230. type: 2,
  231. area: ['600px', '600px'],
  232. shade: 0.5,
  233. title: '住院病历详情',
  234. fixed: true, //不固定
  235. maxmin: true,
  236. closeBtn: 1,
  237. shift: 5,
  238. shadeClose: false, //点击遮罩关闭层
  239. content: '../../rehabilitation/html/medical-records-detail.html?medicalRecordsCode=' + o.code
  240. })
  241. }
  242. },
  243. formatter: function (time) {
  244. return new Date(time).format('yyyy-MM-dd')
  245. },
  246. // 获取最新的诊疗消息
  247. findDiagnosisInformationByPlanId: function () {
  248. var vm = this,
  249. loading = layer.load(0, { shade: false }),
  250. params = {
  251. planId: vm.planId
  252. }
  253. recoverAPI.findDiagnosisInformationByPlanId(params).then(function (res) {
  254. layer.close(loading)
  255. if (res.status == 200) {
  256. vm.diagnosisInformation = res.data
  257. } else {
  258. showErrorMessage(res.msg)
  259. }
  260. })
  261. },
  262. serviceDoctorList: function () {
  263. var vm = this
  264. rehaAPI.serviceDoctorList({ patientCode: this.patientCode }).then(function (res) {
  265. if (res.status == 200) {
  266. vm.docList = res.data
  267. } else {
  268. layer.msg(res.msg, { icon: 5 })
  269. }
  270. })
  271. },
  272. weiXinConfirmClick: function () {
  273. var vm = this
  274. rehaAPI.sendWxMsg({ planId: this.planId }).then(function (res) {
  275. if (res.status == 200) {
  276. layer.msg('发送成功,等待居民确认')
  277. setTimeout(function () {
  278. vm.tabStatus = 3
  279. $('#framePage').attr('src', 'stop_special_service.html?planids=' + vm.planId + '&planStatus=' + vm.planInfo.status)
  280. }, 1000)
  281. } else {
  282. layer.msg(res.msg, { icon: 5 })
  283. }
  284. })
  285. },
  286. setImgSrc: function (src) {
  287. var str = httpRequest.getImgUrl(src)
  288. return str
  289. },
  290. showCompleteDailog: function () {
  291. layer.confirm(
  292. '<div class="mt10 tac"><image src="../images/yiwancheng_icon.png" width="100" height="100"/><div class="mt20 c-f20 c-333 mb40">本次康复计划已完成</div><div class="div-patient-comfirm c-f14 c-fff bgc-12b7f5" style="margin:40px auto 20px;">邀请居民确认</div></div>',
  293. {
  294. btn: [],
  295. area: ['400px', '340px'],
  296. title: '完成提示'
  297. },
  298. function (index) {
  299. // layer.close(index);
  300. }
  301. )
  302. },
  303. refreshPage: function () {
  304. if (!this.planId) {
  305. layer.msg('未传入计划id(planId)', { icon: 2 })
  306. return
  307. }
  308. this.goToLoadData(true)
  309. },
  310. bindEvents: function () {
  311. var vm = this
  312. $('body')
  313. .on('click', '.div-patient-comfirm', function () {
  314. layer.closeAll()
  315. vm.weiXinConfirmClick()
  316. })
  317. .on('click', '.div-patient-home', function () {
  318. location.href = '../../recover/html/personal-manage.html?patientCode=' + vm.patientCode + '&planId=' + vm.planId
  319. })
  320. },
  321. viewDetail: function (planids, type, item) {
  322. var vm = this
  323. if (!planids) {
  324. layer.msg('无服务项', { icon: 5 })
  325. return
  326. }
  327. if (vm.planInfo.disease == '3' && vm.scList.length == 0 && item && item.code == '6' && vm.loginDoctor.doctorType != '1') {
  328. this.$confirm('提示该居民近一年没有进行冠心病风险评估,请先进行评估,再进行随访登记', '提示', {
  329. confirmButtonText: '确定',
  330. cancelButtonText: '取消',
  331. type: 'warning'
  332. }).then(function () {
  333. vm.gotoSc()
  334. })
  335. return false
  336. }
  337. if (type == 1) {
  338. // 单个服务项
  339. layer.open({
  340. type: 2,
  341. area: ['800px', '700px'],
  342. shade: 0.5,
  343. title: '服务项目内容',
  344. fixed: true, //不固定
  345. maxmin: true,
  346. closeBtn: 1,
  347. shift: 5,
  348. shadeClose: false, //点击遮罩关闭层
  349. content:
  350. '../../rehabilitation/html/guide_the_message.html?planid=' +
  351. planids +
  352. '&pId=' +
  353. httpData['planId'] +
  354. '&patient=' +
  355. vm.patientCode +
  356. '&patientName=' +
  357. vm.planInfo.patientName,
  358. end: function () {
  359. vm.goToLoadData(true)
  360. }
  361. })
  362. return
  363. }
  364. layer.open({
  365. // 康复计划的所有服务项
  366. type: 2,
  367. area: ['800px', '700px'],
  368. shade: 0.5,
  369. title: '服务项目内容',
  370. fixed: true, //不固定
  371. maxmin: true,
  372. closeBtn: 1,
  373. shift: 5,
  374. shadeClose: false, //点击遮罩关闭层
  375. content:
  376. '../../rehabilitation/html/service_item_content.html?planids=' +
  377. planids +
  378. '&planId=' +
  379. httpData['planId'] +
  380. '&patient=' +
  381. vm.patientCode +
  382. '&patientName=' +
  383. vm.planInfo.patientName +
  384. '&disease=' +
  385. vm.planInfo.disease +
  386. '&scLenght=' +
  387. vm.scList.length,
  388. end: function () {
  389. vm.goToLoadData(true)
  390. }
  391. })
  392. },
  393. changeStatus: function (val) {
  394. this.status = val.code
  395. },
  396. changeTask: function (val) {
  397. this.searchTask = val.code
  398. this.searchTaskName = val.name
  399. },
  400. monDetail: function () {
  401. this.currentDay = this.ynow + '年' + (this.mnow + 1) + '月'
  402. this.currentDayForEn = this.ynow + '/' + (this.mnow >= 9 ? this.mnow + 1 : '0' + (this.mnow + 1)) + '/' + (this.dnow >= 9 ? this.dnow : '0' + this.dnow)
  403. },
  404. is_leap: function (year) {
  405. //判断是否为闰年
  406. return year % 100 == 0 ? (res = year % 400 == 0 ? 1 : 0) : (res = year % 4 == 0 ? 1 : 0)
  407. },
  408. preMonth: function () {
  409. //上一个月
  410. if (this.mnow <= 0) {
  411. this.mnow = 11
  412. this.ynow = this.ynow - 1
  413. } else {
  414. this.mnow--
  415. }
  416. this.monDetail()
  417. this.goToLoadData(true)
  418. },
  419. getPreMouth: function () {
  420. var pMnow, pYnow
  421. if (this.mnow <= 0) {
  422. pMnow = 11
  423. pYnow = this.ynow - 1
  424. } else {
  425. pMnow = this.mnow - 1
  426. pYnow = this.ynow
  427. }
  428. var m_days = new Array(31, 28 + this.is_leap(pYnow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  429. return {
  430. days: m_days[pMnow],
  431. date: pYnow + '-' + (++pMnow >= 10 ? pMnow : '0' + pMnow)
  432. }
  433. },
  434. nextMonth: function () {
  435. //下一个月
  436. if (this.mnow >= 11) {
  437. this.mnow = 0
  438. this.ynow = this.ynow + 1
  439. } else {
  440. this.mnow++
  441. }
  442. this.monDetail()
  443. this.goToLoadData(true)
  444. },
  445. getNextMouth: function () {
  446. var nMnow, nYnow
  447. if (this.mnow >= 11) {
  448. nMnow = 0
  449. nYnow = this.ynow + 1
  450. } else {
  451. nMnow = this.mnow + 1
  452. nYnow = this.ynow
  453. }
  454. var m_days = new Array(31, 28 + this.is_leap(nYnow), 31, 30, 31, 01, 31, 31, 30, 31, 30, 31) //每个月的天数
  455. return {
  456. days: m_days[nMnow],
  457. date: nYnow + '-' + (++nMnow >= 10 ? nMnow : '0' + nMnow)
  458. }
  459. },
  460. goToLoadData: function (flag) {
  461. //flag是否更新数据
  462. this.tabStatus == 1 && (!this.calendarData.length || flag) && this.calendar()
  463. this.tabStatus == 2 && (!this.timeAxisData.length || flag) && this.timeAxis()
  464. // this.changeSearch(-1)
  465. },
  466. calendar: function () {
  467. var nlstr = new Date(this.ynow, this.mnow, 1) //当月第一天
  468. var firstday = nlstr.getDay() - 1 //第一天星期几,默认是周日 我们改成周一
  469. firstday = firstday == -1 ? 6 : firstday //如果是-1,说明当月的第一天是周日
  470. var m_days = new Array(31, 28 + this.is_leap(this.ynow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  471. var tr_str = Math.ceil((m_days[this.mnow] + firstday) / 7) //当前月天数+第一天是星期几的数值 获得 表格行数
  472. var c_days = m_days[this.mnow] //当前月份的天数
  473. var p_arr = this.getPreMouth()
  474. var n_arr = this.getNextMouth()
  475. var i, k, idx, date_str
  476. var dataArr = [] //天数/年月
  477. for (i = 0; i < tr_str; i++) {
  478. //表格的行
  479. for (k = 0; k < 7; k++) {
  480. //表格每行的单元格
  481. idx = i * 7 + k //单元格自然序列号
  482. date_str = idx - firstday + 1 //计算日期
  483. var __ym
  484. if (date_str <= 0) {
  485. //过滤无效日期(小于等于零的、大于月总天数的)
  486. date_str = date_str + p_arr['days'] //当前日期+上个月的天数就是上个月的日期
  487. __ym = p_arr['date']
  488. } else if (date_str > c_days) {
  489. date_str = date_str - c_days //下个月的日期就是这个月的天数-当月的天数
  490. __ym = n_arr['date']
  491. } else {
  492. __ym = this.ynow + '-' + (this.mnow >= 9 ? '' : '0') + (this.mnow + 1)
  493. }
  494. dataArr.push({
  495. day: date_str,
  496. date: __ym
  497. })
  498. }
  499. }
  500. this.__Data = dataArr
  501. this.monDetail()
  502. this.calenderPlanDetail()
  503. },
  504. daysSort: function (arr) {
  505. var getArr = JSON.parse(JSON.stringify(arr)),
  506. returnArr = []
  507. for (var i = 1; i < 31; i++) {
  508. for (var j = 0, len = getArr.length; j < len; j++) {
  509. var stri = i > 9 + '' ? i : '0' + i
  510. if (getArr[j].day == stri) {
  511. returnArr.push(getArr[j])
  512. getArr.splice(j, 1)
  513. break
  514. }
  515. }
  516. }
  517. return returnArr
  518. },
  519. // 日历有计划数据处理
  520. planHandleData: function (data, day, mounth) {
  521. var item = data
  522. item.day = day
  523. if (mounth) {
  524. item.mounth = mounth
  525. }
  526. var finishFlag = false
  527. var sFlag = false
  528. var fFlag = false
  529. if (item.specialist) {
  530. if (item.specialist.all == item.specialist.finish) {
  531. sFlag = true
  532. }
  533. } else {
  534. sFlag = true
  535. }
  536. if (item.family) {
  537. if (item.family.all == item.family.finish) {
  538. fFlag = true
  539. }
  540. } else {
  541. fFlag = true
  542. }
  543. finishFlag = sFlag && fFlag
  544. item.finishFlag = finishFlag
  545. return item
  546. },
  547. // 日历请求
  548. calenderPlanDetail: function () {
  549. var vm = this
  550. var __days = vm.__Data
  551. var lastDay = __days.concat().pop().day
  552. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  553. if (vm.searchTask != '' || vm.status != '') {
  554. vm.isFastSearch = true
  555. } else {
  556. vm.isFastSearch = false
  557. }
  558. var params = {
  559. executeStartTime: vm.isFastSearch ? '' : __days[0].date + '-' + __days[0].day + ' 00:00:00', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  560. executeEndTime: vm.isFastSearch ? '' : __days.concat().pop().date + '-' + lastDay + ' 23:59:59', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  561. planId: vm.planId, //计划id
  562. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  563. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  564. }
  565. rehaAPI.calendarPlanDetail(params).then(function (res) {
  566. vm.curTask = vm.searchTask
  567. vm.curTaskName = vm.searchTaskName
  568. vm.calendarData = []
  569. var list = []
  570. if (res.status == 200) {
  571. var data = res.data
  572. // 快速查找
  573. if (vm.isFastSearch) {
  574. vm.searchData = []
  575. var searchData0 = [],
  576. searchData1 = [],
  577. searchData2 = []
  578. for (var setM = 1; setM <= 12; setM++) {
  579. var _setM = setM > 9 ? setM : '0' + setM,
  580. _setY = new Date().getFullYear()
  581. var data0 = [],
  582. data1 = [],
  583. data2 = []
  584. for (var i in data) {
  585. var getY = i.split('-')[0],
  586. getM = i.split('-')[1],
  587. getD = i.split('-')[2]
  588. // 去年
  589. if (_setY - 1 == getY && _setM == getM) {
  590. var item = vm.planHandleData(data[i], getD, getM)
  591. data0.push(item)
  592. data.length && data.splice(i, 1)
  593. } else if (_setY == getY && _setM == getM) {
  594. // 今年
  595. var item = vm.planHandleData(data[i], getD, getM)
  596. data1.push(item)
  597. data.length && data.splice(i, 1)
  598. } else if (_setY + 1 == getY && _setM == getM) {
  599. // 明年
  600. var item = vm.planHandleData(data[i], getD, getM)
  601. data2.push(item)
  602. data.length && data.splice(i, 1)
  603. }
  604. }
  605. if (data0.length) {
  606. var dataSort = vm.daysSort(data0)
  607. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  608. for (var i = 0; i < 7 - addlen; i++) {
  609. dataSort.push({
  610. noService: true
  611. })
  612. }
  613. searchData0.push(dataSort)
  614. }
  615. if (data1.length) {
  616. var dataSort = vm.daysSort(data1)
  617. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  618. for (var i = 0; i < 7 - addlen; i++) {
  619. dataSort.push({
  620. noService: true
  621. })
  622. }
  623. searchData1.push(dataSort)
  624. }
  625. if (data2.length) {
  626. var dataSort = vm.daysSort(data2)
  627. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  628. for (var i = 0; i < 7 - addlen; i++) {
  629. dataSort.push({
  630. noService: true
  631. })
  632. }
  633. searchData2.push(dataSort)
  634. }
  635. }
  636. if (searchData0.length) {
  637. vm.searchData.push(searchData0)
  638. }
  639. if (searchData1.length) {
  640. vm.searchData.push(searchData1)
  641. }
  642. if (searchData2.length) {
  643. vm.searchData.push(searchData2)
  644. }
  645. return false
  646. }
  647. // 正常日历
  648. var _currentTimeStamp = +new Date(new Date().setHours(0, 0, 0, 0))
  649. for (var i in __days) {
  650. var _key = __days[i].date + '-' + (__days[i].day > 9 ? __days[i].day : '0' + __days[i].day)
  651. var item = {
  652. noService: true,
  653. day: __days[i].day
  654. }
  655. for (var j in data) {
  656. if (_key == j) {
  657. item = vm.planHandleData(data[j], __days[i].day)
  658. data.length && data.splice(j, 1)
  659. break
  660. }
  661. }
  662. var thatTime = +new Date(_key) - 8 * 60 * 60 * 1000
  663. var future = _currentTimeStamp > thatTime ? 0 : _currentTimeStamp == thatTime ? 1 : 2
  664. item.future = future
  665. list.push(item)
  666. // vm.calendarData.push(item);
  667. }
  668. vm.calendarData = _.chunk(list, 7)
  669. }
  670. })
  671. },
  672. // 时间轴请求
  673. timeAxis: function () {
  674. var m_days = new Array(31, 28 + this.is_leap(this.ynow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  675. var c_days = m_days[this.mnow] //当前月份的天数
  676. var __ym = this.ynow + '-' + (this.mnow >= 9 ? '' : '0') + (this.mnow + 1)
  677. var dataArr = [] //天数/年月
  678. for (; c_days > 0; c_days--) {
  679. dataArr.push({
  680. day: c_days,
  681. date: __ym
  682. })
  683. }
  684. this.__xData = dataArr
  685. this.monDetail()
  686. this.calendarPlanDetailList()
  687. this.calendarPlanDetailItems()
  688. },
  689. //时间轴请求
  690. calendarPlanDetailList: function () {
  691. var vm = this
  692. var __days = vm.__xData
  693. var lastDay = __days.concat().pop().day
  694. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  695. var params = {
  696. executeEndTime: __days[0].date + '-' + __days[0].day + ' 23:59:59', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  697. executeStartTime: __days.concat().pop().date + '-' + lastDay + ' 00:00:00', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  698. planId: vm.planId, //计划id
  699. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  700. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  701. }
  702. rehaAPI.calendarPlanDetailList(params).then(function (res) {
  703. if (res.status == 200) {
  704. // var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  705. var list =
  706. _.map(res.data || {}, function (o) {
  707. // var _time=o.executeTime.split(' ');
  708. // var thatTime=+new Date(_time[0]);
  709. // var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  710. // (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  711. // var _html=o.status==2?'预':(future==-1?'逾':'');
  712. // _html=future==1?'今':_html;
  713. // if(_html=='预') future=3;
  714. var _time = o.executeTime.split(' ')
  715. var _html = ''
  716. var d = new Date(o.execute_time)
  717. if (d.format('yyyy-MM-dd') == new Date().format('yyyy-MM-dd')) {
  718. o.firstSort = '1'
  719. future = 1
  720. _html = '今'
  721. if (o.status) {
  722. o.secondSort = '2'
  723. } else {
  724. o.secondSort = '1'
  725. }
  726. } else if (d > new Date()) {
  727. o.firstSort = '3'
  728. future = 2
  729. if (o.status) {
  730. o.secondSort = '2'
  731. } else {
  732. o.secondSort = '1'
  733. }
  734. } else {
  735. o.firstSort = '2'
  736. future = 0
  737. if (o.status == 0) {
  738. future = -1
  739. _html = '逾'
  740. o.secondSort = '1'
  741. } else {
  742. o.secondSort = '2'
  743. }
  744. }
  745. o.html = _html
  746. o.date = _time[0]
  747. o.time = _time[1]
  748. o.future = future
  749. o.doctorName = o.doctor_name
  750. o.hospitalName = o.hospital_name
  751. return o
  752. }) || []
  753. var nowTime = new Date().getTime()
  754. vm.timeAxisData = _.sortBy(list, function (o) {
  755. return o.firstSort + o.secondSort + nowTime / o.execute_time
  756. })
  757. }
  758. })
  759. },
  760. viewServerItemsDetail: function (o) {
  761. if (o.code == '2') {
  762. showInfoMessage('请从“消息-患者消息列表”中查看患者的康复咨询记录')
  763. return
  764. }
  765. if (o.code == '3') {
  766. layer.open({
  767. type: 2,
  768. area: ['700px', '700px'],
  769. shade: 0.5,
  770. title: '健康记录',
  771. fixed: true, //不固定
  772. maxmin: true,
  773. closeBtn: 1,
  774. // shift: 5,
  775. shadeClose: false, //点击遮罩关闭层
  776. content: '../html/healthMonitor.html?patient=' + this.patientCode
  777. })
  778. return
  779. }
  780. this.serverItemInfo = o
  781. this.showServerItemDetail = true
  782. this.islimit = o.frequency_code ? true : false
  783. },
  784. calendarPlanDetailItems: function () {
  785. var vm = this
  786. var __days = vm.__xData
  787. var lastDay = __days.concat().pop().day
  788. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  789. var params = {
  790. executeEndTime: __days[0].date + '-' + __days[0].day + ' 23:59:59', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  791. executeStartTime: __days.concat().pop().date + '-' + lastDay + ' 00:00:00', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  792. planId: vm.planId, //计划id
  793. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  794. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  795. }
  796. rehaAPI.calendarPlanDetailItems(params).then(function (res) {
  797. if (res.status == 200) {
  798. var arr = []
  799. $.each(res.data, function (i, o) {
  800. if (o.code == '3' && o.type) {
  801. if (o.type == 2) {
  802. o.levelClazz = vm.getLevelClazz(o.value1, 139, 90) || vm.getLevelClazz(o.value2, 89, 60)
  803. o.levelClazz1 = vm.getLevelClazz(o.value1, 139, 90)
  804. o.levelClazz2 = vm.getLevelClazz(o.value2, 89, 60)
  805. o.levelClazz3 = vm.getLevelClazz(o.value3, 100, 60)
  806. } else {
  807. var num = parseInt(o.value2)
  808. var max = normalLevel[num][0],
  809. min = normalLevel[num][1]
  810. o.levelClazz1 = vm.getLevelClazz(o.value1, max, min)
  811. o.levelName = xuetangDuring[o.value2]
  812. }
  813. }
  814. arr.push(o)
  815. })
  816. vm.limitlessItems = arr
  817. }
  818. })
  819. },
  820. getLevelClazz: function (value, max, min) {
  821. if (!value || (!max && !min)) {
  822. return ''
  823. }
  824. var value = parseFloat(value)
  825. if (value < min) {
  826. return 'low'
  827. } else if (value > max) {
  828. return 'high'
  829. } else {
  830. return ''
  831. }
  832. },
  833. getNormalLevel: function (index) {
  834. return [[], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4]][index]
  835. },
  836. confirmSearch: function () {
  837. this.changeSearch(-1)
  838. this.goToLoadData(true)
  839. },
  840. changeSearch: function (status) {
  841. var i = status == 1 ? -400 : 0
  842. var timer1 = setInterval(function () {
  843. i += 5 * status
  844. $('.search-left').css('right', i + 'px')
  845. if (status == 1 && i >= 0) {
  846. clearInterval(timer1)
  847. }
  848. if (status == -1 && i <= -400) {
  849. clearInterval(timer1)
  850. }
  851. }, 5)
  852. },
  853. //邀请视频聊天
  854. openVideoChat: function (otherDoc) {
  855. var vm = this
  856. var loading = layer.load(0)
  857. var participants = []
  858. var participantsMobile = {}
  859. //发起人
  860. participants.push({ mobile: docInfo.mobile, name: docInfo.name, sex: docInfo.sex == 1 ? 1 : 2, birthdate: '', level: 3, hospital_name: docInfo.hospitalName, idcard: '' })
  861. participantsMobile[docInfo.mobile] = 1
  862. if (otherDoc) {
  863. //被邀请人
  864. participants.push({
  865. mobile: otherDoc.doctorMobile,
  866. name: otherDoc.doctorName,
  867. sex: otherDoc.doctorSex == 1 ? 1 : 2,
  868. birthdate: '',
  869. level: 3,
  870. hospital_name: otherDoc.doctorHospitalName,
  871. idcard: otherDoc.doctorIdcard
  872. })
  873. participantsMobile[otherDoc.doctorMobile] = 0
  874. }
  875. videoChatAPI
  876. .addDoctor({ participants: JSON.stringify(participants) })
  877. .then(function (res) {
  878. if (res.status == 200) {
  879. videoChatAPI
  880. .sessions({
  881. sessionId: httpRequest.uuid(24, 16),
  882. sessionType: 4,
  883. sessionName: vm.planInfo.patientName + '的远程门诊',
  884. participants: JSON.stringify(participantsMobile),
  885. videoconferencing: 1,
  886. idcard: vm.planInfo.idcard
  887. })
  888. .then(function (res1) {
  889. layer.close(loading)
  890. if (res1.status == 200) {
  891. layer.msg('发起会话成功', { icon: 6 })
  892. } else {
  893. layer.msg('发起会话失败', { icon: 5 })
  894. }
  895. })
  896. .catch(function () {
  897. layer.close(loading)
  898. layer.msg('系统繁忙', { icon: 5 })
  899. })
  900. } else {
  901. layer.close(loading)
  902. layer.msg(res.msg, { icon: 5 })
  903. }
  904. })
  905. .catch(function () {
  906. layer.close(loading)
  907. layer.msg('系统繁忙', { icon: 5 })
  908. })
  909. }
  910. },
  911. watch: {
  912. tabStatus: function () {
  913. this.goToLoadData()
  914. }
  915. }
  916. })
  917. })()