| | |
| | | import {Search} from "@element-plus/icons-vue" |
| | | import {defineEmits, onMounted, reactive, ref, watch} from "vue" |
| | | import {changeFilterEvent} from "@/hook" |
| | | import request from "@/utils/request"; |
| | | import request from "@/utils/request" |
| | | import exportExcel from "@/hook/exportExcel" |
| | | import deepClone from "@/utils/deepClone"; |
| | | import {ElMessage} from "element-plus"; |
| | | const xGrid = ref() |
| | |
| | | ],//表头按钮 |
| | | toolbarConfig: { |
| | | buttons: [], |
| | | slots: { |
| | | tools: 'toolbar_buttons' |
| | | }, |
| | | // import: false, |
| | | // export: true, |
| | | // print: true, |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <template #toolbar_buttons> |
| | | <vxe-button style="margin-right: 0.5rem" |
| | | @click="exportExcel(props.childrenData.exportUrl, |
| | | props.childrenData.exportName, |
| | | basicProp.selectDate)"> |
| | | 导出</vxe-button> |
| | | </template> |
| | | |
| | | <template #pager> |
| | | <!--使用 pager 插槽--> |
| | | <!-- 'PrevJump','NextJump', --> |
New file |
| | |
| | | import request from "@/utils/request" |
| | | import {ElMessage} from "element-plus" |
| | | |
| | | |
| | | export default function exportExcel(url, fileName,date) { |
| | | if(date===null){ |
| | | ElMessage.warning("请先选择日期") |
| | | return |
| | | } |
| | | |
| | | const date1 = new Date(date[0]); |
| | | const date2 = new Date(date[1]); |
| | | const timeDiff = Math.abs(date2.getTime() - date1.getTime()); |
| | | const daysDiff = timeDiff / (1000 * 3600 * 24); |
| | | if(Math.floor(daysDiff)>180){ |
| | | ElMessage.warning("导出的筛选时间不能超过180天") |
| | | return |
| | | } |
| | | request.post(url,date,{responseType :'blob'}).then(res => { |
| | | const blob = new Blob([res]) |
| | | if ('download' in document.createElement('a')) { // 非IE下载 |
| | | const elink = document.createElement('a') |
| | | elink.download = `${fileName}.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) |
| | | } |
| | | |
| | | }) |
| | | } |
| | | |
| | |
| | | //传递报错信息,把报错信息传递到pinia中 |
| | | userStore.setResponseCode(parseInt(res.code),res.msg) |
| | | if(res.code!=='200'){ |
| | | if(response.config.responseType !== 'blob'){ |
| | | return Promise.reject(res.code) |
| | | } |
| | | } |
| | | |
| | | // 如果是返回的文件 |
| | | if (response.config.responseType === 'blob') { |
| | |
| | | ],//表格表头字段 |
| | | data:[],//表格数据 |
| | | url :'/order/getOrderReport', |
| | | exportUrl :'/order/exportOrderReport', |
| | | exportName:'订单明细报表', |
| | | 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> |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | } |
| | | @ApiOperation("订单报表导出") |
| | | @PostMapping("/exportOrderReport") |
| | | public void exportOrderReport(HttpServletResponse response) throws IOException, IllegalAccessException, InstantiationException { |
| | | DownExcel.download(response,Order.class, orderService.exportOrderReport(),"orderReport"); |
| | | public void exportOrderReport(HttpServletResponse response, @RequestBody List<LocalDate> dates) throws IOException, IllegalAccessException, InstantiationException { |
| | | |
| | | //参数:相应的数据,实体类信息,相应的方法(数据获取),生成的excel名字 |
| | | DownExcel.download(response,Order.class, orderService.exportOrderReport(dates),"orderReport"); |
| | | } |
| | | } |
| | |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | //type为了区别需不需要根据产品分类 |
| | | Map<String,Integer> getOrderReportTotal(Integer offset, Integer pageSize, String startDate, String endDate, OrderDetail orderDetail, String type); |
| | | |
| | | List<Order> exportOrderReport(); |
| | | List<Order> exportOrderReport(List<LocalDate> dates); |
| | | |
| | | List<OrderDetail> getOrderProductSummary(Integer offset, Integer pageSize, String startDate, String endDate, OrderDetail orderDetail); |
| | | |
| | |
| | | return map; |
| | | } |
| | | |
| | | public List<Order> exportOrderReport() { |
| | | return orderDetailMapper.exportOrderReport(); |
| | | public List<Order> exportOrderReport(List<LocalDate> dates) { |
| | | return orderDetailMapper.exportOrderReport(dates); |
| | | } |
| | | |
| | | public Map<String,Object> getOrderProductSummary(Integer pageNum, Integer pageSize, List<String> selectDate, OrderDetail orderDetail) { |
| | |
| | | on d.type_id = c.type_id |
| | | left join sd.basic_glass_type as e |
| | | on e.type_id = d.belong |
| | | where date(a.create_time)>=#{dates[0]} and date(a.create_time) <= #{dates[1]} |
| | | |
| | | </select> |
| | | |