1. 优化 Dialog 组件,增加 scroll 标识滚动

2. 优化配置管理的 :default-time 设置
pull/24/head
YunaiV 2023-03-09 19:36:57 +08:00
parent 0ea6b1b749
commit 74846a11bd
3 changed files with 30 additions and 29 deletions

View File

@ -8,8 +8,9 @@ const props = defineProps({
modelValue: propTypes.bool.def(false),
title: propTypes.string.def('Dialog'),
fullscreen: propTypes.bool.def(true),
maxHeight: propTypes.oneOfType([String, Number]).def('300px'),
width: propTypes.oneOfType([String, Number]).def('40%')
width: propTypes.oneOfType([String, Number]).def('40%'),
scroll: propTypes.bool.def(false), // maxHeight
maxHeight: propTypes.oneOfType([String, Number]).def('300px')
})
const getBindValue = computed(() => {
@ -35,6 +36,7 @@ const dialogHeight = ref(isNumber(props.maxHeight) ? `${props.maxHeight}px` : pr
watch(
() => isFullscreen.value,
async (val: boolean) => {
//
await nextTick()
if (val) {
const windowHeight = document.documentElement.offsetHeight
@ -80,9 +82,12 @@ const dialogStyle = computed(() => {
</div>
</template>
<ElScrollbar :style="dialogStyle">
<!-- 情况一如果 scroll true说明开启滚动条 -->
<ElScrollbar :style="dialogStyle" v-if="scroll">
<slot></slot>
</ElScrollbar>
<!-- 情况一如果 scroll false说明关闭滚动条滚动条 -->
<slot v-else></slot>
<template v-if="slots.footer" #footer>
<slot name="footer"></slot>

View File

@ -1,6 +1,5 @@
<template>
<!-- TODO 芋艿Dialog 貌似高度不太对劲 已解决textarea导致 设置一个最大高就行了 -->
<Dialog :title="modelTitle" v-model="modelVisible" :loading="modelLoading" :max-height="'310px'">
<Dialog :title="modelTitle" v-model="modelVisible" :loading="modelLoading">
<el-form ref="ruleFormRef" :model="formData" :rules="formRules" label-width="80px">
<el-form-item label="参数分类" prop="category">
<el-input v-model="formData.category" placeholder="请输入参数分类" />
@ -48,7 +47,7 @@ const formType = ref('') // 表单的类型create - 新增update - 修改
const formLoading = ref(false) // Loading
// let formRef = ref() // Ref
const formData = reactive({
id: 0,
id: undefined,
category: '',
name: '',
key: '',
@ -70,24 +69,27 @@ const { proxy } = getCurrentInstance() as any
/** 打开弹窗 */
const openModal = async (type: string, id?: number) => {
modelVisible.value = true
modelLoading.value = true
modelTitle.value = t('action.' + type)
formType.value = type
//
resetForm()
//
if (id) {
modelLoading.value = true
try {
const data = await ConfigApi.getConfig(id)
// TODO reactive使 Object1 reactive ref
Object.assign(formData, data)
}
} finally {
modelLoading.value = false
}
}
}
defineExpose({ openModal }) // openModal
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
const formRef = proxy.$refs['ruleFormRef']
console.log(formRef, '======')
const formRef = proxy.$refs['formRef']
//
if (!formRef) return
const valid = await formRef.validate()
@ -112,7 +114,7 @@ const submitForm = async () => {
/** 重置表单 */
const resetForm = () => {
formData.id = 0
formData.id = undefined
formData.category = ''
formData.name = ''
formData.key = ''

View File

@ -36,17 +36,16 @@
/>
</el-select>
</el-form-item>
<!-- TODO时间无法设置 已解决 -->
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="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"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="defaultTime"
:default-time="[new Date(0, 0, 0, 0, 0, 0), new Date(0, 0, 0, 23, 59, 59)]"
/>
</el-form-item>
<el-form-item>
@ -139,14 +138,13 @@
</content-wrap>
<!-- 表单弹窗添加/修改 -->
<!-- TODO 芋艿可以改成 form 已解决 -->
<Form ref="modalRef" @success="getList" />
<config-form ref="modalRef" @success="getList" />
</template>
<script setup lang="ts" name="Config">
import * as ConfigApi from '@/api/infra/config'
import Form from './form.vue'
import ConfigForm from './form.vue'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
import { Delete, Edit, Search, Download, Plus, Refresh } from '@element-plus/icons-vue'
// import { Delete, Edit, Search, Download, Plus, Refresh } from '@element-plus/icons-vue'
import dayjs from 'dayjs'
const showSearch = ref(true) //
const loading = ref(true) //
@ -157,13 +155,9 @@ const queryParams = reactive({
pageSize: 10,
name: undefined,
key: undefined,
type: undefined
type: undefined,
createTime: []
})
const createTime = ref('')
const defaultTime = ref<[Date, Date]>([
new Date(2000, 1, 1, 0, 0, 0),
new Date(2000, 2, 1, 23, 59, 59)
])
const queryFormRef = ref() //
/** 搜索按钮操作 */
@ -196,7 +190,7 @@ const openModal = (type: string, id?: number) => {
modalRef.value.openModal(type, id)
}
// ========== ==========
/** 初始化 **/
onMounted(() => {
getList()
})