Procházet zdrojové kódy

工具函数统一到tools中,删除多余文件

zhouna před 6 roky
rodič
revize
acfe2dd459

+ 0 - 1
src/common/components/Textarea/index.jsx

@@ -2,7 +2,6 @@ import React, { Component } from "react";
 import style from "./index.less";
 import Notify from '../Notify';
 import config from '@config/index';
-import {setLastPosition} from '@common/js/util';
 import {isIE} from '@utils/tools.js';
 import $ from "jquery";
 

+ 0 - 192
src/common/js/func.js

@@ -1,192 +0,0 @@
-import config from '@config/index.js';
-//函数类工具,对函数进行操作 返回函数
-//延时操作
-export function debounce(func, delay) {
-    let timer = null;
-    return function (...args) {
-        if (timer) {
-            clearTimeout(timer);
-        }
-        timer = setTimeout(() => {
-            func.apply(this, args);
-        }, delay);
-    }
-}
-
-// 时间戳转换日期
-export function dateParser(timestamp,link = '-'){
-    let time = new Date(timestamp);
-    let year = time.getFullYear();
-    let month = time.getMonth()+1;
-    let date = time.getDate();
-    let hour = time.getHours().toString().padStart(2,'0');
-    let minute = time.getMinutes().toString().padStart(2,'0');
-    // let result = year+link+month+link+date;
-    let result = year+link+(month<10?"0"+month:month)+link+(date<10?"0"+date:date)+' '+hour+':'+minute;
-    return result;
-}
-
-//时间搓转换年龄
-export const 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对象
-export const 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;
-}
-
-//字符串去空格
-export const strTrim = (str) =>{
-  return str.replace(/&nbsp;|<div>|<\/div>|<br>|\s/g,'');
-};
-
-//获取组合组件已填文字填入saveText
-function getSaveText(data){//console.log(data)
-  const arr = data.questionMapping.map((it)=>{
-    return it.value?(it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||''):'';
-  });
-  return arr.join('');
-}
-
-//添加自由文本标签
-function notTextLabel(label){
-  return +label.tagType!==8;
-}
-/*
-* 给标签组添加自由文本标签
-* 入参:arr源数组,
-*       noPre是否不添加前置文本标签,默认false即添加
-*       noEnd是否不添加后置文本标签,默认false即添加
-*       ifEmpty是否添加空标签,默认true即添加,传false添加逗号,如查体,
-*       showInCheck是否默认在查体中展开
-* */
-export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
-  let newArr =[],
-      pre={},
-      textLabel={},
-      _textLabel={},
-      notText = true,
-      saveText=[],
-      tempText = '',
-      value = '',
-      item={},
-      checkHiddenDefault=false;
-  arr&&arr.map((it,i)=>{
-    notText = notTextLabel(it);
-    value = it.value||'';
-    textLabel = !ifEmpty&&i==0?Object.assign({},JSON.parse(config.textLabel),{showInCheck:true}):JSON.parse(config.textLabel);
-    _textLabel = !ifEmpty&&i<config.showCheckNum+1?Object.assign({},JSON.parse(config._textLabel),{showInCheck:true}):JSON.parse(config._textLabel);
-    if(i===0){
-      //第一个标签不是文本标签时在前面添加文本标签
-      if(!noPre&&notText){
-        newArr.push(textLabel);
-        saveText.push('');
-      }
-      item = ifEmpty?it:Object.assign({},it,{showInCheck:true});
-      newArr.push(item);
-      if(it.tagType != 3){
-        tempText = value?it.labelPrefix+value+it.labelSuffix:'';
-        tempText = notText?tempText:it.value||it.name;
-      }else{
-        tempText = getSaveText(it);
-      }
-      saveText.push(tempText);
-    }else{
-      pre = arr[i-1];
-      item = !ifEmpty&&i<config.showCheckNum?Object.assign({},it,{showInCheck:true}):it;
-      //判断单选项是否有默认选中,位置在隐藏区域时,查体所有标签展示
-      if(!ifEmpty&&!checkHiddenDefault&&i>config.showCheckNum&&+it.tagType===1&&(+it.controlType===0||+it.controlType===1)){
-        if(it.questionDetailList.find((it)=>it.defaultSelect=='1')){
-          checkHiddenDefault=true;
-        }
-      }
-      //如果本身不是文本标签且前面一个也不是文本标签,该标签前面添加文本标签
-      if(notTextLabel(pre)&&notText){
-          // newArr.push(textLabel,it);
-          ifEmpty?newArr.push(textLabel,it):newArr.push(_textLabel,item);
-          if(it.tagType != 3) {
-            tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
-          }else{
-            tempText = getSaveText(it);
-          }
-          saveText.push("",tempText);
-      }else{    //本身是或者前面是文本标签时,前面不添加文本标签
-        newArr.push(item);
-        if(it.tagType != 3) {
-          tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
-          // tempText = notText?tempText:it.value||it.name;
-          tempText = notText ? tempText : (it.value || it.value == "" ? it.value : it.name);
-        }else{
-          tempText = getSaveText(it);
-        }
-        saveText.push(tempText);
-      }
-      if(notText&&!noEnd&&i===arr.length-1){//最后一个非文本标签,后面添加一个文本标签
-        //不能用上面的变量textLabel,因为上一个if可能也进了,这样就是同一个对象,值改变时会同步
-        newArr.push(JSON.parse(config.textLabel));
-        saveText.push("");
-      }
-    }
-  });
-  return {newArr,saveText,checkHiddenDefault};
-};
-
-
-//获取标签index,入参:病例项index+标签index+标签内index
-export const getLabelIndex = (index)=>{
-  let ikey = '';
-  if(index.length == 3){
-    ikey = index.substr(1,1);
-  }else if(index.length == 4){
-    ikey = index.substr(1,2);
-  }else if(index.length == 5){
-    ikey = index.substr(1,3);
-  }
-  return ikey;
-};
-
-export const getWindowInnerHeight = ()=>{
-  if(window.innerHeight!=undefined){
-    return window.innerHeight;
-  }else{
-    let by = document.body, ele = document.documentElement;
-    return Math.min(by.clientHeight,ele.clientHeight);
-  }
-};
-export const getWindowInnerWidth = ()=>{
-  let width = window.innerWidth || document.body.clientWidth || document.documentElement.clientWidth 
-  return width
-};
-
-export const getIds = (data)=>{
-  let ids = [];
-  data&&data.forEach((it,i)=>{
-   ids.push(it.id);
-  })
-  return ids;
-}

