computerCalling.vue 12KB

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