promise.js 8.5 KB

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