设备维修功能完成

This commit is contained in:
liub
2025-09-03 14:16:47 +08:00
parent 1eeb8e7f7c
commit f3c5e1924b
6 changed files with 1256 additions and 64 deletions

46
src/utils/common.ts Normal file
View File

@ -0,0 +1,46 @@
function DateFormat(date, format) {
if (!date) {
date = new Date();
}
if (!format) {
format = 'yyyy-MM-dd HH:mm:ss';
}
// 处理参数默认值
if (typeof date === 'string' || typeof date === 'number') {
date = new Date(date);
}
date = date instanceof Date ? date : new Date();
format = format || 'yyyy-MM-dd';
// 检查日期是否有效
if (isNaN(date.getTime())) {
return 'Invalid Date';
}
// 定义格式化映射
const formatMap = {
'yyyy': date.getFullYear(),
'MM': String(date.getMonth() + 1).padStart(2, '0'),
'dd': String(date.getDate()).padStart(2, '0'),
'HH': String(date.getHours()).padStart(2, '0'),
'mm': String(date.getMinutes()).padStart(2, '0'),
'ss': String(date.getSeconds()).padStart(2, '0'),
'SSS': String(date.getMilliseconds()).padStart(3, '0'),
'M': date.getMonth() + 1,
'd': date.getDate(),
'H': date.getHours(),
'm': date.getMinutes(),
's': date.getSeconds(),
'S': date.getMilliseconds()
};
// 替换格式字符串中的占位符
return format.replace(/(yyyy|MM|dd|HH|mm|ss|SSS|M|d|H|m|s|S)/g, (match) => {
return formatMap[match];
});
}
export default{
DateFormat:DateFormat
}

View File

@ -34,6 +34,7 @@ const service = axios.create({
// 请求拦截器
service.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
// 对应国际化资源文件后缀
config.headers['Content-Language'] = getLanguage();