Skip to content

Commit 1e0b9bf

Browse files
committed
fetch: add retail module view receipt detail export function and api eairps#245
1 parent 236b058 commit 1e0b9bf

File tree

8 files changed

+122
-11
lines changed

8 files changed

+122
-11
lines changed

core/api/src/main/java/com/wansenai/api/receipt/RetailController.java

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import jakarta.servlet.http.HttpServletResponse;
2828
import org.springframework.web.bind.annotation.*;
2929

30+
import java.io.IOException;
3031
import java.util.List;
3132

3233
@RestController
@@ -109,8 +110,18 @@ public void exportShipmentsExcel(@ModelAttribute QueryShipmentsDTO queryShipment
109110
receiptRetailService.exportRetailShipmentsExcel(queryShipmentsDTO, response);
110111
}
111112

113+
@GetMapping("/shipments/exportDetail/{receiptNumber}")
114+
public void exportShipmentsDetailExcel(@PathVariable("receiptNumber") String receiptNumber, HttpServletResponse response) throws IOException {
115+
receiptRetailService.exportShipmentsDetailExcel(receiptNumber, response);
116+
}
117+
112118
@GetMapping("/refund/export")
113119
public void exportRefundExcel(@ModelAttribute QueryRetailRefundDTO queryRetailRefundDTO, HttpServletResponse response) throws Exception {
114120
receiptRetailService.exportRetailRefundExcel(queryRetailRefundDTO, response);
115121
}
122+
123+
@GetMapping("/refund/exportDetail/{receiptNumber}")
124+
public void exportRefundDetailExcel(@PathVariable("receiptNumber") String receiptNumber, HttpServletResponse response) throws IOException {
125+
receiptRetailService.exportRefundDetailExcel(receiptNumber, response);
126+
}
116127
}

core/service/src/main/java/com/wansenai/service/receipt/ReceiptRetailService.java

+11
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ public interface ReceiptRetailService extends IService<ReceiptRetailMain> {
205205
*/
206206
void exportRetailShipmentsExcel(QueryShipmentsDTO queryShipmentsDTO, HttpServletResponse response) throws Exception;
207207

208+
/**
209+
*
210+
* @param receiptNumber
211+
* @param response
212+
* @throws IOException
213+
*/
214+
void exportShipmentsDetailExcel(String receiptNumber, HttpServletResponse response) throws IOException;
215+
216+
208217
/**
209218
* Query data through public query criteria and export retail refund data files
210219
* 根据公共查询条件查询数据并导出零售退货数据文件
@@ -220,4 +229,6 @@ public interface ReceiptRetailService extends IService<ReceiptRetailMain> {
220229
* 异常
221230
*/
222231
void exportRetailRefundExcel(QueryRetailRefundDTO queryRetailRefundDTO, HttpServletResponse response) throws Exception;
232+
233+
void exportRefundDetailExcel(String receiptNumber, HttpServletResponse response) throws IOException;
223234
}

core/service/src/main/java/com/wansenai/service/receipt/impl/ReceiptRetailServiceImpl.java

+49
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.wansenai.vo.receipt.retail.*;
5151
import jakarta.servlet.http.HttpServletResponse;
5252
import lombok.extern.slf4j.Slf4j;
53+
import org.springframework.beans.BeanUtils;
5354
import org.springframework.stereotype.Service;
5455
import org.springframework.transaction.annotation.Transactional;
5556
import org.springframework.util.StringUtils;
@@ -921,6 +922,30 @@ public void exportRetailShipmentsExcel(QueryShipmentsDTO queryShipmentsDTO, Http
921922
}
922923
}
923924

