rehabilitation_management.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  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. console.log(planids, type, item,"item");
  328. if (vm.planInfo.disease == '3' && vm.scList.length == 0 && item && item.code == '6' && vm.loginDoctor.doctorType != '1') {
  329. this.$confirm('提示该居民近一年没有进行冠心病风险评估,请先进行评估,再进行随访登记', '提示', {
  330. confirmButtonText: '确定',
  331. cancelButtonText: '取消',
  332. type: 'warning'
  333. }).then(function () {
  334. vm.gotoSc()
  335. })
  336. return false
  337. }
  338. if (type == 1) {
  339. // 单个服务项
  340. layer.open({
  341. type: 2,
  342. area: ['800px', '700px'],
  343. shade: 0.5,
  344. title: '服务项目内容',
  345. fixed: true, //不固定
  346. maxmin: true,
  347. closeBtn: 1,
  348. shift: 5,
  349. shadeClose: false, //点击遮罩关闭层
  350. content:
  351. '../../rehabilitation/html/guide_the_message.html?planid=' +
  352. planids +
  353. '&pId=' +
  354. httpData['planId'] +
  355. '&patient=' +
  356. vm.patientCode +
  357. '&patientName=' +
  358. vm.planInfo.patientName,
  359. end: function () {
  360. vm.goToLoadData(true)
  361. }
  362. })
  363. return
  364. }
  365. layer.open({
  366. // 康复计划的所有服务项
  367. type: 2,
  368. area: ['800px', '700px'],
  369. shade: 0.5,
  370. title: '服务项目内容',
  371. fixed: true, //不固定
  372. maxmin: true,
  373. closeBtn: 1,
  374. shift: 5,
  375. shadeClose: false, //点击遮罩关闭层
  376. content:
  377. '../../rehabilitation/html/service_item_content.html?planids=' +
  378. planids +
  379. '&planId=' +
  380. httpData['planId'] +
  381. '&patient=' +
  382. vm.patientCode +
  383. '&patientName=' +
  384. vm.planInfo.patientName +
  385. '&disease=' +
  386. vm.planInfo.disease +
  387. '&scLenght=' +
  388. vm.scList.length,
  389. end: function () {
  390. vm.goToLoadData(true)
  391. }
  392. })
  393. },
  394. changeStatus: function (val) {
  395. this.status = val.code
  396. },
  397. changeTask: function (val) {
  398. this.searchTask = val.code
  399. this.searchTaskName = val.name
  400. },
  401. monDetail: function () {
  402. this.currentDay = this.ynow + '年' + (this.mnow + 1) + '月'
  403. this.currentDayForEn = this.ynow + '/' + (this.mnow >= 9 ? this.mnow + 1 : '0' + (this.mnow + 1)) + '/' + (this.dnow >= 9 ? this.dnow : '0' + this.dnow)
  404. },
  405. is_leap: function (year) {
  406. //判断是否为闰年
  407. return year % 100 == 0 ? (res = year % 400 == 0 ? 1 : 0) : (res = year % 4 == 0 ? 1 : 0)
  408. },
  409. preMonth: function () {
  410. //上一个月
  411. if (this.mnow <= 0) {
  412. this.mnow = 11
  413. this.ynow = this.ynow - 1
  414. } else {
  415. this.mnow--
  416. }
  417. this.monDetail()
  418. this.goToLoadData(true)
  419. },
  420. getPreMouth: function () {
  421. var pMnow, pYnow
  422. if (this.mnow <= 0) {
  423. pMnow = 11
  424. pYnow = this.ynow - 1
  425. } else {
  426. pMnow = this.mnow - 1
  427. pYnow = this.ynow
  428. }
  429. var m_days = new Array(31, 28 + this.is_leap(pYnow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  430. return {
  431. days: m_days[pMnow],
  432. date: pYnow + '-' + (++pMnow >= 10 ? pMnow : '0' + pMnow)
  433. }
  434. },
  435. nextMonth: function () {
  436. //下一个月
  437. if (this.mnow >= 11) {
  438. this.mnow = 0
  439. this.ynow = this.ynow + 1
  440. } else {
  441. this.mnow++
  442. }
  443. this.monDetail()
  444. this.goToLoadData(true)
  445. },
  446. getNextMouth: function () {
  447. var nMnow, nYnow
  448. if (this.mnow >= 11) {
  449. nMnow = 0
  450. nYnow = this.ynow + 1
  451. } else {
  452. nMnow = this.mnow + 1
  453. nYnow = this.ynow
  454. }
  455. var m_days = new Array(31, 28 + this.is_leap(nYnow), 31, 30, 31, 01, 31, 31, 30, 31, 30, 31) //每个月的天数
  456. return {
  457. days: m_days[nMnow],
  458. date: nYnow + '-' + (++nMnow >= 10 ? nMnow : '0' + nMnow)
  459. }
  460. },
  461. goToLoadData: function (flag) {
  462. //flag是否更新数据
  463. this.tabStatus == 1 && (!this.calendarData.length || flag) && this.calendar()
  464. this.tabStatus == 2 && (!this.timeAxisData.length || flag) && this.timeAxis()
  465. // this.changeSearch(-1)
  466. },
  467. calendar: function () {
  468. var nlstr = new Date(this.ynow, this.mnow, 1) //当月第一天
  469. var firstday = nlstr.getDay() - 1 //第一天星期几,默认是周日 我们改成周一
  470. firstday = firstday == -1 ? 6 : firstday //如果是-1,说明当月的第一天是周日
  471. var m_days = new Array(31, 28 + this.is_leap(this.ynow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  472. var tr_str = Math.ceil((m_days[this.mnow] + firstday) / 7) //当前月天数+第一天是星期几的数值 获得 表格行数
  473. var c_days = m_days[this.mnow] //当前月份的天数
  474. var p_arr = this.getPreMouth()
  475. var n_arr = this.getNextMouth()
  476. var i, k, idx, date_str
  477. var dataArr = [] //天数/年月
  478. for (i = 0; i < tr_str; i++) {
  479. //表格的行
  480. for (k = 0; k < 7; k++) {
  481. //表格每行的单元格
  482. idx = i * 7 + k //单元格自然序列号
  483. date_str = idx - firstday + 1 //计算日期
  484. var __ym
  485. if (date_str <= 0) {
  486. //过滤无效日期(小于等于零的、大于月总天数的)
  487. date_str = date_str + p_arr['days'] //当前日期+上个月的天数就是上个月的日期
  488. __ym = p_arr['date']
  489. } else if (date_str > c_days) {
  490. date_str = date_str - c_days //下个月的日期就是这个月的天数-当月的天数
  491. __ym = n_arr['date']
  492. } else {
  493. __ym = this.ynow + '-' + (this.mnow >= 9 ? '' : '0') + (this.mnow + 1)
  494. }
  495. dataArr.push({
  496. day: date_str,
  497. date: __ym
  498. })
  499. }
  500. }
  501. this.__Data = dataArr
  502. this.monDetail()
  503. this.calenderPlanDetail()
  504. },
  505. daysSort: function (arr) {
  506. var getArr = JSON.parse(JSON.stringify(arr)),
  507. returnArr = []
  508. for (var i = 1; i < 31; i++) {
  509. for (var j = 0, len = getArr.length; j < len; j++) {
  510. var stri = i > 9 + '' ? i : '0' + i
  511. if (getArr[j].day == stri) {
  512. returnArr.push(getArr[j])
  513. getArr.splice(j, 1)
  514. break
  515. }
  516. }
  517. }
  518. return returnArr
  519. },
  520. // 日历有计划数据处理
  521. planHandleData: function (data, day, mounth) {
  522. var item = data
  523. item.day = day
  524. if (mounth) {
  525. item.mounth = mounth
  526. }
  527. var finishFlag = false
  528. var sFlag = false
  529. var fFlag = false
  530. if (item.specialist) {
  531. if (item.specialist.all == item.specialist.finish) {
  532. sFlag = true
  533. }
  534. } else {
  535. sFlag = true
  536. }
  537. if (item.family) {
  538. if (item.family.all == item.family.finish) {
  539. fFlag = true
  540. }
  541. } else {
  542. fFlag = true
  543. }
  544. finishFlag = sFlag && fFlag
  545. item.finishFlag = finishFlag
  546. return item
  547. },
  548. // 日历请求
  549. calenderPlanDetail: function () {
  550. var vm = this
  551. var __days = vm.__Data
  552. var lastDay = __days.concat().pop().day
  553. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  554. if (vm.searchTask != '' || vm.status != '') {
  555. vm.isFastSearch = true
  556. } else {
  557. vm.isFastSearch = false
  558. }
  559. var params = {
  560. executeStartTime: vm.isFastSearch ? '' : __days[0].date + '-' + __days[0].day + ' 00:00:00', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  561. executeEndTime: vm.isFastSearch ? '' : __days.concat().pop().date + '-' + lastDay + ' 23:59:59', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  562. planId: vm.planId, //计划id
  563. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访)
  564. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  565. }
  566. rehaAPI.calendarPlanDetail(params).then(function (res) {
  567. vm.curTask = vm.searchTask
  568. vm.curTaskName = vm.searchTaskName
  569. vm.calendarData = []
  570. var list = []
  571. if (res.status == 200) {
  572. var data = res.data
  573. // 快速查找
  574. if (vm.isFastSearch) {
  575. vm.searchData = []
  576. var searchData0 = [],
  577. searchData1 = [],
  578. searchData2 = []
  579. for (var setM = 1; setM <= 12; setM++) {
  580. var _setM = setM > 9 ? setM : '0' + setM,
  581. _setY = new Date().getFullYear()
  582. var data0 = [],
  583. data1 = [],
  584. data2 = []
  585. for (var i in data) {
  586. var getY = i.split('-')[0],
  587. getM = i.split('-')[1],
  588. getD = i.split('-')[2]
  589. // 去年
  590. if (_setY - 1 == getY && _setM == getM) {
  591. var item = vm.planHandleData(data[i], getD, getM)
  592. data0.push(item)
  593. data.length && data.splice(i, 1)
  594. } else if (_setY == getY && _setM == getM) {
  595. // 今年
  596. var item = vm.planHandleData(data[i], getD, getM)
  597. data1.push(item)
  598. data.length && data.splice(i, 1)
  599. } else if (_setY + 1 == getY && _setM == getM) {
  600. // 明年
  601. var item = vm.planHandleData(data[i], getD, getM)
  602. data2.push(item)
  603. data.length && data.splice(i, 1)
  604. }
  605. }
  606. if (data0.length) {
  607. var dataSort = vm.daysSort(data0)
  608. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  609. for (var i = 0; i < 7 - addlen; i++) {
  610. dataSort.push({
  611. noService: true
  612. })
  613. }
  614. searchData0.push(dataSort)
  615. }
  616. if (data1.length) {
  617. var dataSort = vm.daysSort(data1)
  618. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  619. for (var i = 0; i < 7 - addlen; i++) {
  620. dataSort.push({
  621. noService: true
  622. })
  623. }
  624. searchData1.push(dataSort)
  625. }
  626. if (data2.length) {
  627. var dataSort = vm.daysSort(data2)
  628. var addlen = (dataSort.length + 1) % 7 ? (dataSort.length + 1) % 7 : 7
  629. for (var i = 0; i < 7 - addlen; i++) {
  630. dataSort.push({
  631. noService: true
  632. })
  633. }
  634. searchData2.push(dataSort)
  635. }
  636. }
  637. if (searchData0.length) {
  638. vm.searchData.push(searchData0)
  639. }
  640. if (searchData1.length) {
  641. vm.searchData.push(searchData1)
  642. }
  643. if (searchData2.length) {
  644. vm.searchData.push(searchData2)
  645. }
  646. return false
  647. }
  648. // 正常日历
  649. var _currentTimeStamp = +new Date(new Date().setHours(0, 0, 0, 0))
  650. for (var i in __days) {
  651. var _key = __days[i].date + '-' + (__days[i].day > 9 ? __days[i].day : '0' + __days[i].day)
  652. var item = {
  653. noService: true,
  654. day: __days[i].day
  655. }
  656. for (var j in data) {
  657. if (_key == j) {
  658. item = vm.planHandleData(data[j], __days[i].day)
  659. data.length && data.splice(j, 1)
  660. break
  661. }
  662. }
  663. var thatTime = +new Date(_key) - 8 * 60 * 60 * 1000
  664. var future = _currentTimeStamp > thatTime ? 0 : _currentTimeStamp == thatTime ? 1 : 2
  665. item.future = future
  666. list.push(item)
  667. // vm.calendarData.push(item);
  668. }
  669. vm.calendarData = _.chunk(list, 7)
  670. }
  671. })
  672. },
  673. // 时间轴请求
  674. timeAxis: function () {
  675. var m_days = new Array(31, 28 + this.is_leap(this.ynow), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) //每个月的天数
  676. var c_days = m_days[this.mnow] //当前月份的天数
  677. var __ym = this.ynow + '-' + (this.mnow >= 9 ? '' : '0') + (this.mnow + 1)
  678. var dataArr = [] //天数/年月
  679. for (; c_days > 0; c_days--) {
  680. dataArr.push({
  681. day: c_days,
  682. date: __ym
  683. })
  684. }
  685. this.__xData = dataArr
  686. this.monDetail()
  687. this.calendarPlanDetailList()
  688. this.calendarPlanDetailItems()
  689. },
  690. //时间轴请求
  691. calendarPlanDetailList: function () {
  692. var vm = this
  693. var __days = vm.__xData
  694. var lastDay = __days.concat().pop().day
  695. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  696. var params = {
  697. executeEndTime: __days[0].date + '-' + __days[0].day + ' 23:59:59', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  698. executeStartTime: __days.concat().pop().date + '-' + lastDay + ' 00:00:00', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  699. planId: vm.planId, //计划id
  700. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  701. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  702. }
  703. rehaAPI.calendarPlanDetailList(params).then(function (res) {
  704. if (res.status == 200) {
  705. // var _currentTimeStamp=+new Date(new Date().setHours(0, 0, 0, 0))
  706. var list =
  707. _.map(res.data || {}, function (o) {
  708. // var _time=o.executeTime.split(' ');
  709. // var thatTime=+new Date(_time[0]);
  710. // var future=_currentTimeStamp>thatTime?0:(_currentTimeStamp==thatTime?1:2);
  711. // (o.status==0 && _currentTimeStamp>thatTime) && (future=-1)
  712. // var _html=o.status==2?'预':(future==-1?'逾':'');
  713. // _html=future==1?'今':_html;
  714. // if(_html=='预') future=3;
  715. var _time = o.executeTime.split(' ')
  716. var _html = ''
  717. var d = new Date(o.execute_time)
  718. if (d.format('yyyy-MM-dd') == new Date().format('yyyy-MM-dd')) {
  719. o.firstSort = '1'
  720. future = 1
  721. _html = '今'
  722. if (o.status) {
  723. o.secondSort = '2'
  724. } else {
  725. o.secondSort = '1'
  726. }
  727. } else if (d > new Date()) {
  728. o.firstSort = '3'
  729. future = 2
  730. if (o.status) {
  731. o.secondSort = '2'
  732. } else {
  733. o.secondSort = '1'
  734. }
  735. } else {
  736. o.firstSort = '2'
  737. future = 0
  738. if (o.status == 0) {
  739. future = -1
  740. _html = '逾'
  741. o.secondSort = '1'
  742. } else {
  743. o.secondSort = '2'
  744. }
  745. }
  746. o.html = _html
  747. o.date = _time[0]
  748. o.time = _time[1]
  749. o.future = future
  750. o.doctorName = o.doctor_name
  751. o.hospitalName = o.hospital_name
  752. return o
  753. }) || []
  754. var nowTime = new Date().getTime()
  755. vm.timeAxisData = _.sortBy(list, function (o) {
  756. return o.firstSort + o.secondSort + nowTime / o.execute_time
  757. })
  758. }
  759. })
  760. },
  761. viewServerItemsDetail: function (o) {
  762. if (o.code == '2') {
  763. showInfoMessage('请从“消息-患者消息列表”中查看患者的康复咨询记录')
  764. return
  765. }
  766. if (o.code == '3') {
  767. layer.open({
  768. type: 2,
  769. area: ['700px', '700px'],
  770. shade: 0.5,
  771. title: '健康记录',
  772. fixed: true, //不固定
  773. maxmin: true,
  774. closeBtn: 1,
  775. // shift: 5,
  776. shadeClose: false, //点击遮罩关闭层
  777. content: '../html/healthMonitor.html?patient=' + this.patientCode
  778. })
  779. return
  780. }
  781. this.serverItemInfo = o
  782. this.showServerItemDetail = true
  783. this.islimit = o.frequency_code ? true : false
  784. },
  785. calendarPlanDetailItems: function () {
  786. var vm = this
  787. var __days = vm.__xData
  788. var lastDay = __days.concat().pop().day
  789. lastDay = lastDay > 9 ? lastDay : '0' + lastDay
  790. var params = {
  791. executeEndTime: __days[0].date + '-' + __days[0].day + ' 23:59:59', //日历开始时间(格式:yyyy-MM-dd HH:mm:ss)
  792. executeStartTime: __days.concat().pop().date + '-' + lastDay + ' 00:00:00', //日历结束时间(格式:yyyy-MM-dd HH:mm:ss)
  793. planId: vm.planId, //计划id
  794. searchTask: vm.searchTask, //快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)
  795. status: vm.status //任务状态(0未完成,1已完成,2已预约)
  796. }
  797. rehaAPI.calendarPlanDetailItems(params).then(function (res) {
  798. if (res.status == 200) {
  799. var arr = []
  800. $.each(res.data, function (i, o) {
  801. if (o.code == '3' && o.type) {
  802. if (o.type == 2) {
  803. o.levelClazz = vm.getLevelClazz(o.value1, 139, 90) || vm.getLevelClazz(o.value2, 89, 60)
  804. o.levelClazz1 = vm.getLevelClazz(o.value1, 139, 90)
  805. o.levelClazz2 = vm.getLevelClazz(o.value2, 89, 60)
  806. o.levelClazz3 = vm.getLevelClazz(o.value3, 100, 60)
  807. } else {
  808. var num = parseInt(o.value2)
  809. var max = normalLevel[num][0],
  810. min = normalLevel[num][1]
  811. o.levelClazz1 = vm.getLevelClazz(o.value1, max, min)
  812. o.levelName = xuetangDuring[o.value2]
  813. }
  814. }
  815. arr.push(o)
  816. })
  817. vm.limitlessItems = arr
  818. }
  819. })
  820. },
  821. getLevelClazz: function (value, max, min) {
  822. if (!value || (!max && !min)) {
  823. return ''
  824. }
  825. var value = parseFloat(value)
  826. if (value < min) {
  827. return 'low'
  828. } else if (value > max) {
  829. return 'high'
  830. } else {
  831. return ''
  832. }
  833. },
  834. getNormalLevel: function (index) {
  835. return [[], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4], [11.1, 4], [7, 4]][index]
  836. },
  837. confirmSearch: function () {
  838. this.changeSearch(-1)
  839. this.goToLoadData(true)
  840. },
  841. changeSearch: function (status) {
  842. var i = status == 1 ? -400 : 0
  843. var timer1 = setInterval(function () {
  844. i += 5 * status
  845. $('.search-left').css('right', i + 'px')
  846. if (status == 1 && i >= 0) {
  847. clearInterval(timer1)
  848. }
  849. if (status == -1 && i <= -400) {
  850. clearInterval(timer1)
  851. }
  852. }, 5)
  853. },
  854. //邀请视频聊天
  855. openVideoChat: function (otherDoc) {
  856. var vm = this
  857. var loading = layer.load(0)
  858. var participants = []
  859. var participantsMobile = {}
  860. //发起人
  861. participants.push({ mobile: docInfo.mobile, name: docInfo.name, sex: docInfo.sex == 1 ? 1 : 2, birthdate: '', level: 3, hospital_name: docInfo.hospitalName, idcard: '' })
  862. participantsMobile[docInfo.mobile] = 1
  863. if (otherDoc) {
  864. //被邀请人
  865. participants.push({
  866. mobile: otherDoc.doctorMobile,
  867. name: otherDoc.doctorName,
  868. sex: otherDoc.doctorSex == 1 ? 1 : 2,
  869. birthdate: '',
  870. level: 3,
  871. hospital_name: otherDoc.doctorHospitalName,
  872. idcard: otherDoc.doctorIdcard
  873. })
  874. participantsMobile[otherDoc.doctorMobile] = 0
  875. }
  876. videoChatAPI
  877. .addDoctor({ participants: JSON.stringify(participants) })
  878. .then(function (res) {
  879. if (res.status == 200) {
  880. videoChatAPI
  881. .sessions({
  882. sessionId: httpRequest.uuid(24, 16),
  883. sessionType: 4,
  884. sessionName: vm.planInfo.patientName + '的远程门诊',
  885. participants: JSON.stringify(participantsMobile),
  886. videoconferencing: 1,
  887. idcard: vm.planInfo.idcard
  888. })
  889. .then(function (res1) {
  890. layer.close(loading)
  891. if (res1.status == 200) {
  892. layer.msg('发起会话成功', { icon: 6 })
  893. } else {
  894. layer.msg('发起会话失败', { icon: 5 })
  895. }
  896. })
  897. .catch(function () {
  898. layer.close(loading)
  899. layer.msg('系统繁忙', { icon: 5 })
  900. })
  901. } else {
  902. layer.close(loading)
  903. layer.msg(res.msg, { icon: 5 })
  904. }
  905. })
  906. .catch(function () {
  907. layer.close(loading)
  908. layer.msg('系统繁忙', { icon: 5 })
  909. })
  910. }
  911. },
  912. watch: {
  913. tabStatus: function () {
  914. this.goToLoadData()
  915. }
  916. }
  917. })
  918. })()