From 84ae4dbb788829df89cfd4dce441ff102d31c41d Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 12 Jan 2023 18:52:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=A2=9E=E5=8A=A0=E5=AF=BC=E5=87=BA=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/server/XEmailTaskServer.java | 38 +++++ frontend/src/components/canvas/DeCanvas.vue | 3 + .../components/canvas/components/Toolbar.vue | 26 ++++ .../canvas/components/editor/DeEditor.vue | 49 ++++++- .../components/editor/PageLineEditor.vue | 136 ++++++++++++++++++ frontend/src/components/canvas/utils/utils.js | 3 +- frontend/src/lang/en.js | 2 + frontend/src/lang/tw.js | 2 + frontend/src/lang/zh.js | 2 + frontend/src/views/panel/panel.js | 9 ++ 10 files changed, 267 insertions(+), 3 deletions(-) create mode 100644 frontend/src/components/canvas/components/editor/PageLineEditor.vue diff --git a/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java b/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java index 965889d66a..07d0736209 100644 --- a/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java +++ b/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java @@ -165,6 +165,44 @@ public class XEmailTaskServer { return xpackEmailCreate; } + @DeRateLimiter + @PostMapping(value = "/screenpdf", produces = {MediaType.APPLICATION_PDF_VALUE}) + public ResponseEntity screenpdf(@RequestBody XpackEmailViewRequest request) { + EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class); + String url = ServletUtils.domain() + "/#/previewScreenShot/" + request.getPanelId() + "/true"; + byte[] bytes = null; + try { + String currentToken = ServletUtils.getToken(); + Future future = priorityExecutor.submit(() -> { + try { + return emailXpackService.printPdf(url, currentToken, buildPixel(request.getPixel())); + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + DEException.throwException("预览失败,请联系管理员"); + } + return null; + }, 0); + Object object = future.get(); + if (ObjectUtils.isNotEmpty(object)) { + bytes = (byte[]) object; + if (ArrayUtil.isNotEmpty(bytes)) { + String fileName = request.getPanelId() + ".pdf"; + ByteArrayResource bar = new ByteArrayResource(bytes); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_PDF); + ContentDisposition contentDisposition = ContentDisposition.parse("attachment; filename=" + URLEncoder.encode(fileName, "UTF-8")); + headers.setContentDisposition(contentDisposition); + return new ResponseEntity(bar, headers, HttpStatus.OK); + } + } + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + DEException.throwException("预览失败,请联系管理员"); + } + + return null; + } + @DeRateLimiter @PostMapping(value = "/screenshot", produces = {MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE}) public ResponseEntity screenshot(@RequestBody XpackEmailViewRequest request) { diff --git a/frontend/src/components/canvas/DeCanvas.vue b/frontend/src/components/canvas/DeCanvas.vue index 797273c3f3..959a1379aa 100644 --- a/frontend/src/components/canvas/DeCanvas.vue +++ b/frontend/src/components/canvas/DeCanvas.vue @@ -297,6 +297,9 @@ export default { // this.$emit('handleDrop', e) // } handleDrop(e) { + if (!this.dragComponentInfo) { + return + } this.dragComponentInfo.moveStatus = 'drop' // 记录拖拽信息 this.dropComponentInfo = deepCopy(this.dragComponentInfo) diff --git a/frontend/src/components/canvas/components/Toolbar.vue b/frontend/src/components/canvas/components/Toolbar.vue index 2900b4b022..cba329b39b 100644 --- a/frontend/src/components/canvas/components/Toolbar.vue +++ b/frontend/src/components/canvas/components/Toolbar.vue @@ -153,6 +153,25 @@ @change="styleChange" /> + + + + + + {{ $t('panel.export_pdf_page') }} + + + + @@ -247,6 +266,7 @@ export default { }, data() { return { + showPageLine: false, showGridSwitch: false, mobileLayoutInitStatus: false, isShowPreview: false, @@ -305,6 +325,7 @@ export default { this.scale = this.canvasStyleData.scale this.mobileLayoutInitStatus = this.mobileLayoutStatus this.showGridSwitch = this.canvasStyleData.aidedDesign.showGrid + this.showPageLine = this.canvasStyleData.pdfPageLine?.showPageLine this.autoCache() }, beforeDestroy() { @@ -323,6 +344,7 @@ export default { }, editPanelInit() { this.showGridSwitch = this.canvasStyleData.aidedDesign.showGrid + this.showPageLine = this.canvasStyleData.pdfPageLine?.showPageLine }, close() { // 关闭页面清理缓存 @@ -589,6 +611,10 @@ export default { this.$store.commit('canvasChange') this.canvasStyleData.aidedDesign.showGrid = !this.canvasStyleData.aidedDesign.showGrid }, + showPageLineChange() { + this.$store.commit('canvasChange') + this.canvasStyleData.pdfPageLine.showPageLine = !this.canvasStyleData.pdfPageLine.showPageLine + }, // batch option batchOption() { bus.$emit('change_panel_right_draw', !this.batchOptStatus) diff --git a/frontend/src/components/canvas/components/editor/DeEditor.vue b/frontend/src/components/canvas/components/editor/DeEditor.vue index 31234920ae..64ee36fd7f 100644 --- a/frontend/src/components/canvas/components/editor/DeEditor.vue +++ b/frontend/src/components/canvas/components/editor/DeEditor.vue @@ -12,6 +12,11 @@ @mousedown="handleMouseDown" @scroll="canvasScroll" > + - + { + const top = this.getShapeStyleIntDeDrag(item.style, 'top') + const height = this.getShapeStyleIntDeDrag(item.style, 'height') + baseHeight = Math.max(baseHeight, top + height) + }) + return baseHeight + }, customStyle() { let style = { width: '100%', @@ -1024,6 +1046,20 @@ export default { }, deep: true }, + scrollHeight: { + handler(newVal, oldVla) { + this.$nextTick(() => { + if (newVal !== oldVla && this.showPageLine) { + const lineRef = this.$refs['main-page-line'] + if (lineRef?.init) { + lineRef.init(newVal) + } + } + console.log(newVal) + }) + }, + deep: true + }, outStyle: { handler(newVal, oldVla) { this.resizeParentBoundsRef() @@ -1251,6 +1287,9 @@ export default { }, changeStyleWithScale, handleMouseDown(e) { + if (this.isPageLineTarget(e)) { + return + } // 如果没有选中组件 在画布上点击时需要调用 e.preventDefault() 防止触发 drop 事件 if (!this.curComponent || (this.curComponent.component !== 'v-text' && this.curComponent.component !== 'rect-shape')) { e.preventDefault() @@ -1259,6 +1298,9 @@ export default { // 挤占式画布设计 this.containerMouseDown(e) }, + isPageLineTarget(e) { + return e.target.classList && [...e.target.classList].includes('page-line-item') + }, hideArea() { this.isShowArea = 0 @@ -1517,6 +1559,9 @@ export default { } }, handleDragOver(e) { + if (!this.dragComponentInfo?.shadowStyle) { + return + } this.dragComponentInfo.shadowStyle.x = e.pageX - 220 this.dragComponentInfo.shadowStyle.y = e.pageY - 90 + this.scrollTop this.dragComponentInfo.style.left = this.dragComponentInfo.shadowStyle.x / this.scalePointWidth diff --git a/frontend/src/components/canvas/components/editor/PageLineEditor.vue b/frontend/src/components/canvas/components/editor/PageLineEditor.vue new file mode 100644 index 0000000000..b31c82cde0 --- /dev/null +++ b/frontend/src/components/canvas/components/editor/PageLineEditor.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/frontend/src/components/canvas/utils/utils.js b/frontend/src/components/canvas/utils/utils.js index 3105ab5341..220e083b0f 100644 --- a/frontend/src/components/canvas/utils/utils.js +++ b/frontend/src/components/canvas/utils/utils.js @@ -8,7 +8,7 @@ import { import { ApplicationContext } from '@/utils/ApplicationContext' import { uuid } from 'vue-uuid' import store from '@/store' -import { AIDED_DESIGN, MOBILE_SETTING, PANEL_CHART_INFO, TAB_COMMON_STYLE } from '@/views/panel/panel' +import { AIDED_DESIGN, MOBILE_SETTING, PANEL_CHART_INFO, TAB_COMMON_STYLE, PAGE_LINE_DESIGN } from '@/views/panel/panel' import html2canvas from 'html2canvasde' export function deepCopy(target) { @@ -83,6 +83,7 @@ export function panelDataPrepare(componentData, componentStyle, callback) { componentStyle.refreshUnit = (componentStyle.refreshUnit || 'minute') componentStyle.refreshViewEnable = (componentStyle.refreshViewEnable === undefined ? true : componentStyle.refreshViewEnable) componentStyle.aidedDesign = (componentStyle.aidedDesign || deepCopy(AIDED_DESIGN)) + componentStyle.pdfPageLine = (componentStyle.pdfPageLine || deepCopy(PAGE_LINE_DESIGN)) componentStyle.chartInfo = (componentStyle.chartInfo || deepCopy(PANEL_CHART_INFO)) componentStyle.chartInfo.tabStyle = (componentStyle.chartInfo.tabStyle || deepCopy(TAB_COMMON_STYLE)) componentStyle.themeId = (componentStyle.themeId || 'NO_THEME') diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 0be62dda0c..7c50fbf6c2 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -2244,6 +2244,8 @@ export default { aided_grid: 'Aided Grid', aided_grid_open: 'Open', aided_grid_close: 'Close', + export_pdf_page: 'Pagination Line', + export_pdf_page_remark: 'Only valid for API export dashboard PDF pagination', subject_no_edit: 'System Subject Can Not Edit', subject_name_not_null: 'Subject Name Can Not Be Null And Less Than 20 charts', is_enable: 'Enable', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 934ee002fd..4fa66c6537 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -2238,6 +2238,8 @@ export default { aided_grid: '輔助設計網格', aided_grid_open: '打開', aided_grid_close: '關閉', + export_pdf_page: '分頁線', + export_pdf_page_remark: '僅對API導出儀表板PDF分頁有效', subject_no_edit: '繫統主題不能修改', subject_name_not_null: '主題名稱需要1~20字符', is_enable: '是否啟用', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index e82257b21a..2462a07cff 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -2238,6 +2238,8 @@ export default { aided_grid: '辅助设计网格', aided_grid_open: '打开', aided_grid_close: '关闭', + export_pdf_page: '分页线', + export_pdf_page_remark: '仅对API导出仪表板PDF分页有效', subject_no_edit: '系统主题不能修改', subject_name_not_null: '主题名称需要1~20字符', is_enable: '是否启用', diff --git a/frontend/src/views/panel/panel.js b/frontend/src/views/panel/panel.js index d9d4c94fff..84dd3c7b52 100644 --- a/frontend/src/views/panel/panel.js +++ b/frontend/src/views/panel/panel.js @@ -69,6 +69,10 @@ export const CANVAS_STYLE = { showGrid: false, matrixBase: 4 // 当前matrix的基数 (是pcMatrixCount的几倍) }, // 辅助设计 + pdfPageLine: { + showPageLine: false, + proportion: null + }, refreshViewEnable: true, // 开启视图刷新(默认开启) refreshViewLoading: true, // 仪表板视图loading提示 refreshUnit: 'minute', // 仪表板刷新时间带外 默认 分钟 @@ -82,6 +86,11 @@ export const AIDED_DESIGN = { matrixBase: 1 // 当前matrix的基数 (是pcMatrixCount的几倍) } +export const PAGE_LINE_DESIGN = { + showPageLine: false, + proportion: null +} + export const DEFAULT_COMMON_CANVAS_STYLE_STRING = { ...CANVAS_STYLE }