From e84fd20593c567068714cd3b4cf3b0b39f8d41c1 Mon Sep 17 00:00:00 2001 From: hanyuxia Date: Fri, 20 Mar 2020 18:47:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=8A=9F=E8=83=BD=201.dashboard?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=9A=E6=9B=B2=E7=BA=BF=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E5=AE=9E=E7=8E=B0=E6=8B=96=E6=8B=BD=E6=94=B9?= =?UTF-8?q?=E5=8F=98=E5=A4=A7=E5=B0=8F,=E5=90=8E=E5=8F=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=B7=B2=E6=B5=8B=E8=AF=95=EF=BC=8C=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=9B=BE=E8=A1=A8=E6=8B=96=E6=8B=BD=E6=94=B9?= =?UTF-8?q?=E5=8F=98=E5=A4=A7=E5=B0=8F=EF=BC=8C=E5=8F=8A=E5=BD=93=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E7=BC=A9=E5=B0=8F=E5=88=B0=E6=9C=80=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E8=B6=85=E5=87=BA=E9=83=A8=E5=88=86=E9=9A=90=E8=97=8F=E7=AD=89?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/charts/chart-list.vue | 134 +++++++++++++--- .../src/components/charts/chart-table.scss | 37 ++++- .../src/components/charts/chart-table.vue | 146 +++++++++++++++++- .../components/charts/line-chart-block.scss | 15 +- .../components/charts/line-chart-block.vue | 15 +- 5 files changed, 320 insertions(+), 27 deletions(-) diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 3589682d3..7c1b48e2d 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -3,6 +3,7 @@ box-sizing: border-box; float:left; padding: 0 10px 10px 10px; + /*position:relative;*/ } .noData{ text-align: center @@ -11,31 +12,79 @@ width: calc(100% - 14px); overflow-x:hidden;/*避免鼠标第一次放到曲线时,x轴出现滚动条后消失*/ } + @@ -44,6 +93,7 @@ import axios from 'axios'; import bus from '../../libs/bus'; import lineChartBlock from './line-chart-block'; import chartTable from './chart-table'; +//import draggable from 'vuedraggable' export default { name: 'chartList', @@ -52,6 +102,7 @@ export default { components: { lineChartBlock, chartTable, + //draggable, }, data() { return { @@ -67,12 +118,49 @@ export default { isPage:true,//是否分页懒加载 currentRecordNum:0,//懒加载:本次取记录的index,第一次从0开始取,每次取3行 lineNum:3,//每页加载的行数 - pagePanelId:''//当前分页的panelId + pagePanelId:'',//当前分页的panelId + dragging: null }; }, computed: {}, watch: {}, methods: { + change (event) { + console.log('change', event) + }, + start (event) { + console.log('start', event) + }, + end (event) { + console.log('end', event, this.groups) + }, + move (event, orgin) { + console.log('move', event, orgin) + }, + handleDragStart(e,item){ + this.dragging = item; + }, + handleDragEnd(e,item){ + this.dragging = null + }, + //首先把div变成可以放置的元素,即重写dragenter/dragover + handleDragOver(e) { + e.dataTransfer.dropEffect = 'move'// e.dataTransfer.dropEffect="move";//在dragenter中针对放置目标来设置! + }, + handleDragEnter(e,item){ + e.dataTransfer.effectAllowed = "move"//为需要移动的元素设置dragstart事件 + if(item === this.dragging){ + return + } + const newItems = [...this.dataList] + console.log(newItems) + const src = newItems.indexOf(this.dragging) + const dst = newItems.indexOf(item) + + newItems.splice(dst, 0, ...newItems.splice(src, 1)) + + this.dataList = newItems + }, initCurrentRecordNum(){ this.currentRecordNum = 0; }, @@ -417,6 +505,12 @@ export default { this.$emit('on-edit-chart', chart); } }, + + editChartForDrag(chartItem){ + let chart = this.dataList.find(item => item.id === chartItem.id); + chart.span = chartItem.span; + chart.height = chartItem.height; + }, // 刷新列表中的一个图表 refreshChart(chartId,searchTime) { this.dataList.forEach((item, index) => { diff --git a/nezha-fronted/src/components/charts/chart-table.scss b/nezha-fronted/src/components/charts/chart-table.scss index f7883dc84..4f9152d5e 100644 --- a/nezha-fronted/src/components/charts/chart-table.scss +++ b/nezha-fronted/src/components/charts/chart-table.scss @@ -41,10 +41,33 @@ border: 1px solid #d8dce1; padding: 20px 8px 3px; margin-bottom: 10px; + .vue-resizable-handle { + position: absolute; + width: 20px; + height: 20px; + bottom: 0; + right: 0; + cursor: se-resize; + box-sizing: border-box; + } + .vue-resizable-handle:after { + border-right: 2px solid #555; + border-bottom: 2px solid #555; + content: ""; + position: absolute; + right: 3px; + bottom: 3px; + width: 5px; + height: 5px; + /*border-right: 2px solid rgba(0,0,0,.4); + border-bottom: 2px solid rgba(0,0,0,.4);*/ + box-sizing: inherit; + } .chartTitle { text-align: center; width: 100%; .nz-chart-top{ + width:100%; } .el-dropdown-link { cursor: pointer; @@ -57,7 +80,19 @@ font-size: 18px; line-height: 26px; color: #333; - margin: -3px 0 3px 10px; + margin: -3px 0 3px 3px; + display:flex; + justify-content:center; + align-items:center; + .chart-title-text{ + max-width:calc(100% - 20px); + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + } + .chart-title-icon{ + display: inline-block; + } } } .edit:after{ diff --git a/nezha-fronted/src/components/charts/chart-table.vue b/nezha-fronted/src/components/charts/chart-table.vue index afc496b29..15c433f03 100644 --- a/nezha-fronted/src/components/charts/chart-table.vue +++ b/nezha-fronted/src/components/charts/chart-table.vue @@ -21,7 +21,8 @@ - {{data.title}} + {{data.title}} +