const $ = require("jquery"); const {get, post, config, getUrlArgObject, openNewWin, titleConfig} = require('./promise.js'); const targetUrl = 'http://114.55.109.16:81/lantone/index'; let treatUrl = targetUrl; $(function () { let mrId = getUrlArgObject('mrId') $(".knowledge .a-link").click(function () { const code = $(this).attr("code"); openNewWin(targetUrl + '?page=' + code, true); }) $("#goPush").on("click", function () { openNewWin(targetUrl + '?page=bztd', true); }); }); function renderConfig(config) { const classMap = { 'conditionder': 'go-push', 'treatment': 'recipe', 'tcmknowledge': 'knowledge', }; config.map((it) => { if (+it.status === 1) { $(".tcmWarp ." + classMap[it.code]).show(); } }) } function getTcmMr(mrId, config) { renderConfig(config.planDetails || []); if (!mrId) { //没有mrId时不显示推送模块 $(".recipe").hide(); return; } post('/sys/mr/getTcmMr', {mrId: mrId}).then((res) => { //console.log(res) let data = res.data.data || {} const {tcmdisease, tcmsyndrome} = data; if (res.data.code === '0') { getTcmData({tcmDiag: (tcmdisease || {}).uniqueName, tcmSyndrome: (tcmsyndrome || {}).uniqueName}, config) } else { } }) } //获取处方推荐 function getTcmData(param, config) { const item = config.planDetails.find((it) => it.code === "treatment"); const num = (item || {}).number || 3; const {tcmDiag, tcmSyndrome} = param; if (!tcmDiag) { //没有推送入参时不显示推送模块 $(".recipe").hide(); return; } $("#jibing").text(tcmDiag + "-" + tcmSyndrome); $('#bingming').text(tcmDiag); $('#zhenghou').text(tcmSyndrome); treatUrl = targetUrl + '?jibing=' + tcmDiag + "&zhengxing=" + tcmSyndrome; //处方推荐 get('/lantone/private/zycftj?jibing=' + tcmDiag + "&zhengxing=" + tcmSyndrome).then((res) => { //console.log(res) let data = res.data.data || [] if (!data.length) { //没有处方时不显示推送模块 $(".recipe").hide(); return; } if (res.data.status) { renderTcm(data, num) } else { } }) //治法推荐-暂时不用 /*get('/lantone/private/zhongyizx?type=1&code=' + tcmDiag + '&value=' + tcmSyndrome).then((res) => { console.log(res) let data = res.data.data || {} if (res.data.status) { //renderTcm(data) } else { } })*/ } function renderTcm(data, num = 3) { let str = ``, it; $("#goTreat").hide(); console.log(num) const n = num < data.length ? num : data.length; for (let i = 0; i < n; i++) { it = data[i]; str += `
${it.name}
${it.effect}