|
@@ -0,0 +1,176 @@
|
|
|
+const qs = require('qs');
|
|
|
+const $ = require("jquery");
|
|
|
+var Utils = require('./rePromise');
|
|
|
+
|
|
|
+//页面映射
|
|
|
+const pageMap={
|
|
|
+ 'YH-KZT':'console.html',
|
|
|
+ 'YH-KZTKS':'deptConsole.html',
|
|
|
+ 'YH-JCSJWH-MKSJWH':'moduleManager.html',
|
|
|
+ 'YH-JCSJWH-TMSJWH':'itemManager.html',
|
|
|
+ 'YH-BLZK-ZKPF':'qcList.html',
|
|
|
+ 'YH-BLZK-ZKPFKS':'qcListDept.html',
|
|
|
+ 'YH-BLZK-ZKPFGR':'qcListPerson.html',
|
|
|
+ 'YH-TJFX':'statistics.html',
|
|
|
+ 'YH-QXGL-YHGL':'userManager.html',
|
|
|
+ 'YH-QXGL-JSGL':'roleManager.html',
|
|
|
+};
|
|
|
+const api={
|
|
|
+ getMenu:'/sys/user/getUserOrgMenu', //获取菜单
|
|
|
+ midifyPassword:'/sys/user/midifyPassword', //修改密码
|
|
|
+ getSubMenu:'/qc/mode/getMenu', //获取质控评分菜单
|
|
|
+ delScore:'/qc/behospitalInfo/delCase' ,//删除评分项
|
|
|
+ editScore:'/qc/behospitalInfo/updCase' ,//修改评分
|
|
|
+ addScore:'/qc/behospitalInfo/addCase' ,//添加评分项
|
|
|
+ getRecordDetail:'/qc/behospitalInfo/getByBehospitalCode', //获取病例明细
|
|
|
+ getInfoModule:'/qc/module/getById',
|
|
|
+ getModuleById:'/qc/module/getModuleMap'
|
|
|
+};
|
|
|
+
|
|
|
+//重写assign方法
|
|
|
+if (typeof Object.assign != 'function') {
|
|
|
+ Object.assign = function (target) {
|
|
|
+ 'use strict';
|
|
|
+ if (target == null) {
|
|
|
+ throw new TypeError('Cannot convert undefined or null to object');
|
|
|
+ }
|
|
|
+
|
|
|
+ target = Object(target);
|
|
|
+ for (var index = 1; index < arguments.length; index++) {
|
|
|
+ var source = arguments[index];
|
|
|
+ if (source != null) {
|
|
|
+ for (var key in source) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
|
+ target[key] = source[key];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return target;
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+window.console = window.console || (function () {
|
|
|
+ var c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
|
|
|
+ = c.clear = c.exception = c.trace = c.assert = function () { };
|
|
|
+ return c;
|
|
|
+})();
|
|
|
+
|
|
|
+const getUrlArgObject = function getQueryString(name) {
|
|
|
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
|
+ var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
|
|
|
+ var r = window.location.search.substr(1).match(reg);
|
|
|
+ var q = window.location.pathname.substr(1).match(reg_rewrite);
|
|
|
+ if (r != null) {
|
|
|
+ return decodeURIComponent(r[2]);
|
|
|
+ } else if (q != null) {
|
|
|
+ return decodeURIComponent(q[2]);
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const post = function (url, data) {
|
|
|
+ const token = getCookie('accessToken')
|
|
|
+ if(!token&&window.location.href.indexOf('login')==-1){
|
|
|
+ window.location.href = "../login.html"
|
|
|
+ }
|
|
|
+ return new Utils((resolve, reject) => {
|
|
|
+ $.ajax({
|
|
|
+ method: 'post',
|
|
|
+ url: url,
|
|
|
+ data: JSON.stringify(data),
|
|
|
+ contentType: "application/json; charset=UTF-8",
|
|
|
+ beforeSend: function (xmlHttp) {
|
|
|
+ xmlHttp.setRequestHeader("If-Modified-Since", "0");
|
|
|
+ xmlHttp.setRequestHeader("Cache-Control", "no-cache");
|
|
|
+ // xmlHttp.setRequestHeader("Authorization",token?"Bearer "+token:'')
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ resolve({ data: res });
|
|
|
+ },
|
|
|
+ error: function (error) {
|
|
|
+ // if(error.status===403||error.status===401){
|
|
|
+ // const wd = window.parent.window||window;
|
|
|
+ // wd.location.href = "../login.html";
|
|
|
+ // }
|
|
|
+ reject(error);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+//判断浏览器是否为Ie8
|
|
|
+const isIe8 = function () {
|
|
|
+ var DEFAULT_VERSION = 8.0;
|
|
|
+ var ua = navigator.userAgent.toLowerCase();
|
|
|
+ var isIE = ua.indexOf("msie") > -1;
|
|
|
+ var safariVersion;
|
|
|
+ if (isIE) {
|
|
|
+ safariVersion = ua.match(/msie ([\d.]+)/)[1];
|
|
|
+ }
|
|
|
+ if (safariVersion <= DEFAULT_VERSION) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+}
|
|
|
+const setCookie = function(name,value){
|
|
|
+ let Days = 30;
|
|
|
+ let exp = new Date();
|
|
|
+ exp.setTime(exp.getTime() + Days*24*60*60*1000);
|
|
|
+ document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
|
|
|
+}
|
|
|
+
|
|
|
+//读取cookies
|
|
|
+const getCookie =function(name){
|
|
|
+ let arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
|
|
+ if(arr=document.cookie.match(reg))
|
|
|
+ return unescape(arr[2]);
|
|
|
+ else
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
+//删除cookies
|
|
|
+const delCookie = function(name){
|
|
|
+ let exp = new Date();
|
|
|
+ exp.setTime(exp.getTime() - 1);
|
|
|
+ let cval=getCookie(name);
|
|
|
+ if(cval!=null)
|
|
|
+ document.cookie= name + "="+cval+";expires="+exp.toGMTString();
|
|
|
+};
|
|
|
+
|
|
|
+//弹窗关闭事件
|
|
|
+$(".modal .close").click(function(){
|
|
|
+ $(".modal").hide();
|
|
|
+});
|
|
|
+//计算容器高度
|
|
|
+function setBoxHeight(){
|
|
|
+ const ht=window.innerHeight;
|
|
|
+ $(".main-part").height((ht-60)+'px');
|
|
|
+ $(".content-ht").height((ht-126)+"px");
|
|
|
+}
|
|
|
+setBoxHeight();
|
|
|
+$(window).resize(function(){
|
|
|
+ setBoxHeight();
|
|
|
+});
|
|
|
+
|
|
|
+//判断有无某一权限
|
|
|
+function hasData(data){
|
|
|
+ let lis = JSON.parse(getCookie("codeLis"))
|
|
|
+ if(lis.indexOf(data)>-1){//有权限
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+module.exports = {
|
|
|
+ pageMap,
|
|
|
+ api,
|
|
|
+ post,
|
|
|
+ getUrlArgObject,
|
|
|
+ isIe8,
|
|
|
+ setCookie,
|
|
|
+ getCookie,
|
|
|
+ delCookie,
|
|
|
+ setBoxHeight,
|
|
|
+ hasData
|
|
|
+};
|