package com.xw.yunwei.ui.work.site import android.app.Application import androidx.lifecycle.MutableLiveData import com.xw.common.base.BaseViewModel import com.xw.yunwei.model.FenceInfoModel import com.xw.yunwei.model.SiteModel import com.xw.yunwei.net.WorkRepository import org.koin.core.component.inject class SiteNavVM(application: Application) : BaseViewModel(application) { val workRepository: WorkRepository by inject() val filterStatus = listOf( "全部", "启用中", "已停用", "失效" ) val selectStatus = mutableListOf(filterStatus[0]) val dataList: MutableLiveData> = MutableLiveData() var siteItem: MutableLiveData = MutableLiveData() // 站点详情 var fences: MutableLiveData> = MutableLiveData() // 站点详情 val search = MutableLiveData("") var cityCode: String = "" fun query() { launchRequest { val map = mutableMapOf() // 运营状态 1=待启用 2=启用中 3=已停用 4=已失效 // map["operationStatus"] = // if (selectStatus.isNotEmpty()) selectStatus.map { filterStatus.indexOf(it) + 1 } // .joinToString(",") else null map["operationStatus"] = if(selectStatus.getOrNull(0) == filterStatus[0]) null else "${filterStatus.indexOf(selectStatus.getOrNull(0))+1}" // map["operationStatus"] = if (selectStatus.isEmpty()) null else filterStatus.indexOf(selectStatus[0]) + 1 // map["pointType"] = null // 点位类型1运营点位 2测试点位 map["queryParams"] = search.value // 查询参数 map["cityCode"] = cityCode workRepository.querySites(map)?.let { dataList.postValue(it) } } } fun getFenceByCode(){ launchRequest(showLoading = false) { workRepository.getFenceByCode(cityCode)?.let { fences.postValue(it) } } } }