|
|
@@ -2,7 +2,7 @@ import { TradeMode } from '@/common/constants/enumCommon';
|
|
|
import { validateCommon } from '@/common/setup/validate';
|
|
|
import { handleForm as useForm } from '@/common/setup/warehouse_receipt_trade/listing';
|
|
|
import { useVerifyListingNum } from '@/hooks/form/verify';
|
|
|
-import { getGoodsGroupsByTradeMode, getIPOGoodsList, getQuoteDayInfoByCodeFindPrice } from '@/services/bus/goods';
|
|
|
+import { getGoodsGroupsByTradeMode, getIPOGoodsList, getGoodsById, getQuoteDayInfoByCodeFindPrice, getQuoteDayInfoByCode } from '@/services/bus/goods';
|
|
|
import { getRules } from '@/services/bus/rules';
|
|
|
import { Goods } from "@/services/go/ermcp/goodsInfo/interface";
|
|
|
import { WrHoldLB } from "@/services/go/wrtrade/interface";
|
|
|
@@ -39,19 +39,51 @@ 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 {
|
|
|
return Promise.reject('请选择商品')
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+ 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)
|
|
|
+
|
|
|
+ if (value < minValue) {
|
|
|
+ return Promise.reject(`基差下限不能小于${minValue}`);
|
|
|
+ }
|
|
|
+ if (value > maxValue) {
|
|
|
+ return Promise.reject(`基差上限不能大于${maxValue}`);
|
|
|
+ }
|
|
|
+ return Promise.resolve();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Promise.reject('没有商品合约');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
const { v_num } = useVerifyListingNum<ListingForm, 'DelistMinQty'>(formState, 'DelistMinQty', minivalue, enableqty)
|
|
|
|
|
|
const rule = {
|
|
|
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, message: '请输入升贴水', trigger: 'blur', type: 'number', }],
|
|
|
+ PriceMove: [{ required: true, validator: v_move, trigger: 'blur', type: 'number', }],
|
|
|
goodsid: [{ required: true, validator: v_group, }],
|
|
|
}
|
|
|
Object.assign(rules, rule)
|