|
@@ -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,
|