Browse Source

chore: 架构调整

master
wangxiang 2 years ago
parent
commit
7b5d2ea050
  1. 17
      src/api/platform/report/controller/reportSystemFile.ts
  2. 16
      src/api/platform/report/entity/reportSystemFile.ts
  3. 4
      src/enums/cacheEnum.ts
  4. 11
      src/router/guard/paramMenuGuard.ts
  5. 5
      src/utils/cache/persistent.ts
  6. 45
      src/views/report/design/design.data.ts
  7. 139
      src/views/report/design/index.vue
  8. 2
      src/views/system/client/client.data.ts

17
src/api/platform/report/controller/reportSystemFile.ts

@ -0,0 +1,17 @@
import type { ReportSystemFile, ReportSystemFileParams, ReportSystemFileResult } from '/@/api/platform/report/entity/reportSystemFile';
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/report_proxy/report/rest/list',
get = '/report_proxy/report/rest',
del = '/report_proxy/report/client/remove',
}
/** 查询报表列表 */
export const listReportSystemFile = (params?: Partial<ReportSystemFileParams>) => defHttp.get<ReportSystemFileResult>({ url: Api.list, params }, { isReturnResultResponse: true });
/** 查询报表详细 */
export const getReportSystemFile = (id: string) => defHttp.get<ReportSystemFile>({ url: `${Api.get}/${id}` });
/** 删除报表 */
export const delReportSystemFile = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` });

16
src/api/platform/report/entity/reportSystemFile.ts

@ -0,0 +1,16 @@
import type { R } from '/#/axios';
import type { CommonEntity, Page } from '/@/api/common/data/entity';
/** 报表系统文件查询参数 */
export type ReportSystemFileParams = Page & ReportSystemFile;
/** 报表系统文件 */
export interface ReportSystemFile extends CommonEntity {
id: string;
name: string;
content: Blob[];
[key: string]: any;
}
/** 报表系统文件响应对象 */
export type ReportSystemFileResult = R<ReportSystemFile[]>;

4
src/enums/cacheEnum.ts

@ -35,10 +35,10 @@ export const MULTIPLE_TABS_KEY = 'MULTIPLE_TABS__KEY__';
/** 应用主题键 */ /** 应用主题键 */
export const APP_DARK_MODE_KEY = '__APP__DARK__MODE__'; export const APP_DARK_MODE_KEY = '__APP__DARK__MODE__';
/** 基本全局本地缓存密钥 */ /** 基本全局本地缓存 */
export const APP_LOCAL_CACHE_KEY = 'COMMON__LOCAL__KEY__'; export const APP_LOCAL_CACHE_KEY = 'COMMON__LOCAL__KEY__';
/** 基本全局会话缓存密钥 */ /** 基本全局会话缓存 */
export const APP_SESSION_CACHE_KEY = 'COMMON__SESSION__KEY__'; export const APP_SESSION_CACHE_KEY = 'COMMON__SESSION__KEY__';
export enum CacheTypeEnum { export enum CacheTypeEnum {

11
src/router/guard/paramMenuGuard.ts

@ -2,24 +2,27 @@ import type { Router } from 'vue-router';
import { configureDynamicParamsMenu } from '../helper/menuHelper'; import { configureDynamicParamsMenu } from '../helper/menuHelper';
import { Menu } from '../types'; import { Menu } from '../types';
import { usePermissionStoreWithOut } from '/@/store/modules/permission'; import { usePermissionStoreWithOut } from '/@/store/modules/permission';
import { merge } from 'lodash-es';
export function createParamMenuGuard(router: Router) { export function createParamMenuGuard(router: Router) {
const permissionStore = usePermissionStoreWithOut(); const permissionStore = usePermissionStoreWithOut();
router.beforeEach(async (to, _, next) => { router.beforeEach(async (to, _, next) => {
// filter no name route // 过滤无名称路由
if (!to.name) { if (!to.name) {
next(); next();
return; return;
} }
// 菜单已经建立
// menu has been built.
if (!permissionStore.getIsDynamicAddedRoute) { if (!permissionStore.getIsDynamicAddedRoute) {
next(); next();
return; return;
} }
let menus: Menu[] = permissionStore.getMenuList; let menus: Menu[] = permissionStore.getMenuList;
menus.forEach((item) => configureDynamicParamsMenu(item, to.params)); menus.forEach((item) => configureDynamicParamsMenu(item, to.params));
// 处理路由切换动态替换vue-router自定义元数据
if (to.query?.enableMetaMerge === 'y') {
merge(to.meta, to.query);
}
next(); next();
}); });
} }

5
src/utils/cache/persistent.ts vendored

@ -20,7 +20,10 @@ import {
PROJ_CFG_KEY, PROJ_CFG_KEY,
APP_LOCAL_CACHE_KEY, APP_LOCAL_CACHE_KEY,
APP_SESSION_CACHE_KEY, APP_SESSION_CACHE_KEY,
MULTIPLE_TABS_KEY, REFRESH_TOKEN_KEY, ROLE_IDS_KEY, PERMISSIONS_KEY, MULTIPLE_TABS_KEY,
REFRESH_TOKEN_KEY,
ROLE_IDS_KEY,
PERMISSIONS_KEY,
} from '/@/enums/cacheEnum'; } from '/@/enums/cacheEnum';
import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting'; import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting';
import { toRaw } from 'vue'; import { toRaw } from 'vue';

45
src/views/report/design/design.data.ts

@ -0,0 +1,45 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '文件名',
dataIndex: 'name',
width: 100
},
{
title: '更新时间',
dataIndex: 'updateTime',
width: 100
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 100
},
];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '文件名',
component: 'Input',
componentProps: {
placeholder: '请输入文件名',
},
colProps: { span: 8 },
},
{
field: 'dateRange',
label: '创建时间',
component: 'RangePicker',
componentProps: {
style: { width:'100%' },
valueFormat: 'YYYY-MM-DD',
placeholder: ['开始日期','结束日期']
},
colProps: { span: 8 }
}
];

139
src/views/report/design/index.vue

@ -0,0 +1,139 @@
<template>
<div>
<BasicTable
@register="registerTable"
@selection-change="handleSelectionChange"
>
<template #toolbar>
<a-button
type="primary"
@click="handleAdd()"
>新增报表</a-button>
<a-button
type="primary"
:disabled="state.multiple"
@click="handleDel()"
>删除报表</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
label: '预览',
icon: 'fa6-solid:file-pdf',
onClick: handlePreview.bind(null, record)
},
{
label: '设计',
icon: 'fa6-solid:pen-ruler',
onClick: handleDesign.bind(null, record)
},
{
label: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
onClick: handleDel.bind(null, record)
}]"
/>
</template>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" setup>
/**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔
*/
import { reactive, toRaw } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listReportSystemFile, delReportSystemFile } from '/@/api/platform/report/controller/reportSystemFile';
import { useModal } from '/@/components/Modal';
import { columns, searchFormSchema } from './design.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { useRouter } from 'vue-router';
interface TableState {
single: boolean;
multiple: boolean;
}
const state = reactive<TableState>({
//
single: true,
//
multiple: true
});
const { push, replace } = useRouter();
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '报表列表',
api: listReportSystemFile,
rowKey: 'id',
columns,
formConfig: {
compact: true,
labelWidth: 100,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
autoAdvancedLine: 3,
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']]
},
rowSelection: { type: 'checkbox' },
useSearchForm: true,
showTableSetting: true,
bordered: true,
clickToRowSelect: false,
showIndexColumn: false,
actionColumn: {
width: 220,
title: '操作',
dataIndex: 'action',
fixed: false
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});
function handleSelectionChange(selection?: Recordable) {
const rowSelection = toRaw(selection?.keys) || [];
state.single = rowSelection.length != 1;
state.multiple = !rowSelection.length;
}
function handleAdd() {
push({ name: '报表设计器', query: { enableMetaMerge: 'y', title: '设计报表', frameSrc: 'https://www.baidu.com' } });
}
function handleDesign(record: Recordable) {
push({ name: '报表设计' });
}
function handlePreview(record: Recordable) {
}
async function handleDel(record?: Recordable) {
const ids = record?.id || getSelectRowKeys();
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否确认删除报表编号为${ids}报表吗?`,
onOk: async () => {
await delReportSystemFile(ids);
createMessage.success('删除成功!');
handleRefreshTable();
}
});
}
function handleRefreshTable() {
clearSelectedRowKeys();
reload();
}
</script>

2
src/views/system/client/client.data.ts

@ -1,6 +1,6 @@
/** /**
* @program: kicc-ui * @program: kicc-ui
* @description: * @description:
* @author: entfrm开发团队- * @author: entfrm开发团队-
* @create: 2022/4/21 * @create: 2022/4/21
*/ */

Loading…
Cancel
Save