mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 21:49:19 +08:00
refactor: 全部改用vben模态框
This commit is contained in:
+28
-19
@@ -6,7 +6,9 @@ import type {
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { Form, Input, message, Modal, Select } from 'ant-design-vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
super_createAccountApi,
|
||||
@@ -21,10 +23,21 @@ defineOptions({ name: 'SuperAccountFormModal' });
|
||||
|
||||
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 currentAccountData = ref<null | SuperAccountVO.AccountInfoVO>(null);
|
||||
|
||||
@@ -76,7 +89,7 @@ function resetForm() {
|
||||
|
||||
// 处理模态框关闭
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
// 暴露给父组件的方法
|
||||
@@ -102,7 +115,7 @@ function open(accountData?: null | SuperAccountVO.AccountInfoVO) {
|
||||
};
|
||||
}
|
||||
|
||||
visible.value = true;
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
// 处理表单提交
|
||||
@@ -120,8 +133,8 @@ async function handleSubmit() {
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
visible.value = false;
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
} catch (error: any) {
|
||||
console.error('保存账户失败:', error);
|
||||
const errorMessage =
|
||||
@@ -132,12 +145,15 @@ async function handleSubmit() {
|
||||
}
|
||||
}
|
||||
|
||||
// 监听弹窗关闭
|
||||
watch(visible, (val) => {
|
||||
if (!val) {
|
||||
resetForm();
|
||||
}
|
||||
});
|
||||
// 监听 modal 关闭状态
|
||||
watch(
|
||||
() => modalApi.useStore()?.value?.isOpen,
|
||||
(newVal) => {
|
||||
if (!newVal) {
|
||||
resetForm();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
@@ -146,14 +162,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"
|
||||
|
||||
+28
-19
@@ -3,7 +3,9 @@ import type { AccountDTO, AccountVO } from '#/api/organization/account';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { Form, Input, message, Modal, Select } from 'ant-design-vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
admin_createAccountApi,
|
||||
@@ -18,10 +20,21 @@ defineOptions({ name: 'AccountFormModal' });
|
||||
|
||||
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 currentAccountData = ref<AccountVO.AccountInfoVO | null>(null);
|
||||
|
||||
@@ -67,7 +80,7 @@ function resetForm() {
|
||||
|
||||
// 处理模态框关闭
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
// 暴露给父组件的方法
|
||||
@@ -91,7 +104,7 @@ function open(accountData?: AccountVO.AccountInfoVO | null) {
|
||||
};
|
||||
}
|
||||
|
||||
visible.value = true;
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
// 处理表单提交
|
||||
@@ -109,8 +122,8 @@ async function handleSubmit() {
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
visible.value = false;
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
} catch (error: any) {
|
||||
console.error('保存账户失败:', error);
|
||||
const errorMessage =
|
||||
@@ -121,12 +134,15 @@ async function handleSubmit() {
|
||||
}
|
||||
}
|
||||
|
||||
// 监听弹窗关闭
|
||||
watch(visible, (val) => {
|
||||
if (!val) {
|
||||
resetForm();
|
||||
}
|
||||
});
|
||||
// 监听 modal 关闭状态
|
||||
watch(
|
||||
() => modalApi.useStore()?.value?.isOpen,
|
||||
(newVal) => {
|
||||
if (!newVal) {
|
||||
resetForm();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
@@ -135,14 +151,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"
|
||||
|
||||
+17
-13
@@ -3,6 +3,7 @@ import type { CompanyDTO, CompanyVO } from '#/api/organization/company';
|
||||
|
||||
import { computed, onUnmounted, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import {
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
Form,
|
||||
Input,
|
||||
message,
|
||||
Modal,
|
||||
Switch,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -28,11 +28,22 @@ interface Emits {
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[600px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleSubmit();
|
||||
},
|
||||
});
|
||||
|
||||
// 创建相机图标组件
|
||||
const CameraIcon = createIconifyIcon('mdi:camera');
|
||||
|
||||
// 内部状态管理
|
||||
const visible = ref(false);
|
||||
const isEdit = ref(false);
|
||||
const currentCompanyData = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||
|
||||
@@ -169,8 +180,8 @@ async function handleSubmit() {
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
visible.value = false;
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
} catch (error) {
|
||||
console.error('保存公司失败:', error);
|
||||
message.error('保存公司失败');
|
||||
@@ -181,7 +192,7 @@ async function handleSubmit() {
|
||||
|
||||
// 处理取消
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
// 暴露给父组件的方法
|
||||
@@ -195,7 +206,7 @@ function open(
|
||||
resetForm(); // 先重置表单
|
||||
initFormData(); // 再初始化数据
|
||||
|
||||
visible.value = true;
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
// 暴露方法给父组件
|
||||
@@ -281,14 +292,7 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
:open="visible"
|
||||
:title="modalTitle"
|
||||
width="600px"
|
||||
:confirm-loading="loading"
|
||||
@ok="handleSubmit"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<Modal :title="modalTitle" :confirm-loading="loading">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
|
||||
+19
-13
@@ -3,7 +3,9 @@ import type { DepartmentVO } from '#/api/organization/department';
|
||||
|
||||
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 {
|
||||
createDepartmentApi,
|
||||
@@ -22,10 +24,21 @@ const props = 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 currentDepartmentData = ref<DepartmentVO.DepartmentInfoVO | null>(null);
|
||||
|
||||
@@ -114,7 +127,7 @@ function resetForm() {
|
||||
|
||||
// 处理模态框关闭
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
// 处理表单提交
|
||||
@@ -137,8 +150,8 @@ async function handleSubmit() {
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
visible.value = false;
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
} catch (error) {
|
||||
console.error('保存部门失败:', error);
|
||||
message.error('保存部门失败');
|
||||
@@ -166,7 +179,7 @@ function open(
|
||||
};
|
||||
}
|
||||
|
||||
visible.value = true;
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
// 暴露方法给父组件
|
||||
@@ -176,14 +189,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"
|
||||
|
||||
+19
-13
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user