|
|
@@ -1,8 +1,13 @@
|
|
|
package com.grkj.iscs.view.fragment
|
|
|
|
|
|
+import android.view.View
|
|
|
import com.grkj.iscs.R
|
|
|
import com.grkj.iscs.databinding.FragmentExceptionReportBinding
|
|
|
import com.grkj.iscs.model.vo.dict.CommonDictRespVO
|
|
|
+import com.grkj.iscs.model.vo.hardware.JobCardPageItem
|
|
|
+import com.grkj.iscs.model.vo.hardware.RfidTokenPageItem
|
|
|
+import com.grkj.iscs.model.vo.key.KeyPageItem
|
|
|
+import com.grkj.iscs.model.vo.lock.LockPageItem
|
|
|
import com.grkj.iscs.util.ToastUtils
|
|
|
import com.grkj.iscs.view.base.BaseMvpFragment
|
|
|
import com.grkj.iscs.view.iview.IExceptionReportView
|
|
|
@@ -19,6 +24,11 @@ class ExceptionReportFragment :
|
|
|
private val mLevelList = mutableListOf<CommonDictRespVO>()
|
|
|
private var mTypeIdx = -1 // 选中的类型
|
|
|
private var mLevelIdx = -1 // 选中的等级
|
|
|
+ private var mSelectDeviceId = ""
|
|
|
+ private var mKeyList: MutableList<KeyPageItem> = mutableListOf()
|
|
|
+ private var mLockList: MutableList<LockPageItem> = mutableListOf()
|
|
|
+ private var mJobCardList: MutableList<JobCardPageItem> = mutableListOf()
|
|
|
+ private var mRfidList: MutableList<RfidTokenPageItem> = mutableListOf()
|
|
|
|
|
|
override val viewBinding: FragmentExceptionReportBinding
|
|
|
get() = FragmentExceptionReportBinding.inflate(layoutInflater)
|
|
|
@@ -40,13 +50,109 @@ class ExceptionReportFragment :
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- mBinding?.siType?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
|
|
|
+ mBinding?.siType?.setOnSpinnerSelectListener(object :
|
|
|
+ SelectableInput.OnSpinnerSelectListener {
|
|
|
override fun onSelect(str: String?, index: Int) {
|
|
|
+ mSelectDeviceId = ""
|
|
|
mTypeIdx = index
|
|
|
+ when (str) {
|
|
|
+ "钥匙异常" -> {
|
|
|
+ mBinding?.siDevice?.visibility = View.VISIBLE
|
|
|
+ mBinding?.siDevice?.setTitle(getString(R.string.exception_report_hardware_key))
|
|
|
+ presenter?.getKeyPage {
|
|
|
+ mKeyList.clear()
|
|
|
+ mKeyList.addAll(it?.records ?: mutableListOf())
|
|
|
+ if (mKeyList.isEmpty()){
|
|
|
+ mBinding?.siDevice?.setOptionList(mutableListOf())
|
|
|
+ }
|
|
|
+ mBinding?.siDevice?.setOptionList(mKeyList.map { "${it.keyName}(${it.keyNfc})" }
|
|
|
+ ?.toMutableList() ?: mutableListOf())
|
|
|
+ }
|
|
|
+ mBinding?.siDevice?.setOnSpinnerSelectListener(object :
|
|
|
+ SelectableInput.OnSpinnerSelectListener {
|
|
|
+ override fun onSelect(str: String?, index: Int) {
|
|
|
+ mSelectDeviceId =
|
|
|
+ mKeyList.find { it.keyNfc?.let { it1 -> str?.contains(it1) } == true }?.keyId
|
|
|
+ ?: ""
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ "挂锁异常" -> {
|
|
|
+ mBinding?.siDevice?.visibility = View.VISIBLE
|
|
|
+ mBinding?.siDevice?.setTitle(getString(R.string.exception_report_hardware_lock))
|
|
|
+ presenter?.getLockPage {
|
|
|
+ mLockList.clear()
|
|
|
+ mLockList.addAll(it?.records ?: mutableListOf())
|
|
|
+ if (mLockList.isEmpty()){
|
|
|
+ mBinding?.siDevice?.setOptionList(mutableListOf())
|
|
|
+ }
|
|
|
+ mBinding?.siDevice?.setOptionList(mLockList.map { "${it.lockName}(${it.lockNfc})" }
|
|
|
+ ?.toMutableList() ?: mutableListOf())
|
|
|
+ }
|
|
|
+ mBinding?.siDevice?.setOnSpinnerSelectListener(object :
|
|
|
+ SelectableInput.OnSpinnerSelectListener {
|
|
|
+ override fun onSelect(str: String?, index: Int) {
|
|
|
+ mSelectDeviceId =
|
|
|
+ mLockList.find { it.lockNfc?.let { it1 -> str?.contains(it1) } == true }?.lockId
|
|
|
+ ?: ""
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ "工卡异常" -> {
|
|
|
+ mBinding?.siDevice?.visibility = View.VISIBLE
|
|
|
+ mBinding?.siDevice?.setTitle(getString(R.string.exception_report_hardware_job_card))
|
|
|
+ presenter?.getJobCardPage {
|
|
|
+ mJobCardList.clear()
|
|
|
+ mJobCardList.addAll(it?.records?.filter { it.nickName != null }
|
|
|
+ ?.toMutableList() ?: mutableListOf())
|
|
|
+ if (mJobCardList.isEmpty()){
|
|
|
+ mBinding?.siDevice?.setOptionList(mutableListOf())
|
|
|
+ }
|
|
|
+ mBinding?.siDevice?.setOptionList(mJobCardList.map { "${it.cardCode}(${it.cardNfc})" }.toMutableList() ?: mutableListOf())
|
|
|
+ }
|
|
|
+ mBinding?.siDevice?.setOnSpinnerSelectListener(object :
|
|
|
+ SelectableInput.OnSpinnerSelectListener {
|
|
|
+ override fun onSelect(str: String?, index: Int) {
|
|
|
+ mSelectDeviceId =
|
|
|
+ mJobCardList.find { it.cardNfc?.let { it1 -> str?.contains(it1) } == true }?.cardId
|
|
|
+ ?: ""
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ "RFID异常" -> {
|
|
|
+ mBinding?.siDevice?.visibility = View.VISIBLE
|
|
|
+ mBinding?.siDevice?.setTitle(getString(R.string.exception_report_hardware_rfid_point))
|
|
|
+ presenter?.getRfidTokenPage {
|
|
|
+ mRfidList.clear()
|
|
|
+ mRfidList.addAll(it?.records ?: mutableListOf())
|
|
|
+ if (mRfidList.isEmpty()){
|
|
|
+ mBinding?.siDevice?.setOptionList(mutableListOf())
|
|
|
+ }
|
|
|
+ mBinding?.siDevice?.setOptionList(mRfidList.map { "${it.rfidCode}(${it.rfid})" }
|
|
|
+ ?.toMutableList() ?: mutableListOf())
|
|
|
+ }
|
|
|
+ mBinding?.siDevice?.setOnSpinnerSelectListener(object :
|
|
|
+ SelectableInput.OnSpinnerSelectListener {
|
|
|
+ override fun onSelect(str: String?, index: Int) {
|
|
|
+ mSelectDeviceId =
|
|
|
+ mRfidList.find { it.rfid?.let { it1 -> str?.contains(it1) } == true }?.rfidId
|
|
|
+ ?: ""
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ else -> {
|
|
|
+ mBinding?.siDevice?.visibility = View.GONE
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- mBinding?.siLevel?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
|
|
|
+ mBinding?.siLevel?.setOnSpinnerSelectListener(object :
|
|
|
+ SelectableInput.OnSpinnerSelectListener {
|
|
|
override fun onSelect(str: String?, index: Int) {
|
|
|
mLevelIdx = index
|
|
|
}
|
|
|
@@ -61,10 +167,15 @@ class ExceptionReportFragment :
|
|
|
ToastUtils.tip(R.string.exception_level_tip)
|
|
|
return@setOnClickListener
|
|
|
}
|
|
|
+ if (mBinding?.siDevice?.visibility == View.VISIBLE && mSelectDeviceId.isEmpty()) {
|
|
|
+ ToastUtils.tip(R.string.exception_select_hardware_tip)
|
|
|
+ return@setOnClickListener
|
|
|
+ }
|
|
|
presenter?.insertException(
|
|
|
mBinding?.siDescription?.getText(),
|
|
|
mLevelList[mLevelIdx].dictValue!!,
|
|
|
- mExceptionList[mTypeIdx].dictValue!!
|
|
|
+ mExceptionList[mTypeIdx].dictValue!!,
|
|
|
+ mSelectDeviceId
|
|
|
) {
|
|
|
ToastUtils.tip(R.string.exception_submit_success_tip)
|
|
|
}
|