导入导出

Raod 3 years ago
parent ccaeabfb5c
commit 17c2265082

@ -11,6 +11,7 @@ import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -72,21 +73,24 @@ public class ReportDashboardController {
* @param reportCode * @param reportCode
* @return * @return
*/ */
@GetMapping("/export/{reportCode}") @GetMapping("/export")
@Permission(code = "view", name = "导出大屏") @Permission(code = "view", name = "导出大屏")
public ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response, @PathVariable("reportCode") String reportCode) { public ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response,
return reportDashboardService.exportDashboard(request, response, reportCode); @RequestParam("reportCode") String reportCode, @RequestParam(value = "showDataSet",required = false, defaultValue = "1") Integer showDataSet) {
return reportDashboardService.exportDashboard(request, response, reportCode, showDataSet);
} }
/** /**
* *
* @param dto * @param file zip
* @param reportCode
* @return * @return
*/ */
@PostMapping("/import") @PostMapping("/import/{reportCode}")
@Permission(code = "design", name = "导入大屏") @Permission(code = "design", name = "导入大屏")
public ResponseBean importDashboard(@RequestBody ChartDto dto) { public ResponseBean importDashboard(@RequestParam("file") MultipartFile file, @PathVariable("reportCode") String reportCode) {
return ResponseBean.builder().data(reportDashboardService.getChartData(dto)).build(); reportDashboardService.importDashboard(file, reportCode);
return ResponseBean.builder().build();
} }
} }

@ -7,6 +7,7 @@ import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.Repo
import com.anjiplus.template.gaea.business.modules.dashboard.controller.param.ReportDashboardParam; import com.anjiplus.template.gaea.business.modules.dashboard.controller.param.ReportDashboardParam;
import com.anjiplus.template.gaea.business.modules.dashboard.dao.entity.ReportDashboard; import com.anjiplus.template.gaea.business.modules.dashboard.dao.entity.ReportDashboard;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -48,5 +49,13 @@ public interface ReportDashboardService extends GaeaBaseService<ReportDashboardP
* @param reportCode * @param reportCode
* @return * @return
*/ */
ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response, String reportCode); ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response, String reportCode, Integer showDataSet);
/**
* zip
* @param file
* @param reportCode
* @return
*/
void importDashboard(MultipartFile file, String reportCode);
} }