+ 0 - 36
src/common/js/util.js

@@ -1,36 +0,0 @@
-
-/**
- * 业务相关工具函数
- */
-export const setLastPosition=(dom)=>{
-    dom.focus();
-    if (window.getSelection && document.createRange) {
-        const range = document.createRange();
-        range.selectNodeContents(dom);
-        range.collapse(false);
-        const sel = window.getSelection();
-        sel.removeAllRanges();
-        sel.addRange(range);
-    } else if (document.body.createTextRange) {
-        const textRange = document.body.createTextRange();
-        textRange.moveToElementText(dom);
-        textRange.collapse(false);
-        textRange.select();
-    }
-};
-// export const setLastPosition=(obj)=> {
-//     if (window.getSelection) {//ie11 10 9 ff safari
-//         obj.focus(); //解决ff不获取焦点无法定位问题
-//         var range = window.getSelection();//创建range
-//         range.selectAllChildren(obj);//range 选择obj下所有子内容
-//         range.collapseToEnd();//光标移至最后
-//     }
-//     else if (document.selection) {//ie10 9 8 7 6 5
-//         var range = document.selection.createRange();//创建选择对象
-//         //var range = document.body.createTextRange();
-//         range.moveToElementText(obj);//range定位到obj
-//         range.collapse(false);//光标移至最后
-//         range.select();
-//     }
-// }
-

+ 1 - 2
src/components/EMRContainer/index.jsx

@@ -11,8 +11,7 @@ import OperationContainer from '../../containers/OperationContainer'
 import style from './index.less';
 import AdviceContainer from '../../containers/AdviceContainer';
 import InfoTitle from '@components/InfoTitle'
