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

export function handleForm() {
    const formRef = ref();
    const formState: UnwrapRef<FormState> = reactive({
        accountid: undefined,
        num: 0,
        price: 0,
    })
    const rules = {
        accountid: [{ required: true, message: '请选择交易账户' }],
        num: [
            { required: true, message: '请输入挂牌数量', trigger: 'blur', type: 'number' },
            { message: '挂牌数量不能小于0', min: 1, type: 'number' }
        ],
        price: [
            { required: true, message: '请输入挂牌价格', trigger: 'blur', type: 'number' },
            { message: '挂牌价格不能小于0', min: 1, type: 'number' }
        ],

    }
    return { rules, formState, formRef }

}
