|
|
@@ -39,7 +39,6 @@ export function handleForm(data: WrHoldLB) {
|
|
|
const { rules, formRef } = useForm();
|
|
|
|
|
|
const v_group = async (rule: RuleObject, value: number) => {
|
|
|
- console.log('formState', formState)
|
|
|
if (formState.goodsgroupid) {
|
|
|
return validateCommon(value, '请选择合约');
|
|
|
} else {
|
|
|
@@ -48,32 +47,33 @@ export function handleForm(data: WrHoldLB) {
|
|
|
};
|
|
|
|
|
|
const v_move = async (rule: RuleObject, value: number) => {
|
|
|
- console.log('formState', formState)
|
|
|
if (formState.goodsid) {
|
|
|
if (value) {
|
|
|
- return Promise.reject('请输入基差');
|
|
|
- }
|
|
|
- const goodsCode = getGoodsById(formState.goodsid)?.goodscode;
|
|
|
- if (goodsCode) {
|
|
|
- const quote = getQuoteDayInfoByCode(goodsCode);
|
|
|
- if (quote) {
|
|
|
- const { basisdownratio, basisupratio } = getRules()[0];
|
|
|
- const minValue = basisdownratio * quote.presettle;
|
|
|
- const maxValue = basisupratio * quote.presettle * -1;
|
|
|
-
|
|
|
- console.log(basisdownratio, basisupratio)
|
|
|
+ const goodsCode = getGoodsById(formState.goodsid)?.goodscode;
|
|
|
+ if (goodsCode) {
|
|
|
+ const quote = getQuoteDayInfoByCode(goodsCode);
|
|
|
+ if (quote) {
|
|
|
+ const { basisdownratio, basisupratio } = getRules()[0];
|
|
|
+ const minValue = basisdownratio * quote.presettle * -1;
|
|
|
+ const maxValue = basisupratio * quote.presettle;
|
|
|
|
|
|
- if (value < minValue) {
|
|
|
- return Promise.reject(`基差下限不能小于${minValue}`);
|
|
|
+ if (value > minValue && value < maxValue) {
|
|
|
+ return Promise.resolve();
|
|
|
+ } else {
|
|
|
+ if (value < minValue) {
|
|
|
+ return Promise.reject(`基差下限不能小于${minValue.toFixed(2)}`);
|
|
|
+ }
|
|
|
+ if (value > maxValue) {
|
|
|
+ return Promise.reject(`基差上限不能大于${maxValue.toFixed(2)}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if (value > maxValue) {
|
|
|
- return Promise.reject(`基差上限不能大于${maxValue}`);
|
|
|
- }
|
|
|
- return Promise.resolve();
|
|
|
}
|
|
|
+ } else {
|
|
|
+ return Promise.reject('请输入基差');
|
|
|
}
|
|
|
} else {
|
|
|
- return Promise.reject('没有商品合约');
|
|
|
+ return Promise.reject('没有合约商品');
|
|
|
}
|
|
|
}
|
|
|
|