| | |
| | | }) |
| | | var myGrid = copmsList; |
| | | this.$TOOL.data.set("DASHBOARDGRID", copmsList); |
| | | |
| | | return this.allCompsList; |
| | | }, |
| | | nowCompsList(){ |
| | |
| | | }, |
| | | methods: { |
| | | endDraggable(e) { |
| | | console.log(e,this.grid) |
| | | |
| | | }, |
| | | getWorkbenchCarList() { |
| | | var data = this.$TOOL.data.get("MENU"); |
| | |
| | | //按ycoordinate进行从小到大排序,如果ycoordinate一样时,按照xcoordinate从小到大排序 |
| | | //cardWide代表宽度 |
| | | //cardKey代表组件名称 |
| | | cards.sort((a, b) => { |
| | | // 先比较 ycoordinate |
| | | if (a.ycoordinate < b.ycoordinate) { |
| | | return -1; |
| | | } |
| | | if (a.ycoordinate > b.ycoordinate) { |
| | | return 1; |
| | | } |
| | | // 如果 ycoordinate 相同,则比较 xcoordinate |
| | | if (a.xcoordinate < b.xcoordinate) { |
| | | return -1; |
| | | } |
| | | if (a.xcoordinate > b.xcoordinate) { |
| | | return 1; |
| | | } |
| | | // 如果 xcoordinate 也相同,则不交换位置 |
| | | return 0; |
| | | }); |
| | | var layout = [...new Set(cards.map(v => v.cardWide *2))]; //布局 |
| | | if(layout.length < 3) { |
| | | layout = [24,12,6,6]; |
| | | } |
| | | // cards.sort((a, b) => { |
| | | // // 先比较 ycoordinate |
| | | // if (a.ycoordinate < b.ycoordinate) { |
| | | // return -1; |
| | | // } |
| | | // if (a.ycoordinate > b.ycoordinate) { |
| | | // return 1; |
| | | // } |
| | | // // 如果 ycoordinate 相同,则比较 xcoordinate |
| | | // if (a.xcoordinate < b.xcoordinate) { |
| | | // return -1; |
| | | // } |
| | | // if (a.xcoordinate > b.xcoordinate) { |
| | | // return 1; |
| | | // } |
| | | // // 如果 xcoordinate 也相同,则不交换位置 |
| | | // return 0; |
| | | // }); |
| | | // var layout = [...new Set(cards.map(v => v.cardWide *2))]; //布局 |
| | | // if(layout.length < 3) { |
| | | // layout = [24,12,6,6]; |
| | | // } |
| | | var result = {} |
| | | //排序 |
| | | cards.forEach(v=> { |
| | | if(!result[`${v.cardWide}-${v.xcoordinate}`]) { |
| | | result[`${v.cardWide}-${v.xcoordinate}`] = [] |
| | | } |
| | | result[`${v.cardWide}-${v.xcoordinate}`].push(v) |
| | | }) |
| | | let resdata = [] |
| | | Object.values(result).forEach(v => { |
| | | let min = v.sort((a,b) => a.ycoordinate - b.ycoordinate)[0]; |
| | | let minYX = Number(min.ycoordinate)*10 + Number(min.xcoordinate); |
| | | let obj = {}; |
| | | obj[minYX] = v; |
| | | resdata.push(obj); |
| | | }) |
| | | var lastData = resdata.map(v => Object.values(v)); |
| | | //转化 |
| | | var copmsList = lastData.map(function(outerArray) { |
| | | // 访问最内层的对象数组 |
| | | var innerArray = outerArray[0]; |
| | | return innerArray.map(function(obj) { |
| | | return obj.cardKey; |
| | | }); |
| | | }); |
| | | // cards.forEach(v=> { |
| | | // if(!result[`${v.cardWide}-${v.xcoordinate}`]) { |
| | | // result[`${v.cardWide}-${v.xcoordinate}`] = [] |
| | | // } |
| | | // result[`${v.cardWide}-${v.xcoordinate}`].push(v) |
| | | // }) |
| | | // let resdata = [] |
| | | // Object.values(result).forEach(v => { |
| | | // let min = v.sort((a,b) => a.ycoordinate - b.ycoordinate)[0]; |
| | | // let minYX = Number(min.ycoordinate)*10 + Number(min.xcoordinate); |
| | | // let obj = {}; |
| | | // obj[minYX] = v; |
| | | // resdata.push(obj); |
| | | // }) |
| | | // var lastData = resdata.map(v => Object.values(v)); |
| | | // //转化 |
| | | // var copmsList = lastData.map(function(outerArray) { |
| | | // // 访问最内层的对象数组 |
| | | // var innerArray = outerArray[0]; |
| | | // return innerArray.map(function(obj) { |
| | | // return obj.cardKey; |
| | | // }); |
| | | // }); |
| | | //保证有4个数组,才能拖拽 |
| | | var neededLength = 4 - copmsList.length; |
| | | for (var i = 0; i < neededLength; i++) { |
| | | copmsList.push([]); |
| | | } |
| | | this.$CONFIG.DEFAULT_GRID.copmsList = copmsList; |
| | | this.$CONFIG.DEFAULT_GRID.layout = layout; |
| | | this.$CONFIG.DEFAULT_GRID.data = cards; |
| | | // var neededLength = 4 - copmsList.length; |
| | | // for (var i = 0; i < neededLength; i++) { |
| | | // copmsList.push([]); |
| | | // } |
| | | // this.$CONFIG.DEFAULT_GRID.copmsList = copmsList; |
| | | // this.$CONFIG.DEFAULT_GRID.layout = layout; |
| | | // this.$CONFIG.DEFAULT_GRID.data = cards; |
| | | //this.$CONFIG.DEFAULT_GRID.copmsList = [["mdcDeviceStatus"],["mdcRunning","mdcEquipmentRun"],[],[]] |
| | | this.$CONFIG.DEFAULT_GRID.copmsList = res.data[0].layoutConfig == null?[]:JSON.parse(res.data[0].layoutConfig); |
| | | // if(this.$CONFIG.DEFAULT_GRID.copmsList.length == 0) { |
| | | // this.$CONFIG.DEFAULT_GRID.copmsList = [["mdcDeviceStatus"],["mdcRunning","mdcEquipmentRun"],[],[]] |
| | | // } |
| | | this.$CONFIG.DEFAULT_GRID.layout = [24,12,6,6]; |
| | | this.$CONFIG.DEFAULT_GRID.data = res.data; |
| | | this.defaultGrid = this.$CONFIG.DEFAULT_GRID; |
| | | this.grid = this.$TOOL.data.get("grid") || JSON.parse(JSON.stringify(this.defaultGrid)); |
| | | console.log(this.$TOOL.data.get("grid"),JSON.parse(JSON.stringify(this.defaultGrid)),555) |
| | | } |
| | | }) |
| | | }, |
| | |
| | | target.copmsList[0].push(item.key) |
| | | } |
| | | this.$nextTick(()=> { |
| | | var height = String(Math.floor(this.$refs.Access[0].offsetHeight/ 57)); |
| | | item.cardLength = height; |
| | | item.cardWide = '12'; |
| | | item.xcoordinate = '0'; |
| | | //var height = String(Math.floor(this.$refs.Access[0].offsetHeight/ 57)); |
| | | //item.cardLength = height; |
| | | //item.cardWide = '12'; |
| | | //item.xcoordinate = '0'; |
| | | //item.ycoordinate = '4'; |
| | | item.cardKey = item.key; |
| | | item.workbenchId = that.workid; |
| | |
| | | this.$refs.widgets.style.removeProperty('transform') |
| | | this.$TOOL.data.set("grid", this.grid) |
| | | //保存接口 |
| | | var copmsList = this.grid.copmsList; |
| | | var flattened = copmsList.reduce((acc, val) => acc.concat(val), []); //扁平化 |
| | | var data = this.grid.data.filter(item=>flattened.includes(item.cardKey)); |
| | | //var copmsList = this.grid.copmsList; |
| | | //var flattened = copmsList.reduce((acc, val) => acc.concat(val), []); //扁平化 |
| | | //var data = this.grid.data.filter(item=>this.nowCompsList.includes(item.cardKey)); |
| | | this.grid.data.forEach(item=> { |
| | | item.layoutConfig = JSON.stringify(this.grid.copmsList); |
| | | }) |
| | | var obj = { |
| | | workbenchCardAddVOList: data, |
| | | workbenchCardAddVOList: this.grid.data, |
| | | workbenchId: this.workid |
| | | } |
| | | this.$HTTP.post(`/api/blade-system/workbench-card/create-workbench-card`,obj).then(res=> { |