Commit c4a33deb315a35e3058721f7340f832914c0e14f
1 parent
b225cd4b
feat: 新增筛选多选&新增比重全部导出
Showing
4 changed files
with
90 additions
and
13 deletions
src/api/project/order.ts
... | ... | @@ -28,12 +28,14 @@ enum Api { |
28 | 28 | |
29 | 29 | OPT_LOG = '/order/erp/opt/log/list_by_page', // 操作日志 |
30 | 30 | AUDIT_LOG = '/order/erp/audit/log/list_by_page', //审批日志 |
31 | + ORDER_RATE_EXPORT = '/order/erp/report/export', // 所有设计师比重导出 | |
31 | 32 | } |
32 | 33 | |
33 | 34 | export const formatSearchData = (params) => { |
34 | 35 | params.createStartTime = params.createStartTime |
35 | 36 | ? formatToDate(params.createStartTime) |
36 | 37 | : undefined; |
38 | + params.createEndTime = params.createEndTime ? formatToDate(params.createEndTime) : undefined; | |
37 | 39 | params.productionDepartmentConsignStartTime = params.productionDepartmentConsignStartTime |
38 | 40 | ? formatToDate(params.productionDepartmentConsignStartTime) |
39 | 41 | : undefined; |
... | ... | @@ -129,6 +131,7 @@ export const orderGravity = async (data: any) => { |
129 | 131 | export const orderExport = async (data: any = {}) => { |
130 | 132 | // const res = await defHttp.post<any>({ url: Api.EXPORT, data }); |
131 | 133 | const userStore = useUserStoreWithOut(); |
134 | + data = formatSearchData(data); | |
132 | 135 | |
133 | 136 | const token = userStore.getToken; |
134 | 137 | message.info('正在导出中...'); |
... | ... | @@ -178,7 +181,44 @@ export const orderExport = async (data: any = {}) => { |
178 | 181 | }) |
179 | 182 | .catch((error) => { |
180 | 183 | // 处理错误 |
181 | - console.error('导出错误', error); | |
184 | + message.error('导出错误', error); | |
185 | + }); | |
186 | +}; | |
187 | + | |
188 | +export const orderRateExport = async (data: any = {}) => { | |
189 | + // const res = await defHttp.post<any>({ url: Api.EXPORT, data }); | |
190 | + const userStore = useUserStoreWithOut(); | |
191 | + data = formatSearchData(data); | |
192 | + | |
193 | + const token = userStore.getToken; | |
194 | + message.info('正在导出中...'); | |
195 | + | |
196 | + return axios({ | |
197 | + url: '/basic-api' + Api.ORDER_RATE_EXPORT, | |
198 | + method: 'post', | |
199 | + responseType: 'blob', | |
200 | + headers: { Authorization: `${token}` }, | |
201 | + data, | |
202 | + }) | |
203 | + .then((response) => { | |
204 | + // 创建一个新的 Blob 对象,它包含了服务器响应的数据(即你的 Excel 文件) | |
205 | + const blob = new Blob([response.data]); // Excel 的 MIME 类型 | |
206 | + const downloadUrl = window.URL.createObjectURL(blob); | |
207 | + const a = document.createElement('a'); | |
208 | + a.href = downloadUrl; | |
209 | + const date = formatToDateTime(Date.now()); | |
210 | + | |
211 | + a.download = `设计比重报表 ${date}.xlsx`; // 你可以为文件命名 | |
212 | + document.body.appendChild(a); | |
213 | + a.click(); // 模拟点击操作来下载文件 | |
214 | + URL.revokeObjectURL(downloadUrl); // 释放掉 blob 对象所占用的内存 | |
215 | + document.body.removeChild(a); | |
216 | + | |
217 | + message.success('导出成功'); | |
218 | + }) | |
219 | + .catch((error) => { | |
220 | + // 处理错误 | |
221 | + message.error('导出错误', error); | |
182 | 222 | }); |
183 | 223 | }; |
184 | 224 | ... | ... |
src/views/project/order/RateModal.vue
... | ... | @@ -11,28 +11,42 @@ |
11 | 11 | <Space> |
12 | 12 | <span> |
13 | 13 | 设计师: |
14 | - <Select :options="manualPreform" placeholder="请选择" v-model:value="activeUser" /> | |
14 | + <Select | |
15 | + :options="options" | |
16 | + placeholder="请选择" | |
17 | + v-model:value="activeUser" | |
18 | + showSearch | |
19 | + style="width: 100px" | |
20 | + /> | |
15 | 21 | </span> |
16 | 22 | <a-button type="primary" @click="handleCalc" className="ml-4">计算</a-button> |
23 | + <a-button type="primary" @click="handleExport" className="ml-4" :loading="exportLoading" | |
24 | + >导出所有设计师比重</a-button | |
25 | + > | |
17 | 26 | </Space> |
18 | 27 | <div className="mt-2">比重结果:{{ info }}</div> |
19 | 28 | </BasicModal> |
20 | 29 | </template> |
21 | 30 | <script lang="ts"> |
22 | - import { defineComponent, ref } from 'vue'; | |
31 | + import { computed, defineComponent, ref } from 'vue'; | |
23 | 32 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
24 | - import { orderGravity } from '/@/api/project/order'; | |
33 | + import { orderGravity, orderRateExport } from '/@/api/project/order'; | |
25 | 34 | import { Select, Space } from 'ant-design-vue'; |
26 | 35 | import { useOrderStoreWithOut } from '/@/store/modules/order'; |
27 | 36 | import { useOrderInfo } from '/@/hooks/component/order'; |
37 | + import { uniqBy } from 'lodash-es'; | |
28 | 38 | |
29 | 39 | export default defineComponent({ |
30 | 40 | components: { BasicModal, Select, Space }, |
31 | 41 | setup() { |
32 | 42 | const orderStore = useOrderStoreWithOut(); |
33 | - const { manualPreform, exchangeRate } = useOrderInfo(orderStore); | |
43 | + const { manualPreform, exchangeRate, ideaSource } = useOrderInfo(orderStore); | |
34 | 44 | |
35 | - const loading = ref(true); | |
45 | + let options = computed(() => { | |
46 | + return uniqBy([...(manualPreform.value || []), ...(ideaSource.value || [])], 'label'); | |
47 | + }); | |
48 | + | |
49 | + const exportLoading = ref(false); | |
36 | 50 | const activeUser = ref(); |
37 | 51 | const info = ref(); |
38 | 52 | const searchData = ref({}); |
... | ... | @@ -44,7 +58,6 @@ |
44 | 58 | |
45 | 59 | function handleShow(visible: boolean) { |
46 | 60 | if (visible) { |
47 | - loading.value = true; | |
48 | 61 | // setModalProps({ loading: true, confirmLoading: true }); |
49 | 62 | setModalProps({ loading: false, confirmLoading: false }); |
50 | 63 | } |
... | ... | @@ -55,17 +68,25 @@ |
55 | 68 | ...searchData.value, |
56 | 69 | designer: activeUser.value, |
57 | 70 | }); |
58 | - info.value = (res?.rate || 0).toFixed(2); | |
71 | + info.value = res?.rate || 0; | |
72 | + } | |
73 | + | |
74 | + async function handleExport() { | |
75 | + exportLoading.value = true; | |
76 | + await orderRateExport({ ...searchData.value }); | |
77 | + exportLoading.value = false; | |
59 | 78 | } |
60 | 79 | return { |
61 | 80 | register, |
62 | - loading, | |
63 | 81 | handleShow, |
64 | 82 | info, |
65 | 83 | manualPreform, |
66 | 84 | handleCalc, |
67 | 85 | activeUser, |
68 | 86 | exchangeRate, |
87 | + options, | |
88 | + exportLoading, | |
89 | + handleExport, | |
69 | 90 | }; |
70 | 91 | }, |
71 | 92 | }); | ... | ... |
src/views/project/order/index.vue
... | ... | @@ -82,15 +82,17 @@ |
82 | 82 | </template> |
83 | 83 | |
84 | 84 | <template #toolbar> |
85 | - <a-button type="primary" @click="handleRateModal">比重计算</a-button> | |
85 | + <a-button type="primary" @click="handleRateModal" v-if="role === ROLE.ADMIN" | |
86 | + >比重计算</a-button | |
87 | + > | |
86 | 88 | <a-button type="primary" @click="handleExportModal">导出</a-button> |
87 | - <a-button type="primary" @click="handleProfitModal" :disabled="role === ROLE.TRACKER" | |
89 | + <a-button type="primary" @click="handleProfitModal" v-if="role === ROLE.ADMIN" | |
88 | 90 | >分析利润</a-button |
89 | 91 | > |
90 | 92 | <a-button |
91 | 93 | type="primary" |
92 | 94 | @click="handleAdd" |
93 | - v-if="role !== ROLE.INSPECT && role !== ROLE.DATA_REPORT_USER" | |
95 | + v-if="role === ROLE.ADMIN && role === ROLE.BUSINESS && role === ROLE.TRACKER" | |
94 | 96 | >创建订单</a-button |
95 | 97 | > |
96 | 98 | </template> | ... | ... |
src/views/project/order/tableData.tsx
... | ... | @@ -1262,6 +1262,8 @@ export function getFormConfig(): Partial<FormProps> { |
1262 | 1262 | labelWidth: 150, |
1263 | 1263 | |
1264 | 1264 | componentProps: { |
1265 | + mode: 'multiple', | |
1266 | + | |
1265 | 1267 | options: [ |
1266 | 1268 | { label: '订单创建完成', value: 0 }, |
1267 | 1269 | { label: '利润分析表待审核', value: 10 }, |
... | ... | @@ -1304,10 +1306,10 @@ export function getFormConfig(): Partial<FormProps> { |
1304 | 1306 | span: 6, |
1305 | 1307 | }, |
1306 | 1308 | labelWidth: 150, |
1307 | - | |
1308 | 1309 | componentProps: { |
1309 | 1310 | options: customerCode, |
1310 | 1311 | showSearch: true, |
1312 | + mode: 'multiple', | |
1311 | 1313 | }, |
1312 | 1314 | }, |
1313 | 1315 | { |
... | ... | @@ -1356,6 +1358,8 @@ export function getFormConfig(): Partial<FormProps> { |
1356 | 1358 | labelWidth: 150, |
1357 | 1359 | |
1358 | 1360 | componentProps: { |
1361 | + mode: 'multiple', | |
1362 | + | |
1359 | 1363 | options: productionDepartment, |
1360 | 1364 | showSearch: true, |
1361 | 1365 | }, |
... | ... | @@ -1428,6 +1432,8 @@ export function getFormConfig(): Partial<FormProps> { |
1428 | 1432 | labelWidth: 150, |
1429 | 1433 | |
1430 | 1434 | componentProps: { |
1435 | + mode: 'multiple', | |
1436 | + | |
1431 | 1437 | options: ideaSource, |
1432 | 1438 | showSearch: true, |
1433 | 1439 | }, |
... | ... | @@ -1443,6 +1449,7 @@ export function getFormConfig(): Partial<FormProps> { |
1443 | 1449 | componentProps: { |
1444 | 1450 | options: manualPreform, |
1445 | 1451 | showSearch: true, |
1452 | + mode: 'multiple', | |
1446 | 1453 | }, |
1447 | 1454 | }, |
1448 | 1455 | { |
... | ... | @@ -1454,6 +1461,8 @@ export function getFormConfig(): Partial<FormProps> { |
1454 | 1461 | }, |
1455 | 1462 | labelWidth: 150, |
1456 | 1463 | componentProps: { |
1464 | + mode: 'multiple', | |
1465 | + | |
1457 | 1466 | options: manualPreform, |
1458 | 1467 | showSearch: true, |
1459 | 1468 | }, |
... | ... | @@ -1468,6 +1477,7 @@ export function getFormConfig(): Partial<FormProps> { |
1468 | 1477 | labelWidth: 150, |
1469 | 1478 | |
1470 | 1479 | componentProps: { |
1480 | + mode: 'multiple', | |
1471 | 1481 | options: [ |
1472 | 1482 | { |
1473 | 1483 | label: 'ok', |
... | ... | @@ -1519,6 +1529,8 @@ export function getFormConfig(): Partial<FormProps> { |
1519 | 1529 | labelWidth: 150, |
1520 | 1530 | |
1521 | 1531 | componentProps: { |
1532 | + mode: 'multiple', | |
1533 | + | |
1522 | 1534 | options: midCheckResult, |
1523 | 1535 | showSearch: true, |
1524 | 1536 | }, |
... | ... | @@ -1533,6 +1545,8 @@ export function getFormConfig(): Partial<FormProps> { |
1533 | 1545 | labelWidth: 150, |
1534 | 1546 | |
1535 | 1547 | componentProps: { |
1548 | + mode: 'multiple', | |
1549 | + | |
1536 | 1550 | showSearch: true, |
1537 | 1551 | options: endCheckResult, |
1538 | 1552 | }, | ... | ... |