<template>
  <a-card>
    <sd-data-table
      data-url="api/xcoa-mobile/v1/kmknowledge/knowledge_account"
      :columns="columns"
      :row-key="'id'"
      :search-fields="['title']"
    >
      <a slot="bt" slot-scope="text, record" :title="text" @click="click(record)">{{ text }} </a>
    </sd-data-table>
  </a-card>
</template>

<script>
import TableColumnTypes from '@/common/services/table-column-types'
import components from './_import-components/km-my-commend-import'
const columns = [
  {
    title: '序号',
    width: '100px',
    align: 'center',
    customRender: (text, record, index) => `${index + 1}`,
  },
  {
    title: '标题',
    dataIndex: 'title',
    width: '200px',
    align: 'center',
    scopedSlots: { customRender: 'bt' },
  },
  {
    title: '版本号',
    dataIndex: 'versionNum',
    width: '100px',
    align: 'center',
  },
  {
    title: '所属分类',
    dataIndex: 'category',
    align: 'center',
  },
  {
    title: '创建时间',
    dataIndex: 'creationTime',
    align: 'center',
    sorter: (a, b) => a.creationTime - b.creationTime,
    sdRender: TableColumnTypes.dateTime, // 特殊处理的数据类型，时间戳会自动调用sdDateFormat处理
  },
  {
    title: '点击次数',
    dataIndex: 'readTimes',
    width: '130px',
    align: 'center',
    sorter: (a, b) => a.readTimes - b.readTimes,
  },
  {
    title: '被推荐次数',
    dataIndex: 'recommendTimes',
    sorter: (a, b) => a.recommendTimes - b.recommendTimes,
    width: '130px',
    align: 'center',
  },
  {
    title: '被点评次数',
    dataIndex: 'commentTimes',
    sorter: (a, b) => a.commentTimes - b.commentTimes,
    width: '150px',
    align: 'center',
  },
]
export default {
  name: 'KmMyKnowledge',
  metaInfo: {
    title: '我的知识',
  },
  components,
  data() {
    return {
      columns,
    }
  },
  created() {},
  methods: {
    click(record) {
      window.open(`#/km-knowledage-view?id=${record.id}&title=${record.title}`, '_blank')
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
