wupengfei
2025-04-02 f5f5dc20f7fa2b59671abccf6c6513fabb39789a
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<template>
  <LoadingLayout :loading="state.loading">
    <AppContainer>
      <ProTableQueryFilterBar
        @on-reset="reset"
        @on-search="getList"
      >
        <template #query>
          <QueryFilterItem>
            <FieldSelect
              v-model="extraParamState.importChannel"
              placeholder="理赔渠道"
              :value-enum="insuranceClaimChannelListForSelect"
              clearable
              @change="getList()"
            />
          </QueryFilterItem>
          <QueryFilterItem>
            <FieldDatePicker
              v-model="extraParamState.creationDate"
              type="daterange"
              range-separator="~"
              start-placeholder="起始日期"
              end-placeholder="结束日期"
              clearable
              @change="getList()"
              tooltipContent="导入日期"
            ></FieldDatePicker>
          </QueryFilterItem>
 
          <!-- <QueryFilterItem>
            <FieldDatePicker
              v-model="extraParamState.creationTime"
              type="date"
              placeholder="导入日期"
              clearable
              @change="getList()"
              tooltipContent="导入日期"
            ></FieldDatePicker>
          </QueryFilterItem> -->
        </template>
        <template #btn>
          <el-button
            v-if="checkSubModuleItemShow('pageButton', 'exportBtn')"
            @click="handleExport()"
            icon="Download"
            type="primary"
            >导出</el-button
          >
        </template>
      </ProTableQueryFilterBar>
      <ProTableV2 v-bind="proTableProps" :columns="column" :operationBtns="operationBtns">
      </ProTableV2>
    </AppContainer>
    <BatchUploadOrderDialog v-bind="dialogBatchUploadOrderProps"></BatchUploadOrderDialog>
  </LoadingLayout>
</template>
 
<script setup lang="ts">
import {
  ProTableQueryFilterBar,
  OperationBtnType,
  ProTableV2,
  SearchInput,
  LoadingLayout,
  AppContainer,
  QueryFilterItem,
  useTable,
  useFormDialog,
  FieldDatePicker,
  FieldSelect,
  FieldRadio,
  UploadUserFile,
} from '@bole-core/components';
import { useAccess, useInsuranceClaimChannelList } from '@/hooks';
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
import { Message, OrderInputType } from '@bole-core/core';
import { downloadFile, downloadFileByUrl, format, setOSSLink } from '@/utils';
import { ModelValueType } from 'element-plus';
import { OnJobFlagEnumText, insuranceTypeText } from '@/constants';
import BatchUploadOrderDialog from './components/BatchUploadOrderDialog.vue';
 
defineOptions({
  name: 'ExportManage',
});
 
const operationBtnMap: Record<string, OperationBtnType> = {
  // checkBtn: { emits: { onClick: (role) => goDetail(role) } },
  policyDownloadBtn: {
    emits: { onClick: (role) => handleDownload(role) },
    extraProps: {
      hide: (row: API.InsuranceOrderListOutput) => !( row.orderBillFile),
    },
  },
};
 
const { checkSubModuleItemShow, column, operationBtns } = useAccess({
  operationBtnMap,
});
 
const { insuranceClaimChannelListForSelect } = useInsuranceClaimChannelList();
 
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 = createParams(pageIndex, pageSize);
      let res = await insuranceOrderServices.getInsuranceOrderPage(params, {
        showLoading: !state.loading,
      });
      return res;
    } catch (error) {}
  },
  {
    defaultExtraParams: {
      orderInput: [{ property: 'id', order: OrderInputType.Desc }],
      // creationTime: '',
      importChannel: '',
      condition: '',
      onJobFlag: '',
      insuranceType: '',
      creationDate: [] as unknown as ModelValueType,
    },
    columnsRenderProps: {
      createTime: {
        type: 'date',
        format: 'YYYY/MM/DD',
      },
      insuranceBeginTime: {
        type: 'date',
        format: 'YYYY/MM/DD',
      },
      insuranceEndTime: {
        type: 'date',
        format: 'YYYY/MM/DD',
      },
    },
  }
);
 
function createParams(pageIndex: number, pageSize: number) {
  let params: API.QueryInsuranceOrderPageInput = {
    pageModel: {
      rows: pageSize,
      page: pageIndex,
      orderInput: extraParamState.orderInput,
    },
    importChannel: extraParamState.importChannel,
    beginCreationTime: format(extraParamState.creationDate?.[0] ?? '', 'YYYY-MM-DD 00:00:00'),
    endCreationTime: format(extraParamState.creationDate?.[1] ?? '', 'YYYY-MM-DD 23:59:59'),
    insuranceType: extraParamState.insuranceType,
    onJobFlag: extraParamState.onJobFlag,
    condition: extraParamState.condition,
  };
  return params;
}
async function handleExport() {
  try {
    if (paginationState.total === 0) {
      Message.warnMessage('没有数据可以导出哦~');
      return;
    }
    let params = createParams(paginationState.pageIndex, paginationState.pageSize);
    let res = await insuranceOrderServices.exportInsuranceOrderList(params, {
      responseType: 'blob',
      getResponse: true,
    });
    if (res) {
      downloadFile(res.data, `保单导出`, 'xlsx');
    }
  } catch (error) {}
}
 
// const router = useRouter();
// function goDetail(row: API.InsuranceOrderListOutput) {
//   router.push({
//     name: 'InsuranceClaimDetail',
//     params: {
//       id: row.id,
//     },
//   });
// }
 
const {
  dialogProps: dialogBatchUploadOrderProps,
  handleAdd: handleBatchUploadOrderAdd,
  editForm: batchUploadOrderForm,
} = useFormDialog({
  onConfirm: addInsuranceOrderBillFile,
  defaultFormParams: {
    orderNo: '',
    url: [] as UploadUserFile[],
  },
});
 
async function addInsuranceOrderBillFile() {
  try {
    let params: API.AddInsuranceOrderBillFile = {
      orderNo: batchUploadOrderForm.orderNo,
      orderBillFile: batchUploadOrderForm.url?.[0].path ?? '',
    };
    let res = await insuranceOrderServices.addInsuranceOrderBillFile(params);
    if (res) {
      Message.successMessage('操作成功');
      getList(paginationState.pageIndex);
    }
  } catch (error) {}
}
 
function handleDownload(row?: API.InsuranceOrderListOutput) {
  downloadFileByUrl(setOSSLink(row.orderBillFile));
}
</script>