导出excel加上日期

This commit is contained in:
weiwei committed 2025-03-06 14:38:52 +08:00
1 parent 8bdf76ae3a
commit 5dce0acf8c
67 files changed
+2300 -2278

No files matched your search

+46 -38
View File
@@ -8,22 +8,30 @@
</el-form-item>
<el-form-item>
<el-button @click="getDataList" icon="search" type="primary">
{{ $t('common.queryBtn') }}
{{ $t("common.queryBtn") }}
</el-button>
<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
<el-button @click="resetQuery" icon="Refresh">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button @click="formDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary" v-auth="'sys_post_add'">
{{ $t('common.addBtn') }}
{{ $t("common.addBtn") }}
</el-button>
<el-button plain @click="excelUploadRef.show()" class="ml10" icon="upload-filled" type="primary" v-auth="'sys_post_add'">
{{ $t('common.importBtn') }}
{{ $t("common.importBtn") }}
</el-button>
<el-button plain :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete" type="primary" v-auth="'sys_post_del'">
{{ $t('common.delBtn') }}
<el-button
plain
:disabled="multiple"
@click="handleDelete(selectObjs)"
class="ml10"
icon="Delete"
type="primary"
v-auth="'sys_post_del'"
>
{{ $t("common.delBtn") }}
</el-button>
<right-toolbar
:export="'sys_post_export'"
@@ -40,7 +48,7 @@
@selection-change="handleSelectionChange"
style="width: 100%"
v-loading="state.loading"
row-key="postId"
row-key="postId"
border
:cell-style="tableStyle?.cellStyle"
:header-cell-style="tableStyle?.headerCellStyle"
@@ -54,11 +62,11 @@
<el-table-column :label="$t('common.action')" width="200">
<template #default="scope">
<el-button icon="edit-pen" @click="formDialogRef.openDialog(scope.row.postId)" text type="primary" v-auth="'sys_post_edit'"
>{{ $t('common.editBtn') }}
>{{ $t("common.editBtn") }}
</el-button>
<el-button icon="delete" @click="handleDelete([scope.row.postId])" text type="primary" v-auth="'sys_post_del'"
>{{ $t('common.delBtn') }}
>{{ $t("common.delBtn") }}
</el-button>
</template>
</el-table-column>
@@ -80,64 +88,64 @@
</template>
<script lang="ts" name="systemPost" setup>
import { BasicTableProps, useTable } from '/@/hooks/table';
import { delObj, fetchList } from '/@/api/admin/post';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { useI18n } from 'vue-i18n';
import { BasicTableProps, useTable } from "/@/hooks/table"
import { delObj, fetchList } from "/@/api/admin/post"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useI18n } from "vue-i18n"
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const { t } = useI18n();
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
const { t } = useI18n()
// 定义变量内容
const formDialogRef = ref();
const excelUploadRef = ref();
const formDialogRef = ref()
const excelUploadRef = ref()
// 搜索变量
const queryRef = ref();
const showSearch = ref(true);
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any;
const multiple = ref(true);
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: fetchList,
});
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile, tableStyle } = useTable(state);
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile, tableStyle } = useTable(state)
// 清空搜索条件
const resetQuery = () => {
queryRef.value.resetFields();
getDataList();
};
queryRef.value.resetFields()
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile('/admin/post/export', Object.assign(state.queryForm,{ids:selectObjs}), 'post.xlsx');
};
downBlobFile("/admin/post/export", Object.assign(state.queryForm, { ids: selectObjs }), "岗位管理.xlsx")
}
// 多选事件
const handleSelectionChange = (objs: { postId: string }[]) => {
selectObjs.value = objs.map(({ postId }) => postId);
multiple.value = !objs.length;
};
selectObjs.value = objs.map(({ postId }) => postId)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm(t('common.delConfirmText'));
await useMessageBox().confirm(t("common.delConfirmText"))
} catch {
return;
return
}
try {
await delObj(ids);
getDataList();
useMessage().success(t('common.delSuccessText'));
await delObj(ids)
getDataList()
useMessage().success(t("common.delSuccessText"))
} catch (err: any) {
useMessage().error(err.msg);
useMessage().error(err.msg)
}
};
}
</script>