|
@@ -25,7 +25,8 @@ import com.zhy.adapter.recyclerview.base.ViewHolder
|
|
|
*/
|
|
*/
|
|
|
class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Unit) :
|
|
class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Unit) :
|
|
|
BaseMvpFragment<IWorkerView, WorkerPresenter, FragmentWorkerBinding>() {
|
|
BaseMvpFragment<IWorkerView, WorkerPresenter, FragmentWorkerBinding>() {
|
|
|
- private val mSelectedList = mutableListOf<TicketUserReqVO>()
|
|
|
|
|
|
|
+ private val mLockerSelectedList = mutableListOf<TicketUserReqVO>()
|
|
|
|
|
+ private val mCoLockerSelectedList = mutableListOf<TicketUserReqVO>()
|
|
|
private val mColockerSelectedShowList = mutableListOf<TicketUserReqVO>() // 仅展示用
|
|
private val mColockerSelectedShowList = mutableListOf<TicketUserReqVO>() // 仅展示用
|
|
|
private val mOriginalUserList =
|
|
private val mOriginalUserList =
|
|
|
mutableListOf<TicketDetailRespVO.JobTicketUserVO>() // 修改前的人员选择列表
|
|
mutableListOf<TicketDetailRespVO.JobTicketUserVO>() // 修改前的人员选择列表
|
|
@@ -52,7 +53,10 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
}
|
|
}
|
|
|
if (isColockerChanged) {
|
|
if (isColockerChanged) {
|
|
|
presenter?.checkColockerChangedStepJump(requireContext(), mStepDetailList, mStep) {
|
|
presenter?.checkColockerChangedStepJump(requireContext(), mStepDetailList, mStep) {
|
|
|
- presenter?.updateTicketUser(mPageChangeBO?.ticketId!!, mSelectedList) {
|
|
|
|
|
|
|
+ presenter?.updateTicketUser(
|
|
|
|
|
+ mPageChangeBO?.ticketId!!,
|
|
|
|
|
+ (mLockerSelectedList + mCoLockerSelectedList).toMutableList()
|
|
|
|
|
+ ) {
|
|
|
//选择人员之后提前打开充电,加速连接
|
|
//选择人员之后提前打开充电,加速连接
|
|
|
presenter?.preOpenKeyCharge()
|
|
presenter?.preOpenKeyCharge()
|
|
|
if (it) {
|
|
if (it) {
|
|
@@ -74,13 +78,19 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
holder.setText(R.id.tv_name, data.userName)
|
|
holder.setText(R.id.tv_name, data.userName)
|
|
|
holder.setOnClickListener(R.id.root) {
|
|
holder.setOnClickListener(R.id.root) {
|
|
|
if (presenter?.colockerCanRemove(requireContext(), data, mStep) == true) {
|
|
if (presenter?.colockerCanRemove(requireContext(), data, mStep) == true) {
|
|
|
- val minColockerSize = presenter?.getMinColockerSize(requireContext())?:1
|
|
|
|
|
|
|
+ val minColockerSize =
|
|
|
|
|
+ presenter?.getMinColockerSize(requireContext()) ?: 1
|
|
|
if (mColockerSelectedShowList.size == minColockerSize) {
|
|
if (mColockerSelectedShowList.size == minColockerSize) {
|
|
|
- ToastUtils.tip(getString(R.string.keep_at_least_colocker,minColockerSize))
|
|
|
|
|
|
|
+ ToastUtils.tip(
|
|
|
|
|
+ getString(
|
|
|
|
|
+ R.string.keep_at_least_colocker,
|
|
|
|
|
+ minColockerSize
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
return@setOnClickListener
|
|
return@setOnClickListener
|
|
|
}
|
|
}
|
|
|
// 共锁人取消
|
|
// 共锁人取消
|
|
|
- mSelectedList.removeIf { it.userId == data.userId }
|
|
|
|
|
|
|
+ mCoLockerSelectedList.removeIf { it.userId == data.userId }
|
|
|
mColockerSelectedShowList.removeIf { it.userId == data.userId }
|
|
mColockerSelectedShowList.removeIf { it.userId == data.userId }
|
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
|
mBinding?.rvColockerInside?.adapter?.notifyDataSetChanged()
|
|
mBinding?.rvColockerInside?.adapter?.notifyDataSetChanged()
|
|
@@ -113,16 +123,16 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
) {
|
|
) {
|
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
|
holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
|
- mSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_LOCKER }
|
|
|
|
|
|
|
+ mLockerSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_LOCKER }
|
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
|
holder.setOnClickListener(R.id.root) {
|
|
holder.setOnClickListener(R.id.root) {
|
|
|
// 上锁人选择
|
|
// 上锁人选择
|
|
|
- if (mSelectedList.any { it.userId == user.userId }) {
|
|
|
|
|
- mSelectedList.removeIf { it.userId == user.userId }
|
|
|
|
|
|
|
+ if (mLockerSelectedList.any { it.userId == user.userId }) {
|
|
|
|
|
+ mLockerSelectedList.removeIf { it.userId == user.userId }
|
|
|
mBinding?.layoutLocker?.root?.visibility = View.INVISIBLE
|
|
mBinding?.layoutLocker?.root?.visibility = View.INVISIBLE
|
|
|
} else {
|
|
} else {
|
|
|
- mSelectedList.removeIf { it.userRole == USER_ROLE_LOCKER }
|
|
|
|
|
- mSelectedList.add(
|
|
|
|
|
|
|
+ mLockerSelectedList.removeIf { it.userRole == USER_ROLE_LOCKER }
|
|
|
|
|
+ mLockerSelectedList.add(
|
|
|
TicketUserReqVO(
|
|
TicketUserReqVO(
|
|
|
user.userId!!,
|
|
user.userId!!,
|
|
|
user.nickName!!,
|
|
user.nickName!!,
|
|
@@ -147,7 +157,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
) {
|
|
) {
|
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
|
holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
|
- mSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_COLOCKER }
|
|
|
|
|
|
|
+ mCoLockerSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_COLOCKER }
|
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
|
holder.setOnClickListener(R.id.root) {
|
|
holder.setOnClickListener(R.id.root) {
|
|
|
if (presenter?.colockerInsideCanAdd(
|
|
if (presenter?.colockerInsideCanAdd(
|
|
@@ -164,22 +174,28 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
ticketUserVOList.find { ticketUser -> ticketUser.userId == user.userId }?.jobStatus
|
|
ticketUserVOList.find { ticketUser -> ticketUser.userId == user.userId }?.jobStatus
|
|
|
)
|
|
)
|
|
|
// 内部共锁人选择
|
|
// 内部共锁人选择
|
|
|
- if (mSelectedList.any { it.userId == user.userId } &&
|
|
|
|
|
|
|
+ if (mCoLockerSelectedList.any { it.userId == user.userId } &&
|
|
|
presenter?.colockerCanRemove(
|
|
presenter?.colockerCanRemove(
|
|
|
requireContext(),
|
|
requireContext(),
|
|
|
addUser,
|
|
addUser,
|
|
|
mStep
|
|
mStep
|
|
|
) == true
|
|
) == true
|
|
|
) {
|
|
) {
|
|
|
- val minColockerSize = presenter?.getMinColockerSize(requireContext())?:1
|
|
|
|
|
|
|
+ val minColockerSize =
|
|
|
|
|
+ presenter?.getMinColockerSize(requireContext()) ?: 1
|
|
|
if (mColockerSelectedShowList.size == minColockerSize) {
|
|
if (mColockerSelectedShowList.size == minColockerSize) {
|
|
|
- ToastUtils.tip(getString(R.string.keep_at_least_colocker,minColockerSize))
|
|
|
|
|
|
|
+ ToastUtils.tip(
|
|
|
|
|
+ getString(
|
|
|
|
|
+ R.string.keep_at_least_colocker,
|
|
|
|
|
+ minColockerSize
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
return@setOnClickListener
|
|
return@setOnClickListener
|
|
|
}
|
|
}
|
|
|
- mSelectedList.removeIf { it.userId == user.userId }
|
|
|
|
|
|
|
+ mCoLockerSelectedList.removeIf { it.userId == user.userId }
|
|
|
mColockerSelectedShowList.removeIf { it.userId == user.userId }
|
|
mColockerSelectedShowList.removeIf { it.userId == user.userId }
|
|
|
} else {
|
|
} else {
|
|
|
- mSelectedList.add(addUser)
|
|
|
|
|
|
|
+ mCoLockerSelectedList.add(addUser)
|
|
|
mColockerSelectedShowList.add(addUser)
|
|
mColockerSelectedShowList.add(addUser)
|
|
|
}
|
|
}
|
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
@@ -200,7 +216,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
) {
|
|
) {
|
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
|
holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
|
- mSelectedList.any { it.userId == user.userId }
|
|
|
|
|
|
|
+ mCoLockerSelectedList.any { it.userId == user.userId }
|
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
|
holder.setOnClickListener(R.id.root) {
|
|
holder.setOnClickListener(R.id.root) {
|
|
|
if (presenter?.colockerOutsideCanAdd(
|
|
if (presenter?.colockerOutsideCanAdd(
|
|
@@ -217,22 +233,28 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
ticketUserVOList.find { ticketUser -> ticketUser.userId == user.userId }?.jobStatus
|
|
ticketUserVOList.find { ticketUser -> ticketUser.userId == user.userId }?.jobStatus
|
|
|
)
|
|
)
|
|
|
// 外部共锁人选择
|
|
// 外部共锁人选择
|
|
|
- if (mSelectedList.any { it.userId == user.userId } &&
|
|
|
|
|
|
|
+ if (mCoLockerSelectedList.any { it.userId == user.userId } &&
|
|
|
presenter?.colockerCanRemove(
|
|
presenter?.colockerCanRemove(
|
|
|
requireContext(),
|
|
requireContext(),
|
|
|
addUser,
|
|
addUser,
|
|
|
mStep
|
|
mStep
|
|
|
) == true
|
|
) == true
|
|
|
) {
|
|
) {
|
|
|
- val minColockerSize = presenter?.getMinColockerSize(requireContext())?:1
|
|
|
|
|
|
|
+ val minColockerSize =
|
|
|
|
|
+ presenter?.getMinColockerSize(requireContext()) ?: 1
|
|
|
if (mColockerSelectedShowList.size == minColockerSize) {
|
|
if (mColockerSelectedShowList.size == minColockerSize) {
|
|
|
- ToastUtils.tip(getString(R.string.keep_at_least_colocker,minColockerSize))
|
|
|
|
|
|
|
+ ToastUtils.tip(
|
|
|
|
|
+ getString(
|
|
|
|
|
+ R.string.keep_at_least_colocker,
|
|
|
|
|
+ minColockerSize
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
return@setOnClickListener
|
|
return@setOnClickListener
|
|
|
}
|
|
}
|
|
|
- mSelectedList.removeIf { it.userId == user.userId }
|
|
|
|
|
|
|
+ mCoLockerSelectedList.removeIf { it.userId == user.userId }
|
|
|
mColockerSelectedShowList.removeIf { it.userId == user.userId }
|
|
mColockerSelectedShowList.removeIf { it.userId == user.userId }
|
|
|
} else {
|
|
} else {
|
|
|
- mSelectedList.add(addUser)
|
|
|
|
|
|
|
+ mCoLockerSelectedList.add(addUser)
|
|
|
mColockerSelectedShowList.add(addUser)
|
|
mColockerSelectedShowList.add(addUser)
|
|
|
}
|
|
}
|
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
@@ -248,7 +270,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
mBinding?.layoutLocker?.root?.setOnClickListener {
|
|
mBinding?.layoutLocker?.root?.setOnClickListener {
|
|
|
if (mBinding?.layoutLocker?.root?.visibility == View.VISIBLE) {
|
|
if (mBinding?.layoutLocker?.root?.visibility == View.VISIBLE) {
|
|
|
mBinding?.layoutLocker?.root?.visibility = View.INVISIBLE
|
|
mBinding?.layoutLocker?.root?.visibility = View.INVISIBLE
|
|
|
- mSelectedList.removeIf { it.userRole == USER_ROLE_LOCKER }
|
|
|
|
|
|
|
+ mLockerSelectedList.removeIf { it.userRole == USER_ROLE_LOCKER }
|
|
|
mBinding?.rvLockerList?.adapter?.notifyDataSetChanged()
|
|
mBinding?.rvLockerList?.adapter?.notifyDataSetChanged()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -257,7 +279,8 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
override fun refreshPage(pageChangeBO: PageChangeBO) {
|
|
override fun refreshPage(pageChangeBO: PageChangeBO) {
|
|
|
mStep = 0
|
|
mStep = 0
|
|
|
mOriginalUserList.clear()
|
|
mOriginalUserList.clear()
|
|
|
- mSelectedList.clear()
|
|
|
|
|
|
|
+ mLockerSelectedList.clear()
|
|
|
|
|
+ mCoLockerSelectedList.clear()
|
|
|
mColockerSelectedShowList.clear()
|
|
mColockerSelectedShowList.clear()
|
|
|
mLockerList.clear()
|
|
mLockerList.clear()
|
|
|
mColockerInsideList.clear()
|
|
mColockerInsideList.clear()
|
|
@@ -284,7 +307,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
mBinding?.layoutLocker?.root?.visibility = View.VISIBLE
|
|
mBinding?.layoutLocker?.root?.visibility = View.VISIBLE
|
|
|
mBinding?.layoutLocker?.tvName?.text = user.userName
|
|
mBinding?.layoutLocker?.tvName?.text = user.userName
|
|
|
}
|
|
}
|
|
|
- mSelectedList.add(
|
|
|
|
|
|
|
+ mLockerSelectedList.add(
|
|
|
TicketUserReqVO(
|
|
TicketUserReqVO(
|
|
|
user.userId!!,
|
|
user.userId!!,
|
|
|
user.userName!!,
|
|
user.userName!!,
|
|
@@ -295,11 +318,11 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
// 上锁人默认选择自己
|
|
// 上锁人默认选择自己
|
|
|
- if (mSelectedList.none { it.userRole == USER_ROLE_LOCKER }) {
|
|
|
|
|
|
|
+ if (mLockerSelectedList.none { it.userRole == USER_ROLE_LOCKER }) {
|
|
|
val user =
|
|
val user =
|
|
|
it?.ticketUserVOList?.find { it.userId == SPUtils.getLoginUser(requireContext())?.userId }
|
|
it?.ticketUserVOList?.find { it.userId == SPUtils.getLoginUser(requireContext())?.userId }
|
|
|
user?.let {
|
|
user?.let {
|
|
|
- mSelectedList.add(
|
|
|
|
|
|
|
+ mLockerSelectedList.add(
|
|
|
TicketUserReqVO(
|
|
TicketUserReqVO(
|
|
|
it.userId!!,
|
|
it.userId!!,
|
|
|
it.userName!!,
|
|
it.userName!!,
|
|
@@ -312,7 +335,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
mBinding?.layoutLocker?.tvName?.text = it.userName
|
|
mBinding?.layoutLocker?.tvName?.text = it.userName
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- mColockerSelectedShowList.addAll(mSelectedList.filter { it.userRole == USER_ROLE_COLOCKER }
|
|
|
|
|
|
|
+ mColockerSelectedShowList.addAll(mCoLockerSelectedList.filter { it.userRole == USER_ROLE_COLOCKER }
|
|
|
.toMutableList())
|
|
.toMutableList())
|
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
|
mBinding?.rvLockerList?.adapter?.notifyDataSetChanged()
|
|
mBinding?.rvLockerList?.adapter?.notifyDataSetChanged()
|
|
@@ -326,11 +349,11 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
mLockerList.addAll(it?.rows!!)
|
|
mLockerList.addAll(it?.rows!!)
|
|
|
}
|
|
}
|
|
|
// 上锁人默认选择自己
|
|
// 上锁人默认选择自己
|
|
|
- if (mSelectedList.none { it.userRole == USER_ROLE_LOCKER }) {
|
|
|
|
|
|
|
+ if (mLockerSelectedList.none { it.userRole == USER_ROLE_LOCKER }) {
|
|
|
val user =
|
|
val user =
|
|
|
it?.rows?.find { it.userId == SPUtils.getLoginUser(requireContext())?.userId }
|
|
it?.rows?.find { it.userId == SPUtils.getLoginUser(requireContext())?.userId }
|
|
|
user?.let {
|
|
user?.let {
|
|
|
- mSelectedList.add(
|
|
|
|
|
|
|
+ mLockerSelectedList.add(
|
|
|
TicketUserReqVO(
|
|
TicketUserReqVO(
|
|
|
it.userId!!,
|
|
it.userId!!,
|
|
|
it.nickName!!,
|
|
it.nickName!!,
|
|
@@ -388,7 +411,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
val minColockerSize =
|
|
val minColockerSize =
|
|
|
presenter?.getMinColockerSize(requireContext()) ?: 1
|
|
presenter?.getMinColockerSize(requireContext()) ?: 1
|
|
|
val hasColocker =
|
|
val hasColocker =
|
|
|
- mSelectedList.count { it.userRole == USER_ROLE_COLOCKER } >= minColockerSize
|
|
|
|
|
|
|
+ mCoLockerSelectedList.count { it.userRole == USER_ROLE_COLOCKER } >= minColockerSize
|
|
|
if (!hasColocker) {
|
|
if (!hasColocker) {
|
|
|
ToastUtils.tip(getString(R.string.please_add_at_least_colockers, minColockerSize))
|
|
ToastUtils.tip(getString(R.string.please_add_at_least_colockers, minColockerSize))
|
|
|
return false
|
|
return false
|
|
@@ -396,7 +419,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
}
|
|
}
|
|
|
if (mStep >= 4) {
|
|
if (mStep >= 4) {
|
|
|
val originLocker = mOriginalUserList.find { it.userRole == USER_ROLE_LOCKER }
|
|
val originLocker = mOriginalUserList.find { it.userRole == USER_ROLE_LOCKER }
|
|
|
- val selectedLocker = mSelectedList.find { it.userRole == USER_ROLE_LOCKER }
|
|
|
|
|
|
|
+ val selectedLocker = mLockerSelectedList.find { it.userRole == USER_ROLE_LOCKER }
|
|
|
if (originLocker != null && selectedLocker != null && originLocker.userId != selectedLocker.userId) {
|
|
if (originLocker != null && selectedLocker != null && originLocker.userId != selectedLocker.userId) {
|
|
|
ToastUtils.tip(R.string.can_not_change_locker)
|
|
ToastUtils.tip(R.string.can_not_change_locker)
|
|
|
return false
|
|
return false
|