promise.js 9.0 KB

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