feat(date-picker): 添加默认时间设置以优化日期范围选择
- 在日期选择器中引入默认时间设置,开始时间为00:00:00,结束时间为23:59:59,提升用户体验 - 增加normalizeMarketingEndTime函数,确保在导出时将结束时间的00:00:00标准化为23:59:59 - 更新相关逻辑以支持新的时间处理,确保日期范围选择的准确性和灵活性
This commit is contained in:
parent
1ee2b4bd79
commit
70680061e2
|
|
@ -247,6 +247,7 @@
|
||||||
end-placeholder="结束时间"
|
end-placeholder="结束时间"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
:shortcuts="dateShortcuts"
|
:shortcuts="dateShortcuts"
|
||||||
|
:default-time="dateDefaultTime"
|
||||||
style="width:100%"
|
style="width:100%"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
|
||||||
24
web/main.js
24
web/main.js
|
|
@ -181,6 +181,12 @@ const app = createApp({
|
||||||
const exportRules = ValidationRules.createExportRules();
|
const exportRules = ValidationRules.createExportRules();
|
||||||
|
|
||||||
// ==================== 时间快捷选项 ====================
|
// ==================== 时间快捷选项 ====================
|
||||||
|
// Element Plus datetimerange 默认时间:开始 00:00:00,结束 23:59:59(仅用于 UI 默认显示)
|
||||||
|
const dateDefaultTime = [
|
||||||
|
new Date(2000, 0, 1, 0, 0, 0),
|
||||||
|
new Date(2000, 0, 1, 23, 59, 59),
|
||||||
|
];
|
||||||
|
|
||||||
const dateShortcuts = [
|
const dateShortcuts = [
|
||||||
{
|
{
|
||||||
text: '本日',
|
text: '本日',
|
||||||
|
|
@ -666,8 +672,23 @@ const app = createApp({
|
||||||
filters.type_eq = Number(typeValue);
|
filters.type_eq = Number(typeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizeMarketingEndTime = (endStr) => {
|
||||||
|
const s = String(endStr || '').trim();
|
||||||
|
if (!s) return s;
|
||||||
|
// value-format is 'YYYY-MM-DD HH:mm:ss' so we just normalize "00:00:00" to end-of-day for marketing exports
|
||||||
|
if (s.length >= 19 && s.slice(11, 19) === '00:00:00') {
|
||||||
|
return s.slice(0, 10) + ' 23:59:59';
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
};
|
||||||
|
|
||||||
if (dateRange?.length === 2) {
|
if (dateRange?.length === 2) {
|
||||||
filters.create_time_between = [dateRange[0], dateRange[1]];
|
const start = String(dateRange[0] || '').trim();
|
||||||
|
let end = String(dateRange[1] || '').trim();
|
||||||
|
if (datasource === 'marketing') {
|
||||||
|
end = normalizeMarketingEndTime(end);
|
||||||
|
}
|
||||||
|
filters.create_time_between = [start, end];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (planId) filters.plan_id_eq = Number(planId);
|
if (planId) filters.plan_id_eq = Number(planId);
|
||||||
|
|
@ -976,6 +997,7 @@ const app = createApp({
|
||||||
createRules,
|
createRules,
|
||||||
editRules,
|
editRules,
|
||||||
exportRules,
|
exportRules,
|
||||||
|
dateDefaultTime,
|
||||||
dateShortcuts,
|
dateShortcuts,
|
||||||
// 表单引用
|
// 表单引用
|
||||||
createFormRef,
|
createFormRef,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue