|
|
@@ -6,15 +6,19 @@ import com.drake.brv.BindingAdapter
|
|
|
import com.drake.brv.annotaion.DividerOrientation
|
|
|
import com.drake.brv.utils.divider
|
|
|
import com.drake.brv.utils.linear
|
|
|
+import com.drake.brv.utils.models
|
|
|
import com.drake.brv.utils.setup
|
|
|
-import com.grkj.data.data.DictConstants
|
|
|
import com.grkj.data.model.vo.IsExceptionStandardVo
|
|
|
import com.grkj.iscs.R
|
|
|
+import com.grkj.iscs.common.DataTransferConstants
|
|
|
import com.grkj.iscs.databinding.FragmentExceptionManageBinding
|
|
|
import com.grkj.iscs.databinding.ItemExceptionManageBinding
|
|
|
import com.grkj.iscs.features.main.viewmodel.exception_manage.ExceptionViewModel
|
|
|
import com.grkj.ui_base.base.BaseFragment
|
|
|
-import com.grkj.ui_base.business.DataBusiness
|
|
|
+import com.grkj.ui_base.dialog.TipDialog
|
|
|
+import com.kongzue.dialogx.dialogs.PopTip
|
|
|
+import com.sik.sikcore.data.GlobalDataTempStore
|
|
|
+import com.sik.sikcore.extension.setDebouncedClickListener
|
|
|
|
|
|
/**
|
|
|
* 异常管理界面
|
|
|
@@ -26,6 +30,21 @@ class ExceptionManageFragment : BaseFragment<FragmentExceptionManageBinding>() {
|
|
|
}
|
|
|
|
|
|
override fun initView() {
|
|
|
+ binding.back.setDebouncedClickListener { navController.popBackStack() }
|
|
|
+ binding.oneKeyHandle.setDebouncedClickListener {
|
|
|
+ viewModel.handleSelectedException().observe(this) {
|
|
|
+ if (it.first) {
|
|
|
+ TipDialog.showSuccess(getString(R.string.handle_exception_success))
|
|
|
+ } else {
|
|
|
+ TipDialog.showError(it.second)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ binding.oneKeyCancel.setDebouncedClickListener {
|
|
|
+ viewModel.cancelSelectedException().observe(this) {
|
|
|
+ TipDialog.showSuccess(getString(R.string.cancel_exception_success))
|
|
|
+ }
|
|
|
+ }
|
|
|
binding.listRv.linear().divider {
|
|
|
this.setColor(Color.BLACK)
|
|
|
this.startVisible = false
|
|
|
@@ -37,23 +56,50 @@ class ExceptionManageFragment : BaseFragment<FragmentExceptionManageBinding>() {
|
|
|
onRVListBinding(this)
|
|
|
}
|
|
|
}
|
|
|
+ setSelectAllListener()
|
|
|
}
|
|
|
|
|
|
- override fun initData() {
|
|
|
- super.initData()
|
|
|
-
|
|
|
+ override fun onResume() {
|
|
|
+ super.onResume()
|
|
|
+ getData()
|
|
|
}
|
|
|
|
|
|
private fun getData() {
|
|
|
+ viewModel.getDictData().observe(this) {
|
|
|
+ viewModel.getExceptionData().observe(this) {
|
|
|
+ binding.listRv.models = viewModel.exceptionDataList
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ private fun setSelectAllListener() {
|
|
|
+ binding.selectAll.setOnCheckedChangeListener { v, checked ->
|
|
|
+ viewModel.exceptionDataList.forEach { it.isSelected = checked }
|
|
|
+ binding.listRv.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun onRVListBinding(holder: BindingAdapter.BindingViewHolder) {
|
|
|
val itemBinding = holder.getBinding<ItemExceptionManageBinding>()
|
|
|
val item = holder.getModel<IsExceptionStandardVo>()
|
|
|
- itemBinding.exceptionType.text = DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_TYPE)
|
|
|
+ itemBinding.exceptionType.text = viewModel.exceptionType
|
|
|
.find { it.dictValue == item.exceptionType.toString() }?.dictLabel
|
|
|
|
|
|
-
|
|
|
+ itemBinding.exceptionStatus.text =
|
|
|
+ viewModel.exceptionStatus.find { it.dictValue == item.exceptionStatus.toString() }?.dictLabel
|
|
|
+ itemBinding.exceptionOccurrenceTime.text = item.createTime
|
|
|
+ itemBinding.select.setOnCheckedChangeListener(null)
|
|
|
+ itemBinding.select.isSelected = item.isSelected
|
|
|
+ itemBinding.select.setOnCheckedChangeListener { _, checked ->
|
|
|
+ item.isSelected = checked
|
|
|
+ binding.selectAll.setOnCheckedChangeListener(null)
|
|
|
+ binding.selectAll.isChecked = viewModel.exceptionDataList.all { it.isSelected }
|
|
|
+ setSelectAllListener()
|
|
|
+ }
|
|
|
+ itemBinding.root.setDebouncedClickListener {
|
|
|
+ GlobalDataTempStore.getInstance()
|
|
|
+ .saveData(DataTransferConstants.KEY_EXCEPTION_DATA, item)
|
|
|
+ navController.navigate(R.id.action_exceptionManageFragment_to_exceptionDetailFragment)
|
|
|
+ }
|
|
|
}
|
|
|
}
|