925+
@Override
926+
public void exportShipmentsDetailExcel(String receiptNumber, HttpServletResponse response) {
927+
var id = lambdaQuery()
928+
.eq(ReceiptRetailMain::getReceiptNumber, receiptNumber)
929+
.eq(ReceiptRetailMain::getDeleteFlag, CommonConstants.NOT_DELETED)
930+
.one()
931+
.getId();
932+
var detail = getRetailShipmentsDetail(id);
933+
if (detail != null) {
934+
var data = detail.getData();
935+
var tableData = data.getTableData();
936+
var exportData = new ArrayList<ShipmentsDataExportBO>();
937+
tableData.forEach(item -> {
938+
var shipmentBo = new ShipmentsDataExportBO();
939+
shipmentBo.setMemberName(data.getMemberName());
940+
shipmentBo.setReceiptNumber(data.getReceiptNumber());
941+
BeanUtils.copyProperties(item, shipmentBo);
942+
exportData.add(shipmentBo);
943+
});
944+
var fileName = data.getReceiptNumber() + "-零售出库单明细";
945+
ExcelUtils.export(response, fileName, ExcelUtils.getSheetData(exportData));
946+
}
947+
}
948+
924949
@Override
925950
public void exportRetailRefundExcel(QueryRetailRefundDTO queryRetailRefundDTO, HttpServletResponse response) throws Exception {
926951
var exportMap = new ConcurrentHashMap<String, List<List<Object>>>();
@@ -957,4 +982,28 @@ public void exportRetailRefundExcel(QueryRetailRefundDTO queryRetailRefundDTO, H
957982
}
958983
}
959984

985+
@Override
986+
public void exportRefundDetailExcel(String receiptNumber, HttpServletResponse response) throws IOException {
987+
var id = lambdaQuery()
988+
.eq(ReceiptRetailMain::getReceiptNumber, receiptNumber)
989+
.eq(ReceiptRetailMain::getDeleteFlag, CommonConstants.NOT_DELETED)
990+
.one()
991+
.getId();
992+
var detail = getRetailRefundDetail(id);
993+
if (detail != null) {
994+
var data = detail.getData();
995+
var tableData = data.getTableData();
996+
var exportData = new ArrayList<ShipmentsDataExportBO>();
997+
tableData.forEach(item -> {
998+
var shipmentBo = new ShipmentsDataExportBO();
999+
shipmentBo.setMemberName(data.getMemberName());
1000+
shipmentBo.setReceiptNumber(data.getReceiptNumber());
1001+
BeanUtils.copyProperties(item, shipmentBo);
1002+
exportData.add(shipmentBo);
1003+
});
1004+
var fileName = data.getReceiptNumber() + "-零售退货单明细";
1005+
ExcelUtils.export(response, fileName, ExcelUtils.getSheetData(exportData));
1006+
}
1007+
}
1008+
9601009
}

web/src/api/retail/model/shipmentsModel.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface AddOrUpdateShipmentsResp {
4141
id: number | string | undefined;
4242
memberId: number | string;
4343
memberName: string;
44+
paymentType: string;
4445
accountId: number | string;
4546
accountName: string;
4647
receiptDate: string;

web/src/api/retail/refund.ts

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum API {
1515
Delete = '/retail/refund/deleteByIds',
1616
GetLinkRefundDetail = '/retail/refund/getLinkRefundDetail',
1717
Export = '/retail/refund/export',
18+
ExportDetail = '/retail/refund/exportDetail',
1819
}
1920

2021
export function getRefundPageList(params: QueryShipmentsReq) {
@@ -89,4 +90,13 @@ export function exportRefund(params: QueryShipmentsReq) {
8990
responseType: "blob"
9091
}
9192
);
93+
}
94+
95+
export function exportRefundDetail(receiptNumber: string) {
96+
return defHttp.get<BaseDataResp<Blob>>(
97+
{
98+
url: `${API.ExportDetail}/${receiptNumber}`,
99+
responseType: "blob"
100+
}
101+
);
92102
}

web/src/api/retail/shipments.ts

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum API {
1616
GetDetail = '/retail/shipments/detail',
1717
GetLinkShipmentDetail = '/retail/shipments/getLinkShipmentDetail',
1818
Export = '/retail/shipments/export',
19+
ExportDetail = '/retail/shipments/exportDetail',
1920
}
2021

2122
export function getShipmentsPageList(params: QueryShipmentsReq) {
@@ -105,4 +106,13 @@ export function exportShipments(params: QueryShipmentsReq) {
105106
responseType: "blob"
106107
}
107108
);
109+
}
110+
111+
export function exportShipmentsDetail(receiptNumber: string) {
112+
return defHttp.get<BaseDataResp<Blob>>(
113+
{
114+
url: `${API.ExportDetail}/${receiptNumber}`,
115+
responseType: "blob"
116+
}
117+
);
108118
}

web/src/views/retail/refund/components/ViewRefundModal.vue

