mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-07 18:25:45 +08:00
fixing dashboard errors (#985)
Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
parent
f6a874784d
commit
cba978916b
@ -22,12 +22,12 @@
|
||||
>
|
||||
<div class="clearfix">
|
||||
<el-row :gutter="2">
|
||||
<el-col :span="isEmptyValue(title) ? 22 : 23">
|
||||
<el-col :span="main ? 22 : 23">
|
||||
<el-button type="text" class="label-dashboard" @click="metadata.isCollapsible = !metadata.isCollapsible">
|
||||
{{ labelDashboard }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col v-if="isEmptyValue(title)" :span="1">
|
||||
<el-col v-if="main" :span="1">
|
||||
<el-button type="text" icon="el-icon-files" @click="sendMain(metadata)" />
|
||||
</el-col>
|
||||
<el-col :span="1">
|
||||
@ -59,6 +59,10 @@ export default {
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
main: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -28,7 +28,7 @@ const dashboard = {
|
||||
},
|
||||
mutations: {
|
||||
addDashboard(state, payload) {
|
||||
state.dashboard.push(payload)
|
||||
state.dashboard = payload
|
||||
},
|
||||
notifyDashboardRefresh: (state, payload) => {
|
||||
|
||||
@ -44,7 +44,7 @@ const dashboard = {
|
||||
refreshDashboard({ commit }, parameters) {
|
||||
commit('notifyDashboardRefresh', parameters)
|
||||
},
|
||||
listDashboard({ commit, rootGetters }, {
|
||||
listDashboard({ commit, state, rootGetters }, {
|
||||
roleId,
|
||||
roleUuid
|
||||
}) {
|
||||
@ -66,7 +66,7 @@ const dashboard = {
|
||||
roleUuid: roleUuid,
|
||||
...dashboardResponse
|
||||
}
|
||||
commit('addDashboard', roleDashboards)
|
||||
commit('addDashboard', dashboardResponse.dashboardsList)
|
||||
resolve(roleDashboards)
|
||||
})
|
||||
.catch(error => {
|
||||
@ -79,15 +79,8 @@ const dashboard = {
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getDashboard: (state) => (dashboardUuid) => {
|
||||
return state.dashboard.find(
|
||||
item => item.uuid === dashboardUuid
|
||||
)
|
||||
},
|
||||
getDashboardByRole: (state) => (roleUuid) => {
|
||||
return state.dashboard.find(
|
||||
item => item.roleUuid === roleUuid
|
||||
)
|
||||
getDashboard: (state) => {
|
||||
return state.dashboard
|
||||
},
|
||||
getMainDashboard: (state) => {
|
||||
return state.mainashboard
|
||||
|
@ -1,15 +1,19 @@
|
||||
<template>
|
||||
<div class="dashboard-editor-container">
|
||||
<el-row :gutter="8">
|
||||
<el-col v-if="!isEmptyValue(mainashboard)" :span="24" style="padding-right:8px;margin-bottom:2px;">
|
||||
<el-row v-if="!isEmptyValue(listDashboard)" :gutter="8">
|
||||
<el-col v-if="!isEmptyValue(maindashboard)" :span="24" style="padding-right:8px;margin-bottom:2px;">
|
||||
<dashboard
|
||||
:metadata="mainashboard"
|
||||
:title="mainashboard.name"
|
||||
:metadata="maindashboard"
|
||||
:title="maindashboard.name"
|
||||
/>
|
||||
</el-col>
|
||||
<template v-for="(dashboardAttributes, index) in dashboardList">
|
||||
<el-col v-if="index > 0" :key="index" :xs="{ span: 24 }" :sm="{ span: 24 }" :md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 12 }" style="padding-right:8px;margin-bottom:2px;">
|
||||
<dashboard :metadata="dashboardAttributes" />
|
||||
<template v-for="(dashboardAttributes, index) in listDashboard">
|
||||
<el-col :key="index" :xs="{ span: 24 }" :sm="{ span: 24 }" :md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 12 }" style="padding-right:8px;margin-bottom:2px;">
|
||||
<dashboard
|
||||
:metadata="dashboardAttributes"
|
||||
:title="dashboardAttributes.name"
|
||||
:main="true"
|
||||
/>
|
||||
</el-col>
|
||||
</template>
|
||||
</el-row>
|
||||
@ -31,8 +35,9 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getterDashboard() {
|
||||
return this.$store.getters.getDashboardByRole(this.roleUuid)
|
||||
listDashboard() {
|
||||
const list = this.$store.getters.getDashboard
|
||||
return list.filter(dashboard => this.maindashboard.id !== dashboard.id)
|
||||
},
|
||||
currentRole() {
|
||||
return this.$store.getters['user/getRole']
|
||||
@ -40,7 +45,7 @@ export default {
|
||||
getterRol() {
|
||||
return this.$store.getters.getRoleUuid
|
||||
},
|
||||
mainashboard() {
|
||||
maindashboard() {
|
||||
return this.$store.getters.getMainDashboard
|
||||
}
|
||||
},
|
||||
@ -48,7 +53,7 @@ export default {
|
||||
getterRol(value) {
|
||||
this.getDashboardListFromServer()
|
||||
},
|
||||
mainashboard(value) {
|
||||
maindashboard(value) {
|
||||
this.getDashboardListFromServer()
|
||||
}
|
||||
},
|
||||
@ -62,8 +67,8 @@ export default {
|
||||
roleUuid: this.currentRole.uuid
|
||||
})
|
||||
.then(response => {
|
||||
if (this.isEmptyValue(this.mainashboard)) {
|
||||
this.$store.dispatch('mainDashboard', response.dashboardsList[1])
|
||||
if (this.isEmptyValue(this.maindashboard)) {
|
||||
this.$store.dispatch('mainDashboard', response.dashboardsList[0])
|
||||
}
|
||||
this.dashboardList = response.dashboardsList
|
||||
this.$forceUpdate()
|
||||
|
Loading…
x
Reference in New Issue
Block a user