<template>
  <a-table :columns="columns" :data-source="data" rowKey="id" :scroll="{x:true}">
    <template slot="finish" slot-scope="text, record">
      <a-checkbox :default-checked="record.finish"/>
    </template>
    <template slot="action" slot-scope="text, record,index">
      <a-space>
        <a-button @click="$emit('onEdit',record,index)">{{ action.edit }}</a-button>

        <a-popconfirm
            v-if="data.length"
            :title="deleteTip"
            @confirm="() => $emit('onDelete',record.id)"
        >
          <a-button type="danger">{{ action.delete }}</a-button>
        </a-popconfirm>
      </a-space>
    </template>
  </a-table>
</template>

<script>
const columns = [
  {
    title: '完成',
    dataIndex: 'finish',
    scopedSlots: {customRender: 'finish'}
  },
  {
    title: '主题',
    dataIndex: 'subject'
  },
  {
    title: '交易',
    dataIndex: 'deal'
  },
  {
    title: '联络人',
    dataIndex: 'participants'
  },
  {
    title: '电子邮件',
    dataIndex: 'email'
  },
  {
    title: '电话',
    dataIndex: 'phone'
  },
  {
    title: '组织',
    dataIndex: 'organization'
  },
  {
    title: '到期日',
    dataIndex: 'date'
  },
  {
    title: '期间',
    dataIndex: 'time'
  },
  {
    title: '指派给使用者',
    dataIndex: 'user'
  },
  {
    title: '操作',
    dataIndex: 'action',
    scopedSlots: {customRender: 'action'}
  }
]
export default {
  name: "list",
  props:{
    data:Array
  },
  data() {
    return {
      //表格列
      columns,
      action: {
        edit: '编辑',
        delete: '删除',
        refresh: '刷新'
      },
      deleteTip: '确认删除此活动记录?',
    }
  },
  mounted() {
    this.$emit('load')
  }
}
</script>

<style scoped>

</style>