Form processing method and device, electronic equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-19
- Publication Date
- 2026-08-11
Smart Images

Figure CN122549385A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a form processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] In related technologies, low-code platforms and workflow approval systems widely use dynamic forms as the data interaction medium. Configuration personnel need to flexibly set the relationships between fields in the form using rule expressions to implement functions such as displaying / hiding fields, disabling fields, setting default values, and data validation.
[0003] Existing configuration and association controls for dynamic forms suffer from insufficient expression parsing capabilities and limited data type handling, making them unsuitable for complex business scenarios and resulting in low accuracy of form processing results. Summary of the Invention
[0004] The purpose of this application is to address the shortcomings of the prior art by providing a form processing method, apparatus, electronic device, and storage medium to meet the control requirements of dynamic forms and improve the processing accuracy and efficiency of dynamic forms.
[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a form processing method, including: Retrieve the associated expression for the target field in the target form; Based on the associated expression and the preset syntax rules, an abstract syntax tree is determined; the abstract syntax tree is used to indicate the syntax hierarchy and operation order contained in the associated expression; Construct a context object based on the abstract syntax tree and the context variables of the target form; Based on the abstract syntax tree, generate the execution function; In response to changes in the associated data in the target form, the execution function is called based on the context object to obtain the status control result of the target field; wherein, the status control result is used to indicate the display status or editable status of the target field in the target form.
[0006] Secondly, embodiments of this application also provide a form processing apparatus, including: an acquisition module, a determination module, a construction module, a generation module, and a processing module; The acquisition module is used to acquire the associated expression of the target field in the target form; The determining module is used to determine an abstract syntax tree based on the associated expression and preset syntax rules; the abstract syntax tree is used to indicate the syntax hierarchy and operation order contained in the associated expression; The construction module is used to construct a context object based on the abstract syntax tree and the context variables of the target form; The generation module is used to generate an executable function based on the abstract syntax tree; The processing module is used to respond to changes in the associated data in the target form, call the execution function based on the context object, and obtain the status control result of the target field; wherein, the status control result is used to indicate the display status or editable status of the target field in the target form.
[0007] Thirdly, embodiments of this application provide an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the form processing method provided in the first aspect.
[0008] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the form processing method as provided in the first aspect.
[0009] The beneficial effects of this application are: This application provides a form processing method, apparatus, electronic device, and storage medium, comprising: obtaining the association expression of a target field in a target form; determining an abstract syntax tree based on the association expression and preset syntax rules; constructing a context object based on the abstract syntax tree and context variables of the target form; generating an execution function based on the abstract syntax tree; responding to changes in the associated data in the target form, calling the execution function based on the context object, and obtaining the state control result of the target field. This method constructs the user-configured association expression into an abstract syntax tree, supports bracket grouping and operator precedence processing based on the abstract syntax tree, and the subsequent execution function generated based on the abstract syntax tree can completely retain the original logical structure of the association expression, achieving accurate parsing of complex expressions and meeting the dynamic form control needs of multiple business scenarios; based on the syntactic sugar mechanism, it can simplify the way users write association expressions, reducing user learning costs and maintenance difficulties.
[0010] In addition, by performing data type enhancement processing on the extracted original field values that are comma-separated strings, a proxy object is encapsulated, which enables these field values to support calls to common methods such as includes() and length(), without requiring configuration personnel to manually convert the data format.
[0011] Secondly, by using an abstract syntax tree to determine the variables and safety functions required for the associated expression, and by constructing a context object based on the variables, safety functions, and proxy objects, a safe and controllable execution environment can be provided for the execution function. By generating the execution function through the function constructor, the use of eval can be avoided, and by restricting the scope of the execution function, the safety of function execution can be guaranteed.
[0012] Finally, by using a batch file automatic matching strategy based on regular expression matching, batch file automatic filling can be achieved, thereby improving the processing efficiency of batch files. Attached Figure Description
[0013] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 A flowchart illustrating the form processing method provided in this application embodiment. Figure 1 ; Figure 2 A flowchart illustrating the form processing method provided in this application embodiment. Figure 2 ; Figure 3 A flowchart illustrating the form processing method provided in this application embodiment. Figure 3 ; Figure 4 A flowchart illustrating the form processing method provided in this application embodiment. Figure 4 ; Figure 5 A flowchart illustrating the form processing method provided in this application embodiment. Figure 5 ; Figure 6 A flowchart illustrating the form processing method provided in this application embodiment. Figure 6 ; Figure 7 A flowchart illustrating the form processing method provided in this application embodiment. Figure 7 ; Figure 8 A flowchart illustrating the form processing method provided in this application embodiment. Figure 8 ; Figure 9 A flowchart illustrating the form processing method provided in this application embodiment. Figure 9 ; Figure 10 A schematic diagram of a form processing device provided in an embodiment of this application; Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0015] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0016] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0017] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0018] Existing dynamic form configuration association controls typically have the following shortcomings: 1. Insufficient expression parsing capabilities: Many systems only support simple string matching or sequential execution logic, lacking handling of bracket grouping and operator precedence, making them unsuitable for complex business scenarios.
[0019] 2. Limited data type handling: For special data such as comma-separated strings, it is still necessary to manually convert them into arrays or objects before performing operations such as includes() and length(), resulting in complex configuration and a high risk of errors.
[0020] 3. Insufficient security: Some systems directly use "eval" to execute configuration expressions, which poses a risk of code injection and makes it difficult to meet security compliance requirements.
[0021] 4. Lack of intelligent processing for batch file uploads: After users upload a batch of files, they need to manually match form fields, which is inefficient and prone to errors.
[0022] 5. Lack of syntactic sugar support: Commonly used existence checks and explicit control logic are written in a lengthy manner, which is not conducive to quick understanding and maintenance by configuration personnel.
[0023] To address the aforementioned shortcomings, this solution constructs an abstract syntax tree (AST) from user-configured associative expressions using lexical analysis and recursive descent parsing. Based on this AST, it supports handling bracket grouping and operator precedence. The subsequent execution function generated from the AST retains the original logical structure of the associative expression, achieving precise parsing of complex expressions. By encapsulating comma-separated string field values as proxy objects, the field values can support calls to common methods such as `includes()` and `length()` without manual data format conversion. The execution function is generated using a function constructor, avoiding the use of `eval`, and the scope of the execution function is restricted to ensure execution safety. A batch file auto-matching strategy based on regular expression matching enables automated filling of batch files, improving processing efficiency. The syntactic sugar mechanism simplifies the writing of associative expressions, reducing learning costs and maintenance difficulty.
[0024] Figure 1 A flowchart illustrating the form processing method provided in this application embodiment. Figure 1 The subject executing this method can be a computer device, such as... Figure 1 As shown, the method includes: S101. Obtain the association expression of the target field in the target form.
[0025] The target form can be any form that needs to be configured for field association control, such as a financial form, an attendance form, etc. The target field can be a field in the target form that needs to be subject to status control. The status of the target field will usually change dynamically based on the changes in the field values of other fields in the target form.
[0026] Users can input association expressions for target fields through the configuration interface. Here, "user" refers to the form configuration personnel, i.e., developers. Association expressions are a rule language used by users to describe the conditions under which a target field is shown / hidden / disabled; in other words, they define the business logic upon which the display / hiding / disabling or other behaviors of the target field depend. Corresponding association expressions can be configured for all target fields in the target form that require configuration. Based on these expressions, execution functions can be generated. Subsequently, when a user fills out the target form, the system can call the corresponding execution function in real time, calculate the result, and dynamically control the state of the target field based on the calculation, thus realizing the linkage logic between form fields.
[0027] Optionally, users can determine the association expression corresponding to the target field according to their needs. The exemplary template library can store association expression templates for common scenarios. Users can refer to the association expression templates according to their usage needs to generate association expressions corresponding to different target fields.
[0028] S102. Determine the abstract syntax tree based on the associated expressions and the preset syntax rules.
[0029] An abstract syntax tree (AST) includes at least function call nodes, identifier nodes, attribute access nodes, comparison operation nodes, and logical operation nodes; the AST is used to indicate the syntax hierarchy and order of operations contained in an associative expression.
[0030] It can split or traverse the associated expression to break it down into the smallest indivisible units, such as numbers, characters, and operators. Then, based on preset syntax rules, it can perform structured processing on the split units to generate an abstract syntax tree.
[0031] The predefined syntax rules define the proper structure of associative expressions, guiding how to correctly organize the smallest decomposed units into an abstract syntax tree, thereby ensuring that associative expressions can be understood and executed unambiguously. These syntax rules include, but are not limited to: specifying operator precedence and associativity (e.g., && has lower precedence than >); specifying the composition of various syntactic components (identifiers, literals, function calls, member accesses, etc.); providing matching criteria during parsing; and supporting error detection and recovery.
[0032] Abstract syntax trees (ASTs) are used to express the syntactic hierarchy and order of operations of associative expressions in a structured and unambiguous manner, providing a traversable and convertible intermediate representation for the construction of subsequent context objects, the generation of execution functions, and real-time computation.
[0033] It should be noted that the function call node indicates a function call in an associative expression, used to invoke a predefined safe function, perform business logic such as existence checks and regular expression matching, and return the calculation result; the identifier node indicates a variable name or field name in an associative expression, used to read the current value of the corresponding field from the context object of the execution environment; the attribute access node indicates access to an object's attribute or method, used to generate calls to methods or nested attributes of fields in the context object, and is usually the left child node of the function call node; the comparison operation node indicates a relational comparison operation, used to compare the values of the left and right sub-expressions and generate a Boolean result; the logical operation node indicates logical AND (&&) and logical OR (||) operations, used to combine multiple Boolean conditions and finally generate a compound Boolean result.
[0034] S103. Construct a context object based on the abstract syntax tree and the context variables of the target form.
[0035] Constructing a context object can also be understood as building an execution environment, that is, preparing the necessary data context and security boundaries for the evaluation of associative expressions. The constructed context object can be used as an input parameter for subsequent execution functions, and as the field values of the fields related to the associative expression in the target form change, the context object can also be updated in real time to ensure real-time evaluation of the associative expression and real-time updates to the state of the target fields.
[0036] Optionally, the context object may include: variable values, safe functions, and proxy objects. Variable values are dynamically updated as the target form is filled in real-time. Proxy objects are the result of data type enhancement processing on some variable values to enable them to support function calls. Safe functions are functions determined by the function call nodes in the abstract syntax tree that need to be called. They can perform specific operations without introducing security risks. Only safe functions can be injected into the execution environment and called normally. Function calls other than safe functions are considered abnormal calls, and configuration error messages may be output or execution may be directly refused.
[0037] The context variables of the target form refer to the collection of all fields and their corresponding values that already exist or are available during the filling or use of the target form. Context can refer to the environmental background, i.e., what data has already been filled in the target form. Variables refer to the individual fields in the target form; the identifier or name of each field is the variable name, and the current value of the field is the variable value. The variables required for calculation can be determined based on the abstract syntax tree, and their current values can be extracted from the context variables of the target form to form the variable values in the context object.
[0038] S104. Generate the execution function based on the abstract syntax tree.
[0039] Based on the generated abstract syntax tree, the corresponding execution function can be compiled and generated. The execution function is used to receive a context object representing the execution environment as input parameter and return the evaluation result of the association expression.
[0040] It's worth noting that the execution function can refer to the executable code generated after compiling the associative expression. The internal calculation logic of the execution function is the same as the rules described by the associative expression. Since the associative expression is a string input by the user according to specific syntax rules, the computer cannot execute it. Therefore, after the above processing, the execution function corresponding to the generated associative expression is computer-readable and executable code. By running the execution function, the result of the associative expression can be calculated.
[0041] S105. In response to changes in the associated data in the target form, the execution function is called based on the context object to obtain the status control result of the target field.
[0042] The status control result is used to indicate the display status or editable status of the target field in the target form.
[0043] The construction of the context object and the execution function described above can be understood as preliminary operations. After construction, during subsequent real-time user interactions with the target form, the system can respond in real-time to changes in the associated data within the target form, thereby triggering the call to the execution function. The execution function is then run based on the context object to obtain the state control results of the target fields. Here, "user" refers to the user filling out the form, and "associated data" refers to the field values related to the associated expressions.
[0044] When the value of a field associated with an association expression changes, the execution function corresponding to the association expression is called. After the execution function completes, the state control result of the target field is obtained.
[0045] If a user's data change operation is not associated with any related expressions, no function will be called.
[0046] For example, a user configures a correlation expression for the target field "Invoice Amount". The rule described by the correlation expression is that if the field value of "Customer Type" contains "VIP" and the field value of "Total Amount" is greater than 5000, then the target field "Invoice Amount" cell will be displayed. When the user changes the field value of "Customer Type" or "Total Amount" while using the target form, the execution function corresponding to the correlation expression will be called and executed to recalculate whether the changed customer type and invoice amount meet the above conditions. If they do, the invoice amount cell will be displayed; otherwise, the invoice amount cell will be hidden.
[0047] In summary, the form processing method provided in this embodiment includes: obtaining the association expression of the target field in the target form; determining an abstract syntax tree based on the association expression and preset syntax rules; constructing a context object based on the abstract syntax tree and the context variables of the target form; generating an execution function based on the abstract syntax tree; responding to changes in the associated data in the target form, calling the execution function based on the context object, and obtaining the state control result of the target field. This method constructs the user-configured association expression into an abstract syntax tree, supports bracket grouping and operator precedence processing based on the abstract syntax tree, and the subsequent execution function generated based on the abstract syntax tree can completely retain the original logical structure of the association expression, achieving accurate parsing of complex expressions and meeting the dynamic form control needs of multiple business scenarios.
[0048] Figure 2 A flowchart illustrating the form processing method provided in this application embodiment. Figure 2 Optionally, in step S102, the abstract syntax tree is determined based on the associative expression and preset syntax rules, including: S201. Perform lexical analysis on the relational expression to generate a word sequence.
[0049] In some embodiments, user-input associative expressions can support syntactic sugar forms, thereby simplifying the writing logic of user-input associative expressions and avoiding redundancy. After obtaining the associative expression in syntactic sugar form, the syntactic sugar can be expanded to convert it into a standard expression before lexical analysis.
[0050] By scanning the associative expression character by character and classifying them according to character type, the associative expression can be decomposed into a series of smallest units with syntactic meaning, resulting in a word sequence, or token sequence.
[0051] For example, suppose the associated expression is: display("invoiceAmount") = exists(customerType)&&customerType.includes("VIP")&&totalAmount>5000; the generated token sequence can be: {identifier "display", left parenthesis, string "invoiceAmount", right parenthesis, equal sign, identifier "exists", left parenthesis, identifier "customerType", right parenthesis, logical AND "&&", identifier "customerType", dot, identifier "includes", left parenthesis, string "VIP", right parenthesis, logical AND "&&", identifier "totalAmount", greater than sign, number 5000}.
[0052] S202. Based on the preset grammar rules, perform recursive descent parsing on the word sequence to generate an abstract syntax tree.
[0053] Using a recursive descent parsing method, the generated token sequence can be converted into an abstract syntax tree according to predefined syntax rules.
[0054] Optionally, a parsing function can be written for each syntax rule. These functions could include, for example, `parseExpression()`, `parseAnd()`, `parseComparison()`, and `parsePrimary()`. By employing recursive descent parsing, each syntax rule corresponds to an independent parsing function. This allows for a step-by-step approach to accurately locate syntax errors when parsing associative expressions containing multiple levels of nested parentheses and complex operator precedence. Compared to general table-driven parsers, recursive descent parsing offers a clearer code structure in low-code forms—business scenarios with relatively fixed rules but frequent syntax expansions—and is easier to quickly extend and maintain based on newly added syntactic sugar rules, thereby improving the flexibility and maintainability of expression parsing.
[0055] Starting with the highest priority rule, each parsing function is recursively called. After successfully matching a syntax rule, each parsing function returns a node object of an abstract syntax tree. The node type includes the various types provided in step S102 above.
[0056] The following priority rules can be used for recursive processing: parseExpression(): Processes the lowest priority ||; parseAnd(): Handles &&, recursively collecting the right operand each time && is encountered; parseComparison(): Handles comparison operations such as >, <, ==, !=; parsePrimary(): Handles function calls (such as exists(...)), property access (such as customerType.includes(...)), constants (numbers, strings), and parentheses grouping.
[0057] For example, the structure of the generated abstract syntax tree is shown below: AND ├── AND │├── FunctionCall: exists(customerType) │└── MethodCall: customerType.includes("VIP") └── BinaryOp: totalAmount>5000 The structure of the abstract syntax tree matches the operator precedence, bracket grouping, and order of operations in the associative expression.
[0058] Figure 3 A flowchart illustrating the form processing method provided in this application embodiment. Figure 3 Optionally, in step S103, a context object is constructed based on the abstract syntax tree and the context variables of the target form, including: S301. Based on the abstract syntax tree, determine the identifiers of each field to be accessed and the security functions to be injected corresponding to the association expression.
[0059] The abstract syntax tree can be traversed, and the identifiers of the fields to be accessed corresponding to each identifier node can be determined. That is, the field names that the association expression needs to access. Taking the above association expression as an example, the identifiers of the fields to be accessed are customerType and totalAmount.
[0060] At the same time, based on the function call nodes traversed, the safe functions to be called by the associated expression can be determined. Based on the above example, the determined safe functions can be, for example, exist(), includes(), and startsWith(); among them, exist() belongs to the existence judgment class of safe functions, while includes() and startsWith() belong to the string matching class of safe functions.
[0061] S302. Based on the identifier of each field to be accessed, extract the original value of each field to be accessed from the context variable of the target form.
[0062] The context variable of the target form contains all the fields that currently exist in the target form and can be obtained, along with their corresponding field values. Based on the identifier of each field to be accessed, the field value corresponding to each field to be accessed can be extracted from it as the original value of each field to be accessed.
[0063] That is, extract the field values of customerType and totalAmount from the context variables of the target form.
[0064] S303. Construct a context object based on the original values of each field to be accessed and each security function.
[0065] The required context object can be obtained by injecting the original values of each field to be accessed and each security function into the initial context object.
[0066] The constructed context object ensures that the executed function only accesses allowed variables and functions at runtime, providing a safe and controllable execution environment and preventing security risks caused by the injection of unsafe functions.
[0067] Figure 4 A flowchart illustrating the form processing method provided in this application embodiment. Figure 4 Optionally, in step S303, a context object is constructed based on the original values of each field to be accessed and each security function, including: S401. Determine whether the target field exists in each field to be accessed.
[0068] The target field to be accessed can refer to fields whose values are of special types. These fields usually cannot directly support calls to certain functions. You can first determine whether the target field to be accessed exists among the fields to be accessed.
[0069] Optionally, the method for determining the target field to be accessed includes: traversing each field to be accessed, and for the current field to be accessed that has been traversed, if the original value of the current field to be accessed satisfies a preset expression, then the current field to be accessed is taken as a target field to be accessed; the preset expression includes a comma-separated string.
[0070] In some embodiments, when the original value of the field to be accessed is a comma-separated string, the field to be accessed is treated as a target field to be accessed.
[0071] S402. If it exists, perform data type enhancement processing on the original value of the target field to be accessed, so as to encapsulate the original value of the target field to be accessed into a proxy object.
[0072] The proxy object supports the invocation of specified functions.
[0073] Since the original value of the target field to be accessed is a special type of data, in order to enable these original values to support the calling of certain specified functions, data type enhancement processing is performed on them to encapsulate the original values into a proxy object that can call the aforementioned specified functions.
[0074] For example, if the original value is "VIP,Partner" or "A,B,C", it will be automatically encapsulated into a proxy object, enabling it to support functions and methods such as .includes(), .length, and .map().
[0075] If the original value is a regular string without commas, such as "VIP", or if the original value is a non-string type, such as a number, boolean value, or real array, then it will not be encapsulated and the original value will be retained directly.
[0076] Using the above method, users can perform array operations on comma-separated strings without writing additional conversion functions, thus improving the ability to handle this data type.
[0077] S403. Assemble the unprocessed raw value of the field to be accessed, the processed proxy object of the target field to be accessed, and each security function to construct the context object.
[0078] By injecting the original values of the unencapsulated fields to be accessed, the encapsulated proxy object, and the security function into the initial context object, the required context object can be obtained.
[0079] Optionally, if the target field to be accessed does not exist among the fields to be accessed, the original values of each field to be accessed and each security function are assembled to construct a context object.
[0080] Figure 5 A flowchart illustrating the form processing method provided in this application embodiment. Figure 5 Optionally, in step S104, an execution function is generated based on the abstract syntax tree, including: S501, Convert the abstract syntax tree into target code.
[0081] You can first convert the abstract syntax tree into a piece of executable target code.
[0082] S502. Use a function constructor to compile the target code into an executable function.
[0083] Optionally, a function constructor can be used to compile the target code into an executable function, which can be: `new Function('context', 'with(context) { return ...}')`. By dynamically creating the function using `newFunction(...)` instead of directly using `eval()`, access to the global scope of the target form page (such as `window`, `document`, etc.) can be avoided. The `context` parameter, i.e., the constructed context object, is a filtered object containing only allowed field values (such as `totalAmount`, `customerType`) and safe functions (such as `exists`). Global objects not listed in `context` cannot be accessed in the associative expression. The purpose of `with(context)` is to automatically look up identifiers (such as `customerType`) in the associative expression from the `context` object, eliminating the need to write `context.customerType` for every variable, making the expression more natural. The function returns a boolean value: after execution, it returns the evaluation result (true / false) of the associative expression, which determines the state of the target field.
[0084] In this implementation, by first converting the abstract syntax tree into an executable target code string and then compiling it into a native executable function using a function constructor, the stack overhead of runtime recursive calls is reduced compared to node-by-node recursive interpretation execution. This allows multiple repeated calls to associative expressions to achieve execution performance closer to native code. At the same time, since the executable function is strictly limited to running within the scope of the passed-in context object, it retains the flexibility of syntax parsing while effectively preventing the injection of unsafe code, thus balancing execution efficiency and runtime security.
[0085] Figure 6 A flowchart illustrating the form processing method provided in this application embodiment. Figure 6 Optionally, in step S105, in response to changes in the associated data in the target form, an execution function is called based on the context object to obtain the status control result of the target field, including: S601. Respond to changes in the field values of fields associated with the association expression in the target form, and obtain the current field values of each field.
[0086] During the process of a user filling out a target form, changes in field values can be detected in real time. When the field values of fields related to the association expression corresponding to the target field change, the current field values of these related fields can be obtained.
[0087] Continuing with the example above, when a change is detected in the values of the fields customerType and totalAmount, the current values of these fields after the change can be obtained.
[0088] S602. Determine the updated context object based on the current field values of each field and the context object.
[0089] When constructing the context object, the field values in the context object are generated based on the data already filled in the target form at the time of construction. However, the field values in the constructed context object may change during the user's subsequent modification of the target form. Therefore, it is necessary to update the context object with the obtained current field values to update the field values in the context object to the latest form data.
[0090] The old field values of these fields in the context object can be replaced with the current field values of each field obtained above to obtain the updated context object.
[0091] For example, when constructing the context object, the field value of the customerType field is "VIP" and the field value of the totalAmount field is 5000. If the user changes the field value of the totalAmount field to 6000 at the current moment, then the 5000 in the context object needs to be replaced with 6000, and the execution function needs to be re-run.
[0092] S603. Pass the updated context object to the execution function, run the execution function, and obtain the execution result.
[0093] Optionally, the updated context object is used as a new input parameter to the execution function, triggering the execution function to obtain the execution result.
[0094] The execution result can be either true or false.
[0095] S604. Based on the execution results, determine the status control result of the target field.
[0096] When the calculation result is true, the cell of the target field will be displayed in the target form; when the calculation result is false, the cell of the target field will not be displayed.
[0097] Of course, this embodiment takes the control of the display status of the target field by the association expression as an example. If the calculation result is true, the cell of the target field is displayed; if the calculation result is false, the cell of the target field is not displayed.
[0098] In practical applications, association expressions can also control the editability of a target field. In this scenario, if the evaluation result is true, the target field is in a non-editable state (i.e., disabled), and if the evaluation result is false, the target field is in an editable state. A non-editable target field means that the target field is visible but the user cannot edit it.
[0099] Of course, association expressions can also be used to control the data validation of the target field. When the calculation result is true, the field value of the target field is successfully validated; when the calculation result is false, an error is displayed.
[0100] Optionally, after determining the status control result of the target field in step S105, the method further includes: refreshing the interface display of the target form in real time based on the status control result of the target field.
[0101] In some embodiments, the display interface of the target form can be dynamically refreshed based on the state control result of the target field. For example, when it is determined that the target field should be displayed, the cell of the target field will be displayed immediately on the page of the target form.
[0102] Figure 7 A flowchart illustrating the form processing method provided in this application embodiment. Figure 7 Optionally, this method also includes: S701: Respond to batch file upload operations and obtain attribute information for each file.
[0103] This method also provides an intelligent matching processing method for files uploaded in batches by users. In some approval processes, the target form may have multiple fields that need to be filled at the same time, and users may upload multiple files in batches, such as ID photos, report photos, etc. In this case, the attribute information of each file can be automatically extracted for each file uploaded in batches.
[0104] The attribute information includes, but is not limited to: file identifier (filename, which may include serial number and category), file size and resolution, file summary information (such as hash value, MD5 value, etc.).
[0105] S702. Based on the attribute information of each file and the pre-configured regular expression matching strategy, determine the matching result between each file and each preset field in the target form.
[0106] Regular expression matching strategies include various types of matching instructions. For example, if the document identifier contains "year" and "front", the document will be matched to the "front of document" field; if the document identifier contains "year" and "back", the document will be matched to the "back of document" field; if the document size matches the size of an ID photo, the document will be matched to the "ID photo" field, etc.
[0107] By matching each attribute of a file with each matching instruction in the regular expression matching strategy, the matching result between each file and each preset field can be determined. The preset fields are the fields configured in the regular expression matching strategy.
[0108] S703. Based on the matching results between each file and each preset field, fill each file into the corresponding field.
[0109] Based on the matching results between each file and each preset field, the field that best matches each file can be automatically determined, so that the file's Uniform Resource Locator (URL) or file identifier can be filled into the corresponding field.
[0110] Figure 8 A flowchart illustrating the form processing method provided in this application embodiment. Figure 8 Optionally, in step S702, based on the attribute information of each file and the pre-configured regular expression matching strategy, the matching result between each file and each preset field in the target form is determined, including: S801. Based on the filenames of each file, determine the first matching data between each file and each preset field.
[0111] This embodiment uses the above three attributes for regular expression matching as an example. In practical applications, more regular expression matching strategies can be configured to extract more different types of attributes for matching.
[0112] The regular expression matching strategy can contain matching instructions for each preset field. Based on the attribute information of each file and the matching instructions for each preset field, matching results can be generated.
[0113] Based on the filenames of each file, each file can be matched with each preset field. Each file corresponds to multiple first matching data. The first matching data of a file is the matching data between the file and a preset field determined based on the filename.
[0114] S802. Based on the size and resolution of each file, determine the second matching data between each file and each preset field.
[0115] Similarly, based on the size and resolution of each file, the second matching data between each file and each preset field can be determined.
[0116] S803. Based on the summary information of each file, determine the third matching data between each file and each preset field.
[0117] Similarly, based on the summary information of each file, the third matching data between each file and each preset field can be determined.
[0118] When matching a predefined field based on filename, if the filename in the filename regular expression strategy requires an exact match, the first matching data can be 100; otherwise, it is 0. If the filename is partially matched, the first matching data can be a midpoint between 0 and 100.
[0119] When matching resolution: check whether the actual width and height of the file (e.g., image) meet the requirements of the preset field (e.g., minimum width 800px); if it meets the requirements, it gets 100 points, otherwise it can be given 0~100 points according to the degree of closeness.
[0120] Matching based on MD5 values: This is typically used for deduplication or validation. For example, you can compare the MD5 value of a file to see if it is the same as the MD5 value of a previously uploaded file (0 points for duplication if the field requires uniqueness); or compare it with a preset MD5 whitelist, giving 100 points for a match and 0 points for otherwise.
[0121] S804. Based on the first matching data between each file and each preset field, the second matching data between each file and each preset field, and the third matching data between each file and each preset field, determine the matching result between each file and each preset field.
[0122] In some embodiments, the matching data from the three dimensions can be weighted and summed to obtain the matching result between each file and each preset field. By combining filename regular expression matching, image size and resolution verification, and file summary information comparison, complex scenarios such as similar filenames but different content, or non-standard filenames but image sizes that meet ID photo requirements, can be effectively handled, significantly reducing the probability of misjudgment caused by single-dimensional matching. For example, when two files both contain the keyword "ID card" in their filenames but have resolutions of 300dpi and 72dpi respectively, the second matching data from the resolution dimension can distinguish between official scans and temporary screenshots, thereby avoiding incorrectly filling the ID photo field with non-compliant files and improving the accuracy and reliability of file-field mapping during batch file uploads.
[0123] Of course, in practical applications, the matching instructions set for each preset field may not necessarily involve all three dimensions mentioned above. They may only involve one or two of them. Alternatively, the matching result can be determined through a step-by-step filtering method. For example, for the preset field to be matched, a first match can be performed based on the filename. If the match fails, the subsequent matching with the current preset field to be matched ends directly, and the next preset field is used as the new field to be matched, performing a first match with the filename. If the first match with the filename is successful, the file resolution is then matched with the current preset field to be matched. The specific matching method is not limited.
[0124] Figure 9 A flowchart illustrating the form processing method provided in this application embodiment. Figure 9 Optionally, in step S703, based on the matching results between each file and each preset field, each file is filled into the corresponding field, including: S901. Based on the matching results between each file and each preset field, determine the field priority sorting result corresponding to each file.
[0125] The matching result between each file and each preset field is the comprehensive matching score between each file and each preset field. The preset fields can be sorted from largest to smallest according to the comprehensive score to obtain the field priority sorting result for each file. The preset field with the highest comprehensive matching score with the file can be sorted first.
[0126] The field priority sorting results for each file are different because some files may best match the preset field a, while others may best match the preset field b.
[0127] S902. Based on the priority sorting results of the fields corresponding to each file, determine the target preset fields corresponding to each file from the preset fields.
[0128] Taking the overall matching score as sorted from largest to smallest as an example, the preset field that ranks first can be used as the target preset field corresponding to the file based on the field priority sorting results.
[0129] S903. Fill each file into the corresponding target preset field.
[0130] The URL, filename, or other identifier of each file can be filled into the corresponding target preset field. By prioritizing each preset field based on the overall matching score, when multiple files match the same target preset field, or when the same file receives high matching data in multiple preset fields, the system can automatically select the optimal mapping relationship based on the ranking results. For example, if two files both meet the matching strategy for a certain ID photo, the file with the higher overall score will be prioritized for filling that field, and the other file will be deferred to the next highest priority field or prompted for user confirmation. This effectively avoids the problems of duplicate field filling and conflict overwriting in batch file upload scenarios, improving the reliability of automated filling.
[0131] In some embodiments, when multiple files correspond to the same target preset field, the file with the best matching result can be selected based on the matching results of these files with the target preset field, that is, the file with the highest overall matching score can be selected.
[0132] In other embodiments, when the overall matching score between the determined optimal file and the target preset field is lower than the matching threshold, a prompt message can be sent to the user for manual confirmation.
[0133] The above method can quickly and automatically match and populate the appropriate fields for batch files uploaded by users, eliminating the need for users to manually upload them one by one.
[0134] In summary, the form processing method provided in this application includes: obtaining the association expression of a target field in a target form; determining an abstract syntax tree based on the association expression and preset syntax rules; constructing a context object based on the abstract syntax tree and the context variables of the target form; generating an execution function based on the abstract syntax tree; responding to changes in the associated data in the target form, calling the execution function based on the context object, and obtaining the state control result of the target field. This method constructs the user-configured association expression into an abstract syntax tree, supports bracket grouping and operator precedence processing based on the abstract syntax tree, and the subsequent execution function generated based on the abstract syntax tree can completely retain the original logical structure of the association expression, achieving accurate parsing of complex expressions and meeting the dynamic form control needs of multiple business scenarios. Based on the syntactic sugar mechanism, it simplifies the way users write association expressions, reducing user learning costs and maintenance difficulty.
[0135] In addition, by performing data type enhancement processing on the extracted original field values that are comma-separated strings, a proxy object is encapsulated, which enables these field values to support calls to common methods such as includes() and length(), without requiring configuration personnel to manually convert the data format.
[0136] Secondly, by using an abstract syntax tree to determine the variables and safety functions required for the associated expression, and by constructing a context object based on the variables, safety functions, and proxy objects, a safe and controllable execution environment can be provided for the execution function. By generating the execution function through the function constructor, the use of eval can be avoided, and by restricting the scope of the execution function, the safety of function execution can be guaranteed.
[0137] Finally, by using a batch file automatic matching strategy based on regular expression matching, batch file automatic filling can be achieved, thereby improving the processing efficiency of batch files.
[0138] The following describes the apparatus, device, and storage medium used to execute the form processing method provided in this application. The specific implementation process and technical effects are described above and will not be repeated below.
[0139] Figure 10 This is a schematic diagram of a form processing device provided in an embodiment of this application. The functions implemented by this form processing device correspond to the steps performed by the above-described method. Optionally, the device may include: an acquisition module 100, a determination module 200, a construction module 300, a generation module 400, and a processing module 500; Module 100 is used to retrieve the associated expression of the target field in the target form; The determination module 200 is used to determine the abstract syntax tree based on the associated expression and the preset syntax rules; the abstract syntax tree is used to indicate the syntax hierarchy and operation order contained in the associated expression; Module 300 is used to construct a context object based on the abstract syntax tree and the context variables of the target form; Module 400 is used to generate executable functions based on the abstract syntax tree; The processing module 500 is used to respond to changes in the associated data in the target form, call the execution function based on the context object, and obtain the status control result of the target field; wherein, the status control result is used to indicate the display status or editable status of the target field in the target form.
[0140] Optionally, module 200 is specifically used to perform lexical analysis on the associated expression and generate a lexical sequence; Based on preset grammar rules, the word sequence is recursively parsed by descent to generate an abstract syntax tree.
[0141] Optionally, the construction module 300 is specifically used to determine the identifiers of each field to be accessed and each security function to be injected based on the abstract syntax tree; Based on the identifier of each field to be accessed, extract the original value of each field to be accessed from the context variables of the target form; The context object is constructed based on the original values of each field to be accessed and each security function.
[0142] Optionally, module 300 is specifically used to determine whether the target field to be accessed exists in each field to be accessed; If it exists, the original value of the target field to be accessed is subjected to data type enhancement processing to encapsulate the original value of the target field to be accessed into a proxy object; the proxy object supports the calling of the specified function; The context object is constructed by assembling the unprocessed raw value of the field to be accessed, the processed proxy object of the target field to be accessed, and each security function.
[0143] Optionally, the construction module 300 is specifically used to assemble the original values of each field to be accessed and each security function if they do not exist, to construct the context object.
[0144] Optionally, the determination module 200 is specifically used to traverse each field to be accessed. For the current field to be accessed that has been traversed, if the original value of the current field to be accessed meets the preset expression form, then the current field to be accessed is taken as a target field to be accessed. The preset expression form includes comma-separated strings.
[0145] Optionally, module 400 is generated, specifically for converting the abstract syntax tree into target code; The target code is compiled into an executable function using a function constructor.
[0146] Optionally, the processing module 500 is specifically used to respond to changes in the field values of fields associated with the association expression in the target form and to obtain the current field values of each field; Determine the updated context object based on the current field values of each field and the context object; The updated context object is passed to the execution function, and the execution function is run to obtain the execution result; Based on the execution results, determine the status control result of the target field.
[0147] Optionally, the processing module 500 is also used to refresh the interface display of the target form in real time based on the status control result of the target field.
[0148] Optionally, the processing module 500 is also used to respond to batch file upload operations and obtain attribute information of each file; Based on the attribute information of each file and the pre-configured regular expression matching strategy, determine the matching results between each file and each preset field in the target form; Based on the matching results between each file and each preset field, each file is filled into the corresponding field.
[0149] Optionally, the processing module 500 is specifically used to determine the first matching data between each file and each preset field based on the file name of each file; Based on the size and resolution of each file, determine the second matching data between each file and each preset field; Based on the summary information of each file, determine the third matching data between each file and each preset field; Based on the first matching data between each file and each preset field, the second matching data between each file and each preset field, and the third matching data between each file and each preset field, determine the matching result between each file and each preset field.
[0150] Optionally, the processing module 500 is specifically used to determine the field priority sorting result corresponding to each file based on the matching result between each file and each preset field; Based on the priority sorting results of the fields corresponding to each file, determine the target preset fields corresponding to each file from each preset field; Fill each file into the corresponding target preset field.
[0151] These modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more digital signal processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).
[0152] The modules described above can be connected or communicate with each other via wired or wireless connections. Wired connections can include metal cables, optical fibers, hybrid cables, or any combination thereof. Wireless connections can include connections via LAN, WAN, Bluetooth, ZigBee, or NFC, or any combination thereof. Two or more modules can be combined into a single module, and any module can be divided into two or more units. Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here.
[0153] Figure 11 A schematic diagram of an electronic device provided in this application embodiment includes: a processor 801, a storage medium 802, and a bus 803. The storage medium 802 stores machine-readable instructions executable by the processor 801. When the electronic device runs a form processing method as described in the embodiment, the processor 801 communicates with the storage medium 802 via the bus 803. The processor 801 executes the machine-readable instructions to perform the following steps: Retrieve the associated expression for the target field in the target form; Based on the associative expressions and the preset syntax rules, an abstract syntax tree is determined; the abstract syntax tree is used to indicate the syntax hierarchy and order of operations contained in the associative expressions. Construct a context object based on the abstract syntax tree and the context variables of the target form; Generate the executable function based on the abstract syntax tree; In response to changes in the associated data in the target form, the execution function is called based on the context object to obtain the status control result of the target field; the status control result is used to indicate the display status or editable status of the target field in the target form.
[0154] In a feasible implementation, when the processor 801 determines the abstract syntax tree based on the associated expression and preset syntax rules, it is specifically used to: perform lexical analysis on the associated expression and generate a sequence of lexical units; Based on preset grammar rules, the word sequence is recursively parsed by descent to generate an abstract syntax tree.
[0155] In a feasible implementation, when the processor 801 constructs a context object based on the abstract syntax tree and the context variables of the target form, it is specifically used to: determine the identifiers of each field to be accessed and each security function to be injected based on the abstract syntax tree. Based on the identifier of each field to be accessed, extract the original value of each field from the context variable of the target form; construct a context object based on the original value of each field to be accessed and each security function.
[0156] In a feasible implementation, when the processor 801 constructs a context object based on the original values of each field to be accessed and each security function, it specifically performs the following: determines whether a target field to be accessed exists among the fields to be accessed; if it exists, it performs data type enhancement processing on the original value of the target field to be accessed to encapsulate the original value of the target field to be accessed into a proxy object; the proxy object supports the calling of the specified function; and assembles the unprocessed original value of the field to be accessed, the processed proxy object of the target field to be accessed, and each security function to construct the context object.
[0157] In one feasible implementation, the processor 801 is also used to perform the following: if not present, assembling the original values of each field to be accessed and each security function to construct a context object.
[0158] In a feasible implementation, when the processor 801 performs the operation of determining whether a target field exists among the fields to be accessed, it specifically performs the following: traversing each field to be accessed, and for the current field to be accessed that has been traversed, if the original value of the current field to be accessed satisfies a preset expression, then the current field to be accessed is taken as a target field to be accessed; the preset expression includes a comma-separated string.
[0159] In one feasible implementation, when the processor 801 executes the generation of an executable function based on the abstract syntax tree, it is specifically used to: convert the abstract syntax tree into target code; The target code is compiled into an executable function using a function constructor.
[0160] In a feasible implementation, when the processor 801 executes the execution function based on the context object to obtain the status control result of the target field after responding to changes in the associated data in the target form, it is specifically used to: respond to changes in the field values of the fields associated with the associated expression in the target form and obtain the current field values of each field; Determine the updated context object based on the current field values of each field and the context object; The updated context object is passed to the execution function, and the execution function is run to obtain the execution result; Based on the execution results, determine the status control result of the target field.
[0161] In one feasible implementation, after executing the determination of the status control result of the target field, the processor 801 is also used to: refresh the interface display of the target form in real time based on the status control result of the target field.
[0162] In one feasible implementation, the processor 801 is also used to perform: responding to a batch file upload operation and obtaining attribute information for each file; Based on the attribute information of each file and the pre-configured regular expression matching strategy, determine the matching results between each file and each preset field in the target form; Based on the matching results between each file and each preset field, each file is filled into the corresponding field.
[0163] In a feasible implementation, when the processor 801 executes the process of determining the matching results between each file and each preset field in the target form based on the attribute information of each file and the pre-configured regular expression matching strategy, it is specifically used to: determine the first matching data between each file and each preset field based on the file name of each file; Based on the size and resolution of each file, determine the second matching data between each file and each preset field; Based on the summary information of each file, determine the third matching data between each file and each preset field; Based on the first matching data between each file and each preset field, the second matching data between each file and each preset field, and the third matching data between each file and each preset field, determine the matching result between each file and each preset field.
[0164] In one feasible implementation, when the processor 801 performs the task of filling each file into the corresponding field based on the matching results between each file and each preset field, it is specifically used to: determine the field priority sorting result corresponding to each file based on the matching results between each file and each preset field; Based on the priority sorting results of the fields corresponding to each file, determine the target preset fields corresponding to each file from each preset field; Fill each file into the corresponding target preset field.
[0165] The storage medium 802 stores program code, which, when executed by the processor 801, causes the processor 801 to perform various steps in the form processing methods according to various exemplary embodiments of this application as described in the "Exemplary Methods" section above.
[0166] The processor 801 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0167] Storage medium 802, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The memory can include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory is any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. Storage medium 802 in the embodiments of this application can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0168] Optionally, embodiments of this application also provide a computer-readable storage medium storing a computer program, which is executed by a processor, and the processor performs the following steps: Retrieve the associated expression for the target field in the target form; Based on the associative expressions and the preset syntax rules, an abstract syntax tree is determined; the abstract syntax tree is used to indicate the syntax hierarchy and order of operations contained in the associative expressions. Construct a context object based on the abstract syntax tree and the context variables of the target form; Generate the executable function based on the abstract syntax tree; In response to changes in the associated data in the target form, the execution function is called based on the context object to obtain the status control result of the target field; the status control result is used to indicate the display status or editable status of the target field in the target form.
[0169] In a feasible implementation, when the processor 801 determines the abstract syntax tree based on the associated expression and preset syntax rules, it is specifically used to: perform lexical analysis on the associated expression and generate a sequence of lexical units; Based on preset grammar rules, the word sequence is recursively parsed by descent to generate an abstract syntax tree.
[0170] In a feasible implementation, when the processor 801 constructs a context object based on the abstract syntax tree and the context variables of the target form, it is specifically used to: determine the identifiers of each field to be accessed and each security function to be injected based on the abstract syntax tree. Based on the identifier of each field to be accessed, extract the original value of each field from the context variable of the target form; construct a context object based on the original value of each field to be accessed and each security function.
[0171] In a feasible implementation, when the processor 801 constructs a context object based on the original values of each field to be accessed and each security function, it specifically performs the following: determines whether a target field to be accessed exists among the fields to be accessed; if it exists, it performs data type enhancement processing on the original value of the target field to be accessed to encapsulate the original value of the target field to be accessed into a proxy object; the proxy object supports the calling of the specified function; and assembles the unprocessed original value of the field to be accessed, the processed proxy object of the target field to be accessed, and each security function to construct the context object.
[0172] In one feasible implementation, the processor 801 is also used to perform the following: if not present, assembling the original values of each field to be accessed and each security function to construct a context object.
[0173] In a feasible implementation, when the processor 801 performs the operation of determining whether a target field exists among the fields to be accessed, it specifically performs the following: traversing each field to be accessed, and for the current field to be accessed that has been traversed, if the original value of the current field to be accessed satisfies a preset expression, then the current field to be accessed is taken as a target field to be accessed; the preset expression includes a comma-separated string.
[0174] In one feasible implementation, when the processor 801 executes the generation of an executable function based on the abstract syntax tree, it is specifically used to: convert the abstract syntax tree into target code; The target code is compiled into an executable function using a function constructor.
[0175] In a feasible implementation, when the processor 801 executes the execution function based on the context object to obtain the status control result of the target field after responding to changes in the associated data in the target form, it is specifically used to: respond to changes in the field values of the fields associated with the associated expression in the target form and obtain the current field values of each field; Determine the updated context object based on the current field values of each field and the context object; The updated context object is passed to the execution function, and the execution function is run to obtain the execution result; Based on the execution results, determine the status control result of the target field.
[0176] In one feasible implementation, after executing the determination of the status control result of the target field, the processor 801 is also used to: refresh the interface display of the target form in real time based on the status control result of the target field.
[0177] In one feasible implementation, the processor 801 is also used to perform: responding to a batch file upload operation and obtaining attribute information for each file; Based on the attribute information of each file and the pre-configured regular expression matching strategy, determine the matching results between each file and each preset field in the target form; Based on the matching results between each file and each preset field, each file is filled into the corresponding field.
[0178] In a feasible implementation, when the processor 801 executes the process of determining the matching results between each file and each preset field in the target form based on the attribute information of each file and the pre-configured regular expression matching strategy, it is specifically used to: determine the first matching data between each file and each preset field based on the file name of each file; Based on the size and resolution of each file, determine the second matching data between each file and each preset field; Based on the summary information of each file, determine the third matching data between each file and each preset field; Based on the first matching data between each file and each preset field, the second matching data between each file and each preset field, and the third matching data between each file and each preset field, determine the matching result between each file and each preset field.
[0179] In one feasible implementation, when the processor 801 performs the task of filling each file into the corresponding field based on the matching results between each file and each preset field, it is specifically used to: determine the field priority sorting result corresponding to each file based on the matching results between each file and each preset field; Based on the priority sorting results of the fields corresponding to each file, determine the target preset fields corresponding to each file from each preset field; Fill each file into the corresponding target preset field.
[0180] In this embodiment, the computer program, when run by the processor, can also execute other machine-readable instructions to perform other methods as described in the embodiments. For details on the specific execution steps and principles, please refer to the description of the embodiments, which will not be repeated here.
[0181] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0182] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0183] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.
[0184] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A form processing method characterized by, include: Retrieve the associated expression for the target field in the target form; Based on the associated expression and the preset syntax rules, an abstract syntax tree is determined; The abstract syntax tree is used to indicate the syntax hierarchy and order of operations contained in the associated expression; Construct a context object based on the abstract syntax tree and the context variables of the target form; Based on the abstract syntax tree, generate the execution function; In response to changes in the associated data in the target form, the execution function is called based on the context object to obtain the status control result of the target field; wherein, the status control result is used to indicate the display status or editable status of the target field in the target form.
2. The method of claim 1, wherein, The step of determining the abstract syntax tree based on the associated expression and preset syntax rules includes: Lexical analysis is performed on the associated expression to generate a word sequence; According to the preset grammar rules, the word sequence is recursively parsed by descent to generate the abstract syntax tree.
3. The method of claim 1, wherein, The step of constructing a context object based on the abstract syntax tree and the context variables of the target form includes: Based on the abstract syntax tree, determine the identifiers of each field to be accessed and the security functions to be injected corresponding to the associated expression; Based on the identifier of each field to be accessed, extract the original value of each field to be accessed from the context variable of the target form; The context object is constructed based on the original values of each field to be accessed and each security function.
4. The method of claim 3, wherein, The step of constructing the context object based on the original values of each field to be accessed and each security function includes: Determine whether the target field exists in any of the fields to be accessed; If it exists, the original value of the target field to be accessed is subjected to data type enhancement processing to encapsulate the original value of the target field to be accessed into a proxy object; the proxy object supports the calling of the specified function; The context object is constructed by assembling the unprocessed raw value of the field to be accessed, the processed proxy object of the target field to be accessed, and each security function.
5. The method of claim 4, wherein, Also includes: If it does not exist, the original values of each field to be accessed and each security function are assembled to construct the context object.
6. The method of claim 4, wherein, Determining whether the target field exists among the fields to be accessed includes: Iterate through each field to be accessed. For the current field to be accessed, if the original value of the current field to be accessed meets the preset expression form, then the current field to be accessed is taken as a target field to be accessed. The preset expression form includes comma-separated strings.
7. The method of claim 1, wherein, The step of generating an execution function based on the abstract syntax tree includes: Convert the abstract syntax tree into target code; The target code is compiled into the executable function using a function constructor.
8. The method of claim 1, wherein, The response to changes in the associated data in the target form, by calling the execution function based on the context object, and obtaining the status control result of the target field, includes: In response to changes in the field values of the fields associated with the association expression in the target form, obtain the current field values of each field; Based on the current field values of each field and the context object, determine the updated context object; The updated context object is passed to the execution function, and the execution function is run to obtain the execution result; Based on the execution result, determine the status control result of the target field.
9. The method according to claim 1, characterized in that, After determining the state control result of the target field, the method further includes: The interface display of the target form is refreshed in real time based on the status control result of the target field.
10. The method according to claim 1, characterized in that, Also includes: Respond to batch file upload operations and obtain the attribute information of each file; Based on the attribute information of each file and the pre-configured regular expression matching strategy, determine the matching result between each file and each preset field in the target form; Based on the matching results between each file and each preset field, each file is filled into the corresponding field.
11. The method according to claim 10, characterized in that, The step of determining the matching result between each file and each preset field in the target form based on the attribute information of each file and the pre-configured regular expression matching strategy includes: Based on the filenames of each file, determine the first matching data between each file and each preset field; Based on the size and resolution of each file, determine the second matching data between each file and each preset field; Based on the summary information of each file, determine the third matching data between each file and each preset field; Based on the first matching data between each file and each preset field, the second matching data between each file and each preset field, and the third matching data between each file and each preset field, determine the matching result between each file and each preset field.
12. The method according to claim 10, characterized in that, The step of filling each file into the corresponding field based on the matching results between each file and each preset field includes: Based on the matching results between each file and each preset field, determine the field priority sorting result corresponding to each file; Based on the priority sorting results of the fields corresponding to each file, determine the target preset fields corresponding to each file from each preset field; Fill each file into the corresponding target preset field.
13. A form processing device, characterized in that, include: The modules include: acquisition module, determination module, construction module, generation module, and processing module. The acquisition module is used to acquire the associated expression of the target field in the target form; The determining module is used to determine an abstract syntax tree based on the associated expression and preset syntax rules; The abstract syntax tree is used to indicate the syntax hierarchy and order of operations contained in the associated expression; The construction module is used to construct a context object based on the abstract syntax tree and the context variables of the target form; The generation module is used to generate an executable function based on the abstract syntax tree; The processing module is used to respond to changes in the associated data in the target form, call the execution function based on the context object, and obtain the status control result of the target field; wherein, the status control result is used to indicate the display status or editable status of the target field in the target form.
14. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores program instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the form processing method as described in any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, performs the form processing method as described in any one of claims 1 to 12.