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>
</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"

View File

@@ -103,14 +103,26 @@ const modalConfig: IModalConfig<UserForm> = {
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,
},
],

View File

@@ -107,14 +107,26 @@ const modalConfig: IModalConfig<UserForm> = {
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,
},
},
],
};

View File

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

View File

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