Merge branch 'master' of gitee.com:youlaiorg/vue3-element-admin

This commit is contained in:
ray
2024-08-03 19:03:40 +08:00
6 changed files with 79 additions and 30 deletions

View File

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

View File

@@ -103,14 +103,26 @@ const modalConfig: IModalConfig<UserForm> = {
maxlength: 50, maxlength: 50,
}, },
}, },
// {
// label: "状态",
// prop: "status",
// type: "radio",
// options: [
// { label: "正常", value: 1 },
// { label: "禁用", value: 0 },
// ],
// initialValue: 1,
// },
{ {
label: "状态", label: "状态",
prop: "status", prop: "status",
type: "radio", type: "switch",
options: [ attrs: {
{ label: "正常", value: 1 }, activeText: "正常",
{ label: "禁用", value: 0 }, inactiveText: "禁用",
], activeValue: 1,
inactiveValue: 0,
},
initialValue: 1, initialValue: 1,
}, },
], ],

View File

@@ -107,14 +107,26 @@ const modalConfig: IModalConfig<UserForm> = {
maxlength: 50, maxlength: 50,
}, },
}, },
// {
// label: "状态",
// prop: "status",
// type: "radio",
// options: [
// { label: "正常", value: 1 },
// { label: "禁用", value: 0 },
// ],
// initialValue: 1,
// },
{ {
label: "状态", label: "状态123",
prop: "status", prop: "status",
type: "radio", type: "switch",
options: [ attrs: {
{ label: "正常", value: 1 }, activeText: "正常",
{ label: "禁用", value: 0 }, inactiveText: "禁用",
], activeValue: 1,
inactiveValue: 0,
},
}, },
], ],
}; };

View File

@@ -91,7 +91,8 @@
size="large" size="large"
class="w-full" class="w-full"
@click.prevent="handleLoginSubmit" @click.prevent="handleLoginSubmit"
>{{ $t("login.login") }} >
{{ $t("login.login") }}
</el-button> </el-button>
<!-- 账号密码提示 --> <!-- 账号密码提示 -->
@@ -155,6 +156,8 @@ const loginFormRef = ref<FormInstance>();
const loginData = ref<LoginData>({ const loginData = ref<LoginData>({
username: "admin", username: "admin",
password: "123456", password: "123456",
captchaKey: "",
captchaCode: "",
} as LoginData); } as LoginData);
const loginRules = computed(() => { const loginRules = computed(() => {

View File

@@ -28,13 +28,14 @@
clearable clearable
class="!w-[100px]" class="!w-[100px]"
> >
<el-option label="启用" value="1" /> <el-option label="正常" :value="1" />
<el-option label="禁用" value="0" /> <el-option label="禁用" :value="0" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="创建时间"> <el-form-item label="创建时间">
<el-date-picker <el-date-picker
:editable="false"
class="!w-[240px]" class="!w-[240px]"
v-model="queryParams.createTimeRange" v-model="queryParams.createTimeRange"
type="daterange" type="daterange"
@@ -105,7 +106,7 @@
label="编号" label="编号"
align="center" align="center"
prop="id" prop="id"
width="100" width="80"
/> />
<el-table-column <el-table-column
key="username" key="username"
@@ -113,12 +114,7 @@
align="center" align="center"
prop="username" prop="username"
/> />
<el-table-column <el-table-column label="用户昵称" align="center" prop="nickname" />
label="用户昵称"
width="120"
align="center"
prop="nickname"
/>
<el-table-column <el-table-column
label="性别" label="性别"
@@ -129,7 +125,7 @@
<el-table-column <el-table-column
label="部门" label="部门"
width="120" width="150"
align="center" align="center"
prop="deptName" prop="deptName"
/> />
@@ -140,10 +136,15 @@
width="120" width="120"
/> />
<el-table-column label="状态" align="center" prop="status"> <el-table-column
label="状态"
align="center"
prop="status"
width="100"
>
<template #default="scope"> <template #default="scope">
<el-tag :type="scope.row.status == 1 ? 'success' : 'info'"> <el-tag :type="scope.row.status == 1 ? 'success' : 'info'">
{{ scope.row.status == 1 ? "启用" : "禁用" }} {{ scope.row.status == 1 ? "正常" : "禁用" }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
@@ -268,10 +269,14 @@
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status"> <el-switch
<el-radio :value="1">正常</el-radio> v-model="formData.status"
<el-radio :value="0">禁用</el-radio> inline-prompt
</el-radio-group> active-text="正常"
inactive-text="禁用"
:active-value="1"
:inactive-value="0"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>