index.vue 9.2KB

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