|
|
@@ -1,14 +1,17 @@
|
|
|
package com.grkj.iscs_mc.view.fragment
|
|
|
|
|
|
-import android.view.View
|
|
|
+import com.bumptech.glide.Glide
|
|
|
import com.grkj.iscs_mc.R
|
|
|
import com.grkj.iscs_mc.databinding.FragmentMaterialManualReplacementBinding
|
|
|
import com.grkj.iscs_mc.extentions.navigateUp
|
|
|
+import com.grkj.iscs_mc.model.vo.material.MaterialPropertyValuePageRespVO
|
|
|
+import com.grkj.iscs_mc.model.vo.material.MaterialTypePageRespVO
|
|
|
import com.grkj.iscs_mc.model.vo.replacement.ManualReplacementListRespVO
|
|
|
import com.grkj.iscs_mc.view.base.BaseMvpFragment
|
|
|
import com.grkj.iscs_mc.view.iview.IMaterialManualReplacementView
|
|
|
import com.grkj.iscs_mc.view.presenter.MaterialManualReplacementPresenter
|
|
|
import com.grkj.iscs_mc.view.widget.ExpandableTabLayout
|
|
|
+import com.grkj.iscs_mc.view.widget.SelectableInput
|
|
|
import com.zhy.adapter.recyclerview.CommonAdapter
|
|
|
import com.zhy.adapter.recyclerview.base.ViewHolder
|
|
|
|
|
|
@@ -18,8 +21,10 @@ import com.zhy.adapter.recyclerview.base.ViewHolder
|
|
|
class MaterialManualReplacementFragment :
|
|
|
BaseMvpFragment<IMaterialManualReplacementView, MaterialManualReplacementPresenter, FragmentMaterialManualReplacementBinding>() {
|
|
|
|
|
|
- private val mTypeList = mutableListOf<ManualReplacementListRespVO>()
|
|
|
+ private val mMaterialList = mutableListOf<ManualReplacementListRespVO>()
|
|
|
private val mDetailList = mutableListOf<ManualReplacementListRespVO.MaterialsPageVO>()
|
|
|
+ private val mTypeList = mutableListOf<MaterialTypePageRespVO.Record>()
|
|
|
+ private val mPropertyList = mutableListOf<MaterialPropertyValuePageRespVO.Record>()
|
|
|
|
|
|
override val viewBinding: FragmentMaterialManualReplacementBinding
|
|
|
get() = FragmentMaterialManualReplacementBinding.inflate(layoutInflater)
|
|
|
@@ -38,14 +43,64 @@ class MaterialManualReplacementFragment :
|
|
|
vo: ManualReplacementListRespVO.MaterialsPageVO,
|
|
|
position: Int
|
|
|
) {
|
|
|
+ // 旧
|
|
|
+ holder.getView<SelectableInput>(R.id.ci_name_old).setText(vo.materialsName)
|
|
|
+ holder.getView<SelectableInput>(R.id.ci_type_old)
|
|
|
+ .setText(mTypeList.find { it.materialsTypeId == vo.materialsTypeId }?.materialsTypeName)
|
|
|
+ holder.getView<SelectableInput>(R.id.ci_model_old)
|
|
|
+ .setText(mPropertyList.find { it.recordId.toString() == vo.propertiesValueId }?.valueName)
|
|
|
+ holder.getView<SelectableInput>(R.id.ci_rfid_old).setText(vo.materialsRfid)
|
|
|
+ holder.getView<SelectableInput>(R.id.ci_date_old).setText(vo.expirationDate)
|
|
|
+ Glide.with(this@MaterialManualReplacementFragment).load(vo.materialsTypePicture)
|
|
|
+ .into(holder.getView(R.id.iv_old))
|
|
|
|
|
|
+ // 新
|
|
|
+ holder.getView<SelectableInput>(R.id.ci_name_new).setText(vo.materialsName)
|
|
|
+
|
|
|
+ // 类型
|
|
|
+ val ciType = holder.getView<SelectableInput>(R.id.ci_type_new)
|
|
|
+ ciType.setOptionList(mTypeList.map { it.materialsTypeName!! }.toMutableList())
|
|
|
+ ciType.setText(mTypeList.find { it.materialsTypeId == vo.selectedTypeId }?.materialsTypeName)
|
|
|
+ ciType.setOnSpinnerSelectListener(object :
|
|
|
+ SelectableInput.OnSpinnerSelectListener {
|
|
|
+ override fun onSelect(str: String?, index: Int) {
|
|
|
+ if (vo.selectedTypeId != mTypeList[index].materialsTypeId) {
|
|
|
+ vo.selectedModelId = null
|
|
|
+ }
|
|
|
+ vo.selectedTypeId = mTypeList[index].materialsTypeId
|
|
|
+ mBinding?.rvReplacement?.adapter?.notifyItemChanged(position)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 型号
|
|
|
+ val ciModel = holder.getView<SelectableInput>(R.id.ci_model_new)
|
|
|
+ ciModel.setOptionList(mPropertyList
|
|
|
+ .filter {
|
|
|
+ it.propertyId.toString() ==
|
|
|
+ mTypeList.find { it.materialsTypeId == vo.selectedTypeId }?.propertyIds
|
|
|
+ }
|
|
|
+ .map { it.valueName!! }
|
|
|
+ .toMutableList())
|
|
|
+ ciModel.setText(mPropertyList.find { it.recordId == vo.selectedModelId }?.valueName)
|
|
|
+ ciModel.setOnSpinnerSelectListener(object :
|
|
|
+ SelectableInput.OnSpinnerSelectListener {
|
|
|
+ override fun onSelect(str: String?, index: Int) {
|
|
|
+ vo.selectedModelId = mPropertyList[index].recordId
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ holder.getView<SelectableInput>(R.id.ci_rfid_new).setText(vo.materialsRfid)
|
|
|
+ holder.getView<SelectableInput>(R.id.ci_date_new).setText(vo.expirationDate)
|
|
|
+ Glide.with(this@MaterialManualReplacementFragment)
|
|
|
+ .load(mTypeList.find { it.materialsTypeId == vo.selectedTypeId }?.materialsTypePicture)
|
|
|
+ .into(holder.getView(R.id.iv_new))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
mBinding?.etlType?.setOnSelectListener(object : ExpandableTabLayout.OnSelectListener {
|
|
|
override fun onSelect(position: Int) {
|
|
|
mDetailList.clear()
|
|
|
- mTypeList[position].materials?.let {
|
|
|
+ mMaterialList[position].materials?.let {
|
|
|
mDetailList.addAll(it)
|
|
|
}
|
|
|
mBinding?.rvReplacement?.adapter?.notifyDataSetChanged()
|
|
|
@@ -54,22 +109,45 @@ class MaterialManualReplacementFragment :
|
|
|
|
|
|
presenter?.getManualReplacementList {
|
|
|
it?.let {
|
|
|
- mTypeList.addAll(it)
|
|
|
+ mMaterialList.addAll(it)
|
|
|
}
|
|
|
val list = mutableListOf<ExpandableTabLayout.ItemData>()
|
|
|
it?.forEach { itData ->
|
|
|
- list.add(ExpandableTabLayout.ItemData("${itData.materialsTypeName}(${itData.exNumber})", iconUrl = itData.materialsTypeIcon))
|
|
|
+ list.add(
|
|
|
+ ExpandableTabLayout.ItemData(
|
|
|
+ "${itData.materialsTypeName}(${itData.exNumber})",
|
|
|
+ iconUrl = itData.materialsTypeIcon
|
|
|
+ )
|
|
|
+ )
|
|
|
}
|
|
|
mBinding?.etlType?.setData(list)
|
|
|
|
|
|
mDetailList.clear()
|
|
|
- if (mTypeList.isNotEmpty()) {
|
|
|
- mTypeList[0].materials?.let {
|
|
|
+ if (mMaterialList.isNotEmpty()) {
|
|
|
+ mMaterialList[0].materials?.let {
|
|
|
mDetailList.addAll(it)
|
|
|
}
|
|
|
+ mDetailList.forEach {
|
|
|
+ it.selectedTypeId = it.materialsTypeId
|
|
|
+ it.selectedModelId = it.propertiesValueId?.toLong()
|
|
|
+ }
|
|
|
}
|
|
|
mBinding?.rvReplacement?.adapter?.notifyDataSetChanged()
|
|
|
}
|
|
|
+
|
|
|
+ presenter?.getMaterialType {
|
|
|
+ if (!it?.records.isNullOrEmpty()) {
|
|
|
+ mTypeList.addAll(it?.records!!)
|
|
|
+ mBinding?.rvReplacement?.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ presenter?.getMaterialProperty {
|
|
|
+ if (!it.isNullOrEmpty()) {
|
|
|
+ mPropertyList.addAll(it)
|
|
|
+ mBinding?.rvReplacement?.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun initPresenter(): MaterialManualReplacementPresenter {
|