فهرست منبع

删除tools中无用函数,右侧推送参数提取,模板引用重复推送bug修改2425

zhouna 5 سال پیش
والد
کامیت
453efe3445

+ 3 - 11
src/common/components/EditableSpan/index.jsx

@@ -1,7 +1,7 @@
 import React,{Component} from 'react';
 import style from './index.less';
 import config from "@config/index";
-import {filterArr,isIE,getPageCoordinate,filterDataArr} from '@utils/tools.js';
+import {filterArr,isIE,getPageCoordinate,filterDataArr,preventDefault} from '@utils/tools.js';
 import Notify from '../Notify/index.js';
 import classNames from 'classnames';
 
@@ -170,11 +170,7 @@ class EditableSpan extends Component{
       let preObj = $(this.$span.current).prev();
       let obj = preObj[0]&&preObj[0].nodeName=="DIV"?preObj.prev():preObj;
       if(textIndex == 0){
-        if(ev.preventDefault){//阻止默认事件
-          ev.preventDefault();
-        }else{
-          ev.returnValue=false;
-        }
+        preventDefault(ev);
         if(obj){
           this.moveEnd(obj[0]);
         }
@@ -184,11 +180,7 @@ class EditableSpan extends Component{
       let nextObj = $(this.$span.current).next();
       let obj = nextObj[0]&&nextObj[0].nodeName=="DIV"?nextObj.next():nextObj;
       if(textIndex == textLength || textLength==undefined || (textIndex == 0 && textLength==1)){
-        if(ev.preventDefault){//阻止默认事件
-          ev.preventDefault();
-        }else{
-          ev.returnValue=false;
-        }
+        preventDefault(ev);
         if(obj){
           obj.focus();
         }

+ 2 - 2
src/components/AssessResult/ScaleItem/index.jsx

@@ -7,7 +7,7 @@ import level1 from "@common/images/级别1.png";
 import checkIcon from '@common/images/check.png';
 import {ComplexModal,MiniToast,Radio} from '@commonComp';
 import Notify from '@commonComp/Notify';
-import {deepClone} from '@utils/tools';
+import {deepClone,preventDefault} from '@utils/tools';
 import { getFormulaResult } from '@store/async-actions/fetchModules'
 /**
  * 来源于页面选择
@@ -79,7 +79,7 @@ class ScaleItem extends Component {
   handleReg(e){   //只能输入数字和特殊符号
     const key = e.key;
     if(key!='Backspace'&&((/[^\d|.\/%*~]/.test(key)))){
-      e.preventDefault();
+      preventDefault(e);
     }
   }
   handleInputformula(id,calcuContent,i,e) {

+ 1 - 8
src/components/ChronicInfo/index.jsx

@@ -232,13 +232,6 @@ class ChronicInfo extends React.Component{
     this.closeFormula(it);
     chronicMagItem&&this.handleAddAssessItem(v,pIndex,i);
   }
-  handleReg(e){   //只能输入数字和特殊符号
-    //const hasDot = e.target.value.indexOf('.')!=-1;
-    // const key = e.key;
-    // if(key!='Backspace'&&((/[^\d|.\/%*~]/.test(key)))){
-    //   e.preventDefault();
-    // }
-  }
   handleInputformula(id,calcuContent,i,e) {
     const {calcuValues} = this.state;
     let obj = deepClone(calcuValues);
@@ -450,7 +443,7 @@ class ChronicInfo extends React.Component{
                                           <span>{item.isShow == '0' ? item.name+':':'请输入'+item.name+':'}</span>
                                         </td>
                                         <td>
-                                          {item.isShow == '0' ? item.value + ' ' +item.uint : <input type="text" className={style['itemInp']} placeholder="请输入"  value={item.value} onKeyDown={this.handleReg.bind(this)} onInput={this.handleInputformula.bind(this,v.conceptId,details,idd)}/>}
+                                          {item.isShow == '0' ? item.value + ' ' +item.uint : <input type="text" className={style['itemInp']} placeholder="请输入"  value={item.value} onInput={this.handleInputformula.bind(this,v.conceptId,details,idd)}/>}
                                         </td>
                                         <td>
                                           {item.isShow != '0'&&<span>{item.uint}</span>}

+ 3 - 3
src/containers/DiagnosticList.js

@@ -9,6 +9,7 @@ import {keepPushData} from '@store/actions/tabTemplate';
 import { visibleHistory } from '@store/actions/historyTemplates'
 import {autoFillModules} from '@store/async-actions/fetchModules';
 import {SET_ASSESS_DATA} from '@types/assessResult';
+import {didPushParamChange} from '@utils/tools';
 
 function mapStateToProps(state) {
     const {diagnosticList,assessResult,pushMessage } = state;
@@ -78,9 +79,6 @@ function mapDispatchToProps(dispatch) {
                 type: GET_DIAGNOSTIC_STR
             });
         },
-        getSearchResult:() => {
-            dispatch(getSearchResult)
-        },
         showTreat: () => {
             dispatch({
                 type: SHOW_TREAT,
@@ -95,7 +93,9 @@ function mapDispatchToProps(dispatch) {
             dispatch(getConceptDetail(item,noTips,noDetails,noNotify))
         },
         getBilling: () => {
+          if (didPushParamChange()) {
             dispatch(billing())
+          }
         },
         hideReferRecord: ()=>{
             dispatch({

+ 3 - 14
src/store/async-actions/fetchModules.js

@@ -11,6 +11,7 @@ import {CURRENT_CHRONIC} from '@store/types/currentIll';
 import {MODI_LOADING} from '@store/types/homePage';
 import {GET_ALL_HIS,FILTER_ALL_HIS} from '@store/types/emergencyHis';
 import {SET_IMPORT_CHECKBODY_LABEL} from "../types/checkBody";
+import {getBigPush} from '@utils/utils';
 
 const api={
   // getSpreadModule:'/questionInfo/getByIds',
@@ -18,7 +19,6 @@ const api={
   getModule:'/questionInfo/getById',
   searchURL: '/retrieval/getTagInfos',
   getOtherHisRecord: '/inquiryInfo/getLastOther',
-  getBigPush:'/push/pushInner',
   saveMode:'/doctorPageMode/saveDoctorPageModes',
   getSymptomFeature:'/feature/getSymptomFeature',
   getAssess:'/evaluationModuleMapping/getEvaluationModules',    //获取管理评估-慢病
@@ -134,19 +134,8 @@ export function pregetCheckbodyData(flag){     //flag=true获取到数据后立
     if(flag){
       dispatch({type:MODI_LOADING,flag:true});
     }
-    const emrData = getEMRParams();
-    const param = {
-      age: emrData.age,
-      featureType: "1,42,41,7",
-      diag: emrData.dis,
-      lis: emrData.lis,
-      other: emrData.other,
-      pacs: emrData.pacs,
-      sex: emrData.sex,
-      vital:emrData.vital,
-      symptom: emrData.current+emrData.main
-    };
-    json(api.getBigPush,param).then((res)=>{
+
+    getBigPush("1,42,41,7").then((res)=>{
       if(+res.data.code === 0){
         const obj = res.data.data;
         const data = obj&&obj.moduleVital;

+ 6 - 23
src/store/async-actions/pushMessage.js

@@ -3,13 +3,13 @@ import { BILLING_ADVICE, SET_TIPS, SET_TIPS_DETAILS ,SET_CHRONIC_TABLELIST,SET_S
 import { SET_DRUG_INFO, SHOW_DRUG_INFO } from '@store/types/treat';
 import { SET_CLICK_DIAG } from '../types/diagnosticList';
 import {storageLocal,getEMRParams} from '@utils/tools';
+import {getBigPush} from '@utils/utils';
 import {SET_IMPORT_CHECKBODY_LABEL,PRESET} from "../types/checkBody";
 import dataLis from '@components/EmergencyProcedure/emergency';
 import  Notify from '@commonComp/Notify';
 import {pregetCheckbodyData} from '@store/async-actions/fetchModules';
 import {tabChange} from '@store/actions/tabTemplate';
 const api={
-  push:'/push/pushInner',
   getTableList:'/scale/getList', //获取量表列表
   getTableInfo:'/scale/getContent', //获取量表明细
   getConceptDetail:'/conceptDetail/getConceptDetail', //获取静态提示信息
@@ -19,28 +19,14 @@ const api={
 export const billing = (mdata,boxMark) => {
  return (dispatch, getState) =>{
   const state = getState();
-  let url = api.push;
    const checkBody = state.checkBody.data;
    let diagMain = state.diagnosticList.diagnosticList.length>0&&state.diagnosticList.diagnosticList[0]
    let getCheck = boxMark==2&&!(checkBody&&checkBody.length>0&&!checkBody[0].full);
   const emrData = getEMRParams();
-  const params = {
-    age: emrData.age,
-    featureType: getCheck?"42,41,5,6,7":"42,5,6,7",    //41只返回查体模板,4只返回查体高亮
-    // featureType: "22",
-    diag: emrData.dis,
-    lis: emrData.lis,
-    other: emrData.other,
-    pacs: emrData.pacs,
-    sex: emrData.sex,
-    vital:emrData.vital,
-    symptom: mdata?(emrData.current + mdata):(emrData.current + emrData.main),
-    hosCode: emrData.hosCode
-  };
-  let savePm = Object.assign({},params);
-  delete savePm.featureType;
-  storageLocal.set('emrParam',savePm);      //推送数据存储,用作推送前对比是否有变,有变才推送
-    json(url, params).then((data) => {
+  //mdata为主诉无标签直接输入时的内容,symptom参数传主诉+现病史文本
+  const mainData =  mdata?(emrData.current + mdata):(emrData.current + emrData.main);
+  const feaType = getCheck?"42,41,5,6,7":"42,5,6,7";    //41只返回查体模板,4只返回查体高亮
+   getBigPush(feaType,mainData,true).then((data) => {
         let {dis, lab, pacs,vitalIds,moduleVital} = data.data.data||{};
         lab = lab||[];
         pacs = pacs||[];
@@ -115,10 +101,8 @@ export const billing = (mdata,boxMark) => {
       console.log(e)
   });
    //单独调指标
-   const ps = Object.assign({},params,{featureType:'22'});
-   json(url, ps).then((data) => {
+   getBigPush('22',mainData).then((data) => {
      let {medicalIndications} = data.data.data||{};
-
      //慢病推送模块数据
      dispatch({
        type:SET_CHRONIC_PUSHS,
@@ -286,7 +270,6 @@ export const getScaleInfo = (it)=>{
             symptom: emrData.current + emrData.main,
             // indications:'' //指标结果
           };
-        // json(api.push, params)
         json(api.getTableInfo, params)
         .then((res)=>{
             const result = res.data;

+ 3 - 1
src/store/async-actions/tabTemplate.js

@@ -171,7 +171,9 @@ export const setPageView = (id) => { //获取模板结构化数据
       if (data.code == 0) {
         //模板列表不筛选模式后,单个模式引用时看本身的模式
         pushAllDataList(data.data.type, 'push', data.data, 'template')//引用
-        store.dispatch(billing())
+        if(didPushParamChange()){     //诊断变化时会调推送,避免重复调
+          dispatch(billing())
+        }
       } else {
         Notify.error(data.msg);
       }

+ 3 - 137
src/utils/tools.js

@@ -22,84 +22,7 @@ import $ from 'jquery';
  * 工具函数
  *
  * ***/
-const ARR = "Array";
-const NUMBER = "Number";
-const STRING = "String";
-const OBJECT = "Object";
-const UNDEFINED = "Undefined";
-const NULL = "Null";
-const BOOLEAN = "Boolean";
 const qs = require('qs');
-
-//  数据类型判断
-const Type = {
-    typeConstant: {
-        'array': ARR,
-        'number': NUMBER,
-        'string': STRING,
-        'object': OBJECT,
-        'undefined': UNDEFINED,
-        'null': NULL,
-        'boolean': BOOLEAN
-    },
-    tolower: (str)=> {
-        if(typeof str !== "string") {
-            return "";
-        }
-        return str.toLowerCase();
-    },
-    checkType: (el, type)=> {
-        type = Type.tolower(type);
-        type = Type.typeConstant[type];
-        return Object.prototype.toString.call(el) === "[object "+ type +"]";
-    }
-}
-
-// 计算字符串长度,该长度将一个中文字算作2个字符长度
-const regexp = {
-    ch: (str)=> {//匹配中文
-        if(typeof str !== "string") {
-            return "";
-        }
-        return str.match(/[\u4e00-\u9fa5]/g) || "";
-    },
-    chLen: function (str) {//中文长度
-        return regexp.ch(str).length;
-    },
-    strLen: function (str) {//字符串长度(一个中文当作两个英文字母)
-        if(typeof str !== "string") {
-            return 0;
-        }
-        return str.length + regexp.chLen(str);
-    }
-}
-
-//判断是否空对象或未定义
-const isUndefined = function (str) {
-    if(str === 0 || str === "") {
-        return false;
-    }
-    return (Type.checkType(str, 'null') || Type.checkType(str, 'undefined'));
-   
-}
-//sessionStorage方法封装
-const Storage = {
-    session: {
-        get: function (name) {
-            return JSON.parse(sessionStorage.getItem(name));
-        },
-        set: function (name, data) {
-            sessionStorage.setItem(name, JSON.stringify(data));
-        },
-        remove: function (name) {
-            sessionStorage.removeItem(name);
-        },
-        clear: function () {
-            sessionStorage.clear();
-        }
-    }
-};
-
 //localStorage方法封装
 const storageLocal = {
   set: function (name, data) {
@@ -122,8 +45,6 @@ const storageLocal = {
   }
 };
 
-const nullFn = ()=>{};
-
 //是否为空
 const isNull = (item)=>{
     return String(item)=== "" || String(item)==="null" || String(item)==="undefined";
@@ -715,16 +636,16 @@ function didPushParamChange(){
   const oldParams = storageLocal.get('emrParam');
   const newParams = JSON.stringify({
     age: emrData.age,
+    hosCode:emrData.hosCode,
     diag: emrData.dis,
     lis: emrData.lis,
     other: emrData.other,
     pacs: emrData.pacs,
     sex: emrData.sex,
     vital:emrData.vital,
-    symptom: emrData.current + emrData.main,
-    hosCode:emrData.hosCode
+    symptom: emrData.current + emrData.main
   });
-  if(newParams == oldParams){
+  if(newParams === oldParams){
       return false;
   }
   return true;
@@ -932,19 +853,6 @@ function parseChartData(indexData){
   //nameObj,obj;
   return {nameObj,obj};
 }
-//函数类工具,对函数进行操作 返回函数
-//延时操作
-function debounce(func, delay) {
-  let timer = null;
-  return function (...args) {
-    if (timer) {
-      clearTimeout(timer);
-    }
-    timer = setTimeout(() => {
-      func.apply(this, args);
-    }, delay);
-  }
-}
 
 // 时间戳转换日期
 function dateParser(timestamp,link = '-'){
@@ -960,40 +868,6 @@ function dateParser(timestamp,link = '-'){
   return result;
 }
 
-//时间搓转换年龄
-function getAge(time){
-  const birthday = new Date(time),
-    year = birthday.getFullYear(),
-    month = birthday.getMonth() + 1,
-    day = birthday.getDate(),
-    now = new Date(),
-    now_year = now.getFullYear(),
-    now_month = now.getMonth() + 1,
-    now_day = now.getDate();
-  let age= now_year - year;
-  if (now_month > month) {
-    age += 1;
-  } else if (now_month === month) {
-    if (now_day >= day) {
-      age += 1;
-    }
-  }
-  return age;
-};
-
-//获取URL参数-返回json对象
-function parseUrl(url){
-  const r = url.substr(1).split("&"),
-    obj = {};
-  r.forEach((v) => {
-    const index = v.indexOf('=');
-    if (index > -1) {
-      obj[v.substring(0, index)] = v.substring(index + 1);
-    }
-  });
-  return obj;
-}
-
 //获取组合组件已填文字填入saveText
 function getSaveText(data){//console.log(data)
   const arr = data.questionMapping.map((it)=>{
@@ -1431,21 +1305,13 @@ function setPosition (e,dom,setHighter){
   },10);
 }
 module.exports = {
-    checkType: Type.checkType,
     getIds,
     getWindowInnerWidth,
     getWindowInnerHeight,
     getLabelIndex,
     fullfillText,
     checkFullfillText,
-    parseUrl,
-    getAge,
     dateParser,
-    debounce,
-    regexp,
-    isUndefined,
-    Storage,
-    nullFn,
     isNotNull,
     isNull,
     deepClone,

+ 29 - 3
src/utils/utils.js

@@ -1,10 +1,12 @@
-import config from '@config/index.js';
-import {getLabelIndex} from './tools';
+import {getLabelIndex,getEMRParams,storageLocal} from './tools';
+import { json } from "./ajax";
 /**
  * 各类标签统一的处理函数
  *
  * */
-
+const api = {
+  push:'/push/pushInner'
+};
 //数字键盘选中事件
 export function setNumberValue(state,action){
   let res = Object.assign({},state);
@@ -131,4 +133,28 @@ export const setRadioInputValue = (state,action)=>{
   res.saveText[index] = str;
   res.update = Math.random();
   return res;
+}
+
+//获取大数据推送结果:
+// type需推送的类型,symData症状相关的内容(symptom入参),save参数是否要保存到本地做变化对比
+export async function getBigPush(type,symData,save){
+  const emrData = getEMRParams();
+  const params = {
+    "age": emrData.age,
+    "hosCode": emrData.hosCode,
+    "featureType": type,  //类型1:症状,4:查体,5:化验,6:辅检,7:诊断
+    "diag": emrData.dis,
+    "lis": emrData.lis,
+    "other": emrData.other,
+    "pacs": emrData.pacs,
+    "sex": emrData.sex,
+    "vital":emrData.vital,
+    "symptom": symData||emrData.current + emrData.main
+  };
+  if(save){
+    let savePm = Object.assign({},params);
+    delete savePm.featureType;
+    storageLocal.set('emrParam',savePm);      //推送数据存储,用作推送前对比是否有变,有变才推送
+  }
+  return json(api.push,params);
 }