vue only dynamically generated by the return of form and submit background

In the crm system, the contents of the form and the content of the page form submission is not fixed, especially in uncertain form content; it is necessary to configure the background; the foreground according to the interface return; render, submit post-processing, so that vue problems occur; vue because the data is rendered after the first use; all data must be life out, it would have resulted in the issue;

Solution:

  1. request interface; rendering the background required to submit a form field when; first of all need to be rendered and submitted the form fields to traverse, and then stored in a data object, I wrote the object is subParams, so that you can All fields are required to submit to submit to subparams in the;

or(var ke in content[key]){
                        if(ke=='办理情况'){
                            this.subContent=content[key][ke];
                            for(var i=0;i<this.subContent.length;i++)
                            {
                                if(this.subContent[i].type=="2")
                                {
                                    var arr = this.subContent[i].value.split(',');
                                    var arr1 = [];
                                    var arr2 = [];
                                    var j=0;
                                    for(var key1 in arr)
                                    {
                                        if(arr[key1]!="")
                                        {
                                            arr1[j]=arr[key1];
                                            arr2[j] = arr[key1];
                                            j++;
                                        }
                                    }
                                    this.ordList[this.subContent[i].fd_name]=new Array(arr1);
                                    if(arr1.length<=1)
                                    {
                                        this.ordvalue[this.subContent[i].fd_name] = new Array(arr1[0]);
                                    }
                                    
                                }
                                else if(this.subContent[i].type=="3")
                                {
                                    var arr = this.subContent[i].value.split(',');
                                    var arr1 = [];
                                    var arr2 = [];
                                    var j=0;
                                    for(var key1 in arr)
                                    {
                                        if(arr[key1]!="")
                                        {
                                            arr1[j]=arr[key1];
                                            arr2[j] = arr[key1];
                                            j++;
                                        }
                                    }
                                    this.ordList[this.subContent[i].fd_name]=new Array(arr1);
                                }
                                else
                                {
                                    this.subParms[this.subContent[i].fd_name]=this.subContent[i].value;
                                }
                                
                            }

In this case can be bound; then requested to render, the corresponding form elements rendered into the corresponding lower too, v-model dynamically bound to a value of subParms in; when finally submitted to subParms as an object to submit up on the line ;

Guess you like

Origin www.cnblogs.com/mrxinxin/p/11527618.html