+13-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import {defineComponent, ref} from 'vue';
6060
import {BasicTable, useTable} from '/src/components/Table';
6161
import {BasicModal, useModal, useModalInner} from "@/components/Modal";
62-
import {getLinkRefundDetail} from "@/api/retail/refund";
62+
import {getLinkRefundDetail, exportRefundDetail} from "@/api/retail/refund";
6363
import {
6464
Descriptions,
6565
DescriptionsItem,
@@ -69,6 +69,7 @@ import {
6969
import {retailShipmentsTableColumns} from "@/views/retail/shipments/shipments.data";
7070
import ViewShipmentModal from "@/views/retail/shipments/components/ViewShipmentModal.vue";
7171
import printJS from "print-js";
72+
import {getTimestamp} from "@/utils/dateUtil";
7273
7374
export default defineComponent({
7475
name: 'ViewRefundModal',
@@ -135,8 +136,17 @@ export default defineComponent({
135136
});
136137
}
137138
138-
function exportTable() {
139-
139+
async function exportTable() {
140+
const file: any = await exportRefundDetail(receiptNumber.value)
141+
if (file.size > 0) {
142+
const blob = new Blob([file]);
143+
const link = document.createElement("a");
144+
const timestamp = getTimestamp(new Date());
145+
link.href = URL.createObjectURL(blob);
146+
link.download = "零售退货单据详情" + timestamp + ".xlsx";
147+
link.target = "_blank";
148+
link.click();
149+
}
140150
}
141151
142152
const flexContainer = 'display: flex; justify-content: space-between; border-bottom: 1px solid #ddd; padding: 8px;';

web/src/views/retail/shipments/components/ViewShipmentModal.vue

+17-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import {defineComponent, ref} from 'vue';
6060
import {BasicTable, useTable} from '/src/components/Table';
6161
import {BasicModal, useModalInner} from "@/components/Modal";
62-
import {getLinkShipmentsDetail} from "@/api/retail/shipments";
62+
import {getLinkShipmentsDetail, exportShipmentsDetail} from "@/api/retail/shipments";
6363
import printJS from 'print-js';
6464
import {
6565
Descriptions,
@@ -68,6 +68,7 @@ import {
6868
Statistic,
6969
} from 'ant-design-vue';
7070
import {retailShipmentsTableColumns} from "@/views/retail/shipments/shipments.data";
71+
import {getTimestamp} from "@/utils/dateUtil";
7172
7273
export default defineComponent({
7374
name: 'ViewShipmentModal',
@@ -82,18 +83,18 @@ export default defineComponent({
8283
setup() {
8384
const receiptNumber = ref('');
8485
const otherReceipt = ref('');
85-
const memberName = ref(0);
86+
const memberName = ref<any>('');
8687
const paymentType = ref('');
8788
const receiptDate = ref('');
8889
const receiptType = ref('');
89-
const receiptAmount = ref('');
90+
const receiptAmount = ref<any>('');
9091
const collectAmount = ref('');
91-
const backAmount = ref('');
92+
const backAmount = ref<any>('');
9293
const accountName = ref('');
9394
const remark = ref('')
9495
const status = ref();
9596
96-
const tableData = ref([]);
97+
const tableData = ref<any>([]);
9798
const [registerTable] = useTable({
9899
title: '出库商品表数据',
99100
columns: retailShipmentsTableColumns,
@@ -106,7 +107,6 @@ export default defineComponent({
106107
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
107108
setModalProps({confirmLoading: false, destroyOnClose: true, width: 1200, showOkBtn: false});
108109
const res = await getLinkShipmentsDetail(data.receiptNumber);
109-
console.info(res.data);
110110
tableData.value = res.data.tableData;
111111
receiptNumber.value = res.data.receiptNumber;
112112
memberName.value = res.data.memberName;
@@ -129,8 +129,17 @@ export default defineComponent({
129129
closeModal();
130130
}
131131
132-
function exportTable() {
133-
132+
async function exportTable() {
133+
const file: any = await exportShipmentsDetail(receiptNumber.value)
134+
if (file.size > 0) {
135+
const blob = new Blob([file]);
136+
const link = document.createElement("a");
137+
const timestamp = getTimestamp(new Date());
138+
link.href = URL.createObjectURL(blob);
139+
link.download = "零售出库单据详情" + timestamp + ".xlsx";
140+
link.target = "_blank";
141+
link.click();
142+
}
134143
}
135144
136145
const flexContainer = 'display: flex; justify-content: space-between; border-bottom: 1px solid #ddd; padding: 8px;';

0 commit comments

Comments
 (0)