beforeDialysisCalling.vue 10KB

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