修复: TaskResponse补remark字段 + 记录按时间降序取最新一条(latestRecord)
This commit is contained in:
@ -123,6 +123,7 @@ class TaskResponse(BaseModel):
|
|||||||
status: str
|
status: str
|
||||||
notify_parent_on_complete: bool
|
notify_parent_on_complete: bool
|
||||||
is_rework: bool = False
|
is_rework: bool = False
|
||||||
|
remark: str | None = None
|
||||||
reject_reason: str | None = None
|
reject_reason: str | None = None
|
||||||
received_at: datetime | None = None
|
received_at: datetime | None = None
|
||||||
completed_at: datetime | None = None
|
completed_at: datetime | None = None
|
||||||
|
|||||||
@ -51,23 +51,23 @@
|
|||||||
<text class="records-bar-arrow">›</text>
|
<text class="records-bar-arrow">›</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 最新一条预览 -->
|
<!-- 最新一条预览 -->
|
||||||
<view class="record-item">
|
<view v-if="latestRecord" class="record-item">
|
||||||
<view class="record-top">
|
<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">
|
<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="$emit('editRecord', { task, record: latestRecord })">✏️</text>
|
||||||
<text class="rec-act" @tap.stop="confirmDelete(task.records[0])">🗑️</text>
|
<text class="rec-act" @tap.stop="confirmDelete(latestRecord)">🗑️</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text v-if="task.records[0].remark" class="record-remark">{{ task.records[0].remark }}</text>
|
<text v-if="latestRecord.remark" class="record-remark">{{ latestRecord.remark }}</text>
|
||||||
<view v-if="task.records[0].images && task.records[0].images.length" class="record-images">
|
<view v-if="latestRecord.images && latestRecord.images.length" class="record-images">
|
||||||
<image
|
<image
|
||||||
v-for="(img, i) in task.records[0].images"
|
v-for="(img, i) in latestRecord.images"
|
||||||
:key="i"
|
:key="i"
|
||||||
:src="imageUrl(img)"
|
:src="imageUrl(img)"
|
||||||
class="record-thumb"
|
class="record-thumb"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
@tap.stop="previewImage(task.records[0].images, i)"
|
@tap.stop="previewImage(latestRecord.images, i)"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -89,13 +89,17 @@ export default {
|
|||||||
emits: ["action", "editRecord", "viewRecords"],
|
emits: ["action", "editRecord", "viewRecords"],
|
||||||
computed: {
|
computed: {
|
||||||
canEditRecord() {
|
canEditRecord() {
|
||||||
// 双重宽松匹配:assignee_id 可能是数字ID或用户名字符串
|
|
||||||
if (this.task.assignee_id == this.currentUserId) return true;
|
if (this.task.assignee_id == this.currentUserId) return true;
|
||||||
if (this.task.assignee_id == this.currentUsername) 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.id == this.task.assignee_id) return true;
|
||||||
if (this.currentUser && this.currentUser.username == this.task.assignee_id) return true;
|
if (this.currentUser && this.currentUser.username == this.task.assignee_id) return true;
|
||||||
return false;
|
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: {
|
methods: {
|
||||||
imageUrl(url) {
|
imageUrl(url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user