Vue3 重构:统一 form 的样式

This commit is contained in:
YunaiV 2023-03-20 00:20:24 +08:00
parent 40bd2c57f8
commit c40de03302
6 changed files with 82 additions and 35 deletions

View File

@ -1,13 +1,20 @@
<template> <template>
<!-- 搜索 --> <!-- 搜索 -->
<content-wrap> <content-wrap>
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true"> <el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="参数名称" prop="name"> <el-form-item label="参数名称" prop="name">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.name"
placeholder="请输入参数名称" placeholder="请输入参数名称"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="参数键名" prop="key"> <el-form-item label="参数键名" prop="key">
@ -16,10 +23,16 @@
placeholder="请输入参数键名" placeholder="请输入参数键名"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="系统内置" prop="type"> <el-form-item label="系统内置" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择系统内置" clearable> <el-select
v-model="queryParams.type"
placeholder="请选择系统内置"
clearable
class="!w-240px"
>
<el-option <el-option
v-for="dict in getDictOptions(DICT_TYPE.INFRA_CONFIG_TYPE)" v-for="dict in getDictOptions(DICT_TYPE.INFRA_CONFIG_TYPE)"
:key="parseInt(dict.value)" :key="parseInt(dict.value)"
@ -36,6 +49,7 @@
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>

View File

@ -8,13 +8,8 @@
label-width="68px" label-width="68px"
> >
<el-form-item label="字典名称" prop="dictType"> <el-form-item label="字典名称" prop="dictType">
<el-select v-model="queryParams.dictType"> <el-select v-model="queryParams.dictType" class="!w-240px">
<el-option <el-option v-for="item in dicts" :key="item.type" :label="item.name" :value="item.type" />
v-for="item in simpleDictList"
:key="item.id"
:label="item.name"
:value="item.type"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="字典标签" prop="label"> <el-form-item label="字典标签" prop="label">
@ -23,10 +18,11 @@
placeholder="请输入字典标签" placeholder="请输入字典标签"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="数据状态" clearable> <el-select v-model="queryParams.status" placeholder="数据状态" clearable class="!w-240px">
<el-option <el-option
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :key="dict.value"
@ -111,18 +107,15 @@
</template> </template>
<script setup lang="ts" name="Data"> <script setup lang="ts" name="Data">
import * as DictDataApi from '@/api/system/dict/dict.data' import * as DictDataApi from '@/api/system/dict/dict.data'
import * as DictTypeApi from '@/api/system/dict/dict.data' import * as DictTypeApi from '@/api/system/dict/dict.type'
import { getDictOptions, DICT_TYPE } from '@/utils/dict' import { getDictOptions, DICT_TYPE } from '@/utils/dict'
import download from '@/utils/download' import download from '@/utils/download'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import DataForm from './data.form.vue' import DataForm from './data.form.vue'
import type { DictTypeVO } from '@/api/system/dict/dict.type'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
const route = useRoute() // const route = useRoute() //
const simpleDictList = ref<DictTypeVO[]>()
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
@ -135,6 +128,7 @@ const queryParams = reactive({
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const exportLoading = ref(false) //
const dicts = ref<DictTypeApi.DictTypeVO[]>() //
/** 查询参数列表 */ /** 查询参数列表 */
const getList = async () => { const getList = async () => {
@ -195,14 +189,14 @@ const handleExport = async () => {
} }
/** 查询字典(精简)列表 */ /** 查询字典(精简)列表 */
const getSimpleDictList = async () => { const getDictList = async () => {
simpleDictList.value = await DictTypeApi.listSimpleDictData() dicts.value = await DictTypeApi.listSimpleDictType()
} }
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getList() getList()
// ) // )
getSimpleDictList() getDictList()
}) })
</script> </script>

View File

