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
孙玉明
2019-07-01 18:17:34 +0800
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
e879c330b4bc8994e6d9be75509788c8bfd0ad48
e879c330
1 parent
91262a40
添加新建时支持输入宽高,修复model关闭报错bug
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
25 deletions
src/components/AddGrid.vue
src/components/setting.vue
src/main.js
src/store/components/layout.js
src/components/AddGrid.vue
View file @
e879c33
...
...
@@ -2,13 +2,17 @@
<a-modal
title="添加小部件"
centered
v-model
="this.visible"
:visible
="this.visible"
@ok="add"
@cancel="cancel"
:destroyOnClose="true"
:maskClosable="false"
:afterClose="afterClose"
:okButtonProps="{ props: {disabled: selectItem===null?true:false} }"
>
宽度:
<a-input-number :min="1" :max="100" v-model="width" />高度:
<a-input-number :min="1" v-model="height" />选择小部件:
<a-select
showSearch
placeholder="搜索小部件"
...
...
@@ -32,7 +36,9 @@ export default {
return {
list: window.componentList,
selectItem: null,
configSelect: null
configSelect: null,
width: 10,
height: 1
};
},
methods: {
...
...
@@ -51,19 +57,26 @@ export default {
this.configSelect = value;
}
},
afterClose: function() {
this.selectItem = null;
this.configSelect = null;
this.width = 10;
this.height = 1;
},
add: function() {
if (!this.isUpdate) {
this.$store.commit("layout/setUpdate", true);
}
this.$store.commit("layout/addLayout", this.selectItem);
this.selectItem = null;
this.configSelect = null;
this.$emit('closeAddGrid');
this.$store.commit("layout/addLayout", {
name: this.selectItem,
width: this.width,
height: this.height
});
this.$emit("closeAddGrid");
},
cancel: function() {
this.selectItem = null;
this.configSelect = null;
this.$emit('closeAddGrid');
this.$emit("closeAddGrid");
}
}
};
...
...
src/components/setting.vue
View file @
e879c33
...
...
@@ -8,8 +8,8 @@
@click="() => visible = true"
v-if="isLock"
></a-button>
<a-button size="small" shape="circle" :icon="isLock?'unlock':'lock'" @click="setLock
()
"></a-button>
<add-grid :visible="visible" @closeAddGrid="setVisible
()
"/>
<a-button size="small" shape="circle" :icon="isLock?'unlock':'lock'" @click="setLock"></a-button>
<add-grid :visible="visible" @closeAddGrid="setVisible"/>
</div>
</template>
...
...
src/main.js
View file @
e879c33
import
Vue
from
'vue'
;
import
App
from
'./App.vue'
;
import
store
from
'./store'
;
import
'./autoImport'
;
import
{
Modal
,
Button
,
Select
,
message
}
from
'ant-design-vue'
;
import
{
inventory
}
from
'./api'
;
import
Vue
from
"vue"
;
import
App
from
"./App.vue"
;
import
store
from
"./store"
;
import
"./autoImport"
;
import
{
Modal
,
Button
,
Select
,
message
,
InputNumber
}
from
"ant-design-vue"
;
import
{
inventory
}
from
"./api"
;
Vue
.
config
.
productionTip
=
false
;
Vue
.
use
(
Modal
);
Vue
.
use
(
Button
);
Vue
.
use
(
Select
);
Vue
.
use
(
InputNumber
);
Vue
.
prototype
.
$message
=
message
;
Vue
.
prototype
.
$inventory
=
inventory
;
new
Vue
({
el
:
'#app'
,
el
:
"#app"
,
store
,
render
:
(
h
)
=>
h
(
App
),
render
:
h
=>
h
(
App
)
});
...
...
src/store/components/layout.js
View file @
e879c33
...
...
@@ -2,7 +2,7 @@ const state = {
layout
:
[],
isLock
:
true
,
dashboardId
:
null
,
isUpdate
:
false
,
isUpdate
:
false
};
const
mutations
=
{
...
...
@@ -15,14 +15,14 @@ const mutations = {
setUpdate
(
state
,
value
)
{
state
.
isUpdate
=
value
;
},
addLayout
(
state
,
name
)
{
addLayout
(
state
,
obj
)
{
state
.
layout
.
push
({
x
:
0
,
y
:
0
,
w
:
10
,
h
:
2
,
w
:
obj
.
width
,
h
:
obj
.
height
,
i
:
state
.
layout
.
length
+
1
,
name
,
name
:
obj
.
name
});
},
updateLayout
(
state
,
array
)
{
...
...
@@ -30,7 +30,7 @@ const mutations = {
},
removeLayout
(
state
,
index
)
{
state
.
layout
.
splice
(
index
,
1
);
}
,
}
};
export
default
{
...
...
Please
register
or
sign in
to post a comment