|
|
@@ -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 {
|
|
|
@@ -47,33 +46,35 @@ export function handleForm(data: WrHoldLB) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const v_move = async (rule: RuleObject, value: number) => {
|
|
|
- console.log('formState', formState)
|
|
|
+ // 验证基差上下限
|
|
|
+ const v_basis = async (rule: RuleObject, value: number) => {
|
|
|
if (formState.goodsid) {
|
|
|
if (value) {
|
|
|
- return Promise.reject('请输入基差');
|
|
|
- }
|
|
|
- const goodsCode = getGoodsById(formState.goodsid)?.goodscode;
|
|
|
- if (goodsCode) {
|
|
|
+ const goodsCode = getGoodsById(formState.goodsid)?.goodscode as string;
|
|
|
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)
|
|
|
+ // 最小值 = 基差下限百分比 * 昨日收盘价 * -1
|
|
|
+ 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('没有合约商品');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -83,7 +84,7 @@ export function handleForm(data: WrHoldLB) {
|
|
|
FixedPrice: [{ required: true, message: '请输入挂牌价格', trigger: 'blur', type: 'number', min: 1, }],
|
|
|
DelistMinQty: [{ required: true, message: '请输入起摘数量', trigger: 'blur', type: 'number', min: 1, }],
|
|
|
OrderQty: [{ required: true, validator: v_num, trigger: 'blur', type: 'number' }],
|
|
|
- PriceMove: [{ required: true, validator: v_move, trigger: 'blur', type: 'number', }],
|
|
|
+ PriceMove: [{ required: true, validator: v_basis, trigger: 'blur', type: 'number', }],
|
|
|
goodsid: [{ required: true, validator: v_group, }],
|
|
|
}
|
|
|
Object.assign(rules, rule)
|