|
|
|
|
@ -23,6 +23,7 @@ import com.project.survey.model.MeasureWorkStatusResult |
|
|
|
|
import com.project.survey.model.PointEntry |
|
|
|
|
import com.project.survey.model.ProjectBean |
|
|
|
|
import com.project.survey.network.RetrofitClient |
|
|
|
|
import com.project.survey.util.CommonUtils |
|
|
|
|
import com.project.survey.util.SPUtils |
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
@ -61,12 +62,15 @@ class ProjectViewModel : BaseViewModel() { |
|
|
|
|
// fun fetchProjectList(name: String? = null, code: String? = null) { |
|
|
|
|
fun fetchProjectList(searchContent: String? = null) { |
|
|
|
|
launch { |
|
|
|
|
var name: String? = null |
|
|
|
|
var code: String? = null |
|
|
|
|
if (CommonUtils.containsChinese(searchContent)) { |
|
|
|
|
name = searchContent |
|
|
|
|
} else { |
|
|
|
|
code = searchContent |
|
|
|
|
} |
|
|
|
|
val res = |
|
|
|
|
api.fetchProjectListByProperty( |
|
|
|
|
SPUtils.getString(SPConstants.PERSON_ID), |
|
|
|
|
searchContent, |
|
|
|
|
searchContent |
|
|
|
|
) |
|
|
|
|
api.fetchProjectListByProperty(SPUtils.getString(SPConstants.PERSON_ID), name, code) |
|
|
|
|
if (res.success) { |
|
|
|
|
_projectListResponse.postValue(res.data.records.map { it.values }) |
|
|
|
|
} else { |
|
|
|
|
@ -340,11 +344,10 @@ class ProjectViewModel : BaseViewModel() { |
|
|
|
|
) { |
|
|
|
|
launch { |
|
|
|
|
val res = api.downloadCoordinateSystem() |
|
|
|
|
if (res.success) { |
|
|
|
|
if (res.data.isNotEmpty()) |
|
|
|
|
withContext(Dispatchers.Main) { |
|
|
|
|
onSuccess(res.data[0].values) |
|
|
|
|
} |
|
|
|
|
if (res.success && res.data.isNotEmpty()) { |
|
|
|
|
withContext(Dispatchers.Main) { |
|
|
|
|
onSuccess(res.data[0].values) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
withContext(Dispatchers.Main) { |
|
|
|
|
onFailure(res.message) |
|
|
|
|
|