tcmiss.js 4.1 KB

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