血透系统pad前端

DialysisArea.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <div>
  3. <div v-loading="loading">
  4. <div class="screening">
  5. <ul>
  6. <el-popover
  7. v-model="zone_options_visible"
  8. placement="bottom"
  9. trigger="click"
  10. >
  11. <li slot="reference">
  12. {{
  13. zones.length <= 1 && zone_selected > 0
  14. ? "全部分区"
  15. : zones[zone_selected].text
  16. }}
  17. <span class="iconfont">&#xe74a;</span>
  18. </li>
  19. <div class="popover-demo-content">
  20. <ul>
  21. <li
  22. v-for="(zone, index) in zones"
  23. :key="zone.value"
  24. @click="handleZoneChange(index)"
  25. :class="zone_selected == index ? 'tick' : ''"
  26. >
  27. {{ zone.text }}
  28. </li>
  29. </ul>
  30. </div>
  31. </el-popover>
  32. <el-popover
  33. v-model="sch_type_options_visible"
  34. placement="bottom"
  35. trigger="click"
  36. >
  37. <li slot="reference">
  38. {{ schedual_types[schedual_type_selected].text }}
  39. <span class="iconfont">&#xe74a;</span>
  40. </li>
  41. <div class="popover-demo-content">
  42. <ul>
  43. <li
  44. v-for="schedualType in schedual_types"
  45. :key="schedualType.value"
  46. @click="handletimeType(schedualType.value)"
  47. :class="
  48. schedual_type_selected == schedualType.value ? 'tick' : ''
  49. "
  50. >
  51. {{ schedualType.text }}
  52. </li>
  53. </ul>
  54. </div>
  55. </el-popover>
  56. <li @click="openPicker()">
  57. {{ selected_date_str }}
  58. <span class="iconfont">&#xe74a;</span>
  59. </li>
  60. <li @click="mypatient()" :class="newMypatient == 1 ? 'active' : ''">
  61. 我的病人
  62. </li>
  63. </ul>
  64. </div>
  65. <div class="stateBox">
  66. <div v-for="(item, index) in filtedScheduals" :key="index">
  67. <h2 class="title">{{ item.zone_name }}</h2>
  68. <patient-box
  69. class="clearfix"
  70. :patients="item.scheduals"
  71. ></patient-box>
  72. </div>
  73. <div class="NoData" v-if="filtedScheduals.length == 0 && networkStates">
  74. <img
  75. style="margin-top: 50px; margin-bottom: 50px"
  76. src="@/assets/login/data.jpg"
  77. alt
  78. />
  79. </div>
  80. <div
  81. class="NoData"
  82. v-if="!networkStates"
  83. style="display: block;text-align: center"
  84. >
  85. <p style="margin-top: 100px;font-size: 18px">
  86. 网络异常,请点击重新加载
  87. </p>
  88. <!--<img style="margin-top: 50px; margin-bottom: 50px" src="@/assets/login/no_network.jpg" alt="">-->
  89. <van-button
  90. slot="button"
  91. size="normal"
  92. type="info"
  93. style="display:block;margin:0 auto"
  94. @click="reloads()"
  95. >重新加载</van-button
  96. >
  97. </div>
  98. </div>
  99. <mt-datetime-picker
  100. v-model="selected_date"
  101. ref="picker"
  102. type="date"
  103. year-format="{value} "
  104. month-format="{value} "
  105. date-format="{value} "
  106. @confirm="handleScheduleDateChange"
  107. ></mt-datetime-picker>
  108. </div>
  109. </div>
  110. </template>
  111. <script>
  112. import PatientBox from "./PatientBox";
  113. import { Popover } from "vux";
  114. import { Datetime } from "vux";
  115. import { parseTime } from "@/utils/index";
  116. import { getDialysisScheduals } from "@/api/dialysis";
  117. import { Toast } from "vant";
  118. import $ from "jquery";
  119. export default {
  120. name: "DialysisArea",
  121. components: {
  122. PatientBox,
  123. Popover,
  124. Datetime
  125. },
  126. inject: ["reload"],
  127. data() {
  128. return {
  129. loading: false,
  130. user_id: 0,
  131. networkStates: true,
  132. timer: null,
  133. ismypatient: this.$store.getters.app.dialysis_area.ismypatient,
  134. selected_date: this.$store.getters.app.dialysis_area.schedule_date, // new Date(),
  135. schedual_types: [
  136. { value: 0, text: "全部班", select: true },
  137. { value: 1, text: "上午", select: false },
  138. { value: 2, text: "下午", select: false },
  139. { value: 3, text: "晚上", select: false }
  140. ],
  141. schedual_type_selected: this.$store.getters.app.dialysis_area
  142. .schedule_type_select_index,
  143. zone_selected: this.$store.getters.app.dialysis_area.zone_select_index,
  144. zones: [{ value: 0, text: "全部分区", select: true }],
  145. dialysis_scheduals: [],
  146. zone_options_visible: false,
  147. sch_type_options_visible: false,
  148. newMypatient: 0
  149. };
  150. },
  151. props: {
  152. search_keyword: {
  153. type: String,
  154. default: ""
  155. }
  156. },
  157. computed: {
  158. selected_date_str: function() {
  159. return parseTime(this.selected_date, "{y}-{m}-{d}");
  160. },
  161. filtedScheduals: function() {
  162. if (this.dialysis_scheduals.length == 0) {
  163. return [];
  164. }
  165. var search_keyword = this.search_keyword;
  166. if (search_keyword.length > 0) {
  167. var schedules = [];
  168. for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
  169. const scheduleInfo = this.dialysis_scheduals[o_i];
  170. var originSchedules = scheduleInfo.scheduals;
  171. if (originSchedules.length == 0) {
  172. continue;
  173. }
  174. var filtedSchedules = [];
  175. for (let s_i = 0; s_i < originSchedules.length; s_i++) {
  176. const schedule = originSchedules[s_i];
  177. if (
  178. schedule.patient.name.indexOf(search_keyword) != -1 ||
  179. schedule.patient.dialysis_no.indexOf(search_keyword) != -1
  180. ) {
  181. filtedSchedules.push(schedule);
  182. break;
  183. }
  184. }
  185. if (filtedSchedules.length > 0) {
  186. schedules.push({
  187. zone_name: scheduleInfo.zone_name,
  188. scheduals: filtedSchedules
  189. });
  190. }
  191. }
  192. return schedules;
  193. }
  194. if (this.ismypatient) {
  195. var zone_selected = this.zone_selected;
  196. var timetype_selected = this.schedual_type_selected;
  197. var zone_name =
  198. zone_selected == 0 ? "" : this.zones[zone_selected].text;
  199. var schedules = [];
  200. for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
  201. const scheduleInfo = this.dialysis_scheduals[o_i];
  202. var originSchedules = scheduleInfo.scheduals;
  203. if (originSchedules.length == 0) {
  204. continue;
  205. }
  206. var filtedSchedules = [];
  207. for (let s_i = 0; s_i < originSchedules.length; s_i++) {
  208. const schedule = originSchedules[s_i];
  209. if (schedule.dialysis_order.start_nurse == this.user_id) {
  210. if (
  211. zone_name.length == 0 ||
  212. (zone_name.length > 0 &&
  213. zone_name == schedule.device_number.zone.name)
  214. ) {
  215. if (
  216. timetype_selected == 0 ||
  217. schedule.schedule_type == timetype_selected
  218. ) {
  219. filtedSchedules.push(schedule);
  220. }
  221. }
  222. // break;
  223. }
  224. }
  225. if (filtedSchedules.length > 0) {
  226. schedules.push({
  227. zone_name: scheduleInfo.zone_name,
  228. scheduals: filtedSchedules
  229. });
  230. }
  231. }
  232. return schedules;
  233. }
  234. var zone_selected = this.zone_selected;
  235. var timetype_selected = this.schedual_type_selected;
  236. if (
  237. (zone_selected == 0 && timetype_selected == 0) ||
  238. this.zones.length <= 1
  239. ) {
  240. return this.dialysis_scheduals;
  241. }
  242. var zone_name = zone_selected == 0 ? "" : this.zones[zone_selected].text;
  243. var schedules = [];
  244. for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
  245. const scheduleInfo = this.dialysis_scheduals[o_i];
  246. var originSchedules = scheduleInfo.scheduals;
  247. var filtedSchedules = [];
  248. for (let s_i = 0; s_i < originSchedules.length; s_i++) {
  249. const schedule = originSchedules[s_i];
  250. if (this.ismypatient) {
  251. if (schedule.dialysis_order.creator == this.user_id) {
  252. filtedSchedules.push(schedule);
  253. }
  254. } else {
  255. if (
  256. zone_name.length == 0 ||
  257. (zone_name.length > 0 &&
  258. zone_name == schedule.device_number.zone.name)
  259. ) {
  260. if (
  261. timetype_selected == 0 ||
  262. schedule.schedule_type == timetype_selected
  263. ) {
  264. filtedSchedules.push(schedule);
  265. }
  266. }
  267. }
  268. }
  269. if (filtedSchedules.length > 0) {
  270. schedules.push({
  271. zone_name: scheduleInfo.zone_name,
  272. scheduals: filtedSchedules
  273. });
  274. }
  275. }
  276. this.ismypatient = false;
  277. return schedules;
  278. }
  279. },
  280. created() {
  281. this.user_id = this.$store.getters.user.user.id;
  282. var storedata = this.$store.getters.scheduals;
  283. var scheduals = storedata.scheduals;
  284. if (Object.keys(storedata).length > 0) {
  285. var zoneMap = {};
  286. var schedualMap = {};
  287. for (let index = 0; index < scheduals.length; index++) {
  288. const schedual = scheduals[index];
  289. if (schedual.dialysis_order == null) {
  290. continue;
  291. }
  292. if (schedualMap[schedual.device_number.zone.name] == null) {
  293. schedualMap[schedual.device_number.zone.name] = [];
  294. }
  295. schedualMap[schedual.device_number.zone.name].push(schedual);
  296. if (zoneMap[schedual.device_number.zone.name] == null) {
  297. zoneMap[schedual.device_number.zone.name] =
  298. schedual.device_number.zone;
  299. }
  300. }
  301. var zones = [];
  302. zones.push({ value: 0, text: "全部分区" });
  303. for (var zoneName in zoneMap) {
  304. zones.push({ value: zoneMap[zoneName].id, text: zoneName });
  305. }
  306. zones = zones.sort(function(a, b) {
  307. return a.value > b.value;
  308. });
  309. this.zones = zones;
  310. var dialysis_scheduals = [];
  311. for (let index = 0; index < zones.length; index++) {
  312. const zone = zones[index];
  313. var scheduals = schedualMap[zone.text];
  314. if (scheduals == null) {
  315. continue;
  316. }
  317. dialysis_scheduals.push({
  318. zone_name: zone.text,
  319. scheduals: scheduals
  320. });
  321. }
  322. this.dialysis_scheduals = dialysis_scheduals;
  323. } else {
  324. this.requestDialysisScheduals();
  325. }
  326. },
  327. mounted() {
  328. this.timer = window.setInterval(() => {
  329. setTimeout(this.requestDialysisScheduals(), 0);
  330. }, 120000);
  331. },
  332. beforeDestroy() {
  333. clearInterval(this.timer);
  334. this.timer = null;
  335. },
  336. methods: {
  337. clearPatient() {
  338. this.search_keyword = "";
  339. this.ismypatient = false;
  340. this.$emit("clear_search_keyword");
  341. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  342. zone: this.zone_selected,
  343. schedule_type: this.schedual_type_selected,
  344. schedule_date: this.selected_date,
  345. ismypatient: this.ismypatient
  346. });
  347. },
  348. mypatient() {
  349. this.search_keyword = "";
  350. this.ismypatient = true;
  351. this.$emit("clear_search_keyword");
  352. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  353. zone: this.zone_selected,
  354. schedule_type: this.schedual_type_selected,
  355. schedule_date: this.selected_date,
  356. ismypatient: this.ismypatient
  357. });
  358. this.newMypatient = 1;
  359. },
  360. reloads: function() {
  361. this.reload();
  362. },
  363. handletimeType: function(index) {
  364. if (!this.ismypatient) {
  365. this.ismypatient = false;
  366. }
  367. this.sch_type_options_visible = false;
  368. this.schedual_type_selected = index;
  369. this.$emit("clear_search_keyword");
  370. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  371. zone: this.zone_selected,
  372. schedule_type: this.schedual_type_selected,
  373. schedule_date: this.selected_date,
  374. ismypatient: this.ismypatient
  375. });
  376. },
  377. handleZoneChange: function(index) {
  378. this.ismypatient = false;
  379. this.zone_options_visible = false;
  380. this.zone_selected = index;
  381. this.$emit("clear_search_keyword");
  382. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  383. zone: this.zone_selected,
  384. schedule_type: this.schedual_type_selected,
  385. schedule_date: this.selected_date,
  386. ismypatient: this.ismypatient
  387. });
  388. this.newMypatient = 0;
  389. },
  390. handleScheduleDateChange: function(date) {
  391. if (!this.ismypatient) {
  392. this.ismypatient = false;
  393. }
  394. this.zone_selected = 0;
  395. this.schedual_type_selected = 0;
  396. this.$emit("clear_search_keyword");
  397. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  398. zone: this.zone_selected,
  399. schedule_type: this.schedual_type_selected,
  400. schedule_date: this.selected_date,
  401. ismypatient: this.ismypatient
  402. });
  403. this.requestDialysisScheduals();
  404. },
  405. requestDialysisScheduals() {
  406. // this.$toast.loading({forbidClick: true, duration: 0})
  407. // this.loading = true;
  408. var type = 0;
  409. getDialysisScheduals({ type: type, date: this.selected_date_str })
  410. .then(rs => {
  411. this.networkStates = true;
  412. var resp = rs.data;
  413. if (resp.state == 1) {
  414. this.loading = false;
  415. // console.log(resp.data)
  416. var scheduals = resp.data.scheduals;
  417. this.$store.dispatch("SetScheduals", { scheduals: scheduals });
  418. var zoneMap = {};
  419. var schedualMap = {};
  420. for (let index = 0; index < scheduals.length; index++) {
  421. const schedual = scheduals[index];
  422. if (schedual.dialysis_order == null) {
  423. continue;
  424. }
  425. if (schedualMap[schedual.device_number.zone.name] == null) {
  426. schedualMap[schedual.device_number.zone.name] = [];
  427. }
  428. schedualMap[schedual.device_number.zone.name].push(schedual);
  429. if (zoneMap[schedual.device_number.zone.name] == null) {
  430. zoneMap[schedual.device_number.zone.name] =
  431. schedual.device_number.zone;
  432. }
  433. }
  434. var zones = [];
  435. zones.push({ value: 0, text: "全部分区" });
  436. for (var zoneName in zoneMap) {
  437. zones.push({ value: zoneMap[zoneName].id, text: zoneName });
  438. }
  439. zones = zones.sort(function(a, b) {
  440. return a.value > b.value;
  441. });
  442. this.zones = zones;
  443. var dialysis_scheduals = [];
  444. for (let index = 0; index < zones.length; index++) {
  445. const zone = zones[index];
  446. var scheduals = schedualMap[zone.text];
  447. if (scheduals == null) {
  448. continue;
  449. }
  450. dialysis_scheduals.push({
  451. zone_name: zone.text,
  452. scheduals: scheduals
  453. });
  454. }
  455. this.dialysis_scheduals = dialysis_scheduals;
  456. } else {
  457. this.loading = false;
  458. this.$toast({
  459. message: resp.msg
  460. });
  461. }
  462. })
  463. .catch(error => {
  464. this.loading = false;
  465. // 超时之后在这里捕抓错误信息.
  466. if (error.response) {
  467. this.networkStates = false;
  468. console.log("error.response");
  469. console.log(error.response);
  470. } else if (error.request) {
  471. this.networkStates = false;
  472. // if(error.request.readyState == 4 && error.request.status == 0){
  473. // //我在这里重新请求
  474. // this.networkStates = false
  475. // }
  476. } else {
  477. this.networkStates = false;
  478. }
  479. });
  480. },
  481. openPicker() {
  482. this.$refs.picker.open();
  483. this.newMypatient = 0;
  484. }
  485. // getMyPatient () {
  486. // console.log('这是啥', this.zone_options_visible)
  487. // console.log('日期', this.selected_date)
  488. // }
  489. }
  490. };
  491. </script>
  492. <style style="stylesheet/scss" lang="scss" scoped>
  493. .screening {
  494. border-bottom: 1px #e5e5e5 solid;
  495. position: fixed;
  496. top: 100px;
  497. @media only screen and (min-width: 768px) {
  498. top: 163px;
  499. }
  500. @media only screen and (min-width: 415px) and (max-width: 767px) {
  501. top: 134px;
  502. }
  503. // @media only screen and (min-width: 813px) and (max-width: 1024px) {
  504. // top: 130px;
  505. // }
  506. right: 0;
  507. z-index: 66;
  508. left: 0;
  509. background: #fff;
  510. // @media only screen and (max-width: 812px) {
  511. // top: 50px !important;
  512. // }
  513. ul {
  514. @include display-flex;
  515. @include align-items-center;
  516. @include text-align;
  517. @include justify-content-between;
  518. width: 90%;
  519. margin: 0 auto;
  520. li {
  521. font-size: 0.45rem;
  522. padding: 0.3rem 0;
  523. cursor: pointer;
  524. .iconfont {
  525. font-size: 0.45rem;
  526. color: #a8b3ba;
  527. margin-left: 0.1rem;
  528. // @media only screen and (max-width: 768px) {
  529. // font-size: 0.45 !important;
  530. // }
  531. }
  532. }
  533. .active {
  534. position: relative;
  535. &::before {
  536. position: absolute;
  537. bottom: 0;
  538. left: 0;
  539. width: 100%;
  540. height: 2px;
  541. background: $main-color;
  542. // border-bottom: 0.04rem $main-color solid;
  543. content: "";
  544. }
  545. }
  546. }
  547. }
  548. .stateBox {
  549. // padding: 0.26rem 0 0 0.6rem;
  550. // background: #fff;
  551. .title {
  552. font-size: 0.34rem;
  553. font-weight: 600;
  554. color: $title-color;
  555. height: 1rem;
  556. line-height: 0.8rem;
  557. display: inline-block;
  558. }
  559. }
  560. .shadow {
  561. width: 100%;
  562. height: 100%;
  563. position: absolute;
  564. left: 0;
  565. top: 0;
  566. z-index: 998;
  567. background-color: #000;
  568. opacity: 0.6;
  569. display: none;
  570. }
  571. .picker-toolbar {
  572. height: 60px;
  573. }
  574. .mint-datetime-action {
  575. line-height: 60px;
  576. font-size: 0.45rem;
  577. @media only screen and (max-width: 768px) {
  578. line-height: 40px !important;
  579. }
  580. }
  581. </style>