const { post, config, getUrlArgObject } = require('./promise.js'); const $ = require("jquery"); $(function () { var scaleInfo; // 用GetQueryString方法从地址栏获取参数,暂时写死 var params = { "age": getUrlArgObject('age') || 28, "featureType": getUrlArgObject('featureType') || '21', "scaleId": getUrlArgObject('scaleId') || 40744, "scaleName": getUrlArgObject('scaleName') || '密西根糖尿病周围神经病评分(MDNS)', "sex": getUrlArgObject('sex') || 1, "diag": getUrlArgObject('diag') || '肺结核(复诊);', "lis": getUrlArgObject('lis') ? JSON.parse(getUrlArgObject('lis')) : [], "symptom": getUrlArgObject('symptom') || '', "other": getUrlArgObject('other') || '', "pacs": getUrlArgObject('pacs') || '', "vital": getUrlArgObject('vital') || '' } if (getUrlArgObject('scaleId')) { post(config.pushInner, params).then((res) => { const data = res.data.data if (res.data.code == 0) { scaleInfo = data.scale; for (var i = 0; i < scaleInfo.length; i++) { if (scaleInfo[i].type == 1) { var scaleList = JSON.parse(scaleInfo[i].content) renderCalcu(scaleList) } else { $('.content').append(scaleInfo[i].content) } } $('input').on('change', function (e) { var indexList = $(this).attr('data-index').split(',') for (var i = 0; i < scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details.length; i++) { scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details[i].select = 0 } scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details[indexList[3]].select = 1 const className = $(this).parent().parent().parent().attr('data-group') for (let i = 0; i < $('.' + className).length; i++) { $('.' + className).eq(i).removeClass('noSelect') } }) $('.calcuBtn').on('click', function () { let allSelect = true for (let i = 0; i < scaleList.group.length; i++) { for (let j = 0; j < scaleList.group[i].rows.length; j++) { if (scaleList.group[i].rows[j].required == 1) { let itemSelect = false for (let x = 0; x < scaleList.group[i].rows[j].row.length; x++) { for (let y = 0; y < scaleList.group[i].rows[j].row[x].details.length; y++) { if (scaleList.group[i].rows[j].row[x].details[y].select == 1) { itemSelect = true } } } if (!itemSelect) { allSelect = false $('.' + i + j).addClass('noSelect') } } } } if (!allSelect) { $('.modal').css('display', 'block'); let timer = setTimeout(() => { $('.modal').css('display', 'none'); }, 2000); $('.closeModal').click(function () { $('.modal').css('display', 'none'); if (timer) { clearTimeout(timer) } }) } if (allSelect) { getCalcuResult(scaleList) } }) } }) } }) function renderCalcu(scaleList) { $("h1").html(scaleList.scaleName); var str = '' for (var j = 0; j < scaleList.group.length; j++) { str += '