|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.muchinfo.rma.view.base.home.accountmanager.futureaccount
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import android.os.Bundle
|
|
|
import android.view.Gravity
|
|
|
import android.view.View
|
|
|
@@ -7,18 +8,24 @@ import android.view.inputmethod.EditorInfo
|
|
|
import android.widget.EditText
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.data.AccMgrTaaccountData
|
|
|
+import cn.muchinfo.rma.global.data.AccMgrTaaccountSonData
|
|
|
import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
import cn.muchinfo.rma.view.autoWidget.*
|
|
|
import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
import cn.muchinfo.rma.view.base.home.contract.emptyView
|
|
|
+import com.blankj.utilcode.util.ToastUtils
|
|
|
import mtp.polymer.com.autowidget.dialog.SelectData
|
|
|
+import mtp.polymer.com.autowidget.dialog.creatBottomSheetDialog
|
|
|
+import mtp.polymer.com.autowidget.dialog.createLoadingDialog
|
|
|
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
import org.jetbrains.anko.*
|
|
|
|
|
|
/**
|
|
|
* 新增期货子账户
|
|
|
*/
|
|
|
-class AddFutureSonAccountActivity : BaseActivity<FutureAccountViewModel>(){
|
|
|
+class AddFutureSonAccountActivity : BaseActivity<FutureAccountViewModel>() {
|
|
|
|
|
|
/**
|
|
|
* 页面操作类型 1 新增 2 修改 3 详情
|
|
|
@@ -26,62 +33,66 @@ class AddFutureSonAccountActivity : BaseActivity<FutureAccountViewModel>(){
|
|
|
private val type by lazy { intent.getStringExtra("type") }
|
|
|
|
|
|
/**
|
|
|
- * 输入的账户名称
|
|
|
+ * 新增/修改时需要拿到的相应期货主账户信息
|
|
|
*/
|
|
|
- private lateinit var account_name : EditText
|
|
|
+ private val data by lazy { intent.getParcelableExtra<AccMgrTaaccountSonData>("data") as AccMgrTaaccountSonData }
|
|
|
|
|
|
/**
|
|
|
- * 选择的期货保证金
|
|
|
+ * 修改时需要拿到的相应期货子账户信息
|
|
|
*/
|
|
|
- private val select_futures_margin : MutableLiveData<SelectData> = MutableLiveData()
|
|
|
+ private val dataSon by lazy { intent.getParcelableExtra<AccMgrTaaccountSonData>("dataSon") as AccMgrTaaccountSonData }
|
|
|
|
|
|
/**
|
|
|
- * 选择的期货手续费
|
|
|
+ * 输入的账户名称
|
|
|
*/
|
|
|
- private val select_forward_commission : MutableLiveData<SelectData> = MutableLiveData()
|
|
|
+ private lateinit var account_name: EditText
|
|
|
|
|
|
/**
|
|
|
* 页面数据初始化
|
|
|
*/
|
|
|
- fun init(){
|
|
|
- select_futures_margin.postValue(SelectData(id = "1",value = "默认保证金"))
|
|
|
- select_forward_commission.postValue(SelectData(id = "1",value = "默认手续费"))
|
|
|
+ fun init() {
|
|
|
+ viewModel.queryTradeConfigTMP()
|
|
|
}
|
|
|
|
|
|
+ val dialog by lazy { createLoadingDialog(hintStr = "请求中...") }
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
verticalLayout {
|
|
|
+ dialog.bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
-
|
|
|
+ init()
|
|
|
//页面标题
|
|
|
topBar {
|
|
|
commonLeftButton()
|
|
|
commonTitle {
|
|
|
- text = if (type == "1"){
|
|
|
+ text = if (type == "1") {
|
|
|
"新增期货子账户"
|
|
|
- }else if (type == "2"){
|
|
|
+ } else if (type == "2") {
|
|
|
"修改期货子账户"
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
"期货子账户详情"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
textView {
|
|
|
text = "所属期货账户"
|
|
|
textSizeAuto = 31
|
|
|
textColorInt = R.color.rma_gray_color
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
marginStart = autoSize(60)
|
|
|
}
|
|
|
|
|
|
textView {
|
|
|
- text = "王小二/18643549988"
|
|
|
+ text = data.accountname + "/" + data.accountid
|
|
|
textSizeAuto = 31
|
|
|
textColorInt = R.color.rma_black_33
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
marginStart = autoSize(65)
|
|
|
}
|
|
|
}.lparams(matchParent, autoSize(132))
|
|
|
@@ -103,12 +114,18 @@ class AddFutureSonAccountActivity : BaseActivity<FutureAccountViewModel>(){
|
|
|
textView {
|
|
|
text = "账户名称"
|
|
|
textSizeAuto = 31
|
|
|
- textColorInt = R.color.rma_black_33
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
}.lparams(wrapContent, wrapContent) {
|
|
|
marginStart = autoSize(10)
|
|
|
}
|
|
|
|
|
|
editText {
|
|
|
+ if (type != "1"){
|
|
|
+ setText(dataSon.accountname)
|
|
|
+ }
|
|
|
+ if (type == "3"){
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
account_name = this
|
|
|
hint = "请输入账户名称"
|
|
|
background = null
|
|
|
@@ -125,44 +142,50 @@ class AddFutureSonAccountActivity : BaseActivity<FutureAccountViewModel>(){
|
|
|
itemView()
|
|
|
|
|
|
linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
onThrottleFirstClick {
|
|
|
-// val selectDataList = arrayListOf(
|
|
|
-// SelectData(
|
|
|
-// id = "2",
|
|
|
-// value = "套利"
|
|
|
-// ),
|
|
|
-// SelectData(
|
|
|
-// id = "1",
|
|
|
-// value = "套保"
|
|
|
-// )
|
|
|
-// )
|
|
|
-// creatBottomSheetDialog("请选择业务类型", selectDataList) {
|
|
|
-//// selectBusinessType.postValue(this)
|
|
|
-// }
|
|
|
+ if (type == "3"){
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ val selectDataList = arrayListOf<SelectData>()
|
|
|
+ viewModel.trademarginConfigTmpDataList.value?.forEach {
|
|
|
+ selectDataList.add(
|
|
|
+ SelectData(
|
|
|
+ id = it?.tradeconfigtmpid ?: "",
|
|
|
+ value = it?.tradeconfigtmpname ?: ""
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ creatBottomSheetDialog("请选择期货保证金", selectDataList) {
|
|
|
+ viewModel.select_futures_margin.postValue(this)
|
|
|
+ }
|
|
|
}
|
|
|
textView {
|
|
|
text = "期货保证金"
|
|
|
textSizeAuto = 31
|
|
|
textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
marginStart = autoSize(60)
|
|
|
}
|
|
|
|
|
|
textView {
|
|
|
- select_futures_margin.bindOptional(context){
|
|
|
+ viewModel.select_futures_margin.bindOptional(context) {
|
|
|
text = it?.value
|
|
|
}
|
|
|
text = "默认保证金"
|
|
|
textSizeAuto = 31
|
|
|
textColorInt = R.color.rma_black_33
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
marginStart = autoSize(110)
|
|
|
}
|
|
|
|
|
|
emptyView()
|
|
|
|
|
|
imageView {
|
|
|
+ if (type == "3"){
|
|
|
+ visibility = View.GONE
|
|
|
+ }
|
|
|
imageResource = R.mipmap.rma_more
|
|
|
}.lparams(autoSize(43), autoSize(43))
|
|
|
}.lparams(matchParent, autoSize(132))
|
|
|
@@ -170,65 +193,102 @@ class AddFutureSonAccountActivity : BaseActivity<FutureAccountViewModel>(){
|
|
|
itemView()
|
|
|
|
|
|
linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
onThrottleFirstClick {
|
|
|
-// val selectDataList = arrayListOf(
|
|
|
-// SelectData(
|
|
|
-// id = "2",
|
|
|
-// value = "套利"
|
|
|
-// ),
|
|
|
-// SelectData(
|
|
|
-// id = "1",
|
|
|
-// value = "套保"
|
|
|
-// )
|
|
|
-// )
|
|
|
-// creatBottomSheetDialog("请选择业务类型", selectDataList) {
|
|
|
-//// selectBusinessType.postValue(this)
|
|
|
-// }
|
|
|
+ if (type == "3"){
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ val selectDataList = arrayListOf<SelectData>()
|
|
|
+ viewModel.tradepoundageConfigTmpDataList.value?.forEach {
|
|
|
+ selectDataList.add(
|
|
|
+ SelectData(
|
|
|
+ id = it.tradeconfigtmpid ?: "",
|
|
|
+ value = it.tradeconfigtmpname ?: ""
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ creatBottomSheetDialog("请选择期货手续费", selectDataList) {
|
|
|
+ viewModel.select_forward_commission.postValue(this)
|
|
|
+ }
|
|
|
}
|
|
|
textView {
|
|
|
text = "期货手续费"
|
|
|
textSizeAuto = 31
|
|
|
textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
marginStart = autoSize(60)
|
|
|
}
|
|
|
|
|
|
textView {
|
|
|
- select_forward_commission.bindOptional(context){
|
|
|
+ viewModel.select_forward_commission.bindOptional(context) {
|
|
|
text = it?.value
|
|
|
}
|
|
|
text = "默认手续费"
|
|
|
textSizeAuto = 31
|
|
|
textColorInt = R.color.rma_black_33
|
|
|
- }.lparams(wrapContent, wrapContent){
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
marginStart = autoSize(110)
|
|
|
}
|
|
|
|
|
|
emptyView()
|
|
|
|
|
|
imageView {
|
|
|
+ if (type == "3"){
|
|
|
+ visibility = View.GONE
|
|
|
+ }
|
|
|
imageResource = R.mipmap.rma_more
|
|
|
}.lparams(autoSize(43), autoSize(43))
|
|
|
}.lparams(matchParent, autoSize(132))
|
|
|
|
|
|
view {
|
|
|
|
|
|
- }.lparams(autoSize(1),0,1f)
|
|
|
+ }.lparams(autoSize(1), 0, 1f)
|
|
|
|
|
|
linearLayout {
|
|
|
background = resources.getDrawable(R.color.white)
|
|
|
gravity = Gravity.CENTER_VERTICAL
|
|
|
-
|
|
|
+ if (type == "3") {
|
|
|
+ visibility = View.GONE
|
|
|
+ } else {
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
textView {
|
|
|
onThrottleFirstClick {
|
|
|
+ if (check().not()) {
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ if (type == "1"){//新增
|
|
|
+ viewModel.hedgeOutMainConfigReq(
|
|
|
+ ismain = 0,
|
|
|
+ accountname = account_name.text.toString(),
|
|
|
+ parentaccountid = data.parentaccountid?.toLong() ?: 0,
|
|
|
+ tradefeetmpid = viewModel.select_forward_commission.value?.id?.toLong() ?: 0,
|
|
|
+ trademargintmpid = viewModel.select_futures_margin.value?.id?.toLong() ?: 0,
|
|
|
+ fromaccountid = data.parentaccountid?.toLong() ?: 0
|
|
|
+ ){
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }else {//修改
|
|
|
+ viewModel.hedgeOutMainConfigReq(
|
|
|
+ ismain = 0,
|
|
|
+ accountname = account_name.text.toString(),
|
|
|
+ parentaccountid = data.parentaccountid?.toLong() ?: 0,
|
|
|
+ tradefeetmpid = viewModel.select_forward_commission.value?.id?.toLong() ?: 0,
|
|
|
+ trademargintmpid = viewModel.select_futures_margin.value?.id?.toLong() ?: 0,
|
|
|
+ fromaccountid = data.parentaccountid?.toLong() ?: 0,
|
|
|
+ accountid = dataSon.accountid?.toLong() ?: 0
|
|
|
+ ){
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
gravity = Gravity.CENTER
|
|
|
- backgroundResource = R.mipmap.rma_save_info_bg
|
|
|
+ backgroundResource = R.mipmap.rma_submit_bg
|
|
|
text = "完成"
|
|
|
textSizeAuto = 38
|
|
|
- textColorInt = R.color.rma_star_color
|
|
|
+ textColorInt = R.color.white
|
|
|
}.lparams(matchParent, autoSize(119)) {
|
|
|
marginStart = autoSize(60)
|
|
|
marginEnd = autoSize(60)
|
|
|
@@ -237,4 +297,22 @@ class AddFutureSonAccountActivity : BaseActivity<FutureAccountViewModel>(){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 操作之前的数据校验
|
|
|
+ */
|
|
|
+ fun check(): Boolean {
|
|
|
+ if (viewModel.select_futures_margin.value?.id?.isNullOrEmpty() == true) {
|
|
|
+ ToastUtils.showLong("请选择保证金模式")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (viewModel.select_forward_commission.value?.id?.isNullOrEmpty() == true) {
|
|
|
+ ToastUtils.showLong("请选择手续费模式")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (account_name.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入名称")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
}
|