Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ui
/
vuedashboard
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
waibao
2019-04-13 08:46:32 +0800
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
bf75c7037bb6099d48a96670e5ae8d6d123faf11
bf75c703
1 parent
1c6a287b
完成vuex转换
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
60 deletions
src/App.vue
src/components/gridComponent.vue
src/components/layout.vue
src/components/setting.vue
src/store/components/layout.js
src/views/index1/index.vue
src/App.vue
View file @
bf75c70
<template>
<div id="app">
<setting/>
<
!-- <layout/> --
>
<
layout/
>
</div>
</template>
<script>
import setting from "./components/setting";
//
import layout from "./components/layout";
import layout from "./components/layout";
export default {
name: "app",
components: {
setting,
//
layout
layout
},
mounted() {
this.$inventory
...
...
@@ -27,7 +27,7 @@ export default {
"dashboard!name!home": {}
})
.then(detail => {
this.$store.commit("setDashboardId", detail.id);
this.$store.commit("
layout/
setDashboardId", detail.id);
});
} else {
this.$store.commit(
...
...
@@ -36,16 +36,6 @@ export default {
);
}
});
},
methods: {
// isLock: function(val) {
// this.$store.commit("setLock", detail.id);
// this.isDraggable = val.isDraggable;
// this.isResizable = val.isResizable;
// this.$message.success(
// val.isResizable && val.isDraggable ? "编辑已解锁" : "编辑已锁定"
// );
// }
}
};
</script>
...
...
src/components/gridComponent.vue
View file @
bf75c70
...
...
@@ -5,15 +5,10 @@
size="small"
shape="circle"
icon="close"
@click="close"
v-show="this.$store.state.layout.isDraggable&&this.$store.state.layout.isResizable"
></a-button>
<a-button
size="small"
shape="circle"
icon="setting"
v-show="this.$store.state.layout.isDraggable&&this.$store.state.layout.isResizable"
@click="close(index)"
v-show="this.$store.state.layout.isLock"
></a-button>
<a-button size="small" shape="circle" icon="setting" v-show="this.$store.state.layout.isLock"></a-button>
</div>
<component :is="layout.name" :isConfig="isConfig"></component>
</div>
...
...
@@ -30,12 +25,12 @@
</style>
<script>
import { mapMutations } from "vuex";
export default {
props: {
layout: Object,
index: Number,
// isDraggable: Boolean,
// isResizable: Boolean
index: Number
},
data() {
return {
...
...
@@ -43,9 +38,9 @@ export default {
};
},
methods: {
close: function()
{
this.$emit("close", this.index);
}
...mapMutations(
{
close: "layout/delLayout"
}
)
}
};
</script>
...
...
src/components/layout.vue
View file @
bf75c70
...
...
@@ -3,8 +3,8 @@
:layout.sync="this.$store.state.layout.layout"
:col-num="100"
:row-height="30"
:is-draggable="this.$store.state.layout.is
Draggable
"
:is-resizable="this.$store.state.layout.is
Resizable
"
:is-draggable="this.$store.state.layout.is
Lock
"
:is-resizable="this.$store.state.layout.is
Lock
"
:is-mirrored="false"
:vertical-compact="true"
:margin="[0, 0]"
...
...
@@ -23,7 +23,7 @@
:maxH="item.maxH"
:key="item.i"
>
<gridComponent :layout="item" :index="index"
@close="close"
/>
<gridComponent :layout="item" :index="index"/>
</grid-item>
</grid-layout>
</template>
...
...
@@ -36,11 +36,6 @@ export default {
GridLayout: VueGridLayout.GridLayout,
GridItem: VueGridLayout.GridItem,
gridComponent
},
methods:{
close:function(val){
// this.layout.splice(val,1)
}
}
};
</script>
...
...
src/components/setting.vue
View file @
bf75c70
...
...
@@ -5,19 +5,20 @@
shape="circle"
icon="plus"
@click="() => visible = true"
v-show="this.$store.state.layout.is
Draggable&&this.$store.state.layout.isResizable
"
v-show="this.$store.state.layout.is
Lock
"
></a-button>
<a-button
size="small"
shape="circle"
icon="lock"
@click="isLock
(!this.$store.state.layout.isDraggable)
"
@click="isLock"
></a-button>
<a-modal
title="添加小部件"
centered
v-model="visible"
@ok="add"
@cancel="cancel"
:destroyOnClose="true"
:maskClosable="false"
:okButtonProps="{ props: {disabled: selectItem===null?true:false} }"
...
...
@@ -48,7 +49,6 @@
<script>
import { mapMutations } from "vuex";
export default {
data() {
return {
...
...
@@ -59,9 +59,6 @@ export default {
};
},
methods: {
...mapMutations({
isLock: "setLock"
}),
filterOption(input, option) {
return (
option.componentOptions.children[0].text
...
...
@@ -78,8 +75,20 @@ export default {
}
},
add: function() {
this.$store.commit("
setLat
out", this.selectItem);
this.$store.commit("
layout/addLay
out", this.selectItem);
this.visible = false;
this.selectItem = null;
this.configSelect = null;
},
cancel: function() {
this.selectItem = null;
this.configSelect = null;
},
isLock: function() {
this.$store.commit("layout/setLock", !this.$store.state.layout.isLock);
this.$message.success(
this.$store.state.layout.isLock ? "编辑已解锁" : "编辑已锁定"
);
}
}
};
...
...
src/store/components/layout.js
View file @
bf75c70
const
state
=
{
layout
:
[],
isDraggable
:
true
,
isResizable
:
true
,
dashboardId
:
null
,
isLock
:
true
,
dashboardId
:
null
};
const
mutations
=
{
...
...
@@ -10,23 +9,25 @@ const mutations = {
state
.
dashboardId
=
id
;
},
setLock
(
state
,
value
)
{
state
.
isDraggable
=
value
;
state
.
isResizable
=
value
;
state
.
isLock
=
value
;
},
setLat
out
(
state
,
name
)
{
addLay
out
(
state
,
name
)
{
state
.
layout
.
push
({
x
:
0
,
y
:
0
,
w
:
10
,
h
:
2
,
i
:
state
.
layout
.
length
+
1
,
name
x
:
0
,
y
:
0
,
w
:
10
,
h
:
2
,
i
:
state
.
layout
.
length
+
1
,
name
});
},
delLayout
(
state
,
index
)
{
state
.
layout
.
splice
(
index
,
1
);
}
};
export
default
{
namespaced
:
true
,
state
,
mutations
,
mutations
};
...
...
src/views/index1/index.vue
View file @
bf75c70
...
...
@@ -11,11 +11,7 @@
</style>
<script>
import config from "./config";
export default {
name: "index1",
components: {
config
}
};
</script>
...
...
Please
register
or
sign in
to post a comment