Commit 0a60e4b5530e508c830584497e857491e1d92f55

Authored by 李宇
1 parent ffd6aaca

最新

antis-ncc-admin/src/views/statisticsList/form13.vue
@@ -609,7 +609,7 @@ export default { @@ -609,7 +609,7 @@ export default {
609 params.SourceType = this.query.SourceType 609 params.SourceType = this.query.SourceType
610 } 610 }
611 if (this.query.storeIds && this.query.storeIds.length > 0) { 611 if (this.query.storeIds && this.query.storeIds.length > 0) {
612 - params.StoreIds = this.query.storeIds 612 + params.StoreIds = this.query.storeIds.join(',')
613 } 613 }
614 614
615 request({ 615 request({
antis-ncc-admin/src/views/statisticsList/form14.vue
@@ -554,7 +554,7 @@ export default { @@ -554,7 +554,7 @@ export default {
554 } 554 }
555 555
556 if (this.query.StoreIds && this.query.StoreIds.length > 0) { 556 if (this.query.StoreIds && this.query.StoreIds.length > 0) {
557 - params.StoreIds = this.query.StoreIds 557 + params.StoreIds = this.query.StoreIds.join(',')
558 } 558 }
559 559
560 request({ 560 request({
antis-ncc-admin/src/views/statisticsList/form18.vue
@@ -539,7 +539,7 @@ export default { @@ -539,7 +539,7 @@ export default {
539 } 539 }
540 540
541 if (this.query.StoreIds && this.query.StoreIds.length > 0) { 541 if (this.query.StoreIds && this.query.StoreIds.length > 0) {
542 - params.StoreIds = this.query.StoreIds 542 + params.StoreIds = this.query.StoreIds.join(',')
543 } 543 }
544 544
545 if (this.query.StartTime) { 545 if (this.query.StartTime) {
antis-ncc-admin/src/views/statisticsList/form21.vue
@@ -285,8 +285,8 @@ @@ -285,8 +285,8 @@
285 285
286 <script> 286 <script>
287 import request from '@/utils/request' 287 import request from '@/utils/request'
  288 +
288 import Pagination from '@/components/Pagination' 289 import Pagination from '@/components/Pagination'
289 -import { saveAs } from 'file-saver'  
290 290
291 export default { 291 export default {
292 name: 'RefundDetailList', 292 name: 'RefundDetailList',
@@ -295,6 +295,7 @@ export default { @@ -295,6 +295,7 @@ export default {
295 }, 295 },
296 data() { 296 data() {
297 return { 297 return {
  298 + baseUrl: process.env.VUE_APP_BASE_API,
298 query: { 299 query: {
299 organizationType: undefined, 300 organizationType: undefined,
300 departmentId: undefined, 301 departmentId: undefined,
@@ -805,107 +806,103 @@ export default { @@ -805,107 +806,103 @@ export default {
805 }, 806 },
806 807
807 // 导出Excel 808 // 导出Excel
808 - async exportExcel() {  
809 - if (!this.list || this.list.length === 0) {  
810 - this.$message({  
811 - type: 'warning',  
812 - message: '暂无数据可导出',  
813 - duration: 1500  
814 - })  
815 - return 809 + exportExcel() {
  810 + this.listLoading = true
  811 +
  812 + // 构建导出参数(参考后端 RefundDetailListQueryInput)
  813 + const params = {}
  814 +
  815 + if (this.query.storeIds && this.query.storeIds.length > 0) {
  816 + params.storeIds = this.query.storeIds
816 } 817 }
817 818
818 - try {  
819 - // 动态导入 xlsx 库  
820 - const XLSX = await import('xlsx')  
821 -  
822 - // 构建表头  
823 - const headers = [  
824 - '门店名称',  
825 - '会员名称',  
826 - '会员电话',  
827 - '退卡时间',  
828 - '退卡品项名称',  
829 - '退卡数量',  
830 - '单价',  
831 - '总价',  
832 - '业绩类型',  
833 - '科美类型',  
834 - '来源类型',  
835 - '品项分类'  
836 - ]  
837 -  
838 - // 构建数据行  
839 - const dataRows = this.list.map(row => [  
840 - row.storeName || '无',  
841 - row.memberName || '无',  
842 - row.memberPhone || '无',  
843 - this.formatDateTime(row.refundTime) || '无',  
844 - row.itemName || '无',  
845 - row.refundQuantity || 0,  
846 - this.formatMoney(row.unitPrice),  
847 - this.formatMoney(row.totalPrice),  
848 - row.performanceType || '无',  
849 - row.beautyType || '无',  
850 - row.sourceType || '无',  
851 - row.itemCategory || '无'  
852 - ])  
853 -  
854 - // 合并表头和数据  
855 - const excelData = [headers, ...dataRows]  
856 -  
857 - // 创建工作簿  
858 - const ws = XLSX.utils.aoa_to_sheet(excelData)  
859 -  
860 - // 设置列宽  
861 - ws['!cols'] = [  
862 - { wch: 15 }, // 门店名称  
863 - { wch: 12 }, // 会员名称  
864 - { wch: 13 }, // 会员电话  
865 - { wch: 18 }, // 退卡时间  
866 - { wch: 20 }, // 退卡品项名称  
867 - { wch: 10 }, // 退卡数量  
868 - { wch: 12 }, // 单价  
869 - { wch: 12 }, // 总价  
870 - { wch: 12 }, // 业绩类型  
871 - { wch: 12 }, // 科美类型  
872 - { wch: 12 }, // 来源类型  
873 - { wch: 12 } // 品项分类  
874 - ]  
875 -  
876 - // 创建工作簿  
877 - const wb = XLSX.utils.book_new()  
878 - XLSX.utils.book_append_sheet(wb, ws, '退卡品项明细表')  
879 -  
880 - // 生成文件名  
881 - const now = new Date()  
882 - const fileName = `退卡品项明细表_${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}_${now.getTime()}.xlsx`  
883 -  
884 - // 导出文件  
885 - const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' })  
886 - saveAs(new Blob([wbout], { type: 'application/octet-stream' }), fileName)  
887 -  
888 - this.$message({  
889 - type: 'success',  
890 - message: '导出成功',  
891 - duration: 1500  
892 - })  
893 - } catch (error) {  
894 - console.error('导出失败:', error)  
895 - if (error.message && error.message.includes('xlsx')) {  
896 - this.$message({  
897 - type: 'error',  
898 - message: '导出失败:请先安装 xlsx 库,运行命令: npm install xlsx --save',  
899 - duration: 3000  
900 - }) 819 + if (this.query.memberId) {
  820 + params.memberId = this.query.memberId
  821 + }
  822 +
  823 + if (this.query.startTime) {
  824 + params.startTime = this.query.startTime
  825 + }
  826 +
  827 + if (this.query.endTime) {
  828 + params.endTime = this.query.endTime
  829 + }
  830 +
  831 + if (this.query.itemId) {
  832 + params.itemId = this.query.itemId
  833 + }
  834 +
  835 + if (this.query.performanceType) {
  836 + params.performanceType = this.query.performanceType
  837 + }
  838 +
  839 + if (this.query.beautyType) {
  840 + params.beautyType = this.query.beautyType
  841 + }
  842 +
  843 + if (this.query.sourceType) {
  844 + params.sourceType = this.query.sourceType
  845 + }
  846 +
  847 + if (this.query.itemCategory) {
  848 + params.itemCategory = this.query.itemCategory
  849 + }
  850 +
  851 + // 排序参数(导出时也使用相同的排序)
  852 + if (this.sortProp) {
  853 + params.sidx = this.sortProp
  854 + params.sort = this.sortOrder === 'ascending' ? 'asc' : 'desc'
  855 + }
  856 +
  857 + request({
  858 + url: '/api/Extend/LqHytkHytk/refund-detail-export',
  859 + method: 'POST',
  860 + data: params
  861 + }).then(res => {
  862 + this.listLoading = false
  863 + if (res.code === 200 && res.data) {
  864 + // 如果返回了错误消息
  865 + if (res.data.message) {
  866 + this.$message({
  867 + type: 'warning',
  868 + message: res.data.message,
  869 + duration: 2000
  870 + })
  871 + return
  872 + }
  873 + // 如果返回了下载链接
  874 + if (res.data.url) {
  875 + // 构建完整URL并下载
  876 + const downloadUrl = this.baseUrl + res.data.url
  877 + window.location.href = downloadUrl
  878 + this.$message({
  879 + type: 'success',
  880 + message: '导出成功',
  881 + duration: 1500
  882 + })
  883 + } else {
  884 + this.$message({
  885 + type: 'error',
  886 + message: '导出失败:未返回下载链接',
  887 + duration: 2000
  888 + })
  889 + }
901 } else { 890 } else {
902 this.$message({ 891 this.$message({
903 type: 'error', 892 type: 'error',
904 - message: '导出失败:' + (error.message || '未知错误'), 893 + message: res.msg || '导出失败',
905 duration: 2000 894 duration: 2000
906 }) 895 })
907 } 896 }
908 - } 897 + }).catch(err => {
  898 + this.listLoading = false
  899 + console.error('导出失败:', err)
  900 + this.$message({
  901 + type: 'error',
  902 + message: '导出失败,请重试',
  903 + duration: 2000
  904 + })
  905 + })
909 } 906 }
910 } 907 }
911 } 908 }