How does a form form in vue receive data and return it to the backend at the same time

clipboard.png
is similar to such a form. The product name and product model in the first row need to be fetched from the backend, but all the data filled in the table should be returned to the backend interface. How to bind the value in el-from.

suppose the code looks like this

the first part is the layout code

    <el-form :model="list" label-width="90px" class="form_border">
        <el-form-item label="">
          <el-input v-model="list.Name"></el-input>
        </el-form-item>
     
      
        <el-form-item label="">
          <el-input v-model="list.Spec"></el-input>
        </el-form-item>
      
        <el-form-item label="">
          <el-input v-model="list.Num></el-input>
        </el-form-item>
      
        <el-form-item label="">
          <el-date-picker v-model="list.Date" type="date" placeholder="">
          </el-date-picker>
        </el-form-item>
    </el-form>

the second part is the js code

data() {
  return {
    list: null,
    updata:{
        Name:undefind,
        Spec:undefind,
        Num:undefind,
        Date:undefind,
    },
  }
  
//
update(item) {
  const param = {
    Name: this.updata.Name,
    Spec: this.updata.Spec,
    Num: this.updata.Num,
    Date: this.updata.Date,
  };
  api.updataInfo(param).then(response => {
    if (response.data.Success) {
      this.$notify({
        title: "",
        message: "",
        type: "success",
        duration: 2000
      });
    } else {
      this.$notify({
        title: "",
        message: response.data.Message,
        type: "error",
        duration: 2000
      });
    }
  });
},

//
getDInfo(){
    const param = {
      id: this.recordPKID
    };
    api.getdinfo(param).then(response => {
      const data = response.data;
      this.list= data;
    });
  },

would like to ask the bosses < el-form >: how to bind the value behind model, because I don"t know much about it soon after I have just come into contact, so I want to ask how and how to do it. If the expression is clearer than that, you can leave a message and ask me, thank you!


I don't quite understand what you're going to do. Do you have any questions now?

you can tie it up fine.


it's better to use the same variables at the front end, and it's best not to separate them. If the content is different, you can copy the data when the event is triggered, but in principle maintain an one-to-one relationship between the content displayed at the front end and the variables of vue. One-to-many bindings certainly don't do this.

Menu