A method and system for rendering forms with dependent fields.
By analyzing the dependency configuration of the tree data format in the form rendering component, the security risks and high development costs of form rendering plug-ins in the existing technology are solved, and efficient and secure form rendering and configuration are achieved, reducing learning and Maintenance cost.
Patent Information
- Application Number
- CN202410492039.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-23
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-04-23
AI Technical Summary
Existing form rendering plug-ins have security risks and high development costs when configuring complex dependencies. In particular, using the eval() function may lead to XSS attacks, and backend developers need to master front-end coding knowledge, learning costs and maintenance costs. Higher.
By parsing dependency configurations of tree data formats in form rendering components, avoiding the use of string expressions and eval() functions, simplifying form configuration data structures, reducing learning costs, and transfer configuration data through interfaces to separate front-end and back-end application.
It improves form development efficiency, reduces learning and maintenance costs, avoids security risks, realizes form rendering of complex logical relationships, and does not require additional development to achieve extended or changed form configuration requirements.
Smart Images

Figure CN118333026B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of web development front-end, and in particular to a form rendering method and system capable of rendering fields with dependency relationships. Background Art
[0002] The forms in web pages are usually developed by developers one by one according to business needs, and deployed to the server for users to use after testing and acceptance. In this development method, every time a form configuration requirement is added, a new form needs to be developed, and then tested, accepted and deployed, and so on, which will cause low efficiency and high labor costs.
[0003] Some form rendering plug-ins such as formily (official website: https: / / react.formilyjs.org / ) or form-render (official website: https: / / xrender.fun / form-render) are also used to render forms. The front-end obtains the form configuration data through the back-end interface, and then renders the form through the form rendering plug-in. When adding form configuration requirements, the back-end only needs to add a corresponding form configuration data according to the requirements. This process eliminates the need for redevelopment of the front-end.
[0004] Currently, plugins such as formily and form-render usually configure the dependency of form items and linkage conditions by configuring string expressions. For example, when the form item field type is set to 1, the configuration is similar to "form.getFieldValue('type') === 1", or "formData.type === 1". The front end then uses JavaScript's eval() function to convert the string into executable code to obtain the calculation result.
[0005] The above method has the following problems:
[0006] 1. When using the eval() function, there may be XSS attack vulnerabilities and certain security risks. When deploying to customers with certain security requirements, it may not pass the customer's sonar code security scan.
[0007] 2. When back-end developers configure forms with complex dependencies, they need to master front-end coding knowledge, such as the value of dependent fields (the form item value method form.getFieldValue('mqType') depends on the front-end framework used. Different front-end frameworks have different corresponding UI frameworks, which requires a certain learning cost). Or they can generate through another set of low-code generation tools (for companies, manpower is needed to develop and maintain such a low-code generation tool, which has a certain development cost). Summary of the invention
[0008] A brief summary of one or more aspects is given below to provide a basic understanding of these aspects. This summary is not an exhaustive overview of all conceived aspects, and is neither intended to identify the key or critical elements of all aspects nor to define the scope of any or all aspects. Its only purpose is to give some concepts of one or more aspects in a simplified form as a prelude to a more detailed description that will be given later.
[0009] The purpose of the present invention is to solve the above-mentioned problem and provide a form rendering method and system that can render form fields with dependency relationships, which can meet both conventional form rendering requirements and form rendering requirements with dependency fields, improve form development efficiency, and have simple configuration rules, which is convenient for developers to quickly master and reduce learning costs.
[0010] The technical solution of the present invention is: the present invention discloses a form rendering method capable of rendering fields with dependency relationships, the method comprising:
[0011] In the first step, in the form rendering page, the form rendering component obtains a single form rendering data through an interface request;
[0012] The second step is to convert the requested form rendering data into the standard data format required by the form rendering component, and then pass it to the form rendering component through the parameters of the form field configuration data;
[0013] In the third step, the form rendering component traverses each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form;
[0014] The fourth step is to render the form to the corresponding position of the form on the target page.
[0015] According to an embodiment of the method for rendering a form with dependency fields of the present invention, the format of the form rendering data includes several form item names, form item types, dependency configurations of form item disabled or visible, and whether it is required;
[0016] Among them, the form item type corresponds to the form item component type, including input item, number input item, drop-down selection, date and time selection, single selection, checkbox, toggle switch, and code editor;
[0017] Among them, the dependency configuration is defined as a tree data format to support complex logical relationship configuration and facilitate interface transmission.
[0018] According to an embodiment of the form rendering method capable of rendering fields with dependency relationships of the present invention, in the second step, the specific processing method of passing the form field configuration data to the form rendering component is as follows:
[0019] The parameters passed to the form rendering component include form field configuration data, form initial value, read-only, disabled, and extended type control mappings.
[0020] Among them, the form field configuration data is bound to the form rendering component through the parameters of the form field configuration data; the form initial value parameter is the initial value after the form is loaded; the read-only parameter is used to set the rendered form controls to read-only mode when viewing the form configuration data; the disable parameter is used to disable the editing function of the form under set conditions; the extended type control mapping realizes the on-demand loading of the corresponding form item type component inside the form rendering component.
[0021] According to an embodiment of the form rendering method capable of rendering fields with dependency relationships of the present invention, in the third step, when there is a dependency configuration in the field, the process of parsing the form field configuration data of the corresponding field further includes the following steps:
[0022] First, use JavaScript's reduce method to traverse the conditional set data in the conditional item configuration and return the final calculation result;
[0023] Then, when traversing the current condition item configuration, the current condition item configuration is parsed, and if there is a sub-item condition set in it, subsequent processing is performed;
[0024] Next, the relational operator is parsed, and the current value of the target form item is obtained according to the current form value and the name of the target form item in the conditional item configuration. The current value of the target form item, the relational operator, and the target form item satisfaction value are substituted into the mapping to obtain the Boolean result of the relational operation.
[0025] Furthermore, depending on whether the Boolean result of the current relational operation needs to be inverted, the corresponding operation is performed. If it needs to be inverted, the Boolean result of the current operation is inverted, and then the logical operation result with the previous result is returned; if it does not need to be inverted, the logical operation result with the previous result is returned.
[0026] After the above steps are processed, the final logical operation result is finally returned.
[0027] The present invention discloses a form rendering method capable of rendering fields having dependency relationships, the method comprising:
[0028] In the first step, in the form rendering page, the form rendering component obtains the configuration list of the current page form through the interface, stores the configuration list data in the state variable, and binds it to the list display view;
[0029] In the second step, a form rendering data in the configuration list is selected and converted into the standard data format required by the form rendering component, and stored in the state variable of the field configuration of the current form;
[0030] In the third step, the state variables are passed to the form rendering component through the parameters of the form field configuration data;
[0031] In the fourth step, the form rendering component traverses each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form;
[0032] The fifth step is to render the form to the corresponding position of the form on the target page.
[0033] According to an embodiment of the method for rendering a form with dependency fields of the present invention, the format of the form rendering data includes several form item names, form item types, dependency configurations of form item disabled or visible, and whether it is required;
[0034] Among them, the form item type corresponds to the form item component type, including input item, number input item, drop-down selection, date and time selection, single selection, checkbox, toggle switch, and code editor;
[0035] Among them, the dependency configuration is defined as a tree data format to support complex logical relationship configuration and facilitate interface transmission.
[0036] According to an embodiment of the form rendering method capable of rendering fields with dependency relationships of the present invention, in the third step, the specific processing method of passing the form field configuration data to the form rendering component is as follows:
[0037] The parameters passed to the form rendering component include form field configuration data, form initial value, read-only, disabled, and extended type control mappings.
[0038] Among them, the form field configuration data is bound to the form rendering component through the parameters of the form field configuration data; the form initial value parameter is the initial value after the form is loaded; the read-only parameter is used to set the rendered form controls to read-only mode when viewing the form configuration data; the disable parameter is used to disable the editing function of the form under set conditions; the extended type control mapping realizes the on-demand loading of the corresponding form item type component inside the form rendering component.
[0039] According to an embodiment of the form rendering method capable of rendering fields with dependency relationships of the present invention, in the fourth step, when there is a dependency configuration in the field, the process of parsing the form field configuration data of the corresponding field further includes the following steps:
[0040] First, use JavaScript's reduce method to traverse the conditional set data in the conditional item configuration and return the final calculation result;
[0041] Then, when traversing the current condition item configuration, the current condition item configuration is parsed, and if there is a sub-item condition set in it, subsequent processing is performed;
[0042] Next, the relational operator is parsed, and the current value of the target form item is obtained according to the current form value and the name of the target form item in the conditional item configuration. The current value of the target form item, the relational operator, and the target form item satisfaction value are substituted into the mapping to obtain the Boolean result of the relational operation.
[0043] Furthermore, depending on whether the Boolean result of the current relational operation needs to be inverted, the corresponding operation is performed. If it needs to be inverted, the Boolean result of the current operation is inverted, and then the logical operation result with the previous result is returned; if it does not need to be inverted, the logical operation result with the previous result is returned.
[0044] After the above steps are processed, the final logical operation result is finally returned.
[0045] The present invention also discloses a form rendering system capable of rendering fields having dependency relationships, the system comprising:
[0046] The data request module is configured so that in the form rendering page, the form rendering component obtains a single form rendering data through an interface request;
[0047] The component parameter transmission module is configured to convert the form rendering data obtained from the request into the standard data format required by the form rendering component, and then transmit the parameters of the form field configuration data to the form rendering component;
[0048] The parsing module is configured as a form rendering component to traverse each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form;
[0049] The form position rendering module is configured to render the form to the corresponding position of the form on the target page.
[0050] The present invention also discloses a form rendering system capable of rendering fields having dependency relationships, the system comprising:
[0051] The data request module is configured so that in the form rendering page, the form rendering component obtains the configuration list of the current page form through the interface, stores the configuration list data in the state variable, and binds it to the list display view;
[0052] The data conversion module is configured to convert a form rendering data in the configuration list into the standard data format required by the form rendering component after it is selected, and store it in the state variable of the field configuration of the current form;
[0053] The component parameter transfer module is configured as a state variable and passes the parameters of the form field configuration data to the form rendering component;
[0054] The parsing module is configured as a form rendering component to traverse each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form;
[0055] The form position rendering module is configured to render the form to the corresponding position of the form on the target page.
[0056] Compared with the prior art, the present invention has the following beneficial effects: the present invention uses tree data to configure the relational expression or logical expression representing the dependency relationship, and uses a customized parsing method to parse the configuration information in the tree data format, thereby avoiding the failure to pass the customer's sonar code security scan due to the use of string expressions combined with eval parsing. For back-end developers, the form configuration data structure of the present invention is relatively simple, and it is relatively easy to master the form configuration method, which can reduce learning costs. For companies, the form configuration data of the present invention is obtained by an interface and is separated from the front-end application. For the expansion or change of the form configuration requirements, no additional development is required and it can be achieved by modifying or adding configurations, which reduces labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The above features and advantages of the present invention can be better understood after reading the detailed description of the embodiments of the present disclosure in conjunction with the following drawings. In the drawings, the components are not necessarily drawn to scale, and components with similar related properties or features may have the same or similar reference numerals.
[0058] Figure 1 A flowchart of a first embodiment of a method for rendering a form with dependency fields according to the present invention is shown.
[0059] Figure 2 A flow chart of a second embodiment of a method for rendering a form with dependency fields according to the present invention is shown.
[0060] Figure 3 An example diagram of parameter passing for a form rendering component is shown.
[0061] Figure 4 An example diagram showing the format of a dependency configuration condition collection for form rendering data.
[0062] Figure 5 An example diagram showing the mapping relationship between relational operator symbols and relational expressions is shown.
[0063] Figure 6 The present invention is a flowchart of a method for parsing a dependent condition set in a form rendering method embodiment of the present invention.
[0064] Figure 7 A module diagram of a first embodiment of a form rendering system capable of rendering form fields with dependency relationships according to the present invention is shown.
[0065] Figure 8 A module diagram of a first embodiment of a form rendering system capable of rendering form fields with dependency relationships according to the present invention is shown. DETAILED DESCRIPTION
[0066] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. Note that the aspects described below in conjunction with the accompanying drawings and specific embodiments are only exemplary and should not be construed as limiting the scope of protection of the present invention in any way.
[0067] Figure 1 The flow chart of the first embodiment of the method for rendering a form with dependency fields of the present invention (single-page single-form rendering method) is shown. Figure 1 , the implementation steps of the method of this embodiment are described in detail as follows.
[0068] Step S11: In the form rendering page, the form rendering component obtains single form rendering data through an interface request.
[0069] The format of form rendering data is pre-designed, including several form item names (field names), form item types (field types) (corresponding to form item component types, including but not limited to input items, numeric input items, drop-down selections, date and time selections, single selections, checkboxes, toggle switches, code editors, etc.), form item disabled or visible dependency configuration (to support complex logical relationship configuration and facilitate interface transmission, it is defined as a tree data format, such as Figure 4 as shown), whether it is required, etc.
[0070] In this embodiment, the configuration data of the entire form field includes configuration items of several form items, which can be in the form of a JSON array. The configuration item of a single form item can be in the form of a JSON object. The component type corresponding to the form item can be configured as one of the types described in the form item type in Table 1, such as a text input type (Input), a drop-down selection type (Select), etc.
[0071] Table 1: Configuration items for form items
[0072]
[0073]
[0074] Table 2: Form item disabling or visible dependent condition item configuration
[0075]
[0076]
[0077] Step S12: convert the form rendering data obtained by the request into the standard data format required by the form rendering component, and then pass the parameters of the form field configuration data to the form rendering component.
[0078] The specific processing method of passing form field configuration data to the form rendering component is as follows.
[0079] Also refer to Figure 3 As shown in the figure, it is an example of parameter transmission of form rendering component. The form field configuration data is bound to the form rendering component through the parameters of the form field configuration data. Figure 3The form initial value, read-only, disabled, and extended type control mappings shown in the figure are shown in the figure. The form initial value parameter is the initial value after the form is loaded; the read-only parameter is used to set the rendered form controls to read-only mode (cannot be edited) when viewing the form configuration data; the disabled parameter is used to disable the editing function of the form under certain conditions (such as insufficient permissions, etc.). The extended type control mapping can realize the on-demand loading of the corresponding form item type components inside the form rendering component. For example, page A needs to use a component A1 and A2 corresponding to the form item type, and page B needs to use another component B1 and B2 corresponding to the form item type. These components do not need to be imported inside the form rendering component. You can import A1 and A2 on page A and import B1 and B2 on page B. They are passed into the form rendering component through the extended type control mapping parameter. The extended type control mapping and the internal basic form item type control mapping are merged inside the form rendering component to obtain the overall form item type control mapping. In this way, page A does not need to load B1 and B2, and page B does not need to load A1 and A2.
[0080] Step S13: The form rendering component traverses each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field will be parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form.
[0081] The specific processing method of traversing the form field configuration data to render the form fields is as follows.
[0082] The form rendering component traverses the form field configuration data, and substitutes the form item type value in the form field configuration data into the form item type control mapping (wherein the value passed in by the extended type control mapping parameter and the internal basic form item type control mapping value are merged), and the target form rendering component that matches the form field can be determined. For example, if the form field type is "Select", according to the mapping relationship between the form field type and the form field type defined by the form rendering component and the specific component, the specific components mapped will be different depending on the UI framework. In the react+antd (UI framework) technical framework, "Select" can be mapped to antd's Select component. In the vue+element (UI framework) technical framework, "Select" can be mapped to element's el-select. If there are customized requirements, custom components can also be mapped. If the field has a format like Figure 4 The dependency configuration shown is through Figure 6The parsing method shown is used to parse the conditional configuration data. The final parsing result is stored through the state variable. If it is a disabled conditional configuration, the state variable is applied to the corresponding component to control the disabled parameters. For example, the Select component under antd is disabled. If it is a visible conditional configuration, the state variable is used to decide whether to render the current form item, that is, to complete the visible or disabled dependency setting.
[0083] For example, when rendering input items or drop-down selections according to the form item type, if there is a disabled or visible dependency configuration for the form item, the dependency data is parsed and restored to a relational expression or logical expression, and an update condition is added. When encapsulating components, other extended parameters are added according to the application scenario, such as read-only, disabled, and extended type control mapping. Read-only is passed in when viewing form data. The form rendering component passes the read-only parameters to the fine-grained type form item components. The content cannot be edited when it is read-only, and the presentation form can also be developed for read-only. In this way, the new, edit, and view pages can share the same page, greatly improving development efficiency. Disabled In certain scenarios (such as insufficient permissions), the form is controlled to prohibit editing as a whole. The form rendering component also passes the disabled parameters to the fine-grained type form item components to control whether it is disabled. The extended type control mapping parameters can realize the on-demand import of some components and achieve page loading efficiency. For example, the form rendering component can only have basic type components built in, which can meet general usage scenarios. However, in some scenarios, when some special types of components or custom components are needed, after the page for rendering the form is imported, a relationship mapping can be made with the value of the form item type field in Table 1, and then the extended type control mapping parameter can be passed to the form rendering component.
[0084] For fields that contain Figure 4 The process of parsing the form field configuration data of the corresponding field is as follows: Figure 6 shown.
[0085] First, use JavaScript's reduce method to traverse the conditional set data in the conditional item configuration and return the final calculation result.
[0086] Then, when traversing the current condition item configuration, the current condition item configuration is parsed, and if there is a sub-item condition set therein, subsequent processing is performed.
[0087] Next, parse the relational operator, obtain the current value of the target form item according to the current form value and the name of the target form item in the conditional item configuration, and substitute the current value of the target form item, the relational operator, and the target form item's satisfied value into the following table: Figure 5 The Boolean result of the relational operation is obtained in the mapping shown.
[0088] Furthermore, depending on whether the Boolean result of the current relational operation needs to be inverted, the corresponding operation is performed. If it needs to be inverted, the Boolean result of the current operation is inverted, and then the logical operation result with the previous result is returned; if it does not need to be inverted, the logical operation result with the previous result is returned.
[0089] After the above steps are processed, the final logical operation result is finally returned.
[0090] Step S14: Render the form to the corresponding position of the form on the target page.
[0091] The components rendered based on each form item form the final form, and the form is rendered to the form position of the target page to complete the rendering of the form.
[0092] Figure 2 The flow chart of the second embodiment of the method for rendering a form with dependency fields of the present invention (single-page multi-form rendering method) is shown. Figure 2 , the implementation steps of the method of this embodiment are described in detail as follows.
[0093] Step S21: In the form rendering page, the form rendering component obtains the configuration list of the current page form through the interface, stores the configuration list data in the state variable, and binds it to the list display view (the display form depends on business requirements).
[0094] Step S22: After a form rendering data in the configuration list is selected, it is converted into the standard data format required by the form rendering component and stored in the state variable of the field configuration of the current form.
[0095] Step S23: The state variable is passed to the form rendering component through the parameters of the form field configuration data.
[0096] Step S24: the form rendering component traverses each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field will be parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form.
[0097] The specific processing method of step S24 is the same as step S13 of the previous embodiment, and will not be repeated here.
[0098] Step S25: Render the form to the corresponding position of the form on the target page.
[0099] The components rendered based on each form item form the final form, and the form is rendered to the form position of the target page to complete the rendering of the form.
[0100] Figure 7The module of the first embodiment of the form rendering system of the present invention that can render form fields with dependency relationships is shown. Figure 7 The system of this embodiment includes: a data request module, a component parameter transmission module, a parsing module, and a form position rendering module. Figure 1 The method embodiments shown correspond.
[0101] The data request module is configured so that in the form rendering page, the form rendering component obtains a single form rendering data through an interface request. Figure 1 Step S11 of the method embodiment shown is not described in detail here.
[0102] The component parameter transfer module is configured to convert the requested form rendering data into the standard data format required by the form rendering component, and then pass the parameters of the form field configuration data to the form rendering component. Figure 1 Step S12 of the method embodiment shown is not described in detail here.
[0103] The parsing module is configured as a form rendering component to traverse each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form. For specific reference Figure 1 Step S13 of the method embodiment shown is not described in detail here.
[0104] The form position rendering module is configured to render the form to the corresponding position of the form on the target page. Figure 1 Step S14 of the method embodiment shown is not described in detail here.
[0105] Figure 8 The module of the first embodiment of the form rendering system of the present invention that can render form fields with dependency relationships is shown. Figure 8 The system of this embodiment includes: a data request module, a data conversion module, a component parameter transmission module, a parsing module, and a form position rendering module. Figure 2 The method embodiments shown correspond.
[0106] The data request module is configured so that in the form rendering page, the form rendering component obtains the configuration list of the current page form through the interface, stores the configuration list data in the state variable, and binds it to the list display view. Figure 2 Step S21 of the method embodiment shown is not described in detail here.
[0107] The data conversion module is configured to convert a form rendering data in the configuration list into the standard data format required by the form rendering component after it is selected, and store it in the state variable of the field configuration of the current form. Figure 2 Step S22 of the method embodiment shown is not described in detail here.
[0108] The component parameter transfer module is configured as a state variable to pass the parameters of the form field configuration data to the form rendering component. For details, refer to Figure 2 Step S23 of the method embodiment shown is not described in detail here.
[0109] The parsing module is configured as a form rendering component to traverse each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form. For specific reference Figure 2 Step S24 of the method embodiment shown is not described in detail here.
[0110] The form position rendering module is configured to render the form to the corresponding position of the form on the target page. Figure 2 Step S25 of the method embodiment shown is not described in detail here.
[0111] Although the above methods are illustrated and described as a series of actions for simplicity of explanation, it should be understood and appreciated that these methods are not limited by the order of the actions, because according to one or more embodiments, some actions may occur in a different order and / or concurrently with other actions from those illustrated and described herein or not illustrated and described herein but understandable to those skilled in the art.
[0112] Those skilled in the art will further appreciate that the various illustrative logic blocks, modules, circuits, and algorithm steps described in conjunction with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or a combination of the two. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps are generally described above in terms of their functionality. Whether such functionality is implemented as hardware or software depends on the specific application and the design constraints imposed on the overall system. The technician may implement the described functionality in different ways for each specific application, but such implementation decisions should not be interpreted as resulting in a departure from the scope of the present invention.
[0113] The various illustrative logic blocks, modules, and circuits described in conjunction with the embodiments disclosed herein may be implemented or performed with a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in cooperation with a DSP core, or any other such configuration.
[0114] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software module may reside in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read and write information from / to the storage medium. In an alternative, a storage medium may be integrated into a processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In an alternative, the processor and the storage medium may reside in a user terminal as discrete components.
[0115] In one or more exemplary embodiments, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented as a computer program product in software, each function may be stored on or transmitted by a computer-readable medium as one or more instructions or codes. Computer-readable media include both computer storage media and communication media, including any medium that facilitates the transfer of a computer program from one place to another. Storage media may be any available medium that can be accessed by a computer. As an example and not limitation, such a computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer. Any connection is also properly referred to as a computer-readable medium. For example, if the software is transmitted from a website, a server, or other remote source using a coaxial cable, a fiber optic cable, a twisted pair, a digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwaves, the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwaves are included in the definition of the medium. Disk and disc as used herein include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, wherein disk often reproduces data magnetically, while disc reproduces data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0116] The previous description of the disclosure is provided to enable any person skilled in the art to make or use the disclosure. Various modifications to the disclosure will be apparent to those skilled in the art, and the general principles defined herein may be applied to other variations without departing from the spirit or scope of the disclosure. Thus, the disclosure is not intended to be limited to the examples and designs described herein, but should be granted the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A form rendering method capable of rendering fields with dependency relationships, characterized in that: Methods include: In the first step, in the form rendering page, the form rendering component obtains a single form rendering data through an interface request; The second step is to convert the requested form rendering data into the standard data format required by the form rendering component, and then pass it to the form rendering component through the parameters of the form field configuration data; In the third step, the form rendering component traverses each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form; Step 4: Render the form to the corresponding position of the form on the target page; Among them, in the third step, when there is a dependent configuration in the field, the process of parsing the form field configuration data of the corresponding field further includes the following steps: First, use JavaScript's reduce method to traverse the conditional set data in the conditional item configuration and return the final calculation result; Then, when traversing the current condition item configuration, the current condition item configuration is parsed, and if there is a sub-item condition set in it, subsequent processing is performed; Next, the relational operator is parsed, and the current value of the target form item is obtained according to the current form value and the name of the target form item in the conditional item configuration. The current value of the target form item, the relational operator, and the target form item satisfaction value are substituted into the mapping to obtain the Boolean result of the relational operation. Furthermore, the corresponding operation is performed according to whether the Boolean result of the current relational operation needs to be inverted. If it needs to be inverted, the Boolean result of the current operation is inverted, and then the logical operation result with the previous result is returned; if it does not need to be inverted, the logical operation result with the previous result is returned; After the above steps are processed, the final logical operation result is finally returned; The format of the form rendering data includes several form item names, form item types, dependency configurations of whether the form item is disabled or visible, and whether it is required. Among them, the form item type corresponds to the form item component type, including input item, number input item, drop-down selection, date and time selection, single selection, checkbox, toggle switch, and code editor; Among them, the dependency configuration is defined as a tree data format to support complex logical relationship configuration and facilitate interface transmission.
2. The form rendering method capable of rendering fields with dependency relationships according to claim 1, characterized in that: In the second step, the specific processing method of passing the form field configuration data to the form rendering component is as follows: The parameters passed to the form rendering component include form field configuration data, form initial value, read-only, disabled, and extended type control mappings. Among them, the form field configuration data is bound to the form rendering component through the parameters of the form field configuration data; the form initial value parameter is the initial value after the form is loaded; the read-only parameter is used to set the rendered form controls to read-only mode when viewing the form configuration data; the disable parameter is used to disable the editing function of the form under set conditions; the extended type control mapping realizes the on-demand loading of the corresponding form item type component inside the form rendering component.
3. A form rendering method capable of rendering fields with dependency relationships, characterized in that: Methods include: In the first step, in the form rendering page, the form rendering component obtains the configuration list of the current page form through the interface, stores the configuration list data in the state variable, and binds it to the list display view; In the second step, a form rendering data in the configuration list is selected and converted into the standard data format required by the form rendering component, and stored in the state variable of the field configuration of the current form; In the third step, the state variables are passed to the form rendering component through the parameters of the form field configuration data; In the fourth step, the form rendering component traverses each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form; Step 5: Render the form to the corresponding position of the form on the target page; Among them, in the fourth step, when there is a dependent configuration in the field, the process of parsing the form field configuration data of the corresponding field further includes the following steps: First, use JavaScript's reduce method to traverse the conditional set data in the conditional item configuration and return the final calculation result; Then, when traversing the current condition item configuration, the current condition item configuration is parsed, and if there is a sub-item condition set in it, subsequent processing is performed; Next, the relational operator is parsed, and the current value of the target form item is obtained according to the current form value and the name of the target form item in the conditional item configuration. The current value of the target form item, the relational operator, and the target form item satisfaction value are substituted into the mapping to obtain the Boolean result of the relational operation. Furthermore, the corresponding operation is performed according to whether the Boolean result of the current relational operation needs to be inverted. If it needs to be inverted, the Boolean result of the current operation is inverted, and then the logical operation result with the previous result is returned; if it does not need to be inverted, the logical operation result with the previous result is returned; After the above steps are processed, the final logical operation result is finally returned; The format of the form rendering data includes several form item names, form item types, dependency configurations of whether the form item is disabled or visible, and whether it is required. Among them, the form item type corresponds to the form item component type, including input item, number input item, drop-down selection, date and time selection, single selection, checkbox, toggle switch, and code editor; Among them, the dependency configuration is defined as a tree data format to support complex logical relationship configuration and facilitate interface transmission.
4. The method for rendering a form having dependency fields according to claim 3, characterized in that: In the third step, the specific processing method of passing the form field configuration data to the form rendering component is as follows: The parameters passed to the form rendering component include form field configuration data, form initial value, read-only, disabled, and extended type control mappings. Among them, the form field configuration data is bound to the form rendering component through the parameters of the form field configuration data; the form initial value parameter is the initial value after the form is loaded; the read-only parameter is used to set the rendered form controls to read-only mode when viewing the form configuration data; the disable parameter is used to disable the editing function of the form under set conditions; the extended type control mapping realizes the on-demand loading of the corresponding form item type component inside the form rendering component.
5. A form rendering system capable of rendering fields with dependency relationships, characterized in that: The system includes: The data request module is configured so that in the form rendering page, the form rendering component obtains a single form rendering data through an interface request; The component parameter transmission module is configured to convert the form rendering data obtained from the request into the standard data format required by the form rendering component, and then transmit the parameters of the form field configuration data to the form rendering component; The parsing module is configured as a form rendering component to traverse each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form; A form position rendering module is configured to render the form to the corresponding position of the form on the target page; Among them, in the parsing module, when there is a dependent configuration in the field, the process of parsing the form field configuration data of the corresponding field further includes the following steps: First, use JavaScript's reduce method to traverse the conditional set data in the conditional item configuration and return the final calculation result; Then, when traversing the current condition item configuration, the current condition item configuration is parsed, and if there is a sub-item condition set in it, subsequent processing is performed; Next, the relational operator is parsed, and the current value of the target form item is obtained according to the current form value and the name of the target form item in the conditional item configuration. The current value of the target form item, the relational operator, and the target form item satisfaction value are substituted into the mapping to obtain the Boolean result of the relational operation. Furthermore, the corresponding operation is performed according to whether the Boolean result of the current relational operation needs to be inverted. If it needs to be inverted, the Boolean result of the current operation is inverted, and then the logical operation result with the previous result is returned; if it does not need to be inverted, the logical operation result with the previous result is returned; After the above steps are processed, the final logical operation result is finally returned; The format of the form rendering data includes several form item names, form item types, dependency configurations of whether the form item is disabled or visible, and whether it is required. Among them, the form item type corresponds to the form item component type, including input item, number input item, drop-down selection, date and time selection, single selection, checkbox, toggle switch, and code editor; Among them, the dependency configuration is defined as a tree data format to support complex logical relationship configuration and facilitate interface transmission.
6. A form rendering system capable of rendering fields with dependency relationships, characterized in that: The system includes: The data request module is configured so that in the form rendering page, the form rendering component obtains the configuration list of the current page form through the interface, stores the configuration list data in the state variable, and binds it to the list display view; The data conversion module is configured to convert a form rendering data in the configuration list into the standard data format required by the form rendering component after it is selected, and store it in the state variable of the field configuration of the current form; The component parameter transfer module is configured as a state variable and passes the parameters of the form field configuration data to the form rendering component; The parsing module is configured as a form rendering component to traverse each field in the form field configuration data. If the current field has a dependent configuration, the form field configuration data of the corresponding field is parsed and applied to the corresponding form rendering component to control the disabled or visible parameter position to obtain the rendered form; A form position rendering module is configured to render the form to the corresponding position of the form on the target page; Among them, in the parsing module, when there is a dependent configuration in the field, the process of parsing the form field configuration data of the corresponding field further includes the following steps: First, use JavaScript's reduce method to traverse the conditional set data in the conditional item configuration and return the final calculation result; Then, when traversing the current condition item configuration, the current condition item configuration is parsed, and if there is a sub-item condition set in it, subsequent processing is performed; Next, the relational operator is parsed, and the current value of the target form item is obtained according to the current form value and the name of the target form item in the conditional item configuration. The current value of the target form item, the relational operator, and the target form item satisfaction value are substituted into the mapping to obtain the Boolean result of the relational operation. Furthermore, the corresponding operation is performed according to whether the Boolean result of the current relational operation needs to be inverted. If it needs to be inverted, the Boolean result of the current operation is inverted, and then the logical operation result with the previous result is returned; if it does not need to be inverted, the logical operation result with the previous result is returned; After the above steps are processed, the final logical operation result is finally returned; The format of the form rendering data includes several form item names, form item types, dependency configurations of whether the form item is disabled or visible, and whether it is required. Among them, the form item type corresponds to the form item component type, including input item, number input item, drop-down selection, date and time selection, single selection, checkbox, toggle switch, and code editor; Among them, the dependency configuration is defined as a tree data format to support complex logical relationship configuration and facilitate interface transmission.
