<script lang="ts" setup>
import { useVbenDrawer } from '@vben/common-ui';

import { useVbenForm } from '#/adapter/form';

const [Drawer, drawerApi] = useVbenDrawer({
  onCancel() {
    drawerApi.close();
  },
  onOpenChange(isOpen: boolean) {
    if (isOpen) {
      const data = drawerApi.getData<any>();
      if (data) {
        console.warn(data);
      }
    }
  },
});

const [TemplateForm] = useVbenForm({
  // 所有表单项共用，可单独在表单内覆盖
  commonConfig: {
    // 所有表单项
    componentProps: {
      class: 'w-full',
    },
  },
  // 提交函数
  handleSubmit: onSubmit,
  // 垂直布局，label和input在不同行，值为vertical
  // 水平布局，label和input在同一行
  layout: 'horizontal',
  schema: [
    {
      component: 'InputNumber',

      componentProps: {
        placeholder: '请输入点位值',
      },

      fieldName: 'writeV',
      label: '请输入点位值',
      rules: 'required',
    },
  ],
  wrapperClass: 'grid-cols-1',
});

function onSubmit() {}
</script>
<template>
  <Drawer title="写值" :footer="false" class="w-[500px]">
    <div class="vp-raw w-full" style="height: 600px">
      <TemplateForm />
    </div>
  </Drawer>
</template>
