feat(M09-B): 完成清洁规则与照片验收闭环
This commit is contained in:
@@ -62,9 +62,14 @@ Page({
|
||||
const taskId = event.currentTarget.dataset.taskId
|
||||
if (!taskId) return
|
||||
try {
|
||||
const result = await wxChooseMedia(9)
|
||||
const current = this.data.selectedPhotosByTask[taskId] || []
|
||||
const next = current.concat(result.tempFiles.map((item) => item.tempFilePath)).slice(0, 9)
|
||||
const maxPhotos = Math.max(1, Math.min(9, Number(event.currentTarget.dataset.maxPhotos || 9)))
|
||||
if (current.length >= maxPhotos) {
|
||||
this.setData({ errorMessage: `当前任务最多上传 ${maxPhotos} 张照片` })
|
||||
return
|
||||
}
|
||||
const result = await wxChooseMedia(maxPhotos - current.length)
|
||||
const next = current.concat(result.tempFiles.map((item) => item.tempFilePath)).slice(0, maxPhotos)
|
||||
this.setData({ [`selectedPhotosByTask.${taskId}`]: next })
|
||||
} catch (error) {
|
||||
this.setData({ errorMessage: error.message || '选择照片失败' })
|
||||
@@ -74,8 +79,10 @@ Page({
|
||||
async submitTask(event) {
|
||||
const taskId = event.currentTarget.dataset.taskId
|
||||
const localPhotos = this.data.selectedPhotosByTask[taskId] || []
|
||||
if (localPhotos.length === 0) {
|
||||
this.setData({ errorMessage: '请先上传至少一张保洁照片' })
|
||||
const task = this.data.myTasks.find((item) => item.id === taskId)
|
||||
const minPhotos = Number(task?.minPhotoCount ?? 1)
|
||||
if (localPhotos.length < minPhotos) {
|
||||
this.setData({ errorMessage: `请先选择至少 ${minPhotos} 张保洁照片` })
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true, errorMessage: '' })
|
||||
@@ -125,7 +132,10 @@ function formatTask(task) {
|
||||
canStart: task.status === 'CLAIMED',
|
||||
canSubmit: task.status === 'STARTED',
|
||||
canRework: task.status === 'REJECTED',
|
||||
canUpload: task.status === 'STARTED' || task.status === 'REJECTED',
|
||||
canUpload: task.status === 'STARTED',
|
||||
photoRuleText: task.photoRequired
|
||||
? `至少 ${task.minPhotoCount} 张,最多 ${task.maxPhotoCount} 张`
|
||||
: `照片可选,最多 ${task.maxPhotoCount} 张`,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,8 @@
|
||||
<button wx:if="{{item.canStart}}" data-task-id="{{item.id}}" bindtap="startTask">开始</button>
|
||||
<button wx:if="{{item.canRework}}" data-task-id="{{item.id}}" bindtap="reworkTask">重做</button>
|
||||
<view wx:if="{{item.canUpload}}" class="submit-box">
|
||||
<button data-task-id="{{item.id}}" bindtap="choosePhotos">选择照片</button>
|
||||
<view class="muted">至少 1 张,最多 9 张</view>
|
||||
<button data-task-id="{{item.id}}" data-max-photos="{{item.maxPhotoCount}}" bindtap="choosePhotos">选择照片</button>
|
||||
<view class="muted">{{item.photoRuleText}}</view>
|
||||
<button data-task-id="{{item.id}}" bindtap="submitTask">提交验收</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user