@ -13,8 +13,8 @@
v-model="queryParams.name" v-model="queryParams.name"
placeholder="请输入字典名称" placeholder="请输入字典名称"
clearable clearable
style="width: 240px"
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="字典类型" prop="type"> <el-form-item label="字典类型" prop="type">
@ -22,17 +22,12 @@
v-model="queryParams.type" v-model="queryParams.type"
placeholder="请输入字典类型" placeholder="请输入字典类型"
clearable clearable
style="width: 240px"
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select <el-select v-model="queryParams.status" placeholder="字典状态" clearable class="!w-240px">
v-model="queryParams.status"
placeholder="字典状态"
clearable
style="width: 240px"
>
<el-option <el-option
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="parseInt(dict.value)" :key="parseInt(dict.value)"
@ -44,13 +39,13 @@
<el-form-item label="创建时间" prop="createTime"> <el-form-item label="创建时间" prop="createTime">
<el-date-picker <el-date-picker
v-model="queryParams.createTime" v-model="queryParams.createTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
type="daterange" type="daterange"
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>

View File

@ -1,17 +1,29 @@
<template> <template>
<content-wrap> <content-wrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true"> <el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="公告标题" prop="title"> <el-form-item label="公告标题" prop="title">
<el-input <el-input
v-model="queryParams.title" v-model="queryParams.title"
placeholder="请输入公告标题" placeholder="请输入公告标题"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="公告状态" prop="status"> <el-form-item label="公告状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择公告状态" clearable> <el-select
v-model="queryParams.status"
placeholder="请选择公告状态"
clearable
class="!w-240px"
>
<el-option <el-option
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="parseInt(dict.value)" :key="parseInt(dict.value)"

View File

@ -1,17 +1,29 @@
<template> <template>
<content-wrap> <content-wrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true"> <el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="90px"
>
<el-form-item label="用户编号" prop="userId"> <el-form-item label="用户编号" prop="userId">
<el-input <el-input
v-model="queryParams.userId" v-model="queryParams.userId"
placeholder="请输入用户编号" placeholder="请输入用户编号"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="用户类型" prop="userType"> <el-form-item label="用户类型" prop="userType">
<el-select v-model="queryParams.userType" placeholder="请选择用户类型" clearable> <el-select
v-model="queryParams.userType"
placeholder="请选择用户类型"
clearable
class="!w-240px"
>
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
:key="dict.value" :key="dict.value"
@ -26,6 +38,7 @@
placeholder="请输入客户端编号" placeholder="请输入客户端编号"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>

View File

@ -1,13 +1,20 @@
<template> <template>
<content-wrap> <content-wrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true"> <el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="系统模块" prop="module"> <el-form-item label="系统模块" prop="module">
<el-input <el-input
v-model="queryParams.module" v-model="queryParams.module"
placeholder="请输入系统模块" placeholder="请输入系统模块"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="操作人员" prop="userNickname"> <el-form-item label="操作人员" prop="userNickname">
@ -16,10 +23,16 @@
placeholder="请输入操作人员" placeholder="请输入操作人员"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="类型" prop="type"> <el-form-item label="操作类型" prop="type">
<el-select v-model="queryParams.type" placeholder="操作类型" clearable> <el-select
v-model="queryParams.type"
placeholder="请选择操作类型"
clearable
class="!w-240px"
>
<el-option <el-option
v-for="dict in getDictOptions(DICT_TYPE.SYSTEM_OPERATE_TYPE)" v-for="dict in getDictOptions(DICT_TYPE.SYSTEM_OPERATE_TYPE)"
:key="parseInt(dict.value)" :key="parseInt(dict.value)"
@ -28,8 +41,13 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="success"> <el-form-item label="操作状态" prop="success">
<el-select v-model="queryParams.success" placeholder="操作状态" clearable> <el-select
v-model="queryParams.success"
placeholder="请选择操作状态"
clearable
class="!w-240px"
>
<el-option :key="true" label="成功" :value="true" /> <el-option :key="true" label="成功" :value="true" />
<el-option :key="false" label="失败" :value="false" /> <el-option :key="false" label="失败" :value="false" />
</el-select> </el-select>
@ -42,6 +60,7 @@
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>