promise.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. ruleTypeMap:{ //大数据推送参数featureType对应
  62. '22':'1,2',
  63. '11':'3',
  64. '8':'4,5'
  65. }
  66. }
  67. const isLocal = window.location.hostname.indexOf('localhost') !=-1;
  68. const imageUrlPrefix = isLocal ?'http://192.168.2.241:82':'http://'+window.location.hostname+':82';
  69. // const getUrlArgObject = function(parm) {
  70. // var query = decodeURI(window.location.search);
  71. // var args = qs.parse(qs.parse(query.substr(1)));
  72. // return args[parm];//返回对象
  73. // }
  74. const getUrlArgObject = function getQueryString(name) {
  75. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  76. var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
  77. var r = window.location.search.substr(1).match(reg);
  78. var q = window.location.pathname.substr(1).match(reg_rewrite);
  79. if (r != null) {
  80. return decodeURIComponent(r[2]);
  81. } else if (q != null) {
  82. return decodeURIComponent(q[2]);
  83. } else {
  84. return null;
  85. }
  86. }
  87. const post = function (url, data) {
  88. return new Promise((resolve, reject) => {
  89. $.ajax({
  90. method: 'post',
  91. url: url,
  92. data: JSON.stringify(data),
  93. contentType: "application/json; charset=UTF-8",
  94. beforeSend: function (xmlHttp) {
  95. xmlHttp.setRequestHeader("If-Modified-Since", "0");
  96. xmlHttp.setRequestHeader("Cache-Control", "no-cache");
  97. },
  98. success: function (res) {
  99. resolve({ data: res });
  100. },
  101. error: function (error) {
  102. reject(error);
  103. },
  104. });
  105. });
  106. }
  107. const newinConf = {
  108. width: '600', //窗口的文档显示区的宽度。以像素计。
  109. height: '600', //窗口文档显示区的高度。以像素计。
  110. left: '0', //窗口的 x 坐标。以像素计。
  111. top: '0', //窗口的 y 坐标。以像素计。
  112. openMode: "_blank" //每次都是新窗口打开为_blank,打开同一窗口填写任意字符串
  113. }
  114. const newWindowLocation = `width=${newinConf.width}, height=${newinConf.height}, left=${newinConf.left}, top=${newinConf.top} scrollbars=yes`
  115. const openNewWin = function (url) {
  116. window.open(url, newinConf.openMode, newWindowLocation)
  117. }
  118. //判断浏览器是否为Ie8
  119. const isIe8 = function () {
  120. var DEFAULT_VERSION = 8.0;
  121. var ua = navigator.userAgent.toLowerCase();
  122. var isIE = ua.indexOf("msie") > -1;
  123. var safariVersion;
  124. if (isIE) {
  125. safariVersion = ua.match(/msie ([\d.]+)/)[1];
  126. }
  127. if (safariVersion <= DEFAULT_VERSION) {
  128. return true
  129. }
  130. }
  131. const throttle = function (fn, threshhold) {
  132. var timeout
  133. var start = new Date;
  134. var threshhold = threshhold || 160
  135. return function () {
  136. var context = this, args = arguments, curr = new Date() - 0
  137. clearTimeout(timeout)//总是干掉事件回调
  138. if (curr - start >= threshhold) {
  139. // console.log("now", curr, curr - start)//注意这里相减的结果,都差不多是160左右
  140. fn.apply(context, args) //只执行一部分方法,这些方法是在某个时间段内执行一次
  141. start = curr
  142. } else {
  143. //让方法在脱离事件后也能执行一次
  144. timeout = setTimeout(function () {
  145. fn.apply(context, args)
  146. }, threshhold);
  147. }
  148. }
  149. }
  150. const titleConfig = {
  151. warning:{
  152. background: "#FFE8DD",
  153. icon: iconWarning,
  154. name:"智能警示"
  155. },
  156. symptomPush:{
  157. background: "#EEF5FD",
  158. icon: iconSymptomPush,
  159. name:"推荐症状"
  160. },
  161. diagPush:{
  162. background: "#FAECED",
  163. icon: iconDiagPush,
  164. name:"智能诊断"
  165. },
  166. checkupPush:{
  167. background: "#EEF5FD",
  168. icon: iconCheckupPush,
  169. name:"推荐体格检查"
  170. },
  171. scalePush:{
  172. background: "#ECF4FC",
  173. icon: iconScalePush,
  174. name:"推荐量表"
  175. },
  176. lisPush:{
  177. background: "#ECF4FC",
  178. icon: iconLisPush,
  179. name:"推荐检验"
  180. },
  181. pacsPush:{
  182. background: "#ECF4FC",
  183. icon: iconPacsPush,
  184. name:"推荐检查"
  185. },
  186. drugPush:{
  187. background: "#E3FEFE",
  188. icon: iconDrugPush,
  189. name:"推荐用药"
  190. },
  191. operationPush:{
  192. background: "#E3FEFE",
  193. icon: iconOperationPush,
  194. name:"推荐手术及操作"
  195. },
  196. operationPush2:{
  197. background: "#E3FEFE",
  198. icon: iconOperationPush,
  199. name:"手术/操作"
  200. }
  201. }
  202. const titleConfigH = {
  203. warning:{
  204. background: "#FFE8DD",
  205. icon: iconWarning,
  206. name:"智能警示"
  207. },
  208. symptomPush:{
  209. background: "#EEF5FD",
  210. icon: iconSymptomPush,
  211. name:"推荐症状"
  212. },
  213. diagPush:{
  214. background: "#FAECED",
  215. icon: iconDiagPush,
  216. name:"智能诊断"
  217. },
  218. checkupPush:{
  219. background: "#EEF5FD",
  220. icon: iconCheckupPush,
  221. name:"体格检查"
  222. },
  223. scalePush:{
  224. background: "#ECF4FC",
  225. icon: iconScalePush,
  226. name:"推荐量表"
  227. },
  228. lisPush:{
  229. background: "#ECF4FC",
  230. icon: iconLisPush,
  231. name:"推荐检验"
  232. },
  233. pacsPush:{
  234. background: "#ECF4FC",
  235. icon: iconPacsPush,
  236. name:"推荐检查"
  237. },
  238. drugPush:{
  239. background: "#E3FEFE",
  240. icon: iconTreatMedicine,
  241. name:"推荐用药"
  242. },
  243. operationPush:{
  244. background: "#E3FEFE",
  245. icon: iconTreatMedicine,
  246. name:"手术/操作"
  247. },
  248. vigilancePush:{
  249. background: "#FFE8DD",
  250. icon: iconWarning,
  251. name:"警惕"
  252. },
  253. treat:{
  254. background: "#FFE8DD",
  255. icon: iconTreat,
  256. name:"治疗方案"
  257. }
  258. }
  259. module.exports = {
  260. config,
  261. post,
  262. getUrlArgObject,
  263. imageUrlPrefix,
  264. throttle,
  265. openNewWin,
  266. isIe8,
  267. titleConfig,
  268. titleConfigH
  269. }