import React, { useState } from 'react'; import { Button, Modal } from 'antd'; import { DiscountInput, MoneyInput, PercentInput } from './inputs'; import { SYSTEM_DEFAULTS } from './constants'; const FIELD_DEFS = [ { key: 'coupon', label: '优惠券金额', Input: MoneyInput }, { key: 'activityDiscount', label: '活动折扣', Input: DiscountInput }, { key: 'installFee', label: '安装费', Input: MoneyInput }, { key: 'targetMargin', label: '营业利润率', Input: PercentInput }, ]; const formatDefaultTip = (key, value) => { if (key === 'targetMargin') return `系统默认 ${Number(value * 100).toFixed(0)}%`; if (key === 'activityDiscount') return `系统默认 ${value}(即 ${Number(value * 10).toFixed(0)} 折)`; return `系统默认 ${value}`; }; // 表单主体:每次打开弹窗时重新挂载,初始值取 个性化配置 > 系统默认 const DefaultsForm = ({ defaults, systemDefaults, saving, onSave }) => { const [form, setForm] = useState(() => ({ ...systemDefaults, ...(defaults || {}) })); return (
配置保存到你的账号,仅自己生效。保存后页面中仍使用旧默认值的行会自动更新为新值,手动修改过的行不受影响;之后的新的测算也按此填充。
{FIELD_DEFS.map(({ key, label, Input }) => (