| | |
| | | <script setup> |
| | | import BasicTable from "@/components/BasicTable.vue" |
| | | import { ref} from "vue" |
| | | |
| | | import request from "@/utils/request" |
| | | const childrenData = ref({ |
| | | columns:[ |
| | | {type:'expand',fixed:"left",width: 80,slots: { content:'content' }}, |
| | |
| | | footList:['quantity','grossArea','computeGrossArea','perimeter','price','grossAmount'] |
| | | }) |
| | | |
| | | request.post('/order/exportOrderReport',null,{responseType :'blob'}).then(res => { |
| | | const blob = new Blob([res]) |
| | | // console.log(blob) |
| | | // if ('download' in document.createElement('a')) { // 非IE下载 |
| | | // const elink = document.createElement('a') |
| | | // elink.download = 'a.xlsx' |
| | | // elink.style.display = 'none' |
| | | // elink.href = URL.createObjectURL(blob) |
| | | // document.body.appendChild(elink) |
| | | // elink.click() |
| | | // URL.revokeObjectURL(elink.href) // 释放URL 对象 |
| | | // document.body.removeChild(elink) |
| | | // } else { // IE10+下载 |
| | | // navigator.msSaveBlob(blob, fileName) |
| | | // } |
| | | |
| | | }) |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | <version>4.3.5.Final</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | <version>3.2.1</version> |
| | | </dependency> |
| | | |
| | | |
| | | </dependencies> |
| | | |
| | |
| | | </build> |
| | | |
| | | |
| | | <!--<repositories> |
| | | <repository> |
| | | <id>nexus-aliyun</id> |
| | | <name>nexus-aliyun</name> |
| | | <url>http://maven.aliyun.com/nexus/content/groups/public/</url> |
| | | <releases> |
| | | <enabled>true</enabled> |
| | | </releases> |
| | | <snapshots> |
| | | <enabled>false</enabled> |
| | | </snapshots> |
| | | </repository> |
| | | </repositories> |
| | | <!-- <repositories>--> |
| | | <!-- <repository>--> |
| | | <!-- <id>nexus-aliyun</id>--> |
| | | <!-- <name>nexus-aliyun</name>--> |
| | | <!-- <url>http://maven.aliyun.com/nexus/content/groups/public/</url>--> |
| | | <!-- <releases>--> |
| | | <!-- <enabled>true</enabled>--> |
| | | <!-- </releases>--> |
| | | <!-- <snapshots>--> |
| | | <!-- <enabled>false</enabled>--> |
| | | <!-- </snapshots>--> |
| | | <!-- </repository>--> |
| | | <!-- </repositories>--> |
| | | |
| | | <pluginRepositories> |
| | | <pluginRepository> |
| | | <id>public</id> |
| | | <name>aliyun nexus</name> |
| | | <url>http://maven.aliyun.com/nexus/content/groups/public/</url> |
| | | <releases> |
| | | <enabled>true</enabled> |
| | | </releases> |
| | | <snapshots> |
| | | <enabled>false</enabled> |
| | | </snapshots> |
| | | </pluginRepository> |
| | | </pluginRepositories>--> |
| | | <!-- <pluginRepositories>--> |
| | | <!-- <pluginRepository>--> |
| | | <!-- <id>public</id>--> |
| | | <!-- <name>aliyun nexus</name>--> |
| | | <!-- <url>http://maven.aliyun.com/nexus/content/groups/public/</url>--> |
| | | <!-- <releases>--> |
| | | <!-- <enabled>true</enabled>--> |
| | | <!-- </releases>--> |
| | | <!-- <snapshots>--> |
| | | <!-- <enabled>false</enabled>--> |
| | | <!-- </snapshots>--> |
| | | <!-- </pluginRepository>--> |
| | | <!-- </pluginRepositories>--> |
| | | </project> |
| | |
| | | import com.example.erp.entity.sd.OrderGlassDetail; |
| | | import com.example.erp.exception.ServiceException; |
| | | import com.example.erp.service.sd.OrderService; |
| | | import com.example.erp.tools.DownExcel; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | return Result.seccess(orderService.getOrderReport(pageNum,pageSize,selectDate,orderDetail)); |
| | | |
| | | } |
| | | @ApiOperation("订单报表导出") |
| | | @PostMapping("/exportOrderReport") |
| | | public void exportOrderReport(HttpServletResponse response) throws IOException, IllegalAccessException, InstantiationException { |
| | | DownExcel.download(response,Order.class, orderService.exportOrderReport(),"orderReport"); |
| | | } |
| | | } |
| | |
| | | package com.example.erp.entity.sd; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | |
| | | @TableName("sd.`order`") |
| | | public class Order { |
| | | @TableId(type = IdType.AUTO) |
| | | |
| | | @ExcelProperty("id") |
| | | private Long id; |
| | | @ExcelProperty("订单编号") |
| | | private String orderId; |
| | | @ExcelProperty("项目名称") |
| | | private String project; |
| | | private Integer customerId; |
| | | private String customerName; |
| | |
| | | List<OrderDetail> getOrderReport(Integer offset, Integer pageSize, String startDate, String endDate, OrderDetail orderDetail); |
| | | |
| | | Map<String,Integer> getOrderReportTotal(Integer offset, Integer pageSize, String startDate, String endDate, OrderDetail orderDetail); |
| | | |
| | | List<Order> exportOrderReport(); |
| | | } |
| | |
| | | // map.put("total",orderMapper.getPageTotal(offset, pageSize, startDate, endDate, orderDetail)); |
| | | return map; |
| | | } |
| | | |
| | | public List<Order> exportOrderReport() { |
| | | return orderDetailMapper.exportOrderReport(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.example.erp.tools; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | //exccel下载 |
| | | public class DownExcel { |
| | | public static void download(HttpServletResponse response, Class t, List list,String reportName) throws IOException, IllegalAccessException,InstantiationException { |
| | | response.setContentType("application/vnd.ms-excel");// 设置文本内省 |
| | | response.setCharacterEncoding("utf-8");// 设置字符编码 |
| | | response.setHeader("Content-disposition", "attachment;filename="+reportName+".xlsx"); // 设置响应头 |
| | | EasyExcel.write(response.getOutputStream(), t).sheet("模板").doWrite(list); //用io流来写入数据 |
| | | } |
| | | } |
| | |
| | | order by a.id desc |
| | | </select> |
| | | |
| | | <select id="exportOrderReport"> |
| | | SELECT |
| | | *, |
| | | a.create_time as createTime, |
| | | d.type_name as levelOne, |
| | | e.type_name as levelTwo |
| | | from order_detail as a |
| | | left join sd.`order` as b |
| | | on b.order_id = a.order_id |
| | | left join sd.product as c |
| | | on c.id = a.product_id |
| | | left join sd.basic_glass_type as d |
| | | on d.type_id = c.type_id |
| | | left join sd.basic_glass_type as e |
| | | on e.type_id = d.belong |
| | | |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | order by a.id desc |
| | | </select> |
| | | |
| | | <select id="exportOrderReport"> |
| | | SELECT |
| | | *, |
| | | a.create_time as createTime, |
| | | d.type_name as levelOne, |
| | | e.type_name as levelTwo |
| | | from order_detail as a |
| | | left join sd.`order` as b |
| | | on b.order_id = a.order_id |
| | | left join sd.product as c |
| | | on c.id = a.product_id |
| | | left join sd.basic_glass_type as d |
| | | on d.type_id = c.type_id |
| | | left join sd.basic_glass_type as e |
| | | on e.type_id = d.belong |
| | | |
| | | </select> |
| | | |
| | | </mapper> |