import type { AsideEntity } from './aside'
import { IzProjectVue, IzStatus, IztaskrromVue, PictureDownloadVue, PlanVue, ReportUserVue, TimeVue } from '@/views/home/aside/comp/items'

export interface RowData {
  id: string
  fromtaskname: string
  approvalnode: string
  states: number
  similarity: string
  fromuptime: string
  updatetime: string
  title: string
  fromtaskid: string
}

export interface ColumnEntity {
  title: string
  fixed: boolean// 固定显示，不可隐藏
  key: string
  fixLeft?: boolean// 列固定显示左侧
  width: number
}

// 表格列默认配置
export const ColumnsMap: Recordable<ColumnEntity> = {
  id: {
    title: '任务Id',
    fixed: true,
    fixLeft: true,
    key: 'id',
    width: 100,
  },
  name: {
    title: '任务名称',
    fixed: true,
    key: 'name',
    width: 200,
  },
  approvalnode: {
    title: '审批节点',
    fixed: true,
    key: 'approvalnode',
    width: 100,
  },
  approvalstatus: {
    title: '审批状态',
    fixed: true,
    key: 'approvalstatus',
    width: 100,
  },
  similarity: {
    title: '图片相似度',
    fixed: false,
    key: 'similarity',
    width: 100,
  },
  uptime: {
    title: '提报时间',
    fixed: false,
    key: 'uptime',
    width: 200,

  },
  updatetime: {
    title: '更新时间',
    fixed: false,
    key: 'updatetime',
    width: 200,
  },
}

export const headRules = ['任务Id', '任务名称', '审批节点', '审批状态', '图片相似度', '提报时间', '更新时间']

export function findKey(columns: any[], header: string) {
  const item = columns.find((column) => { return (column as any).title === header })
  return (item as any).key
}

// 终审左侧配置
export const asideMap: Recordable<AsideEntity> = {
  izupuser: {
    label: '提报人',
    defaultValue: null,
    isDefaultFilter: true,
    key: 'izupuser',
    component: ReportUserVue,
  },
  izproject: {
    label: '所属项目',
    defaultValue: null,
    isDefaultFilter: true,
    key: 'izproject',
    component: IzProjectVue,
  },
  izplan: {
    label: '所属计划',
    defaultValue: null,
    isDefaultFilter: true,
    key: 'izplan',
    component: PlanVue,
  },
  izstatus: {
    label: '审批状态',
    defaultValue: null,
    isDefaultFilter: false,
    key: 'izstatus',
    component: IzStatus, // todo
  },
  izuptime: {
    label: '提报时间',
    defaultValue: null,
    isDefaultFilter: false,
    key: 'izuptime',
    component: TimeVue,
  },
  iztaskrrom: {
    label: '任务来源',
    defaultValue: null,
    isDefaultFilter: false,
    key: 'iztaskrrom',
    component: IztaskrromVue,
  },
  izshowall: {
    label: '显示全部任务数据',
    defaultValue: true,
    isDefaultFilter: false,
    key: 'izshowall',
    component: PictureDownloadVue,
    inFilterList: false,
  },
}
