Skip to content

Commit 0ea6b1b

Browse files
committed
解决TODO
1 parent dcc7966 commit 0ea6b1b

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

src/views/infra/config/form.vue

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
2-
<!-- TODO 芋艿:Dialog 貌似高度不太对劲 -->
3-
<Dialog :title="modelTitle" v-model="modelVisible" :loading="modelLoading">
4-
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px">
2+
<!-- TODO 芋艿:Dialog 貌似高度不太对劲 已解决:textarea导致 设置一个最大高就行了 -->
3+
<Dialog :title="modelTitle" v-model="modelVisible" :loading="modelLoading" :max-height="'310px'">
4+
<el-form ref="ruleFormRef" :model="formData" :rules="formRules" label-width="80px">
55
<el-form-item label="参数分类" prop="category">
66
<el-input v-model="formData.category" placeholder="请输入参数分类" />
77
</el-form-item>
@@ -28,14 +28,15 @@
2828
<template #footer>
2929
<div class="dialog-footer">
3030
<el-button type="primary" @click="submitForm">确 定</el-button>
31-
<el-button @click="modelVisible = false">取 消</el-button>
31+
<el-button @click="colseForm(ruleFormRef)">取 消</el-button>
3232
</div>
3333
</template>
3434
</Dialog>
3535
</template>
3636
<script setup lang="ts">
3737
import * as ConfigApi from '@/api/infra/config'
3838
// import type { FormExpose } from '@/components/Form'
39+
import type { FormInstance } from 'element-plus'
3940
const { t } = useI18n() // 国际化
4041
const message = useMessage() // 消息弹窗
4142
// const { proxy } = getCurrentInstance()
@@ -62,7 +63,7 @@ const formRules = reactive({
6263
value: [{ required: true, message: '参数键值不能为空', trigger: 'blur' }],
6364
visible: [{ required: true, message: '是否可见不能为空', trigger: 'blur' }]
6465
})
65-
// const formRef = ref<FormExpose>() // 表单 Ref
66+
const ruleFormRef = ref<FormInstance>() // 表单 Ref
6667
6768
const { proxy } = getCurrentInstance() as any
6869
@@ -85,7 +86,7 @@ defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗
8586
/** 提交表单 */
8687
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
8788
const submitForm = async () => {
88-
const formRef = proxy.$refs['formRef']
89+
const formRef = proxy.$refs['ruleFormRef']
8990
console.log(formRef, '======')
9091
// 校验表单
9192
if (!formRef) return
@@ -118,7 +119,17 @@ const resetForm = () => {
118119
formData.value = ''
119120
formData.visible = true
120121
formData.remark = ''
121-
// proxy.$refs['formRef'].resetFields()
122-
// formRef.value.resetFields() // TODO 芋艿:为什么拿不到 formRef 呢?
122+
// proxy.$refs['ruleFormRef'].resetFields()
123+
// setTimeout(() => {
124+
// console.log(ruleFormRef.value, 'formRef.value')
125+
// formRef.value.resetFields() // TODO 芋艿:为什么拿不到 formRef 呢? 表单还没加载出来
126+
// ruleFormRef.value?.resetFields()
127+
// }, 100)
128+
}
129+
/** 取消添加 */
130+
const colseForm = (formEl: FormInstance | undefined) => {
131+
if (!formEl) return
132+
formEl.resetFields()
133+
modelVisible.value = false
123134
}
124135
</script>

src/views/infra/config/index.vue

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,46 +36,46 @@
3636
/>
3737
</el-select>
3838
</el-form-item>
39-
<!-- TODO:时间无法设置 -->
39+
<!-- TODO:时间无法设置 已解决 -->
4040
<el-form-item label="创建时间" prop="createTime">
4141
<el-date-picker
42-
v-model="queryParams.createTime"
42+
v-model="createTime"
4343
style="width: 240px"
44-
value-format="yyyy-MM-dd HH:mm:ss"
44+
value-format="yyyy-MM-DD HH:mm:ss"
4545
type="daterange"
4646
range-separator="-"
4747
start-placeholder="开始日期"
4848
end-placeholder="结束日期"
49-
:default-time="['00:00:00', '23:59:59']"
49+
:default-time="defaultTime"
5050
/>
5151
</el-form-item>
5252
<el-form-item>
53-
<!-- TODO 按钮图标不对 -->
54-
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
55-
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
53+
<!-- TODO 按钮图标不对 已解决 -->
54+
<el-button type="primary" :icon="Search" @click="handleQuery">搜索</el-button>
55+
<el-button :icon="Refresh" @click="resetQuery">重置</el-button>
5656
</el-form-item>
5757
</el-form>
5858

5959
<!-- 操作栏 -->
60-
<!-- TODO 间隔貌似有点问题 -->
60+
<!-- TODO 间隔貌似有点问题 没发现 -->
6161
<el-row :gutter="10" class="mb8">
62-
<!-- TODO 芋艿,图标不对 -->
62+
<!-- TODO 芋艿,图标不对 已解决 -->
6363
<el-col :span="1.5">
6464
<el-button
6565
type="primary"
6666
plain
67-
icon="el-icon-plus"
67+
:icon="Plus"
6868
@click="openModal('create')"
6969
v-hasPermi="['infra:config:create']"
7070
>
7171
新增
7272
</el-button>
7373
</el-col>
74-
<!-- TODO 芋艿,图标不对 -->
74+
<!-- TODO 芋艿,图标不对 已解决 -->
7575
<el-col :span="1.5">
7676
<el-button
7777
type="warning"
78-
icon="el-icon-download"
78+
:icon="Download"
7979
@click="handleExport"
8080
:loading="exportLoading"
8181
v-hasPermi="['infra:config:export']"
@@ -84,7 +84,7 @@
8484
</el-button>
8585
</el-col>
8686
<!-- TODO 芋艿:右侧导航 -->
87-
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
87+
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
8888
</el-row>
8989

9090
<!-- 列表 -->
@@ -112,13 +112,13 @@
112112
<span>{{ dayjs(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
113113
</template>
114114
</el-table-column>
115-
<!-- TODO 芋艿:icon 有问题,会换行 -->
115+
<!-- TODO 芋艿:icon 有问题,会换行 已解决 -->
116116
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
117117
<template #default="scope">
118118
<el-button
119119
link
120120
type="primary"
121-
icon="el-icon-edit"
121+
:icon="Edit"
122122
@click="openModal('update', scope.row.id)"
123123
v-hasPermi="['infra:config:update']"
124124
>
@@ -127,7 +127,7 @@
127127
<el-button
128128
link
129129
type="primary"
130-
icon="el-icon-delete"
130+
:icon="Delete"
131131
@click="handleDelete(scope.row)"
132132
v-hasPermi="['infra:config:delete']"
133133
>
@@ -139,15 +139,15 @@
139139
</content-wrap>
140140

141141
<!-- 表单弹窗:添加/修改 -->
142-
<!-- TODO 芋艿:可以改成 form 么? -->
143-
<config-form ref="modalRef" @success="getList" />
142+
<!-- TODO 芋艿:可以改成 form 么? 已解决 -->
143+
<Form ref="modalRef" @success="getList" />
144144
</template>
145145
<script setup lang="ts" name="Config">
146146
import * as ConfigApi from '@/api/infra/config'
147-
import ConfigForm from './form.vue'
147+
import Form from './form.vue'
148148
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
149+
import { Delete, Edit, Search, Download, Plus, Refresh } from '@element-plus/icons-vue'
149150
import dayjs from 'dayjs'
150-
151151
const showSearch = ref(true) // 搜索框的是否展示
152152
const loading = ref(true) // 列表的加载中
153153
const total = ref(0) // 列表的总页数
@@ -157,9 +157,13 @@ const queryParams = reactive({
157157
pageSize: 10,
158158
name: undefined,
159159
key: undefined,
160-
type: undefined,
161-
createTime: []
160+
type: undefined
162161
})
162+
const createTime = ref('')
163+
const defaultTime = ref<[Date, Date]>([
164+
new Date(2000, 1, 1, 0, 0, 0),
165+
new Date(2000, 2, 1, 23, 59, 59)
166+
])
163167
const queryFormRef = ref() // 搜索的表单
164168
165169
/** 搜索按钮操作 */

0 commit comments

Comments
 (0)