+ 新增日期计算
+ 去除效期查询
This commit is contained in:
@@ -25,9 +25,13 @@
|
|||||||
"name": "进样时间",
|
"name": "进样时间",
|
||||||
"location": "./views/injection-sequence.html"
|
"location": "./views/injection-sequence.html"
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// "name": "效期查询",
|
||||||
|
// "location": "./views/expir-info.html"
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
"name": "效期查询",
|
"name": "日期计算",
|
||||||
"location": "./views/expir-info.html"
|
"location": "./views/calc-date.html"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "操作规程",
|
"name": "操作规程",
|
||||||
|
|||||||
238
views/calc-date.html
Normal file
238
views/calc-date.html
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
<!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">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
height: 30px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 100%;
|
||||||
|
height: 36px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#includeToday {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#includeToday+label {
|
||||||
|
display: inline-block;
|
||||||
|
width: 90%;
|
||||||
|
vertical-align: text-bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table {
|
||||||
|
width: 100%;
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table caption {
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="../statics/modules/jquery.min.js"></script>
|
||||||
|
<script>
|
||||||
|
const SS_DATA = [
|
||||||
|
// L014-1
|
||||||
|
{ "name": "RS-LOQ-L014-1", "days": 86 },
|
||||||
|
{ "name": "RS-SST-L014-1", "days": 15 },
|
||||||
|
// L014-2
|
||||||
|
{ "name": "RS-LOQ-L014-2", "days": 85 },
|
||||||
|
{ "name": "RS-SST-L014-2", "days": 85 },
|
||||||
|
{ "name": "E-LOQ-L014-2", "days": 86 },
|
||||||
|
{ "name": "E-SST-L014-2", "days": 86 },
|
||||||
|
// L414-5KR
|
||||||
|
{ "name": "RS-LOQ-L414-5KR", "days": 90 },
|
||||||
|
{ "name": "RS-SST-L414-5KR", "days": 90 },
|
||||||
|
{ "name": "E-LOQ-L414-5KR", "days": 88 },
|
||||||
|
{ "name": "E-SST-L414-5KR", "days": 91 },
|
||||||
|
// L414-7
|
||||||
|
{ "name": "RS-LOQ-L414-7", "days": 90 },
|
||||||
|
{ "name": "RS-SST-L414-7", "days": 90 },
|
||||||
|
{ "name": "E-LOQ-L414-7", "days": 90 },
|
||||||
|
{ "name": "E-SST-L414-7", "days": 90 },
|
||||||
|
// L414-801KR
|
||||||
|
{ "name": "RS-LOQ-L414-801KR", "days": 90 },
|
||||||
|
{ "name": "RS-SST-L414-801KR", "days": 90 },
|
||||||
|
{ "name": "E-LOQ-L414-801KR", "days": 90 },
|
||||||
|
{ "name": "E-SST-L414-801KR", "days": 90 },
|
||||||
|
// L414-9KR
|
||||||
|
{ "name": "RS-LOQ-L414-9KR", "days": 91 },
|
||||||
|
{ "name": "RS-SST-L414-9KR", "days": 91 },
|
||||||
|
{ "name": "E-LOQ-L414-9KR", "days": 90 },
|
||||||
|
{ "name": "E-SST-L414-9KR", "days": 90 }
|
||||||
|
]
|
||||||
|
|
||||||
|
const MP_DATA = [
|
||||||
|
{ "name": "超纯水", "days": 2, "includeToday": true },
|
||||||
|
{ "name": "低于10%有机溶剂", "days": 4, "includeToday": true },
|
||||||
|
{ "name": "不低于10%有机溶剂", "days": 8, "includeToday": true },
|
||||||
|
{ "name": "纯有机溶剂加入酸或碱", "days": 15, "includeToday": true },
|
||||||
|
{ "name": "有机溶剂相互混合", "month": 3, "includeToday": true },
|
||||||
|
{ "name": "原瓶的有机溶剂", "month": 6, "days": -1, "includeToday": false },
|
||||||
|
{ "name": "分装的有机溶剂", "month": 6, "days": 1, "includeToday": true },
|
||||||
|
{ "name": "含三乙胺", "days": 6, "includeToday": true },
|
||||||
|
{ "name": "洗针液", "month": 3, "includeToday": false },
|
||||||
|
]
|
||||||
|
|
||||||
|
$(() => {
|
||||||
|
$("#startDate").val(new Date().toISOString().split("T")[0])
|
||||||
|
|
||||||
|
$("#calculate").click(() => {
|
||||||
|
let startDate = new Date($("#startDate").val())
|
||||||
|
let days = parseInt($("#days").val())
|
||||||
|
let includeToday = $("#includeToday").is(":checked")
|
||||||
|
let endDate = calcDate(startDate, { days: days }, includeToday)
|
||||||
|
$("#endDate").val(endDate.toISOString().split("T")[0])
|
||||||
|
})
|
||||||
|
|
||||||
|
SS_DATA.forEach(ss => {
|
||||||
|
let startDate = new Date()
|
||||||
|
let endDate = calcDate(startDate, { days: ss.days }, true)
|
||||||
|
ss.end = formatDateString(endDate, "Y.M.D")
|
||||||
|
ss.name = `${ss.name}-${formatDateString(startDate, "YMD")}-01`
|
||||||
|
})
|
||||||
|
|
||||||
|
MP_DATA.forEach(mp => {
|
||||||
|
let startDate = new Date()
|
||||||
|
let endDate = new Date(startDate)
|
||||||
|
|
||||||
|
endDate = calcDate(startDate, {
|
||||||
|
year: mp.year,
|
||||||
|
month: mp.month,
|
||||||
|
days: mp.days
|
||||||
|
}, mp.includeToday)
|
||||||
|
|
||||||
|
mp.end = formatDateString(endDate, mp.includeToday ? "Y.M.D(h:m)" : "Y.M.D")
|
||||||
|
})
|
||||||
|
|
||||||
|
let ss_table = createTable(SS_DATA, "稳定性溶液有效期一览表", ["溶液编号", "有效期至"], ["days"])
|
||||||
|
let mp_table = createTable(MP_DATA, "流动相有效期一览表", ["流动相名称", "有效期至"], ["days", "month", "includeToday"])
|
||||||
|
$("#container").append(mp_table)
|
||||||
|
$("#container").append(ss_table)
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算结束日期
|
||||||
|
* @param {Date} startDate 起始日期
|
||||||
|
* @param {number} days 天数
|
||||||
|
* @param {boolean} includeToday 是否包含当日
|
||||||
|
* @returns {Date} 结束日期
|
||||||
|
*/
|
||||||
|
function calcDate(startDate, option, includeToday) {
|
||||||
|
let endDate = new Date(startDate)
|
||||||
|
endDate.setFullYear(endDate.getFullYear() + (option.year || 0))
|
||||||
|
endDate.setMonth(endDate.getMonth() + (option.month || 0))
|
||||||
|
endDate.setDate(endDate.getDate() + (option.days || 0) - (includeToday ? 1 : 0))
|
||||||
|
return endDate
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTable(data, captionText, header, hidden = []) {
|
||||||
|
let table = document.createElement("table")
|
||||||
|
table.setAttribute("class", "pure-table")
|
||||||
|
|
||||||
|
let caption = document.createElement("caption")
|
||||||
|
caption.innerText = captionText
|
||||||
|
table.appendChild(caption)
|
||||||
|
|
||||||
|
let tr = document.createElement("tr")
|
||||||
|
for (const headerText of header) {
|
||||||
|
let th = document.createElement("th")
|
||||||
|
th.innerText = headerText
|
||||||
|
tr.appendChild(th)
|
||||||
|
}
|
||||||
|
table.appendChild(tr)
|
||||||
|
|
||||||
|
data.forEach(element => {
|
||||||
|
let tr = document.createElement("tr")
|
||||||
|
for (const key in element) {
|
||||||
|
if (Object.hasOwnProperty.call(element, key)) {
|
||||||
|
if (hidden.includes(key)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const value = element[key]
|
||||||
|
let td = document.createElement("td")
|
||||||
|
td.innerHTML = value
|
||||||
|
tr.appendChild(td)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
table.appendChild(tr)
|
||||||
|
})
|
||||||
|
|
||||||
|
return table
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateString(date, format) {
|
||||||
|
let obj = formatDateObject(date)
|
||||||
|
format = format.replaceAll("Y", obj.year)
|
||||||
|
format = format.replaceAll("M", obj.month)
|
||||||
|
format = format.replaceAll("D", obj.day)
|
||||||
|
format = format.replaceAll("h", obj.hour)
|
||||||
|
format = format.replaceAll("m", obj.minute)
|
||||||
|
format = format.replaceAll("s", obj.second)
|
||||||
|
return format
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateObject(date) {
|
||||||
|
let year = date.getFullYear()
|
||||||
|
let month = (date.getMonth() + 1).toString().padStart(2, "0")
|
||||||
|
let day = date.getDate().toString().padStart(2, "0")
|
||||||
|
|
||||||
|
let hour = date.getHours().toString().padStart(2, "0")
|
||||||
|
let minute = date.getMinutes().toString().padStart(2, "0")
|
||||||
|
let second = date.getSeconds().toString().padStart(2, "0")
|
||||||
|
|
||||||
|
return { year, month, day, hour, minute, second }
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h3>日期计算</h3>
|
||||||
|
|
||||||
|
<label for="startDate">起始日期:</label>
|
||||||
|
<input type="date" id="startDate">
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<label for="days">天数:</label>
|
||||||
|
<input type="number" id="days" value="0">
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<label for="endDate">结束日期:</label>
|
||||||
|
<input type="date" id="endDate" readonly>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<input type="checkbox" id="includeToday" checked>
|
||||||
|
<label for="includeToday">包含当日</label>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<button id="calculate">计算</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="container"></div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<p style="text-align: center;">
|
||||||
|
<a href="https://beian.miit.gov.cn" target="_blank">赣ICP备2025067425号</a>
|
||||||
|
</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user