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}} +