From 30114e1f4986da9e3ca0bfd44ded4cb75da34eb1 Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Mon, 23 Aug 2021 16:27:49 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/gaea/business/util/FileUtil.java | 367 ++++++++++++++++++ report-ui/src/api/bigscreen.js | 18 + 2 files changed, 385 insertions(+) create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java new file mode 100644 index 00000000..22161395 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java @@ -0,0 +1,367 @@ +package com.anjiplus.template.gaea.business.util; + +import com.anji.plus.gaea.code.ResponseCode; +import com.anji.plus.gaea.exception.BusinessExceptionBuilder; +import lombok.extern.slf4j.Slf4j; +import sun.misc.BASE64Encoder; + +import java.io.*; +import java.net.URL; +import java.nio.channels.FileChannel; +import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Enumeration; +import java.util.zip.*; + +/** + * Created by raodeming on 2021/8/23. + */ +@Slf4j +public class FileUtil { + + //链接url下载图片 + public static void downloadPicture(String urlPath, String path) { + URL url = null; + try { + url = new URL(urlPath); + DataInputStream dataInputStream = new DataInputStream(url.openStream()); + + FileOutputStream fileOutputStream = new FileOutputStream(path); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + + byte[] buffer = new byte[1024]; + int length; + + while ((length = dataInputStream.read(buffer)) > 0) { + output.write(buffer, 0, length); + } + fileOutputStream.write(output.toByteArray()); + dataInputStream.close(); + fileOutputStream.close(); + log.info("链接下载图片:{},临时路径:{}", urlPath, path); + } catch (IOException e) { + log.error("根据链接下载失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + + + /** + * 复制文件 + * + * @param source + * @param dest + * @throws IOException + */ + public static void copyFileUsingFileChannels(File source, File dest) { + FileChannel inputChannel = null; + FileChannel outputChannel = null; + try { + if (!dest.getParentFile().exists()) { + dest.getParentFile().mkdirs(); + } + inputChannel = new FileInputStream(source).getChannel(); + outputChannel = new FileOutputStream(dest).getChannel(); + outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); + } catch (IOException e) { + log.error("复制文件失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } finally { + try { + inputChannel.close(); + outputChannel.close(); + } catch (IOException e) { + log.error("", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + } + + /** + * 复制文件 + * + * @param source + * @param dest + * @throws IOException + */ + public static void copyFileUsingFileChannels(String source, String dest) { + copyFileUsingFileChannels(new File(source), new File(dest)); + } + + + public static void WriteStringToFile(String filePath, String content) { + try { + FileWriter fw = new FileWriter(filePath); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(content); + bw.close(); + fw.close(); + } catch (Exception e) { + log.error("写入文件失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + + + /** + * 根据文件读取文本文件内容 + * + * @param file + * @return + */ + public static String readFile(File file) { + BufferedReader reader = null; + StringBuilder sbf = new StringBuilder(); + try { + reader = new BufferedReader(new FileReader(file)); + String tempStr; + while ((tempStr = reader.readLine()) != null) { + sbf.append(tempStr); + } + reader.close(); + return sbf.toString(); + } catch (IOException e) { + log.error("读文件失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e1.getMessage()); + } + } + } + } + + /** + * 根据文件路径读取文本文件内容 + * + * @param filePath + * @return + */ + public static String readFile(String filePath) { + File file = new File(filePath); + return readFile(file); + } + + static final int BUFFER = 8192; + + /** + * 将文件夹压缩zip包 + * + * @param srcPath + * @param dstPath + * @throws IOException + */ + public static void compress(String srcPath, String dstPath) { + File srcFile = new File(srcPath); + File dstFile = new File(dstPath); + + FileOutputStream out = null; + ZipOutputStream zipOut = null; + try { + out = new FileOutputStream(dstFile); + CheckedOutputStream cos = new CheckedOutputStream(out, new CRC32()); + zipOut = new ZipOutputStream(cos); + String baseDir = ""; + compress(srcFile, zipOut, baseDir); + } catch (IOException e) { + log.error("压缩文件夹失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } finally { + if (null != zipOut) { + try { + zipOut.close(); + } catch (IOException e) { + log.error("", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + out = null; + } + if (null != out) { + try { + out.close(); + } catch (IOException e) { + log.error("", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + } + } + + private static void compress(File file, ZipOutputStream zipOut, String baseDir) { + if (file.isDirectory()) { + compressDirectory(file, zipOut, baseDir); + } else { + compressFile(file, zipOut, baseDir); + } + } + + /** + * 压缩一个目录 + */ + private static void compressDirectory(File dir, ZipOutputStream zipOut, String baseDir) { + File[] files = dir.listFiles(); + for (int i = 0; i < files.length; i++) { + compress(files[i], zipOut, baseDir + dir.getName() + "/"); + } + } + + /** + * 压缩一个文件 + */ + private static void compressFile(File file, ZipOutputStream zipOut, String baseDir) { + if (!file.exists()) { + return; + } + + BufferedInputStream bis = null; + try { + bis = new BufferedInputStream(new FileInputStream(file)); + ZipEntry entry = new ZipEntry(baseDir + file.getName()); + zipOut.putNextEntry(entry); + int count; + byte data[] = new byte[BUFFER]; + while ((count = bis.read(data, 0, BUFFER)) != -1) { + zipOut.write(data, 0, count); + } + + } catch (IOException e) { + log.error("压缩文件夹失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } finally { + if (null != bis) { + try { + bis.close(); + } catch (IOException e) { + log.error("", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + } + } + + + /** + * 解压zip + * + * @param zipFile + * @param dstPath + * @throws IOException + */ + public static void decompress(String zipFile, String dstPath) { + log.info("解压zip:{},临时目录:{}", zipFile, dstPath); + File pathFile = new File(dstPath); + if (!pathFile.exists()) { + pathFile.mkdirs(); + } + ZipFile zip = null; + try { + zip = new ZipFile(zipFile); + + for (Enumeration entries = zip.entries(); entries.hasMoreElements(); ) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + String zipEntryName = entry.getName(); + InputStream in = null; + OutputStream out = null; + try { + in = zip.getInputStream(entry); + String outPath = (dstPath + "/" + zipEntryName).replaceAll("\\*", "/"); + ; + //判断路径是否存在,不存在则创建文件路径 + File file = new File(outPath.substring(0, outPath.lastIndexOf('/'))); + if (!file.exists()) { + file.mkdirs(); + } + //判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压 + if (new File(outPath).isDirectory()) { + continue; + } + + out = new FileOutputStream(outPath); + byte[] buf1 = new byte[1024]; + int len; + while ((len = in.read(buf1)) > 0) { + out.write(buf1, 0, len); + } + } catch (IOException e) { + log.error("解压失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } finally { + if (null != in) { + try { + in.close(); + } catch (IOException e) { + log.error("", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + + if (null != out) { + try { + out.close(); + } catch (IOException e) { + log.error("", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + } + } + zip.close(); + } catch (IOException e) { + log.error("解压失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + + /** + * 删除文件夹 + * @param path + */ + public static void delete(String path) { + + Path directory = Paths.get(path); + try { + Files.walkFileTree(directory, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException { + Files.delete(file); // this will work because it's always a File + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); //this will work because Files in the directory are already deleted + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException e) { + log.error("删除文件失败", e); + throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage()); + } + } + + + public static void main(String[] args) throws Exception { +// String targetFolderPath = "D:\\aa"; +// String rawZipFilePath = "D:\\aa.zip"; +// String newZipFilePath = "D:\\aa.zip"; +// +// +// //将目标目录的文件压缩成Zip文件 +// FileUtil.compress(targetFolderPath, newZipFilePath); +// +// //将Zip文件解压缩到目标目录 +// FileUtil.decompress(rawZipFilePath, targetFolderPath); + +// FileUtil.downloadPicture("http://10.108.26.197:9095/file/download/fd20d563-00aa-45e2-b5db-aff951f814ec", "D:\\abc.png"); + + + +// delete("D:\\aa"); + + } + + +} diff --git a/report-ui/src/api/bigscreen.js b/report-ui/src/api/bigscreen.js index 79217efb..8155503f 100644 --- a/report-ui/src/api/bigscreen.js +++ b/report-ui/src/api/bigscreen.js @@ -45,3 +45,21 @@ export function getData(data) { data, }) } + +// 导出大屏 +export function exportDashboard(data) { + return request({ + url: 'reportDashboard/export/' + data, + method: 'get', + }) +} + + +// 导入大屏 +export function importDashboard(data) { + return request({ + url: 'reportDashboard/import', + method: 'post', + data, + }) +} From 6837371810137b7dcce719cd54eb9148f75fef27 Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Mon, 23 Aug 2021 17:33:29 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReportDashboardController.java | 27 ++++ .../service/ReportDashboardService.java | 14 +++ .../impl/ReportDashboardServiceImpl.java | 119 ++++++++++++++++++ .../template/gaea/business/util/FileUtil.java | 1 - .../src/main/resources/bootstrap-dev.yml | 1 + 5 files changed, 161 insertions(+), 1 deletion(-) diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/controller/ReportDashboardController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/controller/ReportDashboardController.java index 15e376b2..bc2dfb03 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/controller/ReportDashboardController.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/controller/ReportDashboardController.java @@ -9,8 +9,12 @@ import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.Char import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.ReportDashboardObjectDto; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + /** * @desc 大屏设计 controller * @website https://gitee.com/anji-plus/gaea @@ -62,4 +66,27 @@ public class ReportDashboardController { return ResponseBean.builder().data(reportDashboardService.getChartData(dto)).build(); } + + /** + * 导出大屏 + * @param reportCode + * @return + */ + @GetMapping("/export/{reportCode}") + @Permission(code = "view", name = "导出大屏") + public ResponseEntity exportDashboard(HttpServletRequest request, HttpServletResponse response, @PathVariable("reportCode") String reportCode) { + return reportDashboardService.exportDashboard(request, response, reportCode); + } + + /** + * 导入大屏 + * @param dto + * @return + */ + @PostMapping("/import") + @Permission(code = "design", name = "导入大屏") + public ResponseBean importDashboard(@RequestBody ChartDto dto) { + return ResponseBean.builder().data(reportDashboardService.getChartData(dto)).build(); + } + } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/ReportDashboardService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/ReportDashboardService.java index 508bfeed..a3660b6a 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/ReportDashboardService.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/ReportDashboardService.java @@ -6,6 +6,10 @@ import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.Char import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.ReportDashboardObjectDto; import com.anjiplus.template.gaea.business.modules.dashboard.controller.param.ReportDashboardParam; import com.anjiplus.template.gaea.business.modules.dashboard.dao.entity.ReportDashboard; +import org.springframework.http.ResponseEntity; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** * @desc ReportDashboard 大屏设计服务接口 @@ -35,4 +39,14 @@ public interface ReportDashboardService extends GaeaBaseService exportDashboard(HttpServletRequest request, HttpServletResponse response, String reportCode); } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/impl/ReportDashboardServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/impl/ReportDashboardServiceImpl.java index 3a8cdab9..0a99526f 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/impl/ReportDashboardServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/impl/ReportDashboardServiceImpl.java @@ -13,6 +13,9 @@ import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.Repo import com.anjiplus.template.gaea.business.modules.dashboard.dao.ReportDashboardMapper; import com.anjiplus.template.gaea.business.modules.dashboard.service.ChartStrategy; import com.anjiplus.template.gaea.business.modules.dashboard.service.ReportDashboardService; +import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile; +import com.anjiplus.template.gaea.business.modules.file.service.GaeaFileService; +import com.anjiplus.template.gaea.business.modules.file.util.FileUtils; import com.anjiplus.template.gaea.business.util.DateUtil; import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.dto.ReportDashboardWidgetDto; import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.dto.ReportDashboardWidgetValueDto; @@ -22,17 +25,29 @@ import com.anjiplus.template.gaea.business.modules.dashboardwidget.service.Repor import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.DataSetDto; import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.OriginalDataDto; import com.anjiplus.template.gaea.business.modules.dataset.service.DataSetService; +import com.anjiplus.template.gaea.business.util.FileUtil; +import com.anjiplus.template.gaea.business.util.UuidUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; @@ -42,6 +57,7 @@ import java.util.*; * @date 2021-04-12 14:52:21.761 **/ @Service +@Slf4j //@RequiredArgsConstructor public class ReportDashboardServiceImpl implements ReportDashboardService, InitializingBean, ApplicationContextAware { @@ -54,6 +70,18 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi @Autowired private DataSetService dataSetService; + @Autowired + private GaeaFileService gaeaFileService; + + @Value("${customer.file.downloadPath:''}") + private String fileDownloadPath; + + @Value("${customer.file.dist-path:''}") + private String dictPath; + + private final static String ZIP_PATH = "/zip/"; + private final static String JSON_PATH = "dashboard.json"; + private Map queryServiceImplMap = new HashMap<>(); private ApplicationContext applicationContext; @@ -165,6 +193,97 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi // return getTarget(chartType).transform(dto, result.getData()); } + /** + * 导出大屏,zip文件 + * + * @param request + * @param response + * @param reportCode + * @return + */ + @Override + public ResponseEntity exportDashboard(HttpServletRequest request, HttpServletResponse response, String reportCode) { + String userAgent = request.getHeader("User-Agent"); + boolean isIeBrowser = userAgent.indexOf("MSIE") > 0; + + ReportDashboardObjectDto detail = getDetail(reportCode); + List widgets = detail.getDashboard().getWidgets(); + detail.setWidgets(widgets); + detail.getDashboard().setWidgets(null); + + + //1.组装临时目录,/app/disk/upload/zip/临时文件夹 + String path = dictPath + ZIP_PATH + UuidUtil.generateShortUuid(); + + //将涉及到的图片保存下来(1.背景图,2.组件为图片的) + String backgroundImage = detail.getDashboard().getBackgroundImage(); + zipLoadImage(backgroundImage, path); + detail.getWidgets().stream() + .filter(reportDashboardWidgetDto -> "widget-image".equals(reportDashboardWidgetDto.getType())) + .forEach(reportDashboardWidgetDto -> { + String imageAddress = reportDashboardWidgetDto.getValue().getSetup().getString("imageAdress"); + zipLoadImage(imageAddress, path); + }); + + + + //2.将大屏设计到的json文件保存 + String jsonPath = path + "/" + JSON_PATH; + FileUtil.WriteStringToFile(jsonPath, JSONObject.toJSONString(detail)); + + + //将path文件夹打包zip + String zipPath = path + ".zip"; + FileUtil.compress(path, zipPath); + + + File file = new File(zipPath); + ResponseEntity.BodyBuilder builder = ResponseEntity.ok(); + builder.contentLength(file.length()); + //application/octet-stream 二进制数据流(最常见的文件下载) + builder.contentType(MediaType.APPLICATION_OCTET_STREAM); + if (isIeBrowser) { + builder.header("Content-Disposition", "attachment; filename=" + reportCode + ".zip"); + } else { + builder.header("Content-Disposition", "attacher; filename*=UTF-8''" + reportCode + ".zip"); + } + + //删除zip文件 + file.delete(); + //删除path临时文件夹 + FileUtil.delete(path); + log.info("删除临时文件:{},{}", zipPath, path); + + return builder.body(FileUtils.readFileToByteArray(file)); + } + + /** + * 将大屏涉及到的图片存入指定文件夹 + * @param imageAddress + * @param path + */ + private void zipLoadImage(String imageAddress, String path) { + //http://10.108.26.197:9095/file/download/1d9bcd35-82a1-4f08-9465-b66b930b6a8d + if (imageAddress.trim().startsWith(fileDownloadPath)) { + //以fileDownloadPath为前缀的代表为上传的图片 + String fileName = imageAddress.substring(fileDownloadPath.length() + 1); + //根据fileId,从gaea_file中读出filePath + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(GaeaFile::getFileId, fileName); + GaeaFile gaeaFile = gaeaFileService.selectOne(queryWrapper); + if (null != gaeaFile) { + String fileType = gaeaFile.getFileType(); + path = path + "/image/" + fileName + "." + fileType; + //path = /app/disk/upload/zip/UUID/image + + //原始文件的路径 + String filePath = gaeaFile.getFilePath(); + FileUtil.copyFileUsingFileChannels(filePath, path); + } + } + + } + public ChartStrategy getTarget(String type) { for (String s : queryServiceImplMap.keySet()) { if (s.contains(type)) { diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java index 22161395..708cf7d4 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/FileUtil.java @@ -3,7 +3,6 @@ package com.anjiplus.template.gaea.business.util; import com.anji.plus.gaea.code.ResponseCode; import com.anji.plus.gaea.exception.BusinessExceptionBuilder; import lombok.extern.slf4j.Slf4j; -import sun.misc.BASE64Encoder; import java.io.*; import java.net.URL; diff --git a/report-core/src/main/resources/bootstrap-dev.yml b/report-core/src/main/resources/bootstrap-dev.yml index 576f966f..ad947c14 100644 --- a/report-core/src/main/resources/bootstrap-dev.yml +++ b/report-core/src/main/resources/bootstrap-dev.yml @@ -8,3 +8,4 @@ spring: customer: file: dist-path: D:\Workspace\AJ-Report\report-core\upload + downloadPath: http://127.0.0.1:9095/file/download From ccaeabfb5cce89eb4d45be73a54d1122d83bbf1b Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Tue, 24 Aug 2021 09:21:39 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E5=AF=BC=E5=87=BAzip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- report-ui/src/api/bigscreen.js | 18 ++++++-- .../views/report/bigscreen/designer/index.vue | 44 ++++++++++++++++++- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/report-ui/src/api/bigscreen.js b/report-ui/src/api/bigscreen.js index 8155503f..ef090d96 100644 --- a/report-ui/src/api/bigscreen.js +++ b/report-ui/src/api/bigscreen.js @@ -1,5 +1,6 @@ import request from '@/utils/request' import { getShareToken, getToken } from "@/utils/auth"; +import axios from 'axios'; // 保存大屏设计 export function insertDashboard(data) { @@ -48,12 +49,21 @@ export function getData(data) { // 导出大屏 export function exportDashboard(data) { - return request({ - url: 'reportDashboard/export/' + data, - method: 'get', + return new Promise((resolve) =>{ + axios({ + method:'get', + url: process.env.BASE_API + '/reportDashboard/export/' + data, + headers: { 'Authorization': getToken() }, + params:data, + responseType:'blob' + }).then(res =>{ + resolve(res.data); + }).catch(err =>{ + resolve('error'); + }) }) -} +} // 导入大屏 export function importDashboard(data) { diff --git a/report-ui/src/views/report/bigscreen/designer/index.vue b/report-ui/src/views/report/bigscreen/designer/index.vue index f1c9d13d..3f4a6ba4 100644 --- a/report-ui/src/views/report/bigscreen/designer/index.vue +++ b/report-ui/src/views/report/bigscreen/designer/index.vue @@ -87,6 +87,26 @@ + + + + + + + + + + + +
+ + diff --git a/report-ui/src/views/report/bigscreen/designer/widget/temp.vue b/report-ui/src/views/report/bigscreen/designer/widget/temp.vue index 2b1e121a..9396d3f3 100644 --- a/report-ui/src/views/report/bigscreen/designer/widget/temp.vue +++ b/report-ui/src/views/report/bigscreen/designer/widget/temp.vue @@ -33,6 +33,7 @@ import widgetPiePercentageChart from "./pie/widgetPiePercentageChart"; import widgetAirBubbleMap from "./map/widgetAirBubbleMap"; import widgetBarStackChart from "./bar/widgetBarStackChart"; import widgetLineStackChart from "./line/widgetLineStackChart"; +import widgetBarCompareChart from "./bar/widgetBarCompareChart"; export default { name: "WidgetTemp", @@ -58,7 +59,8 @@ export default { widgetPiePercentageChart, widgetAirBubbleMap, widgetBarStackChart, - widgetLineStackChart + widgetLineStackChart, + widgetBarCompareChart }, model: { prop: "value", diff --git a/report-ui/src/views/report/bigscreen/designer/widget/widget.vue b/report-ui/src/views/report/bigscreen/designer/widget/widget.vue index 2096bac2..7b603787 100644 --- a/report-ui/src/views/report/bigscreen/designer/widget/widget.vue +++ b/report-ui/src/views/report/bigscreen/designer/widget/widget.vue @@ -43,6 +43,7 @@ import widgetPiePercentageChart from "./pie/widgetPiePercentageChart"; import widgetAirBubbleMap from "./map/widgetAirBubbleMap"; import widgetBarStackChart from "./bar/widgetBarStackChart"; import widgetLineStackChart from "./line/widgetLineStackChart"; +import widgetBarCompareChart from "./bar/widgetBarCompareChart"; export default { name: "Widget", @@ -68,7 +69,8 @@ export default { widgetPiePercentageChart, widgetAirBubbleMap, widgetBarStackChart, - widgetLineStackChart + widgetLineStackChart, + widgetBarCompareChart }, model: { prop: "value", From 918d397dbc0e332aa7ab2b38f3ffc6f7107641c0 Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Tue, 24 Aug 2021 17:35:54 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BAicon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- report-ui/src/views/report/bigscreen/designer/index.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/report-ui/src/views/report/bigscreen/designer/index.vue b/report-ui/src/views/report/bigscreen/designer/index.vue index 53ba99fe..600d473d 100644 --- a/report-ui/src/views/report/bigscreen/designer/index.vue +++ b/report-ui/src/views/report/bigscreen/designer/index.vue @@ -104,14 +104,14 @@ :on-error="handleError" :show-file-list="false" :limit="1"> - +