<template>
    <div style="min-height: 400px;background:">
        <BasicForm @register="registerFormulaForm" style="width:99%;">
        
        </BasicForm>
    </div>
</template>

<script lang="ts" name="metricMonitorSetForm" setup>
    import {BasicForm,FormSchema, useForm} from '/@/components/Form/index';
    import { propTypes } from '/@/utils/propTypes';
    
    const schemas:FormSchema[] =[{
        label: '参数',
        field: 'params',
        component: 'JSelectMetric',
        colProps: {lg: 24},
        itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
        componentProps: {
            rowKey: 'mtrcNo',
            labelKey: 'mtrcName',
        },
    },{
        label: "计算公式",
        field:"formulas",
        component:"InputTextArea",
        colProps: {lg: 24},
        itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
        componentProps: {
          rows: 8
        }
    }];

    const [registerFormulaForm, {appendSchemaByField, setFieldsValue, setProps, getFieldsValue,validate }] = useForm({
        labelWidth: 150,
        schemas,
        layout:'vertical',
        showActionButtonGroup: false,
        baseColProps: {span: 24}
    });

    async function setData(data) {
        await setFieldsValue(data);
    }


    async function getData() {
        let values = await validate();   
        return values;
    }

    defineExpose({
        setData,
        getData
    });

</script>