import { IColumn } from "../../../store/table"

export const pageOptions: { value: string, label: string }[] = [
  { value: 'A4', label: 'A4 (210.0*297.0)' },
  { value: 'A3', label: 'A3 (297.0*420.0)' },
  { value: 'A5', label: 'A5 (148.0*210.0)' },
  { value: 'B4', label: 'B4 (250.0*354.0)' },
  { value: 'B5', label: 'B5 (182.0*257.0)' },
  { value: '信封 #9', label: '信封 #9 (98.4*225.4)' },
  { value: '信封 #10', label: '信封 #10 (104.8*241.3)' },
  { value: '信封 #11', label: '信封 #11 (114.3*263.5)' },
  { value: '信封 #12', label: '信封 #12 (101.6*279.4)' },
  { value: '信封 #14', label: '信封 #14 (127.0*292.1)' },
  { value: '2开', label: '2开 (215.9*330.2)' },
  { value: '4开', label: '4开 (215.0*275.0)' },
  { value: '大4开', label: '大4开 (254.0*355.6)' },
  { value: '信纸', label: '信纸 (215.9*279.4)' },
  { value: '小报', label: '小报 (279.4*431.8)' },
  { value: '文书', label: '文书 (215.9*355.6)' },
  { value: '申明', label: '申明 (139.7*215.9)' },
  { value: '公函', label: '公函 (190.5*254.0)' },
  { value: '便条', label: '便条 (215.9*279.0)' },
  { value: '方纸', label: '方纸 (100.0*100.0)' },
  { value: '自定义', label: '自定义' }
]

export const sizeOptions: { [key: string]: [width: number, height: number] } = {
  "A4": [210.0, 297.0],
  "A3": [297.0, 420.0],
  "A5": [148.0, 210.0],
  "B4": [250.0, 354.0],
  "B5": [182.0, 257.0],
  "信封 #9": [98.4, 225.4],
  "信封 #10": [104.8, 241.3],
  "信封 #11": [114.3, 263.5],
  "信封 #12": [101.6, 279.4],
  "信封 #14": [127.0, 292.1],
  "2开": [215.9, 330.2],
  "4开": [215.0, 275.0],
  "大4开": [254.0, 355.6],
  "信纸": [215.9, 279.4],
  "小报": [279.4, 431.8],
  "文书": [215.9, 355.6],
  "申明": [139.7, 215.9],
  "公函": [190.5, 254.0],
  "便条": [215.9, 279.0],
  "方纸": [100.0, 100.0],
  "自定义": [0, 0]
}

export interface PrinterParam {
  printer: string
  /** 预览/打印 */
  preview: boolean
  /** 排列 */
  arrange: boolean
  /** 纵向/横向 */
  direction: boolean
  count: number
  pageWidth: number
  pageHeight: number
  marginTop: number
  marginLeft: number
  rowSpacing: number
  colSpacing: number
}

export interface Template {
  width: number;
  height: number;
  tempContent: string;
  tempId: string;
  tempName: string
  tableColumn: TableColumn
}

export interface LabelData {
  items: { [key: string]: any }[]
  total: number
}

export type ColumnInfo = { columns: Column[], statistics?: Stastic[] }

export interface TableColumn {
  [key: string]: ColumnInfo
}

interface Column {
  name: string
  label: string
  statistics?: {
    label: string,
    format: string,
    tdata: string,
    [key: string]: string
  }[]
  [key: string]: any
}

interface Stastic {
  field: string
  property: {
    label: string,
    format: string,
    tdata: string,
    [key: string]: string
  }[]
}

export type SettingValues = {
  printer: string
  direction: 'vertical' | 'horizontal'
  content: 'all' | 'selected' | 'current'
  page: string
  width: number
  height: number
  top: number
  bottom: number
  left: number
  right: number
  copies: number
  scale?: number
}

export type OptionValues = {
  showTitle: boolean
  title: string
  titleAllPrint: boolean
  showSubTitle: boolean
  subTitle: string[]
  subTitleAllPrint: boolean
  showHeaderTitle: boolean
  headerTitle: string
  showHeaderLine: boolean
  showFooterTitle: boolean
  footerTitle: string
  showFooterLine: boolean
  showLogo: boolean
  showPrinter: boolean
  showDate: boolean
  showPageNum: boolean
  lineWidth: number
  borderWidth: number
  rowPadding: number
  colPadding: number
  countOfPage: boolean
  countAllPage: boolean
}

export interface DetailOptionValues {
  showTitle: boolean
  title: string
  showDynamicSubTitles: boolean
  dynamicSubTiltes: string[]
  showPageNum: boolean
  showDate: boolean
  showPrinter: boolean
  showLogo: boolean
  showBarCode: boolean
  showQRCode: boolean
}

export interface IFPTableValue extends IColumn {
  name: string
  title: string
  printType: 'all' | 'none'
  width: number | undefined
  grouping: 'group' | 'column' | 'page' | 'none'
  sort: 'none' | 'asc' | 'desc'
  statistic: 'none' | 'Sum',
  group: string
}

