|
|
@@ -0,0 +1,270 @@
|
|
|
+package cn.muchinfo.rma.view.base.home.xhcp
|
|
|
+
|
|
|
+import android.annotation.SuppressLint
|
|
|
+import android.app.Dialog
|
|
|
+import android.graphics.Color
|
|
|
+import android.view.Gravity
|
|
|
+import androidx.appcompat.app.AppCompatActivity
|
|
|
+import androidx.lifecycle.MutableLiveData
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
+import cn.muchinfo.rma.global.MTPEnums
|
|
|
+import cn.muchinfo.rma.global.data.AccountData
|
|
|
+import cn.muchinfo.rma.global.data.WrPreSaleInfoData
|
|
|
+import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
+import cn.muchinfo.rma.view.autoWidget.*
|
|
|
+import cn.muchinfo.rma.view.autoWidget.utils.NumberUtils
|
|
|
+import cn.muchinfo.rma.view.autoWidget.view.MangeNumberEditText2
|
|
|
+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 com.qmuiteam.qmui.kotlin.onClick
|
|
|
+import mtp.polymer.com.autowidget.dialog.CustomDialogFragment
|
|
|
+import mtp.polymer.com.autowidget.dialog.createCustomDialog
|
|
|
+import mtp.polymer.com.autowidget.dialog.createLoadingDialog
|
|
|
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
+import org.jetbrains.anko.*
|
|
|
+
|
|
|
+@SuppressLint("SetTextI18n")
|
|
|
+fun AppCompatActivity.XhcpHdWRDealScreeningDialog(
|
|
|
+ viewModel: XhcpNewGoodsViewModel,
|
|
|
+ activity: AppCompatActivity,
|
|
|
+ data: WrPreSaleInfoData
|
|
|
+): CustomDialogFragment {
|
|
|
+ return createCustomDialog(cancelable = false) { dialog ->
|
|
|
+ var loadingDialog: Dialog? = null
|
|
|
+ // 认购数量
|
|
|
+ lateinit var qtyNumberEditText: MangeNumberEditText2
|
|
|
+
|
|
|
+ //选择的资金账号
|
|
|
+ val selectAccountData: MutableLiveData<AccountData> = MutableLiveData()
|
|
|
+
|
|
|
+ // 需要的履约保证金
|
|
|
+ val buyMarginValue: MutableLiveData<Double> = MutableLiveData()
|
|
|
+ // 计算需要的履约保证金
|
|
|
+ val unitPrice: Double = data.unitprice?.toDouble() ?: 0.0
|
|
|
+ buyMarginValue.postValue(unitPrice.times(data.baseqty?.toDouble() ?: 0.0))
|
|
|
+
|
|
|
+ // 选择当前资金账户
|
|
|
+ selectAccountData.postValue(GlobalDataCollection.instance?.accountData)
|
|
|
+
|
|
|
+ backgroundColor = Color.parseColor("#5f000000")
|
|
|
+ relativeLayout {
|
|
|
+ loadingDialog = createLoadingDialog(hintStr = "请求中")
|
|
|
+ loadingDialog?.bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white, null)
|
|
|
+
|
|
|
+ // 资金账户
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ selectAccountData.bindOptional(context) {
|
|
|
+ text = it?.accountname + "(" + it?.accountid.toString() + ")"
|
|
|
+ }
|
|
|
+ textSizeAuto = 36
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ }.lparams(matchParent, wrapContent, 1F)
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.rma_more
|
|
|
+ }.lparams(autoSize(36), autoSize(36)) {
|
|
|
+ rightMargin = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, wrapContent) {
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发行方
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ textSizeAuto = 32
|
|
|
+ textColorInt = R.color.text_hint_color_two
|
|
|
+ text = "发行方"
|
|
|
+ }.lparams(autoSize(100), wrapContent) {
|
|
|
+ leftMargin = autoSize(30)
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ textSizeAuto = 36
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ text = data.username
|
|
|
+ }.lparams(autoSize(0), wrapContent, 1F) {
|
|
|
+ leftMargin = autoSize(10)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, wrapContent) {
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发行价格 & 最大认购数量
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ textColorInt = R.color.text_hint_color_two
|
|
|
+ textSizeAuto = 32
|
|
|
+ text = "发行价格"
|
|
|
+ }.lparams(autoSize(0), wrapContent, 1F)
|
|
|
+ textView {
|
|
|
+ textColorInt = R.color.rma_item_yellow_color
|
|
|
+ textSizeAuto = 36
|
|
|
+ text = data.unitprice
|
|
|
+ gravity = Gravity.RIGHT
|
|
|
+ }.lparams(autoSize(0), wrapContent, 1F)
|
|
|
+ }.lparams(matchParent, wrapContent, 1F) {
|
|
|
+ topMargin = autoSize(10)
|
|
|
+ leftMargin = autoSize(30)
|
|
|
+ rightMargin = autoSize(30)
|
|
|
+ }
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ textColorInt = R.color.text_hint_color_two
|
|
|
+ textSizeAuto = 32
|
|
|
+ text = "最大认购数量"
|
|
|
+ }.lparams(autoSize(0), wrapContent, 1F)
|
|
|
+ textView {
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 36
|
|
|
+ text = data.maxbuyqty + " " + data.enumdicname
|
|
|
+ gravity = Gravity.RIGHT
|
|
|
+ }.lparams(autoSize(0), wrapContent, 1F)
|
|
|
+ }.lparams(matchParent, wrapContent, 1F) {
|
|
|
+ topMargin = autoSize(10)
|
|
|
+ leftMargin = autoSize(30)
|
|
|
+ rightMargin = autoSize(20)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ itemView(10)
|
|
|
+
|
|
|
+ // 认购数量
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ textSizeAuto = 32
|
|
|
+ textColorInt = R.color.text_hint_color_two
|
|
|
+ text = "认购数量(" + data.baseqty + data.enumdicname + "起)"
|
|
|
+ }.lparams(autoSize(300), wrapContent) {
|
|
|
+ leftMargin = autoSize(30)
|
|
|
+ topMargin = autoSize(5)
|
|
|
+ }
|
|
|
+ numberEditText {
|
|
|
+ qtyNumberEditText = this
|
|
|
+ text = data.baseqty
|
|
|
+ max = data.maxbuyqty?.toDouble() ?: 0.0
|
|
|
+ min = data.baseqty?.toDouble() ?: 0.0
|
|
|
+ step = data.baseqty?.toDouble() ?: 0.0
|
|
|
+ setOnTextChangeListener { view, value ->
|
|
|
+ if (value.isNullOrEmpty().not()) {
|
|
|
+ // 计算需要的履约保证金
|
|
|
+ val unitPrice: Double = data.unitprice?.toDouble() ?: 0.0
|
|
|
+ buyMarginValue.postValue(unitPrice.times(value.toDouble()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(72), 1f) {
|
|
|
+ marginStart = autoSize(100)
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(100)) {
|
|
|
+ topMargin = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ itemView(10)
|
|
|
+
|
|
|
+ // 履约保证金
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ textSizeAuto = 32
|
|
|
+ textColorInt = R.color.text_hint_color_two
|
|
|
+ text = "履约保证金"
|
|
|
+ }.lparams(autoSize(300), wrapContent) {
|
|
|
+ leftMargin = autoSize(30)
|
|
|
+ topMargin = autoSize(5)
|
|
|
+ }
|
|
|
+ verticalLayout {
|
|
|
+ textView {
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 36
|
|
|
+ buyMarginValue.bindOptional(context) {
|
|
|
+ text = NumberUtils.roundNum(it ?: 0.0, 2)
|
|
|
+ }
|
|
|
+ gravity = Gravity.RIGHT
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ textView {
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 36
|
|
|
+ selectAccountData.bindOptional(context) {
|
|
|
+ if (it != null) {
|
|
|
+ text = "可用资金: " + NumberUtils.roundNum(it.canUserAmount ?: 0.0, 2)
|
|
|
+ } else {
|
|
|
+ text = "可用资金: --"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gravity = Gravity.RIGHT
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(autoSize(0), wrapContent, 1F)
|
|
|
+ }.lparams(matchParent, autoSize(100)) {
|
|
|
+ topMargin = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ itemView(10)
|
|
|
+
|
|
|
+ // 交互区
|
|
|
+ linearLayout {
|
|
|
+ button {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ text = "取消"
|
|
|
+ textSizeAuto = 36
|
|
|
+ textColorInt = R.color.white
|
|
|
+ backgroundDrawable =
|
|
|
+ createRoundRectDrawable("#505050", 10)
|
|
|
+ }.lparams(autoSize(0), autoSize(100), 1F) {
|
|
|
+ leftMargin = autoSize(30)
|
|
|
+ rightMargin = autoSize(15)
|
|
|
+ topMargin = autoSize(30)
|
|
|
+ }.onClick {
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ button {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ text = "认购"
|
|
|
+ textSizeAuto = 36
|
|
|
+ textColorInt = R.color.white
|
|
|
+ backgroundDrawable =
|
|
|
+ createRoundRectDrawable("#2794FF", 10)
|
|
|
+ }.lparams(autoSize(0), autoSize(100), 1F) {
|
|
|
+ leftMargin = autoSize(15)
|
|
|
+ rightMargin = autoSize(30)
|
|
|
+ topMargin = autoSize(30)
|
|
|
+ }.onClick {
|
|
|
+ // 摘牌数量不能为0
|
|
|
+ if (qtyNumberEditText.text.isNullOrEmpty() || qtyNumberEditText.text == "0") {
|
|
|
+ ToastUtils.showLong("认购数量不能为0")
|
|
|
+ return@onClick
|
|
|
+ }
|
|
|
+ val qty = qtyNumberEditText.text.toLong()
|
|
|
+
|
|
|
+ // 市场
|
|
|
+ val marketID = GlobalDataCollection.instance?.getMaketidByTrademode(MTPEnums.TRADEMODE_CDYS) ?: 0
|
|
|
+
|
|
|
+ viewModel.HdWRDealOrderReq(
|
|
|
+ RelatedWRTradeOrderID = data.sellwrtradeorderid?.toLong() ?: 0,
|
|
|
+ WRTransferUserID = GlobalDataCollection.instance?.userAccountData?.userid?.toInt() ?: 0,
|
|
|
+ WRFactorTypeId = data.wrfactortypeid?.toLong() ?: 0,
|
|
|
+ OrderQty = qty,
|
|
|
+ BuyOrSell = 0, // 买方向
|
|
|
+ HasWr = 1,
|
|
|
+ MarketID = marketID,
|
|
|
+ ApplyID = data.presaleapplyid?.toLong() ?: 0
|
|
|
+ ) {
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(200))
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(700)) {
|
|
|
+ gravity = Gravity.BOTTOM
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }
|
|
|
+}
|