Commit dd02c01a183d2ec06d2b7a71fe515af79612e31c

Authored by fengtao
1 parent ae6b0631

refractor:修改报表

... ... @@ -20,7 +20,7 @@ export const columns: BasicColumn[] = [
20 20 dataIndex: 'dataType',
21 21 width: 120,
22 22 format: (_text: string, record: Recordable) => {
23   - return record.dataCompare === 0 ? '原始数据' : '聚合数据';
  23 + return record.dataCompare === 0 ? '原始数据' : '聚合数据';
24 24 },
25 25 },
26 26 {
... ... @@ -33,10 +33,10 @@ export const columns: BasicColumn[] = [
33 33 },
34 34 {
35 35 title: '执行状态',
36   - dataIndex: 'status',
  36 + dataIndex: 'executeStatus',
37 37 width: 120,
38 38 customRender: ({ record }) => {
39   - const status = record.status;
  39 + const status = record.executeStatus;
40 40 const color = status == 1 ? 'green' : status == 0 ? 'red' : 'blue';
41 41 const text = status == 1 ? '成功' : status == 0 ? '失败' : '进行中';
42 42 return h(Tag, { color: color }, () => text);
... ... @@ -62,7 +62,7 @@ export const searchFormSchema: FormSchema[] = [
62 62 },
63 63 },
64 64 {
65   - field: 'status',
  65 + field: 'executeStatus',
66 66 label: '执行状态',
67 67 component: 'Select',
68 68 colProps: { span: 6 },
... ...
... ... @@ -2,36 +2,45 @@
2 2 <div>
3 3 <BasicTable :clickToRowSelect="false" @register="registerTable" :searchInfo="searchInfo">
4 4 <template #toolbar>
5   - <Authority value="api:yt:reportExport:export">
6   - <Popconfirm title="您确定要导出报表数据吗?" ok-text="确定" cancel-text="取消" @confirm="exportCharts()">
7   - <a-button type="primary"> 导出报表 </a-button>
8   - </Popconfirm>
9   - </Authority>
10 5 <Authority value="api:yt:reportExport:delete">
11   - <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消" @confirm="handleDeleteOrBatchDelete(null)">
  6 + <Popconfirm
  7 + title="您确定要批量删除数据"
  8 + ok-text="确定"
  9 + cancel-text="取消"
  10 + @confirm="handleDeleteOrBatchDelete(null)"
  11 + >
12 12 <a-button type="primary" color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
13 13 </Popconfirm>
14 14 </Authority>
15 15 </template>
16 16 <template #action="{ record }">
17   - <TableAction :actions="[
18   - {
19   - label: '报表查看',
20   - icon: 'clarity:note-edit-line',
21   - auth: 'api:yt:reportExport:get',
22   - onClick: handleView.bind(null, record),
23   - },
24   - {
25   - label: '删除',
26   - icon: 'ant-design:delete-outlined',
27   - auth: 'api:yt:reportExport:delete',
28   - color: 'error',
29   - popConfirm: {
30   - title: '是否确认删除',
31   - confirm: handleDeleteOrBatchDelete.bind(null, record),
  17 + <TableAction
  18 + :actions="[
  19 + {
  20 + label: '报表导出',
  21 + icon: 'clarity:note-edit-line',
  22 + auth: 'api:yt:reportExport:export',
  23 + onClick: handleExport.bind(null, record),
  24 + ifShow: record.executeStatus === 1,
  25 + },
  26 + {
  27 + label: '报表查看',
  28 + icon: 'clarity:note-edit-line',
  29 + auth: 'api:yt:reportExport:get',
  30 + onClick: handleView.bind(null, record),
32 31 },
33   - },
34   - ]" />
  32 + {
  33 + label: '删除',
  34 + icon: 'ant-design:delete-outlined',
  35 + auth: 'api:yt:reportExport:delete',
  36 + color: 'error',
  37 + popConfirm: {
  38 + title: '是否确认删除',
  39 + confirm: handleDeleteOrBatchDelete.bind(null, record),
  40 + },
  41 + },
  42 + ]"
  43 + />
35 44 </template>
36 45 </BasicTable>
37 46 <ReportPreviewModal @register="registerModal" />
... ... @@ -39,76 +48,67 @@
39 48 </template>
40 49
41 50 <script lang="ts" setup>
42   -import { reactive, nextTick } from 'vue';
43   -import { BasicTable, useTable, TableAction } from '/@/components/Table';
44   -import { searchFormSchema, columns } from './config.data';
45   -import { Authority } from '/@/components/Authority';
46   -import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
47   -import { Popconfirm } from 'ant-design-vue';
48   -import { useModal } from '/@/components/Modal';
49   -import ReportPreviewModal from './ReportPreviewModal.vue';
50   -import {
51   - // exportPage,
52   - deleteExportManage
53   -} from '/@/api/export/exportManager';
54   -
55   -const searchInfo = reactive<Recordable>({});
  51 + import { reactive, nextTick } from 'vue';
  52 + import { BasicTable, useTable, TableAction } from '/@/components/Table';
  53 + import { searchFormSchema, columns } from './config.data';
  54 + import { Authority } from '/@/components/Authority';
  55 + import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  56 + import { Popconfirm } from 'ant-design-vue';
  57 + import { useModal } from '/@/components/Modal';
  58 + import ReportPreviewModal from './ReportPreviewModal.vue';
  59 + import { exportPage, deleteExportManage } from '/@/api/export/exportManager';
  60 + import { downloadByUrl } from '/@/utils/file/download';
56 61
57   -const [registerTable, { reload, setProps, setTableData }] = useTable({
58   - title: '报表导出列表',
59   - // api: exportPage,
60   - columns,
61   - showIndexColumn: false,
62   - clickToRowSelect: false,
63   - formConfig: {
64   - labelWidth: 120,
65   - schemas: searchFormSchema,
66   - },
67   - useSearchForm: true,
68   - showTableSetting: true,
69   - bordered: true,
70   - rowKey: 'id',
71   - actionColumn: {
72   - width: 200,
73   - title: '操作',
74   - dataIndex: 'action',
75   - slots: { customRender: 'action' },
76   - fixed: 'right',
77   - },
78   -});
79   -
80   -const handleSuccess = () => {
81   - reload();
82   -};
83   -
84   -const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
85   - deleteExportManage,
86   - handleSuccess,
87   - setProps
88   -);
  62 + const searchInfo = reactive<Recordable>({});
  63 + const [registerTable, { reload, setProps }] = useTable({
  64 + title: '报表导出列表',
  65 + api: exportPage,
  66 + columns,
  67 + showIndexColumn: false,
  68 + clickToRowSelect: false,
  69 + formConfig: {
  70 + labelWidth: 120,
  71 + schemas: searchFormSchema,
  72 + },
  73 + useSearchForm: true,
  74 + showTableSetting: true,
  75 + bordered: true,
  76 + rowKey: 'id',
  77 + actionColumn: {
  78 + width: 200,
  79 + title: '操作',
  80 + dataIndex: 'action',
  81 + slots: { customRender: 'action' },
  82 + fixed: 'right',
  83 + },
  84 + });
89 85
90   -nextTick(() => {
91   - setProps(selectionOptions);
92   - setTableData([
93   - {
94   - id:'121212',
95   - reportConfigName: '1',
96   - organizationName: '2',
97   - dataCompare: 1,
98   - executeWay: 1,
99   - executeTime: 1,
100   - status: 1
101   - }
102   - ])
  86 + const handleSuccess = () => {
  87 + reload();
  88 + };
103 89
104   -});
  90 + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
  91 + deleteExportManage,
  92 + handleSuccess,
  93 + setProps
  94 + );
105 95
106   -const [registerModal, { openModal }] = useModal();
107   -const handleView = (_, record) => {
108   - openModal(true, {
109   - isUpdate: true,
110   - record,
  96 + nextTick(() => {
  97 + setProps(selectionOptions);
111 98 });
112   -};
113   -const exportCharts = () => { };
  99 +
  100 + const [registerModal, { openModal }] = useModal();
  101 + const handleView = (_, record) => {
  102 + openModal(true, {
  103 + isUpdate: true,
  104 + record,
  105 + });
  106 + };
  107 + const handleExport = (record) => {
  108 + const url = record.reportPath;
  109 + downloadByUrl({
  110 + url,
  111 + target: '_self',
  112 + });
  113 + };
114 114 </script>
... ...