| | |
| | | return contractVO; |
| | | } |
| | | |
| | | @GetMapping("/download-document") |
| | | @Operation(summary = "按购销合同模板下载合同 Word 文件") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | | public void downloadDocument(@RequestParam("id") Long id, HttpServletResponse response) throws IOException { |
| | | // getContract 包含合同数据权限校验;沿用详情页的产品、单位和客户信息。 |
| | | CrmContractRespVO contract = buildContractDetail(contractService.getContract(id)); |
| | | Assert.notNull(contract, "合同不存在"); |
| | | byte[] content = cn.iocoder.yudao.module.crm.service.contract.CrmContractDocumentRenderer.render(contract); |
| | | String filename = "购销合同-" + contract.getNo() + ".docx"; |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); |
| | | response.setHeader("Cache-Control", "no-store"); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + java.net.URLEncoder.encode(filename, java.nio.charset.StandardCharsets.UTF_8).replace("+", "%20")); |
| | | response.setContentLength(content.length); |
| | | response.getOutputStream().write(content); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得合同分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |