parent
6a7e914a41
commit
283e8e2ab4
@ -0,0 +1,196 @@
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Radio,
|
||||
Form,
|
||||
InputNumber,
|
||||
Input,
|
||||
Select,
|
||||
Checkbox,
|
||||
} from '@arco-design/web-react';
|
||||
import { IconInfoCircle } from '@arco-design/web-react/icon';
|
||||
|
||||
import type { UploadItem } from '@arco-design/web-react/es/Upload';
|
||||
|
||||
export interface SongInfoItemProps {
|
||||
originNode?: React.ReactNode;
|
||||
file?: UploadItem;
|
||||
fileList?: UploadItem[];
|
||||
}
|
||||
|
||||
const { Item: FormItem, useForm, useWatch } = Form;
|
||||
const RadioGroup = Radio.Group;
|
||||
const { TextArea } = Input;
|
||||
|
||||
const AlbumTypeOpt = [
|
||||
{
|
||||
label: '录音室',
|
||||
value: 'recordingStudio',
|
||||
},
|
||||
{
|
||||
label: 'Live',
|
||||
value: 'live',
|
||||
},
|
||||
{
|
||||
label: 'Demo',
|
||||
value: 'demo',
|
||||
},
|
||||
{
|
||||
label: '伴奏',
|
||||
value: 'accompaniment',
|
||||
},
|
||||
{
|
||||
label: '其它',
|
||||
value: 'other',
|
||||
},
|
||||
];
|
||||
|
||||
const IsChargeOpt = [
|
||||
{
|
||||
label: '收费',
|
||||
value: 'charge',
|
||||
},
|
||||
{
|
||||
label: '免费',
|
||||
value: 'free',
|
||||
},
|
||||
];
|
||||
|
||||
export default function SongInfoItem(props: SongInfoItemProps) {
|
||||
const { originNode, file, fileList } = props || {};
|
||||
const [form] = useForm();
|
||||
const [iamLyricist, setIamLyricist] = useState(false); // 我是作词人?
|
||||
const [iamComposer, setIamComposer] = useState(false); // 我是作曲人?
|
||||
const fileName = useMemo(() => file?.name, [file?.name]);
|
||||
const filedNames = useMemo(
|
||||
() => ({
|
||||
albumType: `${fileName}.albumType`,
|
||||
isCharge: `${fileName}.isCharge`,
|
||||
songPricing: `${fileName}.songPricing`,
|
||||
singer: `${fileName}.singer`,
|
||||
songStyle: `${fileName}.songStyle`,
|
||||
language: `${fileName}.language`,
|
||||
lyricist: `${fileName}.lyricist`,
|
||||
composer: `${fileName}.composer`,
|
||||
lyric: `${fileName}.lyric`,
|
||||
}),
|
||||
[fileName]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<FormItem
|
||||
label="专辑类型"
|
||||
field={filedNames.albumType}
|
||||
initialValue={AlbumTypeOpt[0].value}
|
||||
rules={[{ required: true, message: '请选择专辑类型' }]}
|
||||
>
|
||||
<RadioGroup options={AlbumTypeOpt} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="是否收费"
|
||||
field={filedNames.isCharge}
|
||||
initialValue={IsChargeOpt[0].value}
|
||||
rules={[{ required: true, message: '请选择是否收费' }]}
|
||||
>
|
||||
<RadioGroup options={IsChargeOpt} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="歌曲定价"
|
||||
field={filedNames.songPricing}
|
||||
rules={[{ required: true, message: '请输入歌曲定价' }]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0.01}
|
||||
suffix="元"
|
||||
step={1}
|
||||
placeholder="请输入专辑价格"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="歌手名称"
|
||||
field={filedNames.singer}
|
||||
rules={[{ required: true, message: '请输入歌手名称' }]}
|
||||
>
|
||||
<Input
|
||||
allowClear
|
||||
suffix={<IconInfoCircle />}
|
||||
placeholder="请输入歌手名称"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="曲风"
|
||||
field={filedNames.songStyle}
|
||||
rules={[{ required: true, message: '请选择曲风' }]}
|
||||
>
|
||||
<Select
|
||||
mode="multiple"
|
||||
placeholder="请选择曲风"
|
||||
allowClear
|
||||
options={[
|
||||
{ label: '后摇', value: '1' },
|
||||
{ label: '后朋克', value: '2' },
|
||||
]}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="语种"
|
||||
field={filedNames.language}
|
||||
rules={[{ required: true, message: '请选择语种' }]}
|
||||
>
|
||||
<Select
|
||||
placeholder="请选择语种"
|
||||
allowClear
|
||||
options={[
|
||||
{ label: '中文', value: '1' },
|
||||
{ label: '英文', value: '2' },
|
||||
]}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="作词"
|
||||
field={filedNames.lyricist}
|
||||
rules={[{ required: true, message: '请输入作词人' }]}
|
||||
>
|
||||
<Input
|
||||
allowClear
|
||||
suffix={
|
||||
<Checkbox
|
||||
checked={iamLyricist}
|
||||
onChange={(checked) => {
|
||||
setIamLyricist(checked);
|
||||
form?.setFieldValue('lyricist', checked ? 'me' : undefined); // TODO:
|
||||
}}
|
||||
>
|
||||
我是作词人
|
||||
</Checkbox>
|
||||
}
|
||||
placeholder="请输入"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="作曲"
|
||||
field={filedNames.composer}
|
||||
rules={[{ required: true, message: '请输入作曲人' }]}
|
||||
>
|
||||
<Input
|
||||
allowClear
|
||||
suffix={
|
||||
<Checkbox
|
||||
checked={iamComposer}
|
||||
onChange={(checked) => {
|
||||
setIamComposer(checked);
|
||||
form?.setFieldValue('composer', checked ? 'me' : undefined); // TODO:
|
||||
}}
|
||||
>
|
||||
我是作曲人
|
||||
</Checkbox>
|
||||
}
|
||||
placeholder="请输入"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="歌词" field={filedNames.lyric}>
|
||||
<TextArea allowClear placeholder="请输入歌词,注意断句换行" rows={3} />
|
||||
</FormItem>
|
||||
</>
|
||||
);
|
||||
}
|
Loading…
Reference in new issue