feat: 待完成页面按任务类型区分显示
普通任务(type 0/1/2/3/4):地点+备注+打卡时间+指引块"任务进行中"→完成任务 巡检任务(type 5):场景打卡清单(✅已打卡/❌未打卡)+进度(2/5)→开启打卡 新增:InspectScene 数据类,TaskDetail.taskInspectScenes 类型化 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
19
app/src/main/java/com/xiaoqu/watch/data/task/InspectScene.kt
Normal file
19
app/src/main/java/com/xiaoqu/watch/data/task/InspectScene.kt
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.xiaoqu.watch.data.task
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* 巡检场景数据类
|
||||
* 对应 taskInspectScenes 数组中的元素
|
||||
*/
|
||||
data class InspectScene(
|
||||
/** 场景名称 */
|
||||
@SerializedName("name") val name: String = "",
|
||||
/** 是否已打卡(1=已打卡,0=未打卡) */
|
||||
@SerializedName("isCheck") val isCheck: Int = 0,
|
||||
/** 场景状态 */
|
||||
@SerializedName("status") val status: Int = 0
|
||||
) {
|
||||
/** 是否已完成打卡 */
|
||||
val checked: Boolean get() = isCheck == 1
|
||||
}
|
||||
@@ -34,8 +34,8 @@ data class TaskDetail(
|
||||
@SerializedName("finishTime") val finishTime: String? = null,
|
||||
/** 打卡地点列表(非空=有场景打卡) */
|
||||
@SerializedName("taskPositions") val taskPositions: List<String>? = null,
|
||||
/** 巡检场景列表(taskType=5) */
|
||||
@SerializedName("taskInspectScenes") val taskInspectScenes: List<Any>? = null,
|
||||
/** 巡检场景列表(taskType=5,含打卡状态) */
|
||||
@SerializedName("taskInspectScenes") val taskInspectScenes: List<InspectScene>? = null,
|
||||
/** 协作人状态:1=有协作人 */
|
||||
@SerializedName("userStatus") val userStatus: Int = 0,
|
||||
/** 协作人列表 */
|
||||
|
||||
@@ -228,6 +228,8 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
||||
binding.blockHowTo.visibility = View.GONE
|
||||
binding.blockNoScene.visibility = View.GONE
|
||||
binding.blockInProgress.visibility = View.GONE
|
||||
binding.blockInspect.visibility = View.GONE
|
||||
binding.sceneList.removeAllViews()
|
||||
|
||||
// 按状态显示不同内容
|
||||
when (detail.status) {
|
||||
@@ -274,23 +276,22 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
||||
|
||||
// ===== 进行中/待完成:地点+打卡时间+完成指引 =====
|
||||
4 -> {
|
||||
// 地点(提醒在哪里工作)
|
||||
if (detail.hasPosition) {
|
||||
binding.tvPosition.text = "📍 ${detail.positionText}"
|
||||
binding.tvPosition.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
// 备注
|
||||
showNote(detail)
|
||||
|
||||
// 打卡时间(如果有)
|
||||
if (!detail.confirmTime.isNullOrEmpty()) {
|
||||
if (detail.taskType == 5) {
|
||||
// ===== 巡检任务:显示场景打卡清单 =====
|
||||
showInspectScenes(detail)
|
||||
} else {
|
||||
// ===== 普通任务:地点+打卡时间+完成指引 =====
|
||||
if (detail.hasPosition) {
|
||||
binding.tvPosition.text = "\uD83D\uDCCD ${detail.positionText}"
|
||||
binding.tvPosition.visibility = View.VISIBLE
|
||||
}
|
||||
showNote(detail)
|
||||
if (!detail.confirmTime.isNullOrEmpty()) {
|
||||
binding.tvCheckinTime.text = "<EFBFBD><EFBFBD><EFBFBD> ${detail.confirmTime} 已打卡"
|
||||
binding.tvCheckinTime.visibility = View.VISIBLE
|
||||
}
|
||||
binding.blockInProgress.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
// 绿色指引块:任务进行中+完成指引
|
||||
binding.blockInProgress.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
// ===== 其他状态 =====
|
||||
@@ -316,6 +317,43 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示巡检场景打卡清单(taskType=5,status=4)
|
||||
* 每个场景一行:✅ 已打卡 / ❌ 未打卡
|
||||
*/
|
||||
private fun showInspectScenes(detail: TaskDetail) {
|
||||
val scenes = detail.taskInspectScenes
|
||||
if (scenes.isNullOrEmpty()) {
|
||||
binding.blockInProgress.visibility = View.VISIBLE
|
||||
return
|
||||
}
|
||||
|
||||
val checkedCount = scenes.count { it.checked }
|
||||
val totalCount = scenes.size
|
||||
|
||||
// 标题:打卡进度 2/5
|
||||
binding.tvInspectTitle.text = "打卡进度 $checkedCount/$totalCount"
|
||||
binding.blockInspect.visibility = View.VISIBLE
|
||||
|
||||
// 动态添加场景行
|
||||
binding.sceneList.removeAllViews()
|
||||
for (scene in scenes) {
|
||||
val tv = android.widget.TextView(requireContext()).apply {
|
||||
text = if (scene.checked) {
|
||||
" \u2705 ${scene.name}"
|
||||
} else {
|
||||
" \u274C ${scene.name}"
|
||||
}
|
||||
textSize = 22f
|
||||
setTextColor(requireContext().getColor(
|
||||
if (scene.checked) R.color.success else R.color.text_secondary
|
||||
))
|
||||
setPadding(0, 8, 0, 8)
|
||||
}
|
||||
binding.sceneList.addView(tv)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 taskType + status 设置底部操作按钮
|
||||
*
|
||||
|
||||
@@ -263,6 +263,34 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 巡检任务:场景打卡清单 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/blockInspect"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<!-- 打卡进度标题 -->
|
||||
<TextView
|
||||
android:id="@+id/tvInspectTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/text_primary"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="11dp" />
|
||||
|
||||
<!-- 场景清单(动态添加) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/sceneList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 空状态 -->
|
||||
|
||||
Reference in New Issue
Block a user