|
|
@@ -25,7 +25,8 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
BaseMvpFragment<IWorkerView, WorkerPresenter, FragmentWorkerBinding>() {
|
|
|
private val mSelectedList = mutableListOf<TicketUserReqVO>()
|
|
|
private val mColockerSelectedShowList = mutableListOf<TicketUserReqVO>() // 仅展示用
|
|
|
- private val mOriginalUserList = mutableListOf<TicketDetailRespVO.JobTicketUserVO>() // 修改前的人员选择列表
|
|
|
+ private val mOriginalUserList =
|
|
|
+ mutableListOf<TicketDetailRespVO.JobTicketUserVO>() // 修改前的人员选择列表
|
|
|
|
|
|
private val mLockerList = mutableListOf<UserListRespVO.Row>()
|
|
|
private val mColockerInsideList = mutableListOf<UserListRespVO.Row>()
|
|
|
@@ -45,12 +46,18 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
return@setOnClickListener
|
|
|
}
|
|
|
presenter?.updateTicketUser(mPageChangeBO?.ticketId!!, mSelectedList) {
|
|
|
- if (it) { goBack() }
|
|
|
+ if (it) {
|
|
|
+ goBack()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
mBinding?.rvColockerSelected?.adapter =
|
|
|
- object : CommonAdapter<TicketUserReqVO>(requireActivity(), R.layout.item_rv_worker, mColockerSelectedShowList) {
|
|
|
+ object : CommonAdapter<TicketUserReqVO>(
|
|
|
+ requireActivity(),
|
|
|
+ R.layout.item_rv_worker,
|
|
|
+ mColockerSelectedShowList
|
|
|
+ ) {
|
|
|
override fun convert(holder: ViewHolder, data: TicketUserReqVO, position: Int) {
|
|
|
holder.getView<ImageView>(R.id.iv_photo).isSelected = true
|
|
|
holder.setText(R.id.tv_name, data.userName)
|
|
|
@@ -78,9 +85,14 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
}
|
|
|
|
|
|
mBinding?.rvLockerList?.adapter =
|
|
|
- object : CommonAdapter<UserListRespVO.Row>(requireActivity(), R.layout.item_rv_worker, mLockerList) {
|
|
|
+ object : CommonAdapter<UserListRespVO.Row>(
|
|
|
+ requireActivity(),
|
|
|
+ R.layout.item_rv_worker,
|
|
|
+ mLockerList
|
|
|
+ ) {
|
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
|
- holder.getView<ImageView>(R.id.iv_photo).isSelected = mSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_LOCKER}
|
|
|
+ holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
|
+ mSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_LOCKER }
|
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
|
holder.setOnClickListener(R.id.root) {
|
|
|
// 上锁人选择
|
|
|
@@ -89,7 +101,14 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
mBinding?.layoutLocker?.root?.visibility = View.INVISIBLE
|
|
|
} else {
|
|
|
mSelectedList.removeIf { it.userRole == USER_ROLE_LOCKER }
|
|
|
- mSelectedList.add(TicketUserReqVO(user.userId!!, user.nickName!!, "0", USER_ROLE_LOCKER))
|
|
|
+ mSelectedList.add(
|
|
|
+ TicketUserReqVO(
|
|
|
+ user.userId!!,
|
|
|
+ user.nickName!!,
|
|
|
+ "0",
|
|
|
+ USER_ROLE_LOCKER
|
|
|
+ )
|
|
|
+ )
|
|
|
mBinding?.layoutLocker?.root?.visibility = View.VISIBLE
|
|
|
mBinding?.layoutLocker?.tvName?.text = user.nickName
|
|
|
}
|
|
|
@@ -99,9 +118,14 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
}
|
|
|
|
|
|
mBinding?.rvColockerInside?.adapter =
|
|
|
- object : CommonAdapter<UserListRespVO.Row>(requireActivity(), R.layout.item_rv_worker, mColockerInsideList) {
|
|
|
+ object : CommonAdapter<UserListRespVO.Row>(
|
|
|
+ requireActivity(),
|
|
|
+ R.layout.item_rv_worker,
|
|
|
+ mColockerInsideList
|
|
|
+ ) {
|
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
|
- holder.getView<ImageView>(R.id.iv_photo).isSelected = mSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_COLOCKER}
|
|
|
+ holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
|
+ mSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_COLOCKER }
|
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
|
holder.setOnClickListener(R.id.root) {
|
|
|
// 内部共锁人选择
|
|
|
@@ -109,7 +133,12 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
mSelectedList.removeIf { it.userId == user.userId }
|
|
|
mColockerSelectedShowList.removeIf { it.userId == user.userId }
|
|
|
} else {
|
|
|
- val addUser = TicketUserReqVO(user.userId!!, user.nickName!!, "0", USER_ROLE_COLOCKER)
|
|
|
+ val addUser = TicketUserReqVO(
|
|
|
+ user.userId!!,
|
|
|
+ user.nickName!!,
|
|
|
+ "0",
|
|
|
+ USER_ROLE_COLOCKER
|
|
|
+ )
|
|
|
mSelectedList.add(addUser)
|
|
|
mColockerSelectedShowList.add(addUser)
|
|
|
}
|
|
|
@@ -120,9 +149,14 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
}
|
|
|
|
|
|
mBinding?.rvColockerOutside?.adapter =
|
|
|
- object : CommonAdapter<UserListRespVO.Row>(requireActivity(), R.layout.item_rv_worker, mColockerOutsideList) {
|
|
|
+ object : CommonAdapter<UserListRespVO.Row>(
|
|
|
+ requireActivity(),
|
|
|
+ R.layout.item_rv_worker,
|
|
|
+ mColockerOutsideList
|
|
|
+ ) {
|
|
|
override fun convert(holder: ViewHolder, user: UserListRespVO.Row, position: Int) {
|
|
|
- holder.getView<ImageView>(R.id.iv_photo).isSelected = mSelectedList.any { it.userId == user.userId }
|
|
|
+ holder.getView<ImageView>(R.id.iv_photo).isSelected =
|
|
|
+ mSelectedList.any { it.userId == user.userId }
|
|
|
holder.setText(R.id.tv_name, user.nickName)
|
|
|
holder.setOnClickListener(R.id.root) {
|
|
|
// 外部共锁人选择
|
|
|
@@ -130,7 +164,12 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
mSelectedList.removeIf { it.userId == user.userId }
|
|
|
mColockerSelectedShowList.removeIf { it.userId == user.userId }
|
|
|
} else {
|
|
|
- val addUser = TicketUserReqVO(user.userId!!, user.nickName!!, "1", USER_ROLE_COLOCKER)
|
|
|
+ val addUser = TicketUserReqVO(
|
|
|
+ user.userId!!,
|
|
|
+ user.nickName!!,
|
|
|
+ "1",
|
|
|
+ USER_ROLE_COLOCKER
|
|
|
+ )
|
|
|
mSelectedList.add(addUser)
|
|
|
mColockerSelectedShowList.add(addUser)
|
|
|
}
|
|
|
@@ -181,18 +220,34 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
mBinding?.layoutLocker?.root?.visibility = View.VISIBLE
|
|
|
mBinding?.layoutLocker?.tvName?.text = user.userName
|
|
|
}
|
|
|
- mSelectedList.add(TicketUserReqVO(user.userId!!, user.userName!!, user.userType!!, user.userRole!!))
|
|
|
+ mSelectedList.add(
|
|
|
+ TicketUserReqVO(
|
|
|
+ user.userId!!,
|
|
|
+ user.userName!!,
|
|
|
+ user.userType!!,
|
|
|
+ user.userRole!!
|
|
|
+ )
|
|
|
+ )
|
|
|
}
|
|
|
// 上锁人默认选择自己
|
|
|
if (mSelectedList.none { it.userRole == USER_ROLE_LOCKER }) {
|
|
|
- val user = it?.ticketUserVOList?.find { it.userId == SPUtils.getLoginUser(requireContext())?.userId }
|
|
|
+ val user =
|
|
|
+ it?.ticketUserVOList?.find { it.userId == SPUtils.getLoginUser(requireContext())?.userId }
|
|
|
user?.let {
|
|
|
- mSelectedList.add(TicketUserReqVO(it.userId!!, it.userName!!, it.userType!!, USER_ROLE_LOCKER))
|
|
|
+ mSelectedList.add(
|
|
|
+ TicketUserReqVO(
|
|
|
+ it.userId!!,
|
|
|
+ it.userName!!,
|
|
|
+ it.userType!!,
|
|
|
+ USER_ROLE_LOCKER
|
|
|
+ )
|
|
|
+ )
|
|
|
mBinding?.layoutLocker?.root?.visibility = View.VISIBLE
|
|
|
mBinding?.layoutLocker?.tvName?.text = it.userName
|
|
|
}
|
|
|
}
|
|
|
- mColockerSelectedShowList.addAll(mSelectedList.filter { it.userRole == USER_ROLE_COLOCKER }.toMutableList())
|
|
|
+ mColockerSelectedShowList.addAll(mSelectedList.filter { it.userRole == USER_ROLE_COLOCKER }
|
|
|
+ .toMutableList())
|
|
|
mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
|
|
|
mBinding?.rvLockerList?.adapter?.notifyDataSetChanged()
|
|
|
mBinding?.rvColockerInside?.adapter?.notifyDataSetChanged()
|
|
|
@@ -206,9 +261,17 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
}
|
|
|
// 上锁人默认选择自己
|
|
|
if (mSelectedList.none { it.userRole == USER_ROLE_LOCKER }) {
|
|
|
- val user = it?.rows?.find { it.userId == SPUtils.getLoginUser(requireContext())?.userId }
|
|
|
+ val user =
|
|
|
+ it?.rows?.find { it.userId == SPUtils.getLoginUser(requireContext())?.userId }
|
|
|
user?.let {
|
|
|
- mSelectedList.add(TicketUserReqVO(it.userId!!, it.nickName!!, "0", USER_ROLE_LOCKER))
|
|
|
+ mSelectedList.add(
|
|
|
+ TicketUserReqVO(
|
|
|
+ it.userId!!,
|
|
|
+ it.nickName!!,
|
|
|
+ "0",
|
|
|
+ USER_ROLE_LOCKER
|
|
|
+ )
|
|
|
+ )
|
|
|
mBinding?.layoutLocker?.root?.visibility = View.VISIBLE
|
|
|
mBinding?.layoutLocker?.tvName?.text = it.nickName
|
|
|
}
|
|
|
@@ -233,8 +296,10 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
}
|
|
|
|
|
|
presenter?.getStepDetail(pageChangeBO.ticketId!!) {
|
|
|
- mBinding?.tvWorker?.text = "${it?.get(2)?.userNum}/${it?.get(4)?.userNum}/${it?.get(7)?.userNum}"
|
|
|
- mBinding?.tvLock?.text = "${it?.get(2)?.lockNum}/${it?.get(4)?.lockNum}/${it?.get(7)?.lockNum}"
|
|
|
+ mBinding?.tvWorker?.text =
|
|
|
+ "${it?.get(2)?.userNum}/${it?.get(4)?.userNum}/${it?.get(7)?.userNum}"
|
|
|
+ mBinding?.tvLock?.text =
|
|
|
+ "${it?.get(2)?.lockNum}/${it?.get(4)?.lockNum}/${it?.get(7)?.lockNum}"
|
|
|
|
|
|
it?.filter { it.stepStatus == "1" }?.maxByOrNull { it.stepIndex!! }?.stepIndex?.let {
|
|
|
mStep = it
|
|
|
@@ -249,6 +314,14 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
|
|
|
if (mStep == 0) {
|
|
|
return false
|
|
|
}
|
|
|
+ //选择人员的时候一定要添加共锁人
|
|
|
+ if (mStep == 2) {
|
|
|
+ val hasColocker = mSelectedList.any { it.userRole == USER_ROLE_COLOCKER }
|
|
|
+ if (!hasColocker) {
|
|
|
+ ToastUtils.tip(getString(R.string.please_add_colocker))
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
if (mStep >= 4) {
|
|
|
val originLocker = mOriginalUserList.find { it.userRole == USER_ROLE_LOCKER }
|
|
|
val selectedLocker = mSelectedList.find { it.userRole == USER_ROLE_LOCKER }
|