|
|
@@ -13,14 +13,16 @@ import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
import cn.muchinfo.rma.global.data.futureOrders.FutureEntrustData
|
|
|
import cn.muchinfo.rma.view.base.BaseViewModel
|
|
|
import cn.muchinfo.rma.view.base.future.interfaces.OnItemClickListener
|
|
|
-import com.blankj.utilcode.util.LogUtils
|
|
|
-import mtp.polymer.com.autowidget.utils.TaskUiModel
|
|
|
import org.jetbrains.anko.backgroundColor
|
|
|
+import java.text.SimpleDateFormat
|
|
|
+import java.util.*
|
|
|
+import kotlin.collections.ArrayList
|
|
|
|
|
|
/**
|
|
|
* 今日委托和今日可撤model
|
|
|
*/
|
|
|
class EntrustChildViewModel : BaseViewModel() {
|
|
|
+ private var type: EntrustFragment.EntrustType? = EntrustFragment.EntrustType.TODAY_CANCEL_TYPE // 默认进入可撤
|
|
|
|
|
|
val entrustLiveData: MutableLiveData<List<FutureEntrustData>> = MutableLiveData() // 加载状态控制
|
|
|
val noDataLiveData: MutableLiveData<Boolean> = MutableLiveData() // 如果没有数据
|
|
|
@@ -33,20 +35,20 @@ class EntrustChildViewModel : BaseViewModel() {
|
|
|
/**
|
|
|
* 获取配置器。
|
|
|
*/
|
|
|
- fun getAdapter(): RecyclerView.Adapter<HoldAdapter.EntrustHolder> {
|
|
|
- return HoldAdapter(context)
|
|
|
+ fun getAdapter(): RecyclerView.Adapter<EntrustAdapter.EntrustHolder> {
|
|
|
+ return EntrustAdapter(context)
|
|
|
}
|
|
|
|
|
|
/** * 通用的适配器。
|
|
|
*/
|
|
|
- inner class HoldAdapter(context: Context?) : RecyclerView.Adapter<HoldAdapter.EntrustHolder>() {
|
|
|
+ inner class EntrustAdapter(context: Context?) : RecyclerView.Adapter<EntrustAdapter.EntrustHolder>() {
|
|
|
private var list: ArrayList<FutureEntrustData>? = null
|
|
|
private var inflater: LayoutInflater? = null
|
|
|
private var context: Context? = null
|
|
|
private var selectedColor: Int = 0
|
|
|
|
|
|
init {
|
|
|
- this.list = list
|
|
|
+ this.list = GlobalDataCollection.instance?.futureHisEntrustData
|
|
|
this.inflater = LayoutInflater.from(context)
|
|
|
this.context = context
|
|
|
selectedColor = context?.getColor(R.color.p_select_bg_color)!!
|
|
|
@@ -56,6 +58,11 @@ class EntrustChildViewModel : BaseViewModel() {
|
|
|
return list?.size ?: 0
|
|
|
}
|
|
|
|
|
|
+ fun update(list: ArrayList<FutureEntrustData>?) {
|
|
|
+ this.list = list
|
|
|
+ notifyDataSetChanged()
|
|
|
+ }
|
|
|
+
|
|
|
inner class EntrustHolder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {
|
|
|
var idGoodsName = itemView?.findViewById<TextView>(R.id.id_goods_name)
|
|
|
var idStatus = itemView?.findViewById<TextView>(R.id.id_status)
|
|
|
@@ -75,8 +82,8 @@ class EntrustChildViewModel : BaseViewModel() {
|
|
|
|
|
|
entrust.idGoodsName?.text = list?.get(position)?.goodsname
|
|
|
// entrust.idStatus?.text = list?.get(position)?.status
|
|
|
-// entrust.idEntrustType?.text = list?.get(position)?.entrustType
|
|
|
- entrust.idDate?.text = list?.get(position)?.ordertime
|
|
|
+ entrust.idEntrustType?.text = getType(list?.get(position)!!)
|
|
|
+ entrust.idDate?.text = getTime(list?.get(position)!!)
|
|
|
entrust.idEntrustPrice?.text = list?.get(position)?.orderprice.toString()
|
|
|
entrust.idEntrustNum?.text = list?.get(position)?.orderqty.toString()
|
|
|
// entrust.idEntrustPl?.text = list?.get(position)?.pl.toString()
|
|
|
@@ -115,6 +122,18 @@ class EntrustChildViewModel : BaseViewModel() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ fun getType(_data: FutureEntrustData): String {
|
|
|
+ val buyOrSell = _data.buyorsell
|
|
|
+ val channelBuildType = _data.channelbuildtype
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+
|
|
|
+ fun getTime(_data: FutureEntrustData): String {
|
|
|
+ val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss+08:00", Locale.CHINA)
|
|
|
+ val sdf1 = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA)
|
|
|
+ return sdf1.format(sdf.parse(_data.ordertime)!!)
|
|
|
+ }
|
|
|
+
|
|
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EntrustHolder {
|
|
|
return EntrustHolder(inflater?.inflate(R.layout.entrust_item, parent, false))
|
|
|
}
|
|
|
@@ -150,13 +169,14 @@ class EntrustChildViewModel : BaseViewModel() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- FutureManager().queryErmcpHisEntrustDetails { _isSuccess, _respData, _ ->
|
|
|
- if (_isSuccess && !_respData!!.isNullOrEmpty()) { // 查询成功
|
|
|
- entrustLiveData.value = _respData
|
|
|
- } else { // 查询失败
|
|
|
- noDataLiveData.value = true
|
|
|
- }
|
|
|
- }
|
|
|
+// FutureManager().queryErmcpHisEntrustDetails { _isSuccess, _respData, _ ->
|
|
|
+// if (_isSuccess && !_respData!!.isNullOrEmpty()) { // 查询成功
|
|
|
+// list = _respData as ArrayList<FutureEntrustData>?
|
|
|
+// entrustLiveData.value = _respData
|
|
|
+// } else { // 查询失败
|
|
|
+// noDataLiveData.value = true
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
//endregion
|