beforeDialysisCalling.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="page_beforeDialysisCalling">
  3. <div class="cell clearfix">
  4. <label class="title"><span class="name">叫号状态</span> : </label>
  5. <div class="time ">
  6. <ul class="">
  7. <li v-for="option in patient_state" :key="option.value" @click="handleStateChange(option.value)" :class="patientStateVal == option.value ? 'active' : ''" >{{option.label}}
  8. </li>
  9. </ul>
  10. </div>
  11. </div>
  12. <div style="display:flex;justify-content: space-between;">
  13. <div class="callingArea">
  14. <waiting-called v-if="patientStateVal == 0" :waitingCalled='waitingCalledAm' ></waiting-called>
  15. <waiting-called v-if="patientStateVal == 1" :waitingCalled='waitingCalledPm' ></waiting-called>
  16. <called v-if="patientStateVal == 2" :called="called"></called>
  17. </div>
  18. <div class="nowCalling" v-if="patientStateVal == 0 || patientStateVal == 1">
  19. <p class="nowCallingTitle">当前叫号</p>
  20. <p class="nowCallingName">{{ fisrtQueueInfo ? fisrtQueueInfo.patient_name : '' }}</p>
  21. <p class="nowCallingTime">签到时间:{{ fisrtQueueInfo ? fisrtQueueInfo.create_time : '' }}</p>
  22. <el-button type="primary" @click="call(fisrtQueueInfo && fisrtQueueInfo.patient_id ? fisrtQueueInfo.patient_id : '')" style="margin-left:0;margin: 30px 0 20px 0;">&ensp;叫号&ensp;</el-button>
  23. <!-- <el-button style="margin: 0px 0 20px 0;" @click="pass(fisrtQueueInfo.patient_id)">&ensp;过号&ensp;</el-button> -->
  24. <el-button style="margin:0 auto;" @click="next(fisrtQueueInfo && fisrtQueueInfo.patient_id ? fisrtQueueInfo.patient_id : '',fisrtQueueInfo && fisrtQueueInfo.schedule_type ? fisrtQueueInfo.schedule_type : '')">下一位</el-button>
  25. <!-- <el-button style="margin:0 auto;" @click="nextFive(fisrtQueueInfo && fisrtQueueInfo.patient_id ? fisrtQueueInfo.patient_id : '',fisrtQueueInfo && fisrtQueueInfo.schedule_type ? fisrtQueueInfo.schedule_type : '')">下五位</el-button> -->
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. const moment = require('moment')
  32. import axios from 'axios'
  33. import waitingCalled from './waitingCalled'
  34. import called from './called'
  35. export default {
  36. components:{
  37. waitingCalled,
  38. called
  39. },
  40. data(){
  41. return{
  42. patient_state:[
  43. {value: 0,label: '上午待叫号'},
  44. {value: 1,label: '下午待叫号'},
  45. {value: 2,label: '已叫号'},
  46. ],
  47. patientStateVal: 0,
  48. waitingCalled:[],
  49. called:[],
  50. fisrtQueueInfo:{},
  51. timer:null,
  52. waitingCalledAm:[],
  53. waitingCalledPm:[],
  54. newFisrtQueueInfo:{}
  55. }
  56. },
  57. computed: {
  58. websocket() {
  59. return this.$store.state.user.websocket;
  60. },
  61. },
  62. created(){
  63. this.initData = {
  64. cmd: "queue/join",
  65. data: {type:3,page:0,size:0},
  66. };
  67. this.websocketSend(this.initData)
  68. },
  69. beforeMount() {
  70. if (this.websocket) {
  71. if (this.websocket.readyState == 1) {
  72. this.websocketMess();
  73. } else {
  74. setTimeout(() => {
  75. this.websocketMess();
  76. }, 1000);
  77. }
  78. } else {
  79. setTimeout(() => {
  80. if (this.websocket.readyState == 1) {
  81. this.websocketMess();
  82. } else {
  83. setTimeout(() => {
  84. this.websocketMess();
  85. }, 1000);
  86. }
  87. }, 1000);
  88. }
  89. },
  90. mounted(){
  91. // let obj = {
  92. // cmd: "queue/join",
  93. // data: {type:3,page:0,size:0},
  94. // };
  95. // this.websocketSend(obj)
  96. },
  97. beforeDestroy(){
  98. let unObj = {
  99. cmd: "queue/unjoin",
  100. data: {type:3},
  101. };
  102. this.websocketSend(unObj)
  103. let unObj1 = {
  104. cmd: "queue/unjoin",
  105. data: {type:4},
  106. };
  107. this.websocketSend(unObj1)
  108. },
  109. methods:{
  110. websocketSend(data) {
  111. try {
  112. this.websocket.send(JSON.stringify(data))
  113. } catch (error) {
  114. this.showError = true;
  115. this.showIndex = 4;
  116. this.errorInfo = "网络异常,请稍后退出重试!";
  117. }
  118. },
  119. websocketMess() {
  120. console.log('执行',this.websocket)
  121. this.websocket.onmessage = e => {
  122. let res = JSON.parse(e.data);
  123. // let res = re.data;
  124. console.log('res3333ssss333333',res)
  125. if(res.channel == 'queue/join'){
  126. if(res.data.type == 3){
  127. let fisrtQueueInfo = []
  128. this.newFisrtQueueInfo = res.data.fisrtQueueInfo
  129. if(res.data.fisrtQueueInfo != null){
  130. if(this.patientStateVal == 0){
  131. fisrtQueueInfo = res.data.fisrtQueueInfo.morning
  132. if(fisrtQueueInfo != null){
  133. if(fisrtQueueInfo.create_time){
  134. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  135. }
  136. }
  137. }else if(this.patientStateVal == 1){
  138. fisrtQueueInfo = res.data.fisrtQueueInfo.afternoon
  139. if(fisrtQueueInfo != null){
  140. if(fisrtQueueInfo.create_time){
  141. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  142. }
  143. }
  144. }
  145. }
  146. this.fisrtQueueInfo = fisrtQueueInfo
  147. let arr = res.data.patientQueueList.data
  148. // let waitingCalledArr = []
  149. let waitingCalledAm = []
  150. let waitingCalledPm = []
  151. let calledArr = []
  152. arr.map(item => {
  153. if(item.status == 1){
  154. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  155. // waitingCalledArr.push(item)
  156. if(item.schedule_type == 1){
  157. waitingCalledAm.push(item)
  158. }else if(item.schedule_type == 2){
  159. waitingCalledPm.push(item)
  160. }
  161. }else if(item.status == 2){
  162. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  163. calledArr.push(item)
  164. }
  165. })
  166. // this.waitingCalled = waitingCalledArr
  167. this.waitingCalledAm = waitingCalledAm
  168. this.waitingCalledPm = waitingCalledPm
  169. // this.called = calledArr
  170. }
  171. if(res.data.type == 4){
  172. let arr = res.data.patientQueueList.data
  173. let calledArr = []
  174. arr.map(item => {
  175. if(item.status == 2){
  176. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  177. calledArr.push(item)
  178. }
  179. })
  180. this.called = calledArr
  181. }
  182. }else if(res.channel == 'allQueueList'){
  183. let arr = res.data.queue_list.data
  184. // let waitingCalledArr = []
  185. let waitingCalledAm = []
  186. let waitingCalledPm = []
  187. let calledArr = []
  188. arr.map(item => {
  189. if(item.status == 1){
  190. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  191. // waitingCalledArr.push(item)
  192. if(item.schedule_type == 1){
  193. waitingCalledAm.push(item)
  194. }else if(item.schedule_type == 2){
  195. waitingCalledPm.push(item)
  196. }
  197. }else if(item.status == 2){
  198. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  199. calledArr.push(item)
  200. }
  201. })
  202. // this.waitingCalled = waitingCalledArr
  203. this.waitingCalledAm = waitingCalledAm
  204. this.waitingCalledPm = waitingCalledPm
  205. // this.called = calledArr
  206. }else if(res.channel == 'patientCallInfo'){
  207. res.data.patientInfo.create_time = moment(parseInt(res.data.patientInfo.create_time) * 1000).format('HH:mm')
  208. this.fisrtQueueInfo = res.data.patientInfo
  209. this.newFisrtQueueInfo = res.data.patientInfo
  210. }else if(res.channel == 'fisrtQueueInfo'){
  211. let fisrtQueueInfo = []
  212. this.newFisrtQueueInfo = res.data.patientInfo
  213. if(res.data.patientInfo != null){
  214. if(this.patientStateVal == 0){
  215. fisrtQueueInfo = res.data.patientInfo.morning
  216. if(fisrtQueueInfo != null){
  217. if(fisrtQueueInfo.create_time){
  218. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  219. }
  220. }
  221. }else if(this.patientStateVal == 1){
  222. fisrtQueueInfo = res.data.patientInfo.afternoon
  223. if(fisrtQueueInfo != null){
  224. if(fisrtQueueInfo.create_time){
  225. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  226. }
  227. }
  228. }
  229. }
  230. this.fisrtQueueInfo = fisrtQueueInfo
  231. }
  232. }
  233. },
  234. handleStateChange: function(index) {
  235. this.patientStateVal = index
  236. // if(index == 0){
  237. // let arr = this.waitingCalledAm
  238. // let newArr = []
  239. // arr.map(item => {
  240. // if(item.schedule_type == 1){
  241. // newArr.push(item)
  242. // }
  243. // })
  244. // this.waitingCalledAm = newArr
  245. // }else if(index == 1){
  246. // let arr = this.waitingCalledPm
  247. // let newArr = []
  248. // arr.map(item => {
  249. // if(item.schedule_type == 2){
  250. // newArr.push(item)
  251. // }
  252. // })
  253. // this.waitingCalledPm = newArr
  254. // }
  255. if(index == 2){
  256. let obj = {
  257. cmd: "queue/join",
  258. data: {type:4,page:0,size:0},
  259. };
  260. this.websocketSend(obj)
  261. }
  262. let fisrtQueueInfo = []
  263. if(this.newFisrtQueueInfo != null){
  264. if(this.patientStateVal == 0){
  265. fisrtQueueInfo = this.newFisrtQueueInfo.morning
  266. if(fisrtQueueInfo.create_time){
  267. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  268. }
  269. }else if(this.patientStateVal == 1){
  270. fisrtQueueInfo = this.newFisrtQueueInfo.afternoon
  271. if(fisrtQueueInfo.create_time){
  272. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  273. }
  274. }
  275. }
  276. this.fisrtQueueInfo = fisrtQueueInfo
  277. },
  278. call(patient_id){
  279. if(patient_id == undefined || patient_id == ""){
  280. this.$message.error('已经是最后一位了');
  281. return
  282. }
  283. console.log('patient_id',patient_id)
  284. let org_id = parseInt(sessionStorage.getItem("org_id"));
  285. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  286. axios.get('/api/index/callpatient?org_id=' + org_id + '&patient_id=' + patient_id + '&admin_user_id=' + admin_user_id).then(res => {
  287. console.log(res)
  288. // let patientArr = res.data.queue_list.data
  289. // this.patientArr = patientArr
  290. // this.$emit('child-event',this.patientArr)
  291. if(res.data.code == 200){
  292. this.$message({
  293. message: res.data.msg,
  294. type: 'success'
  295. });
  296. }
  297. })
  298. },
  299. next(patient_id){
  300. if(patient_id == undefined || patient_id == ""){
  301. this.$message.error('已经是最后一位了');
  302. return
  303. }
  304. let schedule_type = null
  305. if(this.patientStateVal == 0){
  306. schedule_type = 1
  307. }else if(this.patientStateVal == 1){
  308. schedule_type = 2
  309. }
  310. console.log('patient_id',patient_id)
  311. let org_id = parseInt(sessionStorage.getItem("org_id"));
  312. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  313. axios.get('/api/index/nextcall?org_id=' + org_id + '&patient_id=' + patient_id + '&admin_user_id=' + admin_user_id + '&schedule_type=' + schedule_type).then(res => {
  314. console.log(res)
  315. // let patientArr = res.data.queue_list.data
  316. // this.patientArr = patientArr
  317. // this.$emit('child-event',this.patientArr)
  318. if(res.data.data.patientInfo == null){
  319. this.$message.error('已经是最后一位了');
  320. return
  321. }
  322. if(res.data.code == 200){
  323. this.$message({
  324. message: res.data.msg,
  325. type: 'success'
  326. });
  327. }
  328. })
  329. },
  330. nextFive(patient_id){
  331. if(patient_id == undefined || patient_id == ""){
  332. this.$message.error('已经是最后一位了');
  333. return
  334. }
  335. let schedule_type = null
  336. if(this.patientStateVal == 0){
  337. schedule_type = 1
  338. }else if(this.patientStateVal == 1){
  339. schedule_type = 2
  340. }
  341. console.log('patient_id',patient_id)
  342. let org_id = parseInt(sessionStorage.getItem("org_id"));
  343. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  344. axios.get('/api/index/nextcall?org_id=' + org_id + '&patient_id=' + patient_id + '&admin_user_id=' + admin_user_id + '&schedule_type=' + schedule_type + '&num=5').then(res => {
  345. console.log(res)
  346. // let patientArr = res.data.queue_list.data
  347. // this.patientArr = patientArr
  348. // this.$emit('child-event',this.patientArr)
  349. if(res.data.data.patientInfo == null){
  350. this.$message.error('已经是最后一位了');
  351. return
  352. }
  353. if(res.data.code == 200){
  354. this.$message({
  355. message: res.data.msg,
  356. type: 'success'
  357. });
  358. }
  359. })
  360. },
  361. pass(patient_id){
  362. console.log('patient_id',patient_id)
  363. let org_id = parseInt(sessionStorage.getItem("org_id"));
  364. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  365. axios.get('/api/index/passcall?org_id=' + org_id + '&patient_id=' + patient_id + '&admin_user_id=' + admin_user_id).then(res => {
  366. console.log(res)
  367. // let patientArr = res.data.queue_list.data
  368. // this.patientArr = patientArr
  369. // this.$emit('child-event',this.patientArr)
  370. if(res.data.code == 200){
  371. this.$message({
  372. message: res.data.msg,
  373. type: 'success'
  374. });
  375. }
  376. })
  377. },
  378. }
  379. }
  380. </script>
  381. <style lang="scss" scoped>
  382. .callingArea{
  383. display: flex;
  384. flex-wrap: wrap;
  385. width: 88%;
  386. // @media only screen and (max-width: 1340px) {
  387. // width:750px;
  388. // }
  389. // @media only screen and (min-width: 415px) and (max-width: 767px) {
  390. // }
  391. }
  392. .nowCalling{
  393. height: 313px;
  394. border: 1px solid #e5e5ee;
  395. // flex: 1;
  396. width: 14%;
  397. text-align: center;
  398. .nowCallingTitle{
  399. font-size: 20px;
  400. font-weight: 600;
  401. margin-top: 20px;
  402. text-align: center;
  403. }
  404. .nowCallingName{
  405. color: #338AFB;
  406. font-size: 18px;
  407. margin-top: 10px;
  408. font-weight: 600;
  409. }
  410. .nowCallingTime{
  411. font-size: 16px;
  412. margin-top: 30px;
  413. }
  414. }
  415. </style>