From f120467fc87bc0bcb2eb84198cc6caa6407d1b0b Mon Sep 17 00:00:00 2001
From: hb0730 <1278032416@qq.com>
Date: Thu, 4 Apr 2024 22:14:24 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=87=BD=E6=95=B0=E5=BC=8F=E5=BC=B9?=
=?UTF-8?q?=E6=A1=86`ReDialog`=E6=B7=BB=E5=8A=A0`Popconfirm`=E6=B0=94?=
=?UTF-8?q?=E6=B3=A1=E7=A1=AE=E8=AE=A4=E6=A1=86=20(#1046)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/ReDialog/index.vue | 42 ++++++++++++++++++---------
src/components/ReDialog/type.ts | 39 +++++++++++++++++++++++++
src/views/components/dialog/index.vue | 11 +++++++
3 files changed, 79 insertions(+), 13 deletions(-)
diff --git a/src/components/ReDialog/index.vue b/src/components/ReDialog/index.vue
index e7fb2f108..ba9ba1d00 100644
--- a/src/components/ReDialog/index.vue
+++ b/src/components/ReDialog/index.vue
@@ -37,6 +37,7 @@ const footerButtons = computed(() => {
type: "primary",
text: true,
bg: true,
+ popconfirm: options?.popconfirm,
btnClick: ({ dialog: { options, index } }) => {
const done = () =>
closeDialog(options, index, { command: "sure" });
@@ -149,19 +150,34 @@ function handleClose(
-
- {{ btn?.label }}
-
+
+
+
+ {{ btn?.label }}
+
+
+
+ {{ btn?.label }}
+
+
diff --git a/src/components/ReDialog/type.ts b/src/components/ReDialog/type.ts
index 827e8c7df..4cc747688 100644
--- a/src/components/ReDialog/type.ts
+++ b/src/components/ReDialog/type.ts
@@ -11,6 +11,13 @@ type ArgsType = {
/** `cancel` 点击取消按钮、`sure` 点击确定按钮、`close` 点击右上角关闭按钮或空白页或按下了esc键 */
command: "cancel" | "sure" | "close";
};
+type ButtonType =
+ | "primary"
+ | "success"
+ | "warning"
+ | "danger"
+ | "info"
+ | "text";
/** https://element-plus.org/zh-CN/component/dialog.html#attributes */
type DialogProps = {
@@ -58,6 +65,34 @@ type DialogProps = {
destroyOnClose?: boolean;
};
+//element-plus.org/zh-CN/component/popconfirm.html#attributes
+type Popconfirm = {
+ /** 标题 */
+ title?: string;
+ /** 确认按钮文字 */
+ confirmButtonText?: string;
+ /** 取消按钮文字 */
+ cancelButtonText?: string;
+ /** 确认按钮类型,默认 `primary` */
+ confirmButtonType?: ButtonType;
+ /** 取消按钮类型,默认 `text` */
+ cancelButtonType?: ButtonType;
+ /** 自定义图标,默认 `QuestionFilled` */
+ icon?: string | Component;
+ /** `Icon` 颜色,默认 `#f90` */
+ iconColor?: string;
+ /** 是否隐藏 `Icon`,默认 `false` */
+ hideIcon?: boolean;
+ /** 关闭时的延迟,默认 `200` */
+ hideAfter?: number;
+ /** 是否将 `popover` 的下拉列表插入至 `body` 元素,默认 `true` */
+ teleported?: boolean;
+ /** 当 `popover` 组件长时间不触发且 `persistent` 属性设置为 `false` 时, `popover` 将会被删除,默认 `false` */
+ persistent?: boolean;
+ /** 弹层宽度,最小宽度 `150px`,默认 `150` */
+ width?: string | number;
+};
+
type BtnClickDialog = {
options?: DialogOptions;
index?: number;
@@ -86,6 +121,8 @@ type ButtonProps = {
round?: boolean;
/** 是否为圆形按钮,默认 `false` */
circle?: boolean;
+ /** 确认按钮的 `Popconfirm` 气泡确认框相关配置 */
+ popconfirm?: Popconfirm;
/** 是否为加载中状态,默认 `false` */
loading?: boolean;
/** 自定义加载中状态图标组件 */
@@ -123,6 +160,8 @@ interface DialogOptions extends DialogProps {
props?: any;
/** 是否隐藏 `Dialog` 按钮操作区的内容 */
hideFooter?: boolean;
+ /** 确认按钮的 `Popconfirm` 气泡确认框相关配置 */
+ popconfirm?: Popconfirm;
/**
* @description 自定义对话框标题的内容渲染器
* @see {@link https://element-plus.org/zh-CN/component/dialog.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%A4%B4%E9%83%A8}
diff --git a/src/views/components/dialog/index.vue b/src/views/components/dialog/index.vue
index 1a3be82b1..dda1a57c1 100644
--- a/src/views/components/dialog/index.vue
+++ b/src/views/components/dialog/index.vue
@@ -280,6 +280,16 @@ function onUpdateClick() {
});
}
+// popconfirm 确认框
+function onPopconfirmClick() {
+ addDialog({
+ width: "30%",
+ title: "popconfirm确认框示例",
+ popconfirm: { title: "是否确认修改当前数据" },
+ contentRenderer: () =>
点击右下方确定按钮看看效果吧
+ });
+}
+
// 结合Form表单(第一种方式,弹框关闭立刻恢复初始值)通过 props 属性接收子组件的 prop 并赋值
function onFormOneClick() {
addDialog({
@@ -496,6 +506,7 @@ function onBeforeSureClick() {
关闭后的回调
嵌套的弹框
更改弹框自身属性值
+ popconfirm确认框