+ 干燥失重保存时将记录保存的时间,并显示在批号的选择菜单中

+ 干燥失重对批号的菜单项目进行排序(按批号)
This commit is contained in:
2022-08-08 01:24:18 +08:00
parent 91601add92
commit cfe47f6633

View File

@@ -129,6 +129,7 @@
let m3r = input_m3r.value; let m3r = input_m3r.value;
let lod = { let lod = {
"time": Date.now(),
"m0l": m0l, "m0l": m0l,
"m1l": m1l, "m1l": m1l,
"m3l": m3l, "m3l": m3l,
@@ -183,9 +184,13 @@
for (let i = 0; i < localStorage.length; i++) { for (let i = 0; i < localStorage.length; i++) {
keys.push(localStorage.key(i)); keys.push(localStorage.key(i));
} }
keys.sort();
keys.forEach(key => { keys.forEach(key => {
let timestamp = JSON.parse(localStorage.getItem(key)).time;
let time = new Date(timestamp).format("yyyy-MM-dd hh:mm");
let option = document.createElement("option"); let option = document.createElement("option");
option.innerText = key; $(option).attr("value", key);
$(option).attr("label", `保存于 ${time}`);
$("#keys").append(option); $("#keys").append(option);
}); });
} }
@@ -247,6 +252,28 @@
return m0 == '' || m1 == '' || m3 == ''; return m0 == '' || m1 == '' || m3 == '';
} }
// 为 Date 创建日期格式化方法
Date.prototype.format = function (fmt) {
var 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 (var 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> </script>
</head> </head>