-import {windowEventHandler} from '@utils/tools'
-import {getWindowInnerHeight,getWindowInnerWidth} from '@common/js/func';
+import {getWindowInnerHeight,getWindowInnerWidth,windowEventHandler} from '@utils/tools';
 
 class EMRContainer extends Component {
     constructor(props){

+ 1 - 4
src/components/PushContainer/index.jsx

@@ -1,19 +1,16 @@
 import React, { Component } from 'react';
 import style from './index.less';
 import { Tab ,ConfirmModal,Notify } from '@commonComp';
-
 import { tabChange,allChecked,changeVisible,keepPushData,allCheckedShow} from '@store/actions/tabTemplate';
 import { initItemList,delItem,delBatchItem,changeTitleAsync,saveTemplateDetail } from '@store/async-actions/tabTemplate';
 import { CHANGE_TYPE } from "@store/types/typeConfig";
 import { connect } from "react-redux";
 import store from '@store';
 import {billing} from '@store/async-actions/pushMessage';
-
 import TemplateContainer from '@components/TemplateContainer';
 import TemplateItems from '@components/TemplateItems';
-import {getWindowInnerHeight} from '@common/js/func';
 import PushItemsContainer from '@containers/PushItemsContainer';
-import { pushAllDataList } from '@utils/tools';
+import { pushAllDataList,getWindowInnerHeight } from '@utils/tools';
 import CopyRightContainer from "@containers/CopyRightContainer";
 class PushContainer extends Component {
     constructor(props) {

+ 1 - 2
src/components/PushItems/index.jsx

@@ -11,10 +11,9 @@ import DetailsModal from './DetailsModal';
 import PushDiag from "./PushDiag";
 import DiagnosticItem from "@containers/DiagnosticItem";
 import store from "@store";
-import { getWindowInnerHeight } from "@common/js/func";
 import {addLabel} from '@store/actions/inspect';
 import {addAssistLabel} from '@store/actions/assistCheck';
-import {windowEventHandler,getCurrentDate} from '@utils/tools'
+import {windowEventHandler,getCurrentDate,getWindowInnerHeight} from '@utils/tools'
 import {ConfirmModal} from '@commonComp';
 import ChronicInfo from '@containers/ChronicInfo';//慢病推送模块
 

+ 1 - 2
src/components/SpreadDrop/index.jsx

@@ -2,10 +2,9 @@ import React,{Component} from 'react';
 import classNames from 'classnames';
 import config from '@config/index.js';
 import style from './index.less';
-import {deepClone,filterArr,handleEnter,isIE,getPageCoordinate,windowEventHandler,filterDataArr} from '@utils/tools.js';
+import {deepClone,filterArr,handleEnter,isIE,getPageCoordinate,windowEventHandler,filterDataArr,getIds} from '@utils/tools.js';
 import {Notify} from '@commonComp';
 import ReactDom from "react-dom";
-import {getIds} from '@common/js/func.js';
 import $ from 'jquery';
 /****
  * 标签组合下拉,选中的项目展开

+ 1 - 2
src/components/TemplateItems/index.jsx

@@ -5,8 +5,7 @@ import TemplateItem from './TemplateItem'
 import check_circle from './TemplateItem/img/check-circle.png';
 import check_right from './TemplateItem/img/check-right.png';
 import Empty from '@components/Empty';
-import {getWindowInnerHeight} from '@common/js/func';
-import {windowEventHandler} from '@utils/tools'
+import {windowEventHandler,getWindowInnerHeight} from '@utils/tools'
 
 
 class TemplateItems extends React.Component {

+ 1 - 1
src/containers/InlineTag.js

@@ -5,7 +5,7 @@ import {SETMAININPUT} from '@types/mainSuit';
 import {SETCURRENTINPUT} from '@types/currentIll';
 import {SETCHECKINPUT} from "@types/checkBody";
 import InlineTag from "../common/components/InlineTag";
-import {getLabelIndex} from "@common/js/func";
+import {getLabelIndex} from '@utils/tools.js';
 import {CLICKCOUNT} from '@types/homePage.js';
 
 function mapStateToProps(state){

+ 1 - 2
src/containers/Multiple.js

@@ -6,8 +6,7 @@ import {CURRENT_MUL,CURRENT_TEXT_LABEL} from '@types/currentIll';
 import {MAINSUIT_MUL,CHANGE_LABELVAL} from '@types/mainSuit';
 import {OTHERHIS_MUL,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
 import {CHECKBODY_MUL,CHANGECHECKTEXTLABEL} from '@types/checkBody';
-import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
-import {filterArr,filterDataArr} from '@utils/tools.js';
+import {filterArr,filterDataArr,getLabelIndex,fullfillText,getIds} from '@utils/tools.js';
 import config from '@config/index.js';
 import {Notify} from '@commonComp';
 

+ 1 - 2
src/containers/NumberDrop.js

@@ -5,11 +5,10 @@ import {SETNUMBER,CHANGEOTHERTEXTLABEL,CHANGEOTHERTEXTLABEL_NUMBER} from '@types
 import {SETNUMBER4,CHANGECHECKTEXTLABEL,CHANGECHECKTEXTLABEL_NUMBER} from '@types/checkBody.js';
 import {SETDROPSHOW,CLICKCOUNT,HIDE,RESET,HIDEDROP,ISREAD} from '@types/homePage.js';
 import {NUMBER_SELECT,CHANGE_LABELVAL,CHANGE_LABELVAL_NUMBER} from '@store/types/mainSuit.js';
-import {getLabelIndex} from '@common/js/func.js';
 import {CURRENT_NUMBER,CURRENT_TEXT_LABEL,CURRENT_TEXT_LABEL_NUMBER} from '@store/types/currentIll.js';
 import {billing} from '@store/async-actions/pushMessage';
 import {Notify} from '@commonComp';
-import {filterArr,didPushParamChange,filterDataArr} from '@utils/tools.js';
+import {filterArr,didPushParamChange,filterDataArr,getLabelIndex} from '@utils/tools.js';
 import config from '@config/index.js';
 
 function mapStateToProps(state){

+ 1 - 2
src/containers/NumberUnitDrop.js

@@ -5,10 +5,9 @@ import {SETNUMBER,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
 import {SETNUMBER4,CHANGECHECKTEXTLABEL} from '@types/checkBody.js';
 import {SETDROPSHOW,CLICKCOUNT,HIDE,RESET,HIDEDROP,ISREAD} from '@types/homePage.js';
 import {NUMBER_SELECT,CHANGE_LABELVAL} from '@store/types/mainSuit.js';
-import {getLabelIndex} from '@common/js/func.js';
 import {CURRENT_NUMBER,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
 import {Notify} from '@commonComp';
-import {filterArr,didPushParamChange,filterDataArr} from '@utils/tools.js';
+import {filterArr,didPushParamChange,filterDataArr,getLabelIndex} from '@utils/tools.js';
 import {billing} from '@store/async-actions/pushMessage';
 import config from '@config/index.js';
 

+ 1 - 2
src/containers/OtherHistory.js

@@ -5,8 +5,7 @@ import {SETSELECTED,CLEARSELECTED,CONFIRMSELECTED,SELECTOTHERSEARCHDATA,SETDATA,
 import {HIDE,RESET,ISREAD,SEARCH_DROP_LOCATION} from '@store/types/homePage.js';
 import {getModule,setOtherHisModule} from '@store/async-actions/fetchModules.js';
 import {billing} from '@store/async-actions/pushMessage';
-import {fullfillText} from '@common/js/func';
-import {didPushParamChange,filterDataArr} from '@utils/tools.js';
+import {didPushParamChange,filterDataArr,fullfillText} from '@utils/tools.js';
 
 function mapStateToProps(state){
   const {otherHistory,homePage,typeConfig,mainSuit} = state;

+ 1 - 2
src/containers/RadioDrop.js

@@ -7,9 +7,8 @@ import {SETDROPSHOW,HIDE,RESET,HIDEDROP,CLICKCOUNT,ISREAD} from '@types/homePage
 import {RADIO_SELECT,CHANGE_LABELVAL} from '@store/types/mainSuit.js';
 import {CURRENT_RADIO,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
 import {Notify} from '@commonComp';
-import {filterArr,didPushParamChange,filterDataArr} from '@utils/tools.js';
+import {filterArr,didPushParamChange,filterDataArr,getLabelIndex,fullfillText} from '@utils/tools.js';
 import {billing} from '@store/async-actions/pushMessage';
-import {getLabelIndex,fullfillText} from '@common/js/func.js';
 import config from '@config/index.js';
 
 function mapStateToProps(state){

+ 1 - 2
src/containers/RadioInpDrop.js

@@ -7,9 +7,8 @@ import {SETDROPSHOW,HIDE,RESET,HIDEDROP,CLICKCOUNT,ISREAD} from '@types/homePage
 import {RADIO_SELECT,CHANGE_LABELVAL,SET_MS_RADIO_INPUT_VAL} from '@store/types/mainSuit.js';
 import {CURRENT_RADIO,CURRENT_TEXT_LABEL,SET_RADIO_INPUT_VALUE} from '@store/types/currentIll.js';
 import {Notify} from '@commonComp';
-import {filterArr,didPushParamChange,filterDataArr} from '@utils/tools.js';
+import {filterArr,didPushParamChange,filterDataArr,getLabelIndex,fullfillText} from '@utils/tools.js';
 import {billing} from '@store/async-actions/pushMessage';
-import {getLabelIndex,fullfillText} from '@common/js/func.js';
 import config from '@config/index.js';
 
 function mapStateToProps(state){

+ 1 - 2
src/containers/SpreadDrop.js

@@ -9,10 +9,9 @@ import {getCommSymptomPush} from '@store/async-actions/mainSuit.js'
 import {GET_BIGDATAPUSH,MIX_CONFIRM,COMM_CONFIRM,CHANGE_LABELVAL} from '@store/types/mainSuit';
 import {SETCHECKBOX,CHANGECHECKTEXTLABEL,CHECKCONFIRMSELECTED} from '@types/checkBody';
 import {CURRENT_CONFIRM,SETMAINCHECKBOX,CURRENT_TEXT_LABEL,CURRENT_GET_BIGDATAPUSH} from '@types/currentIll';
-import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
 import {billing} from '@store/async-actions/pushMessage';
 import {Notify} from '@commonComp';
-import {filterArr,didPushParamChange,filterDataArr} from '@utils/tools.js';
+import {filterArr,didPushParamChange,filterDataArr,getLabelIndex,fullfillText,getIds} from '@utils/tools.js';
 import config from '@config/index.js';
 
 function mapStateToProps(state) {//console.log(state);

+ 1 - 2
src/store/actions/checkBody.js

@@ -1,6 +1,5 @@
 import config from '@config/index.js';
-import {getLabelIndex,fullfillText} from '@common/js/func.js';
-import {formatContinueDots} from '@utils/tools.js';
+import {formatContinueDots,getLabelIndex,fullfillText} from '@utils/tools.js';
 //设置查体数据
 export function set(state,action){
   let res = Object.assign({},state);

+ 1 - 2
src/store/actions/currentIll.js

@@ -1,6 +1,5 @@
-import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
 import config from '@config/index.js';
-import {formatContinueDots} from '@utils/tools';
+import {formatContinueDots,getLabelIndex,fullfillText,getIds} from '@utils/tools';
 
 //插入病程变化模板
 function insertPro(data,processModule){

+ 1 - 1
src/store/actions/mainSuit.js

@@ -1,4 +1,4 @@
-import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
+import {getLabelIndex,fullfillText,getIds} from '@utils/tools.js';
 import config from '@config/index.js';
 
 

+ 1 - 2
src/store/actions/otherHistory.js

@@ -1,6 +1,5 @@
 import config from '@config/index';
-import {getLabelIndex,fullfillText} from '@common/js/func.js';
-import {formatContinueDots} from '@utils/tools.js';
+import {formatContinueDots,getLabelIndex,fullfillText} from '@utils/tools.js';
 
 //多选标签选中确定处理
 export const confirm = (state,action) =>{

+ 0 - 41
src/store/async-actions/checkBody.js

@@ -1,41 +0,0 @@
-/*import {json} from '@utils/ajax.js';
-import {SET} from '@types/CheckBody.js';
-import {SETCHECKINIT} from '@types/homePage';
-import {fullfillText} from '@common/js/func';*/
-
-/*
-const api = {
-  getCheckModule:'/api/icss/push/pushInner'
-};
-
-export function getInitData(){
-  return (dispatch,getStore)=>{
-    const param = {
-      "age": 0,
-      "diag": "",
-      "featureType": "1,4,7",
-      "lis": "",
-      "other": "",
-      "pacs": "",
-      "past": "",
-      "sex": 0,
-      "symptom": "咳嗽1天",
-      "vital": ""
-    };
-    json(api.getCheckModule,param).then((res)=>{
-      if(+res.data.code === 0){
-        const data = res.data.data&&res.data.data.vital;
-        const str = JSON.stringify(data);
-        const arr = fullfillText(JSON.parse(str));
-        dispatch({
-          type:SETCHECKINIT,
-          data:arr
-        });
-        dispatch({
-          type:SET,
-          data:[...arr]
-        });
-      }
-    });
-  }
-}*/

+ 1 - 2
src/store/async-actions/fetchModules.js

@@ -1,9 +1,8 @@
 import {json} from '@utils/ajax.js';
 import {SET} from '@types/checkBody.js';
-import {fullfillText,_fullfillText} from '@common/js/func';
 import {SETDATA} from '@store/types/otherHistory';
 import store from '@store';
-import {getEMRParams,didPushParamChange,inspectAndAssist} from '@utils/tools.js';
+import {getEMRParams,didPushParamChange,inspectAndAssist,fullfillText} from '@utils/tools.js';
 import {Notify} from '@commonComp';
 import {billing} from '@store/async-actions/pushMessage';
 import {SETOTHERHISTORY,ISREAD} from "../types/homePage";

+ 1 - 2
src/store/async-actions/homePage.js

@@ -4,11 +4,10 @@ import {SET_CURRENT} from '@store/types/currentIll';
 import {SET_MAINSUIT} from '@store/types/mainSuit';
 import config from '@config/index.js';
 import store from '@store';
-import {fullfillText} from '@common/js/func';
 import {formatContinueDots} from '@utils/tools';
 import {getOtherHisRecord,getInitData} from '@store/async-actions/fetchModules.js';
 import {initHistoryDetails} from '@store/async-actions/patInfo';
-import {storageLocal} from '@utils/tools';
+import {storageLocal,fullfillText} from '@utils/tools';
 
 const api = {
   getModules:'/moduleInfo/getAll',

+ 1 - 1
src/store/reducers/inspect.js

@@ -12,7 +12,7 @@ import {
     ADD_LABEL
 } from '../types/inspect';
 import store from '@store'
-import {dateParser} from '@common/js/func';
+import {dateParser} from '@utils/tools.js';
 
 const initSearchList = {
     list: [], //搜索的结果

+ 195 - 0
src/utils/tools.js

@@ -917,8 +917,203 @@ function readyKeepHistory(){
     return 3;
   }
 }
+//函数类工具,对函数进行操作 返回函数
+//延时操作
+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 = '-'){
+  let time = new Date(timestamp);
+  let year = time.getFullYear();
+  let month = time.getMonth()+1;
+  let date = time.getDate();
+  let hour = time.getHours().toString().padStart(2,'0');
+  let minute = time.getMinutes().toString().padStart(2,'0');
+  // let result = year+link+month+link+date;
+  let result = year+link+(month<10?"0"+month:month)+link+(date<10?"0"+date:date)+' '+hour+':'+minute;
+  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)=>{
+    return it.value?(it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||''):'';
+  });
+  return arr.join('');
+}
+
+//添加自由文本标签
+function notTextLabel(label){
+  return +label.tagType!==8;
+}
+/*
+* 给标签组添加自由文本标签
+* 入参:arr源数组,
+*       noPre是否不添加前置文本标签,默认false即添加
+*       noEnd是否不添加后置文本标签,默认false即添加
+*       ifEmpty是否添加空标签,默认true即添加,传false添加逗号,如查体,
+*       showInCheck是否默认在查体中展开
+* */
+function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
+  let newArr =[],
+    pre={},
+    textLabel={},
+    _textLabel={},
+    notText = true,
+    saveText=[],
+    tempText = '',
+    value = '',
+    item={},
+    checkHiddenDefault=false;
+  arr&&arr.map((it,i)=>{
+    notText = notTextLabel(it);
+    value = it.value||'';
+    textLabel = !ifEmpty&&i==0?Object.assign({},JSON.parse(config.textLabel),{showInCheck:true}):JSON.parse(config.textLabel);
+    _textLabel = !ifEmpty&&i<config.showCheckNum+1?Object.assign({},JSON.parse(config._textLabel),{showInCheck:true}):JSON.parse(config._textLabel);
+    if(i===0){
+      //第一个标签不是文本标签时在前面添加文本标签
+      if(!noPre&&notText){
+        newArr.push(textLabel);
+        saveText.push('');
+      }
+      item = ifEmpty?it:Object.assign({},it,{showInCheck:true});
+      newArr.push(item);
+      if(it.tagType != 3){
+        tempText = value?it.labelPrefix+value+it.labelSuffix:'';
+        tempText = notText?tempText:it.value||it.name;
+      }else{
+        tempText = getSaveText(it);
+      }
+      saveText.push(tempText);
+    }else{
+      pre = arr[i-1];
+      item = !ifEmpty&&i<config.showCheckNum?Object.assign({},it,{showInCheck:true}):it;
+      //判断单选项是否有默认选中,位置在隐藏区域时,查体所有标签展示
+      if(!ifEmpty&&!checkHiddenDefault&&i>config.showCheckNum&&+it.tagType===1&&(+it.controlType===0||+it.controlType===1)){
+        if(it.questionDetailList.find((it)=>it.defaultSelect=='1')){
+          checkHiddenDefault=true;
+        }
+      }
+      //如果本身不是文本标签且前面一个也不是文本标签,该标签前面添加文本标签
+      if(notTextLabel(pre)&&notText){
+        // newArr.push(textLabel,it);
+        ifEmpty?newArr.push(textLabel,it):newArr.push(_textLabel,item);
+        if(it.tagType != 3) {
+          tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
+        }else{
+          tempText = getSaveText(it);
+        }
+        saveText.push("",tempText);
+      }else{    //本身是或者前面是文本标签时,前面不添加文本标签
+        newArr.push(item);
+        if(it.tagType != 3) {
+          tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
+          // tempText = notText?tempText:it.value||it.name;
+          tempText = notText ? tempText : (it.value || it.value == "" ? it.value : it.name);
+        }else{
+          tempText = getSaveText(it);
+        }
+        saveText.push(tempText);
+      }
+      if(notText&&!noEnd&&i===arr.length-1){//最后一个非文本标签,后面添加一个文本标签
+        //不能用上面的变量textLabel,因为上一个if可能也进了,这样就是同一个对象,值改变时会同步
+        newArr.push(JSON.parse(config.textLabel));
+        saveText.push("");
+      }
+    }
+  });
+  return {newArr,saveText,checkHiddenDefault};
+};
+
+
+//获取标签index,入参:病例项index+标签index+标签内index
+function getLabelIndex(index){
+  let ikey = '';
+  if(index.length == 3){
+    ikey = index.substr(1,1);
+  }else if(index.length == 4){
+    ikey = index.substr(1,2);
+  }else if(index.length == 5){
+    ikey = index.substr(1,3);
+  }
+  return ikey;
+};
+
+function getWindowInnerHeight(){
+  if(window.innerHeight!=undefined){
+    return window.innerHeight;
+  }else{
+    let by = document.body, ele = document.documentElement;
+    return Math.min(by.clientHeight,ele.clientHeight);
+  }
+};
+function getWindowInnerWidth(){
+  let width = window.innerWidth || document.body.clientWidth || document.documentElement.clientWidth
+  return width
+};
+
+function getIds(data){
+  let ids = [];
+  data&&data.forEach((it,i)=>{
+    ids.push(it.id);
+  })
+  return ids;
+}
 module.exports = {
     checkType: Type.checkType,
+    getIds,
+    getWindowInnerWidth,
+    getWindowInnerHeight,
+    getLabelIndex,
+    fullfillText,
+    parseUrl,
+    getAge,
+    dateParser,
+    debounce,
     regexp,
     isUndefined,
     Storage,