wupengfei
2025-05-28 6b333bea26b7599a3cf39cfa88333572ad66261e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
  <LoadingLayout :loading="state.loading">
    <AppContainer>
      <ProTableQueryFilterBar @on-reset="reset">
        <template #query>
          <QueryFilterItem>
            <FieldDatePicker
              v-model="extraParamState.creationDate"
              type="daterange"
              range-separator="~"
              start-placeholder="起始时间"
              end-placeholder="结束时间"
              clearable
              @change="getList()"
              tooltipContent="操作时间"
            ></FieldDatePicker>
          </QueryFilterItem>
        </template>
      </ProTableQueryFilterBar>
      <ProTableV2 v-bind="proTableProps" :columns="columns" :operationBtns="operationBtns">
      </ProTableV2>
    </AppContainer>
  </LoadingLayout>
</template>
 
<script setup lang="ts">
import {
  ProTableQueryFilterBar,
  ProTableV2,
  LoadingLayout,
  AppContainer,
  QueryFilterItem,
  useTable,
  FieldDatePicker,
  defineOperationBtns,
  defineColumns,
} from '@bole-core/components';
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
import { OrderInputType, downloadFileByUrl } from '@bole-core/core';
import { format, setOSSLink } from '@/utils';
import { ModelValueType } from 'element-plus';
import { InsurancePolicyStatusEnumText, InsurancePolicyStatusEnum } from '@/constants';
 
defineOptions({
  name: 'FileManage',
});
 
const columns = defineColumns([
  {
    id: '1',
    enCode: 'q',
    name: '标题',
  },
  {
    id: '2',
    enCode: 'q',
    name: '时间',
  },
  {
    id: '3',
    enCode: 'q',
    name: '操作',
  },
  {
    id: '4',
    enCode: 'q',
    name: '状态',
  },
]);
 
const operationBtns = defineOperationBtns([
  {
    data: {
      enCode: 'downloadFileBtn',
      name: '下载文件',
    },
    emits: {
      onClick: (role) => handleDownloadFile(role),
    },
  },
  {
    data: {
      enCode: 'downloadOriginalFileBtn',
      name: '下载原文件',
    },
    emits: {
      onClick: (role) => handleDownloadOriginalFile(role),
    },
  },
  {
    data: {
      enCode: 'downloadErrorDataBtn',
      name: '下载错误数据',
    },
    emits: {
      onClick: (role) => handleDownloadErrorData(role),
    },
  },
]);
 
const BaseState = {
  loading: true,
};
 
const state = reactive({ ...BaseState });
 
onMounted(async () => {
  await getList();
  state.loading = false;
});
 
const {
  getDataSource: getList,
  proTableProps,
  paginationState,
  extraParamState,
  reset,
} = useTable(
  async ({ pageIndex, pageSize }, extraParamState) => {
    try {
      let params: API.GetInsurancePageInput = {
        pageModel: {
          rows: pageSize,
          page: pageIndex,
          orderInput: extraParamState.orderInput,
        },
        importStartDateTime: format(extraParamState.creationDate?.[0] ?? '', 'YYYY-MM-DD 00:00:00'),
        importEndDateTime: format(extraParamState.creationDate?.[1] ?? '', 'YYYY-MM-DD 23:59:59'),
        insurancePeriod: extraParamState.insurancePeriod,
        status: extraParamState.status,
      };
      let res = await insuranceOrderServices.getInsurancePage(params, {
        showLoading: !state.loading,
      });
      return res;
    } catch (error) {}
  },
  {
    defaultExtraParams: {
      orderInput: [{ property: 'id', order: OrderInputType.Desc }],
      creationDate: [] as unknown as ModelValueType,
      status: '' as any as InsurancePolicyStatusEnum,
      insurancePeriod: '',
    },
    columnsRenderProps: {
      status: { type: 'enum', valueEnum: InsurancePolicyStatusEnumText },
      effectEndTime: { type: 'date', format: 'YYYY-MM-DD' },
    },
  }
);
 
function handleDownloadFile(row: API.GetInsurancePageOutput) {
  downloadFileByUrl(setOSSLink(row.insureBillUrl));
}
function handleDownloadOriginalFile(row: API.GetInsurancePageOutput) {
  downloadFileByUrl(setOSSLink(row.insureBillUrl));
}
function handleDownloadErrorData(row: API.GetInsurancePageOutput) {
  downloadFileByUrl(setOSSLink(row.insureBillUrl));
}
</script>