| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <template>
- <div class="safety-platform-container">
- <header class="safety-platform-container__header">
- <div class="breadcrumb-title"> 双体系建设管理 </div>
- </header>
- <main class="safety-platform-container__main">
- <div class="search-table-container">
- <header>
- <div style="position: relative">
- <el-button type="primary" class="search-table-container--button" @click="handleCreate">
- 添加
- </el-button>
- <el-button plain class="search-table-container--button" @click="handleImport">
- 导入
- </el-button>
- <el-button plain class="search-table-container--button" @click="handleDownload">
- 导出
- </el-button>
- </div>
- <div class="act-search">
- <section class="select-box">
- <div class="select-box--item">
- <span>文件名称/编号:</span>
- <el-input
- v-model="queryParams.keyword"
- placeholder="搜索文件名称或编号"
- class="act-search-input"
- />
- </div>
- <div class="select-box--item">
- <span>分类:</span>
- <el-select
- v-model="queryParams.classifyName"
- placeholder="请选择分类"
- clearable
- >
- <el-option label="外部文件" value="外部文件" />
- <el-option label="内部文件" value="内部文件" />
- </el-select>
- </div>
- <div class="select-box--item">
- <span>状态:</span>
- <el-select
- v-model="queryParams.status"
- placeholder="请选择状态"
- clearable
- >
- <el-option label="启用" :value="1" />
- <el-option label="禁用" :value="0" />
- </el-select>
- </div>
- <div class="select-box--item">
- <span>上传日期范围:</span>
- <el-date-picker
- v-model="uploadDateRange"
- type="daterange"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- />
- </div>
- </section>
- <section class="search-btn">
- <el-button type="primary" @click="handleSearch">查询</el-button>
- <el-button @click="handleReset">重置</el-button>
- </section>
- </div>
- </header>
- <div class="batch-table">
- <BasicTable
- ref="basicTableRef"
- :tableData="tableData"
- :tableConfig="tableConfig"
- @update:pageSize="handleSizeChange"
- @update:pageNumber="handleCurrentChange"
- >
- <template #status="scope">
- <span>
- {{ scope.row.status === 1 ? '启用' : scope.row.status === 0 ? '禁用' : '-' }}
- </span>
- </template>
- <template #action="scope">
- <div class="action-container--div" style="justify-content: left">
- <ActionButton text="编辑" @click="handleEdit(scope.row.id)" />
- <ActionButton
- text="删除"
- :popconfirm="{
- title: '确定要删除?',
- }"
- @confirm="handleDelete(scope.row.id)"
- />
- <ActionButton text="查看" @click="handleView(scope.row.id)" />
- <ActionButton text="下载" @click="handleDownloadFile(scope.row)" />
- </div>
- </template>
- </BasicTable>
- </div>
- </div>
- </main>
- <BatchImport
- v-if="batchImportVisible"
- :visible="batchImportVisible"
- :import-api-url="importApiUrl"
- :template-url="templateUrl"
- template-name="下载模板"
- :show-template="false"
- @close="batchImportVisible = false"
- @update="handleUpdate"
- />
- </div>
- </template>
- <script setup lang="ts">
- import { onMounted, reactive, ref } from 'vue';
- import { ElMessage } from 'element-plus';
- import BasicTable from '@/components/BasicTable.vue';
- import useTableConfig from '@/hooks/useTableConfigHook';
- import ActionButton from '@/components/ActionButton.vue';
- import { TABLE_OPTIONS, INVENTORY_TABLE_COLUMNS } from './configs/tables';
- import { useRouter } from 'vue-router';
- import {
- queryDualSystemPage,
- deleteDualSystem,
- exportDualSystem,
- type ProductionSafetyFileQuery,
- type ProductionSafetyFilePageQuery,
- } from '@/api/production-safety-system';
- import { downloadByData } from '@/utils/file/download';
- import BatchImport from '@/components/batch-import/BatchImport.vue';
- import { useGlobSetting } from '@/hooks/setting';
- import urlJoin from 'url-join';
- const router = useRouter();
- // 表格
- const basicTableRef = ref<InstanceType<typeof BasicTable>>();
- const { tableConfig, pagination } = useTableConfig(INVENTORY_TABLE_COLUMNS, TABLE_OPTIONS);
- const tableData = ref<any[]>([]);
- const queryParams = reactive<ProductionSafetyFileQuery>({
- keyword: '', // 文件名称/编号(模糊查询)
- status: undefined, // 状态:1-启用,0-禁用
- classifyName: '', // 分类名称:外部文件/内部文件
- startDate: '', // 上传日期范围-开始日期
- endDate: '', // 上传日期范围-结束日期
- });
- // 上传日期范围(用于日期选择器)
- const uploadDateRange = ref<[string, string] | null>(null);
- const handleSizeChange = (value: number) => {
- pagination.pageSize = value;
- getTableData();
- };
- const handleCurrentChange = (value: number) => {
- pagination.pageNumber = value;
- getTableData();
- };
- async function getTableData() {
- tableConfig.loading = true;
- try {
- const pageQuery: ProductionSafetyFilePageQuery = {
- pageNumber: pagination.pageNumber,
- pageSize: pagination.pageSize,
- queryParam: {
- keyword: queryParams.keyword || undefined,
- status: queryParams.status,
- classifyName: queryParams.classifyName || undefined,
- startDate: queryParams.startDate || undefined,
- endDate: queryParams.endDate || undefined,
- },
- };
- const res = await queryDualSystemPage(pageQuery, queryParams.classifyName || undefined);
- if (res) {
- // 映射返回数据字段到表格字段
- tableData.value = res.records.map((item) => ({
- id: item.id,
- fileName: item.fileName, // 文件名称
- fileCode: item.fileCode, // 文件编号
- classifyName: item.classifyName, // 分类名称
- fileVersion: item.fileVersion, // 文件版本号
- fileFormat: item.fileFormat, // 文件格式
- releaseDate: item.releaseDate, // 发布日期
- status: item.status, // 状态:1-启用,0-禁用
- fileUrl: item.fileUrl, // 文件地址
- uploadTime: item.uploadTime || item.createdAt, // 上传时间
- }));
- pagination.total = res.totalRow || 0;
- }
- } catch (e) {
- console.error('获取双体系建设列表失败:', e);
- tableData.value = [];
- pagination.total = 0;
- } finally {
- tableConfig.loading = false;
- }
- }
- const handleSearch = () => {
- // 处理日期范围
- if (uploadDateRange.value && uploadDateRange.value.length === 2) {
- queryParams.startDate = uploadDateRange.value[0];
- queryParams.endDate = uploadDateRange.value[1];
- } else {
- queryParams.startDate = '';
- queryParams.endDate = '';
- }
- pagination.pageNumber = 1;
- getTableData();
- };
- const handleReset = () => {
- queryParams.keyword = '';
- queryParams.status = undefined;
- queryParams.classifyName = '';
- queryParams.startDate = '';
- queryParams.endDate = '';
- uploadDateRange.value = null;
- handleSearch();
- };
- // 批量导入
- const batchImportVisible = ref(false);
- const { urlPrefix } = useGlobSetting();
- const importApiUrl = ref(urlJoin(urlPrefix, '/productionSafety/dualSystem/import'));
- const templateUrl = ref('./skyeye-file-upload/sfysecurity/TEMPLATE/import-dual-system-template.xlsx');
- const handleImport = () => {
- batchImportVisible.value = true;
- };
- const handleUpdate = () => {
- batchImportVisible.value = false;
- getTableData();
- };
- const handleDownload = async () => {
- try {
- const exportParams: ProductionSafetyFileQuery = {
- keyword: queryParams.keyword || undefined,
- status: queryParams.status,
- classifyName: queryParams.classifyName || undefined,
- startDate: queryParams.startDate || undefined,
- endDate: queryParams.endDate || undefined,
- };
- const response = await exportDualSystem(exportParams, queryParams.classifyName || undefined);
- if (response) {
- const fileName = `双体系建设管理_${new Date().toISOString().split('T')[0]}.xlsx`;
- downloadByData(response, fileName);
- ElMessage.success('导出成功');
- }
- } catch (e) {
- console.error('导出双体系建设失败:', e);
- ElMessage.error('导出失败,请重试');
- }
- };
- // 文件下载
- const handleDownloadFile = (row: any) => {
- const url = row?.fileUrl;
- if (!url) {
- ElMessage.warning('暂无文件可下载');
- return;
- }
- window.open(url, '_blank');
- };
- const handleCreate = () => {
- router.push({
- name: 'DoubleSystemManagementItem',
- query: {
- operate: 'dual-system-create',
- },
- });
- };
- const handleEdit = (id: number) => {
- router.push({
- name: 'DoubleSystemManagementItem',
- query: {
- id,
- operate: 'dual-system-edit',
- },
- });
- };
- const handleDelete = async (id: number) => {
- try {
- await deleteDualSystem(id);
- ElMessage.success('删除成功');
- getTableData();
- } catch (e) {
- console.error('删除双体系建设失败:', e);
- ElMessage.error('删除失败,请重试');
- }
- };
- const handleView = (id: number) => {
- router.push({
- name: 'DoubleSystemManagementItem',
- query: {
- id,
- operate: 'dual-system-view',
- },
- });
- };
- onMounted(() => {
- getTableData();
- });
- </script>
- <style scoped lang="scss">
- @use '@/styles/page-details-layout.scss' as *;
- @use '@/styles/page-main-layout.scss' as *;
- @use '@/styles/basic-table-action.scss' as *;
- @use '@/views/traffic/violation/style/act-search-table.scss' as *;
- </style>
|