promise.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. const qs = require('qs');
  2. const $ = require("jquery");
  3. var Promise = require('./rePromise');
  4. let imgReg = /undefined/g
  5. let iconWarning = require('./../images/icon_warning.png')
  6. let iconSymptomPush = require('./../images/icon_symptom_push.png')
  7. let iconLisPush = require('./../images/icon_lis_push.png')
  8. let iconPacsPush = require('./../images/icon_pacs_push.png')
  9. let iconScalePush = require('./../images/icon_scale_push.png')
  10. let iconOperationPush = require('./../images/icon_operation_push.png')
  11. let iconDrugPush = require('./../images/icon_drug_push.png')
  12. let iconDiagPush = require('./../images/icon_diag_push.png')
  13. let iconCommonTreatPush = require('./../images/icon_drug_push.png')
  14. let iconCheckupPush = require('./../images/icon_checkup_push.png')
  15. //重写assign方法imgR
  16. if (typeof Object.assign != 'function') {
  17. Object.assign = function (target) {
  18. 'use strict';
  19. if (target == null) {
  20. throw new TypeError('Cannot convert undefined or null to object');
  21. }
  22. target = Object(target);
  23. for (var index = 1; index < arguments.length; index++) {
  24. var source = arguments[index];
  25. if (source != null) {
  26. for (var key in source) {
  27. if (Object.prototype.hasOwnProperty.call(source, key)) {
  28. target[key] = source[key];
  29. }
  30. }
  31. }
  32. }
  33. return target;
  34. };
  35. }
  36. window.console = window.console || (function () {
  37. var c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
  38. = c.clear = c.exception = c.trace = c.assert = function () { };
  39. return c;
  40. })();
  41. const config = {
  42. pushInner: '/sys/push/push',
  43. indicationPush:'/sys/push/indicationPush',
  44. calculate: '/api/data/calc/calculate',
  45. disclaimer: '/sys/disclaimerInfo/getDisclaimerInfo',
  46. information: '/api/data/conceptDetail/getConceptDetail',
  47. informationMore: '/api/data/conceptDetail/getConceptDetails',
  48. pushScale: '/api/data/push/pushScale',
  49. getSysSetInfoDatas: '/sys/plan/getSysPlanInfoDatas',
  50. getMr: '/sys/mr/getMr', //页面推送患者信息
  51. getMr2: '/sys/mr/getMr', //icss推送患者信息
  52. getVersion: '/sys/versionInfo/getVersionInfoAlls',
  53. getStaticKnowledge: '/graph/conceptInfo/staticKnowledgeIndex',//静态知识检索
  54. getStaticScale: '/api/data/search/getScale',
  55. dictionaryInfo: '/sys/dictionaryInfo/getList', //字典信息
  56. getPushSet:'/sys/plan/getSysPlanInfoDatas', //获取推送配置
  57. analyse:'/api/data/mrqc/analyse',
  58. getHosptDeptUsal:'/api/data/concept/getHosptDeptUsal', //获取科室常用标签
  59. ruleTypeMap:{ //大数据推送参数featureType对应
  60. '22':'1,2',
  61. '11':'3',
  62. '8':'4,5'
  63. }
  64. }
  65. const imageUrlPrefix = 'http://192.168.2.121:82';
  66. // const getUrlArgObject = function(parm) {
  67. // var query = decodeURI(window.location.search);
  68. // var args = qs.parse(qs.parse(query.substr(1)));
  69. // return args[parm];//返回对象
  70. // }
  71. const getUrlArgObject = function getQueryString(name) {
  72. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  73. var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
  74. var r = window.location.search.substr(1).match(reg);
  75. var q = window.location.pathname.substr(1).match(reg_rewrite);
  76. if (r != null) {
  77. return decodeURIComponent(r[2]);
  78. } else if (q != null) {
  79. return decodeURIComponent(q[2]);
  80. } else {
  81. return null;
  82. }
  83. }
  84. const post = function (url, data) {
  85. return new Promise((resolve, reject) => {
  86. $.ajax({
  87. method: 'post',
  88. url: url,
  89. data: JSON.stringify(data),
  90. contentType: "application/json; charset=UTF-8",
  91. beforeSend: function (xmlHttp) {
  92. xmlHttp.setRequestHeader("If-Modified-Since", "0");
  93. xmlHttp.setRequestHeader("Cache-Control", "no-cache");
  94. },
  95. success: function (res) {
  96. resolve({ data: res });
  97. },
  98. error: function (error) {
  99. reject(error);
  100. },
  101. });
  102. });
  103. }
  104. const newinConf = {
  105. width: '600', //窗口的文档显示区的宽度。以像素计。
  106. height: '600', //窗口文档显示区的高度。以像素计。
  107. left: '0', //窗口的 x 坐标。以像素计。
  108. top: '0', //窗口的 y 坐标。以像素计。
  109. openMode: "_blank" //每次都是新窗口打开为_blank,打开同一窗口填写任意字符串
  110. }
  111. const newWindowLocation = `width=${newinConf.width}, height=${newinConf.height}, left=${newinConf.left}, top=${newinConf.top} scrollbars=yes`
  112. const openNewWin = function (url) {
  113. window.open(url, newinConf.openMode, newWindowLocation)
  114. }
  115. //判断浏览器是否为Ie8
  116. const isIe8 = function () {
  117. var DEFAULT_VERSION = 8.0;
  118. var ua = navigator.userAgent.toLowerCase();
  119. var isIE = ua.indexOf("msie") > -1;
  120. var safariVersion;
  121. if (isIE) {
  122. safariVersion = ua.match(/msie ([\d.]+)/)[1];
  123. }
  124. if (safariVersion <= DEFAULT_VERSION) {
  125. return true
  126. }
  127. }
  128. const throttle = function (fn, threshhold) {
  129. var timeout
  130. var start = new Date;
  131. var threshhold = threshhold || 160
  132. return function () {
  133. var context = this, args = arguments, curr = new Date() - 0
  134. clearTimeout(timeout)//总是干掉事件回调
  135. if (curr - start >= threshhold) {
  136. // console.log("now", curr, curr - start)//注意这里相减的结果,都差不多是160左右
  137. fn.apply(context, args) //只执行一部分方法,这些方法是在某个时间段内执行一次
  138. start = curr
  139. } else {
  140. //让方法在脱离事件后也能执行一次
  141. timeout = setTimeout(function () {
  142. fn.apply(context, args)
  143. }, threshhold);
  144. }
  145. }
  146. }
  147. const titleConfig = {
  148. warning:{
  149. background: "#FFE8DD",
  150. icon: iconWarning,
  151. name:"智能警示"
  152. },
  153. symptomPush:{
  154. background: "#EEF5FD",
  155. icon: iconSymptomPush,
  156. name:"推荐症状"
  157. },
  158. diagPush:{
  159. background: "#FAECED",
  160. icon: iconDiagPush,
  161. name:"智能诊断"
  162. },
  163. checkupPush:{
  164. background: "#EEF5FD",
  165. icon: iconCheckupPush,
  166. name:"推荐体格检查"
  167. },
  168. scalePush:{
  169. background: "#ECF4FC",
  170. icon: iconScalePush,
  171. name:"推荐量表"
  172. },
  173. lisPush:{
  174. background: "#ECF4FC",
  175. icon: iconLisPush,
  176. name:"推荐化验"
  177. },
  178. pacsPush:{
  179. background: "#ECF4FC",
  180. icon: iconPacsPush,
  181. name:"推荐辅检"
  182. },
  183. drugPush:{
  184. background: "#E3FEFE",
  185. icon: iconDrugPush,
  186. name:"推荐用药"
  187. },
  188. operationPush:{
  189. background: "#E3FEFE",
  190. icon: iconOperationPush,
  191. name:"推荐手术及操作"
  192. },
  193. }
  194. module.exports = {
  195. config,
  196. post,
  197. getUrlArgObject,
  198. imageUrlPrefix,
  199. throttle,
  200. openNewWin,
  201. isIe8,
  202. titleConfig
  203. }