beforeDialysisCalling.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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.channel == 'queue/join'){
  120. if(res.data.type == 3){
  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. // this.waitingCalled = waitingCalledArr
  157. this.waitingCalledAm = waitingCalledAm
  158. this.waitingCalledPm = waitingCalledPm
  159. this.called = calledArr
  160. }
  161. }else if(res.channel == 'allQueueList'){
  162. let arr = res.data.queue_list.data
  163. // let waitingCalledArr = []
  164. let waitingCalledAm = []
  165. let waitingCalledPm = []
  166. let calledArr = []
  167. arr.map(item => {
  168. if(item.status == 1){
  169. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  170. // waitingCalledArr.push(item)
  171. if(item.schedule_type == 1){
  172. waitingCalledAm.push(item)
  173. }else if(item.schedule_type == 2){
  174. waitingCalledPm.push(item)
  175. }
  176. }else if(item.status == 2){
  177. item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
  178. calledArr.push(item)
  179. }
  180. })
  181. // this.waitingCalled = waitingCalledArr
  182. this.waitingCalledAm = waitingCalledAm
  183. this.waitingCalledPm = waitingCalledPm
  184. this.called = calledArr
  185. }else if(res.channel == 'patientCallInfo'){
  186. res.data.patientInfo.create_time = moment(parseInt(res.data.patientInfo.create_time) * 1000).format('HH:mm')
  187. this.fisrtQueueInfo = res.data.patientInfo
  188. }
  189. }
  190. },
  191. handleStateChange: function(index) {
  192. this.patientStateVal = index
  193. // if(index == 0){
  194. // let arr = this.waitingCalledAm
  195. // let newArr = []
  196. // arr.map(item => {
  197. // if(item.schedule_type == 1){
  198. // newArr.push(item)
  199. // }
  200. // })
  201. // this.waitingCalledAm = newArr
  202. // }else if(index == 1){
  203. // let arr = this.waitingCalledPm
  204. // let newArr = []
  205. // arr.map(item => {
  206. // if(item.schedule_type == 2){
  207. // newArr.push(item)
  208. // }
  209. // })
  210. // this.waitingCalledPm = newArr
  211. // }
  212. let fisrtQueueInfo = []
  213. if(this.newFisrtQueueInfo != null){
  214. if(this.patientStateVal == 0){
  215. fisrtQueueInfo = this.newFisrtQueueInfo.morning
  216. if(fisrtQueueInfo.create_time){
  217. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  218. }
  219. }else if(this.patientStateVal == 1){
  220. fisrtQueueInfo = this.newFisrtQueueInfo.afternoon
  221. if(fisrtQueueInfo.create_time){
  222. fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
  223. }
  224. }
  225. }
  226. this.fisrtQueueInfo = fisrtQueueInfo
  227. },
  228. call(patient_id){
  229. if(patient_id == undefined || patient_id == ""){
  230. this.$message.error('已经是最后一位了');
  231. return
  232. }
  233. console.log('patient_id',patient_id)
  234. let org_id = parseInt(sessionStorage.getItem("org_id"));
  235. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  236. axios.get('/api/index/callpatient?org_id=' + org_id + '&patient_id=' + patient_id + '&admin_user_id=' + admin_user_id).then(res => {
  237. console.log(res)
  238. // let patientArr = res.data.queue_list.data
  239. // this.patientArr = patientArr
  240. // this.$emit('child-event',this.patientArr)
  241. if(res.data.code == 200){
  242. this.$message({
  243. message: res.data.msg,
  244. type: 'success'
  245. });
  246. }
  247. })
  248. },
  249. next(patient_id){
  250. if(patient_id == undefined || patient_id == ""){
  251. this.$message.error('已经是最后一位了');
  252. return
  253. }
  254. let schedule_type = null
  255. if(this.patientStateVal == 0){
  256. schedule_type = 1
  257. }else if(this.patientStateVal == 0){
  258. schedule_type = 2
  259. }
  260. console.log('patient_id',patient_id)
  261. let org_id = parseInt(sessionStorage.getItem("org_id"));
  262. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  263. 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 => {
  264. console.log(res)
  265. // let patientArr = res.data.queue_list.data
  266. // this.patientArr = patientArr
  267. // this.$emit('child-event',this.patientArr)
  268. if(res.data.data.patientInfo == null){
  269. this.$message.error('已经是最后一位了');
  270. return
  271. }
  272. if(res.data.code == 200){
  273. this.$message({
  274. message: res.data.msg,
  275. type: 'success'
  276. });
  277. }
  278. })
  279. },
  280. pass(patient_id){
  281. console.log('patient_id',patient_id)
  282. let org_id = parseInt(sessionStorage.getItem("org_id"));
  283. let admin_user_id = parseInt(sessionStorage.getItem("admin_user_id"));
  284. axios.get('/api/index/passcall?org_id=' + org_id + '&patient_id=' + patient_id + '&admin_user_id=' + admin_user_id).then(res => {
  285. console.log(res)
  286. // let patientArr = res.data.queue_list.data
  287. // this.patientArr = patientArr
  288. // this.$emit('child-event',this.patientArr)
  289. if(res.data.code == 200){
  290. this.$message({
  291. message: res.data.msg,
  292. type: 'success'
  293. });
  294. }
  295. })
  296. },
  297. }
  298. }
  299. </script>
  300. <style lang="scss" scoped>
  301. .callingArea{
  302. display: flex;
  303. flex-wrap: wrap;
  304. width: 88%;
  305. // @media only screen and (max-width: 1340px) {
  306. // width:750px;
  307. // }
  308. // @media only screen and (min-width: 415px) and (max-width: 767px) {
  309. // }
  310. }
  311. .nowCalling{
  312. height: 313px;
  313. border: 1px solid #e5e5ee;
  314. // flex: 1;
  315. width: 12%;
  316. text-align: center;
  317. .nowCallingTitle{
  318. font-size: 20px;
  319. font-weight: 600;
  320. margin-top: 20px;
  321. text-align: center;
  322. }
  323. .nowCallingName{
  324. color: #338AFB;
  325. font-size: 18px;
  326. margin-top: 10px;
  327. font-weight: 600;
  328. }
  329. .nowCallingTime{
  330. font-size: 16px;
  331. margin-top: 30px;
  332. }
  333. }
  334. </style>