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("https://www.jb51.net/")[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("https://www.jb51.net/")[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);//从数组中删除当前行 }); }); },

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/636bcc29feff2cd295e4f3766d560f2a.html