fix: 操作按钮逻辑按taskType+status组合判断
- type 2(指派): 无抢单步骤,直接从status3开始 - type 5(巡检): status4是NFC打卡(非确认完成),无抢单无完成 - type 0/1/3/4: 完整流程(抢单→打卡→完成) - 抽取 setupPunchButton/setupCompleteButton/showBackButton 方法 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -250,23 +250,67 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 根据状态设置底部操作按钮 */
|
||||
/**
|
||||
* 根据 taskType + status 设置底部操作按钮
|
||||
*
|
||||
* 规则(和旧版一致):
|
||||
* - type 0/1(计划/监控): status2=抢单, status3=打卡, status4=完成
|
||||
* - type 2(指派): 无抢单步骤, status3=打卡, status4=完成
|
||||
* - type 3/4(上报): status2=抢单, status3=打卡, status4=完成
|
||||
* - type 5(巡检): 无抢单, status4=NFC打卡(非完成), 无确认完成
|
||||
*/
|
||||
private fun setupActionButton(detail: TaskDetail) {
|
||||
val btn = binding.btnAction
|
||||
btn.visibility = View.VISIBLE
|
||||
// 重置文字颜色(橙色按钮需要黑色文字,其他白色)
|
||||
btn.setTextColor(requireContext().getColor(R.color.text_primary))
|
||||
|
||||
when (detail.taskType) {
|
||||
// ===== 巡检任务(type 5):特殊流程 =====
|
||||
5 -> {
|
||||
when (detail.status) {
|
||||
// 待抢单 → 蓝色「抢 单」
|
||||
4 -> {
|
||||
// 巡检进行中 → NFC 打卡(不是确认完成)
|
||||
btn.text = "开启打卡"
|
||||
btn.setBackgroundResource(R.drawable.bg_foot_btn_orange)
|
||||
btn.setTextColor(requireContext().getColor(R.color.background))
|
||||
btn.setOnClickListener {
|
||||
// TODO: NFC 打卡流程
|
||||
Timber.d("巡检 NFC 打卡(后续实现)")
|
||||
}
|
||||
}
|
||||
else -> showBackButton(btn)
|
||||
}
|
||||
}
|
||||
// ===== 指派任务(type 2):无抢单步骤 =====
|
||||
2 -> {
|
||||
when (detail.status) {
|
||||
3 -> setupPunchButton(btn, detail)
|
||||
4 -> setupCompleteButton(btn, detail)
|
||||
else -> showBackButton(btn)
|
||||
}
|
||||
}
|
||||
// ===== 计划/监控/上报(type 0/1/3/4):完整流程 =====
|
||||
else -> {
|
||||
when (detail.status) {
|
||||
2 -> {
|
||||
// 抢单
|
||||
btn.text = "抢 单"
|
||||
btn.setBackgroundResource(R.drawable.bg_foot_btn_blue)
|
||||
btn.setTextColor(requireContext().getColor(R.color.text_primary))
|
||||
btn.setOnClickListener { doAction("grab", detail.id) }
|
||||
}
|
||||
// 待打卡
|
||||
3 -> {
|
||||
3 -> setupPunchButton(btn, detail)
|
||||
4 -> setupCompleteButton(btn, detail)
|
||||
else -> showBackButton(btn)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 设置打卡按钮(状态3:根据有无场景决定打卡方式) */
|
||||
private fun setupPunchButton(btn: android.widget.TextView, detail: TaskDetail) {
|
||||
if (detail.hasPosition) {
|
||||
// 有场景 → 橙色「开启打卡」
|
||||
// 有场景 → 橙色「开启打卡」→ NFC
|
||||
btn.text = "开启打卡"
|
||||
btn.setBackgroundResource(R.drawable.bg_foot_btn_orange)
|
||||
btn.setTextColor(requireContext().getColor(R.color.background))
|
||||
@@ -275,29 +319,26 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
||||
Timber.d("NFC 打卡(后续实现)")
|
||||
}
|
||||
} else {
|
||||
// 无场景 → 绿色「确认打卡」
|
||||
// 无场景 → 绿色「确认打卡」→ 直接确认
|
||||
btn.text = "确认打卡"
|
||||
btn.setBackgroundResource(R.drawable.bg_foot_btn_green)
|
||||
btn.setTextColor(requireContext().getColor(R.color.text_primary))
|
||||
btn.setOnClickListener { doAction("assign", detail.id) }
|
||||
}
|
||||
}
|
||||
// 进行中 → 绿色「确认完成」
|
||||
4 -> {
|
||||
|
||||
/** 设置确认完成按钮(状态4) */
|
||||
private fun setupCompleteButton(btn: android.widget.TextView, detail: TaskDetail) {
|
||||
btn.text = "确认完成"
|
||||
btn.setBackgroundResource(R.drawable.bg_foot_btn_green)
|
||||
btn.setTextColor(requireContext().getColor(R.color.text_primary))
|
||||
btn.setOnClickListener { doAction("complete", detail.id) }
|
||||
}
|
||||
// 其他 → 灰色「返回」
|
||||
else -> {
|
||||
|
||||
/** 显示返回按钮(已完成/其他状态) */
|
||||
private fun showBackButton(btn: android.widget.TextView) {
|
||||
btn.text = "返 回"
|
||||
btn.setBackgroundResource(R.drawable.bg_foot_btn_blue)
|
||||
btn.setTextColor(requireContext().getColor(R.color.text_primary))
|
||||
btn.setOnClickListener { findNavController().popBackStack() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 操作 =====
|
||||
|
||||
|
||||
Reference in New Issue
Block a user