瀏覽代碼

风险管理5月18日提交代码-liu.bolan

Liu.bolan 4 年之前
父節點
當前提交
5271461438

+ 2 - 1
RMA/app/src/main/java/cn/muchinfo/rma/business/account/AccountManager.kt

@@ -811,6 +811,7 @@ class AccountManager {
      */
     fun TaaccountTransfersxmoneyReq(
         accountid : Long,
+        relateduserid : Long,
         sxmoney : Double,
         callback: (isCompleted: Boolean, err: Error?) -> Unit
     ){
@@ -820,7 +821,7 @@ class AccountManager {
         }
 
         val reqPacket = AccountAdapter.getTaaccountTransfersxmoneyReqInfo(
-            accountid, sxmoney
+            accountid,relateduserid, sxmoney
         )
 
         tradeSocketManager.send(

+ 2 - 1
RMA/app/src/main/java/cn/muchinfo/rma/business/account/adapter/AccountAdapter.kt

@@ -541,6 +541,7 @@ class AccountAdapter {
          */
         fun getTaaccountTransfersxmoneyReqInfo(
             accountid : Long,
+            relateduserid : Long,
             sxmoney : Double
         ) : Packet50{
             val builder = ManageServiceMI2.TaaccountTransfersxmoneyReq.newBuilder()
@@ -559,7 +560,7 @@ class AccountAdapter {
             builder.accountid = accountid
             builder.sxmoney = sxmoney
             builder.modifierid = loginInfo.loginID
-            builder.areauserid = loginInfo.userID.toLong()
+            builder.areauserid = relateduserid
             val arrayOutputStream = ByteArrayOutputStream()
             builder.build().writeTo(arrayOutputStream)
             return Packet50(FunCode.TaaccountTransfersxmoneyReq, arrayOutputStream.toByteArray())

+ 7 - 6
RMA/app/src/main/java/cn/muchinfo/rma/global/data/AccMgrRoleMenuData.kt

@@ -8,11 +8,11 @@ import android.os.Parcelable
  */
 data class AccMgrRoleMenuData(
     var Menu : RoleSonMenuData? = RoleSonMenuData(),
-    var SubMenu : List<RoleSonMenuData>? = arrayListOf()
+    var SubMenu : List<AccMgrRoleMenuData>? = arrayListOf()
 ) : Parcelable{
     constructor(parcel: Parcel) : this(
         parcel.readParcelable(RoleSonMenuData::class.java.classLoader),
-        parcel.createTypedArrayList(RoleSonMenuData)
+        parcel.createTypedArrayList(CREATOR)
     ) {
     }
 
@@ -35,9 +35,10 @@ data class AccMgrRoleMenuData(
         }
     }
 
-
 }
 
+
+
 data class RoleSonMenuData(
     val iconame : String? = "",//菜单图标
     val menutype : String? = "",//菜单类型 1:管理端 2:交易端 3:终端(企业云平台)
@@ -50,7 +51,7 @@ data class RoleSonMenuData(
     val sort : String? = "",//排序
     val url : String? = "",//URL
     val userid : String? = "",//用户id
-    var isSelcet : Int = 0//是否被选择
+    var ishadrole : Boolean? = false//是否有权限
 ) : Parcelable{
     constructor(parcel: Parcel) : this(
         parcel.readString(),
@@ -64,7 +65,7 @@ data class RoleSonMenuData(
         parcel.readString(),
         parcel.readString(),
         parcel.readString(),
-        parcel.readInt()
+        parcel.readValue(Boolean::class.java.classLoader) as? Boolean
     ) {
     }
 
@@ -80,7 +81,7 @@ data class RoleSonMenuData(
         parcel.writeString(sort)
         parcel.writeString(url)
         parcel.writeString(userid)
-        parcel.writeInt(isSelcet)
+        parcel.writeValue(ishadrole)
     }
 
     override fun describeContents(): Int {

+ 28 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/accountmanager/AccountManagerActivity.kt

@@ -122,6 +122,18 @@ class AccountManagerActivity : BaseActivity<AccountManagerViewModel>() {
 
     }
 
+    override fun onResume() {
+        super.onResume()
+        if (selectedTabIndex == 0){
+            loginAccountManager.refrash()
+        }else if (selectedTabIndex == 1){
+            tradingAccountManager.refrash()
+        }else if (selectedTabIndex == 2){
+            managerAccountUI.refrash()
+        }else if (selectedTabIndex == 3){
+            futuresAccountManager.refrash()
+        }
+    }
 
 
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -202,6 +214,10 @@ class LoginAccountManager(
     //登录账户是否可选择
     val isClickSelect: MutableLiveData<Int> = MutableLiveData<Int>().apply { value = 1 }
 
+    fun refrash(){
+        viewModel.queryBusinessAccMgrLoginUser()
+    }
+
     init {
         viewModel.initAccountData()
         viewModel.queryBusinessAccMgrLoginUser()
@@ -315,6 +331,10 @@ class TradingAccountManager(
     //交易账户是否可选择
     val isClickSelect: MutableLiveData<Int> = MutableLiveData<Int>().apply { value = 1 }
 
+    fun refrash(){
+        viewModel.queryTradingAccMgrLoginUser()
+    }
+
     init {
         viewModel.initAccountData()
         viewModel.queryTradingAccMgrLoginUser()
@@ -430,6 +450,10 @@ class ManagerAccountUI(
         viewModel.queryManagerAccMgrLoginUser()
     }
 
+    fun refrash(){
+        viewModel.queryManagerAccMgrLoginUser()
+    }
+
     val root = _FrameLayout(activity).apply {
         verticalLayout {
 
@@ -579,6 +603,10 @@ class FuturesAccountManager(
         viewModel.queryAccMgrTaaccount()
     }
 
+    fun refrash(){
+        viewModel.queryAccMgrTaaccount()
+    }
+
     val root = _FrameLayout(activity).apply {
         verticalLayout {
             linearLayout {

+ 30 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/accountmanager/AccountManagerViewModel.kt

@@ -357,4 +357,34 @@ class AccountManagerViewModel : BaseViewModel(){
         }
     }
 
+    /**
+     * 期货账户注销
+     * @param accountid Long 期货账户ID
+     * @return Packet50
+     */
+    fun TaaccountOperateReq(
+        accountid : Long,
+        isSuccess: (isCompleted: Boolean) -> Unit
+    ){
+        loadingDialogStatus.value = TaskUiModel.inFlight()
+        GlobalScope.launch {
+            MyApplication.getInstance()?.accountManager?.TaaccountOperateReq(
+                accountid = accountid
+            ){ isCompleted, err ->
+                if (isCompleted) {
+                    loadingDialogStatus.postValue(TaskUiModel.success(msg = "请求成功"))
+                    isSuccess(true)
+                } else {
+                    loadingDialogStatus.postValue(
+                        TaskUiModel.failed(
+                            InteractiveException(
+                                errorMessage = err?.message!!
+                            )
+                        )
+                    )
+                }
+            }
+        }
+    }
+
 }

+ 3 - 7
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/accountmanager/accountviewholder/FutureUserViewHolder.kt

@@ -167,13 +167,9 @@ class FutureUserViewHolder(private val activity : AppCompatActivity,private val
                         }
                     }
                     onThrottleFirstClick {
-//                        viewModel.LoginaccountOperateReq(
-//                            operatetype = 7,
-//                            userid = data.value?.userid?.toLong() ?: 0,
-//                            loginid = data.value?.loginid?.toLong() ?: 0
-//                        ){
-//                            viewModel.queryAccMgrLoginUser()
-//                        }
+                        viewModel.TaaccountOperateReq(accountid = data.value?.accountid?.toLong() ?: 0){
+                            viewModel.queryAccMgrTaaccount()
+                        }
                     }
                     backgroundResource = R.drawable.rma_item_click_bg
                     gravity = Gravity.CENTER

+ 2 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/accountmanager/futureaccount/FutureAccountViewModel.kt

@@ -337,6 +337,7 @@ class FutureAccountViewModel : BaseViewModel(){
      */
     fun TaaccountTransfersxmoneyReq(
         accountid : Long,
+        relateduserid : Long,
         sxmoney : Double,
         isSuccess: (isCompleted: Boolean) -> Unit
     ){
@@ -344,6 +345,7 @@ class FutureAccountViewModel : BaseViewModel(){
         GlobalScope.launch {
             MyApplication.getInstance()?.accountManager?.TaaccountTransfersxmoneyReq(
                 accountid = accountid,
+                relateduserid = relateduserid,
                 sxmoney = sxmoney
             ){ isCompleted, err ->
                 if (isCompleted) {

+ 1 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/accountmanager/futureaccount/FutureCreditActivity.kt

@@ -190,6 +190,7 @@ class FutureCreditActivity : BaseActivity<FutureAccountViewModel>(){
                         }
                         viewModel.TaaccountTransfersxmoneyReq(
                             accountid = data.accountid?.toLong() ?: 0,
+                            relateduserid = data.relateduserid?.toLong() ?: 0,
                             sxmoney = credit_amount.text.toString().toDouble()
                         ){
                             finish()

+ 10 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/contract/AddContractActivity.kt

@@ -1075,6 +1075,16 @@ class AddContractActivity : BaseActivity<ContractViewModel>() {
                             }
 
                             textView {
+//                                selelctCurreryId.bindOptional(context){
+//                                    if (selectWrStandModel.value?.id.isNullOrEmpty()){
+//                                        text = it?.value
+//                                    }else{
+//                                        text = it?.value + "/" +  selectWrStandModel.value?.enumdicname
+//                                    }
+//                                }
+                                selectWrStandModel.bindOptional(context){
+                                    text = "元/" +  it?.enumdicname
+                                }
                                 text = "元"
                                 textSizeAuto = 31
                                 textColorInt = R.color.rma_black_33

+ 179 - 13
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/hedge/HedgeDetailsActivity.kt

@@ -6,13 +6,22 @@ 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.business.hedge.HedgePlanInfo
+import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.ViewEnumUtils
 import cn.muchinfo.rma.global.data.ContractData
 import cn.muchinfo.rma.global.data.HedgePlanData
+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.home.contract.emptyView
 import cn.muchinfo.rma.view.base.home.contract.viewItemUI
+import com.blankj.utilcode.util.SPUtils
+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.*
@@ -41,20 +50,30 @@ class HedgeDetailsActivity : BaseActivity<HedgePlanViewModel>() {
 
     private val dialog by lazy { createLoadingDialog(hintStr = "请求中...") }
 
+    /** 选择的币种 ***/
+    val selelctCurreryId: MutableLiveData<SelectData> = MutableLiveData()
+
+    /** 选择的交易用户 ***/
+    val transactionUserSelectData: MutableLiveData<SelectData> = MutableLiveData()
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         verticalLayout {
             background = resources.getDrawable(R.color.segtabment_bg_color)
             dialog.bindTaskStatus(context, viewModel.loadingDialogStatus)
+            if (type == "2"){
+                selelctCurreryId.value = SelectData(id = data.currencyid ?: "",value = data.currencyname ?: "")
+                transactionUserSelectData.value = SelectData(id = data.tradeuserid ?: "",value = data.tradeusername ?: "")
+            }
+            viewModel.queryTradingAccMgrLoginUser()
             topBar {
                 commonLeftButton()
                 commonTitle {
-                    if (type == "1"){
+                    if (type == "1") {
                         text = "详情"
-                    }else if (type == "2"){
+                    } else if (type == "2") {
                         text = "审核"
-                    }else if (type == "3"){
+                    } else if (type == "3") {
                         text = "撤销"
                     }
 
@@ -127,10 +146,12 @@ class HedgeDetailsActivity : BaseActivity<HedgePlanViewModel>() {
                                 content = data.hedgeplanno.toString()
                             )
 
-
                             viewItemUI()
 
-                            creatHedgeItemView(titleString = "标仓系数", content = data.convertfactor ?: "")
+                            creatHedgeItemView(
+                                titleString = "标仓系数",
+                                content = data.convertfactor ?: ""
+                            )
 
                             viewItemUI()
 
@@ -139,13 +160,121 @@ class HedgeDetailsActivity : BaseActivity<HedgePlanViewModel>() {
                                 content = data.planqty + data.enumdicname
                             )
 
-                            viewItemUI()
+                            if (type == "2") {
 
-                            creatHedgeItemView(titleString = "交易用户", content = data.tradeusername ?: "")
+                                viewItemUI()
+
+                                linearLayout {
+                                    gravity = Gravity.CENTER_VERTICAL
+                                    onThrottleFirstClick {
+                                        creatBottomSheetDialog(
+                                            "请选择交易用户",
+                                            viewModel.getCanSelectTradingAccountList()
+                                        ) {
+                                            transactionUserSelectData.postValue(this)
+                                        }
+                                    }
+                                    textView {
+                                        visibility = View.INVISIBLE
+                                        text = "*"
+                                        textColorInt = R.color.rma_star_color
+                                        textSizeAuto = 31
+                                    }.lparams(wrapContent, wrapContent) {
+                                        marginStart = autoSize(37)
+                                    }
 
-                            viewItemUI()
+                                    textView {
+                                        text = "交易用户"
+                                        textSizeAuto = 31
+                                        textColorInt = R.color.rma_black_33
+                                    }.lparams(wrapContent, wrapContent) {
+                                        marginStart = autoSize(10)
+                                    }
+
+                                    textView {
+                                        transactionUserSelectData.bindOptional(context) {
+                                            text = it?.value
+                                            textColorInt = R.color.rma_black_33
+                                        }
+                                        text = "请选择交易用户"
+                                        textSizeAuto = 31
+                                        textColorInt = R.color.rma_hint_text_color_ccc
+                                    }.lparams(wrapContent, wrapContent) {
+                                        marginStart = autoSize(80)
+                                    }
 
-                            creatHedgeItemView(titleString = "结算币种", content = data.currencyname ?: "")
+                                    emptyView()
+
+                                    imageView {
+                                        imageResource = R.mipmap.rma_more
+                                    }.lparams(autoSize(36), autoSize(36)) {
+                                        marginEnd = autoSize(25)
+                                    }
+                                }.lparams(matchParent, autoSize(132))
+                                viewItemUI()
+
+                                linearLayout {
+                                    background = resources.getDrawable(R.color.white)
+                                    gravity = Gravity.CENTER_VERTICAL
+                                    onThrottleFirstClick {
+                                        creatBottomSheetDialog(
+                                            "请选择结算币种",
+                                            viewModel.getSelectCurreryIdData()
+                                        ) {
+                                            selelctCurreryId.postValue(this)
+                                        }
+                                    }
+                                    textView {
+                                        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 {
+                                        selelctCurreryId.bindOptional(context) {
+                                            text = it?.value
+                                            textColorInt = R.color.rma_black_33
+                                        }
+                                        textSizeAuto = 31
+                                    }.lparams(wrapContent, wrapContent) {
+                                        marginStart = autoSize(80)
+                                    }
+
+                                    emptyView()
+
+                                    imageView {
+                                        imageResource = R.mipmap.rma_more
+                                    }.lparams(autoSize(36), autoSize(36)) {
+                                        marginEnd = autoSize(25)
+                                    }
+                                }.lparams(matchParent, autoSize(132))
+
+                                viewItemUI()
+                            } else {
+                                viewItemUI()
+
+                                creatHedgeItemView(
+                                    titleString = "交易用户",
+                                    content = data.tradeusername ?: ""
+                                )
+
+                                viewItemUI()
+
+                                creatHedgeItemView(
+                                    titleString = "结算币种",
+                                    content = data.currencyname ?: ""
+                                )
+                            }
 
                             viewItemUI()
 
@@ -222,11 +351,21 @@ class HedgeDetailsActivity : BaseActivity<HedgePlanViewModel>() {
                     gravity = Gravity.CENTER_VERTICAL
                     textView {
                         onThrottleFirstClick {
-                            viewModel.orderOneHedge(
+                            if (transactionUserSelectData.value?.id.isNullOrEmpty()){
+                                ToastUtils.showLong("请选择交易用户")
+                                return@onThrottleFirstClick
+                            }
+                            if (selelctCurreryId.value?.id.isNullOrEmpty()){
+                                ToastUtils.showLong("请选择结算币种")
+                                return@onThrottleFirstClick
+                            }
+                            viewModel.orderHedge(
+                                hedgePlanData = getHedgeInfo(),
                                 hedgePlanID = data.hedgeplanid?.toLong() ?: 0,
-                                operateType = 4,
+                                operateType = 5,
                                 remark = audit_opinion_edittext.text.toString()
                             ) {
+                                SPUtils.getInstance().put("isSelect", 0)
                                 finish()
                             }
                         }
@@ -246,13 +385,30 @@ class HedgeDetailsActivity : BaseActivity<HedgePlanViewModel>() {
 
                     textView {
                         onThrottleFirstClick {
-                            viewModel.orderOneHedge(
+                            if (transactionUserSelectData.value?.id.isNullOrEmpty()){
+                                ToastUtils.showLong("请选择交易用户")
+                                return@onThrottleFirstClick
+                            }
+                            if (selelctCurreryId.value?.id.isNullOrEmpty()){
+                                ToastUtils.showLong("请选择结算币种")
+                                return@onThrottleFirstClick
+                            }
+                            viewModel.orderHedge(
+                                hedgePlanData = getHedgeInfo(),
                                 hedgePlanID = data.hedgeplanid?.toLong() ?: 0,
-                                operateType = 3,
+                                operateType = 4,
                                 remark = audit_opinion_edittext.text.toString()
                             ) {
+                                SPUtils.getInstance().put("isSelect", 0)
                                 finish()
                             }
+//                            viewModel.orderOneHedge(
+//                                hedgePlanID = data.hedgeplanid?.toLong() ?: 0,
+//                                operateType = 3,
+//                                remark = audit_opinion_edittext.text.toString()
+//                            ) {
+//                                finish()
+//                            }
                         }
                         if (type == "2") {
                             visibility = View.VISIBLE
@@ -300,6 +456,16 @@ class HedgeDetailsActivity : BaseActivity<HedgePlanViewModel>() {
         }
     }
 
+    private fun getHedgeInfo(): HedgePlanInfo {
+        val hedgePlanInfo = HedgePlanInfo()
+        hedgePlanInfo.Currencyid = selelctCurreryId.value?.id ?: ""
+        //交易用户
+        if (transactionUserSelectData.value?.id.isNullOrEmpty().not()){
+            hedgePlanInfo.Tradeuserid = transactionUserSelectData.value?.id ?: ""
+        }
+        return hedgePlanInfo
+    }
+
 }
 
 fun _LinearLayout.creatHedgeItemView(titleString: String, content: String) {

+ 68 - 34
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/AddRoleItemViewHolder.kt

@@ -2,14 +2,16 @@ package cn.muchinfo.rma.view.base.home.rolemanagement
 
 import android.view.Gravity
 import androidx.appcompat.app.AppCompatActivity
+import androidx.recyclerview.widget.StaggeredGridLayoutManager
 import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.data.AccMgrRoleMenuData
 import cn.muchinfo.rma.global.data.RoleSonMenuData
 import cn.muchinfo.rma.lifecycle.bindOptional
-import cn.muchinfo.rma.view.autoWidget.autoSize
-import cn.muchinfo.rma.view.autoWidget.onThrottleFirstClick
-import cn.muchinfo.rma.view.autoWidget.textColorInt
-import cn.muchinfo.rma.view.autoWidget.textSizeAuto
+import cn.muchinfo.rma.view.autoWidget.*
+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.adapter.BaseAdapter
 import mtp.polymer.com.autowidget.adapter.BaseViewHolder
 import org.jetbrains.anko.*
 
@@ -21,43 +23,75 @@ import org.jetbrains.anko.*
  * @property itemSize IntArray
  * @constructor
  */
-class AddRoleItemViewHolder(private val activity : AppCompatActivity,private val viewModel: RoleSetViewModel,private val resourcecode : String) : BaseViewHolder<RoleSonMenuData>(activity){
-    override val itemSize: IntArray = intArrayOf(autoSize(300), wrapContent)
+class AddRoleItemViewHolder(private val activity : AppCompatActivity,private val viewModel: RoleSetViewModel,private val resourcecode : String) : BaseViewHolder<AccMgrRoleMenuData>(activity){
+    override val itemSize: IntArray = intArrayOf(matchParent, wrapContent)
 
     override fun _FrameLayout.createContentView() {
-        linearLayout {
-            onThrottleFirstClick {
-                viewModel.setOnCloneClick(resourcecode,dataIndex)
-            }
-            gravity = Gravity.CENTER_VERTICAL
-            imageView {
-
-                data.bindOptional(context){
-                    if (it?.isSelcet == 0){
-                        imageResource = R.mipmap.rma_normal_click
-                    }else{
-                        imageResource = R.mipmap.rma_select_click
+        verticalLayout {
+            linearLayout {
+                gravity = Gravity.CENTER_VERTICAL
+
+                linearLayout {
+                    onThrottleFirstClick {//应该变成二级菜单的全部点击事件
+                        viewModel.setOnSecondRoleSelect(resourcecode,data.value?.Menu?.resourcecode ?: "",data.value?.Menu?.ishadrole?.not() ?: false)
                     }
-                }
-            }.lparams(autoSize(38), autoSize(38)){
-                marginStart =  autoSize(36)
-            }
+                    gravity = Gravity.CENTER_VERTICAL
 
-            textView {
-                data.bindOptional(context){
-                    text = it?.resourcename
-                    if (it?.isSelcet == 0){
-                        textColorInt = R.color.rma_black_33
-                    }else{
-                        textColorInt = R.color.rma_blue_color
+                    imageView {
+                        data.bindOptional(context){
+                            if (it?.Menu?.ishadrole == false){
+                                imageResource = R.mipmap.rma_normal_click
+                            }else{
+                                imageResource = R.mipmap.rma_select_click
+                            }
+                        }
+                    }.lparams(autoSize(38), autoSize(38)){
+                        marginStart =  autoSize(36)
+                    }
+
+                    textView {
+                        data.bindOptional(context){
+                            text = it?.Menu?.resourcename
+                            if (it?.Menu?.ishadrole == false){
+                                textColorInt = R.color.rma_black_33
+                            }else{
+                                textColorInt = R.color.rma_blue_color
+                            }
+                        }
+                        textSizeAuto = 31
+
+                    }.lparams(wrapContent, wrapContent){
+                        marginStart = autoSize(20)
                     }
-                }
-                textSizeAuto = 31
 
-            }.lparams(wrapContent, wrapContent){
-                marginStart = autoSize(20)
+
+
+                }.lparams(autoSize(300), autoSize(92))
+
+                view {
+                    background = resources.getDrawable(R.color.line_hint_color)
+                }.lparams(autoSize(1), matchParent)
+
+                recyclerView {
+                    val staggeredGridLayoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
+                    layoutManager = staggeredGridLayoutManager
+
+                    data.bindOptional(context){
+                        val addRoleItemAdapter: BaseAdapter<AccMgrRoleMenuData, AddRoleTwoItemViewHolder> =
+                            BaseAdapter { _, _ -> AddRoleTwoItemViewHolder(activity, viewModel,resourcecode,it?.Menu?.resourcecode ?: "") }
+                        adapter = addRoleItemAdapter
+                        addRoleItemAdapter.setNewData(it?.SubMenu)
+                    }
+                }
+            }.lparams(matchParent, wrapContent)
+            view {
+                background = resources.getDrawable(R.color.line_hint_color)
+            }.lparams(matchParent, autoSize(1)){
+                marginEnd = autoSize(36)
+                marginStart = autoSize(36)
             }
-        }.lparams(autoSize(300), autoSize(92))
+        }.lparams(matchParent, wrapContent)
+
     }
 
 }

+ 63 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/AddRoleTwoItemViewHolder.kt

@@ -0,0 +1,63 @@
+package cn.muchinfo.rma.view.base.home.rolemanagement
+
+import android.view.Gravity
+import androidx.appcompat.app.AppCompatActivity
+import androidx.recyclerview.widget.StaggeredGridLayoutManager
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.data.AccMgrRoleMenuData
+import cn.muchinfo.rma.global.data.RoleSonMenuData
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.*
+import com.blankj.utilcode.util.ToastUtils
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import org.jetbrains.anko.*
+
+/**
+ * 新增角色的item选择的viewholder
+ * @property activity AppCompatActivity
+ * @property viewModel RoleSetViewModel
+ * @property index Int
+ * @property itemSize IntArray
+ * @constructor
+ */
+class AddRoleTwoItemViewHolder(private val activity : AppCompatActivity, private val viewModel: RoleSetViewModel, private val firstresourcecode : String, private val secondresourcecode : String) : BaseViewHolder<AccMgrRoleMenuData>(activity){
+    override val itemSize: IntArray = intArrayOf(autoSize(300), wrapContent)
+
+    override fun _FrameLayout.createContentView() {
+        linearLayout {
+            onThrottleFirstClick {//应该变成二级菜单的全部点击事件
+                viewModel.setOnThreeRoleSelect(firstresourcecode,secondresourcecode,data.value?.Menu?.resourcecode ?: "",data.value?.Menu?.ishadrole?.not() ?: false)
+            }
+            gravity = Gravity.CENTER_VERTICAL
+
+            imageView {
+                data.bindOptional(context){
+                    if (it?.Menu?.ishadrole == false){
+                        imageResource = R.mipmap.rma_normal_click
+                    }else{
+                        imageResource = R.mipmap.rma_select_click
+                    }
+                }
+            }.lparams(autoSize(38), autoSize(38)){
+                marginStart =  autoSize(36)
+            }
+
+            textView {
+                data.bindOptional(context){
+                    text = it?.Menu?.resourcename
+                    if (it?.Menu?.ishadrole == false){
+                        textColorInt = R.color.rma_black_33
+                    }else{
+                        textColorInt = R.color.rma_blue_color
+                    }
+                }
+                textSizeAuto = 31
+
+            }.lparams(wrapContent, wrapContent){
+                marginStart = autoSize(20)
+            }
+        }.lparams(autoSize(300), autoSize(92))
+    }
+
+}

+ 9 - 7
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/AddRoleViewHolder.kt

@@ -53,10 +53,10 @@ class AddRoleViewHolder(private val activity : AppCompatActivity,private val vie
                 textView {
 
                     onThrottleFirstClick {
-                        if (data.value?.Menu?.isSelcet == 0){
-                            viewModel.setAllRoleSelect(dataIndex,1)
+                        if (data.value?.Menu?.ishadrole == true){
+                            viewModel.setAllRoleSelect(data.value?.Menu?.resourcecode ?: "",false)
                         }else{
-                            viewModel.setAllRoleSelect(dataIndex,0)
+                            viewModel.setAllRoleSelect(data.value?.Menu?.resourcecode ?: "",true)
                         }
                     }
                     if (type == "3") {
@@ -65,7 +65,7 @@ class AddRoleViewHolder(private val activity : AppCompatActivity,private val vie
                         visibility = View.VISIBLE
                     }
                     data.bindOptional(context){
-                        text = if (it?.Menu?.isSelcet == 0){
+                        text = if (it?.Menu?.ishadrole == false){
                             "全选"
                         }else{
                             "全不选"
@@ -85,12 +85,14 @@ class AddRoleViewHolder(private val activity : AppCompatActivity,private val vie
                 marginEnd = autoSize(36)
                 marginStart = autoSize(36)
             }
+
+
             recyclerView {
-                val staggeredGridLayoutManager = StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)
-                layoutManager = staggeredGridLayoutManager
+//                val staggeredGridLayoutManager = StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)
+//                layoutManager = staggeredGridLayoutManager
 
                 data.bindOptional(context){
-                    val addRoleItemAdapter: BaseAdapter<RoleSonMenuData, AddRoleItemViewHolder> =
+                    val addRoleItemAdapter: BaseAdapter<AccMgrRoleMenuData, AddRoleItemViewHolder> =
                         BaseAdapter { _, _ -> AddRoleItemViewHolder(activity, viewModel,it?.Menu?.resourcecode ?: "") }
                     adapter = addRoleItemAdapter
                     addRoleItemAdapter.setNewData(it?.SubMenu)

+ 143 - 56
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/rolemanagement/RoleSetViewModel.kt

@@ -6,6 +6,7 @@ import cn.muchinfo.rma.global.data.*
 import cn.muchinfo.rma.netManage.base.InteractiveException
 import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI2
 import cn.muchinfo.rma.view.MyApplication
+import cn.muchinfo.rma.view.autoWidget.replaceOrInsert
 import cn.muchinfo.rma.view.autoWidget.toArrayList
 import cn.muchinfo.rma.view.base.BaseViewModel
 import com.blankj.utilcode.util.LogUtils
@@ -116,7 +117,7 @@ class RoleSetViewModel : BaseViewModel(){
     fun queryAccMgrRoleMenu(roleid : String = ""){
         val params = mutableMapOf<String, String>().apply {
             put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
-            put("roleid","0")
+//            put("roleid","0")
         }
         MyApplication.getInstance()?.accountManager?.queryAccMgrRoleMenu(params = params){isSuccess, respData, error ->
             if (isSuccess){
@@ -146,11 +147,11 @@ class RoleSetViewModel : BaseViewModel(){
     fun setClickMenuList(haveMenuList : List<AccMgrRoleMenuData>) : List<AccMgrRoleMenuData>{
         val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
         haveMenuList.forEach { data ->
-            val newSonMenuList = arrayListOf<RoleSonMenuData>()
-            data.SubMenu?.forEach {
-                newSonMenuList.add(it.copy(isSelcet = 1))
-            }
-            newMenuDataList.add(data.copy(SubMenu = newSonMenuList))
+//            val newSonMenuList = arrayListOf<RoleSonMenuData>()
+//            data.SubMenu?.forEach {
+//                newSonMenuList.add(it.copy(isSelcet = 1))
+//            }
+//            newMenuDataList.add(data.copy(SubMenu = newSonMenuList))
         }
         return newMenuDataList
     }
@@ -163,43 +164,116 @@ class RoleSetViewModel : BaseViewModel(){
         val emptyMenuList = roleMenuDataList.value//请求的全部未选择的列表
         val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()//用来存放组合后的列表
         emptyMenuList?.forEach {data1 ->//遍历
-            val newSonMenuList = arrayListOf<RoleSonMenuData>()//存放data的子列表的容器
-            val haveMenuData = haveMenuList.find { data1.Menu?.resourcecode == it.Menu?.resourcecode }//找到两个列表相同的实体
-            if (haveMenuData?.Menu?.resourcecode?.isNotEmpty() == true){
-                data1.SubMenu?.forEach {emptySonData ->//子列表遍历
-                    val haveSonData = haveMenuData.SubMenu?.find { it.resourcecode == emptySonData.resourcecode }
-                    if (haveSonData?.resourcecode?.isNotEmpty() == true){
-                        newSonMenuList.add(haveSonData.copy(isSelcet = 1))
+//            val newSonMenuList = arrayListOf<RoleSonMenuData>()//存放data的子列表的容器
+//            val haveMenuData = haveMenuList.find { data1.Menu?.resourcecode == it.Menu?.resourcecode }//找到两个列表相同的实体
+//            if (haveMenuData?.Menu?.resourcecode?.isNotEmpty() == true){
+//                data1.SubMenu?.forEach {emptySonData ->//子列表遍历
+//                    val haveSonData = haveMenuData.SubMenu?.find { it.resourcecode == emptySonData.resourcecode }
+//                    if (haveSonData?.resourcecode?.isNotEmpty() == true){
+//                        newSonMenuList.add(haveSonData.copy(isSelcet = 1))
+//                    }else{
+//                        newSonMenuList.add(emptySonData)
+//                    }
+//                }
+//            }else{
+//                data1.SubMenu?.let { newSonMenuList.addAll(it) }
+//            }
+//            newMenuDataList.add(data1.copy(SubMenu = newSonMenuList))
+        }
+        roleMenuDataList.postValue(newMenuDataList)
+    }
+
+    /**
+     * item三级菜单点击
+     * firstresourcecode 一级菜单menu的唯一标识
+     * secondresourcecode 二级菜单的menu唯一标识
+     * isSelect 操作的类型,0 设置全不选 1设置全选
+     */
+    fun setOnThreeRoleSelect(firstresourcecode: String,secondresourcecode : String,threeresourcecode : String,isSelect : Boolean){
+        val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
+        val oldMenuDataList = roleMenuDataList.value
+
+        //遍历出一级菜单项
+        oldMenuDataList?.forEach {
+            if (firstresourcecode == it.Menu?.resourcecode){
+                val newSonMenuData = AccMgrRoleMenuData()//选中的全选的整体数据
+                val newSonSubMenuDataList = arrayListOf<AccMgrRoleMenuData>()//定义一个子submenu列表
+                newSonMenuData.Menu = it.Menu?.copy(ishadrole = isSelect)//设置全选的menu
+
+                //遍历出二级菜单项//二级菜单的点击不需要遍历三级菜单
+                it.SubMenu?.forEach { data ->
+                    if (secondresourcecode == data.Menu?.resourcecode){
+                        val newSonTwoMenuData = AccMgrRoleMenuData()
+                        if (isSelect == true){
+                            newSonTwoMenuData.Menu = data.Menu?.copy(ishadrole = true)
+                        }else{
+                            newSonTwoMenuData.Menu = data.Menu
+                        }
+                        val newSonTwoSubDataList = arrayListOf<AccMgrRoleMenuData>()
+                        //遍历出三级菜单
+                        data.SubMenu?.forEach {dataSon ->
+                            if (threeresourcecode == dataSon.Menu?.resourcecode){
+                                newSonTwoSubDataList.add(dataSon.copy(Menu = dataSon.Menu?.copy(ishadrole = isSelect)))
+                            }else{
+                                newSonTwoSubDataList.add(dataSon.copy(Menu = dataSon.Menu))
+                            }
+                        }
+                        newSonTwoMenuData.SubMenu = newSonTwoSubDataList
+                        newSonSubMenuDataList.add(newSonTwoMenuData)
                     }else{
-                        newSonMenuList.add(emptySonData)
+                        newSonSubMenuDataList.add(data)
                     }
                 }
+
+                newSonMenuData.SubMenu = newSonSubMenuDataList
+                newMenuDataList.add(newSonMenuData)
             }else{
-                data1.SubMenu?.let { newSonMenuList.addAll(it) }
+                newMenuDataList.add(it)
             }
-            newMenuDataList.add(data1.copy(SubMenu = newSonMenuList))
         }
+
         roleMenuDataList.postValue(newMenuDataList)
     }
 
     /**
-     *  item全选点击
-     * @param index Int 点击的item在列表内的索引
+     * item二级菜单点击
+     * firstresourcecode 一级菜单menu的唯一标识
+     * secondresourcecode 二级菜单的menu唯一标识
      * isSelect 操作的类型,0 设置全不选 1设置全选
      */
-    fun setAllRoleSelect(index: Int,isSelect : Int){
+    fun setOnSecondRoleSelect(firstresourcecode: String,secondresourcecode : String,isSelect : Boolean){
         val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
         val oldMenuDataList = roleMenuDataList.value
+
+        //遍历出一级菜单项
         oldMenuDataList?.forEach {
-            if (index == oldMenuDataList.indexOf(it)){
-                val newSonMenuDataList = arrayListOf<RoleSonMenuData>()
-                val oldSonMenuDataList = it.SubMenu
-                val menuData = it.Menu
-                menuData?.isSelcet = isSelect
-                oldSonMenuDataList?.forEach {
-                    newSonMenuDataList.add(it.copy(isSelcet = isSelect))
+            if (firstresourcecode == it.Menu?.resourcecode){
+                val newSonMenuData = AccMgrRoleMenuData()//选中的全选的整体数据
+                val newSonSubMenuDataList = arrayListOf<AccMgrRoleMenuData>()//定义一个子submenu列表
+                newSonMenuData.Menu = it.Menu?.copy(ishadrole = isSelect)//设置全选的menu
+
+                //遍历出二级菜单项
+                it.SubMenu?.forEach { data ->
+                    if (secondresourcecode == data.Menu?.resourcecode){
+                        val newSonTwoMenuData = AccMgrRoleMenuData()
+                        newSonTwoMenuData.Menu = data.Menu?.copy(ishadrole = isSelect)
+                        val newSonTwoSubDataList = arrayListOf<AccMgrRoleMenuData>()
+                        //遍历出三级菜单
+                        data.SubMenu?.forEach {dataSon ->
+                            if (isSelect == true){//二级菜单如果点击取消则取消所有的三级菜单选择
+                                newSonTwoSubDataList.add(dataSon.copy(Menu = dataSon.Menu))
+                            }else{
+                                newSonTwoSubDataList.add(dataSon.copy(Menu = dataSon.Menu?.copy(ishadrole = false)))
+                            }
+                        }
+                        newSonTwoMenuData.SubMenu = newSonTwoSubDataList
+                        newSonSubMenuDataList.add(newSonTwoMenuData)
+                    }else{
+                        newSonSubMenuDataList.add(data)
+                    }
                 }
-                newMenuDataList.add(it.copy(Menu = menuData,SubMenu = newSonMenuDataList))
+                newSonMenuData.SubMenu = newSonSubMenuDataList
+                newMenuDataList.add(newSonMenuData)
             }else{
                 newMenuDataList.add(it)
             }
@@ -208,36 +282,44 @@ class RoleSetViewModel : BaseViewModel(){
         roleMenuDataList.postValue(newMenuDataList)
     }
 
+
     /**
-     * item内单个选项点击
+     *  item全部点击
+     * isSelect 操作的类型,0 设置全不选 1设置全选
      */
-    fun setOnCloneClick(resourcecode: String,dataIndex : Int){
+    fun setAllRoleSelect(resourcecode: String,isSelect : Boolean){
         val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
         val oldMenuDataList = roleMenuDataList.value
+        //遍历出一级菜单项
         oldMenuDataList?.forEach {
             if (resourcecode == it.Menu?.resourcecode){
-                val newSonMenuDataList = arrayListOf<RoleSonMenuData>()
-                val oldSonMenuDataList = it.SubMenu
-                val menuData = it.Menu
-                oldSonMenuDataList?.forEach { data ->
-                    if (dataIndex == oldSonMenuDataList.indexOf(data)){
-                        if (data.isSelcet == 0){
-                            newSonMenuDataList.add(data.copy(isSelcet = 1))
-                        }else{
-                            newSonMenuDataList.add(data.copy(isSelcet = 0))
-                        }
-                    }else{
-                        newSonMenuDataList.add(data)
+                val newSonMenuData = AccMgrRoleMenuData()//选中的全选的整体数据
+                val newSonSubMenuDataList = arrayListOf<AccMgrRoleMenuData>()//定义一个子submenu列表
+                newSonMenuData.Menu = it.Menu?.copy(ishadrole = isSelect)//设置全选的menu
+                //遍历出二级菜单项
+                it.SubMenu?.forEach { data ->
+                    val newSonTwoMenuData = AccMgrRoleMenuData()
+                    newSonTwoMenuData.Menu = data.Menu?.copy(ishadrole = isSelect)
+                    val newSonTwoSubDataList = arrayListOf<AccMgrRoleMenuData>()
+                    //遍历出三级菜单
+                    data.SubMenu?.forEach {dataSon ->
+                        newSonTwoSubDataList.add(dataSon.copy(Menu = dataSon.Menu?.copy(ishadrole = isSelect)))
                     }
+                    newSonTwoMenuData.SubMenu = newSonTwoSubDataList
+                    newSonSubMenuDataList.add(newSonTwoMenuData)
                 }
-                newMenuDataList.add(AccMgrRoleMenuData(Menu = menuData,SubMenu = newSonMenuDataList))
+
+                newSonMenuData.SubMenu = newSonSubMenuDataList
+                newMenuDataList.add(newSonMenuData)
             }else{
                 newMenuDataList.add(it)
             }
         }
+
         roleMenuDataList.postValue(newMenuDataList)
     }
 
+
     /**
      *
      * @param operatetype Int
@@ -284,22 +366,27 @@ class RoleSetViewModel : BaseViewModel(){
     fun getUpdateMenuDataList() : List<ManageServiceMI2.MemberFuncMenu>{
         val menuDataList = roleMenuDataList.value
         val updateMenuList = arrayListOf<ManageServiceMI2.MemberFuncMenu>()
-        menuDataList?.forEach {data ->
-             val mapMenu : HashMap<String,String> = hashMapOf()
-
-            data.SubMenu?.forEach {
-                if (it.isSelcet == 1){
-                    val updataMenuData = ManageServiceMI2.MemberFuncMenu.newBuilder()
-                    updataMenuData.resourcecode = it.resourcecode
-                    updateMenuList.add(updataMenuData.build())
-                    mapMenu.put("resourcecode",data.Menu?.resourcecode ?: "")
+        menuDataList?.forEach {
+            if (it.Menu?.ishadrole == true){
+                val updataMenuData = ManageServiceMI2.MemberFuncMenu.newBuilder()
+                updataMenuData.resourcecode = it.Menu?.resourcecode
+                updateMenuList.add(updataMenuData.build())
+                //二级菜单遍历
+                it.SubMenu?.forEach { data ->
+                    if (data.Menu?.ishadrole == true){
+                        val updataMenuData1 = ManageServiceMI2.MemberFuncMenu.newBuilder()
+                        updataMenuData.resourcecode = it.Menu?.resourcecode
+                        updateMenuList.add(updataMenuData1.build())
+                    }
+                    data.SubMenu?.forEach { dataSon ->
+                        if (dataSon.Menu?.ishadrole == true){
+                            val updataMenuData2 = ManageServiceMI2.MemberFuncMenu.newBuilder()
+                            updataMenuData.resourcecode = it.Menu?.resourcecode
+                            updateMenuList.add(updataMenuData2.build())
+                        }
+                    }
                 }
             }
-            if (mapMenu.isNotEmpty()){
-                val updataMenuData1 = ManageServiceMI2.MemberFuncMenu.newBuilder()
-                updataMenuData1.resourcecode = mapMenu.get("resourcecode")
-                updateMenuList.add(updataMenuData1.build())
-            }
         }
         return updateMenuList
     }