Browse Source

代码优化

liudan 2 weeks ago
parent
commit
6de60f2fef

BIN
dist.zip


+ 3 - 3
src/assets/scss/style.scss

@@ -265,8 +265,8 @@ html{
        text-align: center;
       }
       &.state{
-        // font-size: 1.3rem;
-        flex: 0 0 3.4rem;
+        flex: 0 0 3.3rem;
+        font-size: 1.2rem;
       }
     }
   }
@@ -389,7 +389,7 @@ html{
   overflow: visible;
 }
 .marqueeTop {
-  animation: marqueeTop 40s linear infinite;
+  animation: marqueeTop 50s linear infinite;
   width: 100%;
   display: inline-block;
   position: absolute;

+ 4 - 248
src/pages/bigScreen/Index.jsx

@@ -2,7 +2,7 @@ import React from 'react';
 import logo from '@assets/images/logo.png';
 import Scroll from '@components/Scroll.jsx';
 import { Grid } from 'antd-mobile';
-import { initDate } from '@utils/index.js';
+import { initDate, initArray } from '@utils/index.js';
 import ScrollTop from '@components/ScrollTop.jsx';
 import { Swiper } from 'antd-mobile';
 /**
@@ -44,30 +44,10 @@ class BigScreen extends React.Component {
       }
       this.setState({
         patList: newArray,
+        swapperArray: initArray(newArray, 4)
       });
-      this.initArray(newArray);
     }
   }
-  initArray = (data) => {
-    const newArray = [];
-    const len = data.length;
-    if (len <= 4) {
-      newArray.push(data);
-    } else {
-      for (let i = 0, j = 0; i < data.length; i++) {
-        if (i != 0 && i % 4 == 0) {
-          ++j;
-        }
-        if (!newArray[j]) {
-          newArray[j] = [];
-        }
-        newArray[j].push(data[i]);
-      }
-    }
-    this.setState({
-      swapperArray: newArray,
-    });
-  };
   // 叫号的诊室数据默认
   initRoom = () => {
     let cache = localStorage.getItem('ZZJ-base');
@@ -87,232 +67,8 @@ class BigScreen extends React.Component {
             dateNow: data.curDate, //当前日期,
             weekNow: data.curWeekDate, // 当前日期,
           },
+          swapperArray: initArray(data.result, 4),
         });
-        this.initArray(data.result);
-      }
-    }).catch(() => {
-      const data = {
-        'errorCode': 0,
-        'errorMessage': '成功',
-        'result': [
-          {
-            'locID': '2068',
-            'locDesc': '眼科门诊护士站',
-            'locENDesc': '',
-            'roomID': '1054',
-            'roomDesc': '专家诊室1',
-            'smallRoomDesc': '专家诊室1',
-            'roomENDesc': '',
-            'callMsg': {
-              'callPat': [{ 'patCallNo': '1号', 'patName': '患*者' }],
-              'waitPat': [
-                { 'patCallNo': '0800 01', 'patName': '患*者', patCallType: 'V', patCallStatusDesc: '未签' },
-              ],
-              'reWaitPat': [
-                { 'patCallNo': '12', 'patName': '患*者' },
-              ],
-            },
-            'delayPat': '',
-            'readMsg': '',
-            'areaID': '2068',
-            'docName': '王化峰',
-            'deviceList': [
-              {
-                'deviceID': 'BE998867F1FE62AB90EF5D698A1B7AFA3F7B6BF3'
-              },
-              {
-                'deviceID': '0.0.0.0'
-              },
-              {
-                'deviceID': '5e1af217e8d46320AA7DE4007D0836C2F370B1427C0A6D1DBBDA88B1'
-              }
-            ],
-            'path': '/images/wav/',
-            'holdNumber': '0',
-            'userData': {
-              'userID': '5802',
-              'userCode': '390007',
-              'userDesc': '王化峰',
-              'userENDesc': '',
-              'userTitleID': '6',
-              'userTitleDesc': '副主任医师',
-              'userTitleENDesc': '232',
-              'titleDisplay': '',
-              'userSexID': '1',
-              'userSexDesc': '男',
-              'userPositionID': '',
-              'userPositionDesc': '',
-              'userLanguageID': '1',
-              'userLanguageDesc': '简体中文',
-              'userEmailName': '90',
-              'userMobile': '13669859107',
-              'userDOB': '1973-05-29',
-              'userPswActiveDate': 9999,
-              'userDocFlag': 'Y',
-              'userNurFlag': 'N',
-              'userCertNo': '110441900006510',
-              'userSpecID': '',
-              'userSpecDesc': '',
-              'userSubSpecID': '',
-              'userSubSpecDesc': '',
-              'userSurgeon': 'N',
-              'userAnaesthetist': 'Y',
-              'userComments': '',
-              'userDateTo': '',
-              'userDateFrom': '2024-06-28',
-              'userActive': '有效',
-              'userEffective': 'Y',
-              'userAllowLayout': 'N',
-              'userAllowColumn': 'N',
-              'userName': '王化峰',
-              'userCredTypeID': '1',
-              'userCredTypeDesc': '居民身份证',
-              'userCredNo': '340202197305290058',
-              'userPostID': '',
-              'userPostDesc': '',
-              'userImage': '/images/photo/ff6beb5f6dbb23eeca997eca0a44df56.jpg',
-              'personImage': '',
-              'signUrl': '/images/photo/3b09d32a5eb6ba49047666063693b4bc.jpg',
-              'userIntroduce': '副主任医师,医学硕士\n东莞光明眼科医院门诊部主任,常平健明眼科医院业务院长,对眼科常见病和疑难病症有丰富的治疗经验,擅长眼表疾病,白内障,青光眼,眼底病,眼外伤等疾病的诊治,擅长白内障超声乳化摘除加人工晶体植入术,玻璃体视网膜手术,尤其对视网膜脱离和糖尿病视网膜病变的手术治疗有非常丰富的经验。\n中山大学中山眼科中心硕士研究生毕业,从事眼科临床工作二十余年,担任广东省医院协会眼健康管理专业委员会常委,广东省医师协会眼科分会眼底外科学组委员,广东省视光学学会眼底影像专委会委员,广东省医师协会眼科分会眼外伤学组委员。',
-              'insuUserCode': 'D441901014389',
-              'superDocFlag': 'N',
-              'attendDocFlag': 'N',
-              'optometryFlag': 'N',
-              'financialAuthority': 'N',
-              'hospDesc': '东莞常平健明眼科医院',
-              'organizationCode': 'H44190100519',
-              'businesslicense': '91441900MA4UNP4N95',
-              'certNo': '110441900006510',
-              'userLocked': 0,
-              'userTypeDesc': '医师/麻醉医生/',
-              'locCode': '',
-              'locDesc': '眼科门诊护士站',
-              'roomID': '1054',
-              'roomCode': '',
-              'roomDesc': '专家诊室1',
-              'userQrCode': 'https://np.h03.p0551.com/doctorpage/caf1ecdde8c9e81d321e0099ac4dde1f6ed689480130321e43ec40ad6dc82c1b60e259f5500a4deae7d3c1bd110fed012d3b72b372a69fb41b344f1762d946d8'
-            },
-            'voicenameArr': [
-              'zh-CN',
-              'zh-HK'
-            ],
-            'rate': 0
-          },
-          {
-            'locID': '2068',
-            'locDesc': '眼科门诊护士站',
-            'locENDesc': '',
-            'roomID': '1057',
-            'roomDesc': '专家诊室4',
-            'smallRoomDesc': '专家诊室4',
-            'roomENDesc': '',
-            'callMsg': {
-              'callPat': [
-                {
-                  'patName': '',
-                  'patCallNo': '',
-                  'patCallStatus': '',
-                  'patCallStatusDesc': ''
-                }
-              ],
-              'waitPat': [],
-              'reWaitPat': [],
-              'delayPat': ''
-            },
-            'delayPat': '',
-            'readMsg': '',
-            'areaID': '2068',
-            'docName': '张雪玲',
-            'deviceList': [
-              {
-                'deviceID': 'BE998867F1FE62AB90EF5D698A1B7AFA3F7B6BF3'
-              },
-              {
-                'deviceID': '5e1af217e8d46320AA7DE4007D0836C2F370B1427C0A6D1DBBDA88B1'
-              }
-            ],
-            'path': '/images/wav/',
-            'holdNumber': 1,
-            'userData': {
-              'userID': '6539',
-              'userCode': '340141',
-              'userDesc': '张雪玲',
-              'userENDesc': '',
-              'userTitleID': '5',
-              'userTitleDesc': '主任医师',
-              'userTitleENDesc': '231',
-              'titleDisplay': '',
-              'userSexID': '2',
-              'userSexDesc': '女',
-              'userPositionID': '',
-              'userPositionDesc': '',
-              'userLanguageID': '1',
-              'userLanguageDesc': '简体中文',
-              'userEmailName': '89',
-              'userMobile': '13669898332',
-              'userDOB': '1959-11-17',
-              'userPswActiveDate': 9999,
-              'userDocFlag': 'N',
-              'userNurFlag': 'N',
-              'userCertNo': '199844110420620591117004',
-              'userSpecID': '',
-              'userSpecDesc': '',
-              'userSubSpecID': '',
-              'userSubSpecDesc': '',
-              'userSurgeon': 'N',
-              'userAnaesthetist': 'N',
-              'userComments': '',
-              'userDateTo': '',
-              'userDateFrom': '2024-11-25',
-              'userActive': '有效',
-              'userEffective': 'Y',
-              'userAllowLayout': '',
-              'userAllowColumn': '',
-              'userName': '张雪玲',
-              'userCredTypeID': '1',
-              'userCredTypeDesc': '居民身份证',
-              'userCredNo': '420620591117004',
-              'userPostID': '',
-              'userPostDesc': '',
-              'userImage': '/images/photo/f46bea3ff2065c581a6c0fb22cb1ea6a.png',
-              'personImage': '',
-              'signUrl': '',
-              'userIntroduce': '主任医师 东莞光明眼科医院特聘专家\n擅 长:中西医结合治疗眼科常见病、多发病,尤其是对眼表疾病、白内障、青光眼、眼外伤、眼底病的诊断和治疗\n经历:曾任东莞市中医院眼耳鼻喉科主任、中心门诊部主任、东莞市医学会眼科分会委员。从事眼科临床工作四十余年,积累了丰富的临床诊疗经验。',
-              'insuUserCode': 'D441901008067',
-              'superDocFlag': 'N',
-              'attendDocFlag': 'N',
-              'optometryFlag': 'N',
-              'financialAuthority': 'N',
-              'hospDesc': '东莞光明眼科医院',
-              'organizationCode': '74366622544190031A5122',
-              'businesslicense': '74366622544190031A5122',
-              'certNo': '199844110420620591117004',
-              'userLocked': 0,
-              'userTypeDesc': '',
-              'locCode': '',
-              'locDesc': '眼科门诊护士站',
-              'roomID': '1057',
-              'roomCode': '',
-              'roomDesc': '专家诊室4',
-              'userQrCode': 'https://np.h03.p0551.com/doctorpage/48ec77d28e35953d627330a854ef2d62e95595f37f10fd78d1b733eb5b0add7ac637d5a4258f18be32ee1b1cca7761d85b217ccf8c120c293710c957d81da28a'
-            },
-            'voicenameArr': [
-              'zh-CN',
-              'zh-HK'
-            ],
-            'rate': 0
-          }
-        ]
-      };
-      if (data && data.result) {
-        this.setState({
-          patList: data.result,
-          dateStr: {
-            dateNow: data.curDate, //当前日期,
-            weekNow: data.curWeekDate, // 当前日期,
-          },
-        });
-        this.initArray(data.result);
       }
     });
   };
@@ -373,7 +129,7 @@ class BigScreen extends React.Component {
                               <div className='swaper-text icon'>{v.patCallType}</div>
                               <div className='swaper-text' >
                                 {v.patCallNo}
-                                <span style={{ fontSize: '1.46rem' }}>{v.patName}</span>
+                                <span style={{ fontSize: '1.4rem' }}>{v.patName}</span>
                               </div>
                               <div className={
                                 v.patCallStatusDesc == '待诊'

+ 3 - 28
src/pages/doctorScreen/Index.jsx

@@ -5,6 +5,7 @@ import { Grid } from 'antd-mobile';
 import QRCode from 'qrcode';
 import ScrollTop from '@components/ScrollTop.jsx';
 import { Swiper } from 'antd-mobile';
+import { initArray } from '@utils/index.js';
 /**
  * @刘丹: 医生诊室叫号
  */
@@ -26,15 +27,11 @@ class DoctorScreen extends React.Component {
       this.getQrcSrc(this.props.userData?.userQrCode);
     }
     if (prev.patList != this.props.patList) {
-      this.initArray(this.props.waitPat, 'waitPat', 7);
-      this.initArray(this.props.reWaitPat, 'reWaitPat', 8);
       this.setState({
         callPat: this.props.callPat,
+        waitPat: initArray(this.props.waitPat, 7),
+        reWaitPat: initArray(this.props.reWaitPat, 8),
       });
-      // this.setState({
-      //   patList: this.props.patList,
-      //   reWaitPat: this.props.reWaitPat,
-      // });
     }
   }
   // 链接转二维码链接
