<el-row
class="textarea_top"
v-for="(item, i) in trcList"
:key="item.Code + i"
>
<el-col :span="20">
<el-form-item
:label="item.Code + ':'"
label-width="100px"
>
<el-input
type="textarea"
:rows="2"
:disabled="isData"
resize="none"
v-model="item.Value"
autocomplete="off"
></el-input>
</el-form-item>
</el-col>
<template v-if="isData == false">
<el-col
:span="2"
class="pointer div_line_height div_padding"
>
<el-button size="mini" type="success" icon="el-icon-plus" plain @click="addTrc('trc', i)"></el-button>
</el-col>
<el-col :span="2" class="pointer div_line_height">
<el-button size="mini" type="primary" icon="el-icon-minus" plain @click="delTrc('trc', i)"></el-button>
</el-col>
</template>
</el-row>
</div>
data() {
return {
trcList: [{ Code: "RC1", Value: "", Type: 31 }],
}
},
methods: {
addTrc(type, i) {
if (type === "trc") {
this.trcList.splice(i + 1, 0, {
Code: `RC${this.trcList.length + 1}`,
Value: null,
Type: 31
});
}
},
delTrc(type, i) {
if (type === "trc") {
if (this.trcList.length === 1) {
return;
}
this.trcList.splice(i, 1);
let arr = [];
for (let i = 0; i < this.trcList.length; i++) {
let newArr = {
Code: `RC${i + 1}`,
Value: this.trcList[i].Value,
Type: this.trcList[i].Type
};
arr.push(newArr);
}
this.trcList = arr;
}
},
}