血透系统pad前端

add_urgent_schedule.vue 17KB

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