|
|
@@ -3,8 +3,7 @@ package cn.muchinfo.rma.view.base.home.commodity.newcommodity
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
import androidx.viewpager.widget.ViewPager
|
|
|
import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
-import cn.muchinfo.rma.global.data.ContractData
|
|
|
-import cn.muchinfo.rma.global.data.MiddleGoodsDetails
|
|
|
+import cn.muchinfo.rma.global.data.*
|
|
|
import cn.muchinfo.rma.view.MyApplication
|
|
|
import cn.muchinfo.rma.view.base.BaseViewModel
|
|
|
import cn.muchinfo.rma.view.base.home.commodity.newcommodity.newhedge.HedgeFutureData
|
|
|
@@ -15,19 +14,19 @@ import com.qmuiteam.qmui.widget.tab.QMUITabSegment
|
|
|
class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
|
|
|
/**
|
|
|
- * 现货品种的数据
|
|
|
+ * 套保品种详情
|
|
|
*/
|
|
|
- val demoDataList: MutableLiveData<List<DemoData>> = MutableLiveData()
|
|
|
+ val middleGoodsDetails: MutableLiveData<MiddleGoodsDetails> = MutableLiveData()
|
|
|
|
|
|
/**
|
|
|
- * 套保品种的数据
|
|
|
+ * 套保品种列表
|
|
|
*/
|
|
|
- val hedgeSpeciesList: MutableLiveData<List<HedgeSpeciesData>> = MutableLiveData()
|
|
|
+ val middleGoodsDetailsList : MutableLiveData<List<MiddleGoodsDetail>> = MutableLiveData()
|
|
|
|
|
|
/**
|
|
|
- * 套保品种详情
|
|
|
+ * 现货品种列表
|
|
|
*/
|
|
|
- val middleGoodsDetails: MutableLiveData<MiddleGoodsDetails> = MutableLiveData()
|
|
|
+ val deliveryGoodsDetailList : MutableLiveData<List<DeliveryGoodsDetailData>> = MutableLiveData()
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -45,150 +44,35 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- fun getHedgeSpeciesList() {
|
|
|
- val newhedgeSpeciesList = arrayListOf<HedgeSpeciesData>()
|
|
|
- newhedgeSpeciesList.add(
|
|
|
- HedgeSpeciesData(
|
|
|
- id = "1",
|
|
|
- futureTyeList = arrayListOf(
|
|
|
- HedgeFutureData(
|
|
|
- id = "1",
|
|
|
- futureContractList = arrayListOf("1", "2", "3")
|
|
|
- ), HedgeFutureData(
|
|
|
- id = "2",
|
|
|
- futureContractList = arrayListOf("1", "2", "3")
|
|
|
- )
|
|
|
- ),
|
|
|
- spotTypeList = arrayListOf(
|
|
|
- HedgeSpotData(
|
|
|
- id = "1",
|
|
|
- spotCategoryList = arrayListOf("1", "2", "3")
|
|
|
- ), HedgeSpotData(
|
|
|
- id = "2",
|
|
|
- spotCategoryList = arrayListOf("1", "2", "3")
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
-
|
|
|
- newhedgeSpeciesList.add(
|
|
|
- HedgeSpeciesData(
|
|
|
- id = "2",
|
|
|
- futureTyeList = arrayListOf(
|
|
|
- HedgeFutureData(
|
|
|
- id = "1",
|
|
|
- futureContractList = arrayListOf("1", "2", "3")
|
|
|
- ), HedgeFutureData(
|
|
|
- id = "2",
|
|
|
- futureContractList = arrayListOf("1", "2", "3")
|
|
|
- )
|
|
|
- ),
|
|
|
- spotTypeList = arrayListOf(
|
|
|
- HedgeSpotData(
|
|
|
- id = "1",
|
|
|
- spotCategoryList = arrayListOf("1", "2", "3")
|
|
|
- ), HedgeSpotData(
|
|
|
- id = "2",
|
|
|
- spotCategoryList = arrayListOf("1", "2", "3")
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
-
|
|
|
- newhedgeSpeciesList.add(
|
|
|
- HedgeSpeciesData(
|
|
|
- id = "3",
|
|
|
- futureTyeList = arrayListOf(
|
|
|
- HedgeFutureData(
|
|
|
- id = "1",
|
|
|
- futureContractList = arrayListOf("1", "2", "3")
|
|
|
- ), HedgeFutureData(
|
|
|
- id = "2",
|
|
|
- futureContractList = arrayListOf("1", "2", "3")
|
|
|
- )
|
|
|
- ),
|
|
|
- spotTypeList = arrayListOf(
|
|
|
- HedgeSpotData(
|
|
|
- id = "1",
|
|
|
- spotCategoryList = arrayListOf("1", "2", "3")
|
|
|
- ), HedgeSpotData(
|
|
|
- id = "2",
|
|
|
- spotCategoryList = arrayListOf("1", "2", "3")
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
-
|
|
|
- hedgeSpeciesList.postValue(newhedgeSpeciesList)
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
- * 查询现货品种详情
|
|
|
+ * 查询现货品种详情数据列表
|
|
|
* @param wrstandardid String
|
|
|
*/
|
|
|
- fun queryWrStandardDetails(deliverygoodsid: String) {
|
|
|
+ fun queryDeliveryGoodsDetailList() {
|
|
|
val params = mutableMapOf<String, String>().apply {
|
|
|
put("areauserid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
-// put("deliverygoodsid", deliverygoodsid)
|
|
|
}
|
|
|
MyApplication.getInstance()?.commodityManager?.queryDeliveryGoodsDetail(params = params) { isSuccess, respData, _ ->
|
|
|
if (isSuccess) {
|
|
|
-// wrStandardDetails.postValue(respData?.get(0))
|
|
|
-// initSpotGoodsActivity(respData?.get(0) ?: WrStandardDetail())
|
|
|
+ deliveryGoodsDetailList.postValue(respData)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ *套保品种详情的数据列表
|
|
|
+ */
|
|
|
+ fun queryMiddleGoodsDetailList() {
|
|
|
+ val params = mutableMapOf<String, String>().apply {
|
|
|
+ put("areauserid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.commodityManager?.queryMiddleGoodsDetail(params = params) { isSuccess, respData, error ->
|
|
|
+ if (isSuccess) {
|
|
|
+ middleGoodsDetailsList.postValue(respData)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- fun setDemoDataList() {
|
|
|
- val demoList = arrayListOf<DemoData>()
|
|
|
- demoList.add(
|
|
|
- DemoData(
|
|
|
- id = "1",
|
|
|
- categoryList = arrayListOf("1", "2", "3"),
|
|
|
- brandList = arrayListOf("1", "2", "3"),
|
|
|
- hedgeList = arrayListOf(
|
|
|
- HedgeDetails(id = "1", detailsList = arrayListOf("1", "2", "3")),
|
|
|
- HedgeDetails(id = "2", detailsList = arrayListOf("1", "2"))
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
- demoList.add(
|
|
|
- DemoData(
|
|
|
- id = "2",
|
|
|
- categoryList = arrayListOf("1", "2", "3"),
|
|
|
- brandList = arrayListOf("1", "2", "3"),
|
|
|
- hedgeList = arrayListOf(
|
|
|
- HedgeDetails(id = "1", detailsList = arrayListOf("1", "2", "3")),
|
|
|
- HedgeDetails(id = "2", detailsList = arrayListOf("1", "2"))
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
- demoList.add(
|
|
|
- DemoData(
|
|
|
- id = "3",
|
|
|
- categoryList = arrayListOf("1", "2", "3"),
|
|
|
- brandList = arrayListOf("1", "2", "3"),
|
|
|
- hedgeList = arrayListOf(
|
|
|
- HedgeDetails(id = "1", detailsList = arrayListOf("1", "2", "3")),
|
|
|
- HedgeDetails(id = "2", detailsList = arrayListOf("1", "2"))
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
- demoList.add(
|
|
|
- DemoData(
|
|
|
- id = "4",
|
|
|
- categoryList = arrayListOf("1", "2", "3"),
|
|
|
- brandList = arrayListOf("1", "2", "3"),
|
|
|
- hedgeList = arrayListOf(
|
|
|
- HedgeDetails(id = "1", detailsList = arrayListOf("1", "2", "3")),
|
|
|
- HedgeDetails(id = "2", detailsList = arrayListOf("1", "2"))
|
|
|
- )
|
|
|
- )
|
|
|
- )
|
|
|
- demoDataList.postValue(demoList)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -196,9 +80,9 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
* @param index Int
|
|
|
*/
|
|
|
fun setOnAllHedgeClick(index: Int){
|
|
|
- val datanewList = arrayListOf<HedgeSpeciesData>()
|
|
|
- hedgeSpeciesList.value?.forEach {
|
|
|
- if (index == hedgeSpeciesList.value?.indexOf(it)) {
|
|
|
+ val datanewList = arrayListOf<MiddleGoodsDetail>()
|
|
|
+ middleGoodsDetailsList.value?.forEach {
|
|
|
+ if (index == middleGoodsDetailsList.value?.indexOf(it)) {
|
|
|
if (it.isAllSelect == 0) {
|
|
|
datanewList.add(it.copy(isAllSelect = 1))
|
|
|
} else {
|
|
|
@@ -208,18 +92,58 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
datanewList.add(it)
|
|
|
}
|
|
|
}
|
|
|
- hedgeSpeciesList.postValue(datanewList)
|
|
|
+ middleGoodsDetailsList.postValue(datanewList)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 套保品种-期货品种的展开隐藏点击事件
|
|
|
+ * @param index Int
|
|
|
+ */
|
|
|
+ fun setOnHedgeFutureAllClick(index: Int) {
|
|
|
+ val datanewlist = arrayListOf<MiddleGoodsDetail>()
|
|
|
+ middleGoodsDetailsList.value?.forEach {
|
|
|
+ if (index == middleGoodsDetailsList.value?.indexOf(it)) {
|
|
|
+ if (it.isFutureTypeSelect == 0) {
|
|
|
+ datanewlist.add(it.copy(isFutureTypeSelect = 1))
|
|
|
+ } else {
|
|
|
+ datanewlist.add(it.copy(isFutureTypeSelect = 0))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ datanewlist.add(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ middleGoodsDetailsList.postValue(datanewlist)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 套保品种-现货品种的展开隐藏点击事件
|
|
|
+ * @param index Int
|
|
|
+ */
|
|
|
+ fun setOnHedgeSpotAllClick(index: Int) {
|
|
|
+ val datanewlist = arrayListOf<MiddleGoodsDetail>()
|
|
|
+ middleGoodsDetailsList.value?.forEach {
|
|
|
+ if (index == middleGoodsDetailsList.value?.indexOf(it)) {
|
|
|
+ if (it.isSpotTypeSelect == 0) {
|
|
|
+ datanewlist.add(it.copy(isSpotTypeSelect = 1))
|
|
|
+ } else {
|
|
|
+ datanewlist.add(it.copy(isSpotTypeSelect = 0))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ datanewlist.add(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ middleGoodsDetailsList.postValue(datanewlist)
|
|
|
}
|
|
|
|
|
|
//套保品种-期货品种的展开隐藏点击事件
|
|
|
fun setOnHedgeFutureClick(index: Int, sonIndex: Int) {
|
|
|
- val datanewlist = arrayListOf<HedgeSpeciesData>()
|
|
|
- val oldList = hedgeSpeciesList.value
|
|
|
- hedgeSpeciesList.value?.forEach {
|
|
|
+ val datanewlist = arrayListOf<MiddleGoodsDetail>()
|
|
|
+ val oldList = middleGoodsDetailsList.value
|
|
|
+ middleGoodsDetailsList.value?.forEach {
|
|
|
if (index == oldList?.indexOf(it)) {
|
|
|
- val newHedgeList = arrayListOf<HedgeFutureData>()
|
|
|
- oldList.get(index).futureTyeList.forEach { data ->
|
|
|
- if (sonIndex == oldList.get(index).futureTyeList.indexOf(data)) {
|
|
|
+ val newHedgeList = arrayListOf<Ermcp3GoodsGroupEx>()
|
|
|
+ oldList.get(index).gplist?.forEach { data ->
|
|
|
+ if (sonIndex == oldList.get(index).gplist?.indexOf(data)) {
|
|
|
if (data.isFutureSelect == 0) {
|
|
|
newHedgeList.add(data.copy(isFutureSelect = 1))
|
|
|
} else {
|
|
|
@@ -229,23 +153,23 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
newHedgeList.add(data)
|
|
|
}
|
|
|
}
|
|
|
- datanewlist.add(it.copy(futureTyeList = newHedgeList))
|
|
|
+ datanewlist.add(it.copy(gplist = newHedgeList))
|
|
|
} else {
|
|
|
datanewlist.add(it)
|
|
|
}
|
|
|
}
|
|
|
- hedgeSpeciesList.postValue(datanewlist)
|
|
|
+ middleGoodsDetailsList.postValue(datanewlist)
|
|
|
}
|
|
|
|
|
|
//套保品种-现货品种的item点击展开
|
|
|
fun setOnHedgeSpotClick(index: Int, sonIndex: Int){
|
|
|
- val datanewlist = arrayListOf<HedgeSpeciesData>()
|
|
|
- val oldList = hedgeSpeciesList.value
|
|
|
- hedgeSpeciesList.value?.forEach {
|
|
|
+ val datanewlist = arrayListOf<MiddleGoodsDetail>()
|
|
|
+ val oldList = middleGoodsDetailsList.value
|
|
|
+ middleGoodsDetailsList.value?.forEach {
|
|
|
if (index == oldList?.indexOf(it)) {
|
|
|
- val newHedgeList = arrayListOf<HedgeSpotData>()
|
|
|
- oldList.get(index).spotTypeList.forEach { data ->
|
|
|
- if (sonIndex == oldList.get(index).spotTypeList.indexOf(data)) {
|
|
|
+ val newHedgeList = arrayListOf<ErmcpDeliveryGoodsDetail>()
|
|
|
+ oldList.get(index).dglist?.forEach { data ->
|
|
|
+ if (sonIndex == oldList.get(index).dglist?.indexOf(data)) {
|
|
|
if (data.isSpotSelect == 0) {
|
|
|
newHedgeList.add(data.copy(isSpotSelect = 1))
|
|
|
} else {
|
|
|
@@ -255,12 +179,12 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
newHedgeList.add(data)
|
|
|
}
|
|
|
}
|
|
|
- datanewlist.add(it.copy(spotTypeList = newHedgeList))
|
|
|
+ datanewlist.add(it.copy(dglist = newHedgeList))
|
|
|
} else {
|
|
|
datanewlist.add(it)
|
|
|
}
|
|
|
}
|
|
|
- hedgeSpeciesList.postValue(datanewlist)
|
|
|
+ middleGoodsDetailsList.postValue(datanewlist)
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -270,9 +194,9 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
* @param index Int
|
|
|
*/
|
|
|
fun setOnAllClick(index: Int) {
|
|
|
- val datanewlist = arrayListOf<DemoData>()
|
|
|
- demoDataList.value?.forEach {
|
|
|
- if (index == demoDataList.value?.indexOf(it)) {
|
|
|
+ val datanewlist = arrayListOf<DeliveryGoodsDetailData>()
|
|
|
+ deliveryGoodsDetailList.value?.forEach {
|
|
|
+ if (index == deliveryGoodsDetailList.value?.indexOf(it)) {
|
|
|
if (it.isSelectAll == 0) {
|
|
|
datanewlist.add(it.copy(isSelectAll = 1))
|
|
|
} else {
|
|
|
@@ -282,14 +206,14 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
datanewlist.add(it)
|
|
|
}
|
|
|
}
|
|
|
- demoDataList.postValue(datanewlist)
|
|
|
+ deliveryGoodsDetailList.postValue(datanewlist)
|
|
|
}
|
|
|
|
|
|
//现货品种-品类的展开隐藏点击事件
|
|
|
fun setOnCategoryClick(index: Int) {
|
|
|
- val datanewlist = arrayListOf<DemoData>()
|
|
|
- demoDataList.value?.forEach {
|
|
|
- if (index == demoDataList.value?.indexOf(it)) {
|
|
|
+ val datanewlist = arrayListOf<DeliveryGoodsDetailData>()
|
|
|
+ deliveryGoodsDetailList.value?.forEach {
|
|
|
+ if (index == deliveryGoodsDetailList.value?.indexOf(it)) {
|
|
|
if (it.categoryIsSelect == 0) {
|
|
|
datanewlist.add(it.copy(categoryIsSelect = 1))
|
|
|
} else {
|
|
|
@@ -299,14 +223,14 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
datanewlist.add(it)
|
|
|
}
|
|
|
}
|
|
|
- demoDataList.postValue(datanewlist)
|
|
|
+ deliveryGoodsDetailList.postValue(datanewlist)
|
|
|
}
|
|
|
|
|
|
//现货品种-品牌的展开隐藏点击事件
|
|
|
fun setOnBrandClick(index: Int) {
|
|
|
- val datanewlist = arrayListOf<DemoData>()
|
|
|
- demoDataList.value?.forEach {
|
|
|
- if (index == demoDataList.value?.indexOf(it)) {
|
|
|
+ val datanewlist = arrayListOf<DeliveryGoodsDetailData>()
|
|
|
+ deliveryGoodsDetailList.value?.forEach {
|
|
|
+ if (index == deliveryGoodsDetailList.value?.indexOf(it)) {
|
|
|
if (it.brandIsSelect == 0) {
|
|
|
datanewlist.add(it.copy(brandIsSelect = 1))
|
|
|
} else {
|
|
|
@@ -316,14 +240,14 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
datanewlist.add(it)
|
|
|
}
|
|
|
}
|
|
|
- demoDataList.postValue(datanewlist)
|
|
|
+ deliveryGoodsDetailList.postValue(datanewlist)
|
|
|
}
|
|
|
|
|
|
//现货品种-套保品种的展开隐藏点击事件
|
|
|
fun setOnHedgeClick(index: Int) {
|
|
|
- val datanewlist = arrayListOf<DemoData>()
|
|
|
- demoDataList.value?.forEach {
|
|
|
- if (index == demoDataList.value?.indexOf(it)) {
|
|
|
+ val datanewlist = arrayListOf<DeliveryGoodsDetailData>()
|
|
|
+ deliveryGoodsDetailList.value?.forEach {
|
|
|
+ if (index == deliveryGoodsDetailList.value?.indexOf(it)) {
|
|
|
if (it.hedgeIsSelect == 0) {
|
|
|
datanewlist.add(it.copy(hedgeIsSelect = 1))
|
|
|
} else {
|
|
|
@@ -333,18 +257,18 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
datanewlist.add(it)
|
|
|
}
|
|
|
}
|
|
|
- demoDataList.postValue(datanewlist)
|
|
|
+ deliveryGoodsDetailList.postValue(datanewlist)
|
|
|
}
|
|
|
|
|
|
//现货品种-套保品种-现货品种的展开隐藏点击事件
|
|
|
fun setOnFutureClick(index: Int, sonIndex: Int) {
|
|
|
- val datanewlist = arrayListOf<DemoData>()
|
|
|
- val oldList = demoDataList.value
|
|
|
- demoDataList.value?.forEach {
|
|
|
+ val datanewlist = arrayListOf<DeliveryGoodsDetailData>()
|
|
|
+ val oldList = deliveryGoodsDetailList.value
|
|
|
+ deliveryGoodsDetailList.value?.forEach {
|
|
|
if (index == oldList?.indexOf(it)) {
|
|
|
- val newHedgeList = arrayListOf<HedgeDetails>()
|
|
|
- oldList.get(index).hedgeList.forEach { data ->
|
|
|
- if (sonIndex == oldList.get(index).hedgeList.indexOf(data)) {
|
|
|
+ val newHedgeList = arrayListOf<Ermcp3MiddleGoodsDetail>()
|
|
|
+ oldList.get(index).mgList?.forEach { data ->
|
|
|
+ if (sonIndex == oldList.get(index).mgList?.indexOf(data)) {
|
|
|
if (data.isSelect == 0) {
|
|
|
newHedgeList.add(data.copy(isSelect = 1))
|
|
|
} else {
|
|
|
@@ -354,12 +278,12 @@ class NewCommodityInformationViewModel : BaseViewModel() {
|
|
|
newHedgeList.add(data)
|
|
|
}
|
|
|
}
|
|
|
- datanewlist.add(it.copy(hedgeList = newHedgeList))
|
|
|
+ datanewlist.add(it.copy(mgList = newHedgeList))
|
|
|
} else {
|
|
|
datanewlist.add(it)
|
|
|
}
|
|
|
}
|
|
|
- demoDataList.postValue(datanewlist)
|
|
|
+ deliveryGoodsDetailList.postValue(datanewlist)
|
|
|
}
|
|
|
|
|
|
}
|