|
@@ -2,49 +2,60 @@ package com.grkj.iscs.features.main.dialog.data_manage
|
|
|
|
|
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
import android.view.View
|
|
import android.view.View
|
|
|
|
|
+import androidx.core.view.isVisible
|
|
|
import com.grkj.data.model.vo.AddUserDataVo
|
|
import com.grkj.data.model.vo.AddUserDataVo
|
|
|
|
|
+import com.grkj.data.model.vo.UpdateUserDataVo
|
|
|
import com.grkj.data.model.vo.UserManageVo
|
|
import com.grkj.data.model.vo.UserManageVo
|
|
|
import com.grkj.iscs.R
|
|
import com.grkj.iscs.R
|
|
|
-import com.grkj.iscs.databinding.DialogUserDetailBinding
|
|
|
|
|
|
|
+import com.grkj.iscs.databinding.DialogUpdateUserBinding
|
|
|
import com.grkj.iscs.features.main.dialog.TextDropDownDialog
|
|
import com.grkj.iscs.features.main.dialog.TextDropDownDialog
|
|
|
|
|
+import com.grkj.ui_base.config.ISCSConfig
|
|
|
import com.grkj.ui_base.utils.extension.tipDialog
|
|
import com.grkj.ui_base.utils.extension.tipDialog
|
|
|
import com.kongzue.dialogx.dialogs.PopTip
|
|
import com.kongzue.dialogx.dialogs.PopTip
|
|
|
import razerdp.basepopup.BasePopupWindow
|
|
import razerdp.basepopup.BasePopupWindow
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 新增用户
|
|
|
|
|
|
|
+ * 更新用户
|
|
|
*/
|
|
*/
|
|
|
-class UserDetailDialog(context: Context) : BasePopupWindow(context) {
|
|
|
|
|
- private lateinit var binding: DialogUserDetailBinding
|
|
|
|
|
|
|
+class UpdateUserDialog(context: Context) : BasePopupWindow(context) {
|
|
|
|
|
+ private lateinit var binding: DialogUpdateUserBinding
|
|
|
private var textDropDownDialog: TextDropDownDialog
|
|
private var textDropDownDialog: TextDropDownDialog
|
|
|
private var roleData: List<TextDropDownDialog.TextDropDownEntity> = listOf()
|
|
private var roleData: List<TextDropDownDialog.TextDropDownEntity> = listOf()
|
|
|
private var workstationData: List<TextDropDownDialog.TextDropDownEntity> = listOf()
|
|
private var workstationData: List<TextDropDownDialog.TextDropDownEntity> = listOf()
|
|
|
- private var selectedRoleData: TextDropDownDialog.TextDropDownEntity? = null
|
|
|
|
|
- private var selectedWorkstationData: TextDropDownDialog.TextDropDownEntity? = null
|
|
|
|
|
- private var onConfirm: (AddUserDataVo) -> Unit = {}
|
|
|
|
|
|
|
+ private var selectedRoleData: MutableList<TextDropDownDialog.TextDropDownEntity>? =
|
|
|
|
|
+ mutableListOf()
|
|
|
|
|
+ private var selectedWorkstationData: MutableList<TextDropDownDialog.TextDropDownEntity>? =
|
|
|
|
|
+ mutableListOf()
|
|
|
|
|
+ private var onConfirm: (UpdateUserDataVo) -> Unit = {}
|
|
|
|
|
+ private var userId: Long = 0
|
|
|
|
|
|
|
|
init {
|
|
init {
|
|
|
- setContentView(R.layout.dialog_user_detail)
|
|
|
|
|
|
|
+ setContentView(R.layout.dialog_update_user)
|
|
|
textDropDownDialog = TextDropDownDialog(context)
|
|
textDropDownDialog = TextDropDownDialog(context)
|
|
|
textDropDownDialog.setWidthAsAnchorView(true)
|
|
textDropDownDialog.setWidthAsAnchorView(true)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun onViewCreated(contentView: View) {
|
|
override fun onViewCreated(contentView: View) {
|
|
|
super.onViewCreated(contentView)
|
|
super.onViewCreated(contentView)
|
|
|
- binding = DialogUserDetailBinding.bind(contentView)
|
|
|
|
|
|
|
+ binding = DialogUpdateUserBinding.bind(contentView)
|
|
|
|
|
+ binding.workstationLayout.isVisible = ISCSConfig.isWorkstationOn
|
|
|
binding.roleTv.setOnClickListener {
|
|
binding.roleTv.setOnClickListener {
|
|
|
textDropDownDialog.setData(roleData)
|
|
textDropDownDialog.setData(roleData)
|
|
|
- textDropDownDialog.setOnItemSelectListener {
|
|
|
|
|
- selectedRoleData = it
|
|
|
|
|
- binding.roleTv.text = it.getShowText()
|
|
|
|
|
|
|
+ textDropDownDialog.setOnItemMultiSelectListener {
|
|
|
|
|
+ selectedRoleData = it?.toMutableList()
|
|
|
|
|
+ if (it?.isEmpty() == true) {
|
|
|
|
|
+ binding.roleTv.text = ""
|
|
|
|
|
+ } else {
|
|
|
|
|
+ binding.roleTv.text = it?.joinToString(",") { it.getShowText() }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
textDropDownDialog.showPopupWindow(binding.roleTv)
|
|
textDropDownDialog.showPopupWindow(binding.roleTv)
|
|
|
}
|
|
}
|
|
|
binding.workstationNameTv.setOnClickListener {
|
|
binding.workstationNameTv.setOnClickListener {
|
|
|
textDropDownDialog.setData(workstationData)
|
|
textDropDownDialog.setData(workstationData)
|
|
|
- textDropDownDialog.setOnItemSelectListener {
|
|
|
|
|
- selectedWorkstationData = it
|
|
|
|
|
- binding.workstationNameTv.text = it.getShowText()
|
|
|
|
|
|
|
+ textDropDownDialog.setOnItemMultiSelectListener {
|
|
|
|
|
+ selectedWorkstationData = it?.toMutableList()
|
|
|
|
|
+ binding.workstationNameTv.text = it?.joinToString(",") { it.getShowText() }
|
|
|
}
|
|
}
|
|
|
textDropDownDialog.showPopupWindow(binding.workstationNameTv)
|
|
textDropDownDialog.showPopupWindow(binding.workstationNameTv)
|
|
|
}
|
|
}
|
|
@@ -52,20 +63,20 @@ class UserDetailDialog(context: Context) : BasePopupWindow(context) {
|
|
|
binding.closeIv.setOnClickListener { dismiss() }
|
|
binding.closeIv.setOnClickListener { dismiss() }
|
|
|
binding.confirm.setOnClickListener {
|
|
binding.confirm.setOnClickListener {
|
|
|
if (checkData()) {
|
|
if (checkData()) {
|
|
|
- val addUserData = AddUserDataVo(
|
|
|
|
|
|
|
+ val updateUserData = UpdateUserDataVo(
|
|
|
|
|
+ userId,
|
|
|
binding.nicknameEt.text.toString(),
|
|
binding.nicknameEt.text.toString(),
|
|
|
binding.cardcodeEt.text.toString(),
|
|
binding.cardcodeEt.text.toString(),
|
|
|
- selectedRoleData?.getId() ?: 0,
|
|
|
|
|
- selectedWorkstationData?.getId() ?: 0,
|
|
|
|
|
|
|
+ selectedRoleData?.map { it.getId() } ?: listOf(),
|
|
|
|
|
+ selectedWorkstationData?.map { it.getId() } ?: listOf(),
|
|
|
binding.statusRg.checkedRadioButtonId == binding.activateRb.id
|
|
binding.statusRg.checkedRadioButtonId == binding.activateRb.id
|
|
|
)
|
|
)
|
|
|
- onConfirm(addUserData)
|
|
|
|
|
|
|
+ onConfirm(updateUserData)
|
|
|
binding.nicknameEt.setText("")
|
|
binding.nicknameEt.setText("")
|
|
|
binding.cardcodeEt.setText("")
|
|
binding.cardcodeEt.setText("")
|
|
|
binding.roleTv.text = ""
|
|
binding.roleTv.text = ""
|
|
|
binding.workstationNameTv.text = ""
|
|
binding.workstationNameTv.text = ""
|
|
|
- binding.activateRb.isChecked = false
|
|
|
|
|
- binding.deactivateRb.isChecked = false
|
|
|
|
|
|
|
+ binding.statusRg.clearCheck()
|
|
|
dismiss()
|
|
dismiss()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -115,7 +126,7 @@ class UserDetailDialog(context: Context) : BasePopupWindow(context) {
|
|
|
/**
|
|
/**
|
|
|
* 设置确认监听
|
|
* 设置确认监听
|
|
|
*/
|
|
*/
|
|
|
- fun setOnConfirmListener(onConfirm: (AddUserDataVo) -> Unit) {
|
|
|
|
|
|
|
+ fun setOnConfirmListener(onConfirm: (UpdateUserDataVo) -> Unit) {
|
|
|
this.onConfirm = onConfirm
|
|
this.onConfirm = onConfirm
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -123,11 +134,24 @@ class UserDetailDialog(context: Context) : BasePopupWindow(context) {
|
|
|
* 设置用户数据
|
|
* 设置用户数据
|
|
|
*/
|
|
*/
|
|
|
fun setUserData(userData: UserManageVo) {
|
|
fun setUserData(userData: UserManageVo) {
|
|
|
|
|
+ userId = userData.userId
|
|
|
binding.nicknameEt.setText(userData.nickName)
|
|
binding.nicknameEt.setText(userData.nickName)
|
|
|
binding.cardcodeEt.setText(userData.cardCodes.joinToString(","))
|
|
binding.cardcodeEt.setText(userData.cardCodes.joinToString(","))
|
|
|
binding.roleTv.text = userData.roleNames.filter { it != null }.joinToString(",")
|
|
binding.roleTv.text = userData.roleNames.filter { it != null }.joinToString(",")
|
|
|
|
|
+ roleData.forEach {
|
|
|
|
|
+ if (userData.roleNames.contains(it.getShowText())) {
|
|
|
|
|
+ it.setSelected(userData.roleNames.contains(it.getShowText()))
|
|
|
|
|
+ selectedRoleData?.add(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
binding.workstationNameTv.text =
|
|
binding.workstationNameTv.text =
|
|
|
userData.workstationNames.filter { it != null }.joinToString(",")
|
|
userData.workstationNames.filter { it != null }.joinToString(",")
|
|
|
|
|
+ workstationData.forEach {
|
|
|
|
|
+ if (userData.workstationNames.contains(it.getShowText())) {
|
|
|
|
|
+ it.setSelected(userData.workstationNames.contains(it.getShowText()))
|
|
|
|
|
+ selectedWorkstationData?.add(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
binding.activateRb.isChecked = userData.getStatus()
|
|
binding.activateRb.isChecked = userData.getStatus()
|
|
|
binding.deactivateRb.isChecked = !userData.getStatus()
|
|
binding.deactivateRb.isChecked = !userData.getStatus()
|
|
|
}
|
|
}
|