local_history.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. Index: src/views/board/index.vue
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- src/views/board/index.vue (date 1673333434525)
  7. +++ src/views/board/index.vue (date 1673333434525)
  8. @@ -1,0 +1,362 @@
  9. +<template>
  10. + <div>
  11. + <div v-show="hasRegister">
  12. + <el-header>
  13. + <el-image :src="logo" style="width: 50px; height: 50px" fit="fill" />
  14. + <div class="title">{{ title }}</div>
  15. + <!-- <div class="time">{{ currentTime }}</div>-->
  16. + </el-header>
  17. +
  18. + <el-main>
  19. + <my-carousel ref="carousel" :height="mainAreaHeight+'px'" :interval.sync="swiperInterval" indicator-position="none" arrow="never" :autoplay="autoplay" @change="swiperChange">
  20. + <el-carousel-item>
  21. + <sick-bed-board :bed-info-array="bedInfoArray" :height="mainAreaHeight" :interval="subInterval" :auto-play="carouselCurrentIndex===0" />
  22. + </el-carousel-item>
  23. + <el-carousel-item>
  24. + <calling-list-board :call-data="callData" :nurse-info-data="nurseInfoData" />
  25. + </el-carousel-item>
  26. + <el-carousel-item v-for="(bt,index) in boardData" :key="index">
  27. + <work-info-display :board-title="bt" :work-infos="boardData[index].contents" :height="mainAreaHeight" :interval="subInterval" :auto-play="carouselCurrentIndex===3" />
  28. + </el-carousel-item>
  29. + </my-carousel>
  30. +
  31. + </el-main>
  32. + </div>
  33. + <div v-show="!hasRegister">
  34. + <div class="bullshit">
  35. + <div class="bullshit__oops text-lg text-cyan margin-top-lg">这是一台新的看板设备,请在呼叫中心管理后台设置该设备的所属科室。</div>
  36. + <div class="bullshit__info text-lg text-cyan margin-top-lg">
  37. + 该设备MAC地址为:<span class="text-red">{{ deviceMAC }}</span> ,ID号为:<span class="text-red">{{ deviceId }}</span>
  38. + </div>
  39. + <div class="bullshit__headline" />
  40. + <div class="bullshit__info text-lg text-cyan margin-top-lg">如有疑问,请联系管理员,谢谢!</div>
  41. + </div>
  42. + </div>
  43. + </div>
  44. +</template>
  45. +
  46. +<script>
  47. +import logo from '@/assets/logo.png'
  48. + import * as API_Board from '@/api/board'
  49. + import SickBedBoard from './components/sickBedBoard'
  50. + import CallingListBoard from './components/callingListBoard'
  51. + import WorkInfoDisplay from './components/workInfoDisplay'
  52. + import MyCarousel from '../../components/MyCarousel/index'
  53. + // import { deviceUrl } from '@/utils/domain'
  54. + const deviceUrl = domain.deviceUrl
  55. + export default {
  56. + name: 'Index',
  57. + components: { MyCarousel, WorkInfoDisplay, CallingListBoard, SickBedBoard },
  58. + data() {
  59. + return {
  60. + logo: logo,
  61. + currentTime: '',
  62. + title: '', // 顶部标题
  63. + titles: [], // 标题数组
  64. + timeStr: '',
  65. + swiperInterval: 5000,
  66. + subInterval: 5000,
  67. + stayIndex: 1,
  68. + staySeconds: [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
  69. + showModal: false,
  70. + modalContent: '',
  71. + serverTitle: '',
  72. + bedInfoArray: [], // 床位二维数组
  73. + callData: [],
  74. + nurseInfoData: [],
  75. + boardRowsQty: 10,
  76. + boardData: {},
  77. + carouselCurrentIndex: 0,
  78. + autoplay: true,
  79. + deviceMAC: this.$route.query.mac,
  80. + websock: null,
  81. + hasRegister: false,
  82. + deviceId: ''
  83. + }
  84. + },
  85. + computed: {
  86. + mainAreaHeight() {
  87. + return Number(document.documentElement.clientHeight) - 60
  88. + }
  89. + },
  90. + mounted() {
  91. + // Message({
  92. + // message: '设备宽度' + document.documentElement.clientWidth,
  93. + // duration: 100000
  94. + // })
  95. + if (this.$route.query.mac !== undefined && this.$route.query.mac !== '') {
  96. + // 保存mac地址
  97. + this.$store.dispatch('user/setDeviceMAC', this.$route.query.mac)
  98. + // 初始化websocket
  99. + this.initWebSocket()
  100. + }
  101. + const _this = this
  102. + // 每分钟检查一次websocket状态,如果掉线,则重连
  103. + setInterval(function() {
  104. + if (_this.websock === null || _this.websock.readyState !== 1) {
  105. + _this.initWebSocket()
  106. + }
  107. + }, 60000)
  108. +
  109. + // this.start()
  110. + },
  111. + methods: {
  112. + getBedInfo() {
  113. + API_Board.getBedInfo(this.$store.getters.partid).then(res => {
  114. + const json = res
  115. + this.serverTitle = (json['hospital_name'] || '') + json['part_name']
  116. + if (this.title === '') {
  117. + this.title = this.serverTitle
  118. + }
  119. + this.titles = []
  120. + this.titles.push({
  121. + index: 1,
  122. + title: this.serverTitle
  123. + })
  124. + this.titles.push({
  125. + index: 2,
  126. + title: this.serverTitle
  127. + })
  128. + this.getBoardInfo()
  129. + const itemRows = Math.floor(this.mainAreaHeight / 230)
  130. + const itemColumns = document.documentElement.clientWidth > 1200 ? 6 : 3
  131. + const itemCountPerScreen = itemRows * itemColumns
  132. + const mock = [...json['items']]
  133. + const screens = Math.ceil(mock.length / itemCountPerScreen)
  134. + this.bedInfoArray = []
  135. + for (var i = 1; i <= screens; i++) {
  136. + this.bedInfoArray.push(mock.slice((i - 1) * itemCountPerScreen, i * itemCountPerScreen >= mock.length
  137. + ? mock.length : i * itemCountPerScreen))
  138. + }
  139. + })
  140. + },
  141. + getBoardInfo() {
  142. + API_Board.getBoardInfo(this.$store.getters.partid).then(res => {
  143. + this.boardData = [...res]
  144. + res.forEach((bt, index) => {
  145. + this.titles.push({
  146. + index: bt.screen_title.board_index,
  147. + title: bt.screen_title.board_title
  148. + })
  149. + })
  150. +
  151. + this.$nextTick(() => { // 加载完成自定义项之后,设置到固定屏幕.
  152. + if (this.stayIndex !== 0) {
  153. + this.$refs.carousel.setActiveItem(this.stayIndex - 1)
  154. + }
  155. + })
  156. + })
  157. + },
  158. + getTime() {
  159. + var date = new Date()
  160. + var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
  161. + var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  162. + var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  163. + var timer = hour + ':' + minute + ':' + second
  164. + this.currentTime = timer
  165. + },
  166. + getCallList() {
  167. + API_Board.getCallingList(this.$store.getters.partid).then(res => {
  168. + this.callData = [...res]
  169. + })
  170. + },
  171. + getNurseInfoArray() {
  172. + API_Board.getNurseInfoArray(this.$store.getters.partid).then(res => {
  173. + this.nurseInfoData = [...res]
  174. + })
  175. + },
  176. + changeTitle(index) {
  177. + if (this.titles.length === 0) {
  178. + this.title = this.serverTitle
  179. + } else {
  180. + this.$set(this, 'title', this.titles[index].title)
  181. + }
  182. + },
  183. + swiperChange: function(index) {
  184. + if (this.staySeconds.length > 0) {
  185. + if (index === 0) { // 第一屏停留时间要算上子swiper项数停留时间
  186. + this.swiperInterval = Number(this.staySeconds[index]) * 1000 * (this.bedInfoArray.length + 1) // 此屏停留时间要根据子项数量来计算,加入子项有2屏,停留时间设置为3倍
  187. + this.subInterval = Number(this.staySeconds[index]) * 1000 // 子项轮换间隔时间
  188. + } else {
  189. + this.swiperInterval = Number(this.staySeconds[index]) * 1000
  190. + }
  191. + this.carouselCurrentIndex = index
  192. + if (this.titles.length > 0) {
  193. + this.changeTitle(index)
  194. + }
  195. + }
  196. + },
  197. + initWebSocket: function() {
  198. + var stockbase = deviceUrl.replace('http', 'ws')
  199. + this.websock = new WebSocket(stockbase + '/boardinfo/1/' + this.$store.getters.token)
  200. + this.websock.onopen = this.websocketonopen
  201. + this.websock.onerror = this.websocketonerror
  202. + this.websock.onmessage = this.websocketonmessage
  203. + this.websock.onclose = this.websocketclose
  204. + },
  205. + websocketonopen: function() {
  206. + console.log('WebSocket连接成功')
  207. + this.getBedInfo()
  208. + this.getCallList()
  209. + this.getNurseInfoArray()
  210. + },
  211. + websocketonerror: function(e) {
  212. + console.log('WebSocket连接发生错误')
  213. + },
  214. + websocketonmessage: function(e) {
  215. + const boardObj = JSON.parse(e.data)
  216. + if (boardObj.partId !== undefined && boardObj.partId > 0) { // 返回了partid,说明设备已注册
  217. + // 把科室Id设置到store
  218. + this.hasRegister = true
  219. + this.$store.dispatch('user/setPartId', boardObj.partId)
  220. + this.deviceId = boardObj.id
  221. + // 展示看板内容
  222. + new Promise((resolve, reject) => {
  223. + this.getBedInfo()
  224. + this.getCallList()
  225. + this.getNurseInfoArray()
  226. + resolve()
  227. + }).then(() => {
  228. + if (boardObj.config !== null && boardObj.config !== '') {
  229. + const boardconfig = JSON.parse(boardObj.config)
  230. + this.staySeconds = boardconfig.staySeconds // 轮换时间间隔
  231. + // 固定在某一屏
  232. + this.stayIndex = boardconfig.stayIndex
  233. + if (this.stayIndex === 1) {
  234. + this.swiperInterval = Number(this.staySeconds[this.stayIndex - 1]) * 1000 * (this.bedInfoArray.length + 1) // 此屏停留时间要根据子项数量来计算,加入子项有2屏,停留时间设置为3倍
  235. + this.subInterval = Number(this.staySeconds[this.stayIndex - 1 ]) * 1000 // 子项轮换间隔时间
  236. + }
  237. + if (this.stayIndex === 0) { // 0代表不固定 其他数字为固定屏幕序号
  238. + this.autoplay = true
  239. + } else {
  240. + this.autoplay = false
  241. + }
  242. + this.$refs.carousel.setActiveItem(this.stayIndex - 1)
  243. + } else {
  244. + this.autoplay = true
  245. + }
  246. + })
  247. + } else {
  248. + this.deviceId = boardObj.id
  249. + this.hasRegister = false
  250. + }
  251. + },
  252. + websocketclose: function(e) {
  253. + console.log('connection closed (' + e.code + ')')
  254. + },
  255. + unixToDate(unix, format) {
  256. + if (!unix) return unix
  257. + let _format = format || 'yyyy-MM-dd hh:mm:ss'
  258. + const d = new Date(unix * 1000)
  259. + const o = {
  260. + 'M+': d.getMonth() + 1,
  261. + 'd+': d.getDate(),
  262. + 'h+': d.getHours(),
  263. + 'm+': d.getMinutes(),
  264. + 's+': d.getSeconds(),
  265. + 'q+': Math.floor((d.getMonth() + 3) / 3),
  266. + S: d.getMilliseconds()
  267. + }
  268. + if (/(y+)/.test(_format)) _format = _format.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length))
  269. + for (const k in o) if (new RegExp('(' + k + ')').test(_format)) _format = _format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  270. + return _format
  271. + }
  272. +
  273. + }
  274. + }
  275. +</script>
  276. +
  277. +<style scoped>
  278. + .el-main{
  279. + background: #fff;
  280. + padding: 5px;
  281. + }
  282. + .el-header{
  283. + background: #1cbbb4;
  284. + color: #ffffff;
  285. + text-align: center;
  286. + line-height: 60px;
  287. + font-size: 32px;
  288. + display: flex;
  289. + align-items: center;
  290. + justify-content: space-between;
  291. + }
  292. + .el-main{
  293. + height:calc(100vh - 60px);
  294. + }
  295. + .el-carousel{
  296. + height:calc(100vh - 60px);;
  297. + }
  298. + .el-carousel-item{
  299. + background: #1cbbb4;
  300. + }
  301. + .bullshit {
  302. + position: relative;
  303. + text-align: center;
  304. + padding: 30px 0;
  305. + overflow: hidden;
  306. + &__oops {
  307. + font-size: 32px;
  308. + font-weight: bold;
  309. + line-height: 40px;
  310. + color: #1482f0;
  311. + opacity: 0;
  312. + margin-bottom: 20px;
  313. + animation-name: slideUp;
  314. + animation-duration: 0.5s;
  315. + animation-fill-mode: forwards;
  316. + }
  317. + &__headline {
  318. + font-size: 20px;
  319. + line-height: 24px;
  320. + color: #222;
  321. + font-weight: bold;
  322. + opacity: 0;
  323. + margin-bottom: 10px;
  324. + animation-name: slideUp;
  325. + animation-duration: 0.5s;
  326. + animation-delay: 0.1s;
  327. + animation-fill-mode: forwards;
  328. + }
  329. + &__info {
  330. + font-size: 13px;
  331. + line-height: 21px;
  332. + color: grey;
  333. + opacity: 0;
  334. + margin-bottom: 30px;
  335. + animation-name: slideUp;
  336. + animation-duration: 0.5s;
  337. + animation-delay: 0.2s;
  338. + animation-fill-mode: forwards;
  339. + }
  340. + &__return-home {
  341. + display: block;
  342. + float: left;
  343. + width: 110px;
  344. + height: 36px;
  345. + background: #1482f0;
  346. + border-radius: 100px;
  347. + text-align: center;
  348. + color: #ffffff;
  349. + opacity: 0;
  350. + font-size: 14px;
  351. + line-height: 36px;
  352. + cursor: pointer;
  353. + animation-name: slideUp;
  354. + animation-duration: 0.5s;
  355. + animation-delay: 0.3s;
  356. + animation-fill-mode: forwards;
  357. + }
  358. + @keyframes slideUp {
  359. + 0% {
  360. + transform: translateY(60px);
  361. + opacity: 0;
  362. + }
  363. + 100% {
  364. + transform: translateY(0);
  365. + opacity: 1;
  366. + }
  367. + }
  368. + }
  369. +
  370. +</style>