const qs = require('qs'); const $ = require('jquery'); const axios = require('axios'); var Utils = require('./rePromise'); const { ywCheckApi } = require('./api.js') require('./scrollBar.js'); const baseUrl = ''; //页面映射 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-YHGL': 'useStatistics.html',//权限管理 用户管理 暂时替换为要新添加的页面 'YH-QXGL-JSGL': 'roleManager.html', 'YH-KSZR-GMKQXZB_XQ': 'mukuai.html?from=2', 'YH-KSZR-TMQXZB_XQ': 'singleVeto.html?from=2&special=1', 'YH-ZKK-GMKQXZB_XQ': 'mukuaiControl.html?from=1', 'YH-ZKK-TMQXZB_XQ': 'singleVeto.html?from=1&special=1', 'YH-YCSJJK': 'abnormal.html', 'YH-ZKK-KSPJZYTS_XQ': 'dayDetail.html', 'YH-ZKK-KSPJZYHF_XQ': 'payDetail.html', 'YH-ZKK-GKSQXZB': 'deptScoreDetailControl.html', // 'YH-ZKK-GKSQXZB': 'useStatistics.html', 'YH-ZKK-GKSZKPJF_XQ': 'deptScoreDetailControl.html', 'YH-JCSJWH': 'deptScoreDetailControl.html', 'YH-ZKK-GKSQXZB_XQ': 'deptScoreDetailControl.html', 'YH-KSZR-KSQXZB_XQ': 'deptScoreDetailControlDept.html?from=2', 'YH-ZKK-GKSJJBLZB_XQ': 'jiaji.html', 'YH-ZKK-BASYHGLZB_XQ': 'partDetailControl.html', 'YH-KSZR-BASYHGLZB_XQ': 'partDetailControlDept.html', 'YH-ZKK-ZKHCTJ': 'checkControl.html', 'YH-KSZR-ZKHCTJ_XQ': 'checkControlDept.html', 'YH-KSZR-SXXXGTJ_XQ': 'uncorrectedCasesStatisticsDept.html', 'YH-KSZR-31TZRYRS_XQ': 'readmissionDept.html', 'YH-KSZR-ZMBLJCS_XQ': 'uncorrectedCopyDept.html', 'YH-KSZR-YXBLJCS_XQ': 'uncorrectedCopyDept.html', 'YH-JCSJWH-ZKLXWH': 'assertType.html', 'YH-BLZK-ZKPFYLZ': 'qcListDocteam.html', 'YH-ZKK-GJTMQXZB': 'keyItemFlawControl.html', 'YH-ZKK-BASYHGLYSZB_XQ': 'qualifiedPhysician.html', 'YH-KSZR-BASYHGLYSZB_XQ': 'deptQualifiedPhysician.html', 'YH-ZKK-CYRSTJ': 'qcListOutHospital.html', 'YH-ZKK-RYRSTJ': 'qcListOutHospital.html?inner=2', 'YH-ZKK-WZGBLTJ': 'uncorrectedCasesStatistics.html', 'YH-ZKK-31TZRYRS': 'readmission.html', 'YH-ZKK-YXBLJCB': 'uncorrectedCopy.html', 'YH-ZKK-ZMBLJCB': 'uncorrectedCopy.html', 'YH-KSZR-GJTMQXZB_XQ': 'keyItemFlawControlDept.html', 'YH-KSZR-CYRSTJ_XQ': 'qcListOutHospitalDept.html?from=2', 'YH-KSZR-RYRSTJ_XQ': 'qcListOutHospitalDept.html?inner=2&from=2', 'YH-ZKK-BLZK_XQ': 'qcListYw.html', 'YH-KSZR-BLZK_XQ': 'qcListDeptYw.html', 'YH-ZKHC-SCHCRW': 'creatCheckTask.html', //义乌-生成核查任务 'YH-ZKHC-FPHCRW': 'allotCheckTask.html', //义乌-分配核查任务 'YH-ZKHC-HCRWLB': 'checkTaskList.html', //义乌-核查任务列表 'YH-ZKK-YLZLKZZB_XQ': 'qualityControl.html', 'YH-SJBJ': 'editableDetail.html', //数据编辑 'YH-ZKK-TMQXGSTJ': 'improveStatistics.html', //条目缺陷改善统计 "YH-ZKK-LCZKSYTJ": 'useStatistics.html', //临床质控使用统计 'YH-KSZR-TMQXGSTJ': 'improveStatisticsDept.html', //条目缺陷改善统计(科室) "YH-KSZR-LCZKSYTJ": 'useStatisticsDept.html', //临床质控使用统计(科室) }; //导出时间天数 const exportTimeLimit = { defectTime: 90, normalTime: 7, yiwuTime: 30, }; //重写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) { // console.log('我是编码url的r',r) return decodeURIComponent(r[2]); } else if (q != null) { return decodeURIComponent(q[2]); } else { return null; } }; const getUrlArgObjectNew = function (name, srcUrl) { if (srcUrl.indexOf('?') == -1) { return ''; } var r = srcUrl.split('?')[1].split('&'), obj = {}; for (let i = 0; i < r.length; i++) { let tmp = r[i].split('='); obj[tmp[0]] = tmp[1]; } return obj[name]; }; window.abortAjax = ''; const post = function (url, data) { let isPlacefile = getCookie('isPlacefile') || 1; const token = getCookie('accessToken') || localStorage.getItem('accessToken'); if (!token && window.location.href.indexOf('login') == -1) { setCookie('behosDateStart', ''); setCookie('behosDateEnd', ''); window.location.href = '../login.html'; } for (let i = 0; i < $('.typeFilter').children().length; i++) { if ( $('.typeFilter') .children() .eq(i) .html() == '出院日期:' && isPlacefile == 0 ) { $('.typeFilter') .children() .eq(i) .html('入院日期:'); } } let need = window.location.href.indexOf('localhost') != -1; return new Utils((resolve, reject) => { abortAjax = $.ajax({ method: 'post', url: (need ? baseUrl : '') + url, async: true, cache: false, processData: false, data: JSON.stringify(Object.assign({}, data, { isPlacefile: isPlacefile })), 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) { const json = res let jsonres = null if (typeof (json) === 'string') { jsonres = JSON.parse(json) } else { jsonres = { ...json } } let dialogcode = jsonres.code === '10020011' || jsonres.code === '10020012' if (jsonres.code && dialogcode && (self == top)) { localStorage.removeItem('accessToken') $.alerModal({ gobackBtn: true, title: "提示", type: "modal", width: '470', time: 1000, cancalText: '我知道了', sureBtn: false, message: jsonres.msg || '登录过期', callback: function () { // if (window.parent) { // window.parent.window.location.href = 'login.html' // } else { // window.location.href = 'login.html' // } window.location.href = 'login.html' } }); } else if (jsonres.code && dialogcode && (self != top)) { localStorage.removeItem('accessToken') const dialogmessage = { iframemessage: 1, data: jsonres.msg } window.parent.postMessage(JSON.stringify(dialogmessage), '*') } resolve({ data: res }); }, error: function (error) { const errorCode = { ...error.responseJSON } const wd = window.parent.window || window; // if (jsonres.code && (jsonres.code === '10020011' || jsonres.code === '00020007') && (self != top)) { // let dialog = 'true' // window.parent.postMessage(dialog, '*') // } let dialogcode2 = errorCode.code === '10020011' || errorCode.code === '10020012' if (errorCode.code && dialogcode2 && (self == top)) { localStorage.removeItem('accessToken') $.alerModal({ gobackBtn: true, title: "提示", type: "modal", width: '470', time: 1000, cancalText: '我知道了', sureBtn: false, message: errorCode.msg || '登录过期', callback: function () { window.location.href = 'login.html' } }); } else { if (errorCode.code && dialogcode2 && (self != top)) { localStorage.removeItem('accessToken') const dialogmessage = { iframemessage: 1, data: errorCode.msg } window.parent.postMessage(JSON.stringify(dialogmessage), '*') } if (error.status === 403 || error.status === 401) { setCookie('behosDateStart', ''); setCookie('behosDateEnd', ''); $.alerModal({ "message": "没有该权限", type: "tip", time: '1000', isFather: true, fatherWrapper: $("#mainBox", parent.document) }); // wd.location.href = "../login.html"; } else if (error.status === 500 || error.status === 501 || error.status === 404) { $.alerModal({ "message": '接口错误', type: "tip", time: '1000', isFather: true, fatherWrapper: $("#mainBox", parent.document) }); // wd.location.href = '../error.html?code=' + error.status; } } reject(error); }, }); }); }; // 导出 const expJson = (url, data) => { const token = getCookie('accessToken') || localStorage.getItem('accessToken'); if (!token && window.location.href.indexOf('login') == -1) { setCookie('behosDateStart', ''); setCookie('behosDateEnd', ''); window.location.href = '../login.html'; } let need = window.location.href.indexOf('localhost') != -1; return axios({ method: 'post', url: (need ? baseUrl : '') + url, data: data, contentType: 'application/vnd.ms-excel', responseType: 'blob', //必须添加,否则会乱码 headers: { Authorization: 'Bearer ' + token, }, }); }; //导出接口返回流下载 function downloadExportedData(data, fileName) { var blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8', }); //application/vnd.openxmlformats-officedocument.spreadsheetml.sheet这里表示xlsx类型 var downloadElement = document.createElement('a'); var href = window.URL.createObjectURL(blob); //创建下载的链接 downloadElement.href = href; downloadElement.download = fileName; //下载后文件名 document.body.appendChild(downloadElement); downloadElement.click(); //点击下载 document.body.removeChild(downloadElement); //下载完成移除元素 window.URL.revokeObjectURL(href); } //判断浏览器是否为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; }; const setLocal = function (name, value) { localStorage.setItem(name, value); }; //读取cookies const getLocal = function (name) { return localStorage.getItem(name); }; //删除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; const hw = window.innerWidth; if (hw < 1169) { $('.content-box').height(ht - 110 + 'px'); } else { $('.content-box').height(ht - 60 + 'px'); } //$('.content-box').height(ht - 60 + 'px'); $('.flaw-table').height(ht - 70 + 'px'); $('.content-ht').height(ht - 120 + 'px'); $('.scroll-table tbody').css('max-height', ht - 210 + 'px'); } setBoxHeight(); $(window).resize(function () { setBoxHeight(); }); //判断有无某一权限 function hasData(data) { let lis = JSON.parse(getCookie('codeLis')) || []; if (lis.indexOf(data) > -1) { //有权限 return true; } return false; } //定位对应明细菜单 function focusMenuItem(code) { const ele = $(parent.document).find('.menu .page[code=' + code + ']'); const parEle = ele.parents('.list-1'); if (!parEle.is('.list-1-show')) { parEle.click(); } //console.log($(parent.document).find(".menu .page[code='YH-ZKK-GMKQXZB_XQ']")) ele.click(); } function emptyBox(name, showNum, type) { let showNumer = showNum || 30; let str = `
${name || '暂无数据~'}
${str || '暂无数据~'}