D
D
Diper2020-03-04 05:16:00
JavaScript
Diper, 2020-03-04 05:16:00

How to transfer the received data from the form from the user to the server?

I have a conditional vuetify form in which I receive data from the server (axios), sort it and drop it into its own combobox. The user makes his selection or fills in something on his own and presses the button. I need to transfer this data through axios. I do everything in vue.js.

The question is how to transfer data from the vuetify form to the server (axios) in the correct form for it. Below is a hypothetical example.

One of the fields:

<v-card-text>
          <v-container>
             <v-row>
                <v-col cols="12" sm="5" md="6">
                  <v-autocomplete
                   v-model="sortCust[0]"
                   :items="sortCust"
                    label="отправитель"
                    multiple
                    hint=""
                    ></v-autocomplete>
             </v-col>
          </v-container>
        </v-card-text>


From these forms, I need to extract everything in the following format and transfer it, as I understand it, through a separate axios request. Below is an example request.

"request_type": "setG";
"request": {
  "request_type": "setG,
  "request": {
    "owner": "lsa", 
    "desc": "Новый", 
    "type": "TRANS",
    "cfg": {
      "count": 66, 
      "accept": true, 
      "amount": {
        "currency": "R",
        "min": 666, 
        "max": 777
      },
      "send": {
        "ba": {
          "Ag": {
            "type": "Oth,
            "value": "123",
            "name": "Промо,
            "currency": "RU,
            "addr": { "country": "RU" }
          },
          "Ac": {
            "type": "Oth",
            "value": "789789"
          },
          "AgAc": {
            "type": "Oth",
            "value": "555555"
          }				
        },
        "client": {
          "name": "Промо",
          "Ac": {
            "type": "Oth",
            "value": "777777777"
          }		
        }
      },
      "recip": {
        "ba": {
          "Agt": {
            "type": "Othr",
            "value": "6786778",
            "name": "Промо,
            "currency": "RU",
            "addr": { "country": "RU" }
          },
          "Ac": {
            "type": "Othr",
            "value": "345878"
          },
          "AgAc": {
            "type": "Othr",
            "value": "345346786"
          }				
        },
        "client": {
          "name": "Промо",
          "Ac": {
            "type": "Oth",
            "value": "234200"
          }		
        }
      }
    }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-03-04
@Lkj

create a stub object in the function and let it return something like

// структура опущена
var req = { request: {}}

Further change only the changed fields. After filling in all the values, send in the standard way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question