|
@@ -1,6 +1,7 @@
|
|
|
package com.grkj.iscs.features.main.fragment.common
|
|
package com.grkj.iscs.features.main.fragment.common
|
|
|
|
|
|
|
|
import android.widget.LinearLayout
|
|
import android.widget.LinearLayout
|
|
|
|
|
+import androidx.core.content.ContextCompat
|
|
|
import androidx.core.view.isVisible
|
|
import androidx.core.view.isVisible
|
|
|
import androidx.fragment.app.viewModels
|
|
import androidx.fragment.app.viewModels
|
|
|
import coil.load
|
|
import coil.load
|
|
@@ -137,7 +138,7 @@ class SelectMemberFragment : BaseFragment<FragmentSelectMemeberBinding>() {
|
|
|
}
|
|
}
|
|
|
if (isLockerSelect) {
|
|
if (isLockerSelect) {
|
|
|
selectedLockerData.find {
|
|
selectedLockerData.find {
|
|
|
- it.jobTicketGroupMemberList.map { it.userId }.contains(item.userId)
|
|
|
|
|
|
|
+ it.jobTicketGroupInfo.groupId == viewModel.currentSelectGroup?.groupId
|
|
|
}?.jobTicketGroupMemberList?.removeIf { it.userId == item.userId }
|
|
}?.jobTicketGroupMemberList?.removeIf { it.userId == item.userId }
|
|
|
item.isSelected = false
|
|
item.isSelected = false
|
|
|
} else {
|
|
} else {
|
|
@@ -161,6 +162,13 @@ class SelectMemberFragment : BaseFragment<FragmentSelectMemeberBinding>() {
|
|
|
selectedLockerData.find { it.jobTicketGroupInfo.groupId == viewModel.currentSelectGroup?.groupId }?.jobTicketGroupMemberList?.add(
|
|
selectedLockerData.find { it.jobTicketGroupInfo.groupId == viewModel.currentSelectGroup?.groupId }?.jobTicketGroupMemberList?.add(
|
|
|
item
|
|
item
|
|
|
)
|
|
)
|
|
|
|
|
+ viewModel.userData.forEach {
|
|
|
|
|
+ it.isSelected =
|
|
|
|
|
+ selectedLockerData.find { it.jobTicketGroupInfo.groupId == viewModel.currentSelectGroup?.groupId }
|
|
|
|
|
+ ?.jobTicketGroupMemberList?.map { selectedLocker -> selectedLocker.userId }
|
|
|
|
|
+ ?.contains(it.userId) == true
|
|
|
|
|
+ }
|
|
|
|
|
+ viewModel.userData.sortedBy { it.isSelected }
|
|
|
} else {
|
|
} else {
|
|
|
selectedColockerData.add(item)
|
|
selectedColockerData.add(item)
|
|
|
binding.allUserRv.models =
|
|
binding.allUserRv.models =
|
|
@@ -183,34 +191,25 @@ class SelectMemberFragment : BaseFragment<FragmentSelectMemeberBinding>() {
|
|
|
val itemBinding = holder.getBinding<ItemLockerGroupBinding>()
|
|
val itemBinding = holder.getBinding<ItemLockerGroupBinding>()
|
|
|
val item = holder.getModel<JobTicketGroupDataVo<JobUserVo>>()
|
|
val item = holder.getModel<JobTicketGroupDataVo<JobUserVo>>()
|
|
|
itemBinding.groupName.text = item.jobTicketGroupInfo.groupName
|
|
itemBinding.groupName.text = item.jobTicketGroupInfo.groupName
|
|
|
- itemBinding.groupLockerRv.setDebouncedClickListener {
|
|
|
|
|
|
|
+ fun groupSelected() {
|
|
|
isLockerSelect = true
|
|
isLockerSelect = true
|
|
|
- itemBinding.groupName.isSelected = !itemBinding.groupName.isSelected
|
|
|
|
|
|
|
+ checkSelectArea()
|
|
|
|
|
+ itemBinding.groupTitleLayout.isSelected = true
|
|
|
|
|
+ itemBinding.groupName.isSelected = true
|
|
|
viewModel.currentSelectGroup = item.jobTicketGroupInfo
|
|
viewModel.currentSelectGroup = item.jobTicketGroupInfo
|
|
|
binding.selectMemberTip.text =
|
|
binding.selectMemberTip.text =
|
|
|
getString(R.string.select_locker_tip, viewModel.currentSelectGroup?.groupName ?: "")
|
|
getString(R.string.select_locker_tip, viewModel.currentSelectGroup?.groupName ?: "")
|
|
|
binding.allUserRv.models =
|
|
binding.allUserRv.models =
|
|
|
viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTLOCKER.roleKey) }
|
|
viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTLOCKER.roleKey) }
|
|
|
.onEach {
|
|
.onEach {
|
|
|
- it.isSelected == item.jobTicketGroupMemberList.map { selectedLocker -> selectedLocker.userId }
|
|
|
|
|
- .contains(it.userId)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ it.isSelected =
|
|
|
|
|
+ item.jobTicketGroupMemberList.map { selectedLocker -> selectedLocker.userId }
|
|
|
|
|
+ .contains(it.userId)
|
|
|
|
|
+ }.sortedBy { it.isSelected }
|
|
|
adapter.notifyDataSetChanged()
|
|
adapter.notifyDataSetChanged()
|
|
|
}
|
|
}
|
|
|
itemBinding.groupTitleLayout.setDebouncedClickListener {
|
|
itemBinding.groupTitleLayout.setDebouncedClickListener {
|
|
|
- isLockerSelect = true
|
|
|
|
|
- itemBinding.groupTitleLayout.isSelected = !itemBinding.groupTitleLayout.isSelected
|
|
|
|
|
- itemBinding.groupName.isSelected = itemBinding.groupTitleLayout.isSelected
|
|
|
|
|
- viewModel.currentSelectGroup = item.jobTicketGroupInfo
|
|
|
|
|
- binding.selectMemberTip.text =
|
|
|
|
|
- getString(R.string.select_locker_tip, viewModel.currentSelectGroup?.groupName ?: "")
|
|
|
|
|
- binding.allUserRv.models =
|
|
|
|
|
- viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTLOCKER.roleKey) }
|
|
|
|
|
- .onEach {
|
|
|
|
|
- it.isSelected == item.jobTicketGroupMemberList.map { selectedLocker -> selectedLocker.userId }
|
|
|
|
|
- .contains(it.userId)
|
|
|
|
|
- }
|
|
|
|
|
- adapter.notifyDataSetChanged()
|
|
|
|
|
|
|
+ groupSelected()
|
|
|
}
|
|
}
|
|
|
itemBinding.groupTitleLayout.isSelected =
|
|
itemBinding.groupTitleLayout.isSelected =
|
|
|
isLockerSelect && item.jobTicketGroupInfo.groupId == viewModel.currentSelectGroup?.groupId
|
|
isLockerSelect && item.jobTicketGroupInfo.groupId == viewModel.currentSelectGroup?.groupId
|
|
@@ -219,13 +218,14 @@ class SelectMemberFragment : BaseFragment<FragmentSelectMemeberBinding>() {
|
|
|
itemBinding.groupLockerRv.linear(LinearLayout.HORIZONTAL).setup {
|
|
itemBinding.groupLockerRv.linear(LinearLayout.HORIZONTAL).setup {
|
|
|
addType<JobUserVo>(R.layout.item_select_member)
|
|
addType<JobUserVo>(R.layout.item_select_member)
|
|
|
onBind {
|
|
onBind {
|
|
|
- onLockerRVBinding(item.jobTicketGroupInfo, this)
|
|
|
|
|
|
|
+ onLockerRVBinding(item.jobTicketGroupInfo, item.jobTicketGroupMemberList, this)
|
|
|
}
|
|
}
|
|
|
}.models = item.jobTicketGroupMemberList
|
|
}.models = item.jobTicketGroupMemberList
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun BindingAdapter.BindingViewHolder.onLockerRVBinding(
|
|
private fun BindingAdapter.BindingViewHolder.onLockerRVBinding(
|
|
|
groupData: JobTicketGroupInfoVo,
|
|
groupData: JobTicketGroupInfoVo,
|
|
|
|
|
+ memberData: MutableList<JobUserVo>,
|
|
|
holder: BindingAdapter.BindingViewHolder
|
|
holder: BindingAdapter.BindingViewHolder
|
|
|
) {
|
|
) {
|
|
|
val itemBinding = holder.getBinding<ItemSelectMemberBinding>()
|
|
val itemBinding = holder.getBinding<ItemSelectMemberBinding>()
|
|
@@ -244,9 +244,37 @@ class SelectMemberFragment : BaseFragment<FragmentSelectMemeberBinding>() {
|
|
|
PopTip.build().tip(com.grkj.ui_base.R.string.can_not_remove_current_locker)
|
|
PopTip.build().tip(com.grkj.ui_base.R.string.can_not_remove_current_locker)
|
|
|
return@setDebouncedClickListener
|
|
return@setDebouncedClickListener
|
|
|
}
|
|
}
|
|
|
- selectedLockerData.find { it.jobTicketGroupInfo.groupId == groupData.groupId }?.jobTicketGroupMemberList?.removeIf { it.userId == item.userId }
|
|
|
|
|
- viewModel.userData.find { it.userId == item.userId }?.isSelected = false
|
|
|
|
|
- adapter.notifyDataSetChanged()
|
|
|
|
|
|
|
+ if (isLockerSelect) {
|
|
|
|
|
+ selectedLockerData.find { it.jobTicketGroupInfo.groupId == groupData.groupId }?.jobTicketGroupMemberList?.removeIf { it.userId == item.userId }
|
|
|
|
|
+ viewModel.userData.find { it.userId == item.userId }?.isSelected = false
|
|
|
|
|
+ if (groupData.groupId == viewModel.currentSelectGroup?.groupId) {
|
|
|
|
|
+ binding.allUserRv.adapter?.notifyDataSetChanged()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ binding.allUserRv.models =
|
|
|
|
|
+ viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTLOCKER.roleKey) }
|
|
|
|
|
+ .onEach {
|
|
|
|
|
+ it.isSelected =
|
|
|
|
|
+ memberData.map { selectedLocker -> selectedLocker.userId }
|
|
|
|
|
+ .contains(it.userId)
|
|
|
|
|
+ }.sortedBy { it.isSelected }
|
|
|
|
|
+ }
|
|
|
|
|
+ adapter.notifyDataSetChanged()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ isLockerSelect = true
|
|
|
|
|
+ checkSelectArea()
|
|
|
|
|
+ viewModel.currentSelectGroup = groupData
|
|
|
|
|
+ selectedLockerData.find { it.jobTicketGroupInfo.groupId == groupData.groupId }?.jobTicketGroupMemberList?.removeIf { it.userId == item.userId }
|
|
|
|
|
+ viewModel.userData.find { it.userId == item.userId }?.isSelected = false
|
|
|
|
|
+ binding.allUserRv.models =
|
|
|
|
|
+ viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTLOCKER.roleKey) }
|
|
|
|
|
+ .onEach {
|
|
|
|
|
+ it.isSelected =
|
|
|
|
|
+ selectedLockerData.find { it.jobTicketGroupInfo.groupId == groupData.groupId }?.jobTicketGroupMemberList?.map { selectedLocker -> selectedLocker.userId }
|
|
|
|
|
+ ?.contains(it.userId) == true
|
|
|
|
|
+ }.sortedBy { it.isSelected }
|
|
|
|
|
+ adapter.notifyDataSetChanged()
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.lockerRv.adapter?.notifyDataSetChanged()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -269,17 +297,26 @@ class SelectMemberFragment : BaseFragment<FragmentSelectMemeberBinding>() {
|
|
|
}
|
|
}
|
|
|
selectedColockerData.removeIf { it.userId == item.userId }
|
|
selectedColockerData.removeIf { it.userId == item.userId }
|
|
|
viewModel.userData.find { it.userId == item.userId }?.isSelected = false
|
|
viewModel.userData.find { it.userId == item.userId }?.isSelected = false
|
|
|
- adapter.notifyDataSetChanged()
|
|
|
|
|
- binding.allUserRv.models =
|
|
|
|
|
- viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTCOLOCKER.roleKey) }
|
|
|
|
|
- .filter {
|
|
|
|
|
- it.userId !in selectedColockerData.map { it.userId }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (isLockerSelect) {
|
|
|
|
|
+ isLockerSelect = false
|
|
|
|
|
+ checkSelectArea()
|
|
|
|
|
+ viewModel.currentSelectGroup = null
|
|
|
|
|
+ binding.lockerRv.adapter?.notifyDataSetChanged()
|
|
|
|
|
+ setColockerData()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ adapter.notifyDataSetChanged()
|
|
|
|
|
+ binding.allUserRv.models =
|
|
|
|
|
+ viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTCOLOCKER.roleKey) }
|
|
|
|
|
+ .filter {
|
|
|
|
|
+ it.userId !in selectedColockerData.map { it.userId }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun setLockerData() {
|
|
private fun setLockerData() {
|
|
|
isLockerSelect = true
|
|
isLockerSelect = true
|
|
|
|
|
+ checkSelectArea()
|
|
|
binding.selectMemberTip.text =
|
|
binding.selectMemberTip.text =
|
|
|
getString(R.string.select_locker_tip, viewModel.currentSelectGroup?.groupName ?: "")
|
|
getString(R.string.select_locker_tip, viewModel.currentSelectGroup?.groupName ?: "")
|
|
|
binding.lockerRv.models = selectedLockerData
|
|
binding.lockerRv.models = selectedLockerData
|
|
@@ -298,10 +335,14 @@ class SelectMemberFragment : BaseFragment<FragmentSelectMemeberBinding>() {
|
|
|
|
|
|
|
|
private fun setColockerData() {
|
|
private fun setColockerData() {
|
|
|
isLockerSelect = false
|
|
isLockerSelect = false
|
|
|
|
|
+ checkSelectArea()
|
|
|
binding.selectMemberTip.text = CommonUtils.getStr(R.string.select_colocker_tip)
|
|
binding.selectMemberTip.text = CommonUtils.getStr(R.string.select_colocker_tip)
|
|
|
binding.colockerRv.models = selectedColockerData
|
|
binding.colockerRv.models = selectedColockerData
|
|
|
binding.allUserRv.models =
|
|
binding.allUserRv.models =
|
|
|
- viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTCOLOCKER.roleKey) && it.userId in selectedColockerData.map { it.userId } }
|
|
|
|
|
|
|
+ viewModel.userData.filter { it.roleKeys.contains(RoleEnum.JTCOLOCKER.roleKey) && it.userId !in selectedColockerData.map { it.userId } }
|
|
|
|
|
+ .apply {
|
|
|
|
|
+ forEach { it.isSelected = false }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun initData() {
|
|
override fun initData() {
|
|
@@ -342,4 +383,27 @@ class SelectMemberFragment : BaseFragment<FragmentSelectMemeberBinding>() {
|
|
|
viewModel.getTicketUsers(ticketId).observe(this) {}
|
|
viewModel.getTicketUsers(ticketId).observe(this) {}
|
|
|
viewModel.getTicketData(ticketId).observe(this) {}
|
|
viewModel.getTicketData(ticketId).observe(this) {}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 选择区域
|
|
|
|
|
+ */
|
|
|
|
|
+ private fun checkSelectArea() {
|
|
|
|
|
+ if (isLockerSelect) {
|
|
|
|
|
+ binding.lockerRv.setBackgroundColor(
|
|
|
|
|
+ ContextCompat.getColor(
|
|
|
|
|
+ requireContext(),
|
|
|
|
|
+ R.color.color_4d2196f3
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ binding.colockerRv.background = null
|
|
|
|
|
+ } else {
|
|
|
|
|
+ binding.colockerRv.setBackgroundColor(
|
|
|
|
|
+ ContextCompat.getColor(
|
|
|
|
|
+ requireContext(),
|
|
|
|
|
+ R.color.color_4d2196f3
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ binding.lockerRv.background = null
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|