1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| <template> <div> <a-table :columns="columns" :dataSource="data" :rowSelection="rowSelection"> <a slot="operation" slot-scope="text,record,index" @click="handleDisabled(index)" >activate/disabled</a> </a-table> <a-button @click="handleDisabled(3)">activate/disabled</a-button> </div> </template> <script> export default { data() { return { columns: [ { title: "Operation", scopedSlots: { customRender: "operation" } }, { title: "Name", dataIndex: "name" }, { title: "Age", dataIndex: "age" }, { title: "Address", dataIndex: "address" } ], data: [ { key: "1", name: "John Brown", age: 32, address: "New York No. 1 Lake Park", disabled: false }, { key: "2", name: "Jim Green", age: 42, address: "London No. 1 Lake Park", disabled: false }, { key: "3", name: "Joe Black", age: 32, address: "Sidney No. 1 Lake Park", disabled: false }, { key: "4", name: "Disabled User", age: 99, address: "Sidney No. 1 Lake Park", disabled: true } ], selectedRowKeys: ["4"] }; }, computed: { rowSelection() { return { getCheckboxProps: record => ({ props: { disabled: record.disabled } }) }; } }, methods: { handleDisabled(index) { this.data[index].disabled = !this.data[index].disabled; this.data = [...this.data]; } } }; </script>
|