当前位置:网站首页>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 !)
边栏推荐
- Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice
- Fiddler download and installation
- 一种分布式深度学习编程新范式:Global Tensor
- Interview shock 68: why does TCP need three handshakes?
- Cloud native (36) | introduction and installation of harbor in kubernetes
- Interpretation of the standard of software programming level examination for teenagers_ second level
- Learning notes: what are the common array APIs that change the original array or do not change the original array?
- 面试突击68:为什么 TCP 需要 3 次握手?
- [datawhale] [machine learning] Diabetes genetic risk detection challenge
- 2019 ICPC Asia Yinchuan regional (water problem solution)
猜你喜欢
Mqtt x cli officially released: powerful and easy-to-use mqtt 5.0 command line tool
配置ADCS后访问certsrv的问题
2019 ICPC Asia Yinchuan Regional(水题题解)
服务器内存故障预测居然可以这样做!
R language ggplot2 visualization: align the legend title to the middle of the legend box in ggplot2 (default left alignment, align legend title to middle of legend)
Customize permission validation in blazor
Wechat applet learning notes 1
一种分布式深度学习编程新范式:Global Tensor
Fiddler packet capturing tool for mobile packet capturing
图解用户登录验证流程,写得太好了!
随机推荐
官方颁发的SSL证书与自签名证书结合实现网站双向认证
JS one line code to obtain the maximum and minimum values of the array
2021 windows penetration of "Cyberspace Security" B module of Shandong secondary vocational group (analysis)
Xiaobai makes a wave of deep copy and shallow copy
(1) Hand eye calibration of face scanner and manipulator (eye on hand)
云原生(三十六) | Kubernetes篇之Harbor入门和安装
B站这个视频我是跪着看完的
MySQL 5.7.25 source code installation record
“互联网+”时代的现代医学
苹果独占鳌头,三星大举复兴,国产手机在高端市场颗粒无收
Network flow learning notes
Flutter Event 派发
QT handy notes (II) edit control and float, qstring conversion
Interpretation of the standard of software programming level examination for teenagers_ second level
Applet record
Redis sentinel mode setup under Windows
Why does new public chain Aptos meet market expectations?
MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res
Installation and use of cocoapods