export const mapFields = {
    invoiceNo:'invoiceNo', //发票类型
    invoiceType:'invoiceType', //发票类型
    invoiceNumber:"invoiceNum", //发票号码
    invoiceCode:'invoiceCode',  //发票代码
    invoiceName:'invoiceName', //发票名称
    openTime:'openDate', //开票日期
    beforeTax:'subTotal', //税前金额
    afterTax:'total', //税后金额
    checkNumber:'checkCode'
}

/***
 * @props
 * 发票申请编号 invoiceNo
 * 发票状态 invoiceStatus
 * 发票类型 invoiceType
 * 发票号码 invoiceNumber
 * 发票代码 invoiceCode
 * 发票名称 invoiceName
 * 开票日期 openTime
 * 税前金额 beforeTax
 * 税后金额 afterTax
 * 校验码 checkNumber
*/

export const manuallyUploadRules = {
   [mapFields.invoiceType]:[
        {
            trigger: "blur",
            message: "请选择发票类型",
            required: true
        }
    ],
    [mapFields.invoiceNumber]: [
        {
            trigger: "blur",
            message: "请输入发票号码",
            required: true
        }
    ],
    [mapFields.invoiceCode]: [
        {
            trigger: "blur",
            message: "请选择发票代码",
            required: true
        }
    ],
    [mapFields.openTime]: [
        {
            trigger: "blur",
            message: "请选择开票时间",
            required: true
        }
    ],
    [mapFields.beforeTax]: [
        {
            trigger: "blur",
            message: "请输入金额",
            required: true
        }
    ],
    [mapFields.afterTax]: [
        {
            trigger: "blur",
            message: "请输入税后金额",
            required: true
        }
    ],
    [mapFields.checkNumber]: [
        {
            trigger: "blur",
            message: "请输入校验码",
            required: false
        }
    ]
}


export const columns = [
    {
        type: 'index',
        label: '序号',
        width: '70px'
    },
    // {
    //     prop: mapFields.invoiceNo,
    //     label: '发票申请编号',
    //     width: '110px',
    //     required: true,
    // },
    {
        prop: mapFields.invoiceType,
        label: '发票类型',
        width: '120px',
        required: true,
        templateData:'增值税普通发票'
    },
    {
        prop: mapFields.invoiceNumber,
        label: '发票号码',
        width: '156px',
        required: true,
        templateData:'10000'
    },
    {
        prop: mapFields["invoiceCode"],
        label: '发票代码',
        width: '156px',
        required: true,
        templateData:'10000000'
    },
    {
        prop: mapFields["openTime"],
        label: '开票日期',
        width: '180px',
        required: true,
        templateData:'2023-01-01'
    },
    {
        prop: mapFields["afterTax"],
        label: '税后金额',
        width: '156px',
        required: true,
        templateData: 106
    },
    {
        prop: mapFields["beforeTax"],
        label: '税前金额',
        width: '150px',
        required: true,
        templateData: 100
    },
    {
        prop: mapFields["checkNumber"],
        label: '校验码',
        minWidth: '150px',
        required: false,
        templateData:'10000'
    },
]

export const getColumn = (key) => {
    return (columns.find(({prop}) => key === prop) || {})
}

export const getTableProperty = (key) => {
    return (columns.find(({label}) => key === label) || {}).prop
}

export const template = Array(1).fill(1).map(() => columns.slice(1).reduce((prev, {label,templateData}) => {
    prev[label] = templateData
    return prev
}, {}))

export const requsetFields = [
    mapFields.invoiceNumber,
    mapFields.invoiceCode,
    mapFields.invoiceType,
    mapFields.afterTax,
    mapFields.beforeTax,
    mapFields.openTime,
    mapFields.checkNumber
]

export const requiredFields = [
    mapFields.invoiceNumber,
    mapFields.invoiceCode,
    mapFields.invoiceType,
    mapFields.afterTax,
    mapFields.beforeTax,
    mapFields.openTime,
]

export const numberFields = []
