+ L414-5KR 相关物质修改提示信息
+ 目录结构调整
This commit is contained in:
193
views/injection-sequence.html
Normal file
193
views/injection-sequence.html
Normal file
@@ -0,0 +1,193 @@
|
||||
<!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/dayjs.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script type="module">
|
||||
import { Decimal } from "../statics/modules/decimal.mjs"
|
||||
|
||||
const decimal = Decimal.set({
|
||||
rounding: Decimal.ROUND_HALF_EVEN,
|
||||
precision: 12
|
||||
})
|
||||
|
||||
$(document).ready(() => {
|
||||
let tip = `
|
||||
<p>此功能用于计算批处理中每一针样品运行的时间。</p>
|
||||
<p>设置时间偏移量可以将每一针的结束时间提前,用于给查看样品图谱及现配现进等操作预留时间。</p>
|
||||
<p>仪器进样需要一定的时间,该部分时间虽然短,积累起来却不可忽视。<br>
|
||||
此功能以当前运行样品的时间为起点,再向前/向后计算其他针的时间。所以,越远离当前运行的样品,则误差越大。
|
||||
</p>`
|
||||
$("#output").append(tip)
|
||||
|
||||
$("#ok").click(() => {
|
||||
let allId = new Decimal($("#allId").val()).toNumber()
|
||||
let nowId = new Decimal($("#nowId").val()).toNumber()
|
||||
let time = new Decimal($("#time").val()).toNumber()
|
||||
let nowTime = new Decimal($("#nowTime").val()).toNumber()
|
||||
let offset = new Decimal($("#offset").val()).toNumber()
|
||||
let data = []
|
||||
|
||||
// 生成数据
|
||||
let array = genData(allId, nowId, time, nowTime, offset)
|
||||
let formatString = 'YYYY-MM-DD HH:mm'
|
||||
array.forEach((value, index) => {
|
||||
data.push({
|
||||
"id": index + 1,
|
||||
"startTime": value.format(formatString),
|
||||
"endTime": value.add(time, 'minute').format(formatString),
|
||||
"offsetTime": value.add(time - offset, 'minute').format(formatString)
|
||||
})
|
||||
})
|
||||
|
||||
// 未生成数据,不进行结果展示
|
||||
if (data.length == 0) return
|
||||
|
||||
$("#output").empty()
|
||||
$("#output").append(createTable(data))
|
||||
})
|
||||
|
||||
$("#clear").click(() => {
|
||||
$("#allId").val("")
|
||||
$("#nowId").val("")
|
||||
$("#time").val("")
|
||||
$("#nowTime").val("")
|
||||
$("#offset").val("")
|
||||
$("#output").empty()
|
||||
$("#output").append(tip)
|
||||
})
|
||||
|
||||
$("#new_page").click(() => {
|
||||
window.open(window.location.href, "_blank")
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 生成数据
|
||||
* @author <a href="mailto:3243430237@qq.com" target="_blank">hbk01</a>
|
||||
* @param {Number} allId 总针数(即需要计算多少条数据)
|
||||
* @param {Number} nowId 当前针数(当前仪器运行到第几针)
|
||||
* @param {Number} time 一针有多少分钟(包括后运行)
|
||||
* @param {Number} nowTime 当前这针已经运行了多少分钟
|
||||
* @param {Number} offset 每一针需偏移多少分钟
|
||||
* @return {Array} dayjs
|
||||
*/
|
||||
function genData(allId, nowId, time, nowTime, offset) {
|
||||
let array = new Array(allId)
|
||||
let now = new dayjs()
|
||||
// 将当前这针的开始时间先设置好
|
||||
array[nowId - 1] = now.subtract(nowTime, 'minute')
|
||||
// 计算当前这针前面的时间
|
||||
for (let index = nowId - 2; index >= 0; index--) {
|
||||
array[index] = array[index + 1].subtract(time, 'minute')
|
||||
}
|
||||
// 计算当前这针后面的时间
|
||||
for (let index = nowId; index < allId; index++) {
|
||||
array[index] = array[index - 1].add(time, 'minute')
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建表格元素并将数据填入其中。
|
||||
*/
|
||||
function createTable(data) {
|
||||
let nowId = new Decimal($("#nowId").val()).toNumber()
|
||||
|
||||
let table = document.createElement("table")
|
||||
table.setAttribute("style", "width: 100%; text-align: center; font-size: smaller;")
|
||||
table.setAttribute("class", "pure-table")
|
||||
|
||||
let row = document.createElement("tr")
|
||||
let lineNum = document.createElement("th")
|
||||
let startTime = document.createElement("th")
|
||||
let endTime = document.createElement("th")
|
||||
let offset = document.createElement("th")
|
||||
lineNum.innerText = "序号"
|
||||
startTime.innerText = "开始时间"
|
||||
endTime.innerText = "结束时间"
|
||||
offset.innerText = "偏移后"
|
||||
row.appendChild(lineNum)
|
||||
row.appendChild(startTime)
|
||||
row.appendChild(endTime)
|
||||
// row.appendChild(offset)
|
||||
table.appendChild(row)
|
||||
let highlight = 'background-color: #ffffcc;'
|
||||
data.forEach(element => {
|
||||
let tr = document.createElement("tr")
|
||||
let td_id = document.createElement("td")
|
||||
let td_start_time = document.createElement("td")
|
||||
let td_end_time = document.createElement("td")
|
||||
let td_offset_time = document.createElement("td")
|
||||
|
||||
td_id.innerText = element.id
|
||||
td_start_time.innerText = element.startTime
|
||||
// td_end_time.innerText = element.endTime
|
||||
td_end_time.innerText = element.offsetTime
|
||||
td_offset_time.innerText = element.offsetTime
|
||||
|
||||
if (element.id == nowId) tr.style = highlight
|
||||
|
||||
tr.appendChild(td_id)
|
||||
tr.appendChild(td_start_time)
|
||||
tr.appendChild(td_end_time)
|
||||
// tr.appendChild(td_offset_time)
|
||||
table.appendChild(tr)
|
||||
})
|
||||
return table
|
||||
}
|
||||
|
||||
// 为 Date 创建日期格式化方法
|
||||
Date.prototype.format = function (fmt) {
|
||||
let o = {
|
||||
"M+": this.getMonth() + 1, //月份
|
||||
"d+": this.getDate(), //日
|
||||
"h+": this.getHours(), //小时
|
||||
"m+": this.getMinutes(), //分
|
||||
"s+": this.getSeconds(), //秒
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
}
|
||||
if (/(y+)/.test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
|
||||
}
|
||||
for (let k in o) {
|
||||
if (new RegExp("(" + k + ")").test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)))
|
||||
}
|
||||
}
|
||||
return fmt
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>进样时间</h3>
|
||||
<div class="input">
|
||||
<div class="inputbox">
|
||||
<input type="number" id="allId" placeholder="批处理中样品的总数" inputmode="decimal" autocomplete="off">
|
||||
<input type="number" id="time" placeholder="每一针的运行时间" inputmode="decimal" autocomplete="off">
|
||||
<input type="number" id="nowId" placeholder="当前运行到第几针" inputmode="decimal" autocomplete="off">
|
||||
<input type="number" id="nowTime" placeholder="现在这针运行多少分钟" inputmode="decimal" autocomplete="off">
|
||||
<input type="number" id="offset" placeholder="时间偏移量" inputmode="decimal" autocomplete="off">
|
||||
</div>
|
||||
<br>
|
||||
<div class="buttons">
|
||||
<button id="new_page">新开标签页</button>
|
||||
<button id="clear">清除内容</button>
|
||||
<button id="ok">计算</button>
|
||||
</div>
|
||||
<br>
|
||||
</div>
|
||||
<div id="output"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user