<template>
  <BzDrawer v-bind="$attrs" @register="register" title="Drawer Title" width="50%">
    <div>
      <BzForm @register="registerForm" />
    </div>
  </BzDrawer>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { BzDrawer, useDrawerInner } from '/@/index';

  import { BzForm, FormSchema, useForm } from '/@/index';
  const schemas: FormSchema[] = [
    {
      field: 'field1',
      component: 'Input',
      label: '字段1',
      colProps: {
        span: 12,
      },
      defaultValue: '111',
    },
    {
      field: 'field2',
      component: 'Input',
      label: '字段2',
      colProps: {
        span: 12,
      },
    },
  ];
  export default defineComponent({
    components: { BzDrawer, BzForm },
    setup() {
      const [registerForm, { setFieldsValue }] = useForm({
        labelWidth: 120,
        schemas,
        showActionButtonGroup: false,
        actionColOptions: {
          span: 24,
        },
      });
      const [register] = useDrawerInner((data) => {
        // 方式1
        setFieldsValue({
          field2: data.data,
          field1: data.info,
        });
      });
      return { register, schemas, registerForm };
    },
  });
</script>
