Files
qctool/views/titer.html

109 lines
3.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>标水</title>
<link rel="stylesheet" href="../statics/github.css">
<link rel="stylesheet" href="../statics/theme.css">
<script src="../statics/modules/jquery.min.js"></script>
<script type="module">
import { Decimal } from "../statics/modules/decimal.mjs"
import { Formula } from "../statics/modules/tools.js"
let debug = false
let tip = `<br>
请输入三次 F 值<br>
公式:<br>
F' = AVERAGE(F1, F2, F3)<br>
RDx = [ Fx - F' ] / F' * 100`
let decimal = Decimal.set({
rounding: Decimal.ROUND_HALF_EVEN,
precision: 12
})
$(document).ready(() => {
message(tip)
$("#ok").click(() => {
let m0 = $("#m0").val()
let m1 = $("#m1").val()
let m2 = $("#m2").val()
let f = Formula.AVERAGE(m0, m1, m2).toFixed(4, Decimal.ROUND_HALF_EVEN)
let msg = `
<br>
F值平均值 = ${f}<br>
RD1 = ${format(titer(f, m0))}<br>
RD2 = ${format(titer(f, m1))}<br>
RD3 = ${format(titer(f, m2))}<br>
`
message(msg)
})
$("#clear").click(() => {
$("#m0").val("")
$("#m1").val("")
$("#m2").val("")
message(tip)
})
$("#new_page").click(() => {
window.open(window.location.href, "_blank")
})
if (debug) {
$("#m0").val(5.1183)
$("#m1").val(5.1823)
$("#m2").val(5.0926)
}
})
function message(msg) {
$(".msgbox").empty()
$(".msgbox").html(msg)
}
/**
* 计算标水
* @param f F值为三次mg/mL值的平均值
* @param m 该次mg/mL的值
*/
function titer(f, m) {
let temp = decimal.sub(m, f)
return temp.div(f).mul(100).toFixed(2, Decimal.ROUND_HALF_EVEN)
}
function format(value, min = -1, max = 1) {
if (value <= min || value >= max) {
return `<span style='font-family: none; color: red;'>${value}</span>`
}
return `<span style='font-family: none;'>${value}</span>`
}
</script>
</head>
<body>
<h3>标水</h3>
<div class="team">
<input type="number" id="m0" class="m0" placeholder="F1" inputmode="decimal"><br>
<input type="number" id="m1" class="m1" placeholder="F2" inputmode="decimal"><br>
<input type="number" id="m2" class="m2" placeholder="F3" inputmode="decimal"><br>
</div>
<br>
<div class="buttons">
<button id="new_page">新开标签页</button>
<button id="clear">清除内容</button>
<button id="ok">计算</button>
</div>
<div class="msgbox"></div>
</body>
</html>