<template>
  <div class="demo-table-select">
    <ui-table
      :data-source="dataSource"
      :columns="columns"
      :row-selection="rowSelection"
      :selected-rows="selected"></ui-table>
  </div>
</template>

<script>
import { Table } from "amumu-ui"

const dataSource = [
  {
    id: "100001",
    title: "升级版本方案",
    status: "待处理",
    handler: "吴彦祖",
  },
  {
    id: "100002",
    title: "升级版本方案",
    status: "待处理",
    handler: "吴彦祖",
  },
  {
    id: "100003",
    title: "升级版本方案",
    status: "待处理",
    handler: "吴彦祖",
  },
  {
    id: "100004",
    title: "升级版本方案",
    status: "待处理",
    handler: "吴尊",
  },
]

const columns = [
  {
    title: "ID",
    key: "id",
  },
  {
    title: "标题",
    key: "title",
  },
  {
    title: "状态",
    key: "status",
  },
  {
    title: "处理人",
    key: "handler",
  },
]

export default {
  components: {
    "ui-table": Table,
  },
  data() {
    return {
      dataSource: dataSource,
      columns: columns,
      rowSelection: {
        onChange: this.onRowSelectChange,
        getCheckboxProps: this.getCheckboxProps,
      },
      selected: [],
    }
  },
  methods: {
    onRowSelectChange(selected) {
      console.log(selected)
    },
    getCheckboxProps(row) {
      return {
        disabled: row.handler === "吴尊",
      }
    },
  },
}
</script>
