| | |
| | | <div class="widgets-content"> |
| | | <div class="widgets-top"> |
| | | <div class="widgets-top-title"> |
| | | 控制台 |
| | | 工作台 |
| | | </div> |
| | | <div class="widgets-top-actions"> |
| | | <el-button v-if="customizing" type="primary" icon="el-icon-check" round @click="save">完成</el-button> |
| | |
| | | } |
| | | }, |
| | | created(){ |
| | | this.grid = this.$TOOL.data.get("grid") || JSON.parse(JSON.stringify(this.defaultGrid)) |
| | | //this.grid = this.$TOOL.data.get("grid") || JSON.parse(JSON.stringify(this.defaultGrid)) |
| | | this.getWorkbenchCarList(); |
| | | }, |
| | | mounted() { |
| | | this.$emit('on-mounted') |
| | |
| | | return allCompsList |
| | | }, |
| | | myCompsList(){ |
| | | var myGrid = this.$TOOL.data.get("DASHBOARDGRID") |
| | | alert(1) |
| | | var copmsList = []; |
| | | if(this.defaultGrid.copmsList == undefined) return []; |
| | | this.defaultGrid.copmsList.forEach(item=> { |
| | | copmsList = copmsList.concat([...item]) |
| | | }) |
| | | var myGrid = copmsList; |
| | | this.$TOOL.data.set("DASHBOARDGRID", copmsList); |
| | | return this.allCompsList.filter(item => !item.disabled && myGrid.includes(item.key)) |
| | | }, |
| | | nowCompsList(){ |
| | | return this.grid.copmsList.reduce(function(a, b){return a.concat(b)}) |
| | | var copmsList = []; |
| | | if(this.grid.copmsList == undefined) return []; |
| | | this.grid.copmsList.forEach(item=> { |
| | | copmsList = copmsList.concat([...item]) |
| | | }) |
| | | return copmsList; |
| | | } |
| | | }, |
| | | methods: { |
| | | getWorkbenchCarList() { |
| | | var data = this.$TOOL.data.get("MENU"); |
| | | this.workid = data[0].children[0].id; //记录第一个children的id |
| | | this.$HTTP.get(`/api/blade-system/workbench-card/list?workbenchId=${this.workid}`).then(res=> { |
| | | if(res.code == 200) { |
| | | let cards = res.data; |
| | | //ycoordinate表示从上往下从第几个开始,从0开始数 |
| | | //xcoordinate表示从左往右从第几个开始,从0开始数 |
| | | //按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; |
| | | }); |
| | | cards.forEach((item,index)=> { |
| | | this.$CONFIG.DEFAULT_GRID.copmsList[index] = [item.cardKey]; |
| | | this.$CONFIG.DEFAULT_GRID.layout[index] = item.cardWide * 2; |
| | | }) |
| | | console.log(this.$CONFIG.DEFAULT_GRID.copmsList,this.$CONFIG.DEFAULT_GRID.layout,234) |
| | | this.$CONFIG.DEFAULT_GRID.data = cards; |
| | | this.defaultGrid = this.$CONFIG.DEFAULT_GRID; |
| | | this.grid = this.$TOOL.data.get("grid") || JSON.parse(JSON.stringify(this.defaultGrid)) |
| | | } |
| | | }) |
| | | }, |
| | | //开启自定义 |
| | | custom(){ |
| | | this.customizing = true |
| | |
| | | }, |
| | | //隐藏组件 |
| | | remove(item){ |
| | | console.log(item,222) |
| | | var newCopmsList = this.grid.copmsList |
| | | newCopmsList.forEach((obj, index) => { |
| | | var newObj = obj.filter(o=>o!=item) |
| | | newCopmsList[index] = newObj; |
| | | }) |
| | | //console.log(newCopmsList,123) |
| | | }, |
| | | //保存 |
| | | save(){ |