import { RuleObject } from "ant-design-vue/lib/form/interface"; // 验证 挂牌数量 /** * * @param delistingQty 起摘数量 * @param 挂牌数量对应的key * @param minivalue 最小单位 * @param maxValue 最大数量(可选) * @returns */ export const useVerifyListingNum = (formState: T, key: k, minivalue: number, maxValue?: number) => { const v_num = async (rule: RuleObject, value: number) => { if (value) { if (formState[key] && value < (formState[key] as unknown as number)) { return Promise.reject(`挂牌数量不能小于起摘数量`) } if (value < minivalue) { return Promise.reject(`挂牌数量不能小于${minivalue}`) } if (maxValue && value > maxValue) { return Promise.reject(`挂牌数量不能大于${maxValue}`) } if (value % minivalue) { return Promise.reject(`挂牌数量不是${minivalue}的倍数`) } return Promise.resolve(); } else { return Promise.reject('请输入挂牌数量') } }; return { v_num } }