beforeDialysisCalling.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. const moment = require('moment')
  31. import axios from 'axios'
  32. import waitingCalled from './waitingCalled'
  33. import called from './called'
  34. export default {
  35. components:{
  36. waitingCalled,
  37. called
  38. },
  39. data(){
  40. return{
  41. patient_state:[
  42. {value: 0,label: '上午待叫号'},
  43. {value: 1,label: '下午待叫号'},
  44. {value: 2,label: '已叫号'},
  45. ],
  46. patientStateVal: 0,
  47. waitingCalled:[],
  48. called:[],
  49. fisrtQueueInfo:{},
  50. timer:null,
  51. waitingCalledAm:[],
  52. waitingCalledPm:[],
  53. newFisrtQueueInfo:{}
  54. }
  55. },
  56. computed: {
  57. websocket() {
  58. return this.$store.state.user.websocket;
  59. },
  60. },
  61. created(){
  62. this.initData = {
  63. cmd: "queue/join",
  64. data: {type:3,page:0,size:0},
  65. };
  66. this.websocketSend(this.initData)
  67. },
  68. beforeMount() {
  69. if (this.websocket) {
  70. if (this.websocket.readyState == 1) {
  71. this.websocketMess();
  72. } else {
  73. setTimeout(() => {
  74. this.websocketMess();
  75. }, 1000);
  76. }
  77. } else {
  78. setTimeout(() => {
  79. if (this.websocket.readyState == 1) {
  80. this.websocketMess();
  81. } else {
  82. setTimeout(() => {
  83. this.websocketMess();
  84. }, 1000);
  85. }
  86. }, 1000);
  87. }
  88. },
  89. mounted(){
  90. // let obj = {
  91. // cmd: "queue/join",
  92. // data: {type:3,page:0,size:0},
  93. // };
  94. // this.websocketSend(obj)
  95. },
  96. beforeDestroy(){
  97. let unObj = {
  98. cmd: "queue/unjoin",
  99. data: {type:3},
  100. };
  101. this.websocketSend(unObj)
  102. },
  103. methods:{
  104. websocketSend(data) {
  105. try {
  106. this.websocket.send(JSON.stringify(data))
  107. } catch (error) {
  108. this.showError = true;
  109. this.showIndex = 4;
  110. this.errorInfo = "网络异常,请稍后退出重试!";
  111. }
  112. },
  113. websocketMess() {
  114. console.log('执行',this.websocket)
  115. this.websocket.onmessage = e => {
  116. let res = JSON.parse(e.data);
  117. // let res = re.data;
  118. console.log('res3333333333',res)
  119. if(res.data.type == 3){
  120. if(res.channel == 'queue/join'){
  121. let fisrtQueueInfo = []
  122. this.newFisrtQueueInfo = res.data.fisrtQueueInfo
  123. if(res.data.fisrtQueueInfo != null){
  124. if(this.patientStateVal == 0){
  125. fisrtQueueInfo = res.data.fisrtQueueInfo.morning
  126. if(fisrtQueueInfo.create_time){
  127. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  128. }
  129. }else if(this.patientStateVal == 1){
  130. fisrtQueueInfo = res.data.fisrtQueueInfo.afternoon
  131. if(fisrtQueueInfo.create_time){
  132. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  133. }
  134. }
  135. }
  136. this.fisrtQueueInfo = fisrtQueueInfo
  137. let arr = res.data.patientQueueList.data
  138. // let waitingCalledArr = []
  139. let waitingCalledAm = []
  140. let waitingCalledPm = []
  141. let calledArr = []
  142. arr.map(item => {
  143. if(item.status == 1){
  144. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  145. // waitingCalledArr.push(item)
  146. if(item.schedule_type == 1){
  147. waitingCalledAm.push(item)
  148. }else if(item.schedule_type == 2){
  149. waitingCalledPm.push(item)
  150. }
  151. }else if(item.status == 2){
  152. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  153. calledArr.push(item)
  154. }
  155. })
  156. console.log('waitingCalledArr待叫号',waitingCalledArr)
  157. console.log('waitingCalledArr以较好',calledArr)
  158. // this.waitingCalled = waitingCalledArr
  159. this.waitingCalledAm = waitingCalledArr
  160. this.waitingCalledPm = waitingCalledArr
  161. this.called = calledArr
  162. }else if(res.channel == 'allQueueList'){
  163. let arr = res.data.queue_list.data
  164. let waitingCalledArr = []
  165. let calledArr = []
  166. arr.map(item => {
  167. if(item.status == 1){
  168. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  169. waitingCalledArr.push(item)
  170. }else if(item.status == 2){
  171. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  172. calledArr.push(item)
  173. }
  174. })
  175. this.waitingCalled = waitingCalledArr
  176. this.called = calledArr
  177. }else if(res.channel == 'patientCallInfo'){
  178. res.data.patientInfo.create_time = moment(parseInt(res.data.patientInfo.create_time) * 1000).format('HH:mm')
  179. this.fisrtQueueInfo = res.data.patientInfo
  180. }
  181. }
  182. }
  183. },
  184. handleStateChange: function(index) {
  185. this.patientStateVal = index
  186. // if(index == 0){
  187. // let arr = this.waitingCalledAm
  188. // let newArr = []
  189. // arr.map(item => {
  190. // if(item.schedule_type == 1){
  191. // newArr.push(item)
  192. // }
  193. // })
  194. // this.waitingCalledAm = newArr
  195. // }else if(index == 1){
  196. // let arr = this.waitingCalledPm
  197. // let newArr = []
  198. // arr.map(item => {
  199. // if(item.schedule_type == 2){
  200. // newArr.push(item)
  201. // }
  202. // })
  203. // this.waitingCalledPm = newArr
  204. // }
  205. let fisrtQueueInfo = []
  206. if(this.newFisrtQueueInfo != null){
  207. if(this.patientStateVal == 0){
  208. fisrtQueueInfo = this.newFisrtQueueInfo.morning
  209. if(fisrtQueueInfo.create_time){
  210. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  211. }
  212. }else if(this.patientStateVal == 1){
  213. fisrtQueueInfo = this.newFisrtQueueInfo.afternoon
  214. if(fisrtQueueInfo.create_time){
  215. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  216. }
  217. }
  218. }
  219. this.fisrtQueueInfo = fisrtQueueInfo
  220. },
  221. call(patient_id){
  222. if(patient_id == undefined || patient_id == ""){
  223. this.$message.error('已经是最后一位了');
  224. return
  225. }
  226. console.log('patient_id',patient_id)
  227. let org_id = parseInt(sessionStorage.getItem("org_id"));
  228. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  229. axios.get('/api/index/callpatient?org_id=' + org_id + '&patient_id=' + patient_id + '&admin_user_id=' + admin_user_id).then(res => {
  230. console.log(res)
  231. // let patientArr = res.data.queue_list.data
  232. // this.patientArr = patientArr
  233. // this.$emit('child-event',this.patientArr)
  234. if(res.data.code == 200){
  235. this.$message({
  236. message: res.data.msg,
  237. type: 'success'
  238. });
  239. }
  240. })
  241. },
  242. next(patient_id,schedule_type){
  243. if(patient_id == undefined || patient_id == ""){
  244. this.$message.error('已经是最后一位了');
  245. return
  246. }
  247. console.log('patient_id',patient_id)
  248. let org_id = parseInt(sessionStorage.getItem("org_id"));
  249. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  250. 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 => {
  251. console.log(res)
  252. // let patientArr = res.data.queue_list.data
  253. // this.patientArr = patientArr
  254. // this.$emit('child-event',this.patientArr)
  255. if(res.data.data.patientInfo == null){
  256. this.$message.error('已经是最后一位了');
  257. return
  258. }
  259. if(res.data.code == 200){
  260. this.$message({
  261. message: res.data.msg,
  262. type: 'success'
  263. });
  264. }
  265. })
  266. },
  267. pass(patient_id){
  268. console.log('patient_id',patient_id)
  269. let org_id = parseInt(sessionStorage.getItem("org_id"));
  270. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  271. axios.get('/api/index/passcall?org_id=' + org_id + '&patient_id=' + patient_id + '&admin_user_id=' + admin_user_id).then(res => {
  272. console.log(res)
  273. // let patientArr = res.data.queue_list.data
  274. // this.patientArr = patientArr
  275. // this.$emit('child-event',this.patientArr)
  276. if(res.data.code == 200){
  277. this.$message({
  278. message: res.data.msg,
  279. type: 'success'
  280. });
  281. }
  282. })
  283. },
  284. }
  285. }
  286. </script>
  287. <style lang="scss" scoped>
  288. .callingArea{
  289. display: flex;
  290. flex-wrap: wrap;
  291. width: 88%;
  292. // @media only screen and (max-width: 1340px) {
  293. // width:750px;
  294. // }
  295. // @media only screen and (min-width: 415px) and (max-width: 767px) {
  296. // }
  297. }
  298. .nowCalling{
  299. height: 313px;
  300. border: 1px solid #e5e5ee;
  301. // flex: 1;
  302. width: 12%;
  303. text-align: center;
  304. .nowCallingTitle{
  305. font-size: 20px;
  306. font-weight: 600;
  307. margin-top: 20px;
  308. text-align: center;
  309. }
  310. .nowCallingName{
  311. color: #338AFB;
  312. font-size: 18px;
  313. margin-top: 10px;
  314. font-weight: 600;
  315. }
  316. .nowCallingTime{
  317. font-size: 16px;
  318. margin-top: 30px;
  319. }
  320. }
  321. </style>