孙玉明

setting

...@@ -27,7 +27,7 @@ export default { ...@@ -27,7 +27,7 @@ export default {
27 "dashboard!name!home": {} 27 "dashboard!name!home": {}
28 }) 28 })
29 .then(detail => { 29 .then(detail => {
30 - this.$store.commit("setDashboardId", detail.id); 30 + this.$store.commit("layout/setDashboardId", detail.id);
31 }); 31 });
32 } else { 32 } else {
33 this.$store.commit( 33 this.$store.commit(
......
1 +import axios from "axios";
2 +
3 +axios.interceptors.request.use(
4 + config => {
5 + config.data = JSON.stringify(config.data);
6 + config.headers["Authorization"] =
7 + "Basic c3VueXVtaW5nL3N1bnl1bWluZzoxMjM0NTY3OA==";
8 + return config;
9 + },
10 + error => {
11 + return Promise.reject(error);
12 + }
13 +);
14 +
15 +function get(url, params = {}) {
16 + return new Promise((resolve, reject) => {
17 + axios
18 + .get(url, {
19 + params: params
20 + })
21 + .then(response => {
22 + resolve(response.data);
23 + })
24 + .catch(err => {
25 + reject(err);
26 + });
27 + });
28 +}
29 +
30 +function post(url, data = {}, config = {}) {
31 + return new Promise((resolve, reject) => {
32 + axios.post(url, data, config).then(
33 + response => {
34 + resolve(response.data);
35 + },
36 + err => {
37 + reject(err);
38 + }
39 + );
40 + });
41 +}
42 +
43 +function put(url, data = {}, config = {}) {
44 + return new Promise((resolve, reject) => {
45 + axios.put(url, data, config).then(
46 + response => {
47 + resolve(response.data);
48 + },
49 + err => {
50 + reject(err);
51 + }
52 + );
53 + });
54 +}
55 +
56 +export {
57 + get,
58 + post,
59 + put
60 +}
...\ No newline at end of file ...\ No newline at end of file
1 -import axios from "axios"; 1 +import inventory from './inventory';
2 2
3 -axios.interceptors.request.use( 3 +export { inventory };
4 - config => {
5 - config.data = JSON.stringify(config.data);
6 - config.headers["Authorization"] =
7 - "Basic c3VueXVtaW5nL3N1bnl1bWluZzpoZWxsb0AxMjM=";
8 - return config;
9 - },
10 - error => {
11 - return Promise.reject(error);
12 - }
13 -);
14 -
15 -export function get(url, params = {}) {
16 - return new Promise((resolve, reject) => {
17 - axios
18 - .get(url, {
19 - params: params
20 - })
21 - .then(response => {
22 - resolve(response.data);
23 - })
24 - .catch(err => {
25 - reject(err);
26 - });
27 - });
28 -}
29 -
30 -export function post(url, data = {}, config = {}) {
31 - return new Promise((resolve, reject) => {
32 - axios.post(url, data, config).then(
33 - response => {
34 - resolve(response.data);
35 - },
36 - err => {
37 - reject(err);
38 - }
39 - );
40 - });
41 -}
42 -
43 -export function put(url, data = {}, config = {}) {
44 - return new Promise((resolve, reject) => {
45 - axios.put(url, data, config).then(
46 - response => {
47 - resolve(response.data);
48 - },
49 - err => {
50 - reject(err);
51 - }
52 - );
53 - });
54 -}
......
1 -import { get, post, put } from "./index"; 1 +import { get, post, put } from './basic';
2 2
3 -let path = "/inventory/managedObjects"; 3 +let path = '/inventory/managedObjects';
4 -let NAMESPACE = "application/vnd.com.nsn.cumulocity."; 4 +let NAMESPACE = 'application/vnd.com.nsn.cumulocity.';
5 let config = { 5 let config = {
6 headers: { 6 headers: {
7 - "Content-Type": `${NAMESPACE}managedObject+json`, 7 + 'Content-Type': `${NAMESPACE}managedObject+json`,
8 - Accept: `${NAMESPACE}managedObject+json` 8 + Accept: `${NAMESPACE}managedObject+json`,
9 - } 9 + },
10 }; 10 };
11 11
12 function buildDetailUrl(mo) { 12 function buildDetailUrl(mo) {
...@@ -33,7 +33,7 @@ function update(mo) { ...@@ -33,7 +33,7 @@ function update(mo) {
33 let inventory = { 33 let inventory = {
34 list, 34 list,
35 create, 35 create,
36 - update 36 + update,
37 }; 37 };
38 38
39 -export { inventory }; 39 +export default inventory;
......
1 <template> 1 <template>
2 <div class="setting"> 2 <div class="setting">
3 - <a-button 3 + <a-button size="small" shape="circle" icon="plus" @click="() => visible = true" v-show="isLock"></a-button>
4 - size="small" 4 + <a-button size="small" shape="circle" :icon="isLock?'unlock':'lock'" @click="setLock()"></a-button>
5 - shape="circle"
6 - icon="plus"
7 - @click="() => visible = true"
8 - v-show="this.$store.state.layout.isDraggable&&this.$store.state.layout.isResizable"
9 - ></a-button>
10 - <a-button
11 - size="small"
12 - shape="circle"
13 - icon="lock"
14 - @click="isLock(!this.$store.state.layout.isDraggable)"
15 - ></a-button>
16 <a-modal 5 <a-modal
17 title="添加小部件" 6 title="添加小部件"
18 centered 7 centered
...@@ -37,19 +26,10 @@ ...@@ -37,19 +26,10 @@
37 </div> 26 </div>
38 </template> 27 </template>
39 28
40 -<style lang="less" scoped>
41 -.setting {
42 - position: fixed;
43 - top: 10px;
44 - right: 30px;
45 - z-index: 1;
46 -}
47 -</style>
48 -
49 -
50 <script> 29 <script>
51 -import { mapMutations } from "vuex"; 30 +import { mapState } from "vuex";
52 export default { 31 export default {
32 + computed: mapState({ isLock: state => state.layout.isLock }),
53 data() { 33 data() {
54 return { 34 return {
55 visible: false, 35 visible: false,
...@@ -59,9 +39,10 @@ export default { ...@@ -59,9 +39,10 @@ export default {
59 }; 39 };
60 }, 40 },
61 methods: { 41 methods: {
62 - ...mapMutations({ 42 + setLock() {
63 - isLock: "setLock" 43 + this.$store.commit("layout/setLock", !this.isLock);
64 - }), 44 + this.$message.success(this.isLock ? "编辑已解锁" : "编辑已锁定");
45 + },
65 filterOption(input, option) { 46 filterOption(input, option) {
66 return ( 47 return (
67 option.componentOptions.children[0].text 48 option.componentOptions.children[0].text
...@@ -78,9 +59,18 @@ export default { ...@@ -78,9 +59,18 @@ export default {
78 } 59 }
79 }, 60 },
80 add: function() { 61 add: function() {
81 - this.$store.commit("setLatout", this.selectItem); 62 + this.$store.commit("layout/setLatout", this.selectItem);
82 this.visible = false; 63 this.visible = false;
83 } 64 }
84 } 65 }
85 }; 66 };
86 </script> 67 </script>
68 +
69 +<style lang="less" scoped>
70 +.setting {
71 + position: fixed;
72 + top: 10px;
73 + right: 30px;
74 + z-index: 1;
75 +}
76 +</style>
......
...@@ -3,7 +3,7 @@ import App from './App.vue'; ...@@ -3,7 +3,7 @@ import App from './App.vue';
3 import store from './store'; 3 import store from './store';
4 import './autoImport'; 4 import './autoImport';
5 import { Modal, Button, Select, message } from 'ant-design-vue'; 5 import { Modal, Button, Select, message } from 'ant-design-vue';
6 -import { inventory } from './api/inventory'; 6 +import { inventory } from './api';
7 7
8 Vue.config.productionTip = false; 8 Vue.config.productionTip = false;
9 Vue.use(Modal); 9 Vue.use(Modal);
......
1 const state = { 1 const state = {
2 layout: [], 2 layout: [],
3 - isDraggable: true, 3 + isLock: true,
4 - isResizable: true,
5 dashboardId: null, 4 dashboardId: null,
6 }; 5 };
7 6
...@@ -10,8 +9,7 @@ const mutations = { ...@@ -10,8 +9,7 @@ const mutations = {
10 state.dashboardId = id; 9 state.dashboardId = id;
11 }, 10 },
12 setLock(state, value) { 11 setLock(state, value) {
13 - state.isDraggable = value; 12 + state.isLock = value;
14 - state.isResizable = value;
15 }, 13 },
16 setLatout(state, name) { 14 setLatout(state, name) {
17 state.layout.push({ 15 state.layout.push({
......