update values of itemcard
This commit is contained in:
parent
853b20a7cd
commit
5761dd4144
|
@ -21,4 +21,20 @@ class GetItemCardUserCase : RestClient() {
|
|||
params.add(isTrash)
|
||||
return restClient!!.itemStockUpdate("json","1",usuario,password,"application/json",params = params)!!
|
||||
}
|
||||
|
||||
fun itemPlacementSave(usuario:String,password:String,itemFk:String,warehouseFk:String,value:String ) : Call<String> {
|
||||
val params:ArrayList<String> = ArrayList();
|
||||
params.add(itemFk)
|
||||
params.add(warehouseFk)
|
||||
params.add(value)
|
||||
return restClient!!.itemPlacementSave("json","1",usuario,password,"application/json",params = params)!!
|
||||
}
|
||||
|
||||
fun updateGrouping(usuario:String,password:String,itemFk:String,value:String ,warehouseFk:String) : Call<String> {
|
||||
val params:ArrayList<String> = ArrayList();
|
||||
params.add(itemFk)
|
||||
params.add(value)
|
||||
params.add(warehouseFk)
|
||||
return restClient!!.updateGrouping("json","1",usuario,password,"application/json",params = params)!!
|
||||
}
|
||||
}
|
|
@ -59,4 +59,22 @@ interface VerdnaturaService {
|
|||
@Body params: List<String>):
|
||||
Call<String>
|
||||
|
||||
@POST("almacenv2/item_placement_save")
|
||||
fun itemPlacementSave(@Header("aplicacion") aplicacion: String,
|
||||
@Header("version") version: String,
|
||||
@Header("user") user: String,
|
||||
@Header("pass") pass: String,
|
||||
@Header("Content-Type") content_type: String,
|
||||
@Body params: List<String>):
|
||||
Call<String>
|
||||
|
||||
@POST("almacenv2/buy_updateGrouping")
|
||||
fun updateGrouping(@Header("aplicacion") aplicacion: String,
|
||||
@Header("version") version: String,
|
||||
@Header("user") user: String,
|
||||
@Header("pass") pass: String,
|
||||
@Header("Content-Type") content_type: String,
|
||||
@Body params: List<String>):
|
||||
Call<String>
|
||||
|
||||
}
|
|
@ -35,6 +35,8 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
|
|||
private var password = ""
|
||||
private var warehouseFk = ""
|
||||
private var itemFk = ""
|
||||
private var adapter : ItemCardAdapter? = null
|
||||
private var listItemsRow:ArrayList<ItemCardRowVO> = ArrayList()
|
||||
|
||||
companion object {
|
||||
fun newInstance() = ItemCardFragment()
|
||||
|
@ -122,8 +124,6 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
|
|||
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
|
||||
customDialog.hide()
|
||||
}.show()
|
||||
}else{
|
||||
this@ItemCardFragment.getItemCard(itemFk)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -139,25 +139,25 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
|
|||
itemcard_tag2.text = itemInfo.value5
|
||||
itemcard_tag3.text = itemInfo.value6
|
||||
itemcard_tag4.text = itemInfo.value7 + " " + itemInfo.origin
|
||||
val listItemsRow:ArrayList<ItemCardRowVO> = ArrayList()
|
||||
listItemsRow = ArrayList()
|
||||
listItemsRow.add(ItemCardRowVO(title = "Total",value = itemInfo.total,isEditable = false))
|
||||
listItemsRow.add(ItemCardRowVO(title = "Disponible",value = itemInfo.available,isEditable = false))
|
||||
listItemsRow.add(ItemCardRowVO(title = "Ubicado",value = itemInfo.enAltillo,isEditable = false))
|
||||
//EDITABLES
|
||||
|
||||
listItemsRow.add(ItemCardRowVO(title = "SIN UBICAR",value = itemInfo.enNicho,isEditable = true, action = "itemStockUpdate"))
|
||||
listItemsRow.add(ItemCardRowVO(title = "NICHO",value = itemInfo.nicho,isEditable = true))
|
||||
listItemsRow.add(ItemCardRowVO(title = "RESERVA",value = itemInfo.reserva,isEditable = true))
|
||||
listItemsRow.add(ItemCardRowVO(title = "GROUPING",value = itemInfo.grouping,isEditable = true))
|
||||
listItemsRow.add(ItemCardRowVO(title = "NICHO",value = itemInfo.nicho,isEditable = true, action = "itemPlacementSave"))
|
||||
listItemsRow.add(ItemCardRowVO(title = "RESERVA",value = itemInfo.reserva,isEditable = true, action = "itemPlacementSave"))
|
||||
listItemsRow.add(ItemCardRowVO(title = "GROUPING",value = itemInfo.grouping,isEditable = true, action = "updateGrouping"))
|
||||
listItemsRow.add(ItemCardRowVO(title = "PACKING",value = itemInfo.packing,isEditable = true))
|
||||
listItemsRow.add(ItemCardRowVO(title = "MINIMO",value = itemInfo.min,isEditable = true))
|
||||
listItemsRow.add(ItemCardRowVO(title = "BARCODE",barcodes = itemInfo.barcodes,isEditable = true))
|
||||
|
||||
itemcard_recyclerview.adapter = ItemCardAdapter(listItemsRow,object: OnItemCardRowClickListener{
|
||||
adapter = ItemCardAdapter(listItemsRow,object: OnItemCardRowClickListener{
|
||||
override fun onItemCardRowClickListener(item: ItemCardRowVO) {
|
||||
customDialogInput.setTitle(item.title!!).setDescription("Valor actual: "+item.value!!).setOkButton("Guardar"){
|
||||
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||
editItemCardRow(item.action!!,customDialogInput.getValue())
|
||||
editItemCardRow(item,customDialogInput.getValue())
|
||||
customDialogInput.hide()
|
||||
|
||||
}.setKoButton("Cancelar"){
|
||||
|
@ -168,7 +168,7 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
|
|||
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
if (!customDialogInput.getValue().isNullOrEmpty())
|
||||
editItemCardRow(item.action!!,customDialogInput.getValue())
|
||||
editItemCardRow(item,customDialogInput.getValue())
|
||||
customDialogInput.setValue("")
|
||||
customDialogInput.hide()
|
||||
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
|
||||
|
@ -178,6 +178,7 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
|
|||
}
|
||||
}
|
||||
})
|
||||
itemcard_recyclerview.adapter = adapter
|
||||
itemcard_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
scroll_view.post(Runnable {
|
||||
|
@ -189,12 +190,27 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
|
|||
|
||||
}
|
||||
|
||||
private fun editItemCardRow(action:String,value:String){
|
||||
splash_progress.visibility = View.VISIBLE
|
||||
when (action){
|
||||
private fun editItemCardRow(item:ItemCardRowVO,value:String){
|
||||
|
||||
when (item.action){
|
||||
"itemStockUpdate" -> viewModel.itemStockUpdate(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0")
|
||||
|
||||
"itemPlacementSave" -> viewModel.itemPlacementSave(itemFk = itemFk, warehouseFk = warehouseFk, user = user, password = password, value = value)
|
||||
"updateGrouping" -> viewModel.updateGrouping(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk)
|
||||
}
|
||||
changeOfflineValue(item,value)
|
||||
}
|
||||
|
||||
private fun changeOfflineValue(item:ItemCardRowVO,newValue:String){
|
||||
var i = 0
|
||||
var position = 0
|
||||
listItemsRow.forEach {
|
||||
if (it.title == item.title) {
|
||||
position = i
|
||||
}
|
||||
i = i.plus(1)
|
||||
}
|
||||
listItemsRow.get(position).value = newValue
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,4 +58,40 @@ class ItemCardViewModel : BaseViewModel() {
|
|||
|
||||
})
|
||||
}
|
||||
|
||||
fun itemPlacementSave(itemFk:String,warehouseFk:String,user:String,password:String,value:String){
|
||||
getItemCardUserCase.itemPlacementSave(user,password,itemFk,warehouseFk,value).enqueue(object : Callback<String>{
|
||||
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||
_response.value = ResponseItemVO(isError = true,errorMessage = t.message!!)
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||
if (response.body() == null){
|
||||
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate")
|
||||
}else{
|
||||
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun updateGrouping(itemFk:String,user:String,password:String,value:String,warehouseFk: String){
|
||||
getItemCardUserCase.updateGrouping(user,password,itemFk,value,warehouseFk).enqueue(object : Callback<String>{
|
||||
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||
_response.value = ResponseItemVO(isError = true,errorMessage = t.message!!)
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||
if (response.body() == null){
|
||||
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate")
|
||||
}else{
|
||||
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue