From af34b28016d95c420aff0368f243524f1c3e4eee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=83=A1=E5=B0=91=E7=BF=94?= <971366405@qq.com>
Date: Fri, 2 Aug 2024 10:51:19 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20:recycle:=20=E5=A2=9E=E5=88=A0?=
=?UTF-8?q?=E6=94=B9=E6=9F=A5=E7=9A=84=E7=A4=BA=E4=BE=8B=E4=B8=AD=E7=8A=B6?=
=?UTF-8?q?=E6=80=81=E6=9B=B4=E6=94=B9=E4=B8=BAswitch=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
增删改查的示例中状态更改为switch组件
closed #I9QEFC
---
src/components/CURD/PageModal.vue | 18 +++++++++++++++++-
src/components/CURD/types.ts | 1 +
src/views/demo/curd/config/add.ts | 22 +++++++++++++++++-----
src/views/demo/curd/config/edit.ts | 24 ++++++++++++++++++------
4 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/src/components/CURD/PageModal.vue b/src/components/CURD/PageModal.vue
index 3d53e394..37854c11 100644
--- a/src/components/CURD/PageModal.vue
+++ b/src/components/CURD/PageModal.vue
@@ -66,6 +66,14 @@
+
+
+
+
+
+
+
+
func());
// 获取表单数据
function getFormData(key?: string) {
- return key === undefined ? formData : formData[key] ?? undefined;
+ return key === undefined ? formData : (formData[key] ?? undefined);
}
// 设置表单值
diff --git a/src/components/CURD/types.ts b/src/components/CURD/types.ts
index 97f4d834..229dc0bb 100644
--- a/src/components/CURD/types.ts
+++ b/src/components/CURD/types.ts
@@ -220,6 +220,7 @@ export type IFormItems = Array<{
| "input"
| "select"
| "radio"
+ | "switch"
| "checkbox"
| "tree-select"
| "date-picker"
diff --git a/src/views/demo/curd/config/add.ts b/src/views/demo/curd/config/add.ts
index 023548c4..38bcf59d 100644
--- a/src/views/demo/curd/config/add.ts
+++ b/src/views/demo/curd/config/add.ts
@@ -103,14 +103,26 @@ const modalConfig: IModalConfig = {
maxlength: 50,
},
},
+ // {
+ // label: "状态",
+ // prop: "status",
+ // type: "radio",
+ // options: [
+ // { label: "正常", value: 1 },
+ // { label: "禁用", value: 0 },
+ // ],
+ // initialValue: 1,
+ // },
{
label: "状态",
prop: "status",
- type: "radio",
- options: [
- { label: "正常", value: 1 },
- { label: "禁用", value: 0 },
- ],
+ type: "switch",
+ attrs: {
+ activeText: "正常",
+ inactiveText: "禁用",
+ activeValue: 1,
+ inactiveValue: 0,
+ },
initialValue: 1,
},
],
diff --git a/src/views/demo/curd/config/edit.ts b/src/views/demo/curd/config/edit.ts
index 983546a4..bbcf2cb1 100644
--- a/src/views/demo/curd/config/edit.ts
+++ b/src/views/demo/curd/config/edit.ts
@@ -107,14 +107,26 @@ const modalConfig: IModalConfig = {
maxlength: 50,
},
},
+ // {
+ // label: "状态",
+ // prop: "status",
+ // type: "radio",
+ // options: [
+ // { label: "正常", value: 1 },
+ // { label: "禁用", value: 0 },
+ // ],
+ // initialValue: 1,
+ // },
{
- label: "状态",
+ label: "状态123",
prop: "status",
- type: "radio",
- options: [
- { label: "正常", value: 1 },
- { label: "禁用", value: 0 },
- ],
+ type: "switch",
+ attrs: {
+ activeText: "正常",
+ inactiveText: "禁用",
+ activeValue: 1,
+ inactiveValue: 0,
+ },
},
],
};