+ 将标品信息和设备信息合并为效期查询
This commit is contained in:
@@ -1,142 +0,0 @@
|
||||
<!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">
|
||||
<style>
|
||||
.expir30 {
|
||||
color: darkorange;
|
||||
}
|
||||
|
||||
.expir7 {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.expired {
|
||||
color: red;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.pure-table {
|
||||
width: 100%;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.pure-table caption {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="../statics/modules/jquery.min.js"></script>
|
||||
<script src="./common-standards.info.js"></script>
|
||||
<script type="module">
|
||||
$(() => {
|
||||
createTable(info)
|
||||
|
||||
$("#search").click(() => {
|
||||
let keyword = $("#keyword").val()
|
||||
if (keyword.trim() == "") {
|
||||
createTable(info)
|
||||
return
|
||||
}
|
||||
|
||||
let temp = []
|
||||
info.filter(value => {
|
||||
if (value.batch.toLowerCase().includes(keyword.toLowerCase())) {
|
||||
temp.push(value)
|
||||
}
|
||||
})
|
||||
|
||||
createTable(temp)
|
||||
})
|
||||
})
|
||||
|
||||
function createTable(data) {
|
||||
let content = document.getElementById("content")
|
||||
content.innerHTML = ""
|
||||
let table = document.createElement("table")
|
||||
table.setAttribute("class", "pure-table")
|
||||
|
||||
// 添加
|
||||
let caption = document.createElement("caption")
|
||||
caption.innerText = `共找到 ${data.length} 条记录`
|
||||
table.appendChild(caption)
|
||||
|
||||
// 添加表头
|
||||
let tr = document.createElement("tr")
|
||||
let th_batch = document.createElement("th")
|
||||
let th_expir = document.createElement("th")
|
||||
let th_contont = document.createElement("th")
|
||||
th_batch.innerText = "批号"
|
||||
th_expir.innerText = "有效期至"
|
||||
th_contont.innerText = "含量丨纯度"
|
||||
tr.appendChild(th_batch)
|
||||
tr.appendChild(th_expir)
|
||||
tr.appendChild(th_contont)
|
||||
table.appendChild(tr)
|
||||
|
||||
// 向表格添加内容
|
||||
data.forEach((value) => {
|
||||
let tr = document.createElement("tr")
|
||||
let td_batch = document.createElement("td")
|
||||
let td_expir = document.createElement("td")
|
||||
let td_content = document.createElement("td")
|
||||
|
||||
td_batch.innerHTML = value.batch
|
||||
td_expir.innerHTML = expir(value.expir)
|
||||
td_content.innerHTML = value.content
|
||||
|
||||
tr.appendChild(td_batch)
|
||||
tr.appendChild(td_expir)
|
||||
tr.appendChild(td_content)
|
||||
table.appendChild(tr)
|
||||
})
|
||||
|
||||
content.appendChild(table)
|
||||
}
|
||||
|
||||
function expir(value) {
|
||||
let date = new Date()
|
||||
let array = value.split(".")
|
||||
date.setFullYear(array[0], array[1] - 1, array[2])
|
||||
|
||||
let day = (date - Date.now()) / 86400000
|
||||
|
||||
if (day <= 0) {
|
||||
return `<span class='expired'>${value}</span>`
|
||||
}
|
||||
|
||||
if (day <= 7) {
|
||||
return `<span class='expir7'>${value}</span>`
|
||||
}
|
||||
|
||||
if (day <= 30) {
|
||||
return `<span class='expir30'>${value}</span>`
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="width: 100%; white-space: nowrap;">
|
||||
<input style="width: 80%;" type="text" id="keyword" placeholder="输入批号进行搜索(忽略大小写)">
|
||||
<button style="width: 15%;" id="search" type="submit">搜索</button>
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
<p>
|
||||
过期提醒:<br>
|
||||
<span class="expir30">黄色表示有效期剩余30天</span><br>
|
||||
<span class="expir7">红色表示有效期剩余7天</span><br>
|
||||
<span class="expired">红色加删除线表示已过期</span><br>
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,144 +0,0 @@
|
||||
let info = [
|
||||
// L014 系列
|
||||
{
|
||||
"kind": "L014-1",
|
||||
"batch": "S014-1-21029069",
|
||||
"expir": "2023.05.16",
|
||||
"content": "99.5%"
|
||||
},
|
||||
{
|
||||
"kind": "L014-1",
|
||||
"batch": "S014-1(Dimer)-21029079",
|
||||
"expir": "2027.03.24",
|
||||
"content": "96.9%"
|
||||
},
|
||||
{
|
||||
"kind": "L014-1",
|
||||
"batch": "2-乙酰噻吩<br>M01-051-190201",
|
||||
"expir": "2024.02.12",
|
||||
"content": "99.7%"
|
||||
},
|
||||
// L018 系列
|
||||
{
|
||||
"kind": "L018-1",
|
||||
"batch": "S018-1-21037023",
|
||||
"expir": "2023.05.18",
|
||||
"content": "99.4%"
|
||||
},
|
||||
{
|
||||
"kind": "L018-4",
|
||||
"batch": "S018-2-21029065",
|
||||
"expir": "2026.11.04",
|
||||
"content": "99.9%"
|
||||
},
|
||||
{
|
||||
"kind": "L018-4",
|
||||
"batch": "S018-3-21037001",
|
||||
"expir": "2026.11.04",
|
||||
"content": "99.1%"
|
||||
},
|
||||
{
|
||||
"kind": "L018-4",
|
||||
"batch": "L018-4-211101",
|
||||
"expir": "2023.05.06",
|
||||
"content": "99.8%"
|
||||
},
|
||||
{
|
||||
"kind": "L018-5",
|
||||
"batch": "L018-5S-210801",
|
||||
"expir": "2026.08.16",
|
||||
"content": "99.6%"
|
||||
},
|
||||
{
|
||||
"kind": "L018-5",
|
||||
"batch": "L018-5(TP6)-220901",
|
||||
"expir": "2027.08.31",
|
||||
"content": "100.0%"
|
||||
},
|
||||
{
|
||||
"kind": "L018-6",
|
||||
"batch": "L018-6-210101",
|
||||
"expir": "2026.01.01",
|
||||
"content": "100.0%"
|
||||
},
|
||||
{
|
||||
"kind": "L018-6",
|
||||
"batch": "L018-6S-2021017081",
|
||||
"expir": "2026.08.20",
|
||||
"content": "99.8%"
|
||||
},
|
||||
|
||||
// L414 系列
|
||||
{
|
||||
"kind": "L414-1",
|
||||
"batch": "L414-1-20220051-11",
|
||||
"expir": "2024.03.27",
|
||||
"content": "99.47%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-1",
|
||||
"batch": "联苯甲酸<br>LL2105003",
|
||||
"expir": "2025.12.24",
|
||||
"content": "99.17%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-1",
|
||||
"batch": "4-氯苯甲醛<br>LL2112512",
|
||||
"expir": "2025.09.16",
|
||||
"content": "99.00%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-5KR",
|
||||
"batch": "S414-3-2021002055",
|
||||
"expir": "2026.07.06",
|
||||
"content": "99.5%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-5KR",
|
||||
"batch": "S414-4KR-20220253-41",
|
||||
"expir": "2027.02.27",
|
||||
"content": "99.2%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-5KR",
|
||||
"batch": "L414-5S-18600061",
|
||||
"expir": "2023.08.31",
|
||||
"content": "99.4%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-5KR",
|
||||
"batch": "L414-5-191201",
|
||||
"expir": "2023.12.17",
|
||||
"content": "99.5%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-5KR",
|
||||
"batch": "L414-5IM-21043055",
|
||||
"expir": "2026.05.09",
|
||||
"content": "99.7%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-801KR",
|
||||
"batch": "L414-801KR-210708",
|
||||
"expir": "2023.07.08",
|
||||
"content": "99.8%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-801KR",
|
||||
"batch": "S414-801-2021020097",
|
||||
"expir": "2026.09.09",
|
||||
"content": "99.83%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-801KR",
|
||||
"batch": "三苯基氧膦<br>H1915109",
|
||||
"expir": "2024.08.22",
|
||||
"content": "98.3%"
|
||||
},
|
||||
{
|
||||
"kind": "L414-801KR",
|
||||
"batch": "TEMPO<br>M02-108-210601",
|
||||
"expir": "2023.05.15",
|
||||
"content": "99.6%"
|
||||
},
|
||||
]
|
||||
@@ -1,151 +0,0 @@
|
||||
<!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">
|
||||
<style>
|
||||
.expir30 {
|
||||
color: darkorange;
|
||||
}
|
||||
|
||||
.expir7 {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.expired {
|
||||
color: red;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.pure-table {
|
||||
width: 100%;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.pure-table caption {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="../statics/modules/jquery.min.js"></script>
|
||||
<script src="./equipment.info.js"></script>
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
createTable(info)
|
||||
|
||||
$("#search").click(() => {
|
||||
let keyword = $("#keyword").val()
|
||||
if (keyword == "") {
|
||||
createTable(info)
|
||||
return
|
||||
}
|
||||
let temp = []
|
||||
info.filter(value => {
|
||||
if (value.id.toLowerCase().includes(keyword.toLowerCase()) ||
|
||||
value.name.includes(keyword) ||
|
||||
value.where.includes(keyword) ||
|
||||
value.expir.includes(keyword)) {
|
||||
temp.push(value)
|
||||
}
|
||||
})
|
||||
|
||||
createTable(temp)
|
||||
})
|
||||
})
|
||||
|
||||
// 根据data创建表格
|
||||
function createTable(data) {
|
||||
let content = document.getElementById("content")
|
||||
content.innerHTML = ""
|
||||
let table = document.createElement("table")
|
||||
table.setAttribute("class", "pure-table")
|
||||
|
||||
let caption = document.createElement("caption")
|
||||
caption.innerText = `共找到 ${data.length} 条记录`
|
||||
table.appendChild(caption)
|
||||
|
||||
// add header
|
||||
let tr = document.createElement("tr")
|
||||
let th_where = document.createElement("th")
|
||||
let th_name = document.createElement("th")
|
||||
let th_id = document.createElement("th")
|
||||
let th_expir = document.createElement("th")
|
||||
|
||||
th_where.innerText = "位置"
|
||||
th_name.innerText = "名称"
|
||||
th_id.innerText = "编号"
|
||||
th_expir.innerText = "有效期至"
|
||||
tr.appendChild(th_where)
|
||||
tr.appendChild(th_name)
|
||||
tr.appendChild(th_id)
|
||||
tr.appendChild(th_expir)
|
||||
table.appendChild(tr)
|
||||
|
||||
// add contents
|
||||
data.forEach((value) => {
|
||||
let tr = document.createElement("tr")
|
||||
let td_where = document.createElement("td")
|
||||
let td_name = document.createElement("td")
|
||||
let td_id = document.createElement("td")
|
||||
let td_expir = document.createElement("td")
|
||||
|
||||
td_where.innerText = value.where
|
||||
td_name.innerText = value.name
|
||||
td_id.innerText = value.id
|
||||
td_expir.innerHTML = expir(value.expir)
|
||||
|
||||
tr.appendChild(td_where)
|
||||
tr.appendChild(td_name)
|
||||
tr.appendChild(td_id)
|
||||
tr.appendChild(td_expir)
|
||||
table.appendChild(tr)
|
||||
})
|
||||
|
||||
content.appendChild(table)
|
||||
}
|
||||
|
||||
// 设置日期样式
|
||||
function expir(value) {
|
||||
let date = new Date()
|
||||
let array = value.split(".")
|
||||
date.setFullYear(array[0], array[1] - 1, array[2])
|
||||
|
||||
let day = (date - Date.now()) / 86400000
|
||||
|
||||
if (day <= 0) {
|
||||
return `<span class='expired'>${value}</span>`
|
||||
}
|
||||
|
||||
if (day <= 7) {
|
||||
return `<span class='expir7'>${value}</span>`
|
||||
}
|
||||
|
||||
if (day <= 30) {
|
||||
return `<span class='expir30'>${value}</span>`
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="width: 100%; white-space: nowrap;">
|
||||
<input style="width: 80%;" type="text" id="keyword" placeholder="输入查询关键字(忽略大小写)">
|
||||
<button style="width: 15%;" id="search" type="submit">搜索</button>
|
||||
</div>
|
||||
<div id="content"></div>
|
||||
<p>
|
||||
过期提醒:<br>
|
||||
<span class="expir30">黄色表示有效期剩余30天</span><br>
|
||||
<span class="expir7">红色表示有效期剩余7天</span><br>
|
||||
<span class="expired">红色加删除线表示已过期</span><br>
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,377 +0,0 @@
|
||||
let info = [
|
||||
// 天平室
|
||||
{
|
||||
"where": "天平室",
|
||||
"name": "天平",
|
||||
"id": "CAQ-14-011",
|
||||
"expir": "2023.04.17"
|
||||
},
|
||||
{
|
||||
"where": "天平室",
|
||||
"name": "天平",
|
||||
"id": "CAQ-14-012",
|
||||
"expir": "2023.12.06"
|
||||
},
|
||||
{
|
||||
"where": "天平室",
|
||||
"name": "天平",
|
||||
"id": "CAQ-14-014",
|
||||
"expir": "2023.07.10"
|
||||
},
|
||||
{
|
||||
"where": "天平室",
|
||||
"name": "天平",
|
||||
"id": "CAQ-14-015",
|
||||
"expir": "2023.07.10"
|
||||
},
|
||||
{
|
||||
"where": "分样间",
|
||||
"name": "天平",
|
||||
"id": "CAQ-14-009",
|
||||
"expir": "2023.12.06"
|
||||
},
|
||||
|
||||
// 水分室
|
||||
{
|
||||
"where": "水分室",
|
||||
"name": "水分仪",
|
||||
"id": "CAS-14-005",
|
||||
"expir": "2023.12.06"
|
||||
},
|
||||
{
|
||||
"where": "水分室",
|
||||
"name": "快干水分仪",
|
||||
"id": "CAS-14-006",
|
||||
"expir": "2024.01.08"
|
||||
},
|
||||
{
|
||||
"where": "水分室",
|
||||
"name": "水分仪",
|
||||
"id": "CAS-14-007",
|
||||
"expir": "2023.06.13"
|
||||
},
|
||||
{
|
||||
"where": "水分室",
|
||||
"name": "水分仪",
|
||||
"id": "CAS-14-008",
|
||||
"expir": "2023.07.10"
|
||||
},
|
||||
|
||||
// 高温室
|
||||
{
|
||||
"where": "高温室",
|
||||
"name": "鼓风干燥箱",
|
||||
"id": "CBA-14-001",
|
||||
"expir": "2023.12.11"
|
||||
},
|
||||
{
|
||||
"where": "高温室",
|
||||
"name": "马弗炉",
|
||||
"id": "CBB-14-001",
|
||||
"expir": "2023.12.11"
|
||||
},
|
||||
{
|
||||
"where": "高温室",
|
||||
"name": "马弗炉",
|
||||
"id": "CBB-14-002",
|
||||
"expir": "2023.06.13"
|
||||
},
|
||||
{
|
||||
"where": "高温室",
|
||||
"name": "真空干燥箱",
|
||||
"id": "CBC-14-001",
|
||||
"expir": "2023.12.11"
|
||||
},
|
||||
{
|
||||
"where": "高温室",
|
||||
"name": "真空干燥箱",
|
||||
"id": "CBC-14-002",
|
||||
"expir": "2023.06.13"
|
||||
},
|
||||
{
|
||||
"where": "高温室",
|
||||
"name": "真空干燥箱",
|
||||
"id": "CBC-14-003",
|
||||
"expir": "2023.04.17"
|
||||
},
|
||||
|
||||
// 液相室一
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-006",
|
||||
"expir": "2024.02.14"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-009",
|
||||
"expir": "2024.06.13"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-012",
|
||||
"expir": "2024.06.13"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-013",
|
||||
"expir": "2024.06.13"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-014",
|
||||
"expir": "2024.06.13"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-015",
|
||||
"expir": "2024.06.13"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-016",
|
||||
"expir": "2024.12.11"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-017",
|
||||
"expir": "2024.12.11"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-018",
|
||||
"expir": "2023.07.01"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-023",
|
||||
"expir": "2024.06.13"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-024",
|
||||
"expir": "2024.06.13"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-025",
|
||||
"expir": "2023.07.01"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-034",
|
||||
"expir": "2024.09.21"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-035",
|
||||
"expir": "2024.09.21"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-036",
|
||||
"expir": "2024.09.21"
|
||||
},
|
||||
{
|
||||
"where": "液相室一",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-037",
|
||||
"expir": "2024.09.21"
|
||||
},
|
||||
|
||||
// 液相室二
|
||||
{
|
||||
"where": "液相室二",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-026",
|
||||
"expir": "2024.07.24"
|
||||
},
|
||||
{
|
||||
"where": "液相室二",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-027",
|
||||
"expir": "2024.07.24"
|
||||
},
|
||||
{
|
||||
"where": "液相室二",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-028",
|
||||
"expir": "2024.07.24"
|
||||
},
|
||||
{
|
||||
"where": "液相室二",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-029",
|
||||
"expir": "2024.07.24"
|
||||
},
|
||||
{
|
||||
"where": "液相室二",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-030",
|
||||
"expir": "2023.12.02"
|
||||
},
|
||||
{
|
||||
"where": "液相室二",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-031",
|
||||
"expir": "2023.12.05"
|
||||
},
|
||||
{
|
||||
"where": "液相室二",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-032",
|
||||
"expir": "2023.12.01"
|
||||
},
|
||||
{
|
||||
"where": "液相室二",
|
||||
"name": "液相色谱仪",
|
||||
"id": "CAA-14-033",
|
||||
"expir": "2023.12.01"
|
||||
},
|
||||
|
||||
// 气相室
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-001",
|
||||
"expir": "2024.02.14"
|
||||
},
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-002",
|
||||
"expir": "2024.12.11"
|
||||
},
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-004",
|
||||
"expir": "2024.12.11"
|
||||
},
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-007",
|
||||
"expir": "2024.06.13"
|
||||
},
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-008",
|
||||
"expir": "2023.06.30"
|
||||
},
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-009",
|
||||
"expir": "2023.12.01"
|
||||
},
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-010",
|
||||
"expir": "2023.12.01"
|
||||
},
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-011",
|
||||
"expir": "2023.12.01"
|
||||
},
|
||||
{
|
||||
"where": "气相室",
|
||||
"name": "气相色谱仪",
|
||||
"id": "CAB-14-012",
|
||||
"expir": "2024.09.22"
|
||||
},
|
||||
|
||||
// 综合仪器室二
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "质谱仪",
|
||||
"id": "DLZ-14-001",
|
||||
"expir": "2023.10.30"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "粒度仪",
|
||||
"id": "CAV-14-001",
|
||||
"expir": "2023.07.24"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "旋光仪",
|
||||
"id": "CAI-14-002",
|
||||
"expir": "2023.12.06"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "电导率仪",
|
||||
"id": "CAH-14-001",
|
||||
"expir": "2023.12.06"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "电导率仪",
|
||||
"id": "CAH-14-002",
|
||||
"expir": "2023.07.10"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "熔点仪",
|
||||
"id": "CAJ-14-002",
|
||||
"expir": "2023.12.11"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "pH 计",
|
||||
"id": "CAD-14-001",
|
||||
"expir": "2023.12.06"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "pH 计",
|
||||
"id": "CAD-14-003",
|
||||
"expir": "2023.10.27"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "红外光谱仪",
|
||||
"id": "CAP-14-002",
|
||||
"expir": "2023.06.13"
|
||||
},
|
||||
{
|
||||
"where": "仪器室二",
|
||||
"name": "衍射仪",
|
||||
"id": "XRD-14-001",
|
||||
"expir": "2024.07.31"
|
||||
},
|
||||
|
||||
// 综合仪器室三
|
||||
{
|
||||
"where": "仪器室三",
|
||||
"name": "电位滴定仪",
|
||||
"id": "DDY-14-002",
|
||||
"expir": "2023.06.13"
|
||||
},
|
||||
{
|
||||
"where": "仪器室三",
|
||||
"name": "紫外光度计",
|
||||
"id": "CAF-14-005",
|
||||
"expir": "2023.07.10"
|
||||
}
|
||||
];
|
||||
203
views/expir-info.html
Normal file
203
views/expir-info.html
Normal file
@@ -0,0 +1,203 @@
|
||||
<!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">
|
||||
<style>
|
||||
.searchbox {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#keyword {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
#search {
|
||||
width: 15%;
|
||||
}
|
||||
|
||||
.pure-table {
|
||||
width: 100%;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.pure-table caption {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.expir30 {
|
||||
color: orange;
|
||||
|
||||
}
|
||||
|
||||
.expir7 {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.expired {
|
||||
color: red;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="../statics/modules/jquery.min.js"></script>
|
||||
<script>
|
||||
// 可用于查询的数据
|
||||
const databases = [
|
||||
{
|
||||
"name": "device",
|
||||
"path": "../statics/info/device.json"
|
||||
},
|
||||
{
|
||||
"name": "standard",
|
||||
"path": "../statics/info/standard.json"
|
||||
}
|
||||
]
|
||||
|
||||
$(() => {
|
||||
let info = {}
|
||||
let count = databases.length
|
||||
let interval = setInterval(() => {
|
||||
if (count == 0) {
|
||||
$("#content").append("已加载所有数据")
|
||||
clearInterval(interval)
|
||||
}
|
||||
}, 100)
|
||||
|
||||
// 加载所有数据
|
||||
for (const database of databases) {
|
||||
$.getJSON(database.path, (data) => {
|
||||
info[database.name] = data
|
||||
count = --count
|
||||
switch (database.name) {
|
||||
case "device":
|
||||
$("#content").append(`已加载设备数据,共 ${data.length} 条<br>`)
|
||||
break
|
||||
case "standard":
|
||||
$("#content").append(`已加载对照品数据,共 ${data.length} 条<br>`)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$("#search").click(() => {
|
||||
let keyword = $("#keyword").val().toLowerCase()
|
||||
$("#content").empty()
|
||||
searchDevice(keyword)
|
||||
searchStandard(keyword)
|
||||
})
|
||||
|
||||
function searchDevice(keyword) {
|
||||
let device = info.device.filter((value) => {
|
||||
return value.id.toLowerCase().includes(keyword)
|
||||
})
|
||||
if (device.length > 0) {
|
||||
let table_device = createDeviceTable(device)
|
||||
$("#content").append(table_device)
|
||||
}
|
||||
}
|
||||
|
||||
function searchStandard(keyword) {
|
||||
let standard = info.standard.filter((value) => {
|
||||
return value.batch.toLowerCase().includes(keyword)
|
||||
})
|
||||
if (standard.length > 0) {
|
||||
let table_standard = createStandardTable(standard)
|
||||
$("#content").append(table_standard)
|
||||
}
|
||||
}
|
||||
|
||||
function createDeviceTable(data) {
|
||||
return createTable(data, `设备信息(${data.length}条)`, ["名称", "编号", "有效期至"], hidden = ["where"])
|
||||
}
|
||||
|
||||
function createStandardTable(data) {
|
||||
return createTable(data, `对照品信息(${data.length}条)`, ["批号", "有效期至", "含量丨纯度"], hidden = ["kind"])
|
||||
}
|
||||
|
||||
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 = (key == "expir") ? checkExpir(value) : value
|
||||
tr.appendChild(td)
|
||||
}
|
||||
}
|
||||
table.appendChild(tr)
|
||||
})
|
||||
|
||||
return table
|
||||
}
|
||||
|
||||
function checkExpir(value) {
|
||||
let date = new Date()
|
||||
let array = value.split(".")
|
||||
date.setFullYear(array[0], array[1] - 1, array[2])
|
||||
|
||||
let day = (date - Date.now()) / 86400000
|
||||
|
||||
if (day <= 0) {
|
||||
return `<span class='expired'>${value}</span>`
|
||||
}
|
||||
|
||||
if (day <= 7) {
|
||||
return `<span class='expir7'>${value}</span>`
|
||||
}
|
||||
|
||||
if (day <= 30) {
|
||||
return `<span class='expir30'>${value}</span>`
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="searchbox">
|
||||
<input type="text" name="keyword" id="keyword" placeholder="输入查询关键字(忽略大小写)">
|
||||
<button type="submit" id="search">搜索</button>
|
||||
</div>
|
||||
|
||||
<div id="content"></div>
|
||||
<div>
|
||||
<p>
|
||||
过期提醒:<br>
|
||||
<span class="expir30">黄色表示有效期剩余 30 天</span><br>
|
||||
<span class="expir7">红色表示有效期剩余 7 天</span><br>
|
||||
<span class="expired">红色加删除线表示已过期</span><br>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user