From e21b2ba792508464e242dee61e9d12755fd8ba66 Mon Sep 17 00:00:00 2001 From: hbk01 <3243430237@qq.com> Date: Sat, 12 Apr 2025 20:19:39 +0800 Subject: [PATCH] =?UTF-8?q?+=20=E8=BF=9B=E6=A0=B7=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=97=B6=E9=97=B4=E5=81=8F=E7=A7=BB=E9=87=8F?= =?UTF-8?q?=20+=20=E8=BF=9B=E6=A0=B7=E6=97=B6=E9=97=B4=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=A1=A5=E5=81=BF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/injection-sequence.html | 62 +++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/views/injection-sequence.html b/views/injection-sequence.html index fa11eb1..7cfe539 100644 --- a/views/injection-sequence.html +++ b/views/injection-sequence.html @@ -21,16 +21,23 @@ $(document).ready(() => { let tip = `
此功能用于计算批处理中每一针样品运行的时间。
-设置时间偏移量可以将每一针的结束时间提前,用于给查看样品图谱及现配现进等操作预留时间。
-仪器进样需要一定的时间,该部分时间虽然短,积累起来却不可忽视。
- 此功能以当前运行样品的时间为起点,再向前/向后计算其他针的时间。所以,越远离当前运行的样品,则误差越大。
-
仪器进样需要一定的时间,该部分时间虽然短,积累起来却不可忽视。
+此功能以当前运行样品的时间为起点,再向前或向后计算其他针的时间。所以,越远离当前运行的样品,则误差越大。
+误差不可避免,但勾选时间补偿可尽量校正该误差。
+ ` $("#output").append(tip) // 初始化当前日期和时间 $("#nowDate").val(new Date().format("yyyy-MM-dd")) $("#nowTime").val(new Date().format("hh:mm")) + // 默认选中时间补偿 + let offset = true + // 注册时间补偿的事件监听器 + $("#offset").on("change", function () { + offset = $(this).is(":checked") + }) + $("#ok").click(() => { let nowDate = $("#nowDate").val() let nowTime = $("#nowTime").val() @@ -38,18 +45,17 @@ let nowId = new Decimal($("#nowId").val()).toNumber() let time = new Decimal($("#time").val()).toNumber() let nowRunTime = new Decimal($("#nowRunTime").val()).toNumber() - let offset = new Decimal($("#offset").val()).toNumber() + let data = [] // 生成数据 - let array = genData(nowDate, nowTime, allId, nowId, time, nowRunTime, offset) + let array = genData(nowDate, nowTime, allId, nowId, time, nowRunTime, offset ? 30 : 1) 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) }) }) @@ -67,7 +73,6 @@ $("#nowId").val("") $("#time").val("") $("#nowRunTime").val("") - // $("#offset").val("") $("#output").empty() $("#output").append(tip) }) @@ -86,8 +91,8 @@ * @param {Number} nowId 当前针数(当前仪器运行到第几针) * @param {Number} time 一针有多少分钟(包括后运行) * @param {Number} nowRunTime 当前这针已经运行了多少分钟 - * @param {Number} offset 每一针需偏移多少分钟 - * @return {Array} dayjs + * @param {Number} offset 每一针需偏移多少秒(默认 30 秒) + * @return {Array} 保存了 dayjs 对象的数组,每一个元素代表一针的开始时间 */ function genData(nowDate, nowTime, allId, nowId, time, nowRunTime, offset) { let array = new Array(allId) @@ -97,11 +102,11 @@ array[nowId - 1] = now.subtract(nowRunTime, 'minute') // 计算当前这针前面的时间 for (let index = nowId - 2; index >= 0; index--) { - array[index] = array[index + 1].subtract(time, 'minute') + array[index] = array[index + 1].subtract(time, 'minute').subtract(offset, 'second') } // 计算当前这针后面的时间 for (let index = nowId; index < allId; index++) { - array[index] = array[index - 1].add(time, 'minute') + array[index] = array[index - 1].add(time, 'minute').add(offset, 'second') } return array } @@ -120,15 +125,12 @@ 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 => { @@ -136,20 +138,16 @@ 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 + td_end_time.innerText = element.endTime 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 @@ -214,6 +212,23 @@ font-size: medium; line-height: 32px; } + + .offset { + display: flex; + display: -webkit-flex; + align-items: center; + line-height: 32px; + } + + .offset label { + width: 100%; + line-height: 32px; + padding-left: 5px; + } + + #offset { + width: 20px; + } @@ -256,10 +271,9 @@ - -