Explorar o código

修改 平安管理账号 权限

huangbin %!s(int64=4) %!d(string=hai) anos
pai
achega
2c14e2f8b7

+ 91 - 30
src/views/information/account_info/compoments/add-managers-permission/index.vue

@@ -6,7 +6,7 @@
            @cancel="cancel"
            centered
            :maskClosable="false"
-           width="100%">
+           :width="isPingAnOem() ? '800px' : '100%'">
     <template #footer>
       <a-button key="cancel"
                 type="primary"
@@ -35,10 +35,14 @@
                        name></a-form-item>
         </a-col>
         <a-col :span="24">
-          <div class="powerTable">
-            <!-- <a-checkbox-group class="commonCheckboxGroup"
-
-                        >-->
+          <a-tree v-if="isPingAnOem()"
+                  checkable
+                  :tree-data="tableList"
+                  v-model:checkedKeys="checkedKeys"
+                  :replace-fields="replaceFields">
+          </a-tree>
+          <div class="powerTable"
+               v-else>
             <div class="powerRow"
                  v-for="(item, i) in tableList"
                  :key="i + '0'">
@@ -68,7 +72,6 @@
                 </div>
               </div>
             </div>
-            <!-- </a-checkbox-group> -->
           </div>
         </a-col>
       </a-row>
@@ -89,6 +92,7 @@ import { ManagerRoleOperateReq, MemberFuncMenu } from '@/services/proto/accounti
 import { getUserId } from '@/services/bus/account';
 import { getAoletype_string, getAreaUserId, getUserAccountType } from '@/services/bus/user';
 import { geLoginID_number } from '@/services/bus/login';
+import { isPingAnOem } from '@/common/config/projectName';
 
 export default defineComponent({
     name: 'account_info_manager_btn_add',
@@ -99,48 +103,75 @@ export default defineComponent({
         const loading = ref<boolean>(false);
         const tableList = ref<ErmcpRoleMenuEx[]>([]);
         const name = ref<string>('');
+        const replaceFields = {
+            children: 'SubMenu',
+            title: 'resourcename',
+            key: 'resourcecode',
+        };
+        const checkedKeys = ref<string[]>([]);
         watchEffect(() => {
             if (visible.value) {
-                const param = { userid: getUserId(), roleid: getAoletype_string() };
+                // 平安 权限层级超过 4 层了,原先设计最多支持3个层级,故得重新写
+                // 菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易 ps:新加的参数,为了兼容以前,不传则默认查3
+                const menutype = isPingAnOem() ? 5 : 3;
+                const param = { userid: getUserId(), roleid: getAoletype_string(), menutype };
+
                 queryResultLoadingAndInfo(QueryAccMgrRoleMenu, loading, param).then((res) => {
+                    const fn = (arr: any[]) => {
+                        arr.forEach((el) => {
+                            Object.assign(el, el.Menu);
+                            if (el.SubMenu.length) {
+                                fn(el.SubMenu);
+                            }
+                        });
+                    };
+                    fn(res);
                     tableList.value = res;
                 });
             }
         });
 
         function submit() {
-            const result: string[] = [];
-            // 处理已经勾选的数据
-            tableList.value.forEach((first) => {
-                if (first.Menu.ishadrole) {
-                    result.push(first.Menu.resourcecode);
-                    first.SubMenu.forEach((second) => {
-                        if (second.Menu.ishadrole) {
-                            result.push(second.Menu.resourcecode);
-                            second.SubMenu.forEach((third) => {
-                                if (third.Menu.ishadrole) {
-                                    result.push(third.Menu.resourcecode);
-                                }
-                            });
-                        }
-                    });
-                }
-            });
             if (!name.value) {
                 message.error('请输入角色名称');
                 return;
             }
-            if (result.length === 0) {
-                message.error('请至少选择一个权限');
-                return;
+
+            let checkedCodes = [];
+            if (isPingAnOem()) {
+                checkedCodes = checkedKeys.value;
+            } else {
+                const result: string[] = [];
+                // 处理已经勾选的数据
+                tableList.value.forEach((first) => {
+                    if (first.Menu.ishadrole) {
+                        result.push(first.Menu.resourcecode);
+                        first.SubMenu.forEach((second) => {
+                            if (second.Menu.ishadrole) {
+                                result.push(second.Menu.resourcecode);
+                                second.SubMenu.forEach((third) => {
+                                    if (third.Menu.ishadrole) {
+                                        result.push(third.Menu.resourcecode);
+                                    }
+                                });
+                            }
+                        });
+                    }
+                });
+                if (result.length === 0) {
+                    message.error('请至少选择一个权限');
+                    return;
+                }
+                checkedCodes = result;
             }
+
             const reqParam: ManagerRoleOperateReq = {
                 autoid: getUserId(), // uint64 角色ID
                 operatetype: 1, // uint32 操作类型-1:新增 2:修改
                 areauserid: getAreaUserId(), // uint64 所属机构
                 modifierid: Number(geLoginID_number()), // uint64 修改人ID
                 rolename: name.value, // string 角色名称
-                memberfuncmenus: result.map((item) => {
+                memberfuncmenus: checkedCodes.map((item) => {
                     return {
                         resourcecode: item,
                     } as MemberFuncMenu;
@@ -190,6 +221,9 @@ export default defineComponent({
             loading,
             tableList,
             firstChaneg,
+            isPingAnOem,
+            replaceFields,
+            checkedKeys,
         };
     },
 });
@@ -347,5 +381,32 @@ export default defineComponent({
         }
     }
 }
-</style
->;
+
+.ant-tree-checkbox {
+    margin-right: 2px;
+    .ant-tree-checkbox-inner {
+        background: @m-grey21;
+        border: 1px solid @m-grey14;
+        border-radius: 3px;
+        &::after {
+            border-color: @m-blue0;
+        }
+    }
+    &::after {
+        border-color: @m-blue0;
+    }
+}
+
+.ant-tree-title {
+    color: @m-white0;
+}
+.anticon {
+    color: @m-white0;
+}
+.ant-tree li .ant-tree-node-content-wrapper.ant-tree-node-selected {
+    background: none;
+}
+.ant-tree li .ant-tree-node-content-wrapper:hover {
+    background: none;
+}
+</style>;

+ 1 - 1
src/views/information/account_info/list/account_info_manager/index.vue

@@ -74,7 +74,7 @@
     <Reset @refresh="handleBtnAction"
            :selectedData="moreModelData" />
     <Detail :selectedData="moreModelData" />
-    <AddPermission />
+    <AddPermission @refresh="handleBtnAction" />
     <Permission />
   </div>
 </template>