import { Api, SchemaNode } from "../../types"

export interface FlowingJson {
  title: string,
  api: Api
  detailApi: Api
}

export interface FlowData {
  items: taskList[],
  total: number
}
export interface FlowDetailList {
  approvalNo: string
  duration: string
  processInstanceId: string
  taskCreatedTime?: string
  taskEndTime?: string
  taskId?: string
  taskName?: string
  taskRemark?: string
  taskStatus?: string
  workCondition: FlowList[]
  endTime?: string
  processDefinitionName?: string
  processStatus?: string
  startTime?: string
  startUser?: {
    userAvatar?: string
    userId?: string
    userName?: string
    userRole?: string
  }
}

interface FlowList {
  label: string
  value: string
}

export interface FlowSun {
  title: string;
  count: number;
  name: string;
  icon: JSX.Element;
  hierarchy: number;
  data: string;
  key: string;
}

export interface AttachmentApi {
  attachmentUploadApi: Api
  // 附件下载Api
  attachmentDownloadApi: Api
  // 删除附件
  attachmentDeleteApi: Api
  // 删除当前Taskid中所有附件
  attachmentDeleteByTaskApi: Api
  // 附件获取任务Api
  attachmentGetTaskApi: Api
  //通讯率Api
  addrBookApi: Api
}


export interface FlowDetail {
  editFormUI: SchemaNode
  flowButtonList: FlowButtonUI[]
  flowProcess: flowProcess
  formUI: SchemaNode
  processInstanceId: string
  processNodeList: processNodeList[]
  flowDesc?: string
  notPrintFieldList?: string[]
}
export interface flowProcess {
  approvalNo: string
  duration: string
  endTime: string
  processDefinitionName: string
  processInstanceId: string
  processStatus: string
  startTime: string
  startUser: startUser
  workCondition?: string
  // 附件上传
  attachmentUploadApi: Api
  // 附件下载Api
  attachmentDownloadApi: Api
  // 删除附件
  attachmentDeleteApi: Api
  // 删除当前Taskid中所有附件
  attachmentDeleteByTaskApi: Api
  // 附件获取任务Api
  attachmentGetTaskApi: Api
}
export interface startUser {
  userAvatar: string | null,
  userId: string
  userName: string
  userRole: string | null,
}
export interface processNodeList {
  activeId: string
  nodeCreatedTime: string
  nodeEndTime: string
  nodeId: string
  nodeName: string
  nodeStatus: string
  nodeType: number
  nodeUser: startUser
  remarkComment: string | null,
  assignComment: string | null,
  attachments: attachments[]
  seq: number
  errorList?: any[]
  referralList: string[]
}
export interface attachments {
  attachmentId: string,
  chunkDownload: false,
  preview_name: string,
  processInstanceId: string,
  taskId: string,
  userId: string,
  name: string,
  size: number,
  addr: string,
  thumbnailAddr: string
}
export interface TaskHisActivity {
  currentTaskName: string
  assigneeUser: string
  assigneeUserName: string
  taskCreatedTime: string
  taskEndTime: string
  taskId: string
  taskSeq: string
  businessStatus?: Exclude<BusinessStatus, 'start' | 'end'>
  optionComment?: string
}

export interface UserTaskBean {
  taskName: string
  taskSeq: number
  taskType: number
  userId: string
  userRole: string
  userName: string
}
export interface taskList {
  currentTaskName: string
  assigneeUser: string
  assigneeUserName: string
  taskCreatedTime: string
  taskEndTime: string
  taskId: string
  taskSeq: string
  businessStatus?: Exclude<BusinessStatus, 'start' | 'end'>
  optionComment?: string
  taskStatus: string
}

export interface FlieText {
  attachmentId: string,
  preview_name: string,
  processInstanceId: string,
  taskId: string,
  userId: string,
  name: string,
  addr: string,
  thumbnailAddr: string
  size: number
}



type FlowStyle<T extends string> = { [key in T]: [color: string, label?: string] } & Object

export type ActionName = 'flow_agree' | 'flow_refuse' | 'flow_reject_to_start' | 'flow_reject_to_any' | 'flow_add_sign' | 'flow_cancel' | 'flow_assign' | 'flow_return' | 'flow_referral' | 'flow_revert' | 'flow_urge'

export type ActionLevel = 'success' | 'primary' | 'danger' | 'warning'

export type BusinessStatus = 'start' | 'end' | 'doing' | 'refuse' | 'reject' | 'success' | 'revert' | 'addSign' | 'none'

export interface FlowButtonUI {
  level: ActionLevel
  label: string
  name: ActionName
  api: Api
}

export const FLOWACTION_LEVEL_STYLE: FlowStyle<ActionLevel> = {
  success: ['#15bc83'],
  primary: ['#1890ff'],
  danger: ['#f25643'],
  warning: ['#ffad14']
}

export const BUSINESS_STATUS_STYLE: FlowStyle<Exclude<BusinessStatus, 'start' | 'end'>> = {
  success: ['#15bc83', '审核通过'],
  doing: ['#1890ff', '正在处理'],
  revert: ['#1890ff', '审核撤销'],
  reject: ['#f25643', '审核驳回'],
  refuse: ['#f25643', '审核拒绝'],
  addSign: ['#fa8c16', '添加加签人员'],
  none: ['#b6b6b6', '未定义']
}
