Skip to content

Commit 72b0ec2

Browse files
committed
重构:完善配置管理的导出功能
1 parent faaa47a commit 72b0ec2

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/views/infra/config/index.vue

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ import { DICT_TYPE, getDictOptions } from '@/utils/dict'
144144
import * as ConfigApi from '@/api/infra/config'
145145
import ConfigForm from './form.vue'
146146
import dayjs from 'dayjs'
147+
import download from '@/utils/download'
147148
const message = useMessage() // 消息弹窗
148149
const { t } = useI18n() // 国际化
149150
@@ -162,12 +163,6 @@ const queryParams = reactive({
162163
const queryFormRef = ref() // 搜索的表单
163164
const exportLoading = ref(false) // 导出的加载中
164165
165-
/** 搜索按钮操作 */
166-
const handleQuery = () => {
167-
queryParams.pageNo = 1
168-
getList()
169-
}
170-
171166
/** 查询参数列表 */
172167
const getList = async () => {
173168
loading.value = true
@@ -180,6 +175,12 @@ const getList = async () => {
180175
}
181176
}
182177
178+
/** 搜索按钮操作 */
179+
const handleQuery = () => {
180+
queryParams.pageNo = 1
181+
getList()
182+
}
183+
183184
/** 重置按钮操作 */
184185
const resetQuery = () => {
185186
queryFormRef.value.resetFields()
@@ -195,7 +196,7 @@ const openModal = (type: string, id?: number) => {
195196
/** 删除按钮操作 */
196197
const handleDelete = async (id: number) => {
197198
try {
198-
// 二次确认
199+
// 删除的二次确认
199200
await message.delConfirm()
200201
// 发起删除
201202
await ConfigApi.deleteConfig(id)
@@ -205,6 +206,20 @@ const handleDelete = async (id: number) => {
205206
} catch {}
206207
}
207208
209+
const handleExport = async () => {
210+
try {
211+
// 导出的二次确认
212+
await message.exportConfirm()
213+
// 发起导出
214+
exportLoading.value = true
215+
const data = await ConfigApi.exportConfigApi(queryParams)
216+
download.excel(data, '参数配置.xls')
217+
} catch {
218+
} finally {
219+
exportLoading.value = false
220+
}
221+
}
222+
208223
/** 初始化 **/
209224
onMounted(() => {
210225
getList()

0 commit comments

Comments
 (0)