赞
踩
以下代码:
<div v-for="(item, index) in addForm.domains" :key="index"> <el-form-item label="联系人" :prop="'domains.' + index + '.contactss'" :rules="{ required: true, message: '联系人不能为空', trigger: 'blur' }" > <el-input v-model="item.contactss" style="width:300px" /> </el-form-item> <el-form-item label="试点名称" :prop="'domains.' + index + '.regionNames'" :rules="[ {required: true, message: '试点名称不能为空', trigger: 'blur'} ]" > <el-input v-model="item.regionNames" style="width:300px" /> </el-form-item> <el-form-item label="承试单位" :prop="'domains.' + index + '.undertakeOrgs'" :rules="[ {required: true, message: '承试单位不能为空', trigger: 'blur'} ]" > <el-input v-model="item.undertakeOrgs" style="width:300px" /> </el-form-item> <el-form-item label="试验情况" :prop="'domains.' + index + '.remarks'" :rules="[ {required: true, message: '试验情况不能为空', trigger: 'blur'} ]" > <el-input v-model="item.remarks" style="width:300px" /> </el-form-item> <el-form-item> <i class="el-icon-delete" @click="deleteItem(item, index)" /> </el-form-item> </div> <div class="text-center"> <el-button @click="addItem">新增试点</el-button> <el-button class="button" @click="handleAddcancel()">取消</el-button> <el-button class="button" type="primary" @click="handleAddsave()">保存</el-button> </div> domains: [{ contactss: '', regionNames: '', undertakeOrgs: '', remarks: '' }], addItem() { this.addForm.domains.push({ contactss: '', regionNames: '', undertakeOrgs: '', remarks: '' }) }, deleteItem(item, index) { if (this.addForm.domains.length !== 1) { this.addForm.domains.splice(index, 1) } else { Message({ message: '最少添加一个试点', type: 'warning', duration: 5 * 1000 }) } },
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。