您好,欢迎来到测品娱乐。
搜索
您的当前位置:首页vue+element模态框中新增模态框和删除功能

vue+element模态框中新增模态框和删除功能

来源:测品娱乐


实现效果如下

结构

 <el-table-column sortable label="操作">
 <template slot-scope="scope">
 <el-button type="primary" @click="getMembers(scope.row.id)">成员</el-button>
 <el-buttontype="primary" @click="delRole(scope.row.id, scope.$index)">删除</el-button>
 </template>
 </el-table-column>
 //scope.$index 获取当前行的index

// 打开新增成员

openAddStaff() {
 this.getAllStaff();
},
// 确定新增
addStaff() {
 if (!this.user) {
 this.$message.error("请选择用户!");
 return;
 }
 this.$post(
 "/api/RoleMemberController/add",
 { userId: this.user.split("/")[0], roleId: this.roleId },
 data => {
 console.log(data,111)
 this.$message.success("添加成功!");
 this.dialogAddStaffVisible = false;
 let item = {
 id: data.rm.id,
 userId: data.rm.userId,
 userCname: this.user.split("/")[1]
 };
 this.staffList.push(item);//从数组中添加当前行
 }
 );
},

// 删除员工

delStaff(id, index) {
 this._confirm("确定删除吗?", () => {
 this.$post("/api/RoleMemberController/delOne", { id: id }, data => {
 this.$message.success("删除成功!");
 this.staffList.splice(index, 1);//从数组中删除当前行
 });
 });
},

Copyright © 2019- cepb.cn 版权所有 湘ICP备2022005869号-7

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务