import { reactive, ref, UnwrapRef } from "vue";
import { FormState } from "./interface";

export function handleForm() {
    const formRef = ref();
    const formState: UnwrapRef<FormState> = reactive({
        price: 0,
        num: 0,
        goodsid: 0,
    })
    const rules = {
        price: [
            { require, message: '请输入挂牌价', trigger: 'blur', type: 'number' },
            { message: '挂牌价不能小于1', min: 1, type: 'number' }
        ],
        num: [
            { require, message: '请输入挂牌数量', trigger: 'blur', type: 'number' },
            { message: '挂牌数量小于1', min: 1, type: 'number' }
        ],
    }
    return { rules, formState, formRef }
}