|
|
@@ -1,6 +1,7 @@
|
|
|
package com.grkj.iscs.view.fragment
|
|
|
|
|
|
import android.widget.ImageView
|
|
|
+import android.widget.LinearLayout
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.bumptech.glide.Glide
|
|
|
import com.grkj.iscs.R
|
|
|
@@ -21,6 +22,8 @@ class TechnologySopFragment :
|
|
|
BaseMvpFragment<ITechnologySopView, TechnologySopPresenter, FragmentTechnologySopBinding>() {
|
|
|
|
|
|
private val mMachineryList = mutableListOf<MachineryPageRespVO.Record>()
|
|
|
+ private var mMachineryIdx = -1
|
|
|
+ private var mSopTypeIdx = -1
|
|
|
|
|
|
override val viewBinding: FragmentTechnologySopBinding
|
|
|
get() = FragmentTechnologySopBinding.inflate(layoutInflater)
|
|
|
@@ -31,31 +34,55 @@ class TechnologySopFragment :
|
|
|
R.layout.item_rv_technology_sop,
|
|
|
mMachineryList
|
|
|
) {
|
|
|
- override fun convert(holder: ViewHolder, data: MachineryPageRespVO.Record?, position: Int) {
|
|
|
+ override fun convert(holder: ViewHolder, data: MachineryPageRespVO.Record?, parPos: Int) {
|
|
|
+ holder.getView<LinearLayout>(R.id.root).isSelected = parPos == mMachineryIdx
|
|
|
holder.setText(R.id.tv_name, data?.machineryName)
|
|
|
Glide.with(this@TechnologySopFragment).load(data?.machineryImg).into(holder.getView(R.id.iv_pic))
|
|
|
+ holder.setOnClickListener(R.id.root) {
|
|
|
+ if (mMachineryIdx != parPos) {
|
|
|
+ mSopTypeIdx = -1
|
|
|
+ }
|
|
|
+ mMachineryIdx = parPos
|
|
|
+ refreshSelected()
|
|
|
+ notifyDataSetChanged()
|
|
|
+ }
|
|
|
+
|
|
|
val recyclerView = holder.getView<RecyclerView>(R.id.rv_type)
|
|
|
recyclerView.adapter = object : CommonAdapter<MachineryPageRespVO.Record.SysDictData>(
|
|
|
requireActivity(),
|
|
|
R.layout.item_rv_technology_sop_type,
|
|
|
data?.sysDictDatas ?: mutableListOf()
|
|
|
) {
|
|
|
- override fun convert(holder: ViewHolder, type: MachineryPageRespVO.Record.SysDictData?, position: Int) {
|
|
|
+ override fun convert(holder: ViewHolder, type: MachineryPageRespVO.Record.SysDictData?, childPos: Int) {
|
|
|
+ holder.getView<LinearLayout>(R.id.root).isSelected = (childPos == mSopTypeIdx && parPos == mMachineryIdx)
|
|
|
type?.dictLabel?.let {
|
|
|
holder.setText(R.id.tv_name, it)
|
|
|
}
|
|
|
mSopTypeList.find { it.type.toString() == type?.dictValue }?.icon?.let { icon ->
|
|
|
holder.getView<ImageView>(R.id.iv_type).setImageResource(icon)
|
|
|
}
|
|
|
+ holder.setOnClickListener(R.id.root) {
|
|
|
+ mMachineryIdx = parPos
|
|
|
+ mSopTypeIdx = childPos
|
|
|
+ mBinding?.rvTechnology?.adapter?.notifyDataSetChanged()
|
|
|
+ refreshSelected()
|
|
|
+ notifyDataSetChanged()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- refreshPage(8)
|
|
|
+ // TODO 测试数据
|
|
|
+ refreshPage("本地测试工艺", 8)
|
|
|
+
|
|
|
+ mBinding?.cbStart?.setOnClickListener {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- fun refreshPage(workstationId: Int) {
|
|
|
+ fun refreshPage(title: String, workstationId: Int) {
|
|
|
+ mBinding?.tvTitle?.text = title
|
|
|
presenter?.getMachineryPage(workstationId) {
|
|
|
mMachineryList.clear()
|
|
|
it?.records?.let {
|
|
|
@@ -65,6 +92,20 @@ class TechnologySopFragment :
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun refreshSelected() {
|
|
|
+ val sopName = if (mMachineryIdx == -1) {
|
|
|
+ ""
|
|
|
+ } else {
|
|
|
+ "-${mMachineryList[mMachineryIdx].machineryName}"
|
|
|
+ }
|
|
|
+ val sopTypeName = if (mSopTypeIdx == -1) {
|
|
|
+ ""
|
|
|
+ } else {
|
|
|
+ "-${mMachineryList[mMachineryIdx].sysDictDatas?.get(mSopTypeIdx)?.dictLabel}"
|
|
|
+ }
|
|
|
+ mBinding?.tvSelected?.text = getString(R.string.current_sop, "${mBinding?.tvTitle?.text}$sopName$sopTypeName")
|
|
|
+ }
|
|
|
+
|
|
|
override fun initPresenter(): TechnologySopPresenter {
|
|
|
return TechnologySopPresenter()
|
|
|
}
|