fix: route target can be set 0

This commit is contained in:
jialin
2026-03-10 19:06:49 +08:00
parent 972e147fdf
commit 353ee3a9ae
+9 -8
View File
@@ -139,11 +139,12 @@ const TargetsForm = forwardRef((props, ref) => {
}; };
const handleOnWeightChange = (value: any, index: number) => { const handleOnWeightChange = (value: any, index: number) => {
const weight = value || 0;
const targetList = [...targets]; const targetList = [...targets];
if (targetList[index]) { if (targetList[index]) {
targetList[index] = { targetList[index] = {
...targetList[index], ...targetList[index],
weight: value weight: weight
}; };
form.setFieldValue('targets', [...targetList]); form.setFieldValue('targets', [...targetList]);
} }
@@ -151,7 +152,7 @@ const TargetsForm = forwardRef((props, ref) => {
const newDataList = [...dataList]; const newDataList = [...dataList];
newDataList[index] = { newDataList[index] = {
...newDataList[index], ...newDataList[index],
weight: value weight: weight
}; };
form.validateFields(['targets']); form.validateFields(['targets']);
setDataList(newDataList); setDataList(newDataList);
@@ -256,12 +257,12 @@ const TargetsForm = forwardRef((props, ref) => {
{ {
validator(rule, value) { validator(rule, value) {
if (value && value?.length > 0) { if (value && value?.length > 0) {
if (_.some(value, (item: any) => !item.weight)) { // if (_.some(value, (item: any) => !item.weight)) {
setValidTriggered(true); // setValidTriggered(true);
return Promise.reject( // return Promise.reject(
getRuleMessage('input', 'routes.form.target.weight') // getRuleMessage('input', 'routes.form.target.weight')
); // );
} // }
if ( if (
_.some( _.some(