This commit is contained in:
caozehui
2024-11-06 10:35:54 +08:00
parent d7518e41e4
commit ea254245c7
2 changed files with 19 additions and 10 deletions

View File

@@ -26,4 +26,9 @@ export const getDicDataById = (params: string) => {
return http.post('/dictData/getDicDataById', params) return http.post('/dictData/getDicDataById', params)
} }
//导出字典数据
export const exportDictData = (params: Dict.ReqDictDataParams) => {
return http.download(`/dictData/export`, params)
}

View File

@@ -7,7 +7,7 @@
<ProTable ref='proTable' :columns="columns" :request-api='getDictDataListByTypeId' :initParam="initParam"> <ProTable ref='proTable' :columns="columns" :request-api='getDictDataListByTypeId' :initParam="initParam">
<template #tableHeader="scope"> <template #tableHeader="scope">
<el-button type="primary" :icon="CirclePlus" @click="openDialog('add')">新增</el-button> <el-button type="primary" :icon="CirclePlus" @click="openDialog('add')">新增</el-button>
<el-button type='primary' :icon='Download' plain>导出</el-button> <el-button type='primary' :icon='Download' plain @click="downloadFile">导出</el-button>
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected" <el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected"
@click="batchDelete(scope.selectedListIds)"> @click="batchDelete(scope.selectedListIds)">
批量删除 批量删除
@@ -27,13 +27,11 @@
<script setup lang="tsx" name="dictData"> <script setup lang="tsx" name="dictData">
import {CirclePlus, Delete, Download, EditPen} from '@element-plus/icons-vue' import {CirclePlus, Delete, Download, EditPen} from '@element-plus/icons-vue'
import {Dict} from '@/api/system/dictionary/interface' import {Dict} from '@/api/system/dictionary/interface'
import {ProTableInstance, ColumnProps} from '@/components/ProTable/interface' import {ColumnProps, ProTableInstance} from '@/components/ProTable/interface'
import {useHandleData} from '@/hooks/useHandleData' import {useHandleData} from '@/hooks/useHandleData'
import DataPopup from '@/views/system/dictionary/dictData/components/dataPopup.vue' import {deleteDictData, getDictDataListByTypeId, exportDictData} from "@/api/system/dictionary/dictData";
import { import {useDownload} from "@/hooks/useDownload";
getDictDataListByTypeId, import {exportDictType} from "@/api/system/dictionary/dictType";
deleteDictData,
} from "@/api/system/dictionary/dictData";
const proTable = ref<ProTableInstance>() const proTable = ref<ProTableInstance>()
const dialogVisible = ref(false) const dialogVisible = ref(false)
@@ -89,9 +87,9 @@ const columns = reactive<ColumnProps<Dict.ResDictData>[]>([
return ( return (
<> <>
{ {
(<el-tag type={scope.row.level === 1 ? 'info' : scope.row.level === 2 ? 'warning' : 'danger'}> (<el-tag type={scope.row.level === 1 ? 'info' : scope.row.level === 2 ? 'warning' : 'danger'}>
{scope.row.level === 1 ? '普通' : scope.row.level === 2 ? '中等' : '严重'} {scope.row.level === 1 ? '普通' : scope.row.level === 2 ? '中等' : '严重'}
</el-tag>) </el-tag>)
} }
</> </>
) )
@@ -136,4 +134,10 @@ const handleDelete = async (params: Dict.ResDictData) => {
await useHandleData(deleteDictData, [params.id], `删除【${params.name}】字典数据`) await useHandleData(deleteDictData, [params.id], `删除【${params.name}】字典数据`)
proTable.value?.getTableList() proTable.value?.getTableList()
} }
const downloadFile = async () => {
ElMessageBox.confirm('确认导出字典数据?', '温馨提示', {type: 'warning'}).then(() =>
useDownload(exportDictData, '字典数据导出数据', {typeId: dictTypeId.value, ...(proTable.value?.searchParam)}, false, '.xls'),
)
}
</script> </script>