實(shí)現(xiàn)效果如下

結(jié)構(gòu)
<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 獲取當(dāng)前行的index
// 打開新增成員
openAddStaff() { this.getAllStaff();},// 確定新增addStaff() { if (!this.user) { this.$message.error("請(qǐng)選擇用戶!"); 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);//從數(shù)組中添加當(dāng)前行 } );},// 刪除員工
delStaff(id, index) { this._confirm("確定刪除嗎?", () => { this.$post("/api/RoleMemberController/delOne", { id: id }, data => { this.$message.success("刪除成功!"); this.staffList.splice(index, 1);//從數(shù)組中刪除當(dāng)前行 }); });},以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注