<template>
  <a-card>
    <a-tabs v-if="leaderList.length > 0" v-model="activeKey">
      <a-tab-pane v-for="leader in leaderList" :key="leader.leaderAccount" :tab="leader.leaderName">
        <sd-data-table
          :ref="leader.leaderAccount"
          data-url="api/framework/v1/user-tasks/leader/inform-with-trustor"
          :columns="columns"
          :row-key="'instId'"
          :search-fields="['title']"
          :process-req="processReq"
        >
          <a
            slot="bt"
            slot-scope="text, record"
            :class="record.opened === 0 ? $style.unread : ''"
            @click="openTaskItem(record, 'informleader')"
          >
            <a-badge v-if="record.opened === 0" dot title="未查看" />{{ text }}
          </a>
        </sd-data-table>
      </a-tab-pane>
    </a-tabs>
    <a-empty v-else />
  </a-card>
</template>

<script>
import TableColumnTypes from '@/common/services/table-column-types'
import components from './_import-components/sd-leaderinform-import'
import leaderOfficeMixins from './leader-office-mixins'
export default {
  name: 'SdLeaderinform',
  metaInfo: {
    title: '领导待阅',
  },
  components,
  mixins: [leaderOfficeMixins],
  data() {
    return {
      leaderList: [],
      activeKey: '',
      columns: [
        {
          title: '业务类型',
          dataIndex: 'appCat',
        },
        {
          title: '标题',
          dataIndex: 'title',
          scopedSlots: { customRender: 'bt' },
        },
        {
          title: '发送人',
          dataIndex: 'senderName',
        },
        {
          title: '接收时间',
          dataIndex: 'sentDate',
          sdRender: TableColumnTypes.dateTime,
          sorter: true,
          defaultSortOrder: 'desc',
        },
        {
          title: '发起人',
          dataIndex: 'creatorName',
          sdCandidate: true,
        },
        {
          title: '发起部门',
          dataIndex: 'createDeptName',
          sdCandidate: true,
        },
        {
          title: '创建时间',
          dataIndex: 'creationTime',
          sdRender: TableColumnTypes.dateTime,
          sdCandidate: true,
        },
      ],
    }
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.unread {
  :global(.ant-badge) {
    margin-right: 6px;
    vertical-align: baseline;
  }

  font-weight: 600;
}
</style>
