血透系统pad前端

add_urgent_schedule.vue 18KB

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