index.vue 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="mainBox">
  3. <div class="newBox">
  4. <div class="mainContent">
  5. <record-page
  6. @refAdvice="refAdvice"
  7. :un_read_wait_num="unReadWaitNum"
  8. :un_read_dialysis_num="unReadDialysisNum"
  9. ></record-page>
  10. </div>
  11. <side-bar :active_index="0" :total_read_dot="readNum"></side-bar>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import RecordPage from "./RecordPage";
  17. import SideBar from "@/pages/layout/SideBar";
  18. import { getDialysisScheduals, getWaitingScheduals } from "@/api/dialysis";
  19. import { parseTime } from "@/utils/index";
  20. export default {
  21. name: "Main",
  22. data() {
  23. return {
  24. timer: null,
  25. scheduals: [],
  26. advice_groups: [],
  27. unReadWaitNum: 0,
  28. unReadDialysisNum: 0
  29. };
  30. },
  31. components: {
  32. RecordPage,
  33. SideBar
  34. },
  35. created() {
  36. // this.requestScheduals()
  37. // this.requestDialysisScheduals()
  38. },
  39. mounted() {
  40. // console.log("更新")
  41. // this.timer = window.setInterval(() => {
  42. // setTimeout(this.requestScheduals(), 0)
  43. // }, 10000)
  44. // this.timerDia = window.setInterval(() => {
  45. // setTimeout(this.requestDialysisScheduals(), 0)
  46. // }, 10000)
  47. },
  48. // beforeDestroy () {
  49. // clearInterval(this.timer)
  50. // this.timer = null
  51. // this.$once('hook:beforeDestroy', () => {
  52. // clearInterval(this.timer)
  53. // })
  54. // clearInterval(this.timerDia)
  55. // this.timerDia = null
  56. // this.$once('hook:beforeDestroy', () => {
  57. // clearInterval(this.timerDia)
  58. // })
  59. // },
  60. methods: {
  61. refAdvice() {
  62. this.requestScheduals();
  63. this.requestDialysisScheduals();
  64. },
  65. requestScheduals() {
  66. var storedata = this.$store.getters.waitscheduals;
  67. var scheduals = storedata.waitscheduals;
  68. if (Object.keys(storedata).length > 0) {
  69. this.scheduals = scheduals;
  70. console.log(this.scheduals);
  71. let doctorAdvice = [];
  72. for (let i = 0; i < this.scheduals.length; i++) {
  73. for (let y = 0; y < this.scheduals[i].doctor_advice.length; y++) {
  74. if (this.scheduals[i].dialysis_order == null) {
  75. if (this.scheduals[i].doctor_advice[y].execution_state == 2) {
  76. doctorAdvice.push(this.scheduals[i].doctor_advice[y]);
  77. }
  78. }
  79. }
  80. }
  81. const sorted = this.groupBy(doctorAdvice, function(item) {
  82. return [item.groupno];
  83. });
  84. this.unReadWaitNum = sorted.length;
  85. }
  86. // else {
  87. // var date = parseTime(Date.parse(new Date()), '{y}-{m}-{d}')
  88. // getWaitingScheduals({ date: date }).then(rs => {
  89. // var resp = rs.data
  90. // this.$store.dispatch('SetRequestScheduals', { resp })
  91. // // console.log(resp);
  92. // if (resp.state == 1) {
  93. // var scheduals = resp.data.scheduals
  94. // this.scheduals = scheduals
  95. // console.log(this.scheduals)
  96. // let doctorAdvice = []
  97. // for (let i = 0; i < this.scheduals.length; i++) {
  98. // for (let y = 0; y < this.scheduals[i].doctor_advice.length; y++) {
  99. // if (this.scheduals[i].dialysis_order == null) {
  100. // if (this.scheduals[i].doctor_advice[y].execution_state == 2) {
  101. // doctorAdvice.push(this.scheduals[i].doctor_advice[y])
  102. // }
  103. // }
  104. // }
  105. // }
  106. // const sorted = this.groupBy(doctorAdvice, function (item) {
  107. // return [item.groupno]
  108. // })
  109. // this.unReadWaitNum = sorted.length
  110. // } else {
  111. // this.$toast({
  112. // message: resp.msg
  113. // })
  114. // }
  115. // })
  116. // }
  117. },
  118. requestDialysisScheduals() {
  119. var storedata = this.$store.getters.scheduals;
  120. var scheduals = storedata.scheduals;
  121. if (Object.keys(storedata).length > 0) {
  122. let doctorAdvice = [];
  123. for (let index = 0; index < scheduals.length; index++) {
  124. const schedual = scheduals[index];
  125. if (schedual.dialysis_order == null) {
  126. continue;
  127. }
  128. for (let y = 0; y < schedual.doctor_advice.length; y++) {
  129. if (schedual.doctor_advice[y].execution_state == 2) {
  130. doctorAdvice.push(schedual.doctor_advice[y]);
  131. }
  132. }
  133. }
  134. const sorted = this.groupBy(doctorAdvice, function(item) {
  135. return [item.groupno];
  136. });
  137. this.unReadDialysisNum = sorted.length;
  138. }
  139. // else {
  140. // var date = this.$store.getters.app.dialysis_area.schedule_date
  141. // var type = 0
  142. // getDialysisScheduals({
  143. // type: type,
  144. // date: parseTime(date, '{y}-{m}-{d}')
  145. // })
  146. // .then(rs => {
  147. // var resp = rs.data
  148. // this.$store.dispatch('SetRequestDialysisScheduals', { resp })
  149. // if (resp.state == 1) {
  150. // var scheduals = resp.data.scheduals
  151. // let doctorAdvice = []
  152. // for (let index = 0; index < scheduals.length; index++) {
  153. // const schedual = scheduals[index]
  154. // if (schedual.dialysis_order == null) {
  155. // continue
  156. // }
  157. // for (let y = 0; y < schedual.doctor_advice.length; y++) {
  158. // if (schedual.doctor_advice[y].execution_state == 2) {
  159. // doctorAdvice.push(schedual.doctor_advice[y])
  160. // }
  161. // }
  162. // }
  163. // const sorted = this.groupBy(doctorAdvice, function (item) {
  164. // return [item.groupno]
  165. // })
  166. // this.unReadDialysisNum = sorted.length
  167. // } else {
  168. // this.$toast({
  169. // message: resp.msg
  170. // })
  171. // }
  172. // })
  173. // .catch(v => {})
  174. // }
  175. },
  176. groupBy(array, f) {
  177. const groups = {};
  178. array.forEach(function(o) {
  179. const group = JSON.stringify(f(o));
  180. groups[group] = groups[group] || [];
  181. groups[group].push(o);
  182. });
  183. return Object.keys(groups).map(function(group) {
  184. return groups[group];
  185. });
  186. },
  187. getData() {
  188. console.log("111111");
  189. // this.requestScheduals()
  190. // this.requestDialysisScheduals()
  191. }
  192. },
  193. computed: {
  194. readNum: function() {
  195. return this.unReadWaitNum + this.unReadDialysisNum;
  196. }
  197. }
  198. };
  199. </script>
  200. <style style="stylesheet/scss" lang="scss" scoped>
  201. html,
  202. body {
  203. height: 100%;
  204. }
  205. .mainBox {
  206. height: 100%;
  207. font-size: 0.3rem;
  208. .sideColumn {
  209. .column {
  210. .head {
  211. @include display-flex;
  212. @include align-items-center;
  213. @include flex-direction;
  214. @include text-align;
  215. @include justify-content-center;
  216. margin: 0.5rem 0 0.5rem 0;
  217. img {
  218. width: 100%;
  219. height: 100%;
  220. border-radius: 0.5rem;
  221. width: 0.7rem;
  222. height: 0.7rem;
  223. }
  224. }
  225. .sidebar {
  226. @include display-flex;
  227. @include align-items-center;
  228. @include flex-direction;
  229. @include text-align;
  230. padding: 0;
  231. li {
  232. padding: 0 0 0.8rem 0;
  233. a {
  234. color: #a8b3ba;
  235. display: inline-block;
  236. padding: 0;
  237. margin: 0;
  238. p {
  239. font-size: 0.24rem;
  240. margin-top: 0.2rem;
  241. }
  242. .iconfont {
  243. font-size: 0.5rem;
  244. display: inline-block;
  245. }
  246. }
  247. &.active {
  248. a {
  249. color: #409eff;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. .mainContent {
  258. // margin: 0 0 0 1.58rem;
  259. }
  260. .newBox {
  261. display: flex;
  262. flex-direction: column;
  263. height: 100%;
  264. overflow: hidden;
  265. > :first-child {
  266. flex: 1;
  267. overflow: auto;
  268. }
  269. }
  270. </style>