<template>
  <a-card>
    <a-tabs v-model="activeKey">
      <a-tab-pane key="communication" tab="待反馈">
        <sd-data-table
          ref="communication"
          data-url="api/framework/v1/user-tasks/communication"
          :columns="columns"
          :row-key="'instId'"
          :search-fields="['title']"
          @rowClick="rowClick"
        >
        </sd-data-table>
      </a-tab-pane>
      <a-tab-pane key="commFeedback" tab="已反馈">
        <sd-data-table
          ref="commFeedback"
          data-url="api/framework/v1/user-tasks/replied-communication"
          :columns="columns2"
          :row-key="'instId'"
          :search-fields="['title']"
          @rowClick="rowClick"
        >
        </sd-data-table>
      </a-tab-pane>
    </a-tabs>
  </a-card>
</template>

<script>
import TodoListService from '@/todo/todo-list-service'
import TableColumnTypes from '../common/services/table-column-types'
import components from './_import-components/sd-communication-import'

const columns = [
  {
    title: '业务类型',
    dataIndex: 'processName',
    width: '10%',
  },
  {
    title: '标题',
    dataIndex: 'title',
    sdClickable: true,
  },
  {
    title: '发起人',
    dataIndex: 'senderName',
    width: '10%',
  },
  {
    title: '创建时间',
    sorter: true,
    dataIndex: 'createdTime',
    sdRender: TableColumnTypes.dateTime,
  },
  {
    title: '发起人意见',
    dataIndex: 'startOpinion',
  },
]

const columns2 = [
  {
    title: '业务类型',
    dataIndex: 'processName',
  },
  {
    title: '标题',
    dataIndex: 'title',
    sdClickable: true,
  },
  {
    title: '发起人',
    dataIndex: 'senderName',
  },
  {
    title: '创建时间',
    sorter: true,
    dataIndex: 'createdTime',
    sdRender: TableColumnTypes.dateTime,
  },
  {
    title: '反馈时间',
    sorter: true,
    dataIndex: 'modifiedTime',
    sdRender: TableColumnTypes.dateTime,
  },
]

export default {
  name: 'SdCommunication',
  metaInfo: {
    title: '我的沟通',
  },
  components,
  data() {
    return {
      activeKey: 'communication',
      columns,
      columns2,
    }
  },
  methods: {
    // 查看详情
    rowClick(record, rowIndex) {
      TodoListService.openTaskItem(record, this.activeKey)
    },
  },
}
</script>

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