web123456

@selection-change in Element-ui--el-tablez [Get the checkbox collection]

// Get the list of role selection boxes async getOptionSelect() { const result = await this.$API.system.role.optionSelect.post(); this.apiObj = result.data; // To the data source for the table this.loadData(result.data); }, // Load the selected item for the role list loadData(dataTable) { this.$nextTick(() => { dataTable.forEach((row) => { // hasSelectList array composed of selected ids if (this.hasSelectList.indexOf(row.roleId) >= 0) { // toggleRowSelection(row, selected) accepts two parameters, row passes the data of the selected row, and selected sets whether to select this.$refs.table.toggleRowSelection(row, true); } }); }); }, // When the user manually checks, the event will be triggered selectionChange(selection, row) { this.selection = selection; if (this.hasSelectList.includes(row.roleId)) { //Array consisting of return true, hasSelectList selected id this.hasSelectList.splice(this.hasSelectList.indexOf(row.roleId), 1); // Delete 1 item for matching subscript } else { this.hasSelectList.push(row.roleId); } }, //Includes() method is used to determine whether an array contains a specified value. According to the situation, if included, it returns true, otherwise it returns false. //splice() method modifys the array by deleting or replacing existing elements or adding new elements in place, and returns the modified content in the form of an array. This method changes the original array //Splice specifies two parameters, the location of the first item to be deleted and the number of items to be deleted. //indexOf() method returns the first index where a given element can be found in the array, and if it does not exist, it returns -1.