|
@@ -6,6 +6,7 @@ import cn.muchinfo.rma.global.data.*
|
|
|
import cn.muchinfo.rma.netManage.base.InteractiveException
|
|
import cn.muchinfo.rma.netManage.base.InteractiveException
|
|
|
import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI2
|
|
import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI2
|
|
|
import cn.muchinfo.rma.view.MyApplication
|
|
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.autoWidget.toArrayList
|
|
|
import cn.muchinfo.rma.view.base.BaseViewModel
|
|
import cn.muchinfo.rma.view.base.BaseViewModel
|
|
|
import com.blankj.utilcode.util.LogUtils
|
|
import com.blankj.utilcode.util.LogUtils
|
|
@@ -116,7 +117,7 @@ class RoleSetViewModel : BaseViewModel(){
|
|
|
fun queryAccMgrRoleMenu(roleid : String = ""){
|
|
fun queryAccMgrRoleMenu(roleid : String = ""){
|
|
|
val params = mutableMapOf<String, String>().apply {
|
|
val params = mutableMapOf<String, String>().apply {
|
|
|
put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
- put("roleid","0")
|
|
|
|
|
|
|
+// put("roleid","0")
|
|
|
}
|
|
}
|
|
|
MyApplication.getInstance()?.accountManager?.queryAccMgrRoleMenu(params = params){isSuccess, respData, error ->
|
|
MyApplication.getInstance()?.accountManager?.queryAccMgrRoleMenu(params = params){isSuccess, respData, error ->
|
|
|
if (isSuccess){
|
|
if (isSuccess){
|
|
@@ -146,11 +147,11 @@ class RoleSetViewModel : BaseViewModel(){
|
|
|
fun setClickMenuList(haveMenuList : List<AccMgrRoleMenuData>) : List<AccMgrRoleMenuData>{
|
|
fun setClickMenuList(haveMenuList : List<AccMgrRoleMenuData>) : List<AccMgrRoleMenuData>{
|
|
|
val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
|
|
val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
|
|
|
haveMenuList.forEach { data ->
|
|
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
|
|
return newMenuDataList
|
|
|
}
|
|
}
|
|
@@ -163,43 +164,116 @@ class RoleSetViewModel : BaseViewModel(){
|
|
|
val emptyMenuList = roleMenuDataList.value//请求的全部未选择的列表
|
|
val emptyMenuList = roleMenuDataList.value//请求的全部未选择的列表
|
|
|
val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()//用来存放组合后的列表
|
|
val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()//用来存放组合后的列表
|
|
|
emptyMenuList?.forEach {data1 ->//遍历
|
|
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{
|
|
}else{
|
|
|
- newSonMenuList.add(emptySonData)
|
|
|
|
|
|
|
+ newSonSubMenuDataList.add(data)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ newSonMenuData.SubMenu = newSonSubMenuDataList
|
|
|
|
|
+ newMenuDataList.add(newSonMenuData)
|
|
|
}else{
|
|
}else{
|
|
|
- data1.SubMenu?.let { newSonMenuList.addAll(it) }
|
|
|
|
|
|
|
+ newMenuDataList.add(it)
|
|
|
}
|
|
}
|
|
|
- newMenuDataList.add(data1.copy(SubMenu = newSonMenuList))
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
roleMenuDataList.postValue(newMenuDataList)
|
|
roleMenuDataList.postValue(newMenuDataList)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * item全选点击
|
|
|
|
|
- * @param index Int 点击的item在列表内的索引
|
|
|
|
|
|
|
+ * item二级菜单点击
|
|
|
|
|
+ * firstresourcecode 一级菜单menu的唯一标识
|
|
|
|
|
+ * secondresourcecode 二级菜单的menu唯一标识
|
|
|
* isSelect 操作的类型,0 设置全不选 1设置全选
|
|
* isSelect 操作的类型,0 设置全不选 1设置全选
|
|
|
*/
|
|
*/
|
|
|
- fun setAllRoleSelect(index: Int,isSelect : Int){
|
|
|
|
|
|
|
+ fun setOnSecondRoleSelect(firstresourcecode: String,secondresourcecode : String,isSelect : Boolean){
|
|
|
val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
|
|
val newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
|
|
|
val oldMenuDataList = roleMenuDataList.value
|
|
val oldMenuDataList = roleMenuDataList.value
|
|
|
|
|
+
|
|
|
|
|
+ //遍历出一级菜单项
|
|
|
oldMenuDataList?.forEach {
|
|
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{
|
|
}else{
|
|
|
newMenuDataList.add(it)
|
|
newMenuDataList.add(it)
|
|
|
}
|
|
}
|
|
@@ -208,36 +282,44 @@ class RoleSetViewModel : BaseViewModel(){
|
|
|
roleMenuDataList.postValue(newMenuDataList)
|
|
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 newMenuDataList = arrayListOf<AccMgrRoleMenuData>()
|
|
|
val oldMenuDataList = roleMenuDataList.value
|
|
val oldMenuDataList = roleMenuDataList.value
|
|
|
|
|
+ //遍历出一级菜单项
|
|
|
oldMenuDataList?.forEach {
|
|
oldMenuDataList?.forEach {
|
|
|
if (resourcecode == it.Menu?.resourcecode){
|
|
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{
|
|
}else{
|
|
|
newMenuDataList.add(it)
|
|
newMenuDataList.add(it)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
roleMenuDataList.postValue(newMenuDataList)
|
|
roleMenuDataList.postValue(newMenuDataList)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
* @param operatetype Int
|
|
* @param operatetype Int
|
|
@@ -284,22 +366,27 @@ class RoleSetViewModel : BaseViewModel(){
|
|
|
fun getUpdateMenuDataList() : List<ManageServiceMI2.MemberFuncMenu>{
|
|
fun getUpdateMenuDataList() : List<ManageServiceMI2.MemberFuncMenu>{
|
|
|
val menuDataList = roleMenuDataList.value
|
|
val menuDataList = roleMenuDataList.value
|
|
|
val updateMenuList = arrayListOf<ManageServiceMI2.MemberFuncMenu>()
|
|
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
|
|
return updateMenuList
|
|
|
}
|
|
}
|