血透系统pad前端

add_urgent_schedule.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. // this.$nextTick(() => {
  336. // // this.$refs.schedule.setColumnIndex(2)
  337. // // .setIndexes(this.schedule_type)
  338. // console.log(this.$refs.schedule)
  339. // console.log(this.$refs.schedule.getColumnIndex)
  340. // console.log(this.$refs.schedule.getColumnValue)
  341. //
  342. // })
  343. },
  344. didChangePatient: function(picker, patient, index) {
  345. this.patient_id = patient.id;
  346. },
  347. didChangeMode: function(picker, mode, index) {
  348. this.mode_id = mode.id;
  349. },
  350. didChangeBed: function(picker, values, col_index) {
  351. if (col_index == 0) {
  352. this.zone_name = values[0];
  353. this.current_devices = this.zone_device_map[this.zone_name];
  354. this.device_id = this.current_devices[0].id;
  355. picker.setColumnValues(1, this.current_devices);
  356. } else if (col_index == 1) {
  357. this.device_id = values[1].id;
  358. }
  359. },
  360. didChangeSchType: function(picker, sch_type, index) {
  361. this.schedule_type = sch_type.value;
  362. this.loading = true;
  363. let params = {
  364. type: this.schedule_type
  365. };
  366. getUrgentScheduleInitData(params)
  367. .then(rs => {
  368. this.loading = false;
  369. // console.log(rs.data.data)
  370. if (rs.data.state == 1) {
  371. this.zone_device_options = []
  372. this.origin_schedules = rs.data.data.schedules;
  373. this.patients = rs.data.data.patients;
  374. this.modes = rs.data.data.modes;
  375. this.origin_device_numbers = rs.data.data.device_numbers;
  376. var zone_device_map = {};
  377. for (
  378. let index = 0;
  379. index < this.origin_device_numbers.length;
  380. index++
  381. ) {
  382. const device_number = this.origin_device_numbers[index];
  383. if (
  384. zone_device_map[device_number.zone_name] == null ||
  385. zone_device_map[device_number.zone_name] == undefined
  386. ) {
  387. zone_device_map[device_number.zone_name] = [];
  388. }
  389. zone_device_map[device_number.zone_name].push(device_number);
  390. }
  391. this.zone_device_map = zone_device_map;
  392. this.zone_names = Object.keys(this.zone_device_map);
  393. if (this.zone_names.length > 0) {
  394. this.zone_name = this.zone_names[0];
  395. this.current_devices = this.zone_device_map[this.zone_name];
  396. this.device_id = this.current_devices[0].id;
  397. }
  398. this.zone_device_options = [
  399. { values: this.zone_names },
  400. // { values: this.getDeviceNumberNames(this.current_devices) },
  401. { values: this.current_devices }
  402. ];
  403. console.log( this.zone_device_options)
  404. } else {
  405. Toast.fail(rs.data.msg);
  406. }
  407. })
  408. .catch(err => {
  409. this.loading = false;
  410. Toast.fail(err);
  411. });
  412. },
  413. submitAction: function() {
  414. if (this.patient_id == 0 || this.mode_id == 0 || this.device_id == 0) {
  415. Toast.fail("请选择班次、床位等");
  416. return;
  417. }
  418. var repeated = false;
  419. for (let index = 0; index < this.origin_schedules.length; index++) {
  420. const schedule = this.origin_schedules[index];
  421. if (
  422. schedule.bed_id == this.device_id &&
  423. this.schedule_type == schedule.schedule_type
  424. ) {
  425. repeated = true;
  426. break;
  427. }
  428. }
  429. if (repeated) {
  430. Dialog.confirm({
  431. title: "提醒",
  432. message: "你选择的床位已经被排班,确认要替换吗?"
  433. })
  434. .then(() => {
  435. // on confirm
  436. this.submit();
  437. })
  438. .catch(() => {
  439. // on cancel
  440. });
  441. } else {
  442. this.submit();
  443. }
  444. },
  445. submit: function() {
  446. var params = {
  447. patient_id: this.patient_id,
  448. mode: this.mode_id,
  449. schedule_type: this.schedule_type,
  450. bed: this.device_id
  451. };
  452. this.loading = true;
  453. postUrgentSchedule(params)
  454. .then(rs => {
  455. this.loading = false;
  456. var resp = rs.data;
  457. if (resp.state == 1) {
  458. var patient = resp.data.patient;
  459. var schedule = resp.data.schedule;
  460. this.$router.push({
  461. path: "/details",
  462. query: {
  463. patient_id: patient.id,
  464. date: schedule.schedule_date,
  465. patient_name: patient.name
  466. }
  467. });
  468. } else {
  469. Toast.fail(resp.msg);
  470. }
  471. })
  472. .catch(err => {
  473. this.loading = false;
  474. Toast.fail("err");
  475. });
  476. }
  477. }
  478. };
  479. </script>
  480. <style style="stylesheet/scss" lang="scss" scoped>
  481. .mainContent {
  482. position: relative;
  483. .navigation {
  484. padding: 0.3rem 0.36rem;
  485. border-bottom: 1px #e5e5e5 solid;
  486. position: fixed;
  487. top: 0;
  488. left: 0;
  489. right: 0;
  490. z-index: 100;
  491. background: #fff;
  492. .goBack {
  493. float: left;
  494. .back {
  495. color: $main-color;
  496. margin-right: 0.87rem;
  497. .iconfont {
  498. color: $main-color;
  499. }
  500. }
  501. }
  502. .nav {
  503. text-align: center;
  504. font-size: 0.45rem;
  505. margin-right: 56px;
  506. }
  507. }
  508. .form {
  509. background: #fff;
  510. min-height: calc(100vh - 2px);
  511. padding-top: 55px;
  512. // padding-left: 20px;
  513. @media only screen and (min-width: 768px) {
  514. padding-top: 100px;
  515. }
  516. .row {
  517. // padding: 5px 0;
  518. width: 80%;
  519. margin: 0 auto;
  520. .title {
  521. color: #8f8f8f;
  522. margin-right: 5px;
  523. text-align: left;
  524. font-size: 0.45rem;
  525. line-height: 45px;
  526. width: 3rem;
  527. float: left;
  528. // @media only screen and (max-width: 812px) {
  529. // font-size: 0.3rem !important;
  530. // }
  531. // @media only screen and (max-width: 376px) {
  532. // width: 50px !important;
  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. height: 1.4rem;
  545. .field {
  546. padding: 0 0;
  547. font-size: 0.45rem;
  548. line-height: 45px;
  549. width: 180px;
  550. // @media only screen and (max-width: 812px) {
  551. // width: 100px;
  552. // }
  553. }
  554. }
  555. .danger_hint {
  556. font-size: 0.4rem;
  557. line-height: 40px;
  558. text-align: center;
  559. color: #f56c6c;
  560. @media only screen and (max-width: 812px) {
  561. margin-left: -10px !important;
  562. }
  563. }
  564. .nowScheduling {
  565. width: 100%;
  566. height: 1.3rem;
  567. line-height: 1.3rem;
  568. border-radius: 30px;
  569. text-align: center;
  570. background: #258ffc;
  571. font-size: 0.45rem;
  572. color: #fff;
  573. margin-top: 0.5rem;
  574. }
  575. }
  576. }
  577. }
  578. .popup {
  579. border-radius: 0 !important;
  580. top: initial !important;
  581. }
  582. .mainBox {
  583. display: flex;
  584. height: 100%;
  585. flex-direction: column;
  586. > :first-child {
  587. overflow: auto;
  588. flex: 1;
  589. }
  590. }
  591. </style>
  592. <style lang="scss">
  593. .Input {
  594. width: 100%;
  595. .el-input__inner {
  596. border-radius: 30px;
  597. font-size: 0.4rem;
  598. @media only screen and (max-width: 767px) {
  599. height: 1.4rem;
  600. line-height: 1.4rem;
  601. }
  602. @media only screen and (min-width: 768px) {
  603. height: 1.2rem;
  604. line-height: 1.2rem;
  605. border-radius: 50px;
  606. }
  607. }
  608. .el-input__icon {
  609. font-size: 0.45rem;
  610. @media only screen and (min-width: 768px) {
  611. margin-top: 2px;
  612. margin-right: 8px;
  613. }
  614. }
  615. }
  616. .van-ellipsis {
  617. font-size: 0.45rem;
  618. }
  619. </style>