<template>
  <div class="demo-table-basic">
    <ui-table
      :data-source="dataSource"
      :columns="columns"
      :on-click="onClick"
      @column-width-dragend="headDragend">
      <template
        slot="title"
        slot-scope="{ rowIndex, colIndex, value }">
        <span>{{ rowIndex }}:{{ colIndex }} = {{ value }}</span>
      </template>
      <template
        slot="common"
        slot-scope="{ value }">
        <span>当前: {{ value }}</span>
      </template>
      <template
        slot="input"
        slot-scope="{ value }">
        <span><ui-input :value="value"></ui-input></span>
      </template>
    </ui-table>
  </div>
</template>

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

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

const columns = [
  {
    title: "ID",
    key: "id",
    className: "test-class",
    align: "right",
    width: 100,
    defaultSort: "desc",
    minDragWidth: 80,
  },
  {
    title: "标题",
    key: "title",
    slot: "title",
  },
  {
    title: "状态",
    key: "status",
    slot: "common",
  },
  {
    title: "处理人",
    key: "handler",
    slot: "common",
  },
  {
    title: "评分",
    key: "score",
    slot: "input",
  },
]

export default {
  components: {
    "ui-table": Table,
    "ui-input": Input,
  },
  data() {
    return {
      dataSource: dataSource,
      columns: columns,
    }
  },
  methods: {
    onClick() {
      console.log(arguments)
    },
    headDragend(data) {
      console.log("data", data)
    },
  },
}
</script>

<style lang="scss">
.demo-table-basic {
  table {
    margin: 0;
  }

  th,
  td {
    border: none;
  }
}
</style>
