血透系统pad前端

add_urgent_schedule.vue 14KB

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