Role authority control method for intelligent water conservancy digital management system
By using nested tables to display role permissions and inherit role functions in the smart water conservancy management system, the problem of unintuitive permission display and inefficient management in traditional systems is solved, and more efficient and intuitive role permission management is achieved.
Patent Information
- Application Number
- CN202411654166.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-03-18
AI Technical Summary
In terms of role management in traditional smart water conservancy management systems, the display of menu/button permissions is not intuitive enough, and when the number of user roles is large, the super administrator needs to enter a large amount of permission information, resulting in inefficient management.
The permission menu and buttons that the current role has are fully displayed in the form of a nested table, and provides the "Inheriting Role" function, allowing the super-manager to inherit the existing user role permissions and reduce duplicate operations.
Through the display of nested tables, the intuitiveness and management efficiency of permission information are improved, and the inheritance of role functions simplifies the management of large-scale role permissions, and improves the efficiency and intuitiveness of operations.
Smart Images

Figure CN119646867A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of authority control, and in particular to a role authority control method for a smart water conservancy digital management system. Background Art
[0002] With global changes and rapid economic and social development, the contradiction between water supply and demand in my country has become increasingly prominent, and extreme hydrological events have occurred frequently, seriously threatening my country's water security, food security and ecological and environmental security. my country has a vast territory, numerous water systems, and many water conservancy projects with wide coverage, large volume and complex types. The rapid development of the economy and society has put forward higher requirements for water resource security and the safe and efficient operation of water conservancy projects. At present, traditional water conservancy can no longer fully meet the professional, refined and intelligent management requirements required for economic and social development in the new era. With the continuous development of the digital economy, big data, the Internet of Things and its applications with the basic characteristics of "perception, interconnection and intelligence" have greatly changed the efficiency, ease of use and behavioral paradigms of information services in various industries. The informatization, modernization and intelligent development of water conservancy have ushered in a good opportunity. The development of smart water conservancy is becoming a powerful tool and inevitable choice for the modernization of water conservancy and the rapid improvement of water resource efficiency.
[0003] When developing a smart water conservancy digital management system, one function that must be implemented is role management. That is, for the same system, different users will be displayed different pages according to their roles after logging in, or when users enter the same page, the system displays different buttons for users to operate. The smart water conservancy digital management system faces the problem of numerous user roles, pages, and buttons. User roles alone may include super administrators (hereinafter referred to as "super administrators", and the management of general role permissions is performed by super administrators), organization administrators, visiting leaders, regional water resources managers, monitors, and other different roles. The management pages involve water resources monitoring, large-screen display, hydropower station management, user management, organization management, etc.
[0004] The prior art has the following defects:
[0005] When implementing the role management function, traditional smart water management systems generally use a tree-like folding panel to add / modify roles. This can certainly achieve the function, but there are also some problems. First, displaying the menu / button permissions of different roles in a tree-like folding panel is not intuitive enough, and it is difficult to quickly see the various types of permission information corresponding to a role; secondly, when the number of user roles in the water management system is too large, the super administrator needs to enter a large amount of permission information for different roles. Much of this role information is highly homogeneous, but the super administrator needs to repeatedly click and check. If there are many management pages, the super administrator may need to check hundreds of check boxes for the permission information of only one role, which greatly reduces management efficiency. Summary of the invention
[0006] In view of the deficiencies of the above-mentioned prior art, the purpose of the present invention is to provide a role authority control method for a smart water conservancy digital management system, which comprehensively displays the authority menus and buttons owned by the current role (or that need to be modified) in the form of nested tables. At the same time, it provides an "inherit role" function, so that super administrators can inherit existing user role permissions when adding / modifying a large number of user role permissions. In this way, there is no need to frequently click and check various menu button permissions, and user role management can be performed efficiently, quickly and intuitively.
[0007] In order to achieve the above object, the present invention provides the following technical solution: a role authority control method for a smart water conservancy digital management system, the control method comprising the following steps:
[0008] The user clicks to enter the new / edit role interface, performs corresponding operations on the new / edit role page, and generates relevant responses based on the user operation control system. When the generated relevant response is that the user does not choose to inherit the existing role, the general menu and button permission array is obtained, and the menu and button permission array is converted into a tree / forest structure and backed up;
[0009] The control system automatically generates HTML code for nested tables based on the tree / forest structure, converts the tree / forest structure into table data for nested table rendering through the flatten-Tree function, and passes the table data to the rendering code for rendering and display;
[0010] The event processing function is triggered when the user performs the corresponding operation. The event processing function is used to process the state change of the check box, redraw the nested table according to the check box state, update the state of the table data, send the selected menu / button identifier to the server and perform persistent processing.
[0011] In a preferred embodiment, the user clicks to enter the create / edit role interface, performs corresponding operations on the create / edit role page, and generates a relevant response based on the user operation control system, including the following steps:
[0012] The corresponding operation is for the user to choose whether to inherit an existing role. The existing role refers to various roles that have been stored in the system, including system administrator, water conservancy director, and regional water resources manager;
[0013] In the array elements of the menu and button permission array, id represents the unique identifier of the element, title represents the name of the permission, checked represents whether the permission is selected, where false is unchecked and true is selected, code represents the code value of the permission, parent-Code represents the code value of the parent permission item of the permission, if it is null, it means that the permission item is a top-level permission item, type represents the category of the permission item, where '0' represents that the permission is a menu, and '1' represents that the permission is a button. When the general menu and button permission array is obtained, the checked values of all data items are false by default. If the user chooses to inherit an existing role, the control system obtains the corresponding menu and button permission array according to the selected existing role ID. At this time, the checked values of the menu and button permission array data items are set to true or false according to the different permissions set for different roles.
[0014] In a preferred embodiment, the menu and button permission array is converted into a tree / forest structure and then backed up, including the following steps:
[0015] If the role management data has multiple top-level menus, the final generated structure is a forest structure, that is, the length of the forest structure array is greater than 1. If the role management data has only one top-level menu, the final generated structure is a tree structure, that is, the length of the tree structure array is equal to 1. In the tree / forest structure array, the meaning of all object attributes is consistent with the menu and button permission array. A disabled attribute is added. When the disabled attribute is true, the corresponding check box rendered by the front end cannot be edited. When this attribute is false, the corresponding check box can be edited. The disabled attribute is generated by traversing the elements in the menu and button permission array before converting the menu and button permission array into a tree / forest structure array and adding the disabled attribute to each element.
[0016] In a preferred embodiment, the tree / forest structure is converted into table data for nested table rendering by flatten-Tree function, including the following steps:
[0017] initMergetable-Data() method: initializes and starts the row merging process, first calculates the number of occurrences of each code, and then calls the row merging logic; handleable-Data(): processes table data, sets rowspan for each cell according to the number of occurrences of the code. In HTML, rowspan is an attribute for tables that allows cells to span multiple rows. Rowspan is used in or elements to specify how many rows the cell occupies and perform the actual row merging operation; calCodeCount() method: calculates and counts the number of occurrences of each code in the table. The results are used to determine which cells need to be merged to obtain table data.
[0018] In a preferred embodiment, when the user performs a corresponding operation, an event processing function is triggered, and the event processing function is used to process the state change of the check box and redraw the nested table according to the check box state, including the following steps:
[0019] The user performs corresponding operations, including selecting / unchecking menu / button permissions. The event handling function accepts the checkItem parameter, which represents the object of the currently selected checkbox, including the code and checked attributes. The currently selected checkItem is stored in the curCheckItem object, and then the redrawMergeTable() method is called to redraw the nested table according to the checkbox status, update the table data status, and recalculate and display the table data.
[0020] In a preferred embodiment, redrawing the table and updating the table data state through the redrawMergeTable() method includes the following steps:
[0021] After resetting the table data, extract the currently selected code and checked status from curCheckItem, create a deep copy of authority-DTOS and assign it to the authority-DTOS object, traverse authority-DTOS, initialize the disabled attribute and add it to the authority-DTOS element item to obtain a new array object authority-DTOS, and regenerate and render the nested table data by calling the handle-Authority-DTOS method.
[0022] In the above technical solution, the technical effects and advantages provided by the present invention are:
[0023] The present invention obtains a general menu and button permission array, and converts the menu and button permission array into a tree / forest structure and then backs it up, automatically generates HTML code for a nested table based on the tree / forest structure, converts the tree / forest structure into table data for nested table rendering through a flatten-Tree function, passes the table data to a rendering code for rendering and display, and triggers an event processing function when a user performs a corresponding operation. The event processing function is used to process the state change of the check box, and redraw the nested table according to the check box state, and update the state of the table data. The control system fully displays the permission menu and buttons owned by the current role in the form of a nested table, so that the super administrator can inherit the existing user role permissions when adding / modifying a large number of user role permissions, and can efficiently, quickly and intuitively manage user roles. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0025] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] The traditional role management method presented in a tree-like folding box is not intuitive and comprehensive enough when adding / modifying role permissions. When adding and modifying permissions of several roles in large quantities, the menu and button selection boxes presented to the super administrator are not intuitive and comprehensive enough. Moreover, when it is necessary to add and modify permissions of several roles in batches, it is necessary to re-check the menu and button permissions of the role in turn each time, and the super administrator needs to perform a large number of repeated operations. In order to solve the above problems, the present invention provides a role permission control method for a smart water conservancy digital management system, which comprehensively displays the permission menus and buttons owned by the current role (or need to be modified) in the form of nested tables. At the same time, it provides an "inherit role" function, so that the super administrator can check based on the existing user role permissions when adding / modifying user role permissions in large quantities, which greatly improves the efficiency of role management.
[0028] Example 1: Please refer to Figure 1 As shown, the role authority control method for a smart water conservancy digital management system described in this embodiment includes the following steps:
[0029] The user clicks to enter the new / edit role interface, performs corresponding operations on the new / edit role page, and generates relevant responses based on the user operation control system. When the generated relevant response is that the user does not choose to inherit the existing role, the general menu and button permission array is obtained, and the menu and button permission array is converted into a tree / forest structure and backed up;
[0030] The control system automatically generates HTML code for nested tables based on the tree / forest structure, converts the tree / forest structure into table data for nested table rendering through the flatten-Tree function, and passes the table data to the rendering code for rendering and display;
[0031] The event processing function is triggered when the user performs the corresponding operation. The event processing function is used to process the state change of the check box, redraw the nested table according to the check box state, update the state of the table data, send the selected menu / button identifier to the server and perform persistent processing.
[0032] This application obtains the general menu and button permission array, and converts the menu and button permission array into a tree / forest structure and backs it up. Based on the tree / forest structure, the HTML code of the nested table is automatically generated, and the tree / forest structure is converted into table data for nested table rendering through the flatten-Tree function. The table data is passed to the rendering code for rendering and display. When the user performs the corresponding operation, the event processing function is triggered. The event processing function is used to process the state change of the check box, and redraw the nested table according to the check box state, and update the state of the table data. The control system fully displays the permission menu and buttons owned by the current role in the form of a nested table, so that the super administrator can inherit the existing user role permissions when adding / modifying a large number of user role permissions, and can manage user roles efficiently, quickly and intuitively.
[0033] The user (super administrator) clicks to enter the Create / Edit Role interface. On the Create / Edit Role page, the user needs to fill in the role's name, category, remarks, etc.
[0034] The user can choose whether to inherit an existing role, which refers to various roles that have been stored in the system, such as system administrator, water conservancy director, regional water resources manager, etc. If the user does not choose to inherit an existing role, the system will obtain the general menu and button permission array authArr. The following is an example of the format of the authArr array:
[0035]
[0036]
[0037] As shown above, in the elements of the authArr array, id represents the unique identifier of the element, title represents the name of the permission, which is generally the name of the menu page or button, checked represents whether the permission is selected, where false is unselected and true is selected, code represents the code value of the permission, parent-Code represents the code value of the parent permission item of the permission, and if it is null, it means that the permission item is a top-level permission item. type represents the category of the permission item, where '0' means that the permission is a menu, and '1' means that the permission is a button. When the general menu and button permission array authArr is obtained, the default checked value of all data items is false. If the user chooses to inherit an existing role, the system will obtain the corresponding menu and button permission array authArr according to the selected existing role ID. At this time, the checked value of the data item in the authArr array will be set to true or false according to the different permissions set for different roles.
[0038] The system will convert the menu and button permission array authArr into a tree / forest structure authTree, and back up the menu and button permission array authArr. The following is the data structure of authTree:
[0039]
[0040]
[0041] As shown above, the reason why authTree is a tree or forest structure is that it depends on the different role management data. If the role management data has multiple top-level menus, the final generated authTree is a forest structure, that is, the length of the authTree array is greater than 1. If the role management data has only one top-level menu, the final generated authTree can be considered a tree structure, that is, the length of the authTree array is equal to 1. In the authTree array, the meaning of all object attributes is consistent with authArr, but a new attribute disabled is added. When this attribute is true, the corresponding checkbox rendered by the front end will not be editable. When this attribute is false, the corresponding checkbox will be editable (checked / unchecked). The disabled attribute is generated by traversing the elements in the authArr array before converting it to authTree, and adding the disabled attribute to each element (default is false). The process of converting the menu and button permission array into a tree / forest structure is implemented through a tool function called handle-Tree. The main idea of this function is to traverse the data, first establish a parent-child relationship map (children-List-Map), then find the root node (those elements whose parent-Code is null), and then recursively mount the child nodes of each node on their children fields, finally forming a tree structure and returning it.
[0042] Write HTML code to implement nested tables. In the field of web front-end development, if you want to implement a nested table displayed on a browser, there are two ways of thinking. One is to use the table component of the existing front-end component library, and the other is to implement it through the HTML native table tag. Since nested tables require the operation of a large number of table attributes, and most of the table components of the front-end component library are based on the native table tag encapsulation implementation, it hides a lot of underlying details of the table tag, which is not easy to implement when flexible nested tables need to be implemented. Therefore, the present invention uses the HTML native table tag to implement nested tables. The following is the HTML pseudo code for the nested table implementation:
[0043]
[0044]
[0045] Flatten authTree into data that can be rendered in nested tables. First, a function called flatten-Tree is needed to convert authTree into data suitable for nested table rendering of the present invention. The pseudo code for implementing the flatten-Tree function is as follows:
[0046]
[0047]
[0048] ode-List) and extracts the information of each node according to the level and saves it in the table data. It processes each node recursively and decides how to handle different types of data (menus or buttons) according to the level. After the flatten-Tree method is used, the new table data (temp-table-Data) is obtained, and its data structure is as follows:
[0049]
[0050]
[0051] The data structure of temp-table-Data is shown above. The values of one-Feature, two-Feature, and three-Feature correspond to col-Key-Map objects, whose values are {1:'one-Feature', 2:'two-Feature', 3:'three-Feature', 4:'four-Feature', 5:'five-Feature'}. The reason why one-Feature and others are used to identify the menu level is to facilitate the customization of the menu level name, and also to make the entire character menu data level clearer. After obtaining the temp-table-Data data, the overall structure of the data that can be rendered by the nested tables has been basically clarified. What needs to be clarified now is the rowspan attribute corresponding to each data item. As we mentioned above, rowspan is used to specify how many rows a cell (or) spans in the vertical direction. In the present invention, the nested tables used for smart water conservancy role management only involve nesting of table rows (not column nesting). For example, the user management menu in the temp-table-Data mentioned above includes sub-pages such as user authority management, role management, and login log, and each sub-page contains different buttons.
[0052] In the user management data item, you need to add a rowspan attribute, and the rowspan value is 3, which means that the user management cell will merge 3 rows. To achieve the above function, you need to use the initMergetable-Data, handletable-Data, calCodeCount methods. The following is the pseudo code for these three methods:
[0053]
[0054]
[0055]
[0056]
[0057] As described in the pseudocode above, initMergetable-Data(): initializes and starts the row merging process, first calculates the number of occurrences of each code, and then calls the row merging logic. handletable-Data(): processes the table data, sets the rowspan for each cell according to the number of occurrences of the code, and performs the actual row merging operation. calCodeCount(): calculates and counts the number of occurrences of each code in the table, and the result is used to determine which cells need to be merged. Finally, this process implements the use of code to determine the row merging operation in the table, so that cells with the same code can be merged together, and the rowspan value of the table data is updated at the same time, and the table-Data data is finally obtained.
[0058] The nested table (with permission checkboxes) is rendered and displayed. The table-Data data is passed to the rendering code for rendering and display.
[0059] The user checks / unchecks the menu / button permission. When the user checks / unchecks the menu / button permission, the onChangeCheckbox method is triggered, which is used to handle the state change of the checkbox. The specific process is as follows: The onChangeCheckbox method accepts a parameter named checkItem: an object representing the currently selected checkbox, containing properties such as code and checked. The currently selected checkItem is then stored in the curCheckItem object for subsequent operations. The redrawMergeTable() method is then called to redraw the nested table based on the checkbox status. The table data needs to be recalculated and displayed, so this step is very critical. The redrawMergeTable() method is responsible for redrawing the table and updating the status of the table data. The specific process is as follows: this.table-Data = []: reset the table data, clear the previous content, so as to redraw the table; then extract the currently selected code and checked status from curCheckItem for subsequent logical processing, next, create a deep copy of authorityDTOS and assign it to the authorityDTOS object to ensure that subsequent modifications to the data will not affect the original data, and finally, traverse authorityDTOS, initialize the disabled (set to false) attribute and add it to the authorityDTOS element item to obtain a new array object authorityDTOS. Next, the handleAuthorityDTOS method is called to achieve the regeneration and rendering of the nested table data, and its steps are consistent with the regeneration and rendering of the nested table data described above.
[0060] In the above steps, three additional issues need to be paid attention to. The first issue is how to achieve read-only display (i.e., unable to edit) of the current role management nested table; the second issue is how to deal with the situation when the user only needs to view the content of a page and does not have any button-level editing permissions for the page; the third issue is how to achieve the cascading relationship between check boxes at different levels in the nested table. The first issue is relatively easy to solve. The solution is to add a disabled attribute to the authorityDTOS object array as mentioned above, and use the disabled attribute to control whether the check box corresponding to the current data item is editable. In addition, add an allCheckboxDisabled globally in the html rendering code. The priority of allCheckboxDisabled is the highest. When allCheckboxDisabled is true, it means that all check boxes in the nested table will be in a read-only state without checking the disabled attribute of each cell data. The second issue requires adding a permission button named "Read Permission" under each menu page (i.e., a menu whose child node data type is a button). The "Read Permission" button does not actually exist in the page display. It represents whether the corresponding permission user can view the page. Therefore, there is a certain linkage relationship between the "Read Permission" button and other buttons of the same level. That is, when the "Read Permission" button is checked, other buttons of the same level can be checked. If the "Read Permission" button is not checked, the check status of other buttons of the same level must also be unchecked and become read-only. For the third question, when the user clicks to check / uncheck the permission checkbox, the cascade relationship of the tree structure where the currently edited checkbox is located needs to be updated synchronously.
[0061] Regarding the solution to the second and third problems, the present invention provides a way of thinking. First, when setting all the permission code values, it is necessary to agree that only the code value of the "read permission" button ends with "_Read", and the code values of other buttons cannot end with "_Read". Secondly, we need to consider a problem, that is, whether the tree cascade relationship (i.e., the value of checked) corresponding to the menu and button permission array obtained by the user management page from the server is normal. There is such a possibility that the cascade relationship of the menu and button permission array obtained by the system from the server is abnormal, and the permissions of the two pages of project overview and water situation monitoring overview under the leader cockpit module are not checked. At this time, the checked attribute corresponding to the leader cockpit should be false, but the checked attribute corresponding to the leader cockpit we obtained from the server is true. At this time, the cascade relationship displayed in the table is abnormal.
[0062] So is it necessary for the front end to repair this cascading relationship? Generally speaking, it does need to be repaired, but there are certain conditions. In fact, the front-end display system needs to repair the cascading relationship of the entire nested table after the user clicks to check the content in the nested table, and the cascading relationship should not be repaired when the table content is initialized. If the cascading relationship is repaired when the table rendering display is initialized, then when the user clicks the Save button without performing any operation, the check state of the entire rendering list may change dramatically. At this time, the user does not have the function of editing the nested button, which will cause the user to be troubled by the system function to a certain extent. Based on the above logic, the present invention implements a method called updateAllTreeCheckedAndDisabled to update the linkage relationship between the "read permission" button of the table data and other buttons and the overall tree cascading relationship. Its main pseudo code is as follows:
[0063]
[0064]
[0065]
[0066]
[0067]
[0068] As shown in the pseudo code above, the updateAllTreeCheckedAndDisabled() method decides how to update the node status in the tree structure based on the current operation and hierarchical relationship. The updateLeafNodeReadCheckedAndDisabledStatus() method is mainly responsible for processing the status of leaf nodes, especially the button nodes of the "read permission" type. updateCheckedStatus(): recursively updates the selected status of parent nodes and child nodes. updateOtherTreeCheckedStatus(): ensures that the parent node is updated according to the status of the child node to reflect the selected status of the entire tree. This set of logical methods is used to process structures similar to the role management permission tree to ensure that when a user selects or deselects a node, the status of the related parent and child nodes will also be updated synchronously according to business needs.
[0069] Click the Save button to send the selected menu / button identification code to the server for persistence. Filter the checked attribute in the authorityDTOS array element to get the user's currently selected role authority code value list, send the value list to the server via an http request and persist it.
[0070] The present invention aims to solve the problem that users (super administrators) need to repeatedly re-operate and edit a large number of role permissions in the smart water digital management system. The present invention proposes a method of inheriting role permissions to simplify the operation of editing role permissions. At the same time, in view of the problem that the traditional role management system page displays various menu / button permissions in a non-specific and intuitive manner, a method based on nested tables is proposed. In addition, for the problems of cascading relationship errors and read-only page permission management after the data obtained from the server is tree-formatted, a series of solutions are proposed, which is conducive to the efficient management of the smart water digital management system.
[0071] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0072] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to only specific implementation methods. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A role authority control method for a smart water conservancy digital management system, characterized by: The control method comprises the following steps: The user clicks to enter the new / edit role interface, performs corresponding operations on the new / edit role page, and generates relevant responses based on the user operation control system. When the generated relevant response is that the user does not choose to inherit the existing role, the general menu and button permission array is obtained, and the menu and button permission array is converted into a tree / forest structure and backed up; The control system automatically generates HTML code for nested tables based on the tree / forest structure, converts the tree / forest structure into table data for nested table rendering through the flatten-Tree function, and passes the table data to the rendering code for rendering and display; The event processing function is triggered when the user performs the corresponding operation. The event processing function is used to process the state change of the check box, redraw the nested table according to the check box state, update the state of the table data, send the selected menu / button identifier to the server and perform persistent processing.
2. A role authority control method for a smart water conservancy digital management system according to claim 1, characterized in that: The user clicks to enter the new / edit role interface, performs corresponding operations on the new / edit role page, and the control system generates relevant responses based on the user operation, including the following steps: The corresponding operation is for the user to choose whether to inherit an existing role. The existing role refers to various roles that have been stored in the system, including system administrator, water conservancy director, and regional water resources manager; In the array elements of the menu and button permission array, id represents the unique identifier of the element, title represents the name of the permission, checked represents whether the permission is selected, where false is unchecked and true is selected, code represents the code value of the permission, parent-Code represents the code value of the parent permission item of the permission, if it is null, it means that the permission item is a top-level permission item, type represents the category of the permission item, where '0' represents that the permission is a menu, and '1' represents that the permission is a button. When the general menu and button permission array is obtained, the checked values of all data items are false by default. If the user chooses to inherit an existing role, the control system obtains the corresponding menu and button permission array according to the selected existing role ID. At this time, the checked values of the menu and button permission array data items are set to true or false according to the different permissions set for different roles.
3. A role authority control method for a smart water conservancy digital management system according to claim 2, characterized in that: Convert the menu and button permission array into a tree / forest structure and then back it up, including the following steps: If the role management data has multiple top-level menus, the final generated structure is a forest structure, that is, the length of the forest structure array is greater than 1. If the role management data has only one top-level menu, the final generated structure is a tree structure, that is, the length of the tree structure array is equal to 1. In the tree / forest structure array, the meaning of all object attributes is consistent with the menu and button permission array. A disabled attribute is added. When the disabled attribute is true, the corresponding check box rendered by the front end cannot be edited. When this attribute is false, the corresponding check box can be edited. The disabled attribute is generated by traversing the elements in the menu and button permission array before converting the menu and button permission array into a tree / forest structure array and adding the disabled attribute to each element.
4. A role authority control method for a smart water conservancy digital management system according to claim 3, characterized in that: The tree / forest structure is converted into table data for nested table rendering through the flatten-Tree function, including the following steps: initMergetable-Data() method: initializes and starts the row merging process, first calculates the number of occurrences of each code, and then calls the row merging logic; handleable-Data(): processes table data, sets rowspan for each cell according to the number of occurrences of the code. In HTML, rowspan is an attribute for tables that allows cells to span multiple rows. Rowspan is used in or elements to specify how many rows the cell occupies and perform the actual row merging operation; calCodeCount() method: calculates and counts the number of occurrences of each code in the table. The results are used to determine which cells need to be merged to obtain table data.
5. A role authority control method for a smart water conservancy digital management system according to claim 4, characterized in that: When the user performs a corresponding operation, the event processing function is triggered. The event processing function is used to process the state change of the check box and redraw the nested table according to the check box state. It includes the following steps: The user performs corresponding operations, including selecting / unchecking menu / button permissions. The event handling function accepts the checkItem parameter, which represents the object of the currently selected checkbox, including the code and checked attributes. The currently selected checkItem is stored in the curCheckItem object, and then the redrawMergeTable() method is called to redraw the nested table according to the checkbox status, update the table data status, and recalculate and display the table data.
6. A role authority control method for a smart water conservancy digital management system according to claim 5, characterized in that: Redraw the table and update the table data status through the redrawMergeTable() method, including the following steps: After resetting the table data, extract the currently selected code and checked status from curCheckItem, create a deep copy of authority-DTOS and assign it to the authority-DTOS object, traverse authority-DTOS, initialize the disabled attribute and add it to the authority-DTOS element item to get a new array object authority-DTOS, and regenerate and render the nested table data by calling the handle-Authority-DTOS method.
Citation Information
Patent Citations
Permission configuration interface display method and device, terminal and storage medium
CN110457891A
Authority control method and device, electronic equipment and storage medium
CN115221481A
Creating roles and controlling access within a computer network
US11516220B1