Commit c4a33deb315a35e3058721f7340f832914c0e14f

Authored by sanmu
1 parent b225cd4b

feat: 新增筛选多选&新增比重全部导出

src/api/project/order.ts
@@ -28,12 +28,14 @@ enum Api { @@ -28,12 +28,14 @@ enum Api {
28 28
29 OPT_LOG = '/order/erp/opt/log/list_by_page', // 操作日志 29 OPT_LOG = '/order/erp/opt/log/list_by_page', // 操作日志
30 AUDIT_LOG = '/order/erp/audit/log/list_by_page', //审批日志 30 AUDIT_LOG = '/order/erp/audit/log/list_by_page', //审批日志
  31 + ORDER_RATE_EXPORT = '/order/erp/report/export', // 所有设计师比重导出
31 } 32 }
32 33
33 export const formatSearchData = (params) => { 34 export const formatSearchData = (params) => {
34 params.createStartTime = params.createStartTime 35 params.createStartTime = params.createStartTime
35 ? formatToDate(params.createStartTime) 36 ? formatToDate(params.createStartTime)
36 : undefined; 37 : undefined;
  38 + params.createEndTime = params.createEndTime ? formatToDate(params.createEndTime) : undefined;
37 params.productionDepartmentConsignStartTime = params.productionDepartmentConsignStartTime 39 params.productionDepartmentConsignStartTime = params.productionDepartmentConsignStartTime
38 ? formatToDate(params.productionDepartmentConsignStartTime) 40 ? formatToDate(params.productionDepartmentConsignStartTime)
39 : undefined; 41 : undefined;
@@ -129,6 +131,7 @@ export const orderGravity = async (data: any) => { @@ -129,6 +131,7 @@ export const orderGravity = async (data: any) => {
129 export const orderExport = async (data: any = {}) => { 131 export const orderExport = async (data: any = {}) => {
130 // const res = await defHttp.post<any>({ url: Api.EXPORT, data }); 132 // const res = await defHttp.post<any>({ url: Api.EXPORT, data });
131 const userStore = useUserStoreWithOut(); 133 const userStore = useUserStoreWithOut();
  134 + data = formatSearchData(data);
132 135
133 const token = userStore.getToken; 136 const token = userStore.getToken;
134 message.info('正在导出中...'); 137 message.info('正在导出中...');
@@ -178,7 +181,44 @@ export const orderExport = async (data: any = {}) =&gt; { @@ -178,7 +181,44 @@ export const orderExport = async (data: any = {}) =&gt; {
178 }) 181 })
179 .catch((error) => { 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,28 +11,42 @@
11 <Space> 11 <Space>
12 <span> 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 </span> 21 </span>
16 <a-button type="primary" @click="handleCalc" className="ml-4">计算</a-button> 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 </Space> 26 </Space>
18 <div className="mt-2">比重结果:{{ info }}</div> 27 <div className="mt-2">比重结果:{{ info }}</div>
19 </BasicModal> 28 </BasicModal>
20 </template> 29 </template>
21 <script lang="ts"> 30 <script lang="ts">
22 - import { defineComponent, ref } from 'vue'; 31 + import { computed, defineComponent, ref } from 'vue';
23 import { BasicModal, useModalInner } from '/@/components/Modal'; 32 import { BasicModal, useModalInner } from '/@/components/Modal';
24 - import { orderGravity } from '/@/api/project/order'; 33 + import { orderGravity, orderRateExport } from '/@/api/project/order';
25 import { Select, Space } from 'ant-design-vue'; 34 import { Select, Space } from 'ant-design-vue';
26 import { useOrderStoreWithOut } from '/@/store/modules/order'; 35 import { useOrderStoreWithOut } from '/@/store/modules/order';
27 import { useOrderInfo } from '/@/hooks/component/order'; 36 import { useOrderInfo } from '/@/hooks/component/order';
  37 + import { uniqBy } from 'lodash-es';
28 38
29 export default defineComponent({ 39 export default defineComponent({
30 components: { BasicModal, Select, Space }, 40 components: { BasicModal, Select, Space },
31 setup() { 41 setup() {
32 const orderStore = useOrderStoreWithOut(); 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 const activeUser = ref(); 50 const activeUser = ref();
37 const info = ref(); 51 const info = ref();
38 const searchData = ref({}); 52 const searchData = ref({});
@@ -44,7 +58,6 @@ @@ -44,7 +58,6 @@
44 58
45 function handleShow(visible: boolean) { 59 function handleShow(visible: boolean) {
46 if (visible) { 60 if (visible) {
47 - loading.value = true;  
48 // setModalProps({ loading: true, confirmLoading: true }); 61 // setModalProps({ loading: true, confirmLoading: true });
49 setModalProps({ loading: false, confirmLoading: false }); 62 setModalProps({ loading: false, confirmLoading: false });
50 } 63 }
@@ -55,17 +68,25 @@ @@ -55,17 +68,25 @@
55 ...searchData.value, 68 ...searchData.value,
56 designer: activeUser.value, 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 return { 79 return {
61 register, 80 register,
62 - loading,  
63 handleShow, 81 handleShow,
64 info, 82 info,
65 manualPreform, 83 manualPreform,
66 handleCalc, 84 handleCalc,
67 activeUser, 85 activeUser,
68 exchangeRate, 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,15 +82,17 @@
82 </template> 82 </template>
83 83
84 <template #toolbar> 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 <a-button type="primary" @click="handleExportModal">导出</a-button> 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 >分析利润</a-button 90 >分析利润</a-button
89 > 91 >
90 <a-button 92 <a-button
91 type="primary" 93 type="primary"
92 @click="handleAdd" 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 >创建订单</a-button 96 >创建订单</a-button
95 > 97 >
96 </template> 98 </template>
src/views/project/order/tableData.tsx
@@ -1262,6 +1262,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1262,6 +1262,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1262 labelWidth: 150, 1262 labelWidth: 150,
1263 1263
1264 componentProps: { 1264 componentProps: {
  1265 + mode: 'multiple',
  1266 +
1265 options: [ 1267 options: [
1266 { label: '订单创建完成', value: 0 }, 1268 { label: '订单创建完成', value: 0 },
1267 { label: '利润分析表待审核', value: 10 }, 1269 { label: '利润分析表待审核', value: 10 },
@@ -1304,10 +1306,10 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1304,10 +1306,10 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1304 span: 6, 1306 span: 6,
1305 }, 1307 },
1306 labelWidth: 150, 1308 labelWidth: 150,
1307 -  
1308 componentProps: { 1309 componentProps: {
1309 options: customerCode, 1310 options: customerCode,
1310 showSearch: true, 1311 showSearch: true,
  1312 + mode: 'multiple',
1311 }, 1313 },
1312 }, 1314 },
1313 { 1315 {
@@ -1356,6 +1358,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1356,6 +1358,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1356 labelWidth: 150, 1358 labelWidth: 150,
1357 1359
1358 componentProps: { 1360 componentProps: {
  1361 + mode: 'multiple',
  1362 +
1359 options: productionDepartment, 1363 options: productionDepartment,
1360 showSearch: true, 1364 showSearch: true,
1361 }, 1365 },
@@ -1428,6 +1432,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1428,6 +1432,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1428 labelWidth: 150, 1432 labelWidth: 150,
1429 1433
1430 componentProps: { 1434 componentProps: {
  1435 + mode: 'multiple',
  1436 +
1431 options: ideaSource, 1437 options: ideaSource,
1432 showSearch: true, 1438 showSearch: true,
1433 }, 1439 },
@@ -1443,6 +1449,7 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1443,6 +1449,7 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1443 componentProps: { 1449 componentProps: {
1444 options: manualPreform, 1450 options: manualPreform,
1445 showSearch: true, 1451 showSearch: true,
  1452 + mode: 'multiple',
1446 }, 1453 },
1447 }, 1454 },
1448 { 1455 {
@@ -1454,6 +1461,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1454,6 +1461,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1454 }, 1461 },
1455 labelWidth: 150, 1462 labelWidth: 150,
1456 componentProps: { 1463 componentProps: {
  1464 + mode: 'multiple',
  1465 +
1457 options: manualPreform, 1466 options: manualPreform,
1458 showSearch: true, 1467 showSearch: true,
1459 }, 1468 },
@@ -1468,6 +1477,7 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1468,6 +1477,7 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1468 labelWidth: 150, 1477 labelWidth: 150,
1469 1478
1470 componentProps: { 1479 componentProps: {
  1480 + mode: 'multiple',
1471 options: [ 1481 options: [
1472 { 1482 {
1473 label: 'ok', 1483 label: 'ok',
@@ -1519,6 +1529,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1519,6 +1529,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1519 labelWidth: 150, 1529 labelWidth: 150,
1520 1530
1521 componentProps: { 1531 componentProps: {
  1532 + mode: 'multiple',
  1533 +
1522 options: midCheckResult, 1534 options: midCheckResult,
1523 showSearch: true, 1535 showSearch: true,
1524 }, 1536 },
@@ -1533,6 +1545,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; { @@ -1533,6 +1545,8 @@ export function getFormConfig(): Partial&lt;FormProps&gt; {
1533 labelWidth: 150, 1545 labelWidth: 150,
1534 1546
1535 componentProps: { 1547 componentProps: {
  1548 + mode: 'multiple',
  1549 +
1536 showSearch: true, 1550 showSearch: true,
1537 options: endCheckResult, 1551 options: endCheckResult,
1538 }, 1552 },