@ -43,6 +43,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -133,7 +134,7 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi
* @param dto * @param dto
*/ */
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public void insertDashboard(ReportDashboardObjectDto dto) { public void insertDashboard(ReportDashboardObjectDto dto) {
String reportCode = dto.getReportCode(); String reportCode = dto.getReportCode();
GaeaAssert.notEmpty(reportCode, ResponseCode.PARAM_IS_NULL, "reportCode"); GaeaAssert.notEmpty(reportCode, ResponseCode.PARAM_IS_NULL, "reportCode");
@ -149,6 +150,7 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi
} else { } else {
//更新 //更新
dashboard.setId(reportDashboard.getId()); dashboard.setId(reportDashboard.getId());
dashboard.setVersion(null);
this.update(dashboard); this.update(dashboard);
} }
@ -202,7 +204,7 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi
* @return * @return
*/ */
@Override @Override
public ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response, String reportCode) { public ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response, String reportCode, Integer showDataSet) {
String userAgent = request.getHeader("User-Agent"); String userAgent = request.getHeader("User-Agent");
boolean isIeBrowser = userAgent.indexOf("MSIE") > 0; boolean isIeBrowser = userAgent.indexOf("MSIE") > 0;
@ -225,6 +227,16 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi
zipLoadImage(imageAddress, path); zipLoadImage(imageAddress, path);
}); });
//showDataSet == 0 代表不包含数据集
if (0 == showDataSet) {
detail.getWidgets().forEach(reportDashboardWidgetDto -> {
ReportDashboardWidgetValueDto value = reportDashboardWidgetDto.getValue();
JSONObject data = value.getData();
if (null != data && data.containsKey("dataType")) {
reportDashboardWidgetDto.getValue().getData().put("dataType", "staticData");
}
});
}
//2.将大屏设计到的json文件保存 //2.将大屏设计到的json文件保存
@ -248,13 +260,101 @@ public class ReportDashboardServiceImpl implements ReportDashboardService, Initi
builder.header("Content-Disposition", "attacher; filename*=UTF-8''" + reportCode + ".zip"); builder.header("Content-Disposition", "attacher; filename*=UTF-8''" + reportCode + ".zip");
} }
ResponseEntity<byte[]> body = builder.body(FileUtils.readFileToByteArray(file));
//删除zip文件 //删除zip文件
file.delete(); file.delete();
//删除path临时文件夹 //删除path临时文件夹
FileUtil.delete(path); FileUtil.delete(path);
log.info("删除临时文件:{}{}", zipPath, path); log.info("删除临时文件:{}{}", zipPath, path);
return builder.body(FileUtils.readFileToByteArray(file)); return body;
}
/**
* zip
*
* @param file
* @param reportCode
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void importDashboard(MultipartFile file, String reportCode) {
log.info("导入开始,{}", reportCode);
//1.组装临时目录,/app/disk/upload/zip/临时文件夹
String path = dictPath + ZIP_PATH + UuidUtil.generateShortUuid();
//2.解压
FileUtil.decompress(file, path);
// path/uuid/
File parentPath = new File(path);
//获取打包的第一层目录
File firstFile = parentPath.listFiles()[0];
File[] files = firstFile.listFiles();
//定义map
Map<String, String> fileMap = new HashMap<>();
String content = "";
for (int i = 0; i < files.length; i++) {
File childFile = files[i];
if (JSON_PATH.equals(childFile.getName())) {
//json文件
content = FileUtil.readFile(childFile);
} else if ("image".equals(childFile.getName())) {
File[] imageFiles = childFile.listFiles();
//所有需要上传的图片
for (File imageFile : imageFiles) {
//查看是否存在此image
String name = imageFile.getName();
String fileName = imageFile.getName().split("\\.")[0];
//根据fileId从gaea_file中读出filePath
LambdaQueryWrapper<GaeaFile> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(GaeaFile::getFileId, fileName);
GaeaFile gaeaFile = gaeaFileService.selectOne(queryWrapper);
if (null == gaeaFile) {
GaeaFile upload = gaeaFileService.upload(null, imageFile, fileName);
fileMap.put(fileName, upload.getUrlPath());
}
}
}
}
//解析cotent
ReportDashboardObjectDto detail = JSONObject.parseObject(content, ReportDashboardObjectDto.class);
//将涉及到的图片路径替换1.背景图2.组件为图片的)
String backgroundImage = detail.getDashboard().getBackgroundImage();
detail.getDashboard().setBackgroundImage(replaceUrl(backgroundImage, fileMap));
detail.getWidgets().stream()
.filter(reportDashboardWidgetDto -> "widget-image".equals(reportDashboardWidgetDto.getType()))
.forEach(reportDashboardWidgetDto -> {
String imageAddress = reportDashboardWidgetDto.getValue().getSetup().getString("imageAdress");
String address = replaceUrl(imageAddress, fileMap);
reportDashboardWidgetDto.getValue().getSetup().put("imageAdress", address);
reportDashboardWidgetDto.getOptions().getJSONArray("setup").getJSONObject(4).put("value", address);
});
//将新的大屏编码赋值
detail.setReportCode(reportCode);
//解析结束,删除临时文件夹
FileUtil.delete(path);
log.info("解析成功,开始存入数据库...");
insertDashboard(detail);
}
private String replaceUrl(String imageAddress, Map<String, String> fileMap) {
String fileId = imageAddress.substring(imageAddress.trim().length() - 36);
String orDefault = fileMap.getOrDefault(fileId, null);
if (StringUtils.isBlank(orDefault)) {
return imageAddress;
}
return orDefault;
} }
/** /**

@ -33,7 +33,7 @@ public class GaeaFileController extends BaseController<GaeaFileParam, GaeaFile,
@PostMapping("/upload") @PostMapping("/upload")
@Permission(code = "upload", name = "文件上传") @Permission(code = "upload", name = "文件上传")
public ResponseBean upload(@RequestParam("file") MultipartFile file) { public ResponseBean upload(@RequestParam("file") MultipartFile file) {
return ResponseBean.builder().message("success").data((gaeaFileService.upload(file))).build(); return ResponseBean.builder().message("success").data((gaeaFileService.upload(file, null, null))).build();
} }
@GetMapping(value = "/download/{fileId}") @GetMapping(value = "/download/{fileId}")

@ -8,6 +8,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File;
/** /**
* (GaeaFile)Service * (GaeaFile)Service
@ -17,15 +18,13 @@ import javax.servlet.http.HttpServletResponse;
*/ */
public interface GaeaFileService extends GaeaBaseService<GaeaFileParam, GaeaFile> { public interface GaeaFileService extends GaeaBaseService<GaeaFileParam, GaeaFile> {
/** /**
* *
* *
* @param file * @param file
* @return 访 * @return 访
*/ */
GaeaFile upload(MultipartFile file); GaeaFile upload(MultipartFile multipartFile, File file, String customFileName);
/** /**
* fileId * fileId
* *

@ -10,6 +10,7 @@ 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.service.GaeaFileService;
import com.anjiplus.template.gaea.business.modules.file.util.FileUtils; import com.anjiplus.template.gaea.business.modules.file.util.FileUtils;
import com.anjiplus.template.gaea.business.modules.file.util.StringPatternUtil; import com.anjiplus.template.gaea.business.modules.file.util.StringPatternUtil;
import com.anjiplus.template.gaea.business.util.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -64,11 +65,18 @@ public class GaeaFileServiceImpl implements GaeaFileService {
return gaeaFileMapper; return gaeaFileMapper;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public GaeaFile upload(MultipartFile file) { public GaeaFile upload(MultipartFile multipartFile, File file, String customFileName) {
try { try {
String fileName = file.getOriginalFilename(); String fileName = "";
if (null != multipartFile) {
fileName = multipartFile.getOriginalFilename();
}else {
fileName = file.getName();
}
if (StringUtils.isBlank(fileName)) { if (StringUtils.isBlank(fileName)) {
throw BusinessExceptionBuilder.build(ResponseCode.FILE_EMPTY_FILENAME); throw BusinessExceptionBuilder.build(ResponseCode.FILE_EMPTY_FILENAME);
} }
@ -82,7 +90,12 @@ public class GaeaFileServiceImpl implements GaeaFileService {
throw BusinessExceptionBuilder.build(ResponseCode.FILE_SUFFIX_UNSUPPORTED); throw BusinessExceptionBuilder.build(ResponseCode.FILE_SUFFIX_UNSUPPORTED);
} }
// 生成文件唯一性标识 // 生成文件唯一性标识
String fileId = UUID.randomUUID().toString(); String fileId;
if (StringUtils.isBlank(customFileName)) {
fileId = UUID.randomUUID().toString();
} else {
fileId = customFileName;
}
String newFileName = fileId + suffixName; String newFileName = fileId + suffixName;
// 本地文件保存路径 // 本地文件保存路径
String filePath = dictPath + newFileName; String filePath = dictPath + newFileName;
@ -102,7 +115,11 @@ public class GaeaFileServiceImpl implements GaeaFileService {
if (!parentFile.exists()) { if (!parentFile.exists()) {
parentFile.mkdirs(); parentFile.mkdirs();
} }
file.transferTo(dest); if (null != multipartFile) {
multipartFile.transferTo(dest);
}else {
FileUtil.copyFileUsingFileChannels(file, dest);
}
// 将完整的http访问路径返回 // 将完整的http访问路径返回
return gaeaFile; return gaeaFile;
} catch (Exception e) { } catch (Exception e) {

@ -3,6 +3,7 @@ package com.anjiplus.template.gaea.business.util;
import com.anji.plus.gaea.code.ResponseCode; import com.anji.plus.gaea.code.ResponseCode;
import com.anji.plus.gaea.exception.BusinessExceptionBuilder; import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
import java.net.URL; import java.net.URL;
@ -90,6 +91,11 @@ public class FileUtil {
public static void WriteStringToFile(String filePath, String content) { public static void WriteStringToFile(String filePath, String content) {
try { try {
//不存在创建文件
File file = new File(filePath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
FileWriter fw = new FileWriter(filePath); FileWriter fw = new FileWriter(filePath);
BufferedWriter bw = new BufferedWriter(fw); BufferedWriter bw = new BufferedWriter(fw);
bw.write(content); bw.write(content);
@ -241,23 +247,45 @@ public class FileUtil {
} }
} }
public static void decompress(String zipFile, String dstPath) {
try {
decompress(new ZipFile(zipFile), dstPath);
} catch (IOException e) {
log.error("", e);
throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage());
}
}
public static void decompress(MultipartFile zipFile, String dstPath) {
try {
File file = new File(dstPath + File.separator + zipFile.getOriginalFilename());
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
zipFile.transferTo(file);
decompress(new ZipFile(file), dstPath);
//解压完删除
file.delete();
} catch (IOException e) {
log.error("", e);
throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage());
}
}
/** /**
* zip * zip
* *
* @param zipFile * @param zip
* @param dstPath * @param dstPath
* @throws IOException * @throws IOException
*/ */
public static void decompress(String zipFile, String dstPath) { public static void decompress(ZipFile zip, String dstPath) {
log.info("解压zip{},临时目录:{}", zipFile, dstPath); log.info("解压zip{},临时目录:{}", zip.getName(), dstPath);
File pathFile = new File(dstPath); File pathFile = new File(dstPath);
if (!pathFile.exists()) { if (!pathFile.exists()) {
pathFile.mkdirs(); pathFile.mkdirs();
} }
ZipFile zip = null;
try { try {
zip = new ZipFile(zipFile);
for (Enumeration entries = zip.entries(); entries.hasMoreElements(); ) { for (Enumeration entries = zip.entries(); entries.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) entries.nextElement(); ZipEntry entry = (ZipEntry) entries.nextElement();
@ -314,8 +342,30 @@ public class FileUtil {
} }
} }
/**
*
* @param ins
* @param file
*/
private static void inputStreamToFile(InputStream ins, File file) {
try {
OutputStream os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
ins.close();
} catch (Exception e) {
log.error("获取流文件失败", e);
throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage());
}
}
/** /**
* *
*
* @param path * @param path
*/ */
public static void delete(String path) { public static void delete(String path) {
@ -357,7 +407,6 @@ public class FileUtil {
// FileUtil.downloadPicture("http://10.108.26.197:9095/file/download/fd20d563-00aa-45e2-b5db-aff951f814ec", "D:\\abc.png"); // FileUtil.downloadPicture("http://10.108.26.197:9095/file/download/fd20d563-00aa-45e2-b5db-aff951f814ec", "D:\\abc.png");
// delete("D:\\aa"); // delete("D:\\aa");
} }

@ -52,7 +52,7 @@ export function exportDashboard(data) {
return new Promise((resolve) =>{ return new Promise((resolve) =>{
axios({ axios({
method:'get', method:'get',
url: process.env.BASE_API + '/reportDashboard/export/' + data, url: process.env.BASE_API + '/reportDashboard/export',
headers: { 'Authorization': getToken() }, headers: { 'Authorization': getToken() },
params:data, params:data,
responseType:'blob' responseType:'blob'

@ -59,7 +59,7 @@
:style="{ width: widthLeftForToolsHideButton + 'px' }" :style="{ width: widthLeftForToolsHideButton + 'px' }"
@click="toolIsShow = !toolIsShow" @click="toolIsShow = !toolIsShow"
> >
<i class="el-icon-arrow-right" /> <i class="el-icon-arrow-right"/>
</div> </div>
<div <div
@ -94,49 +94,80 @@
content="导入" content="导入"
placement="bottom" placement="bottom"
> >
<i class="iconfont iconyulan" @click="importDashboard"></i>
</el-tooltip> <el-upload class="el-upload"
</span> ref="upload"
<span class="btn"> :action="uploadUrl"
<el-tooltip :headers="headers"
class="item" accept=".zip"
effect="dark" :on-success="handleUpload"
content="导出" :on-error="handleError"
placement="bottom" :show-file-list="false"
> :limit="1">
<i class="iconfont iconyulan" @click="exportDashboard"></i> <i class="iconfont iconxiazai"></i>
</el-upload>
</el-tooltip> </el-tooltip>
</span> </span>
<!-- <span class="btn border-left"> <span class="btn border-left">
<ul class="nav"> <ul class="nav">
<li> <li>
<i class="el-icon-brush"></i><i class="el-icon-arrow-down"></i> <i class="iconfont iconfenxiang_2"></i><i class="el-icon-arrow-down"></i>
<ul> <ul>
<li> <li>
<div> <el-tooltip
<i class="el-icon-full-screen mr10"></i>边框 class="item"
<i class="el-icon-arrow-right ml20"></i> effect="dark"
</div> content="适合当前系统"
<ul class="three-level"> placement="right"
<li><a href="#">边框1</a></li> >
<li><a href="#">边框2</a></li> <div @click="exportDashboard(1)">()</div>
<li><a href="#">边框3</a></li> </el-tooltip>
</ul>
</li> </li>
<li> <li>
<div> <el-tooltip
<i class="el-icon-magic-stick mr10"></i>装饰<i class="item"
class="el-icon-arrow-right ml20" effect="dark"
></i> content="适合跨系统"
</div> placement="right"
<ul class="three-level"> >
<li><a href="#">装饰1</a></li> <div @click="exportDashboard(0)">()</div>
</ul> </el-tooltip>
</li> </li>
</ul> </ul>
</li> </li>
</ul> </ul>
</span> --> </span>
<!-- <span class="btn border-left">
<ul class="nav">
<li>
<i class="el-icon-brush"></i><i class="el-icon-arrow-down"></i>
<ul>
<li>
<div>
<i class="el-icon-full-screen mr10"></i>边框
<i class="el-icon-arrow-right ml20"></i>
</div>
<ul class="three-level">
<li><a href="#">边框1</a></li>
<li><a href="#">边框2</a></li>
<li><a href="#">边框3</a></li>
</ul>
</li>
<li>
<div>
<i class="el-icon-magic-stick mr10"></i>装饰<i
class="el-icon-arrow-right ml20"
></i>
</div>
<ul class="three-level">
<li><a href="#">装饰1</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</span>-->
</div> </div>
<div <div
class="workbench-container" class="workbench-container"
@ -246,13 +277,15 @@
</template> </template>
<script> <script>
import { insertDashboard, detailDashboard, importDashboard, exportDashboard } from "@/api/bigscreen"; import {insertDashboard, detailDashboard, importDashboard, exportDashboard} from "@/api/bigscreen";
import { widgetTools, getToolByCode } from "./tools"; import {widgetTools, getToolByCode} from "./tools";
import widget from "./widget/widget.vue"; import widget from "./widget/widget.vue";
import dynamicForm from "./form/dynamicForm.vue"; import dynamicForm from "./form/dynamicForm.vue";
import draggable from "vuedraggable"; import draggable from "vuedraggable";
import VueRulerTool from "vue-ruler-tool"; // import VueRulerTool from "vue-ruler-tool"; //
import contentMenu from "./form/contentMenu"; import contentMenu from "./form/contentMenu";
import {getToken} from "@/utils/auth";
export default { export default {
name: "Login", name: "Login",
components: { components: {
@ -264,6 +297,7 @@ export default {
}, },
data() { data() {
return { return {
uploadUrl: process.env.BASE_API + '/reportDashboard/import/' + this.$route.query.reportCode,
grade: false, grade: false,
layerWidget: [], layerWidget: [],
widgetTools: widgetTools, // js widgetTools: widgetTools, // js
@ -330,6 +364,11 @@ export default {
}; };
}, },
computed: { computed: {
headers() {
return {
Authorization: getToken(), // token
}
},
// //
middleWidth() { middleWidth() {
var widthLeftAndRight = 0; var widthLeftAndRight = 0;
@ -402,7 +441,7 @@ export default {
}, },
async initEchartData() { async initEchartData() {
const reportCode = this.$route.query.reportCode; const reportCode = this.$route.query.reportCode;
const { code, data } = await detailDashboard(reportCode); const {code, data} = await detailDashboard(reportCode);
if (code != 200) return; if (code != 200) return;
const processData = this.handleInitEchartsData(data); const processData = this.handleInitEchartsData(data);
const screenData = this.handleBigScreen(data.dashboard); const screenData = this.handleBigScreen(data.dashboard);
@ -502,7 +541,7 @@ export default {
}, },
widgets: this.widgets widgets: this.widgets
}; };
const { code, data } = await insertDashboard(screenData); const {code, data} = await insertDashboard(screenData);
if (code == "200") { if (code == "200") {
this.$message.success("保存成功!"); this.$message.success("保存成功!");
} }
@ -511,14 +550,19 @@ export default {
viewScreen() { viewScreen() {
var routeUrl = this.$router.resolve({ var routeUrl = this.$router.resolve({
path: "/bigscreen/viewer", path: "/bigscreen/viewer",
query: { reportCode: this.$route.query.reportCode } query: {reportCode: this.$route.query.reportCode}
}); });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
}, },
// //
async exportDashboard() { async exportDashboard(val) {
const fileName = this.$route.query.reportCode + ".zip" const fileName = this.$route.query.reportCode + ".zip"
exportDashboard(this.$route.query.reportCode).then(res=>{
const param = {
reportCode:this.$route.query.reportCode,
showDataSet:val
}
exportDashboard(param).then(res => {
const blob = new Blob([res], {type: "application/octet-stream"}); const blob = new Blob([res], {type: "application/octet-stream"});
if (window.navigator.msSaveOrOpenBlob) {//msSaveOrOpenBlobbool if (window.navigator.msSaveOrOpenBlob) {//msSaveOrOpenBlobbool
navigator.msSaveBlob(blob, fileName);// navigator.msSaveBlob(blob, fileName);//
@ -532,11 +576,24 @@ export default {
}) })
}, },
//
// handleUpload(response, file, fileList) {
importDashboard() { //el-upload
alert("导入,开发中") this.$refs.upload.clearFiles();
//
this.initEchartData();
this.$message({
message: '导入成功!',
type: 'success',
})
},
handleError() {
this.$message({
message: '上传失败!',
type: 'error',
})
}, },
// //
getPXUnderScale(px) { getPXUnderScale(px) {
return this.bigscreenScaleInWorkbench * px; return this.bigscreenScaleInWorkbench * px;
@ -792,22 +849,28 @@ export default {
.mr10 { .mr10 {
margin-right: 10px; margin-right: 10px;
} }
.ml20 { .ml20 {
margin-left: 20px; margin-left: 20px;
} }
.border-right { .border-right {
border-right: 1px solid #273b4d; border-right: 1px solid #273b4d;
} }
.border-left { .border-left {
border-left: 1px solid #273b4d; border-left: 1px solid #273b4d;
} }
.el-icon-arrow-down { .el-icon-arrow-down {
font-size: 10px; font-size: 10px;
} }
.is-active { .is-active {
background: #31455d !important; background: #31455d !important;
color: #bfcbd9 !important; color: #bfcbd9 !important;
} }
.layout { .layout {
display: -webkit-box; display: -webkit-box;
display: -ms-flexbox; display: -ms-flexbox;
@ -817,6 +880,7 @@ export default {
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: hidden;
.layout-left { .layout-left {
display: inline-block; display: inline-block;
height: 100%; height: 100%;
@ -849,6 +913,7 @@ export default {
border: 1px solid #3a4659; border: 1px solid #3a4659;
background: #282a30; background: #282a30;
} }
.tools-item-text { .tools-item-text {
} }
} }
@ -865,6 +930,7 @@ export default {
background-color: #242a30; background-color: #242a30;
cursor: pointer; cursor: pointer;
padding-top: 26%; padding-top: 26%;
i { i {
font-size: 18px; font-size: 18px;
width: 18px; width: 18px;
@ -886,18 +952,21 @@ export default {
align-items: center; align-items: center;
vertical-align: middle; vertical-align: middle;
text-align: center; text-align: center;
.top-button { .top-button {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
height: 40px; height: 40px;
line-height: 40px; line-height: 40px;
margin-left: 9px; margin-left: 9px;
.btn { .btn {
color: #788994; color: #788994;
width: 55px; width: 55px;
text-align: center; text-align: center;
display: block; display: block;
cursor: pointer; cursor: pointer;
.el-icon-arrow-down { .el-icon-arrow-down {
transform: rotate(0deg); transform: rotate(0deg);
-ms-transform: rotate(0deg); /* IE 9 */ -ms-transform: rotate(0deg); /* IE 9 */
@ -906,8 +975,10 @@ export default {
-o-transform: rotate(0deg); /* Opera */ -o-transform: rotate(0deg); /* Opera */
transition: all 0.4s ease-in-out; transition: all 0.4s ease-in-out;
} }
&:hover { &:hover {
background: rgb(25, 29, 34); background: rgb(25, 29, 34);
.el-icon-arrow-down { .el-icon-arrow-down {
transform: rotate(180deg); transform: rotate(180deg);
-ms-transform: rotate(180deg); /* IE 9 */ -ms-transform: rotate(180deg); /* IE 9 */
@ -919,6 +990,7 @@ export default {
} }
} }
} }
.workbench-container { .workbench-container {
position: relative; position: relative;
-webkit-transform-origin: 0 0; -webkit-transform-origin: 0 0;
@ -927,10 +999,12 @@ export default {
box-sizing: border-box; box-sizing: border-box;
margin: 0; margin: 0;
padding: 0; padding: 0;
.vueRuler { .vueRuler {
width: 100%; width: 100%;
padding: 18px 0px 0px 18px; padding: 18px 0px 0px 18px;
} }
.workbench { .workbench {
background-color: #1e1e1e; background-color: #1e1e1e;
position: relative; position: relative;
@ -943,6 +1017,7 @@ export default {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
.bg-grid { .bg-grid {
position: absolute; position: absolute;
top: 0; top: 0;
@ -953,11 +1028,12 @@ export default {
background-image: linear-gradient( background-image: linear-gradient(
hsla(0, 0%, 100%, 0.1) 1px, hsla(0, 0%, 100%, 0.1) 1px,
transparent 0 transparent 0
), ),
linear-gradient(90deg, hsla(0, 0%, 100%, 0.1) 1px, transparent 0); linear-gradient(90deg, hsla(0, 0%, 100%, 0.1) 1px, transparent 0);
// z-index: 2; // z-index: 2;
} }
} }
.bottom-text { .bottom-text {
width: 100%; width: 100%;
color: #a0a0a0; color: #a0a0a0;
@ -972,36 +1048,43 @@ export default {
height: 100%; height: 100%;
} }
/deep/.el-tabs--border-card { /deep/ .el-tabs--border-card {
border: 0; border: 0;
.el-tabs__header { .el-tabs__header {
.el-tabs__nav { .el-tabs__nav {
.el-tabs__item { .el-tabs__item {
background-color: #242f3b; background-color: #242f3b;
border: 0px; border: 0px;
} }
.el-tabs__item.is-active { .el-tabs__item.is-active {
background-color: #31455d; background-color: #31455d;
} }
} }
} }
.el-tabs__content { .el-tabs__content {
background-color: #242a30; background-color: #242a30;
height: calc(100vh - 39px); height: calc(100vh - 39px);
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
.el-tab-pane { .el-tab-pane {
color: #bfcbd9; color: #bfcbd9;
} }
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 5px; width: 5px;
height: 14px; height: 14px;
} }
&::-webkit-scrollbar-track, &::-webkit-scrollbar-track,
&::-webkit-scrollbar-thumb { &::-webkit-scrollbar-thumb {
border-radius: 1px; border-radius: 1px;
border: 0 solid transparent; border: 0 solid transparent;
} }
&::-webkit-scrollbar-track-piece { &::-webkit-scrollbar-track-piece {
/*修改滚动条的背景和圆角*/ /*修改滚动条的背景和圆角*/
background: #29405c; background: #29405c;
@ -1011,14 +1094,17 @@ export default {
&::-webkit-scrollbar-track { &::-webkit-scrollbar-track {
box-shadow: 1px 1px 5px rgba(116, 148, 170, 0.5) inset; box-shadow: 1px 1px 5px rgba(116, 148, 170, 0.5) inset;
} }
&::-webkit-scrollbar-thumb { &::-webkit-scrollbar-thumb {
min-height: 20px; min-height: 20px;
background-clip: content-box; background-clip: content-box;
box-shadow: 0 0 0 5px rgba(116, 148, 170, 0.5) inset; box-shadow: 0 0 0 5px rgba(116, 148, 170, 0.5) inset;
} }
&::-webkit-scrollbar-corner { &::-webkit-scrollbar-corner {
background: transparent; background: transparent;
} }
/*修改垂直滚动条的样式*/ /*修改垂直滚动条的样式*/
&::-webkit-scrollbar-thumb:vertical { &::-webkit-scrollbar-thumb:vertical {
background-color: #00113a; background-color: #00113a;
@ -1033,34 +1119,41 @@ export default {
} }
} }
} }
ul, ul,
li { li {
list-style: none; list-style: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
.nav { .nav {
width: 40px; width: 40px;
padding: 0; padding: 0;
list-style: none; list-style: none;
/* overflow: hidden; */ /* overflow: hidden; */
} }
.nav { .nav {
zoom: 1; zoom: 1;
} }
.nav:before, .nav:before,
.nav:after { .nav:after {
content: ""; content: "";
display: table; display: table;
} }
.nav:after { .nav:after {
clear: both; clear: both;
} }
.nav li { .nav li {
width: 55px; width: 55px;
text-align: center; text-align: center;
position: relative; position: relative;
} }
.nav li a { .nav li a {
float: left; float: left;
padding: 12px 30px; padding: 12px 30px;
@ -1068,9 +1161,11 @@ li {
font: bold 12px; font: bold 12px;
text-decoration: none; text-decoration: none;
} }
.nav li:hover { .nav li:hover {
color: #788994; color: #788994;
} }
.nav li ul { .nav li ul {
visibility: hidden; visibility: hidden;
position: absolute; position: absolute;
@ -1085,14 +1180,17 @@ li {
width: 120px; width: 120px;
transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out;
} }
.nav li:hover > ul { .nav li:hover > ul {
opacity: 1; opacity: 1;
visibility: visible; visibility: visible;
margin: 0; margin: 0;
li:hover { li:hover {
background-color: rgb(25, 29, 34); background-color: rgb(25, 29, 34);
} }
} }
.nav ul li { .nav ul li {
float: left; float: left;
display: block; display: block;
@ -1100,6 +1198,7 @@ li {
width: 100%; width: 100%;
font-size: 12px; font-size: 12px;
} }
.nav ul a { .nav ul a {
padding: 10px; padding: 10px;
width: 100%; width: 100%;
@ -1110,12 +1209,15 @@ li {
background-color: rgb(25, 29, 34); background-color: rgb(25, 29, 34);
transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out;
} }
.nav ul a:hover { .nav ul a:hover {
border: 1px solid #3c5e88; border: 1px solid #3c5e88;
} }
.nav ul li:first-child > a:hover:before { .nav ul li:first-child > a:hover:before {
border-bottom-color: #04acec; border-bottom-color: #04acec;
} }
.nav ul ul { .nav ul ul {
top: 0; top: 0;
left: 120px; left: 120px;
@ -1125,6 +1227,7 @@ li {
padding: 10px; padding: 10px;
_margin: 0; _margin: 0;
} }
.nav ul ul li { .nav ul ul li {
width: 120px; width: 120px;
height: 120px; height: 120px;
@ -1132,10 +1235,12 @@ li {
display: block; display: block;
float: left; float: left;
} }
/deep/.vue-ruler-h {
/deep/ .vue-ruler-h {
opacity: 0.3; opacity: 0.3;
} }
/deep/.vue-ruler-v {
/deep/ .vue-ruler-v {
opacity: 0.3; opacity: 0.3;
} }
</style> </style>

Loading…
Cancel
Save