package cn.flightfeather.thirdapp.module.inspection
|
|
import android.arch.lifecycle.MutableLiveData
|
import cn.flightfeather.thirdapp.bean.LastSubtaskPack
|
import cn.flightfeather.thirdapp.bean.Subtask
|
import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo
|
import cn.flightfeather.thirdapp.common.net.ResultCallBack
|
import cn.flightfeather.thirdapp.module.base.BaseViewModel
|
import cn.flightfeather.thirdapp.repository.InspectionRepository
|
import cn.flightfeather.thirdapp.util.DateFormatter
|
|
/**
|
* @author riku
|
* Date: 2019/8/1
|
*/
|
class BaseProblemListViewModel : BaseViewModel() {
|
|
private val inspectionRepository = InspectionRepository()
|
|
var problemList = MutableLiveData<ArrayList<ProblemlistVo>>().apply { value = ArrayList() }
|
|
var subTaskPack = MutableLiveData<LastSubtaskPack>()
|
|
/**
|
* 获取问题列表
|
*/
|
fun getProblems(inspectionId: String?) {
|
inspectionId?.let {
|
inspectionRepository.getProblemList(it, object : ResultCallBack<List<ProblemlistVo>> {
|
override fun onSuccess(result: List<ProblemlistVo>?) {
|
result?.let {
|
problemList.value?.clear()
|
|
problemList.value?.addAll(ArrayList<ProblemlistVo>().apply {
|
addAll(it)
|
})
|
|
problemList.value = problemList.value
|
}
|
}
|
|
override fun onFailure() {
|
|
}
|
|
})
|
}
|
|
}
|
|
/**
|
* 获取上次任务的问题列表
|
*/
|
fun getLastProblems(subTask: Subtask?) {
|
subTask?.let { subtask ->
|
val dateStr = DateFormatter.dateTimeFormat2.format(subtask.executionstarttime)
|
inspectionRepository.getLastProblemList(subtask.scenseid, dateStr, object : ResultCallBack<LastSubtaskPack> {
|
override fun onSuccess(result: LastSubtaskPack?) {
|
result?.let {
|
subTaskPack.value = it
|
}
|
}
|
|
override fun onFailure() {
|
}
|
|
})
|
}
|
}
|
}
|