哪些網(wǎng)站百度不收錄網(wǎng)絡(luò)營銷的主要手段和策略
官方有個屬性selectable 設(shè)置chechBox是否可以勾選,結(jié)合在初始化獲取數(shù)據(jù)時候toggleAllSelection選中checkBox, 最后并沒有效果,checkBox沒有選中,不知道是啥原因,找了很多文章也沒有看到實際解決問題的,所以換了一種思路,如下:
重點:@select和@select-all結(jié)合
<el-table:data="receivableList"style="width: 100%"ref="multipleTable"@selection-change="handleSelectionChange"@select="handleSelect" // 用戶選擇checkBox觸發(fā)的事件@select-all="handleSelectAll" // 用戶選擇全選觸發(fā)的事件><el-table-column type="selection" width="50" fixed="right"></el-table-column>
</el-table>
getReceivableList() {//關(guān)鍵代碼,數(shù)據(jù)處理請結(jié)果業(yè)務(wù)進(jìn)行相關(guān)調(diào)整receivableList().then((response) => {this.receivableList = response.data.receivableList; //列表數(shù)據(jù)if (this.receivableList.length) {this.$refs.multipleTable.toggleAllSelection(); // 設(shè)置全選中this.selectList = this.receivableList // 選中的數(shù)據(jù)} });},
// 選中行:如果沒有權(quán)限 不讓其取消handleSelect(selection, row) {if(!this.$hasPermi("編輯清單") && selection.length != this.selectList.length) {this.$refs.multipleTable.toggleRowSelection(row, true);this.$message.warning("沒有權(quán)限編輯清單,請聯(lián)系管理員");}},// 全選 取消:如果沒有權(quán)限 強制全部選中handleSelectAll(selection) {if(!this.$hasPermi("編輯清單") && selection.length == 0) {this.$refs.multipleTable.toggleAllSelection();this.$message.warning("沒有權(quán)限編輯清單,請聯(lián)系管理員");}}
整體思路就是用戶點擊取消了,都給它再設(shè)置選中,就這么簡單,雖然實現(xiàn)了但是感覺很雞肋,如有其他實現(xiàn)方式,煩請評論相告,謝謝奧~~