@@ -46,28 +43,6 @@ class DoctorScreen extends React.Component {
       document.querySelector('#qrccodeimg').src = url;
     });
   };
-  initArray = (data, key, num = 7) => {
-    const newArray = [];
-    const len = data.length;
-    if (len <= num) {
-      newArray.push(data);
-    } else {
-      for (let i = 0, j = 0; i < data.length; i++) {
-        if (i != 0 && i % num == 0) {
-          ++j;
-        }
-        if (!newArray[j]) {
-          newArray[j] = [];
-        }
-        newArray[j].push(data[i]);
-      }
-    }
-    this.setState({
-      [key]: newArray,
-    }, () => {
-      console.log(this.state[key]);
-    });
-  };
   render() {
     const { userData = {} } = this.props;
     return (

+ 1 - 1
src/pages/home/Index.jsx

@@ -271,7 +271,7 @@ class Home extends React.Component {
     this.initAndroidVoice();
     const test = () => {
       var start = 0;
-      setTimeout(() => {
+      setInterval(() => {
         if (start > 12) {
           return;
         }

+ 23 - 0
src/utils/index.js

@@ -13,3 +13,26 @@ export const initDate = () => {
     weekNow: `${weekdays[weekdayNumber]}`,
   };
 };
+/**
+ * 数组data拆分为num个为一组的二维数组
+ * @param {*} data 
+ * @param {*} num 
+ */
+export  const initArray = (data, num = 7) => {
+  const newArray = [];
+  const len = data.length;
+  if (len <= num) {
+    newArray.push(data);
+  } else {
+    for (let i = 0, j = 0; i < data.length; i++) {
+      if (i != 0 && i % num == 0) {
+        ++j;
+      }
+      if (!newArray[j]) {
+        newArray[j] = [];
+      }
+      newArray[j].push(data[i]);
+    }
+  }
+  return newArray;
+};