export type ForeignCurrencyOption = { label: string shortLabel: string value: string unit: string symbol: string } export type ForeignOption = { label: string value: string } export type ForeignStatusOption = ForeignOption & { className: string } export const allForeignCurrencyOption: ForeignCurrencyOption = { label: '全部币种', shortLabel: '全部币种', value: '', unit: '万元', symbol: '¤', } export const foreignCurrencyOptions: ForeignCurrencyOption[] = [ allForeignCurrencyOption, { label: 'CNY-人民币', shortLabel: '人民币', value: 'CNY', unit: '万元', symbol: '¥' }, { label: 'USD-美元', shortLabel: '美元', value: 'USD', unit: '万美元', symbol: '$' }, { label: 'HKD-港元', shortLabel: '港元', value: 'HKD', unit: '万港元', symbol: 'HK$' }, { label: 'EUR-欧元', shortLabel: '欧元', value: 'EUR', unit: '万欧元', symbol: '€' }, { label: 'AUD-澳大利亚元', shortLabel: '澳大利亚元', value: 'AUD', unit: '万澳大利亚元', symbol: 'A$', }, { label: 'CHF-瑞士法郎', shortLabel: '瑞士法郎', value: 'CHF', unit: '万瑞士法郎', symbol: 'Fr', }, { label: 'GBP-英镑', shortLabel: '英镑', value: 'GBP', unit: '万英镑', symbol: '£' }, { label: 'CAD-加拿大元', shortLabel: '加拿大元', value: 'CAD', unit: '万加拿大元', symbol: 'C$', }, { label: 'NZD-新西兰元', shortLabel: '新西兰元', value: 'NZD', unit: '万新西兰元', symbol: 'NZ$', }, { label: 'SGD-新加坡元', shortLabel: '新加坡元', value: 'SGD', unit: '万新加坡元', symbol: 'S$', }, { label: 'JPY-日元', shortLabel: '日元', value: 'JPY', unit: '万日元', symbol: '¥' }, { label: 'SEK-瑞典克朗', shortLabel: '瑞典克朗', value: 'SEK', unit: '万瑞典克朗', symbol: 'kr', }, { label: 'NOK-挪威克朗', shortLabel: '挪威克朗', value: 'NOK', unit: '万挪威克朗', symbol: 'kr', }, { label: 'DKK-丹麦克朗', shortLabel: '丹麦克朗', value: 'DKK', unit: '万丹麦克朗', symbol: 'kr', }, { label: 'KZT-哈萨克斯坦坚戈', shortLabel: '哈萨克斯坦坚戈', value: 'KZT', unit: '万哈萨克斯坦坚戈', symbol: '₸', }, ] export const allForeignBusinessOption: ForeignOption = { label: '全部业务类型', value: '' } export const defaultForeignBusinessOption: ForeignOption = { label: '普通汇款', value: '10' } export const foreignBusinessOptions: ForeignOption[] = [ allForeignBusinessOption, defaultForeignBusinessOption, { label: '单证业务', value: '11' }, { label: '同业/其他业务', value: '12' }, { label: '资金调拨', value: '13' }, ] export const foreignPayDirectionMap: Record = { I: '收入', O: '支出', } export const foreignPaymentRouteMap: Record = { '01': '人行境内外币支付', '02': '境外汇款', '03': '境内汇款走境外汇路', '10': '普通汇款', '11': '单证业务', '12': '同业/其他业务', '13': '资金调拨', } export const foreignClientTypeMap: Record = { CT01: '对公客户', CT02: '个人客户', CT03: '同业客户', } export const foreignOriginalForeignMap: Record = { '01': '结汇', '02': '购汇', '03': '现汇', } export const foreignVerifyStatusMap: Record = { '1': '未核销', '2': '部分核销', '3': '已核销', VS01: '未核销', VS02: '部分核销', VS03: '已核销', } export const allForeignStatusOption: ForeignStatusOption = { label: '全部预报状态', value: '', className: 'status-tag-unknown', } export const foreignStatusOptions: ForeignStatusOption[] = [ allForeignStatusOption, { label: '待分行确认', value: '1', className: 'status-tag-pending' }, { label: '待总行确认', value: '2', className: 'status-tag-pending' }, { label: '已确认', value: '3', className: 'status-tag-confirmed' }, { label: '分行拒绝', value: '4', className: 'status-tag-rejected' }, { label: '已删除', value: '5', className: 'status-tag-cancelled' }, { label: '待分行确认删除', value: '6', className: 'status-tag-pending' }, { label: '待总行确认删除', value: '7', className: 'status-tag-pending' }, { label: '总行拒绝', value: '8', className: 'status-tag-rejected' }, ] export const unknownForeignStatus: ForeignStatusOption = { label: '未知状态', value: '', className: 'status-tag-unknown', } export function resolveForeignCurrency(value?: string) { const normalizedValue = value?.trim().toUpperCase() if (!normalizedValue) { return allForeignCurrencyOption } return ( foreignCurrencyOptions.find((item) => item.value === normalizedValue) || { label: normalizedValue, shortLabel: normalizedValue, value: normalizedValue, unit: `万${normalizedValue}`, symbol: normalizedValue, } ) } export function resolveForeignBusinessType(value?: string) { if (!value?.trim()) return '普通汇款' return foreignBusinessOptions.find((item) => item.value === value)?.label || value } export function resolveForeignPayDirection(value?: string) { return resolveForeignCode(foreignPayDirectionMap, value) } export function resolveForeignPaymentRoute(value?: string) { return resolveForeignCode(foreignPaymentRouteMap, value) } export function resolveForeignClientType(value?: string) { return resolveForeignCode(foreignClientTypeMap, value) } export function resolveForeignOriginalForeign(value?: string) { return resolveForeignCode(foreignOriginalForeignMap, value) } export function resolveForeignVerifyStatus(value?: string) { return resolveForeignCode(foreignVerifyStatusMap, value) } export function resolveForeignStatus(value?: string) { const code = value?.trim() if (!code) { return unknownForeignStatus } const normalizedCode = /^PS0([1-8])$/.exec(code)?.[1] || code return foreignStatusOptions.find((item) => item.value === normalizedCode) || unknownForeignStatus } export function formatForeignForecastDate(value?: string) { if (value && /^\d{8}$/.test(value)) { return `${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}` } return value || '-' } export function toTenThousandAmount(value?: string) { const amount = Number(value?.replaceAll(',', '') || 0) return Number.isFinite(amount) ? amount / 10000 : 0 } export function formatForeignForecastAmount(value: number) { const sign = value >= 0 ? '+' : '-' return `${sign}${Math.abs(value).toFixed(2)}` } export function formatForeignForecastAmountText(value?: string, currencyValue?: string) { const currency = resolveForeignCurrency(currencyValue) return `${formatForeignForecastAmount(toTenThousandAmount(value))}${currency.unit}` } export function formatForeignForecastAmountYuanText(value?: string) { const amount = Number(value?.replaceAll(',', '') || 0) if (!Number.isFinite(amount)) return '-' return `${amount.toLocaleString('zh-CN', { maximumFractionDigits: 2, minimumFractionDigits: 2, })} 元` } function resolveForeignCode(map: Record, value?: string) { const code = value?.trim() return code ? map[code] || code : '-' }