|
|
|
@@ -21,6 +21,7 @@ const UserRatioSection = ({ userId }) => { |
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
const [addModalVisible, setAddModalVisible] = useState(false); |
|
|
|
const [channelOptions, setChannelOptions] = useState([]); |
|
|
|
const [modelOptions, setModelOptions] = useState([]); |
|
|
|
const formApiRef = useRef(null); |
|
|
|
|
|
|
|
const loadRatios = async () => { |
|
|
|
@@ -50,6 +51,7 @@ const UserRatioSection = ({ userId }) => { |
|
|
|
? `${ch.name} (${ch.remark})` |
|
|
|
: `${ch.name} (ID: ${ch.id})`, |
|
|
|
value: ch.id, |
|
|
|
models: (ch.models || '').split(',').map((m) => m.trim()).filter(Boolean), |
|
|
|
})); |
|
|
|
setChannelOptions(options); |
|
|
|
} else { |
|
|
|
@@ -190,12 +192,6 @@ const UserRatioSection = ({ userId }) => { |
|
|
|
getFormApi={(api) => (formApiRef.current = api)} |
|
|
|
onSubmit={handleAdd} |
|
|
|
> |
|
|
|
<Form.Input |
|
|
|
field='model_name' |
|
|
|
label={t('模型名称')} |
|
|
|
placeholder='gpt-4o' |
|
|
|
rules={[{ required: true, message: t('请输入模型名称') }]} |
|
|
|
/> |
|
|
|
<Form.Select |
|
|
|
field='channel_id' |
|
|
|
label={t('渠道')} |
|
|
|
@@ -205,6 +201,26 @@ const UserRatioSection = ({ userId }) => { |
|
|
|
showClear |
|
|
|
rules={[{ required: true, message: t('请选择渠道') }]} |
|
|
|
style={{ width: '100%' }} |
|
|
|
onChange={(val) => { |
|
|
|
formApiRef.current?.setValue('model_name', undefined); |
|
|
|
const selected = channelOptions.find((c) => c.value === val); |
|
|
|
if (selected?.models) { |
|
|
|
setModelOptions(selected.models.map((m) => ({ label: m, value: m }))); |
|
|
|
} else { |
|
|
|
setModelOptions([]); |
|
|
|
} |
|
|
|
}} |
|
|
|
/> |
|
|
|
<Form.Select |
|
|
|
field='model_name' |
|
|
|
label={t('模型')} |
|
|
|
placeholder={t('请选择模型')} |
|
|
|
optionList={modelOptions} |
|
|
|
filter |
|
|
|
showClear |
|
|
|
disabled={modelOptions.length === 0} |
|
|
|
rules={[{ required: true, message: t('请选择模型') }]} |
|
|
|
style={{ width: '100%' }} |
|
|
|
/> |
|
|
|
<Form.InputNumber |
|
|
|
field='ratio' |
|
|
|
|