Commit 1484978afeeb9556b57fb76f2ea4deabdff26762
Merge branch 'zwl-develop' into 'develop'
feat: 智拓数据导出 See merge request !23
Showing
1 changed file
with
67 additions
and
1 deletions
src/views/project/order/index.vue
... | ... | @@ -117,6 +117,22 @@ |
117 | 117 | <div style="padding-left: 50px; right: 123px"> |
118 | 118 | <!-- <a-space wrap :size="[8, 16]" :style="{ marginBottom: '2px', marginLeft: '10px' }"> --> |
119 | 119 | <a-space wrap :style="{ marginBottom: '2px', marginTop: '2px' }"> |
120 | + <a-select | |
121 | + ref="select" | |
122 | + v-model:value="valueZhituo" | |
123 | + @change="handleChange" | |
124 | + class="passCalculate" | |
125 | + dropdown-class-name="dropdown-class" | |
126 | + v-if="role === ROLE.ADMIN || role === ROLE.TRACKER || role === ROLE.BUSINESS" | |
127 | + > | |
128 | + <a-select-option value="智拓数据导出">智拓数据导出</a-select-option> | |
129 | + <a-select-option value="智拓跟单" @click="handleZhituoModal('1')" | |
130 | + >智拓跟单</a-select-option | |
131 | + > | |
132 | + <a-select-option value="智拓内部" @click="handleZhituoModal('2')" | |
133 | + >智拓内部</a-select-option | |
134 | + > | |
135 | + </a-select> | |
120 | 136 | <a-button |
121 | 137 | :style="{backgroundColor: '#ff69b4', borderColor: '#ff69b4', color: 'white',borderRadius: '5px 5px 5px 5px' }" |
122 | 138 | shape="default" |
... | ... | @@ -295,7 +311,8 @@ |
295 | 311 | import { ROLE } from './type.d'; |
296 | 312 | import { getUserList } from '/@/api/project/account'; |
297 | 313 | import { useMessage } from '/@/hooks/web/useMessage'; |
298 | - import { getBaseInvoice } from '/@/api/project/invoice'; | |
314 | + import { getBaseInvoice, getZhituoExport} from '/@/api/project/invoice'; | |
315 | + import axios from 'axios'; | |
299 | 316 | |
300 | 317 | const orderStore = useOrderStoreWithOut(); |
301 | 318 | const userStore = useUserStoreWithOut(); |
... | ... | @@ -726,6 +743,7 @@ |
726 | 743 | |
727 | 744 | //一次通过率 |
728 | 745 | const value1 = ref('一次通过率'); |
746 | + const valueZhituo = ref('智拓数据导出'); | |
729 | 747 | function handleChange() {} |
730 | 748 | function handlePassModal(title) { |
731 | 749 | const form = getForm(); |
... | ... | @@ -736,6 +754,52 @@ |
736 | 754 | searchData: values, |
737 | 755 | }); |
738 | 756 | } |
757 | + | |
758 | + function handleZhituoModal(type) { | |
759 | + if (!checkedKeys.value.length) { | |
760 | + createMessage.warn('请选择要导出的数据!'); | |
761 | + return; | |
762 | + } | |
763 | + const params = { | |
764 | + ids: checkedKeys.value, | |
765 | + type: type, | |
766 | + }; | |
767 | + const token = userStore.getToken; | |
768 | + axios | |
769 | + .post( | |
770 | + '/basic-api/order/erp/order/exportExcel', // 修正接口地址 | |
771 | + params, | |
772 | + { | |
773 | + headers: { | |
774 | + Authorization: `${token}`, | |
775 | + }, | |
776 | + responseType: 'blob', | |
777 | + }, | |
778 | + ) | |
779 | + .then((response) => { | |
780 | + const blob = new Blob([response.data], { type: 'application/zip' }); | |
781 | + const getFormattedDate = (): string => { | |
782 | + const date = new Date(); | |
783 | + const year = date.getFullYear(); | |
784 | + const month = String(date.getMonth() + 1).padStart(2, '0'); | |
785 | + const day = String(date.getDate()).padStart(2, '0'); | |
786 | + const hours = String(date.getHours()).padStart(2, '0'); | |
787 | + const minutes = String(date.getMinutes()).padStart(2, '0'); | |
788 | + const seconds = String(date.getSeconds()).padStart(2, '0'); | |
789 | + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; | |
790 | + }; | |
791 | + const date = getFormattedDate(); | |
792 | + const link = document.createElement('a'); | |
793 | + link.href = window.URL.createObjectURL(blob); | |
794 | + link.download = `智拓导出${date}.xlsx`; | |
795 | + document.body.appendChild(link); | |
796 | + link.click(); | |
797 | + document.body.removeChild(link); | |
798 | + }) | |
799 | + .catch((error) => { | |
800 | + console.error(error); | |
801 | + }); | |
802 | + } | |
739 | 803 | // const form = getForm(); |
740 | 804 | // const values = form.getFieldsValue(); |
741 | 805 | // if (title == '确认样品') { |
... | ... | @@ -930,7 +994,9 @@ |
930 | 994 | handleHistory, |
931 | 995 | focus, |
932 | 996 | value1, |
997 | + valueZhituo, | |
933 | 998 | handlePassModal, |
999 | + handleZhituoModal, | |
934 | 1000 | handleTrackHistory, |
935 | 1001 | handleAdd, |
936 | 1002 | createImgPreview, | ... | ... |