修复: TaskResponse补remark字段 + 记录按时间降序取最新一条(latestRecord)

This commit is contained in:
2026-08-05 15:37:10 +08:00
parent e5b201a040
commit f736cf0c13
2 changed files with 14 additions and 9 deletions

View File

@ -51,23 +51,23 @@
<text class="records-bar-arrow"></text>
</view>
<!-- 最新一条预览 -->
<view class="record-item">
<view v-if="latestRecord" class="record-item">
<view class="record-top">
<text class="record-time">{{ formatTime(task.records[0].created_at) }}</text>
<text class="record-time">{{ formatTime(latestRecord.created_at) }}</text>
<view v-if="canEditRecord" class="record-actions">
<text class="rec-act" @tap.stop="$emit('editRecord', { task, record: task.records[0] })"></text>
<text class="rec-act" @tap.stop="confirmDelete(task.records[0])">🗑</text>
<text class="rec-act" @tap.stop="$emit('editRecord', { task, record: latestRecord })"></text>
<text class="rec-act" @tap.stop="confirmDelete(latestRecord)">🗑</text>
</view>
</view>
<text v-if="task.records[0].remark" class="record-remark">{{ task.records[0].remark }}</text>
<view v-if="task.records[0].images && task.records[0].images.length" class="record-images">
<text v-if="latestRecord.remark" class="record-remark">{{ latestRecord.remark }}</text>
<view v-if="latestRecord.images && latestRecord.images.length" class="record-images">
<image
v-for="(img, i) in task.records[0].images"
v-for="(img, i) in latestRecord.images"
:key="i"
:src="imageUrl(img)"
class="record-thumb"
mode="aspectFill"
@tap.stop="previewImage(task.records[0].images, i)"
@tap.stop="previewImage(latestRecord.images, i)"
/>
</view>
</view>
@ -89,13 +89,17 @@ export default {
emits: ["action", "editRecord", "viewRecords"],
computed: {
canEditRecord() {
// 双重宽松匹配assignee_id 可能是数字ID或用户名字符串
if (this.task.assignee_id == this.currentUserId) return true;
if (this.task.assignee_id == this.currentUsername) return true;
if (this.currentUser && this.currentUser.id == this.task.assignee_id) return true;
if (this.currentUser && this.currentUser.username == this.task.assignee_id) return true;
return false;
},
latestRecord() {
const recs = this.task.records;
if (!recs || !recs.length) return null;
return [...recs].sort((a, b) => new Date(b.created_at) - new Date(a.created_at))[0];
},
},
methods: {
imageUrl(url) {