refactor: ♻️ 增删改查的示例中状态更改为switch组件

增删改查的示例中状态更改为switch组件

closed #I9QEFC
This commit is contained in:
胡少翔
2024-08-02 10:51:19 +08:00
parent 0e85cb2dd5
commit af34b28016
4 changed files with 53 additions and 12 deletions

View File

@@ -66,6 +66,14 @@
</template>
</el-radio-group>
</template>
<!-- switch 开关 -->
<template v-else-if="item.type === 'switch'">
<el-switch
inline-prompt
v-model="formData[item.prop]"
v-bind="item.attrs"
/>
</template>
<!-- Checkbox 多选框 -->
<template v-else-if="item.type === 'checkbox'">
<el-checkbox-group
@@ -209,6 +217,14 @@
</template>
</el-radio-group>
</template>
<!-- switch 开关 -->
<template v-else-if="item.type === 'switch'">
<el-switch
inline-prompt
v-model="formData[item.prop]"
v-bind="item.attrs"
/>
</template>
<!-- Checkbox 多选框 -->
<template v-else-if="item.type === 'checkbox'">
<el-checkbox-group
@@ -334,7 +350,7 @@ prepareFuncs.forEach((func) => func());
// 获取表单数据
function getFormData(key?: string) {
return key === undefined ? formData : formData[key] ?? undefined;
return key === undefined ? formData : (formData[key] ?? undefined);
}
// 设置表单值

View File

@@ -220,6 +220,7 @@ export type IFormItems<T = any> = Array<{
| "input"
| "select"
| "radio"
| "switch"
| "checkbox"
| "tree-select"
| "date-picker"