|
@@ -97,7 +97,7 @@
|
|
|
<el-input v-model="item.name" autocomplete="off" />
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
- <div class="singO_right" ><el-button type="danger" @click="removeUnit(item.id)">删除</el-button></div>
|
|
|
+ <div class="singO_right" ><el-button type="danger" @click="removeUnit(item.id,index)">删除</el-button></div>
|
|
|
</div>
|
|
|
|
|
|
</el-form>
|
|
@@ -277,11 +277,12 @@ export default {
|
|
|
// const newId = Date.now();
|
|
|
this.unitNames.push({ id: '', name: '' }); // 每次添加单元时,为 unitNames 数组添加一个带有ID的对象
|
|
|
},
|
|
|
- removeUnit(id) {
|
|
|
- const index = this.unitNames.findIndex(item => item.id === id);
|
|
|
- if (index !== -1) {
|
|
|
- this.unitNames.splice(index, 1);
|
|
|
- }
|
|
|
+ removeUnit(id, chooseIndex) {
|
|
|
+ this.unitNames.splice(chooseIndex, 1)
|
|
|
+ // const index = this.unitNames.findIndex(item => item.id === id);
|
|
|
+ // if (index !== -1) {
|
|
|
+ // this.unitNames.splice(index, 1);
|
|
|
+ // }
|
|
|
},
|
|
|
submitForm() {
|
|
|
console.log('json', JSON.stringify(this.unitNames));
|