|
|
@@ -1,5 +1,6 @@
|
|
|
package com.grkj.iscs_mc.view.presenter
|
|
|
|
|
|
+import com.grkj.iscs_mc.R
|
|
|
import com.grkj.iscs_mc.extentions.serialNo
|
|
|
import com.grkj.iscs_mc.model.vo.material.MaterialManualReplacementReqVO
|
|
|
import com.grkj.iscs_mc.model.vo.material.MaterialPropertyValuePageRespVO
|
|
|
@@ -7,6 +8,7 @@ import com.grkj.iscs_mc.model.vo.material.MaterialTypePageRespVO
|
|
|
import com.grkj.iscs_mc.model.vo.replacement.ManualReplacementListRespVO
|
|
|
import com.grkj.iscs_mc.util.Executor
|
|
|
import com.grkj.iscs_mc.util.NetApi
|
|
|
+import com.grkj.iscs_mc.util.ToastUtils
|
|
|
import com.grkj.iscs_mc.view.base.BasePresenter
|
|
|
import com.grkj.iscs_mc.view.iview.IMaterialManualReplacementView
|
|
|
|
|
|
@@ -36,8 +38,63 @@ class MaterialManualReplacementPresenter : BasePresenter<IMaterialManualReplacem
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fun manualReplacement(list: MutableList<MaterialManualReplacementReqVO>, callBack: (Boolean) -> Unit) {
|
|
|
- NetApi.manualReplacement(list) {
|
|
|
+ fun checkData(vo: ManualReplacementListRespVO.MaterialsPageVO): Boolean {
|
|
|
+ if (vo.newName.isNullOrEmpty()) {
|
|
|
+ ToastUtils.tip(R.string.manual_replacement_name_check_tip)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (vo.selectedTypeId == null) {
|
|
|
+ ToastUtils.tip(R.string.manual_replacement_type_check_tip)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (vo.selectedModelId == null) {
|
|
|
+ ToastUtils.tip(R.string.manual_replacement_mode_check_tip)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (vo.newRfid.isNullOrEmpty()) {
|
|
|
+ ToastUtils.tip(R.string.manual_replacement_mode_rfid_tip)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!vo.isValidNewDate()) {
|
|
|
+ ToastUtils.tip(R.string.manual_replacement_mode_date_tip)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ fun submit(
|
|
|
+ list: MutableList<ManualReplacementListRespVO>,
|
|
|
+ propertyList: MutableList<MaterialPropertyValuePageRespVO.Record>,
|
|
|
+ callBack: (Boolean) -> Unit
|
|
|
+ ) {
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ val filterList = list.flatMap { it.materials ?: emptyList() }
|
|
|
+ .filter { it.isDone } // 只提交保存的
|
|
|
+ .distinctBy { it.materialsId } // 不同tab页数据去重
|
|
|
+ .toMutableList()
|
|
|
+ if (filterList.isEmpty()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ val submitList = mutableListOf<MaterialManualReplacementReqVO>()
|
|
|
+ filterList.forEach { itFilter ->
|
|
|
+ val property = propertyList.find { it.recordId == itFilter.selectedModelId }
|
|
|
+ submitList.add(
|
|
|
+ MaterialManualReplacementReqVO(
|
|
|
+ itFilter.materialsId,
|
|
|
+ itFilter.newName,
|
|
|
+ itFilter.selectedTypeId,
|
|
|
+ property?.recordId?.toString(),
|
|
|
+ property?.valueName,
|
|
|
+ property?.propertyId?.toString(),
|
|
|
+ property?.propertyName,
|
|
|
+ itFilter.newRfid,
|
|
|
+ itFilter.newDate,
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ NetApi.manualReplacement(submitList) {
|
|
|
Executor.runOnMain {
|
|
|
callBack(it)
|
|
|
}
|
|
|
@@ -47,7 +104,10 @@ class MaterialManualReplacementPresenter : BasePresenter<IMaterialManualReplacem
|
|
|
/**
|
|
|
* 同步不同tab标签的数据
|
|
|
*/
|
|
|
- fun syncData(list: MutableList<ManualReplacementListRespVO>, material: ManualReplacementListRespVO.MaterialsPageVO) {
|
|
|
+ fun syncData(
|
|
|
+ list: MutableList<ManualReplacementListRespVO>,
|
|
|
+ material: ManualReplacementListRespVO.MaterialsPageVO
|
|
|
+ ) {
|
|
|
list.forEach {
|
|
|
it.materials?.find { it.materialsId == material.materialsId }?.let { itVO ->
|
|
|
itVO.newName = material.newName
|