From 216264ed5b3bd7e56d2975bc9a20f915300ae2be Mon Sep 17 00:00:00 2001 From: hbk01 <3243430237@qq.com> Date: Fri, 11 Apr 2025 00:42:18 +0800 Subject: [PATCH] =?UTF-8?q?+=20=E8=BF=9B=E6=A0=B7=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E6=8B=A9=E6=97=A5=E6=9C=9F=E6=97=B6=E9=97=B4?= =?UTF-8?q?=20+=20=E8=BF=9B=E6=A0=B7=E6=97=B6=E9=97=B4=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=81=8F=E7=A7=BB=E9=87=8F=E9=BB=98=E8=AE=A4=E4=B8=BA?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/injection-sequence.html | 48 ++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/views/injection-sequence.html b/views/injection-sequence.html index 22348b2..fa11eb1 100644 --- a/views/injection-sequence.html +++ b/views/injection-sequence.html @@ -27,16 +27,22 @@
` $("#output").append(tip) + // 初始化当前日期和时间 + $("#nowDate").val(new Date().format("yyyy-MM-dd")) + $("#nowTime").val(new Date().format("hh:mm")) + $("#ok").click(() => { + let nowDate = $("#nowDate").val() + let nowTime = $("#nowTime").val() 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 nowRunTime = new Decimal($("#nowRunTime").val()).toNumber() let offset = new Decimal($("#offset").val()).toNumber() let data = [] // 生成数据 - let array = genData(allId, nowId, time, nowTime, offset) + let array = genData(nowDate, nowTime, allId, nowId, time, nowRunTime, offset) let formatString = 'YYYY-MM-DD HH:mm' array.forEach((value, index) => { data.push({ @@ -55,11 +61,13 @@ }) $("#clear").click(() => { + $("#nowDate").val(new Date().format("yyyy-MM-dd")) + $("#nowTime").val(new Date().format("hh:mm")) $("#allId").val("") $("#nowId").val("") $("#time").val("") - $("#nowTime").val("") - $("#offset").val("") + $("#nowRunTime").val("") + // $("#offset").val("") $("#output").empty() $("#output").append(tip) }) @@ -72,18 +80,21 @@ /** * 生成数据 * @author hbk01 + * @param {String} nowDate 当前日期,yyyy-MM-dd + * @param {String} nowTime 当前时间,hh:mm:ss * @param {Number} allId 总针数(即需要计算多少条数据) * @param {Number} nowId 当前针数(当前仪器运行到第几针) * @param {Number} time 一针有多少分钟(包括后运行) - * @param {Number} nowTime 当前这针已经运行了多少分钟 + * @param {Number} nowRunTime 当前这针已经运行了多少分钟 * @param {Number} offset 每一针需偏移多少分钟 * @return {Array} dayjs */ - function genData(allId, nowId, time, nowTime, offset) { + function genData(nowDate, nowTime, allId, nowId, time, nowRunTime, offset) { let array = new Array(allId) - let now = new dayjs() + let now = new dayjs(`${nowDate} ${nowTime}`) + // 将当前这针的开始时间先设置好 - array[nowId - 1] = now.subtract(nowTime, 'minute') + array[nowId - 1] = now.subtract(nowRunTime, 'minute') // 计算当前这针前面的时间 for (let index = nowId - 2; index >= 0; index--) { array[index] = array[index + 1].subtract(time, 'minute') @@ -210,6 +221,19 @@