import type { FormRules } from 'element-plus'

export const rules = (): FormRules => {
    return {
        name: [
            { required: true, message: '请输入名称', trigger: ['blur'] }
        ],
        status: [
            { required: true, message: '请选择状态', trigger: ['change'] }
        ],
        isDefault: [
            { required: true, message: '请选择是否默认', trigger: ['change'] }
        ],
        isWithdrawalAllowed: [
            { required: true, message: '请选择是否允许出金', trigger: ['change'] }
        ],
        isWithdrawalAuditRequired: [
            { required: true, message: '请选择是否需要出金审核', trigger: ['change'] }
        ],
        maxOpenPosition: [
            { required: true, message: '请输入单笔开仓最大数量', trigger: ['blur','change'] },
            { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' }
        ],
        maxPositionPerSymbol: [
            { required: true, message: '请输入单品种最大持仓数量', trigger: ['blur','change'] },
            { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' }
        ],
        maxTotalPosition: [
            { required: true, message: '请输入总品种最大持仓数量', trigger: ['blur','change'] },
            { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' }
        ],
        strongCloseRatio: [
            { required: true, message: '请输入强平比例', trigger: ['blur','change'] },
            { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' }
        ],
        maxWithdrawalAmount: [
            { required: true, message: '请输入最大出金金额', trigger: ['blur','change'] },
            { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' }
        ],
        withdrawalTimeSetting: [
            { required: true, message: '请选择出金时间', trigger: ['change'] }
        ],
        buildCloseTime: [
            { required: true, message: '请输入建仓多少秒不能平仓', trigger: ['blur','change'] },
            { pattern: /^[0-9]+$/, message: '请输入整数' }
        ],
        minWithdrawalAmount: [
            { required: true, message: '请输入出金最小金额', trigger: ['blur','change'] },
            { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' }
        ],
        slippage: [
            { required: true, message: '请输入滑点', trigger: ['blur','change'] },
            { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' }
        ],
        minDepositAmount: [
            { required: true, message: '请输入入金最小金额', trigger: ['blur','change'] },
            { pattern: /^[0-9]+(\.[0-9]+)?$/, message: '请输入有效的数字' } 
        ],
    }
}