<template>
    <BasicModal :useWrapper="true" @register="registerModal" @ok="ok" v-bind="$attrs" title="选择">
        <BasicForm @register="registerForm" />
    </BasicModal>
</template>
<script lang="ts" setup>
import { BasicModal, useModalInner } from '/@/components/Modal';
import { defineEmits } from 'vue';
import { FormSchema } from '/@/components/Table';
import { BasicForm, useForm } from '/@/components/Form/index';

const emit = defineEmits(['sumbitTable'])
const formSchema: FormSchema[] = [
    {
        field: 'ydzs',
        label: '总数',
        component: 'Input',
        required: true,
        dynamicRules: () => {
            return [
                { pattern: /^[1-9][0-9]*$/, message: '只能输入数字', required: true, },
            ];
        },
    },
    {
        field: 'pgtype',
        label: 'pgtype',
        component: 'Input',
        ifShow: () => false,
    },
    {
        field: 'scjdbm',
        label: '所处阶段编码',
        component: 'Input',
        ifShow: () => false,
    },
    {
        field: 'status',
        label: '状态',
        component: 'Input',
        ifShow: () => false,
    },
    {
        field: 'wrdkid',
        label: '污染地块id',
        component: 'Input',
        ifShow: () => false,
    },
    {
        field: 'ydlx',
        label: '样点类型',
        ifShow: () => false,
        component: 'Input',

    },
    {
        field: 'id',
        label: '主键',
        ifShow: () => false,
        component: 'Input',
    },
];
const [registerForm, { resetFields, setFieldsValue, getFieldsValue, updateSchema, validate }] = useForm({
    labelWidth: 100,
    schemas: formSchema,
    showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner((data) => {
    resetFields();
    setFieldsValue({
        ...data,
    });
})

async function ok() {
    let fromData = await getFieldsValue()
    emit('sumbitTable', fromData)
}
defineExpose({
    // save,
})

</script>
