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-04-26 17:32:44 +0800
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
c3abc6220af7adf2c6a16bfdda949bfff6f9346d
c3abc622
1 parent
1c6a287b
setting
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
95 deletions
src/App.vue
src/api/basic.js
src/api/index.js
src/api/inventory.js
src/components/setting.vue
src/main.js
src/store/components/layout.js
src/App.vue
View file @
c3abc62
...
...
@@ -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(
...
...
src/api/basic.js
0 → 100644
View file @
c3abc62
import
axios
from
"axios"
;
axios
.
interceptors
.
request
.
use
(
config
=>
{
config
.
data
=
JSON
.
stringify
(
config
.
data
);
config
.
headers
[
"Authorization"
]
=
"Basic c3VueXVtaW5nL3N1bnl1bWluZzoxMjM0NTY3OA=="
;
return
config
;
},
error
=>
{
return
Promise
.
reject
(
error
);
}
);
function
get
(
url
,
params
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
get
(
url
,
{
params
:
params
})
.
then
(
response
=>
{
resolve
(
response
.
data
);
})
.
catch
(
err
=>
{
reject
(
err
);
});
});
}
function
post
(
url
,
data
=
{},
config
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
post
(
url
,
data
,
config
).
then
(
response
=>
{
resolve
(
response
.
data
);
},
err
=>
{
reject
(
err
);
}
);
});
}
function
put
(
url
,
data
=
{},
config
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
put
(
url
,
data
,
config
).
then
(
response
=>
{
resolve
(
response
.
data
);
},
err
=>
{
reject
(
err
);
}
);
});
}
export
{
get
,
post
,
put
}
\ No newline at end of file
src/api/index.js
View file @
c3abc62
import
axios
from
"axios"
;
import
inventory
from
'./inventory'
;
axios
.
interceptors
.
request
.
use
(
config
=>
{
config
.
data
=
JSON
.
stringify
(
config
.
data
);
config
.
headers
[
"Authorization"
]
=
"Basic c3VueXVtaW5nL3N1bnl1bWluZzpoZWxsb0AxMjM="
;
return
config
;
},
error
=>
{
return
Promise
.
reject
(
error
);
}
);
export
function
get
(
url
,
params
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
get
(
url
,
{
params
:
params
})
.
then
(
response
=>
{
resolve
(
response
.
data
);
})
.
catch
(
err
=>
{
reject
(
err
);
});
});
}
export
function
post
(
url
,
data
=
{},
config
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
post
(
url
,
data
,
config
).
then
(
response
=>
{
resolve
(
response
.
data
);
},
err
=>
{
reject
(
err
);
}
);
});
}
export
function
put
(
url
,
data
=
{},
config
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
put
(
url
,
data
,
config
).
then
(
response
=>
{
resolve
(
response
.
data
);
},
err
=>
{
reject
(
err
);
}
);
});
}
export
{
inventory
};
...
...
src/api/inventory.js
View file @
c3abc62
import
{
get
,
post
,
put
}
from
"./index"
;
import
{
get
,
post
,
put
}
from
'./basic'
;
let
path
=
"/inventory/managedObjects"
;
let
NAMESPACE
=
"application/vnd.com.nsn.cumulocity."
;
let
path
=
'/inventory/managedObjects'
;
let
NAMESPACE
=
'application/vnd.com.nsn.cumulocity.'
;
let
config
=
{
headers
:
{
"Content-Type"
:
`
${
NAMESPACE
}
managedObject+json`
,
Accept
:
`
${
NAMESPACE
}
managedObject+json`
}
'Content-Type'
:
`
${
NAMESPACE
}
managedObject+json`
,
Accept
:
`
${
NAMESPACE
}
managedObject+json`
,
}
,
};
function
buildDetailUrl
(
mo
)
{
...
...
@@ -33,7 +33,7 @@ function update(mo) {
let
inventory
=
{
list
,
create
,
update
update
,
};
export
{
inventory
}
;
export
default
inventory
;
...
...
src/components/setting.vue
View file @
c3abc62
<template>
<div class="setting">
<a-button
size="small"
shape="circle"
icon="plus"
@click="() => visible = true"
v-show="this.$store.state.layout.isDraggable&&this.$store.state.layout.isResizable"
></a-button>
<a-button
size="small"
shape="circle"
icon="lock"
@click="isLock(!this.$store.state.layout.isDraggable)"
></a-button>
<a-button size="small" shape="circle" icon="plus" @click="() => visible = true" v-show="isLock"></a-button>
<a-button size="small" shape="circle" :icon="isLock?'unlock':'lock'" @click="setLock()"></a-button>
<a-modal
title="添加小部件"
centered
...
...
@@ -37,19 +26,10 @@
</div>
</template>
<style lang="less" scoped>
.setting {
position: fixed;
top: 10px;
right: 30px;
z-index: 1;
}
</style>
<script>
import { map
Mutations
} from "vuex";
import { map
State
} from "vuex";
export default {
computed: mapState({ isLock: state => state.layout.isLock }),
data() {
return {
visible: false,
...
...
@@ -59,9 +39,10 @@ export default {
};
},
methods: {
...mapMutations({
isLock: "setLock"
}),
setLock() {
this.$store.commit("layout/setLock", !this.isLock);
this.$message.success(this.isLock ? "编辑已解锁" : "编辑已锁定");
},
filterOption(input, option) {
return (
option.componentOptions.children[0].text
...
...
@@ -78,9 +59,18 @@ export default {
}
},
add: function() {
this.$store.commit("setLatout", this.selectItem);
this.$store.commit("
layout/
setLatout", this.selectItem);
this.visible = false;
}
}
};
</script>
<style lang="less" scoped>
.setting {
position: fixed;
top: 10px;
right: 30px;
z-index: 1;
}
</style>
...
...
src/main.js
View file @
c3abc62
...
...
@@ -3,7 +3,7 @@ import App from './App.vue';
import
store
from
'./store'
;
import
'./autoImport'
;
import
{
Modal
,
Button
,
Select
,
message
}
from
'ant-design-vue'
;
import
{
inventory
}
from
'./api
/inventory
'
;
import
{
inventory
}
from
'./api'
;
Vue
.
config
.
productionTip
=
false
;
Vue
.
use
(
Modal
);
...
...
src/store/components/layout.js
View file @
c3abc62
const
state
=
{
layout
:
[],
isDraggable
:
true
,
isResizable
:
true
,
isLock
:
true
,
dashboardId
:
null
,
};
...
...
@@ -10,8 +9,7 @@ const mutations = {
state
.
dashboardId
=
id
;
},
setLock
(
state
,
value
)
{
state
.
isDraggable
=
value
;
state
.
isResizable
=
value
;
state
.
isLock
=
value
;
},
setLatout
(
state
,
name
)
{
state
.
layout
.
push
({
...
...
Please
register
or
sign in
to post a comment