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

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

import { drawerFormSchema } from './config-data';

defineOptions({
  name: 'CreateTaskDrawer',
});

const [Form, formApi] = useVbenForm({
  schema: drawerFormSchema(),
  showDefaultActions: false,
});
const [Drawer, drawerApi] = useVbenDrawer({
  onCancel() {
    drawerApi.close();
  },
  onConfirm: async () => {
    await formApi.submitForm();
    drawerApi.close();
  },
  onOpenChange(isOpen: boolean) {
    if (isOpen) {
      const { values } = drawerApi.getData<Record<string, any>>();
      if (values) {
        formApi.setValues(values);
      }
    }
  },
  title: '油站新增任务',
});
</script>
<template>
  <Drawer>
    <Form>
      <!-- <template #attachment="scope">
        <ElUpload
          v-model:file-list="scope.attachment"
          action="#"
          accept=".jpg,.jpeg,.png,.gif,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx"
          list-type="text"
          show-file-list
          :auto-upload="true"
          :drag="false"
          :limit="5"
          :multiple="true"
          class="mb-4"
        >
          <div class="flex items-center justify-center">
            <ElIcon class="el-upload__icon">
              <Plus size="18" />
            </ElIcon>
            <div class="el-upload__text">
              <div>上传附件</div>
              <div class="text-xs text-gray-500">最多上传5个附件</div>
            </div>
          </div>
        </ElUpload>
      </template> -->
    </Form>
  </Drawer>
</template>
