<script lang="ts" setup>
import { ref } from 'vue';

// @ts-ignore
import { useVbenDrawer } from '@vben/common-ui';

// 导入工单创建组件
import CreatOrder from '#/views/workflow/order/creatOrder.vue';

// 接收props参数
const props = defineProps<{
  id?: string;
}>();

// 定义emit事件
const emit = defineEmits<{
  close: [];
}>();

// 工单创建组件引用
const creatOrderRef = ref();

const [Drawer, drawerApi] = useVbenDrawer({
  showCancelButton: false,
  showConfirmButton: false,
  onCancel() {
    drawerApi.close();
  },
  onConfirm: async () => {
    // 调用工单创建组件的提交方法
    if (creatOrderRef.value) {
      await creatOrderRef.value.handleSubmit();
      // 关闭抽屉
      drawerApi.close();
    }
  },
  title: '工单提报',
});
</script>

<template>
  <Drawer title="工单提报">
    <div class="wrap">
      <CreatOrder ref="creatOrderRef" />
    </div>
  </Drawer>
</template>

<style lang="scss" scoped>
.wrap {
  padding: 16px;
  background-color: #fff;
  border-radius: 6px;
}
</style>
