refactor: 全部改用vben模态框

This commit is contained in:
ah--desktop
2025-11-10 00:10:08 +08:00
parent 5e0a085648
commit 8547e0714a
19 changed files with 401 additions and 292 deletions
@@ -3,7 +3,9 @@ import type { PositionVO } from '#/api/organization/position';
import { computed, ref } from 'vue';
import { Form, Input, message, Modal, Select, Switch } from 'ant-design-vue';
import { useVbenModal } from '@vben/common-ui';
import { Form, Input, message, Select, Switch } from 'ant-design-vue';
import {
createPositionApi,
@@ -22,10 +24,21 @@ defineProps<Props>();
const emit = defineEmits<Emits>();
// 创建 vben modal
const [Modal, modalApi] = useVbenModal({
draggable: true,
class: 'w-[500px]',
onCancel() {
handleCancel();
},
onConfirm() {
handleSubmit();
},
});
// 响应式数据
const formRef = ref();
const loading = ref(false);
const visible = ref(false);
const isEdit = ref(false);
const currentPositionData = ref<null | PositionVO.PositionInfoVO>(null);
@@ -66,7 +79,7 @@ function resetForm() {
// 处理模态框关闭
function handleCancel() {
visible.value = false;
modalApi.close();
}
// 处理表单提交
@@ -89,8 +102,8 @@ async function handleSubmit() {
message.success('创建成功');
}
visible.value = false;
emit('success');
modalApi.close();
} catch (error) {
console.error('保存岗位失败:', error);
message.error('保存岗位失败');
@@ -119,7 +132,7 @@ function open(
};
}
visible.value = true;
modalApi.open();
}
// 暴露方法给父组件
@@ -129,14 +142,7 @@ defineExpose({
</script>
<template>
<Modal
:open="visible"
:title="modalTitle"
width="500px"
:confirm-loading="loading"
@ok="handleSubmit"
@cancel="handleCancel"
>
<Modal :title="modalTitle" :confirm-loading="loading">
<Form
ref="formRef"
:model="formData"