tcmiss.js 3.6 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.find((it) => it.code === "treatment");
  46. const num = (item || {}).number || 3;
  47. const {tcmDiag, tcmSyndrome} = param;
  48. if (!tcmDiag) { //没有推送入参时不显示推送模块
  49. $(".recipe").hide();
  50. return;
  51. }
  52. $("#jibing").text(tcmDiag + "-" + tcmSyndrome);
  53. $('#bingming').text(tcmDiag);
  54. $('#zhenghou').text(tcmSyndrome);
  55. treatUrl = targetUrl + '?jibing=' + tcmDiag + "&zhengxing=" + tcmSyndrome;
  56. //处方推荐
  57. get('/lantone/private/zycftj?jibing=' + tcmDiag + "&zhengxing=" + tcmSyndrome).then((res) => {
  58. //console.log(res)
  59. let data = res.data.data || []
  60. if (!data.length) { //没有处方时不显示推送模块
  61. $(".recipe").hide();
  62. return;
  63. }
  64. if (res.data.status) {
  65. renderTcm(data, num)
  66. } else {
  67. }
  68. })
  69. //治法推荐-暂时不用
  70. /*get('/lantone/private/zhongyizx?type=1&code=' + tcmDiag + '&value=' + tcmSyndrome).then((res) => {
  71. console.log(res)
  72. let data = res.data.data || {}
  73. if (res.data.status) {
  74. //renderTcm(data)
  75. } else {
  76. }
  77. })*/
  78. }
  79. function renderTcm(data, num = 3) {
  80. let str = ``, it;
  81. $("#goTreat").hide();
  82. console.log(num)
  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(treatUrl, true);
  105. });
  106. }
  107. module.exports = {
  108. getTcmMr
  109. }