当前位置:网站首页>El table implements adding / deleting rows, and a parameter changes accordingly
El table implements adding / deleting rows, and a parameter changes accordingly
2022-07-26 09:52:00 【Zhou Xiaotiao】
Effect display :


When deleting or adding rows in the middle , The content of the leftmost step will also change .
Code display :
First ,html Medium el-table Code :
<el-table-self :data="setList" style="width: 100%" max-height="250">
<el-table-column align="center" prop="orderNum" label=" step " width="80">
<template slot-scope="scope">
<span> The first {
{
scope.row.orderNum}} Step </span>
</template>
</el-table-column>
<el-table-column align="center" prop="type" label=" type ">
<template slot-scope="scope">
<el-select
size="small"
v-model="scope.row.type" placeholder=" Please select ">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" prop="realname" label=" Approve users ">
<template slot-scope="scope">
<el-select
size="small"
:disabled="scope.row.type!=='1'"
v-model="scope.row.userId"
placeholder=" Please select ">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.realname"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" prop="roleName" label=" Approval role ">
<template slot-scope="scope">
<el-select
size="small"
:disabled="scope.row.type!=='2'"
v-model="scope.row.roleId"
placeholder=" Please select ">
<el-option
v-for="item in roleList"
:key="item.id"
:label="item.roleName"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="flowCode" label=" Process code " ></el-table-column>
<el-table-column fixed="right" align="center" label=" operation " width="180">
<template slot-scope="scope">
<el-button size="mini" type="primary" icon="el-icon-plus"
@click.native.prevent="addRow(scope.$index, setList)"></el-button>
<el-button size="mini" type="primary" icon="el-icon-minus"
@click.native.prevent="deleteRow(scope.$index, setList)"></el-button>
</template>
</el-table-column>
</el-table-self>
then ,methods There need to be three methods :( as follows )
// First of all : obtain el-table Data in setList
getcheckedId() {
this.$axios({
//url And parameters
}).then((res) => {
// Assign the obtained return value to setList
this.setList=res.data
// If setList No data in , Then manually push A piece of data , Can show + ,— Number
if(this.setList.length<1){
this.setList.push({
flowCode:'',
orderNum: res.data.length+1,
realname: '',
userId: '',
remark: "",
roleId: "",
roleName: "",
scope: 0,
updateTime: null,
})
}
}).catch(() => {
// return
})
},
// second : Click on + Execute the method of adding a row of data
addRow(index, rows) {
// Using array splice Methods from index+1 Location delete 0 Elements , And insert an empty piece of data
rows.splice(index+1,0,{
flowCode:'',
orderNum: index+2,
realname: '',
userId: '',
remark: "",
roleId: "",
roleName: "",
scope: 0,
updateTime: null,
});
},
// Third : Click on — No. execute the method of deleting a row
deleteRow(index, rows) {
// Using arrays splice Method , Will be index Data deletion
rows.splice(index, 1);
},
The final point , Yes orderNum( Step number ) To deal with —— Yes setList Listen to your data
setList:{
handler: function (newVal,oldVal) {
// console.log(" monitor setList length ",newVal.length,oldVal.length)
if(newVal.length){
for(let i in newVal){
// Get... In real time orderNum Value
newVal[i].orderNum=Number(i)+1
}
}
// It's here to judge , If it is user approval , Just make the character empty ; If it is role approval , Just empty the user
for(let i in newVal){
if(newVal[i].type==='1'){
newVal[i].roleId=''
newVal[i].roleName=''
}else if(newVal[i].type==='2'){
newVal[i].userId=''
newVal[i].realname=''
}
}
},
deep: true // Deep monitoring
}
Conclusion :
above , We can achieve the results we want !(ps: Blogging is for taking notes !)
边栏推荐
- 高斯消元
- Qt随手笔记(三)在vs中使用QtCharts画折线图
- 高斯消元求解异或线性方程组
- Apple dominates, Samsung revives, and domestic mobile phones fail in the high-end market
- 在Blazor 中自定义权限验证
- 学习笔记之常用数组api 改变原数组和不改变原数组的有哪些?
- 2019 ICPC Asia Yinchuan Regional(水题题解)
- SSG框架Gatsby访问数据库,并显示到页面上
- 编写一个在bash / shell 和 PowerShell中均可运行的脚本
- JS table auto cycle scrolling, mouse move in pause
猜你喜欢

CSV data file settings of JMeter configuration components

服务发现原理分析与源码解读

The problem of accessing certsrv after configuring ADCs

开发转测试:从0开始的6年自动化之路...

Interview shock 68: why does TCP need three handshakes?

挡不住了,纯国产PC已就位,美国的软硬件体系垄断正式被破

论文笔记(SESSION-BASED RECOMMENDATIONS WITHRECURRENT NEURAL NETWORKS)

Mysql5.7.25 master-slave replication (one-way)

【荧光字效果】

QT handy notes (III) use qtcharts to draw a line chart in VS
随机推荐
Xiaobai makes a wave of deep copy and shallow copy
面试突击68:为什么 TCP 需要 3 次握手?
Why does new public chain Aptos meet market expectations?
Login module use case writing
Mo team learning summary (II)
Applet record
Nodejs service background execution (forever)
2022 zhongkepan cloud - server internal information acquisition and analysis flag
The combination of officially issued SSL certificate and self signed certificate realizes website two-way authentication
新增市场竞争激烈,中国移动被迫推出限制性超低价5G套餐
regular expression
2019 ICPC Asia Yinchuan Regional(水题题解)
[MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)
服务器、客户端双认证(2)
AR model in MATLAB for short-term traffic flow prediction
B站这个视频我是跪着看完的
RMQ学习笔记
Show default image when wechat applet image cannot be displayed
copyTo
Double authentication of server and client