血透系统pad前端

DialysisArea.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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. };
  149. },
  150. props: {
  151. search_keyword: {
  152. type: String,
  153. default: ""
  154. }
  155. },
  156. computed: {
  157. selected_date_str: function() {
  158. return parseTime(this.selected_date, "{y}-{m}-{d}");
  159. },
  160. filtedScheduals: function() {
  161. if (this.dialysis_scheduals.length == 0) {
  162. return [];
  163. }
  164. var search_keyword = this.search_keyword;
  165. if (search_keyword.length > 0) {
  166. var schedules = [];
  167. for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
  168. const scheduleInfo = this.dialysis_scheduals[o_i];
  169. var originSchedules = scheduleInfo.scheduals;
  170. if (originSchedules.length == 0) {
  171. continue;
  172. }
  173. var filtedSchedules = [];
  174. for (let s_i = 0; s_i < originSchedules.length; s_i++) {
  175. const schedule = originSchedules[s_i];
  176. if (
  177. schedule.patient.name.indexOf(search_keyword) != -1 ||
  178. schedule.patient.dialysis_no.indexOf(search_keyword) != -1
  179. ) {
  180. filtedSchedules.push(schedule);
  181. break;
  182. }
  183. }
  184. if (filtedSchedules.length > 0) {
  185. schedules.push({
  186. zone_name: scheduleInfo.zone_name,
  187. scheduals: filtedSchedules
  188. });
  189. }
  190. }
  191. return schedules;
  192. }
  193. if (this.ismypatient) {
  194. var zone_selected = this.zone_selected;
  195. var timetype_selected = this.schedual_type_selected;
  196. var zone_name =
  197. zone_selected == 0 ? "" : this.zones[zone_selected].text;
  198. var schedules = [];
  199. for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
  200. const scheduleInfo = this.dialysis_scheduals[o_i];
  201. var originSchedules = scheduleInfo.scheduals;
  202. if (originSchedules.length == 0) {
  203. continue;
  204. }
  205. var filtedSchedules = [];
  206. for (let s_i = 0; s_i < originSchedules.length; s_i++) {
  207. const schedule = originSchedules[s_i];
  208. if (schedule.dialysis_order.start_nurse == this.user_id) {
  209. if (
  210. zone_name.length == 0 ||
  211. (zone_name.length > 0 &&
  212. zone_name == schedule.device_number.zone.name)
  213. ) {
  214. if (
  215. timetype_selected == 0 ||
  216. schedule.schedule_type == timetype_selected
  217. ) {
  218. filtedSchedules.push(schedule);
  219. }
  220. }
  221. // break;
  222. }
  223. }
  224. if (filtedSchedules.length > 0) {
  225. schedules.push({
  226. zone_name: scheduleInfo.zone_name,
  227. scheduals: filtedSchedules
  228. });
  229. }
  230. }
  231. return schedules;
  232. }
  233. var zone_selected = this.zone_selected;
  234. var timetype_selected = this.schedual_type_selected;
  235. if (
  236. (zone_selected == 0 && timetype_selected == 0) ||
  237. this.zones.length <= 1
  238. ) {
  239. return this.dialysis_scheduals;
  240. }
  241. var zone_name = zone_selected == 0 ? "" : this.zones[zone_selected].text;
  242. var schedules = [];
  243. for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
  244. const scheduleInfo = this.dialysis_scheduals[o_i];
  245. var originSchedules = scheduleInfo.scheduals;
  246. var filtedSchedules = [];
  247. for (let s_i = 0; s_i < originSchedules.length; s_i++) {
  248. const schedule = originSchedules[s_i];
  249. if (this.ismypatient) {
  250. if (schedule.dialysis_order.creator == this.user_id) {
  251. filtedSchedules.push(schedule);
  252. }
  253. } else {
  254. if (
  255. zone_name.length == 0 ||
  256. (zone_name.length > 0 &&
  257. zone_name == schedule.device_number.zone.name)
  258. ) {
  259. if (
  260. timetype_selected == 0 ||
  261. schedule.schedule_type == timetype_selected
  262. ) {
  263. filtedSchedules.push(schedule);
  264. }
  265. }
  266. }
  267. }
  268. if (filtedSchedules.length > 0) {
  269. schedules.push({
  270. zone_name: scheduleInfo.zone_name,
  271. scheduals: filtedSchedules
  272. });
  273. }
  274. }
  275. this.ismypatient = false;
  276. return schedules;
  277. }
  278. },
  279. created() {
  280. this.user_id = this.$store.getters.user.user.id;
  281. var storedata = this.$store.getters.scheduals;
  282. var scheduals = storedata.scheduals;
  283. if (Object.keys(storedata).length > 0) {
  284. var zoneMap = {};
  285. var schedualMap = {};
  286. for (let index = 0; index < scheduals.length; index++) {
  287. const schedual = scheduals[index];
  288. if (schedual.dialysis_order == null) {
  289. continue;
  290. }
  291. if (schedualMap[schedual.device_number.zone.name] == null) {
  292. schedualMap[schedual.device_number.zone.name] = [];
  293. }
  294. schedualMap[schedual.device_number.zone.name].push(schedual);
  295. if (zoneMap[schedual.device_number.zone.name] == null) {
  296. zoneMap[schedual.device_number.zone.name] =
  297. schedual.device_number.zone;
  298. }
  299. }
  300. var zones = [];
  301. zones.push({ value: 0, text: "全部分区" });
  302. for (var zoneName in zoneMap) {
  303. zones.push({ value: zoneMap[zoneName].id, text: zoneName });
  304. }
  305. zones = zones.sort(function(a, b) {
  306. return a.value > b.value;
  307. });
  308. this.zones = zones;
  309. var dialysis_scheduals = [];
  310. for (let index = 0; index < zones.length; index++) {
  311. const zone = zones[index];
  312. var scheduals = schedualMap[zone.text];
  313. if (scheduals == null) {
  314. continue;
  315. }
  316. dialysis_scheduals.push({
  317. zone_name: zone.text,
  318. scheduals: scheduals
  319. });
  320. }
  321. this.dialysis_scheduals = dialysis_scheduals;
  322. } else {
  323. this.requestDialysisScheduals();
  324. }
  325. },
  326. mounted() {
  327. this.timer = window.setInterval(() => {
  328. setTimeout(this.requestDialysisScheduals(), 0);
  329. }, 30000);
  330. },
  331. beforeDestroy() {
  332. clearInterval(this.timer);
  333. this.timer = null;
  334. },
  335. methods: {
  336. clearPatient() {
  337. this.search_keyword = "";
  338. this.ismypatient = false;
  339. this.$emit("clear_search_keyword");
  340. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  341. zone: this.zone_selected,
  342. schedule_type: this.schedual_type_selected,
  343. schedule_date: this.selected_date,
  344. ismypatient: this.ismypatient
  345. });
  346. },
  347. mypatient() {
  348. this.search_keyword = "";
  349. this.ismypatient = true;
  350. this.$emit("clear_search_keyword");
  351. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  352. zone: this.zone_selected,
  353. schedule_type: this.schedual_type_selected,
  354. schedule_date: this.selected_date,
  355. ismypatient: this.ismypatient
  356. });
  357. this.newMypatient = 1;
  358. },
  359. reloads: function() {
  360. this.reload();
  361. },
  362. handletimeType: function(index) {
  363. if (!this.ismypatient) {
  364. this.ismypatient = false;
  365. }
  366. this.sch_type_options_visible = false;
  367. this.schedual_type_selected = index;
  368. this.$emit("clear_search_keyword");
  369. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  370. zone: this.zone_selected,
  371. schedule_type: this.schedual_type_selected,
  372. schedule_date: this.selected_date,
  373. ismypatient: this.ismypatient
  374. });
  375. },
  376. handleZoneChange: function(index) {
  377. this.ismypatient = false;
  378. this.zone_options_visible = false;
  379. this.zone_selected = index;
  380. this.$emit("clear_search_keyword");
  381. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  382. zone: this.zone_selected,
  383. schedule_type: this.schedual_type_selected,
  384. schedule_date: this.selected_date,
  385. ismypatient: this.ismypatient
  386. });
  387. this.newMypatient = 0;
  388. },
  389. handleScheduleDateChange: function(date) {
  390. if (!this.ismypatient) {
  391. this.ismypatient = false;
  392. }
  393. this.zone_selected = 0;
  394. this.schedual_type_selected = 0;
  395. this.$emit("clear_search_keyword");
  396. this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
  397. zone: this.zone_selected,
  398. schedule_type: this.schedual_type_selected,
  399. schedule_date: this.selected_date,
  400. ismypatient: this.ismypatient
  401. });
  402. this.requestDialysisScheduals();
  403. },
  404. requestDialysisScheduals() {
  405. // this.$toast.loading({forbidClick: true, duration: 0})
  406. // this.loading = true;
  407. var type = 0;
  408. getDialysisScheduals({ type: type, date: this.selected_date_str })
  409. .then(rs => {
  410. this.networkStates = true;
  411. var resp = rs.data;
  412. if (resp.state == 1) {
  413. this.loading = false;
  414. // console.log(resp.data)
  415. var scheduals = resp.data.scheduals;
  416. this.$store.dispatch("SetScheduals", { scheduals: scheduals });
  417. var zoneMap = {};
  418. var schedualMap = {};
  419. for (let index = 0; index < scheduals.length; index++) {
  420. const schedual = scheduals[index];
  421. if (schedual.dialysis_order == null) {
  422. continue;
  423. }
  424. if (schedualMap[schedual.device_number.zone.name] == null) {
  425. schedualMap[schedual.device_number.zone.name] = [];
  426. }
  427. schedualMap[schedual.device_number.zone.name].push(schedual);
  428. if (zoneMap[schedual.device_number.zone.name] == null) {
  429. zoneMap[schedual.device_number.zone.name] =
  430. schedual.device_number.zone;
  431. }
  432. }
  433. var zones = [];
  434. zones.push({ value: 0, text: "全部分区" });
  435. for (var zoneName in zoneMap) {
  436. zones.push({ value: zoneMap[zoneName].id, text: zoneName });
  437. }
  438. zones = zones.sort(function(a, b) {
  439. return a.value > b.value;
  440. });
  441. this.zones = zones;
  442. var dialysis_scheduals = [];
  443. for (let index = 0; index < zones.length; index++) {
  444. const zone = zones[index];
  445. var scheduals = schedualMap[zone.text];
  446. if (scheduals == null) {
  447. continue;
  448. }
  449. dialysis_scheduals.push({
  450. zone_name: zone.text,
  451. scheduals: scheduals
  452. });
  453. }
  454. this.dialysis_scheduals = dialysis_scheduals;
  455. } else {
  456. this.loading = false;
  457. this.$toast({
  458. message: resp.msg
  459. });
  460. }
  461. })
  462. .catch(error => {
  463. this.loading = false;
  464. // 超时之后在这里捕抓错误信息.
  465. if (error.response) {
  466. this.networkStates = false;
  467. console.log("error.response");
  468. console.log(error.response);
  469. } else if (error.request) {
  470. this.networkStates = false;
  471. // if(error.request.readyState == 4 && error.request.status == 0){
  472. // //我在这里重新请求
  473. // this.networkStates = false
  474. // }
  475. } else {
  476. this.networkStates = false;
  477. }
  478. });
  479. },
  480. openPicker() {
  481. this.$refs.picker.open();
  482. this.newMypatient = 0;
  483. }
  484. // getMyPatient () {
  485. // console.log('这是啥', this.zone_options_visible)
  486. // console.log('日期', this.selected_date)
  487. // }
  488. }
  489. };
  490. </script>
  491. <style style="stylesheet/scss" lang="scss" scoped>
  492. .screening {
  493. border-bottom: 1px #e5e5e5 solid;
  494. position: fixed;
  495. top: 100px;
  496. @media only screen and (min-width: 768px) {
  497. top: 163px;
  498. }
  499. @media only screen and (min-width: 415px) and (max-width: 767px) {
  500. top: 134px;
  501. }
  502. // @media only screen and (min-width: 813px) and (max-width: 1024px) {
  503. // top: 130px;
  504. // }
  505. right: 0;
  506. z-index: 66;
  507. left: 0;
  508. background: #fff;
  509. // @media only screen and (max-width: 812px) {
  510. // top: 50px !important;
  511. // }
  512. ul {
  513. @include display-flex;
  514. @include align-items-center;
  515. @include text-align;
  516. @include justify-content-between;
  517. width: 90%;
  518. margin: 0 auto;
  519. li {
  520. font-size: 0.45rem;
  521. padding: 0.3rem 0;
  522. cursor: pointer;
  523. .iconfont {
  524. font-size: 0.45rem;
  525. color: #a8b3ba;
  526. margin-left: 0.1rem;
  527. // @media only screen and (max-width: 768px) {
  528. // font-size: 0.45 !important;
  529. // }
  530. }
  531. }
  532. .active {
  533. position: relative;
  534. &::before {
  535. position: absolute;
  536. bottom: 0;
  537. left: 0;
  538. width: 100%;
  539. height: 2px;
  540. background: $main-color;
  541. // border-bottom: 0.04rem $main-color solid;
  542. content: "";
  543. }
  544. }
  545. }
  546. }
  547. .stateBox {
  548. // padding: 0.26rem 0 0 0.6rem;
  549. // background: #fff;
  550. .title {
  551. font-size: 0.34rem;
  552. font-weight: 600;
  553. color: $title-color;
  554. height: 1rem;
  555. line-height: 0.8rem;
  556. display: inline-block;
  557. }
  558. }
  559. .shadow {
  560. width: 100%;
  561. height: 100%;
  562. position: absolute;
  563. left: 0;
  564. top: 0;
  565. z-index: 998;
  566. background-color: #000;
  567. opacity: 0.6;
  568. display: none;
  569. }
  570. .picker-toolbar {
  571. height: 60px;
  572. }
  573. .mint-datetime-action {
  574. line-height: 60px;
  575. font-size: 0.45rem;
  576. @media only screen and (max-width: 768px) {
  577. line-height: 40px !important;
  578. }
  579. }
  580. </style>