feat: now one channel can belong to multiple groups (close #153)

This commit is contained in:
JustSong
2023-06-14 12:14:08 +08:00
parent 38668e7331
commit 7f9577a386
2 changed files with 19 additions and 10 deletions

View File

@@ -15,8 +15,8 @@ const EditChannel = () => {
key: '',
base_url: '',
other: '',
group: 'default',
models: [],
groups: ['default']
};
const [batch, setBatch] = useState(false);
const [inputs, setInputs] = useState(originInputs);
@@ -37,6 +37,11 @@ const EditChannel = () => {
} else {
data.models = data.models.split(",")
}
if (data.group === "") {
data.groups = []
} else {
data.groups = data.group.split(",")
}
setInputs(data);
} else {
showError(message);
@@ -94,6 +99,7 @@ const EditChannel = () => {
}
let res;
localInputs.models = localInputs.models.join(",")
localInputs.group = localInputs.groups.join(",")
if (isEdit) {
res = await API.put(`/api/channel/`, { ...localInputs, id: parseInt(channelId) });
} else {
@@ -185,14 +191,14 @@ const EditChannel = () => {
<Form.Dropdown
label='分组'
placeholder={'请选择分组'}
name='group'
name='groups'
fluid
search
multiple
selection
allowAdditions
additionLabel={'请在系统设置页面编辑分组倍率以添加新的分组:'}
onChange={handleInputChange}
value={inputs.group}
value={inputs.groups}
autoComplete='new-password'
options={groupOptions}
/>