血透系统pad前端

add_urgent_schedule.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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>返回
  9. </span>
  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">本次临时排班会覆盖已有排班中的同班次、同床位的排班,请仔细检查后再提交</van-col>
  19. </van-row>
  20. <van-row class="row">
  21. <van-col :span="9">
  22. <span class="title">日期:</span>
  23. <div class="field_panel">
  24. <van-field v-model="date" disabled class="field"></van-field>
  25. </div>
  26. </van-col>
  27. </van-row>
  28. <van-row class="row">
  29. <van-col :span="9">
  30. <span class="title">患者:</span>
  31. <div class="field_panel">
  32. <van-field
  33. ref="patient_field"
  34. @focus="selectPatientAction"
  35. :value="patient_name"
  36. class="field"
  37. left-icon="arrow-down"
  38. ></van-field>
  39. </div>
  40. </van-col>
  41. <van-col :span="9">
  42. <span class="title">班次:</span>
  43. <div class="field_panel">
  44. <van-field
  45. ref="sch_type_field"
  46. @focus="selectSchTypeAction"
  47. :value="schedule_type_title"
  48. class="field"
  49. left-icon="arrow-down"
  50. ></van-field>
  51. </div>
  52. </van-col>
  53. </van-row>
  54. <van-row class="row">
  55. <van-col :span="9">
  56. <span class="title">治疗模式:</span>
  57. <div class="field_panel">
  58. <van-field
  59. ref="mode_field"
  60. @focus="selectModeAction"
  61. :value="mode_name"
  62. class="field"
  63. left-icon="arrow-down"
  64. ></van-field>
  65. </div>
  66. </van-col>
  67. <van-col :span="9">
  68. <span class="title">床位:</span>
  69. <div class="field_panel">
  70. <van-field
  71. ref="bed_field"
  72. @focus="selectBedAction"
  73. :value="bed_name"
  74. class="field"
  75. left-icon="arrow-down"
  76. ></van-field>
  77. </div>
  78. </van-col>
  79. </van-row>
  80. <van-row class="row">
  81. <van-col :span="24">
  82. <span class="title">&nbsp;</span>
  83. <div class="field_panel">
  84. <van-button type="info" @click="submitAction">立即排班</van-button>
  85. </div>
  86. </van-col>
  87. </van-row>
  88. </div>
  89. </div>
  90. <van-popup v-model="show_patient_picker" position="bottom" class="popup">
  91. <van-picker :columns="patients" value-key="name" @change="didChangePatient"></van-picker>
  92. </van-popup>
  93. <van-popup v-model="show_mode_picker" position="bottom" class="popup">
  94. <van-picker :columns="modes" value-key="name" @change="didChangeMode"></van-picker>
  95. </van-popup>
  96. <van-popup v-model="show_bed_picker" position="bottom" class="popup">
  97. <van-picker :columns="zone_device_options" value-key="number" @change="didChangeBed"></van-picker>
  98. </van-popup>
  99. <van-popup v-model="show_sch_type_picker" position="bottom" class="popup">
  100. <van-picker :columns="schedule_types" value-key="text" @change="didChangeSchType"></van-picker>
  101. </van-popup>
  102. </div>
  103. </template>
  104. <script>
  105. import SideBar from "@/pages/layout/SideBar";
  106. import { parseTime } from "@/utils";
  107. import { getUrgentScheduleInitData, postUrgentSchedule } from "@/api/dialysis";
  108. import { Toast, Dialog } from "vant";
  109. export default {
  110. name: "AddUrgentSchedule",
  111. components: {
  112. SideBar
  113. },
  114. data() {
  115. return {
  116. loading: false,
  117. date: "2019-09-09",
  118. patient_id: 0,
  119. mode_id: 0,
  120. device_id: 0,
  121. schedule_type: 1,
  122. zone_name: "",
  123. show_patient_picker: false,
  124. show_mode_picker: false,
  125. show_bed_picker: false,
  126. show_sch_type_picker: false,
  127. patients: [],
  128. modes: [],
  129. schedule_types: [
  130. { value: 1, text: "上午" },
  131. { value: 2, text: "下午" },
  132. { value: 3, text: "晚上" }
  133. ],
  134. origin_device_numbers: [],
  135. zone_device_map: {},
  136. zone_names: [],
  137. current_devices: [],
  138. zone_device_options: [],
  139. origin_schedules: []
  140. };
  141. },
  142. computed: {
  143. patient_name: function() {
  144. for (let index = 0; index < this.patients.length; index++) {
  145. const patient = this.patients[index];
  146. if (patient.id == this.patient_id) {
  147. return patient.name;
  148. }
  149. }
  150. return "";
  151. },
  152. mode_name: function() {
  153. for (let index = 0; index < this.modes.length; index++) {
  154. const mode = this.modes[index];
  155. if (mode.id == this.mode_id) {
  156. return mode.name;
  157. }
  158. }
  159. return "";
  160. },
  161. bed_name: function() {
  162. if (this.zone_name.length > 0 && this.device_id != 0) {
  163. for (let index = 0; index < this.current_devices.length; index++) {
  164. const device_number = this.current_devices[index];
  165. if (device_number.id == this.device_id) {
  166. return device_number.zone.name + " - " + device_number.number;
  167. }
  168. }
  169. }
  170. return "";
  171. },
  172. schedule_type_title: function() {
  173. for (let index = 0; index < this.schedule_types.length; index++) {
  174. const type = this.schedule_types[index];
  175. if (type.value == this.schedule_type) {
  176. return type.text;
  177. }
  178. }
  179. return "";
  180. }
  181. },
  182. mounted() {
  183. var today = new Date();
  184. this.date = parseTime(today, "{y}-{m}-{d}");
  185. var hour = today.getHours();
  186. if (hour > 3 && hour < 11) {
  187. this.schedule_type = 1;
  188. } else if (hour >= 11 && hour < 18) {
  189. this.schedule_type = 2;
  190. } else {
  191. this.schedule_type = 3;
  192. }
  193. this.loading = true;
  194. getUrgentScheduleInitData()
  195. .then(rs => {
  196. this.loading = false;
  197. // console.log(rs.data.data)
  198. if (rs.data.state == 1) {
  199. this.origin_schedules = rs.data.data.schedules;
  200. this.patients = rs.data.data.patients;
  201. this.modes = rs.data.data.modes;
  202. this.origin_device_numbers = rs.data.data.device_numbers;
  203. if (this.patients.length > 0) {
  204. this.patient_id = this.patients[0].id;
  205. }
  206. if (this.modes.length > 0) {
  207. this.mode_id = this.modes[0].id;
  208. }
  209. var zone_device_map = {};
  210. for (
  211. let index = 0;
  212. index < this.origin_device_numbers.length;
  213. index++
  214. ) {
  215. const device_number = this.origin_device_numbers[index];
  216. if (
  217. zone_device_map[device_number.zone.name] == null ||
  218. zone_device_map[device_number.zone.name] == undefined
  219. ) {
  220. zone_device_map[device_number.zone.name] = [];
  221. }
  222. zone_device_map[device_number.zone.name].push(device_number);
  223. }
  224. this.zone_device_map = zone_device_map;
  225. this.zone_names = Object.keys(this.zone_device_map);
  226. if (this.zone_names.length > 0) {
  227. this.zone_name = this.zone_names[0];
  228. this.current_devices = this.zone_device_map[this.zone_name];
  229. this.device_id = this.current_devices[0].id;
  230. }
  231. this.zone_device_options = [
  232. { values: this.zone_names },
  233. // { values: this.getDeviceNumberNames(this.current_devices) },
  234. { values: this.current_devices }
  235. ];
  236. } else {
  237. Toast.fail(rs.data.msg);
  238. }
  239. })
  240. .catch(err => {
  241. this.loading = false;
  242. Toast.fail(err);
  243. });
  244. },
  245. methods: {
  246. // getDeviceNumberNames: function(device_numbers) {
  247. // var names = []
  248. // for (let index = 0; index < device_numbers.length; index++) {
  249. // const device_number = device_numbers[index];
  250. // names.push(device_number.number)
  251. // }
  252. // return names
  253. // },
  254. selectPatientAction: function() {
  255. this.$refs.patient_field.blur();
  256. this.show_patient_picker = true;
  257. },
  258. selectModeAction: function() {
  259. this.$refs.mode_field.blur();
  260. this.show_mode_picker = true;
  261. },
  262. selectBedAction: function() {
  263. this.$refs.bed_field.blur();
  264. this.show_bed_picker = true;
  265. },
  266. selectSchTypeAction: function() {
  267. this.$refs.sch_type_field.blur();
  268. this.show_sch_type_picker = true;
  269. },
  270. didChangePatient: function(picker, patient, index) {
  271. this.patient_id = patient.id;
  272. },
  273. didChangeMode: function(picker, mode, index) {
  274. this.mode_id = mode.id;
  275. },
  276. didChangeBed: function(picker, values, col_index) {
  277. if (col_index == 0) {
  278. this.zone_name = values[0];
  279. this.current_devices = this.zone_device_map[this.zone_name];
  280. this.device_id = this.current_devices[0].id;
  281. picker.setColumnValues(1, this.current_devices);
  282. } else if (col_index == 1) {
  283. this.device_id = values[1].id;
  284. }
  285. },
  286. didChangeSchType: function(picker, sch_type, index) {
  287. this.schedule_type = sch_type.value;
  288. },
  289. submitAction: function() {
  290. if (this.patient_id == 0 || this.mode_id == 0 || this.device_id == 0) {
  291. Toast.fail("请选择班次、床位等");
  292. return;
  293. }
  294. var repeated = false;
  295. for (let index = 0; index < this.origin_schedules.length; index++) {
  296. const schedule = this.origin_schedules[index];
  297. if (
  298. schedule.bed_id == this.device_id &&
  299. this.schedule_type == schedule.schedule_type
  300. ) {
  301. repeated = true;
  302. break;
  303. }
  304. }
  305. if (repeated) {
  306. Dialog.confirm({
  307. title: "提醒",
  308. message: "你选择的床位已经被排班,确认要替换吗?"
  309. })
  310. .then(() => {
  311. // on confirm
  312. this.submit();
  313. })
  314. .catch(() => {
  315. // on cancel
  316. });
  317. } else {
  318. this.submit();
  319. }
  320. },
  321. submit: function() {
  322. var params = {
  323. patient_id: this.patient_id,
  324. mode: this.mode_id,
  325. schedule_type: this.schedule_type,
  326. bed: this.device_id
  327. };
  328. this.loading = true;
  329. postUrgentSchedule(params)
  330. .then(rs => {
  331. this.loading = false;
  332. var resp = rs.data;
  333. if (resp.state == 1) {
  334. console.log(resp.data);
  335. var patient = resp.data.patient;
  336. var schedule = resp.data.schedule;
  337. this.$router.push({
  338. path: "/details",
  339. query: {
  340. patient_id: patient.id,
  341. date: schedule.schedule_date,
  342. patient_name: patient.name
  343. }
  344. });
  345. } else {
  346. Toast.fail(resp.msg);
  347. }
  348. })
  349. .catch(err => {
  350. this.loading = false;
  351. Toast.fail("err");
  352. });
  353. }
  354. }
  355. };
  356. </script>
  357. <style style="stylesheet/scss" lang="scss" scoped>
  358. .mainContent {
  359. position: relative;
  360. .navigation {
  361. padding: 0.3rem 0.36rem;
  362. border-bottom: 1px #e5e5e5 solid;
  363. // position: fixed;
  364. // top: 0;
  365. // left:1.58rem;
  366. // right: 0;
  367. z-index: 100;
  368. background: #fff;
  369. .goBack {
  370. float: left;
  371. .back {
  372. color: $main-color;
  373. margin-right: 0.87rem;
  374. .iconfont {
  375. color: $main-color;
  376. }
  377. }
  378. }
  379. .nav {
  380. text-align: center;
  381. font-size: 0.36rem;
  382. }
  383. }
  384. .form {
  385. padding: 10px 10px;
  386. .row {
  387. padding: 5px 0;
  388. .title {
  389. color: #8f8f8f;
  390. margin-right: 5px;
  391. text-align: right;
  392. font-size: 16px;
  393. line-height: 45px;
  394. width: 80px;
  395. float: left;
  396. }
  397. .field_panel {
  398. display: inline-block;
  399. .field {
  400. padding: 0 0;
  401. font-size: 18px;
  402. line-height: 45px;
  403. width: 180px;
  404. @media only screen and (max-width: 812px) {
  405. width: 100px;
  406. }
  407. }
  408. }
  409. .danger_hint {
  410. font-size: 0.34rem;
  411. line-height: 40px;
  412. text-align: center;
  413. color: red;
  414. }
  415. }
  416. }
  417. }
  418. .popup {
  419. border-radius: 0 !important;
  420. top: initial !important;
  421. }
  422. </style>