From 1a5d32ee47a086247dec5cd7f3fde28700c6b187 Mon Sep 17 00:00:00 2001 From: zhang_12370 <z2864490065@outlook.com> Date: 星期三, 02 七月 2025 20:39:41 +0800 Subject: [PATCH] 提交设备管理模块 --- src/hooks/useModal.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git a/src/hooks/useModal.js b/src/hooks/useModal.js new file mode 100644 index 0000000..0d443a1 --- /dev/null +++ b/src/hooks/useModal.js @@ -0,0 +1,41 @@ +import { ref } from "vue"; +export function useModal(options) { + const id = ref(); + const visible = ref(false); + const loading = ref(false); + const modalOptions = ref({}); + + const openModal = (e) => { + id.value = e; + modalOptions.value = { + title: e ? `淇敼${options.title}` : `鏂板${options.title}`, + content: "纭畾鎵ц姝ゆ搷浣滃悧锛�", + confirmText: "纭畾", + cancelText: "鍙栨秷", + }; + visible.value = true; + }; + + // 鍏抽棴妯℃�佹 + const closeModal = () => { + visible.value = false; + loading.value = false; + }; + + // 纭鎿嶄綔 + const handleConfirm = async (callback) => { + loading.value = true; + callback(); + closeModal(); + }; + + return { + id, + visible, + loading, + modalOptions, + openModal, + closeModal, + handleConfirm, + }; +} -- Gitblit v1.9.3