Movatterモバイル変換


[0]ホーム

URL:


HK40016164A - Form component state switching method and device - Google Patents

Form component state switching method and device
Download PDF

Info

Publication number
HK40016164A
HK40016164AHK42020005748.7AHK42020005748AHK40016164AHK 40016164 AHK40016164 AHK 40016164AHK 42020005748 AHK42020005748 AHK 42020005748AHK 40016164 AHK40016164 AHK 40016164A
Authority
HK
Hong Kong
Prior art keywords
state
component
page
code
code set
Prior art date
Application number
HK42020005748.7A
Other languages
Chinese (zh)
Other versions
HK40016164B (en
Inventor
郑淳
Original Assignee
阿里巴巴集团控股有限公司
Filing date
Publication date
Application filed by 阿里巴巴集团控股有限公司filedCritical阿里巴巴集团控股有限公司
Publication of HK40016164ApublicationCriticalpatent/HK40016164A/en
Publication of HK40016164BpublicationCriticalpatent/HK40016164B/en

Links

Description

Form component state switching method and device
Technical Field
The present application relates to the field of information technologies, and in particular, to a method and an apparatus for switching states of form components.
Background
The form page generation technology is a common technology in Web application development, and usually when a form page is compiled, a plurality of form pages in different states, such as new creation, editing, details and the like of an order, are often needed to be compiled, and most form elements in the plurality of form pages in different states are the same, but only the states of the form elements are different.
Currently, for a JSP (Java Server Pages) form component library, switching of a form page state can be controlled based on switching of read-only and edit states of a browser basic component, so that different HTML (HyperText Markup Language) codes are generated for a same form page resource in the read-only and edit states, and when the browser needs to switch the form page state, different HTML codes are accessed.
However, in the prior art, the states of the generated form page cannot be switched at will, two page codes in different states need to be generated, and only two states of read-only and editing can be controlled.
Disclosure of Invention
In view of the foregoing problems, an embodiment of the present application provides a form component state switching method, where a form state control component is loaded, a first form component used by a form page is obtained through the form state control component, a state switching instruction for switching the first form component from a first state to a second state is received, and a code set corresponding to the second state is used to replace a code set corresponding to the first state in a page code of the form page through the form state control component, so as to solve the problem that the state of the form page generated in the prior art cannot be switched at will, page codes in two different states need to be generated, and only read-only and editing states can be controlled.
Correspondingly, the embodiment of the application also provides a form component state switching device, which is used for ensuring the realization and the application of the method.
In order to solve the above problem, an embodiment of the present application discloses a form component state switching method, including:
loading a form state control component;
acquiring a first form component used by a form page through the form state control component; the first form component comprises a plurality of states, and the states respectively correspond to a code set;
receiving a state switching instruction for switching the first form component from a first state to a second state;
and replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page through the form state control component. Correspondingly, the embodiment of the present application further discloses a form component state switching device, including:
the loading module is used for loading the form state control component;
the first form component acquisition module is used for acquiring a first form component used by a form page through the form state control component; the first form component comprises a plurality of states, and the states respectively correspond to a code set;
the instruction receiving module is used for receiving a state switching instruction for switching the first form component from a first state to a second state;
and the replacing module is used for replacing the code set corresponding to the first state by using the code set corresponding to the second state in the page code of the form page through the form state control component.
Correspondingly, this application embodiment still discloses a device, its characterized in that includes:
one or more processors; and
one or more machine-readable media having instructions stored thereon, which when executed by the one or more processors, cause the apparatus to perform a form component state switching method.
Accordingly, one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a form component state switching method are also disclosed.
The embodiment of the application has the following advantages:
according to the embodiment of the application, the form state control assembly is loaded, the first form assembly used by the form page is obtained through the form state control assembly, the first form assembly comprises multiple states, the multiple states correspond to the code sets respectively, the state switching instruction for switching the first form assembly from the first state to the second state is received, and the code set corresponding to the second state is used for replacing the code set corresponding to the first state in the page codes of the form page through the form state control assembly. In the running process of the page code, when the state of the first form component needs to be switched, the form state control component replaces code sets in different states, the page code of one form page is written, the form page can be reused in multiple states, the function of randomly switching the page state of the form is achieved through state switching of the first form component, and the cost for writing the form page is greatly reduced.
Drawings
FIG. 1 is a processing diagram of a form component state switching method according to an embodiment of the present application;
FIG. 2 is a processing diagram of another form component state switching method according to an embodiment of the present application;
FIG. 3 is a diagram illustrating a switching of a form page according to an embodiment of the present application;
FIG. 4 is a flowchart of a form component state switching method according to an embodiment of the present application;
FIG. 5 is a flowchart illustrating a method for switching states of form components according to an embodiment of the present disclosure;
FIG. 6 is a flow chart of another form component state switching method according to an embodiment of the present application;
FIG. 7 is a block diagram of a form component state switching apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a client according to an embodiment of the present application.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description.
The technical scheme of the application is mainly applied to an internet scene so as to switch the state of the first form component in the form page of the client. The client in the embodiment of the present application may be a browser, for example, a browser in a computer or a browser in a mobile phone, or may also be other applications including a form page, such as applications in panning, kyoto, and the like, and the embodiment of the present application does not limit the application.
Referring to fig. 1, a processing diagram of a form component state switching method according to an embodiment of the present application is shown.
In this embodiment of the application, when the user accesses the form page through the client, the client performs step S1: sending a form page request to the application server, and after receiving the form page request sent by the client, the application server executes step S2: the method comprises the steps of returning a corresponding page code of a form page to a client, loading the page code after the client receives the page code of the form page returned by an application server, executing step S3 while loading the page code, loading a form state control component, and then executing step S4, and obtaining a first form component used by the form page from an adaptation layer through the form state control component, wherein the first form component comprises a plurality of states, and the plurality of states respectively correspond to a section of code set. In the running process of the form page of the client, when a state switching instruction for switching the first form component from the first state to the second state is received, step S5 is executed, a code set corresponding to the second state of the first form component is acquired from the adaptation layer through the form state control component, and then step S6 is executed, and the code set corresponding to the second state of the first form component is used to replace the code set corresponding to the first state of the first form component. Wherein, the adaptation layer can be arranged in the application server.
In this embodiment, when the state of the first form component of the form page is switched, the other code sets except the code set of the first form component are updated and may remain unchanged.
The form state control component is a state switching core of the embodiment of the application, and can run in a thread form after being loaded, and then obtains the first form component, stores the form value, switches states and other logics.
Referring to fig. 2, a processing diagram of another form component state switching method according to the embodiment of the present application is shown.
The adaptation layer including the first form component can also be arranged in the component server, the client loads the page code after receiving the page code of the form page returned by the application server, the first form component used by the form page is obtained from the adaptation layer of the component server through the form state control component, in the running process of the form page of the client, when a state switching instruction for switching the first form component from the first state to the second state is received, a code set corresponding to the second state of the first form component is obtained from the adaptation layer of the component server through the form state control component, and then subsequent steps are executed.
As described in fig. 1 and fig. 2, in the embodiment of the present application, for the adaptation layer providing the first form component, the adaptation layer may be disposed in an application server, and disposed in the same server as the provider of the form page, and the adaptation layer may also be disposed in a component server, and disposed in two different servers separately from the provider of the form page, which is not limited in the embodiment of the present application.
Referring to fig. 3, a schematic diagram of switching a form page according to an embodiment of the present application is shown.
Specifically, for each original form component library, carrying out standardization processing on an original second form component in the original form component library to obtain an adaptation layer, wherein the adaptation layer comprises a standardized first form component corresponding to the original second form component, and the first form component comprises multiple states; the original form component library comprises an anti open source form component library, an open source amazeui form component library, an open source rc-component form component library, an open source RSUITE form component library and the like.
After the adaptation layer is obtained, the client side obtains a page code of the form page from the application server, loads the page code, loads the form state control component while loading the page code, obtains a first form component used by the form page from the adaptation layer through the form state control component, obtains a code set corresponding to a second state of the first form component from the adaptation layer through the form state control component when a state switching instruction for switching the first form component from the first state to the second state is received in the running process of the form page, replaces the code set corresponding to the first state of the first form component with the code set corresponding to the second state of the first form component, and switches the form pages in different states by switching the states of the first form component.
In the running process of the page code, the form state control assembly is used for replacing code sets in different states so as to switch the state of the first form assembly, and the function of randomly switching the page state of the form is achieved.
Example one
Referring to fig. 4, a flowchart of a form component state switching method according to an embodiment of the present application is shown, which may specifically include the following steps:
step 401, load form state control component.
In the embodiment of the application, after the page code of the form page is acquired from the application server, the page code is loaded, and the form state control component is loaded while the page code is loaded.
The page code can be an HTML code, one or more form tags are arranged in the page code, in addition, a form state control component is also arranged, the form tags in the page code are bound with the corresponding form state control component, and the state of a first form component in the page code can be controlled through the form state control component.
Step 402, obtaining a first form component used by a form page through the form state control component; the first form component comprises a plurality of states, and the states respectively correspond to a code set.
In the embodiment of the application, a form state control component acquires a first form component used by a form page, where the first form component includes multiple states, such as an edit state, a preview state, and the like, and each state corresponds to a segment of a code set.
In an embodiment of the application, a code set of a first form component used by a form page is written into a page code of the form page, and when the page code of the form page is acquired from an application server, the code set of the first form component is acquired at the same time, and the code set of the first form component is loaded through a form state control component.
Wherein the state of the first form component comprises: at least one of an edit state, a preview state, a disable state, a load state, and a hide state.
The first form component includes an < input > input box for gathering user-entered content, a < select > drop-down selection box, etc., where the type attribute specifies the type of input tag, such as text box txet, password box passboard, radio, check box checkbox, hidden field hodden, submit button, etc. When the type of the < input > form component is a text box txet, the input text information is directly displayed in the box, when the type of the < input > form component is a password box passboard, the input text is displayed in the form of an origin or an asterisk, and when the type of the < input > form component is a hidden field hodden, the text information is not displayed on a page but is submitted along with other contents when the text information is submitted; when the type of the < input > form component is submit button submit, it is used to submit the contents in the form page.
Step 403, receiving a state switching instruction for switching the first form component from the first state to the second state.
In the embodiment of the invention, in the running process of the form page, a state switching instruction for switching the first form component from the first state to the second state is received.
Wherein, the state switching instruction of the first form component comprises: when the triggering operation of the designated control is received in the form page, the business logic of the form page automatically executes at least one of the nodes reaching the state switching logic.
For example, after an order is edited, the order is submitted by clicking, then a trigger operation for a specified control, such as a receiving address, a contact telephone and the like, is received in the form page, and a first form component in the order page is switched from an editing state to a preview state; when a form page needs to be opened, the first form component is in a loading state, and when the loading is completed, the first form component is automatically switched to an editing state.
Step 404, replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page through the form state control component.
In the embodiment of the application, after a state switching instruction for switching the first form component from the first state to the second state is received, the form state control component is used to obtain a code set corresponding to the second state of the first form component, and in a page code of a form page, the code set corresponding to the second state of the first form component is used to replace the code set corresponding to the first state of the first form component, so that the state switching of the first form component is successful.
The form page may be composed of a plurality of code sets, that is, the form page may include a plurality of first form components, and when one of the code sets of the first form components is replaced, the state of the form page is switched.
According to the embodiment of the application, the form state control assembly is loaded, the first form assembly used by the form page is obtained through the form state control assembly, the first form assembly comprises multiple states, the multiple states correspond to the code sets respectively, the state switching instruction for switching the first form assembly from the first state to the second state is received, and the code set corresponding to the second state is used for replacing the code set corresponding to the first state in the page codes of the form page through the form state control assembly. In the running process of the page code, when the state of the first form component needs to be switched, the form state control component replaces code sets in different states, the page code of one form page is written, the form page can be reused in multiple states, the function of randomly switching the page state of the form is achieved through state switching of the first form component, and the cost for writing the form page is greatly reduced.
Example two
Referring to fig. 5, a specific flowchart of a form component state switching method according to an embodiment of the present application is shown, which specifically includes the following steps:
step 501, obtaining an original second form component in an original form component library.
In the embodiment of the application, the original second form components are obtained from the original form component library, all the original second form components in all the original form component libraries may be obtained, or required original second form components may be obtained from the corresponding original form component library according to the requirement of the form page.
The original form component library comprises an anti open source form component library, an open source amazeui form component library, an open source rc-component form component library, an open source RSUITE form component library and the like, standards in the original form component libraries are different, the number of original second form components in each original form component library is small, and if only original second form elements in one original form component library are obtained, the requirement of a form page is difficult to meet.
Optionally, step 501 may include sub-steps 5011 and 5012.
And a substep 5011 of obtaining a preset form component name and a corresponding original form component library name according to the page code.
Substep 5012, obtaining a second form component corresponding to the form component name from the original form component library corresponding to the original form component library name.
The method comprises the steps of obtaining preset form component names and corresponding original form component library names according to page codes in form pages, searching corresponding original form component libraries according to the original form component library names, and obtaining corresponding second form components from the original form component libraries according to the form component names.
For example, the name of the obtained original form component library is antd, the name of the obtained form component is input, and the corresponding second form component input can be obtained from the antd open source form component library.
502, carrying out standardization processing on the second form component to obtain an adaptation layer; the adaptation layer includes a normalized first form component corresponding to the second form component.
In the embodiment of the present application, the second form component is normalized to obtain the adaptation layer, and the required second form component may be normalized only according to the page code in the form page, or all the original second form components in all the original form component libraries may be normalized.
The original second form components in the anti open source form component library, the open source amazeui form component library, the open source rc-component form component library and the open source RSUITE form component library only have editing states generally, the original second form components are subjected to normalized processing to obtain an adaptation layer, the adaptation layer comprises normalized first form components corresponding to the second form components, and the first form components in the adaptation layer comprise multiple states, such as editing states, preview states, forbidden states, loading states, hidden states and the like.
Through the writing adaptation layer, different form pages can be written according to a plurality of form components in each form component library.
Optionally, step 502 may include sub-step 5021.
Substep 5021, adding a packaging layer using the same processing function to the second form component, setting a code set with multiple states in the packaging layer, and obtaining the first form component corresponding to the second form component to construct the adaptation layer.
In this step, an encapsulation layer using the same processing function is added to the original second form component, a code set in multiple states, such as a code set in an edit state, a preview state, a disable state, a load state, a hidden state, etc., is set in the encapsulation layer, and the first form component after the encapsulation processing of the original second form component is obtained to construct an adaptation layer.
For example, for an ant open source form component library, a corresponding adaptation layer is written according to an original second form component in the ant open source form component library.
Firstly, acquiring original second form components < input > and < select > from an antd open source form component library, and carrying out normalized processing on the < input > and the < select >, for example, repackaging each original second form component according to a specified format, and writing various states for the second form components in the repackaging process.
And then, after all the original second form components in all the form component libraries are subjected to standardization processing, a code set with multiple states can be obtained to construct an adaptation layer.
Step 503, load form status control component.
This step can refer to step 401, which is not described herein again.
Step 504, after the page code of the form page is obtained from the application server, the form state control component scans the preset form tag in the page code, and determines the name of the form component.
In the embodiment of the application, after the page code of the form page is acquired from the application server, the form state control component scans a preset form tag in the page code, mainly scans the form tag in the view layer code, and determines the name of the form component after the form tag is scanned, wherein the page code comprises the view layer code, and the view layer code refers to the form component part in the page code.
Wherein the view layer code is determined by the Form tag < Form >. The Form tag < Form > can be scanned by the Form state control component core, and the Form component names in the view layer code, such as input1, select1, input2, and select2, can be determined from the Form tag < Form >.
And 505, acquiring a corresponding first form component from the adaptation layer according to the form component name.
In the embodiment of the application, the adaptation layer of the corresponding original form component library is accessed according to the determined form component name, the first form component is obtained in the corresponding adaptation layer, and different original form libraries correspond to one adaptation layer, so that the management is convenient, and the adaptation layers of the original form libraries are logically decoupled.
For example, the form component names include input1, select1, input2 and select2, input1 is an input form component of the ant open source form component library, select1 is a select form component of the ant open source form component library, an adaptation layer of the ant open source form component library is accessed, and a corresponding first form component input1 and select1 are obtained from the adaptation layer of the ant open source form component library; input2 is an input form component of the open source amazeui form component library, select2 is a select form component of the open source amazeui form component library, access is made to an adaptation layer of the open source amazeui form component library, and corresponding first form components input2 and select2 are obtained from the adaptation layer of the open source amazeui form component library.
Of course, in the embodiment of the present application, an adaptation layer may also be constructed for all the original form component libraries, and then the corresponding first form component is obtained from the adaptation layer according to the form component name. The embodiments of the present application are not limited thereto.
Step 506, receiving a state switching instruction for switching the first form component from the first state to the second state.
This step can refer to step 403, which is not described herein again.
Step 507, replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page through the form state control component.
In the embodiment of the present application, after a state switching instruction for switching the first form component from the first state to the second state is received, the code set corresponding to the second state of the first form component is obtained through the form state control component core, and in the page code of the form page, the code set corresponding to the second state of the first form component is used to replace the code set corresponding to the first state of the first form component.
For example, when the first form component input1 is switched from the edit state to the preview state, the form state control component core acquires a code set corresponding to 'input 1' of the preview state 'preview' from an adaptation layer of the anti open source form component library by executing a state setting function core, setfieldstatus ('input 1', 'preview'), and replaces the code set corresponding to the input1 of the edit state in the page code with a code set corresponding to the input1 of the preview state; when the first form component select1 is switched from the editing state to the disabled state, the form state control component core acquires a code set corresponding to 'select 1' in the disabled state 'disable' from an adaptation layer of the anti open source form component library by executing a state setting function core, setFieldStatus ('select 1', 'disable'), and replaces the code set corresponding to the select1 in the editing state in the page code with the code set corresponding to the select1 in the disabled state; when the first form component input2 is switched from the editing state to the loading state, the form state control component core acquires a code set corresponding to ' input2 ' in the loading state ' from an adaptation layer of the open source amazeui form component library by executing a state setting function core, setfieldstatus (' input2 ', ' loading '), and replaces the code set corresponding to the input2 in the editing state in the page code with the code set corresponding to the input2 in the loading state. Certainly, the name of the state setting function core.
Optionally, step 507 may include sub-step 5071.
And when the triggering operation of the specified control is received in the form page, replacing a code set corresponding to a first state in the view layer codes of the page codes by using a code set corresponding to a second state through the form state control assembly according to the second state of the first form assembly required by the switched form page.
In this step, when a trigger operation for a designated control is received in the form page, a code set corresponding to the second state of the first form component is acquired from the adaptation layer through the form state control component core according to the second state of the first form component required by the switched form page, and the code set corresponding to the first state of the first form component in the view layer code of the page code is replaced with the code set corresponding to the second state of the first form component.
In one embodiment of the application, when the form value is received by the first form component in the edit state, the form value is recorded in the form state control component; the form value is shared by multiple states of the first form component; when the first form component is switched to other states from the editing state, the form state control component fills the recorded form values into the code sets corresponding to the other states, and replaces the code sets corresponding to the editing state in the view layer codes of the page codes by using the code sets filled with the form values.
The form value refers to a character input by a user in the first form component when the form page is in an editing state, for example, when a user name needs to be input in the first form component, an < input > form component can be selected, and if the type is a text box txet, the input form value is "username"; when a password needs to be input in the first form component, an < input > form component can be selected, the type is a password box passboard, the input form value is 'passboard', and the input text is displayed in the form of an origin or an asterisk.
When the form page is in an editing state, the first form component records the form value into the form state control component core after receiving the form value, when the first form component is switched from the editing state to other states, the form state control component core fills the recorded form value into a code set corresponding to other states, and meanwhile, a code set corresponding to the editing state in the view layer code of the page code is replaced by a code set corresponding to other states filled with the form value.
When a form page is newly created, the default state of a first form component of a form state control component is an editing state, when the form page needs to be edited, the first state of the first form component is the editing state, only corresponding form values are filled in a code set of the first form component, when the first form component needs to be switched from the editing state to a preview state, a code set corresponding to the preview state of the first form component is obtained, the code set of the editing state of the first form component in page codes of the form page is replaced by the code set corresponding to the preview state, and corresponding form values are filled in the code set corresponding to the first form component in the preview state.
For example, when a commodity is purchased in Taobao, an order can be newly created, at this time, an order page is in an editing state, form values, such as the number of the commodity, a receiving address, a contact name, a contact phone number and the like, are filled in a first form component of the order page, the order is submitted after filling, at this time, a trigger operation of a designated control is triggered, the state of the first form component is switched from the editing state to a preview state, at this time, the first form component in the preview state is replaced by the first form component in the editing state through a form state control component core, and at the same time, the form values are filled in a code set corresponding to the first form component in the preview state.
Optionally, step 507 may further include sub-step 5072 and sub-step 5073.
In sub-step 5072, when all the first form components are switched from the first state to the second state, a global state switching function is called, and the code set corresponding to the second state of each first form component is used to replace the code set corresponding to the first state in the view layer code of the page code.
In this step, when all the first form components in the form page are switched from the first state to the second state, a global state switching function core. Note that, the name of the global state switching function core.
For example, when all first form components in the form page are switched from the preview state to the edit state, including the first form components a1, a2 and A3, the form state control component calls core.
Sub-step 5073, when a part of the first form components are switched from the first state to the second state, calling a local state switching function for each first form component, and replacing a code set corresponding to the first state in the view layer codes of the page codes with a code set corresponding to the second state of the first form component.
In this step, when only part of the first form components in the form page need to be subjected to state switching, for the first form components needing to be subjected to state switching, the form state control component respectively calls a local state switching function core. Note that, the name of the local state switching function core.
The state switching of the form page can be realized based on the state switching of part of the first form components or all the first form components in the form page, when a user accesses a newly created, edited and previewed detail page, a form page is actually accessed, but the form page can be subjected to state switching through a form state control component core, so that the form page has multiple states.
According to the method and the device, only one form page needs to be written, and when a certain field in the form page needs to be modified, only one form page needs to be modified, so that the labor cost for modification is reduced.
The embodiment of the application carries out standardization processing on an original second form component in an original form component library to obtain an adaptation layer, a required first form component is obtained from the adaptation layer through a form state control component, when the state of the first form component needs to be switched, code set replacement of different states is carried out through the form state control component, the page code of a form page can be compiled, the form page can be used in multiple states repeatedly, the state switching through the first form component is realized, the function of randomly switching the page state of the form page is achieved, the cost for compiling the form page is greatly reduced, and meanwhile, the form page can be suitable for multiple form component libraries.
EXAMPLE III
Referring to fig. 6, a flowchart of another form component state switching method according to the embodiment of the present application is shown, which specifically includes the following steps:
step 601, respectively loading form state control components corresponding to a plurality of form tags in a form page, and binding each form state control component with a corresponding form tag.
In the embodiment of the application, a plurality of form tags can be included in one form page, and one form tag corresponds to one form state control component.
The method comprises the steps of obtaining a page code of a form page from an application server, loading the page code, loading form state control components corresponding to a plurality of form tags in the form page respectively while loading the page code, and binding each form state control component with the corresponding form tag.
For example, one form page includes 3 form tags, which are respectively form tag 1, form tag 2, and form tag 3, where the form state control component bound to form tag 1 is core1, the form state control component bound to form tag 2 is core2, and the form state control component bound to form tag 3 is core 3.
Step 602, obtaining a first form component in the form label bound with the form state control component through the form state control component.
In the embodiment of the application, the form state control component acquires the first form component in the form label bound with the form state control component, and the number of the first form component in the form label may be one or multiple.
For example, the form state control component core1 is used to obtain the first form components A11 and A12 in the form tag 1, the form state control component core2 is used to obtain the first form components A21, A22 and A23 in the form tag 2, and the form state control component core3 is used to obtain the first form component A31 in the form tag 3.
Step 603, receiving a state switching instruction for switching the first form component from the first state to the second state.
In the embodiment of the invention, in the running process of the form page, a state switching instruction for switching the first form component from the first state to the second state is received.
For example, a state switch instruction is received for the first form component A11.
Step 604, replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page through the form state control component corresponding to the first form component.
In the embodiment of the present invention, after a state switching instruction for switching the first form component from the first state to the second state is received, a code set corresponding to the second state of the first form component is acquired through the form state control component corresponding to the first form component, and the code set corresponding to the first state of the first form component is replaced with the code set corresponding to the second state of the first form component.
For example, after receiving the state switching instruction for the first form component a11, the form state control component core1 is used to obtain the code set corresponding to the second state of the first form component a11, and the code set corresponding to the first state of the first form component a11 is replaced with the code set corresponding to the second state of the first form component a11
The method includes the steps that aiming at a form page including a plurality of form labels, form state control components corresponding to the form labels in the form page are loaded respectively, each form state control component is bound with the corresponding form label, a first form component in the form labels bound with the form state control components is obtained through the form state control components, a state switching instruction for switching the first form component from a first state to a second state is received, and a code set corresponding to the second state is used in a page code of the form page to replace the code set corresponding to the first state through the form state control component corresponding to the first form component. In the running process of the page code, when the state of the first form component needs to be switched, the form state control component is used for carrying out code replacement in different states, the writing of a form page code is realized, the form page code can be reused in various states, the function of randomly switching the form page state is achieved through the state switching of the first form component, and the cost for writing the form page is greatly reduced.
Example four
Referring to fig. 7, a block diagram of a form component state switching apparatus according to an embodiment of the present application is shown, where the apparatus 700 may specifically include the following modules:
and the loading module 701 is used for loading the form state control component.
A first form component obtaining module 702, configured to obtain, through the form state control component, a first form component used by a form page; the first form component comprises a plurality of states, and the states respectively correspond to a code set.
The instruction receiving module 703 is configured to receive a state switching instruction for switching the first form component from the first state to the second state.
A replacing module 704, configured to replace, by the form state control component, the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page.
Optionally, the apparatus 700 further includes:
the second form component acquisition module is used for acquiring an original second form component in the original form component library;
the standardization processing module is used for carrying out standardization processing on the second form component to obtain an adaptation layer; the adaptation layer includes a normalized first form component corresponding to the second form component.
Optionally, the normalization processing module includes:
and the packaging layer adding submodule is used for adding a packaging layer using the same processing function to the second form component, setting a code set with multiple states in the packaging layer, and acquiring the first form component corresponding to the second form component to construct the adaptation layer.
Optionally, the second form component obtaining module includes:
the name acquisition submodule is used for acquiring a preset form component name and a corresponding original form component library name according to the page code;
and the second form component acquisition sub-module is used for acquiring a second form component corresponding to the form component name from the original form component library corresponding to the original form component library name.
Optionally, the first form component obtaining module 702 includes:
the form label scanning sub-module is used for scanning a preset form label in a page code through the form state control component after the page code of a form page is obtained from an application server, and determining the name of a form component;
and the first obtaining submodule of the first form component is used for obtaining the corresponding first form component from the adaptation layer according to the form component name.
Optionally, the state switching instruction includes: when the triggering operation of the designated control is received in the form page, the business logic of the form page automatically executes at least one of the nodes reaching the state switching logic.
Optionally, when a trigger operation on a specified control is received in the form page, the replacing module 704 includes:
and the code set first replacing submodule is used for replacing the code set corresponding to the first state in the view layer codes of the page codes by using the code set corresponding to the second state according to the second state of the first form component required by the switched form page through the form state control component.
Optionally, the apparatus 700 further includes:
the recording module is used for recording the form value into the form state control component when the first form component receives the form value in the editing state; the form value is shared by multiple states of the first form component.
Optionally, the replacing module 704 includes:
and the form value filling sub-module is used for filling the recorded form values into the code sets corresponding to other states through the form state control component when the first form component is switched from the editing state to other states, and replacing the code sets corresponding to the editing state in the view layer codes of the page codes by using the code sets filled with the form values.
Optionally, the replacing module 704 includes:
the global replacement submodule is used for calling a global state switching function when all the first form components are switched from a first state to a second state, and replacing a code set corresponding to the first state in the view layer codes of the page codes by using a code set corresponding to the second state of each first form component;
and the first form component replacing submodule is used for calling a local state switching function for each first form component when a part of the first form components are switched from a first state to a second state, and replacing a code set corresponding to the first state in the view layer codes of the page codes by using a code set corresponding to the second state of the first form components.
Optionally, the loading module 701 includes:
and the loading submodule is used for respectively loading the form state control components corresponding to the plurality of form tags in the form page and binding each form state control component with the corresponding form tag.
Optionally, the first form component obtaining module 702 includes:
and the first form component second acquisition submodule is used for acquiring a first form component in the form label bound with the form state control component through the form state control component.
Optionally, the replacing module 704 includes:
and the second code set replacing submodule is used for replacing the code set corresponding to the first state by using the code set corresponding to the second state in the page code of the form page through the form state control component corresponding to the first form component.
Optionally, the status includes: at least one of an edit state, a preview state, a disable state, a load state, and a hide state.
According to the embodiment of the application, the form state control assembly is loaded, the first form assembly used by the form page is obtained through the form state control assembly, the first form assembly comprises multiple states, the multiple states correspond to the code sets respectively, the state switching instruction for switching the first form assembly from the first state to the second state is received, and the code set corresponding to the second state is used for replacing the code set corresponding to the first state in the page codes of the form page through the form state control assembly. In the running process of the page code, when the state of the first form component needs to be switched, the form state control component replaces code sets in different states, the page code of one form page is written, the form page can be reused in multiple states, the function of randomly switching the page state of the form is achieved through state switching of the first form component, and the cost for writing the form page is greatly reduced.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
Fig. 8 is a schematic structural diagram of a client according to an embodiment of the present application. Referring to fig. 8, a client 800 may be used to implement the form component state switching method provided in the first embodiment, the second embodiment, and the third embodiment. The client 800 may vary significantly depending on configuration or performance, and may include one or more Central Processing Units (CPUs) 822 (e.g., one or more processors) and memory 832, one or more storage media 830 (e.g., one or more mass storage devices) storing applications 842 or data 844. Memory 832 and storage medium 830 may be transitory or persistent, among other things. The program stored in the storage medium 830 may include one or more modules (not shown), each of which may include a series of instruction operations for the server. Still further, central processor 822 may be configured to communicate with storage medium 830 and execute a series of instruction operations in storage medium 830 on client 800.
Client 800 may also include one or more power supplies 826, one or more wired or wireless network interfaces 850, one or more input-output interfaces 858, one or more keyboards 856, and/or one or more operating systems 841, such as Windows Server, Mac OS XTM, UnixTM, Linux, FreeBSDTM, etc. Central processor 822 may execute instructions on client 800 to:
loading a form state control component;
acquiring a first form component used by a form page through the form state control component; the first form component comprises a plurality of states, and the states respectively correspond to a code set;
receiving a state switching instruction for switching the first form component from a first state to a second state;
and replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page through the form state control component.
An apparatus, one or more machine-readable media having instructions stored thereon, which when executed by the one or more processors, cause the apparatus to perform a form component state switching method.
The present application also provides one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a form component state switching method.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one of skill in the art, embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method and the device for switching the form component states provided by the application are introduced in detail, a specific example is applied in the method to explain the principle and the implementation mode of the application, and the description of the embodiment is only used for helping to understand the method and the core idea of the application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (30)

1. A form component state switching method is characterized by comprising the following steps:
loading a form state control component;
acquiring a first form component used by a form page through the form state control component; the first form component comprises a plurality of states, and the states respectively correspond to a code set;
receiving a state switching instruction for switching the first form component from a first state to a second state;
and replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page through the form state control component.
2. The method of claim 1, further comprising:
acquiring an original second form component in an original form component library;
carrying out standardization processing on the second form component to obtain an adaptation layer; the adaptation layer includes a normalized first form component corresponding to the second form component.
3. The method of claim 2, wherein the step of normalizing the second form component to obtain an adaptation layer comprises:
and adding an encapsulation layer using the same processing function to the second form component, setting a code set with multiple states in the encapsulation layer, and acquiring the first form component corresponding to the second form component to construct the adaptation layer.
4. The method of claim 2, wherein the step of obtaining an original second form component in an original form component library comprises:
acquiring a preset form component name and a corresponding original form component library name according to the page code;
and acquiring a second form component corresponding to the form component name from an original form component library corresponding to the original form component library name.
5. The method of claim 2, wherein the step of obtaining the first form component used by the form page via the form state control component comprises:
after a page code of a form page is acquired from an application server, scanning a preset form label in the page code through the form state control component, and determining a form component name;
and acquiring a corresponding first form component from the adaptation layer according to the form component name.
6. The method of claim 1, wherein the state switching instruction comprises: when the triggering operation of the designated control is received in the form page, the business logic of the form page automatically executes at least one of the nodes reaching the state switching logic.
7. The method according to claim 6, wherein the step of receiving a trigger operation for a specified control in the form page, and replacing, by the form state control component, the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page comprises:
and replacing a code set corresponding to the first state in the view layer codes of the page codes by using the code set corresponding to the second state according to the second state of the first form component required by the switched form page through the form state control component.
8. The method of claim 1, further comprising:
when the first form component receives a form value in an editing state, recording the form value into a form state control component; the form value is shared by multiple states of the first form component.
9. The method according to claim 8, wherein the step of replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page by the form state control component comprises:
when the first form component is switched to other states from the editing state, the form state control component fills the recorded form values into the code sets corresponding to the other states, and replaces the code sets corresponding to the editing state in the view layer codes of the page codes by using the code sets filled with the form values.
10. The method according to claim 6, wherein the step of replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page by the form state control component comprises:
when all the first form components are switched from a first state to a second state, a global state switching function is called, and a code set corresponding to the first state in the view layer codes of the page codes is replaced by a code set corresponding to the second state of each first form component;
when a part of first form components are switched to a second state from a first state, a local state switching function is called for each first form component, and a code set corresponding to the second state of the first form component is used for replacing a code set corresponding to the first state in the view layer codes of the page codes.
11. The method of claim 1, wherein the step of loading the form state control component comprises:
and respectively loading form state control components corresponding to a plurality of form labels in the form page, and binding each form state control component with the corresponding form label.
12. The method of claim 11, wherein the step of obtaining a first form component used by the form state control component to access the form page comprises:
and acquiring a first form component in the form label bound with the form state control component through the form state control component.
13. The method according to claim 12, wherein the step of replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page by the form state control component comprises:
and replacing the code set corresponding to the first state with the code set corresponding to the second state in the page code of the form page through the form state control component corresponding to the first form component.
14. The method of claim 1, wherein the state comprises: at least one of an edit state, a preview state, a disable state, a load state, and a hide state.
15. A form component state switching apparatus, comprising:
the loading module is used for loading the form state control component;
the first form component acquisition module is used for acquiring a first form component used by a form page through the form state control component; the first form component comprises a plurality of states, and the states respectively correspond to a code set;
the instruction receiving module is used for receiving a state switching instruction for switching the first form component from a first state to a second state;
and the replacing module is used for replacing the code set corresponding to the first state by using the code set corresponding to the second state in the page code of the form page through the form state control component.
16. The apparatus of claim 15, further comprising:
the second form component acquisition module is used for acquiring an original second form component in the original form component library;
the standardization processing module is used for carrying out standardization processing on the second form component to obtain an adaptation layer; the adaptation layer includes a normalized first form component corresponding to the second form component.
17. The apparatus of claim 16, wherein the normalization processing module comprises:
and the packaging layer adding submodule is used for adding a packaging layer using the same processing function to the second form component, setting a code set with multiple states in the packaging layer, and acquiring the first form component corresponding to the second form component to construct the adaptation layer.
18. The apparatus of claim 16, wherein the second form component acquisition module comprises:
the name acquisition submodule is used for acquiring a preset form component name and a corresponding original form component library name according to the page code;
and the second form component acquisition sub-module is used for acquiring a second form component corresponding to the form component name from the original form component library corresponding to the original form component library name.
19. The apparatus of claim 16, wherein the first form component acquisition module comprises:
the form label scanning sub-module is used for scanning a preset form label in a page code through the form state control component after the page code of a form page is obtained from an application server, and determining the name of a form component;
and the first obtaining submodule of the first form component is used for obtaining the corresponding first form component from the adaptation layer according to the form component name.
20. The apparatus of claim 15, wherein the state switching instruction comprises: when the triggering operation of the designated control is received in the form page, the business logic of the form page automatically executes at least one of the nodes reaching the state switching logic.
21. The apparatus of claim 20, wherein when a trigger operation for a specified control is received in the form page, the replacement module comprises:
and the code set first replacing submodule is used for replacing the code set corresponding to the first state in the view layer codes of the page codes by using the code set corresponding to the second state according to the second state of the first form component required by the switched form page through the form state control component.
22. The apparatus of claim 15, further comprising:
the recording module is used for recording the form value into the form state control component when the first form component receives the form value in the editing state; the form value is shared by multiple states of the first form component.
23. The apparatus of claim 22, wherein the replacement module comprises:
and the form value filling sub-module is used for filling the recorded form values into the code sets corresponding to other states through the form state control component when the first form component is switched from the editing state to other states, and replacing the code sets corresponding to the editing state in the view layer codes of the page codes by using the code sets filled with the form values.
24. The apparatus of claim 20, wherein the replacement module comprises:
the global replacement submodule is used for calling a global state switching function when all the first form components are switched from a first state to a second state, and replacing a code set corresponding to the first state in the view layer codes of the page codes by using a code set corresponding to the second state of each first form component;
and the first form component replacing submodule is used for calling a local state switching function for each first form component when a part of the first form components are switched from a first state to a second state, and replacing a code set corresponding to the first state in the view layer codes of the page codes by using a code set corresponding to the second state of the first form components.
25. The apparatus of claim 15, wherein the load module comprises:
and the loading submodule is used for respectively loading the form state control components corresponding to the plurality of form tags in the form page and binding each form state control component with the corresponding form tag.
26. The apparatus of claim 25, wherein the first form component acquisition module comprises:
and the first form component second acquisition submodule is used for acquiring a first form component in the form label bound with the form state control component through the form state control component.
27. The apparatus of claim 26, wherein the replacement module comprises:
and the second code set replacing submodule is used for replacing the code set corresponding to the first state by using the code set corresponding to the second state in the page code of the form page through the form state control component corresponding to the first form component.
28. The apparatus of claim 15, wherein the state comprises: at least one of an edit state, a preview state, a disable state, a load state, and a hide state.
29. An apparatus, comprising:
one or more processors; and
one or more machine-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of one or more of claims 1-14.
30. One or more machine-readable media having instructions stored thereon that, when executed by one or more processors, perform a method as recited in one or more of claims 1-14.
HK42020005748.7A2020-04-14Form component state switching method and deviceHK40016164B (en)

Publications (2)

Publication NumberPublication Date
HK40016164Atrue HK40016164A (en)2020-09-11
HK40016164B HK40016164B (en)2024-05-24

Family

ID=

Similar Documents

PublicationPublication DateTitle
CN106569783B (en)Method and device for executing task script
CN109614158B (en)Plug-in calling method, system, storage medium and processor
US11262883B2 (en)Associating browser with application
CN110362305B (en)Form component state switching method and device
CN114398073B (en)Application updating method and device based on RN
WO2023092580A1 (en)Page display method and apparatus, storage medium, and electronic device
CN112199200B (en)Resource scheduling method and device, computer equipment and storage medium
CN115712794A (en)Page management method and device, processor and electronic equipment
CN111381745B (en)Page switching method, device and equipment
CN112256696A (en)Form data processing method, device, equipment and storage medium
CN112087370A (en)Method, system, electronic device and computer-readable storage medium for issuing GitHub Issues
CN114254232B (en) Cloud product page generation method, device, computer equipment and storage medium
CN118132166B (en)Application server class loading resource isolation processing method, device, equipment and medium
HK40016164A (en)Form component state switching method and device
CN117742767A (en)Service characteristic management method, device, equipment and storage medium
CN117633382A (en)Page loading method and device, electronic equipment and computer readable medium
WO2020135129A1 (en)Method and device for loading plug-in of application, and terminal
CN118034717A (en)Page configuration method and device of micro front-end system and computer equipment
CN110377813A (en)A kind of selenium supports method, electronic equipment and the medium of customized request header
CN116048501A (en)Method, processor, device and storage medium for adjusting webpage layout
CN116204226A (en)Application development system, method, device and storage medium
CN107180107B (en)Method and system for uploading selected files by mobile phone attachment under Ionic framework
SubramanianReact Router
US12423092B2 (en)System and method for classifying software code based on functionality and criticality
US20230222245A1 (en)Framework for exposing context-driven services within a web browser

[8]ページ先頭

©2009-2025 Movatter.jp