tcmiss.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. const $ = require("jquery");
  2. const {get, post, config, getUrlArgObject, openNewWin, titleConfig} = require('./promise.js');
  3. const targetUrl = 'http://114.55.109.16:81/lantone/index';
  4. let treatUrl = targetUrl;
  5. $(function () {
  6. let mrId = getUrlArgObject('mrId')
  7. $(".knowledge .a-link").click(function () {
  8. const code = $(this).attr("code");
  9. openNewWin(targetUrl + '?page=' + code, true);
  10. })
  11. $("#goPush").on("click", function () {
  12. openNewWin(targetUrl + '?page=bztd', true);
  13. });
  14. });
  15. function renderConfig(config) {
  16. const classMap = {
  17. 'conditionder': 'go-push',
  18. 'treatment': 'recipe',
  19. 'tcmknowledge': 'knowledge',
  20. };
  21. config.map((it) => {
  22. if (+it.status === 1) {
  23. $(".tcmWarp ." + classMap[it.code]).show();
  24. }
  25. })
  26. }
  27. function getTcmMr(mrId, config) {
  28. renderConfig(config.planDetails || []);
  29. if (!mrId) { //没有mrId时不显示推送模块
  30. $(".recipe").hide();
  31. return;
  32. }
  33. post('/sys/mr/getTcmMr', {mrId: mrId}).then((res) => {
  34. //console.log(res)
  35. let data = res.data.data || {}
  36. const {tcmdisease, tcmsyndrome} = data;
  37. if (res.data.code === '0') {
  38. getTcmData({tcmDiag: (tcmdisease || {}).uniqueName, tcmSyndrome: (tcmsyndrome || {}).uniqueName}, config)
  39. } else {
  40. }
  41. })
  42. }
  43. //获取处方推荐
  44. function getTcmData(param, config) {
  45. const item = config.planDetails.filter((it) => it.code === "treatment");
  46. const isHor = window.location.pathname.indexOf("cdssHorizontal") > -1;
  47. const num = isHor ? 3 : ((item[0] || {}).number || 3);
  48. const {tcmDiag, tcmSyndrome} = param;
  49. if (!tcmDiag) { //没有推送入参时不显示推送模块
  50. $(".recipe").hide();
  51. return;
  52. }
  53. $("#jibing").text(tcmDiag + "-" + tcmSyndrome);
  54. $('#bingming').text(tcmDiag);
  55. $('#zhenghou').text(tcmSyndrome);
  56. treatUrl = targetUrl + '?jibing=' + tcmDiag + "&zhengxing=" + tcmSyndrome;
  57. //处方推荐
  58. get(window.encodeURI('/lantone/private/zycftj?jibing=' + tcmDiag + "&zhengxing=" + tcmSyndrome)).then((res) => {
  59. console.log("窗口地址:", treatUrl)
  60. let data = res.data.data || []
  61. if (!data.length) { //没有处方时不显示推送模块
  62. $(".recipe").hide();
  63. return;
  64. }
  65. if (res.data.status) {
  66. renderTcm(data, num)
  67. } else {
  68. }
  69. })
  70. //治法推荐-暂时不用
  71. /*get('/lantone/private/zhongyizx?type=1&code=' + tcmDiag + '&value=' + tcmSyndrome).then((res) => {
  72. console.log(res)
  73. let data = res.data.data || {}
  74. if (res.data.status) {
  75. //renderTcm(data)
  76. } else {
  77. }
  78. })*/
  79. }
  80. function renderTcm(data, num = 3) {
  81. let str = ``, it;
  82. $("#goTreat").hide();
  83. const n = num < data.length ? num : data.length;
  84. for (let i = 0; i < n; i++) {
  85. it = data[i];
  86. str += `<li class="clearfix"><div class="label">处方${i + 1}:</div>
  87. <div class="val">
  88. <p class="name">${it.name}</p>
  89. <p class="desc" title="${it.effect}">${it.effect}</p>
  90. </div></li>`;
  91. }
  92. if (data.length > num) {
  93. if ($("#goTreat").length) { //竖版不增加更多按钮,显示即可
  94. str += ``;
  95. $("#goTreat").show();
  96. } else {
  97. str += `<a class="go go-push" id="goTreat">更多 <img class="icon" src="./images/go.png" alt=""></a>`;
  98. $("#goTreat").show();
  99. }
  100. }
  101. $('.detail ul').html(str);
  102. //更多治法
  103. $("#goTreat").on('click', function () {
  104. openNewWin(window.encodeURI(treatUrl), true);
  105. });
  106. }
  107. module.exports = {
  108. getTcmMr
  109. }