Compare commits
1 Commits
main
...
fix/system
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8d7f18c9f |
@ -93,6 +93,20 @@ class SystemizationTodo extends Model
|
||||
return $this->belongsTo(User::class, 'created_by')->withTrashed();
|
||||
}
|
||||
|
||||
public function creationTimeLabel(): string
|
||||
{
|
||||
if ($this->created_at === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$timezone = (string) config('app.platform_timezone', config('app.timezone', 'Asia/Shanghai'));
|
||||
if ($timezone === '') {
|
||||
$timezone = 'Asia/Shanghai';
|
||||
}
|
||||
|
||||
return $this->created_at->copy()->setTimezone($timezone)->format('Y-m-d H:i');
|
||||
}
|
||||
|
||||
public function attachments(): HasMany
|
||||
{
|
||||
return $this->hasMany(SystemizationTodoAttachment::class, 'systemization_todo_id')
|
||||
|
||||
@ -767,7 +767,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td class="sys-todo-table__immutable" title="创建后不可修改" data-sys-todo-immutable="created_by">{{ $item->creator?->name ?: '—' }}</td>
|
||||
<td class="sys-todo-table__immutable sys-todo-table__immutable-time" title="创建后不可修改" data-sys-todo-immutable="created_at">{{ $item->created_at?->format('Y-m-d H:i') ?: '—' }}</td>
|
||||
<td class="sys-todo-table__immutable sys-todo-table__immutable-time" title="创建后不可修改" data-sys-todo-immutable="created_at">{{ $item->creationTimeLabel() ?: '—' }}</td>
|
||||
@php($ownerNames = $personNames($item->owner_display ?? null))
|
||||
<td class="sys-todo-table__people">
|
||||
<span class="sys-todo-grid-value"
|
||||
|
||||
@ -1361,7 +1361,7 @@ class SystemizationTodosTest extends FeatureTestCase
|
||||
|
||||
$creatorId = (int) $todo->created_by;
|
||||
$createdAt = $todo->created_at->format('Y-m-d H:i:s');
|
||||
$displayedCreatedAt = $todo->created_at->format('Y-m-d H:i');
|
||||
$displayedCreatedAt = $todo->creationTimeLabel();
|
||||
|
||||
$this->get(route('business.pages.show', [
|
||||
'section' => 'other',
|
||||
@ -1402,6 +1402,43 @@ class SystemizationTodosTest extends FeatureTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function test_creation_time_is_displayed_in_the_platform_timezone(): void
|
||||
{
|
||||
$originalTimezone = config('app.timezone');
|
||||
$originalPlatformTimezone = config('app.platform_timezone');
|
||||
|
||||
try {
|
||||
config([
|
||||
'app.timezone' => 'Europe/London',
|
||||
'app.platform_timezone' => 'Asia/Shanghai',
|
||||
]);
|
||||
date_default_timezone_set('Europe/London');
|
||||
Carbon::setTestNow('2026-11-10 08:21:30');
|
||||
|
||||
$this->loginAs();
|
||||
$todo = $this->createTodo('收入', '创建时间测试', '创建时间按上海展示', '2026-11-12', 1);
|
||||
$todo->refresh();
|
||||
|
||||
$this->assertSame('2026-11-10 08:21', $todo->created_at->format('Y-m-d H:i'));
|
||||
$this->assertSame('2026-11-10 16:21', $todo->creationTimeLabel());
|
||||
|
||||
$this->get(route('business.pages.show', [
|
||||
'section' => 'other',
|
||||
'page' => 'systemization-todos',
|
||||
]))->assertOk()->assertSee(
|
||||
'data-sys-todo-immutable="created_at">2026-11-10 16:21</td>',
|
||||
false,
|
||||
);
|
||||
} finally {
|
||||
Carbon::setTestNow();
|
||||
config([
|
||||
'app.timezone' => $originalTimezone,
|
||||
'app.platform_timezone' => $originalPlatformTimezone,
|
||||
]);
|
||||
date_default_timezone_set((string) $originalTimezone);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_edit_redirect_keeps_current_filters_and_highlight(): void
|
||||
{
|
||||
$this->loginAs();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user