前端对象添加进数组里会触发页面的v-modle

vue+elementui 前端问题
对象写好了填充到数组里,数组里的信息会跟页面上的对象同步,说不清看图吧

img


            <el-table :data="documentsData" border style="width: 100%;margin-top: 20px;">
                <el-table-column prop="documentNumber" label="单据号" width="200">
                </el-table-column>
                <el-table-column prop="treatmentHospital" label="医院名称" width="250">
                </el-table-column>
                <el-table-column prop="startDate" label="开始日期" width="250">
                </el-table-column>
                <el-table-column prop="endDate" label="结束日期" width="250">
                </el-table-column>
                <el-table-column prop="assembleDays" label="总天数" width="200">
                </el-table-column>
                <el-table-column prop="assembleMoney" label="总金额" width="200">
                </el-table-column>
                <el-table-column prop="right" label="操作" width="290">
                    <template slot-scope="scope">
                        <el-popconfirm title="确认删除吗?" @confirm="demo(scope.row.documentNumber)">
                            <el-button slot="reference" type="danger" size="small" icon="el-icon-delete"
                                style="margin-left: 60px;">删除
                            </el-button>
                        </el-popconfirm>
                    </template>

                </el-table-column>
            </el-table>
            <el-button @click="onSubmit">新增</el-button>
        </div>
        <el-form :model="documents" ref="documents" :rules="rules">
            <el-descriptions v-model="documents" class="margin-top" :column="4" :size="size" border>

                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-user"></i>
                        <span>单据号</span>
                    </template>
                    <el-form-item prop="documentNumber">
                        <el-input v-model="documents.documentNumber"></el-input>
                    </el-form-item>
                </el-descriptions-item>


                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-mobile-phone"></i>
                        <span>医院名称</span>
                    </template>
                    <el-form-item prop="treatmentHospital">
                        <el-input v-model="documents.treatmentHospital"></el-input>
                    </el-form-item>
                </el-descriptions-item>


                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-location-outline"></i>
                        <span>开始日期</span>
                    </template>
                    <el-form-item prop="startDate">
                        <el-date-picker v-model="documents.startDate" type="date" placeholder="选择日期" @change="zhuYuan"
                            style="width: 254px;" value-format="yyyy-MM-dd">
                        </el-date-picker>
                    </el-form-item>
                </el-descriptions-item>


                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-tickets"></i>
                        <span>结束日期</span>
                    </template>
                    <el-form-item prop="endDate">
                        <el-date-picker v-model="documents.endDate" type="date" placeholder="选择日期" style="width: 254px;"
                            @change="zhuYuan" value-format="yyyy-MM-dd">
                        </el-date-picker>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-office-building"></i>
                        <span>天数</span>
                    </template>
                    <el-input v-model="documents.assembleDays" disabled></el-input>
                </el-descriptions-item>


                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-office-building"></i>
                        <span>距离意外事故发生天数</span>
                    </template>
                    <el-input v-model="documents.JLYWTS" disabled></el-input>
                </el-descriptions-item>


                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-office-building"></i>
                        <span>距离出险日期天数</span>
                    </template>
                    <el-input v-model="documents.JLCXTS" disabled></el-input>
                </el-descriptions-item>


                <el-descriptions-item>
                    <template slot="label">
                        <i class="el-icon-office-building"></i>
                        <span>金额合计</span>
                    </template>
                    <el-input v-model="documents.assembleMoney" disabled></el-input>
                </el-descriptions-item>



            </el-descriptions>
        </el-form>







    //表单验证
            async onSubmit() {
                const form1Valid = await this.$refs.documents.validate()
                const form2Valid = await this.$refs.cost.validate()
                if (form1Valid && form2Valid) {
                    var a = this.documents
                    this.documentsData.push(a)
                }
            },
            //删除
            demo(documentNumber) {
                this.documentsData = this.documentsData.filter((o) => {
                    return o.documentNumber !== documentNumber
                })

            },







documentsData: [],
                //报案信息表
                documents: {
                    documentsId: '', //单证录入Id
                    customerId: '', //客户Id
                    documentNumber: '', //单据号
                    startDate: '', //开始时间
                    endDate: '', //结束时间
                    treatmentHospital: '', //治疗医院
                    assembleDays: '', //总天数
                    assembleMoney: 0, //总金额
                    selfFunded: '', //客户自费

                    JLYWTS: '', //距离意外事故发生天数
                    JLCXTS: '', //距离出险日期天数
                },






深拷贝一下

async onSubmit() {
                const form1Valid = await this.$refs.documents.validate()
                const form2Valid = await this.$refs.cost.validate()
                if (form1Valid && form2Valid) {
                    var a = JSON.parse(JSON.stringify(this.documents))
                    this.documentsData.push(a)
                }
            },

找到问题了,新增的时候要换个对象新增

img