管理日志时区筛选

This commit is contained in:
unknown 2023-07-30 16:58:44 +08:00
parent 5ca6c18513
commit 8e5c072634
2 changed files with 15 additions and 3 deletions

View File

@ -3,7 +3,7 @@ import { Table, Typography, Input, Button, DatePicker } from "antd";
import { adminLog } from "../../../api"; import { adminLog } from "../../../api";
// import styles from "./index.module.less"; // import styles from "./index.module.less";
import type { ColumnsType } from "antd/es/table"; import type { ColumnsType } from "antd/es/table";
import { dateWholeFormat } from "../../../utils/index"; import { dateWholeFormat, transUtcTime } from "../../../utils/index";
import { AdminLogDetailDialog } from "./compenents/detail-dialog"; import { AdminLogDetailDialog } from "./compenents/detail-dialog";
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
import moment from "moment"; import moment from "moment";
@ -176,8 +176,10 @@ const SystemLogPage = () => {
value={createdAts} value={createdAts}
style={{ marginLeft: 10 }} style={{ marginLeft: 10 }}
onChange={(date, dateString) => { onChange={(date, dateString) => {
dateString[0] += "T00:00:00.000+00:00"; let date1 = dateString[0] + " 00:00:00";
dateString[1] += "T23:59:59.000+00:00"; let date2 = dateString[1] + " 23:59:59";
dateString[0] = transUtcTime(date1);
dateString[1] = transUtcTime(date2);
setCreatedAt(dateString); setCreatedAt(dateString);
setCreatedAts(date); setCreatedAts(date);
}} }}

View File

@ -140,3 +140,13 @@ export function dateWholeFormat(dateStr: string) {
} }
return moment(dateStr).format("YYYY-MM-DD HH:mm:ss"); return moment(dateStr).format("YYYY-MM-DD HH:mm:ss");
} }
export function transUtcTime(value: string) {
const specifiedTime = value;
// 创建一个新的Date对象传入指定时间
const specifiedDate = new Date(specifiedTime);
//将指定时间转换为UTC+0时间
const utcTime = specifiedDate.toISOString();
return utcTime;
}