血透系统pad前端

add_urgent_schedule.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <div class="mainBox">
  3. <div class="mainContent">
  4. <div class="navigation">
  5. <div class="goBack">
  6. <span class="back" @click="$router.back(-1)">
  7. <span class="iconfont">&#xe720;</span>返回
  8. </span>
  9. </div>
  10. <div class="nav">
  11. <span>临时排班</span>
  12. </div>
  13. <div class="goBack"></div>
  14. </div>
  15. <div class="form" v-loading="loading">
  16. <van-row class="row">
  17. <van-col :span="24" class="danger_hint">
  18. <!--本次临时排班会覆盖已有排班中的同班次、同床位的排班,请仔细检查后再提交-->
  19. 温馨提示:本次临时排班只能调整到空余的床位
  20. </van-col>
  21. </van-row>
  22. <van-row class="row">
  23. <van-col :span="12">
  24. <span class="title">日期:</span>
  25. <div class="field_panel">
  26. <van-field v-model="date" class="field"></van-field>
  27. </div>
  28. </van-col>
  29. </van-row>
  30. <van-row class="row">
  31. <van-col :span="12">
  32. <span class="title">患者:</span>
  33. <div class="field_panel">
  34. <van-field
  35. ref="patient_field"
  36. @focus="selectPatientAction"
  37. :value="patient_name"
  38. class="field"
  39. left-icon="arrow-down"
  40. ></van-field>
  41. </div>
  42. </van-col>
  43. <van-col :span="9">
  44. <div class="field_panel">
  45. <el-autocomplete
  46. style="float: right"
  47. popper-class="my-autocomplete"
  48. v-model="value"
  49. :fetch-suggestions="querySearchAsync"
  50. :trigger-on-focus="false"
  51. placeholder="请输入病人名字"
  52. @select="handleSelect"
  53. >
  54. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  55. <template slot-scope="{ item }">
  56. <div class="name">{{ item.name }}</div>
  57. </template>
  58. </el-autocomplete>
  59. </div>
  60. </van-col>
  61. </van-row>
  62. <van-row class="row">
  63. <van-col :span="12">
  64. <span class="title">班次:</span>
  65. <div class="field_panel">
  66. <van-field
  67. ref="sch_type_field"
  68. @focus="selectSchTypeAction"
  69. :value="schedule_type_title"
  70. class="field"
  71. left-icon="arrow-down"
  72. ></van-field>
  73. </div>
  74. </van-col>
  75. <van-col :span="12">
  76. <span class="title">治疗模式:</span>
  77. <div class="field_panel">
  78. <van-field
  79. ref="mode_field"
  80. @focus="selectModeAction"
  81. :value="mode_name"
  82. class="field"
  83. left-icon="arrow-down"
  84. ></van-field>
  85. </div>
  86. </van-col>
  87. <van-col :span="12">
  88. <span class="title">床位:</span>
  89. <div class="field_panel">
  90. <van-field
  91. ref="bed_field"
  92. @focus="selectBedAction"
  93. :value="bed_name"
  94. class="field"
  95. left-icon="arrow-down"
  96. ></van-field>
  97. </div>
  98. </van-col>
  99. </van-row>
  100. <van-row class="row">
  101. <van-col :span="24">
  102. <span class="title">&nbsp;</span>
  103. <div class="field_panel">
  104. <van-button type="info" size="normal" @click="submitAction">立即排班</van-button>
  105. </div>
  106. </van-col>
  107. </van-row>
  108. </div>
  109. </div>
  110. <side-bar :active_index="0"></side-bar>
  111. <van-popup v-model="show_patient_picker" position="bottom" class="popup">
  112. <van-picker :columns="patients" value-key="name" @change="didChangePatient"></van-picker>
  113. </van-popup>
  114. <van-popup v-model="show_mode_picker" position="bottom" class="popup">
  115. <van-picker :columns="modes" value-key="name" @change="didChangeMode"></van-picker>
  116. </van-popup>
  117. <van-popup v-model="show_bed_picker" position="bottom" class="popup">
  118. <van-picker :columns="zone_device_options" value-key="number" @change="didChangeBed"></van-picker>
  119. </van-popup>
  120. <van-popup v-model="show_sch_type_picker" position="bottom" class="popup">
  121. <van-picker :columns="schedule_types" value-key="text" @change="didChangeSchType"></van-picker>
  122. </van-popup>
  123. </div>
  124. </template>
  125. <script>
  126. import SideBar from "@/pages/layout/SideBar";
  127. import { parseTime } from "@/utils";
  128. import {
  129. getUrgentScheduleInitData,
  130. PostSearch,
  131. postUrgentSchedule
  132. } from "@/api/dialysis";
  133. import { Dialog, Toast } from "vant";
  134. export default {
  135. name: "AddUrgentSchedule",
  136. components: {
  137. SideBar
  138. },
  139. data() {
  140. return {
  141. loading: false,
  142. value: "",
  143. date: "2019-09-09",
  144. patient_id: 0,
  145. mode_id: 0,
  146. device_id: 0,
  147. schedule_type: 1,
  148. zone_name: "",
  149. show_patient_picker: false,
  150. show_mode_picker: false,
  151. show_bed_picker: false,
  152. show_sch_type_picker: false,
  153. patients: [],
  154. modes: [],
  155. schedule_types: [
  156. { value: 1, text: "上午" },
  157. { value: 2, text: "下午" },
  158. { value: 3, text: "晚上" }
  159. ],
  160. origin_device_numbers: [],
  161. zone_device_map: {},
  162. zone_names: [],
  163. current_devices: [],
  164. zone_device_options: [],
  165. origin_schedules: []
  166. };
  167. },
  168. computed: {
  169. patient_name: function() {
  170. for (let index = 0; index < this.patients.length; index++) {
  171. const patient = this.patients[index];
  172. if (patient.id == this.patient_id) {
  173. return patient.name;
  174. }
  175. }
  176. return "";
  177. },
  178. mode_name: function() {
  179. for (let index = 0; index < this.modes.length; index++) {
  180. const mode = this.modes[index];
  181. if (mode.id == this.mode_id) {
  182. return mode.name;
  183. }
  184. }
  185. return "";
  186. },
  187. bed_name: function() {
  188. if (this.zone_name.length > 0 && this.device_id != 0) {
  189. for (let index = 0; index < this.current_devices.length; index++) {
  190. const device_number = this.current_devices[index];
  191. if (device_number.id == this.device_id) {
  192. return device_number.zone.name + " - " + device_number.number;
  193. }
  194. }
  195. }
  196. return "";
  197. },
  198. schedule_type_title: function() {
  199. for (let index = 0; index < this.schedule_types.length; index++) {
  200. const type = this.schedule_types[index];
  201. if (type.value == this.schedule_type) {
  202. return type.text;
  203. }
  204. }
  205. return "";
  206. }
  207. },
  208. mounted() {
  209. var today = new Date();
  210. this.date = parseTime(today, "{y}-{m}-{d}");
  211. var hour = today.getHours();
  212. if (hour > 3 && hour < 11) {
  213. this.schedule_type = 1;
  214. } else if (hour >= 11 && hour < 18) {
  215. this.schedule_type = 2;
  216. } else {
  217. this.schedule_type = 3;
  218. }
  219. this.loading = true;
  220. let params = {
  221. type: this.schedule_type
  222. };
  223. console.log(params);
  224. getUrgentScheduleInitData(params)
  225. .then(rs => {
  226. this.loading = false;
  227. // console.log(rs.data.data)
  228. if (rs.data.state == 1) {
  229. this.origin_schedules = rs.data.data.schedules;
  230. this.patients = rs.data.data.patients;
  231. this.modes = rs.data.data.modes;
  232. this.origin_device_numbers = rs.data.data.device_numbers;
  233. for (let i = this.origin_schedules.length - 1; i >= 0; i--) {
  234. for (let y = this.origin_device_numbers.length - 1; y >= 0; y--) {
  235. if (
  236. this.origin_device_numbers[y].id ==
  237. this.origin_schedules[i].bed_id
  238. ) {
  239. this.origin_device_numbers.splice(y, 1);
  240. }
  241. }
  242. }
  243. if (this.patients.length > 0) {
  244. this.patient_id = this.patients[0].id;
  245. }
  246. if (this.modes.length > 0) {
  247. this.mode_id = this.modes[0].id;
  248. }
  249. var zone_device_map = {};
  250. for (
  251. let index = 0;
  252. index < this.origin_device_numbers.length;
  253. index++
  254. ) {
  255. const device_number = this.origin_device_numbers[index];
  256. if (
  257. zone_device_map[device_number.zone.name] == null ||
  258. zone_device_map[device_number.zone.name] == undefined
  259. ) {
  260. zone_device_map[device_number.zone.name] = [];
  261. }
  262. zone_device_map[device_number.zone.name].push(device_number);
  263. }
  264. this.zone_device_map = zone_device_map;
  265. this.zone_names = Object.keys(this.zone_device_map);
  266. if (this.zone_names.length > 0) {
  267. this.zone_name = this.zone_names[0];
  268. this.current_devices = this.zone_device_map[this.zone_name];
  269. this.device_id = this.current_devices[0].id;
  270. }
  271. this.zone_device_options = [
  272. { values: this.zone_names },
  273. // { values: this.getDeviceNumberNames(this.current_devices) },
  274. { values: this.current_devices }
  275. ];
  276. } else {
  277. Toast.fail(rs.data.msg);
  278. }
  279. })
  280. .catch(err => {
  281. this.loading = false;
  282. Toast.fail(err);
  283. });
  284. },
  285. methods: {
  286. handleSelect(val) {
  287. this.patient_name = val.name;
  288. this.patient_id = val.id;
  289. },
  290. querySearchAsync(keyword, cb) {
  291. let key = "";
  292. if (keyword != undefined) {
  293. key = keyword;
  294. }
  295. let searchArray = [];
  296. PostSearch(key).then(response => {
  297. if (response.data.state == 1) {
  298. searchArray = response.data.data.patient;
  299. cb(searchArray);
  300. } else {
  301. cb([]);
  302. }
  303. });
  304. },
  305. selectPatientAction: function() {
  306. this.$refs.patient_field.blur();
  307. this.show_patient_picker = true;
  308. },
  309. selectModeAction: function() {
  310. this.$refs.mode_field.blur();
  311. this.show_mode_picker = true;
  312. },
  313. selectBedAction: function() {
  314. this.$refs.bed_field.blur();
  315. this.show_bed_picker = true;
  316. },
  317. selectSchTypeAction: function() {
  318. this.$refs.sch_type_field.blur();
  319. this.show_sch_type_picker = true;
  320. },
  321. didChangePatient: function(picker, patient, index) {
  322. this.patient_id = patient.id;
  323. },
  324. didChangeMode: function(picker, mode, index) {
  325. this.mode_id = mode.id;
  326. },
  327. didChangeBed: function(picker, values, col_index) {
  328. if (col_index == 0) {
  329. this.zone_name = values[0];
  330. this.current_devices = this.zone_device_map[this.zone_name];
  331. this.device_id = this.current_devices[0].id;
  332. picker.setColumnValues(1, this.current_devices);
  333. } else if (col_index == 1) {
  334. this.device_id = values[1].id;
  335. }
  336. },
  337. didChangeSchType: function(picker, sch_type, index) {
  338. this.schedule_type = sch_type.value;
  339. this.loading = true;
  340. let params = {
  341. type: this.schedule_type
  342. };
  343. getUrgentScheduleInitData(params)
  344. .then(rs => {
  345. this.loading = false;
  346. // console.log(rs.data.data)
  347. if (rs.data.state == 1) {
  348. this.origin_schedules = rs.data.data.schedules;
  349. this.patients = rs.data.data.patients;
  350. this.modes = rs.data.data.modes;
  351. this.origin_device_numbers = rs.data.data.device_numbers;
  352. for (let i = this.origin_schedules.length - 1; i >= 0; i--) {
  353. for (let y = this.origin_device_numbers.length - 1; y >= 0; y--) {
  354. if (
  355. this.origin_device_numbers[y].id ==
  356. this.origin_schedules[i].bed_id
  357. ) {
  358. this.origin_device_numbers.splice(y, 1);
  359. }
  360. }
  361. }
  362. // if (this.patients.length > 0) {
  363. // this.patient_id = this.patients[0].id
  364. // }
  365. // if (this.modes.length > 0) {
  366. // this.mode_id = this.modes[0].id
  367. // }
  368. var zone_device_map = {};
  369. for (
  370. let index = 0;
  371. index < this.origin_device_numbers.length;
  372. index++
  373. ) {
  374. const device_number = this.origin_device_numbers[index];
  375. if (
  376. zone_device_map[device_number.zone.name] == null ||
  377. zone_device_map[device_number.zone.name] == undefined
  378. ) {
  379. zone_device_map[device_number.zone.name] = [];
  380. }
  381. zone_device_map[device_number.zone.name].push(device_number);
  382. }
  383. this.zone_device_map = zone_device_map;
  384. this.zone_names = Object.keys(this.zone_device_map);
  385. if (this.zone_names.length > 0) {
  386. this.zone_name = this.zone_names[0];
  387. this.current_devices = this.zone_device_map[this.zone_name];
  388. this.device_id = this.current_devices[0].id;
  389. }
  390. this.zone_device_options = [
  391. { values: this.zone_names },
  392. // { values: this.getDeviceNumberNames(this.current_devices) },
  393. { values: this.current_devices }
  394. ];
  395. } else {
  396. Toast.fail(rs.data.msg);
  397. }
  398. })
  399. .catch(err => {
  400. this.loading = false;
  401. Toast.fail(err);
  402. });
  403. },
  404. submitAction: function() {
  405. if (this.patient_id == 0 || this.mode_id == 0 || this.device_id == 0) {
  406. Toast.fail("请选择班次、床位等");
  407. return;
  408. }
  409. var repeated = false;
  410. for (let index = 0; index < this.origin_schedules.length; index++) {
  411. const schedule = this.origin_schedules[index];
  412. if (
  413. schedule.bed_id == this.device_id &&
  414. this.schedule_type == schedule.schedule_type
  415. ) {
  416. repeated = true;
  417. break;
  418. }
  419. }
  420. if (repeated) {
  421. Dialog.confirm({
  422. title: "提醒",
  423. message: "你选择的床位已经被排班,确认要替换吗?"
  424. })
  425. .then(() => {
  426. // on confirm
  427. this.submit();
  428. })
  429. .catch(() => {
  430. // on cancel
  431. });
  432. } else {
  433. this.submit();
  434. }
  435. },
  436. submit: function() {
  437. var params = {
  438. patient_id: this.patient_id,
  439. mode: this.mode_id,
  440. schedule_type: this.schedule_type,
  441. bed: this.device_id
  442. };
  443. this.loading = true;
  444. postUrgentSchedule(params)
  445. .then(rs => {
  446. this.loading = false;
  447. var resp = rs.data;
  448. if (resp.state == 1) {
  449. console.log(resp.data);
  450. var patient = resp.data.patient;
  451. var schedule = resp.data.schedule;
  452. this.$router.push({
  453. path: "/details",
  454. query: {
  455. patient_id: patient.id,
  456. date: schedule.schedule_date,
  457. patient_name: patient.name
  458. }
  459. });
  460. } else {
  461. Toast.fail(resp.msg);
  462. }
  463. })
  464. .catch(err => {
  465. this.loading = false;
  466. Toast.fail("err");
  467. });
  468. }
  469. }
  470. };
  471. </script>
  472. <style style="stylesheet/scss" lang="scss" scoped>
  473. .mainContent {
  474. position: relative;
  475. .navigation {
  476. padding: 0.3rem 0.36rem;
  477. border-bottom: 1px #e5e5e5 solid;
  478. position: fixed;
  479. top: 0;
  480. left: 0;
  481. right: 0;
  482. z-index: 100;
  483. background: #fff;
  484. .goBack {
  485. float: left;
  486. .back {
  487. color: $main-color;
  488. margin-right: 0.87rem;
  489. .iconfont {
  490. color: $main-color;
  491. }
  492. }
  493. }
  494. .nav {
  495. text-align: center;
  496. font-size: 0.36rem;
  497. margin-right: 56px;
  498. }
  499. }
  500. .form {
  501. background: #fff;
  502. min-height: calc(100vh - 2px);
  503. padding-top: 55px;
  504. padding-left: 20px;
  505. .row {
  506. padding: 5px 0;
  507. .title {
  508. color: #8f8f8f;
  509. margin-right: 5px;
  510. text-align: right;
  511. font-size: 16px;
  512. line-height: 45px;
  513. width: 80px;
  514. float: left;
  515. // @media only screen and (max-width: 812px) {
  516. // font-size: 0.3rem !important;
  517. // }
  518. @media only screen and (max-width: 376px) {
  519. width: 50px !important;
  520. font-size: 0.3rem !important;
  521. }
  522. }
  523. .el-input__inner {
  524. @media only screen and (max-width: 812px) {
  525. height: 24px !important;
  526. line-height: 24px !important;
  527. }
  528. }
  529. .field_panel {
  530. display: inline-block;
  531. .field {
  532. padding: 0 0;
  533. font-size: 18px;
  534. line-height: 45px;
  535. width: 180px;
  536. @media only screen and (max-width: 812px) {
  537. width: 100px;
  538. }
  539. }
  540. }
  541. .danger_hint {
  542. font-size: 0.34rem;
  543. line-height: 40px;
  544. text-align: center;
  545. color: red;
  546. @media only screen and (max-width: 812px) {
  547. margin-left: -10px !important;
  548. }
  549. }
  550. }
  551. }
  552. }
  553. .popup {
  554. border-radius: 0 !important;
  555. top: initial !important;
  556. }
  557. .mainBox {
  558. display: flex;
  559. height: 100%;
  560. flex-direction: column;
  561. > :first-child {
  562. overflow: auto;
  563. flex: 1;
  564. }
  565. }
  566. </style>