|
|
@@ -0,0 +1,484 @@
|
|
|
+package cn.muchinfo.rma.view.base.home.rolemanagement
|
|
|
+
|
|
|
+import android.os.Bundle
|
|
|
+import android.view.Gravity
|
|
|
+import android.view.View
|
|
|
+import android.view.inputmethod.EditorInfo
|
|
|
+import android.widget.EditText
|
|
|
+import androidx.lifecycle.MutableLiveData
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.MTPEnums
|
|
|
+import cn.muchinfo.rma.global.data.AccMgrLoginUserData
|
|
|
+import cn.muchinfo.rma.global.data.Userlist
|
|
|
+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.*
|
|
|
+
|
|
|
+/**
|
|
|
+ * 账户管理进入的新增登录账户
|
|
|
+ * @property dialog Dialog
|
|
|
+ */
|
|
|
+class AddLoginRoleActivity : BaseActivity<RoleSetViewModel>() {
|
|
|
+
|
|
|
+ val dialog by lazy { createLoadingDialog(hintStr = "请求中...") }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 1 新增 2 详情 3 修改 4 锁定 5 注销
|
|
|
+ */
|
|
|
+ val type by lazy { intent.getSerializableExtra("type") }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 传入的可供选择的账户角色类型
|
|
|
+ */
|
|
|
+ val seletType by lazy { intent.getSerializableExtra("seletType") as List<AccMgrLoginUserData> }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 当前选择操作的账户角色类型
|
|
|
+ */
|
|
|
+ val data by lazy { intent.getParcelableExtra<AccMgrLoginUserData>("data") as AccMgrLoginUserData }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 当页面是详情 修改 锁定 注销时的数据回填用
|
|
|
+ */
|
|
|
+ val data1 by lazy { intent.getParcelableExtra<Userlist>("data1") as Userlist }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 输入的登录账户
|
|
|
+ */
|
|
|
+ lateinit var login_account: EditText
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 输入的账户名称
|
|
|
+ */
|
|
|
+ lateinit var account_name: EditText
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 输入的登录密码
|
|
|
+ */
|
|
|
+ lateinit var login_password: EditText
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 手机号码
|
|
|
+ */
|
|
|
+ lateinit var phone_number: EditText
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择的账户角色
|
|
|
+ */
|
|
|
+ val roleTypeSelectData: MutableLiveData<SelectData> = MutableLiveData()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面数据的初始化
|
|
|
+ */
|
|
|
+ fun init() {
|
|
|
+ roleTypeSelectData.postValue(
|
|
|
+ SelectData(
|
|
|
+ id = data.roleid ?: "",
|
|
|
+ value = data.rolename ?: ""
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ verticalLayout {
|
|
|
+ init()
|
|
|
+ dialog.bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
+ background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
+ //页面标题
|
|
|
+ topBar {
|
|
|
+ commonLeftButton()
|
|
|
+ commonTitle {
|
|
|
+ if (type == "1") {
|
|
|
+ text = "新增角色"
|
|
|
+ } else if (type == "2") {
|
|
|
+ text = "角色详情"
|
|
|
+ } else if (type == "3") {
|
|
|
+ text = "修改"
|
|
|
+ } else if (type == "4") {
|
|
|
+ text = "锁定"
|
|
|
+ } else if (type == "5") {
|
|
|
+ text = "注销"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ frameLayout {
|
|
|
+ nestedScrollView {
|
|
|
+ verticalLayout {
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.INVISIBLE
|
|
|
+ text = "*"
|
|
|
+ textColorInt = R.color.rma_star_color
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(37)
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ text = "登录账号"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ }
|
|
|
+
|
|
|
+ editText {
|
|
|
+ isEnabled = type == "1" || type == "3"
|
|
|
+ if (type != "1") {
|
|
|
+ setText(data1.rolename)
|
|
|
+ }
|
|
|
+ login_account = this
|
|
|
+ hint = "请输入登录账号"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132)) {
|
|
|
+ marginStart = autoSize(80)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.INVISIBLE
|
|
|
+ text = "*"
|
|
|
+ textColorInt = R.color.rma_star_color
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(37)
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ text = "账户名称"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ }
|
|
|
+
|
|
|
+ editText {
|
|
|
+ account_name = this
|
|
|
+ isEnabled = type == "1" || type == "3"
|
|
|
+ if (type != "1") {
|
|
|
+ setText(data1.accountname)
|
|
|
+ }
|
|
|
+ hint = "请输入账户名称"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132)) {
|
|
|
+ marginStart = autoSize(80)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.INVISIBLE
|
|
|
+ text = "*"
|
|
|
+ textColorInt = R.color.rma_star_color
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(37)
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ text = "登录密码"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ }
|
|
|
+
|
|
|
+ editText {
|
|
|
+ login_password = this
|
|
|
+ isEnabled = type == "1" || type == "3"
|
|
|
+ if (type != "1") {
|
|
|
+ setText("********")
|
|
|
+ }
|
|
|
+ hint = "请输入登录密码"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132)) {
|
|
|
+ marginStart = autoSize(80)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.INVISIBLE
|
|
|
+ text = "*"
|
|
|
+ textColorInt = R.color.rma_star_color
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(37)
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ text = "手机号码"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ }
|
|
|
+
|
|
|
+ editText {
|
|
|
+ phone_number = this
|
|
|
+ isEnabled = type == "1" || type == "3"
|
|
|
+ if (type != "1") {
|
|
|
+ setText("")
|
|
|
+ }
|
|
|
+ hint = "非必填,用于找回密码"
|
|
|
+ background = null
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_PHONE
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(132)) {
|
|
|
+ marginStart = autoSize(80)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ onThrottleFirstClick {
|
|
|
+ creatBottomSheetDialog("请选择合同类型", getSelectDataList()) {
|
|
|
+ roleTypeSelectData.postValue(this)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ visibility = View.INVISIBLE
|
|
|
+ text = "*"
|
|
|
+ textColorInt = R.color.rma_star_color
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(37)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "账户角色"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ }
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.rma_select_click
|
|
|
+ }.lparams(autoSize(25), autoSize(25)) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ textSizeAuto = 31
|
|
|
+ text = "业务员"
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(wrapContent, autoSize(132))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.rma_select_click
|
|
|
+ }.lparams(autoSize(25), autoSize(25)) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ textSizeAuto = 31
|
|
|
+ text = "跟单员"
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(wrapContent, autoSize(132))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.rma_select_click
|
|
|
+ }.lparams(autoSize(25), autoSize(25)) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ textSizeAuto = 31
|
|
|
+ text = "交易员"
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(wrapContent, autoSize(132))
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.INVISIBLE
|
|
|
+ text = "*"
|
|
|
+ textColorInt = R.color.rma_star_color
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(37)
|
|
|
+ }
|
|
|
+ textView {
|
|
|
+ text = "授权期货账户"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "请勾选期货账户"
|
|
|
+ textColorInt = R.color.rma_yellow_text_color
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(40)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.add_role_bg_color)
|
|
|
+// adapter = addRoleAdapter
|
|
|
+ isNestedScrollingEnabled = false
|
|
|
+ }.lparams(matchParent, wrapContent){
|
|
|
+ bottomMargin = autoSize(200)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+
|
|
|
+
|
|
|
+ textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ if (check().not()) {
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ if (type == "1") {// 1 新增 2 详情 3 修改 4 锁定 5 注销
|
|
|
+ viewModel.LoginaccountOperateReq(
|
|
|
+ operatetype = 3,
|
|
|
+ logincode = login_account.text.toString(),
|
|
|
+ accountname = account_name.text.toString(),
|
|
|
+ password = login_password.text.toString(),
|
|
|
+ mobile = phone_number.text.toString(),
|
|
|
+ roleids = arrayListOf(
|
|
|
+ roleTypeSelectData.value?.id?.toLong() ?: 0
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ } else if (type == "3") {//修改
|
|
|
+ viewModel.LoginaccountOperateReq(
|
|
|
+ operatetype = 4,
|
|
|
+ logincode = login_account.text.toString(),
|
|
|
+ accountname = account_name.text.toString(),
|
|
|
+ password = login_password.text.toString(),
|
|
|
+ mobile = phone_number.text.toString(),
|
|
|
+ roleids = arrayListOf(
|
|
|
+ roleTypeSelectData.value?.id?.toLong() ?: 0
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ backgroundResource = R.mipmap.rma_submit_bg
|
|
|
+ text = "完成"
|
|
|
+ textColorInt = R.color.white
|
|
|
+ textSizeAuto = 38
|
|
|
+ }.lparams(matchParent, autoSize(119)) {
|
|
|
+ marginStart = autoSize(60)
|
|
|
+ marginEnd = autoSize(60)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(144)) {
|
|
|
+ gravity = Gravity.BOTTOM
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 可选择的账户角色
|
|
|
+ */
|
|
|
+ fun getSelectDataList(): List<SelectData> {
|
|
|
+ val selectList = arrayListOf<SelectData>()
|
|
|
+ seletType.forEach {
|
|
|
+ selectList.add(SelectData(id = it.roleid ?: "", value = it.rolename ?: ""))
|
|
|
+ }
|
|
|
+ return selectList
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 操作前的数据效验
|
|
|
+ * @return Boolean
|
|
|
+ */
|
|
|
+ fun check(): Boolean {
|
|
|
+ if (login_account.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入登录账号")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (account_name.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入账户名称")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (login_password.text.toString().isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入登录密码")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+}
|