index.vue 8.9KB

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