refactor: ♻️ 导入导出方法优化
Former-commit-id: 35fa3ebfb81a57bd3621bd9f5150da2c97e2fdec
This commit is contained in:
@@ -294,13 +294,6 @@ function downloadTemplate() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 打开导入弹窗 */
|
|
||||||
async function openImportDialog() {
|
|
||||||
await getDeptOptions();
|
|
||||||
importDeptId.value = undefined;
|
|
||||||
importDialog.visible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel文件change事件
|
* Excel文件change事件
|
||||||
*
|
*
|
||||||
@@ -316,8 +309,22 @@ function handleExcelChange(file: UploadFile) {
|
|||||||
excelFile.value = file.raw;
|
excelFile.value = file.raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 打开导入弹窗 */
|
||||||
|
async function openImportDialog() {
|
||||||
|
await getDeptOptions();
|
||||||
|
importDeptId.value = undefined;
|
||||||
|
importDialog.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 关闭导入弹窗 */
|
||||||
|
function closeImportDialog() {
|
||||||
|
importDialog.visible = false;
|
||||||
|
excelFile.value = undefined;
|
||||||
|
excelFilelist.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
/** 导入用户提交 */
|
/** 导入用户提交 */
|
||||||
function handleUserImport() {
|
function handleImport() {
|
||||||
if (importDeptId.value) {
|
if (importDeptId.value) {
|
||||||
if (!excelFile.value) {
|
if (!excelFile.value) {
|
||||||
ElMessage.warning("上传Excel文件不能为空");
|
ElMessage.warning("上传Excel文件不能为空");
|
||||||
@@ -331,15 +338,8 @@ function handleUserImport() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 关闭导入弹窗 */
|
|
||||||
function closeImportDialog() {
|
|
||||||
importDialog.visible = false;
|
|
||||||
excelFile.value = undefined;
|
|
||||||
excelFilelist.value = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出用户 */
|
/** 导出用户 */
|
||||||
function handleUserExport() {
|
function handleExport() {
|
||||||
exportUser(queryParams).then((response: any) => {
|
exportUser(queryParams).then((response: any) => {
|
||||||
const blob = new Blob([response.data], {
|
const blob = new Blob([response.data], {
|
||||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
|
||||||
@@ -457,7 +457,7 @@ onMounted(() => {
|
|||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<el-button class="ml-3" @click="handleUserExport"
|
<el-button class="ml-3" @click="handleExport"
|
||||||
><template #icon><i-ep-download /></template>导出</el-button
|
><template #icon><i-ep-download /></template>导出</el-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
@@ -695,7 +695,7 @@ onMounted(() => {
|
|||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button type="primary" @click="handleUserImport">确 定</el-button>
|
<el-button type="primary" @click="handleImport">确 定</el-button>
|
||||||
<el-button @click="closeImportDialog">取 消</el-button>
|
<el-button @click="closeImportDialog">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user