Index.jsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import React from 'react';
  2. import logo from '@assets/images/logo.png';
  3. import userImage from '@assets/images/userImage.png';
  4. import { Grid } from 'antd-mobile';
  5. import QRCode from 'qrcode';
  6. import { preload } from 'react-dom';
  7. /**
  8. * @刘丹: 医生诊室叫号
  9. */
  10. class DoctorScreen extends React.Component {
  11. constructor() {
  12. super();
  13. this.state = {
  14. pageSize: 5,
  15. patList: [],
  16. };
  17. }
  18. componentDidMount() {
  19. //this.getQrcSrc('https://www.kimi.com/');
  20. this.initScroll();
  21. }
  22. componentDidUpdate(prev) {
  23. if (prev?.userData?.userQrCode != this.props.userData?.userQrCode) {
  24. this.getQrcSrc(this.props.userData?.userQrCode);
  25. }
  26. if (prev.patList != this.props.patList) {
  27. this.setPatList();
  28. }
  29. }
  30. // 初始化滚动
  31. initScroll = () => {
  32. const parentDom = document.getElementById('patWrapDoc');
  33. const childDom = document.getElementById('nextDom');
  34. const style = window.getComputedStyle(parentDom);
  35. const parentH = parentDom.offsetHeight - parseInt(style.paddingTop) - parseInt(style.paddingBottom);
  36. const childH = childDom.children[0].offsetHeight;
  37. const pageSize = Math.floor(parentH / childH) - 1;
  38. this.setState({
  39. pageSize,
  40. });
  41. };
  42. // 滚动设置就诊数据
  43. setPatList = () => {
  44. if (this.state.timer) {
  45. clearTimeout(this.state.timer);
  46. }
  47. this.setState({
  48. current: 0,
  49. totalPage: Math.ceil(this.props.patList?.length / this.state.pageSize),
  50. }, () => {
  51. if (this.props.patList?.length <= this.state.pageSize) {
  52. this.setState({
  53. patList: this.props.patList,
  54. });
  55. } else {
  56. const fn = () => {
  57. let current = this.state.current + 1;
  58. if (current > this.state.totalPage) {
  59. current = 1;
  60. }
  61. const { pageSize } = this.state;
  62. this.setState({
  63. current,
  64. patList: this.props.patList?.slice((current - 1) * pageSize, current * pageSize),
  65. });
  66. // 10s切换
  67. const timer = setTimeout(fn, 6000);
  68. this.setState({
  69. timer,
  70. });
  71. };
  72. fn();
  73. }
  74. });
  75. };
  76. // 链接转二维码链接
  77. getQrcSrc = (src) => {
  78. if (!src) {
  79. return;
  80. }
  81. QRCode.toDataURL(src).then((url) => {
  82. document.querySelector('#qrccodeimg').src = url;
  83. });
  84. };
  85. render() {
  86. const { userData = {}, reWaitPat = [] } = this.props;
  87. return (
  88. <div className='page-body big-scrren'>
  89. <div className='header'>
  90. <img
  91. src={this.props.hosLogo || logo}
  92. alt='Logo'
  93. className={this.props.hosLogo ? 'logo' : 'logodefault'}
  94. onError={(e) => {
  95. e.target.src = `${logo}`;
  96. }}
  97. />
  98. <span className='heaer-btn'>
  99. <span className='date'>接诊中</span>
  100. <br /> Opening
  101. </span>
  102. </div>
  103. <Grid columns={3} gap={8} className='mt'>
  104. <Grid.Item span={1}>
  105. <div className='section'>
  106. <div className='chinese-name big'>{userData.roomDesc || '诊区'}</div>
  107. </div>
  108. </Grid.Item>
  109. <Grid.Item span={2}>
  110. <div className='section'>
  111. <div className='chinese-name big'>{userData.locDesc || '科室'}</div>
  112. </div>
  113. </Grid.Item>
  114. </Grid>
  115. <div className='section mt'>
  116. <Grid columns={23} gap={8}>
  117. <Grid.Item span={4} style={{textAlign: 'center'}}>
  118. <img
  119. src={userData.userImage || userImage}
  120. className='user-header'
  121. />
  122. </Grid.Item>
  123. <Grid.Item span={8}>
  124. <div className='section section-inner'>
  125. <div className='chinese-name'>{userData.userDesc || '医生'}</div>
  126. </div>
  127. </Grid.Item>
  128. <Grid.Item span={11}>
  129. <div className='section section-inner'>
  130. <div className='chinese-name'>{userData.userTitleDesc || '职称'}</div>
  131. </div>
  132. </Grid.Item>
  133. </Grid>
  134. </div>
  135. <div className='section mt'>
  136. <Grid columns={4} gap={16}>
  137. <Grid.Item span={3}>
  138. <div className='doctor-profile'>
  139. {userData.userIntroduce || '医生简介:暂无'}
  140. </div>
  141. </Grid.Item>
  142. <Grid.Item span={1}>
  143. <div className='center'>
  144. <img
  145. className='qrccode-img'
  146. id="qrccodeimg"
  147. />
  148. </div>
  149. <div className='qrccode-text'>扫码关注医师</div>
  150. </Grid.Item>
  151. </Grid>
  152. </div>
  153. <div style={{flex: 1, overflow: 'hidden'}} id="patWrapDoc" className='mt'>
  154. <Grid columns={3} gap={8} style={{height: '100%'}}>
  155. <Grid.Item span={2} style={{height: '100%'}}>
  156. <div className='table section' id="nextDom" style={{height: '100%'}}>
  157. <Grid columns={1} gap={8}>
  158. <Grid.Item span={1}>
  159. <div className='table-header'>候诊</div>
  160. </Grid.Item>
  161. </Grid>
  162. {this.state.patList?.map((item,index) => {
  163. return (<Grid columns={2} gap={8} key={index} className='mt'>
  164. <Grid.Item span={1}>
  165. <div className='table-content'>{item.patName || '***'} { item.patCallNo }</div>
  166. </Grid.Item>
  167. <Grid.Item span={1}>
  168. <div className={item.status == 'waiting' ? 'table-content waiting' :'table-content sussess'}>
  169. {item.status == 'waiting'
  170. ? '候诊'
  171. : '正在就诊'
  172. }
  173. </div>
  174. </Grid.Item>
  175. </Grid>);
  176. })}
  177. </div>
  178. </Grid.Item>
  179. <Grid.Item span={1} style={{height: '100%'}}>
  180. <div className='table section' style={{height: '100%'}}>
  181. <Grid columns={1} gap={8}>
  182. <Grid.Item span={1}>
  183. <div className='table-header'>看报告</div>
  184. </Grid.Item>
  185. </Grid>
  186. {reWaitPat.map((item, index) => {
  187. return (<Grid columns={1} gap={8} key={index}>
  188. <Grid.Item span={1}>
  189. <div className='table-content'>{item.patName || '***'} {item.patCallNo}</div>
  190. </Grid.Item>
  191. </Grid>);
  192. })}
  193. </div>
  194. </Grid.Item>
  195. </Grid>
  196. </div>
  197. <div className='footer'>请按显示信息排队就诊,看报告请到报道机或护士站报到!</div>
  198. </div>
  199. );
  200. }
  201. }
  202. export default DoctorScreen;