|
@@ -1,67 +1,76 @@
|
1
|
1
|
/* eslint-disable */
|
2
|
|
-import axios from 'axios';
|
|
2
|
+import axios from 'axios'
|
3
|
3
|
|
4
|
4
|
export default {
|
5
|
|
- namespaced: true,
|
6
|
|
- state: {
|
7
|
|
- statusList: [],
|
8
|
|
- singleStatus: {}
|
9
|
|
- },
|
10
|
|
- mutations: {
|
11
|
|
- setStatusList(state, list) {
|
12
|
|
- state.statusList = list;
|
|
5
|
+ namespaced: true,
|
|
6
|
+ state: {
|
|
7
|
+ statusList: [],
|
|
8
|
+ status: {},
|
13
|
9
|
},
|
14
|
|
- addNewStatus(state, status){
|
15
|
|
- state.statusList.push(status)
|
|
10
|
+ mutations: {
|
|
11
|
+ setStatusList(state, list) {
|
|
12
|
+ state.statusList = list
|
|
13
|
+ },
|
|
14
|
+ addNewStatus(state, status) {
|
|
15
|
+ state.statusList.push(status)
|
|
16
|
+ },
|
|
17
|
+ setSingleStatus(state, status) {
|
|
18
|
+ state.status = status
|
|
19
|
+ },
|
|
20
|
+ deleteStatus(state, id) {
|
|
21
|
+ var index = state.statusList.findIndex((stat) => stat.id == id)
|
|
22
|
+ state.statusList.splice(index, 1)
|
|
23
|
+ },
|
|
24
|
+ clearStatus(state) {
|
|
25
|
+ state.status = {
|
|
26
|
+ code: '',
|
|
27
|
+ description: '',
|
|
28
|
+ }
|
|
29
|
+ },
|
16
|
30
|
},
|
17
|
|
- setSingleStatus(state, status){
|
18
|
|
- state.singleStatus = status
|
|
31
|
+ getters: {},
|
|
32
|
+ actions: {
|
|
33
|
+ getStatusList({ commit }) {
|
|
34
|
+ axios
|
|
35
|
+ .get('/api/status')
|
|
36
|
+ .then((result) => commit('setStatusList', result.data))
|
|
37
|
+ .catch(console.error)
|
|
38
|
+ },
|
|
39
|
+ async getSingleStatus({ commit }, id) {
|
|
40
|
+ await axios
|
|
41
|
+ .get('/api/status/' + id)
|
|
42
|
+ .then((result) => {
|
|
43
|
+ commit('setSingleStatus', result.data[0])
|
|
44
|
+ })
|
|
45
|
+ .catch((e) => {
|
|
46
|
+ console.log(e.response)
|
|
47
|
+ })
|
|
48
|
+ },
|
|
49
|
+ async createNewStatus({ commit }, status) {
|
|
50
|
+ await axios
|
|
51
|
+ .post('/api/status', status)
|
|
52
|
+ .then((result) => {
|
|
53
|
+ commit('addNewStatus', result.data)
|
|
54
|
+ })
|
|
55
|
+ .catch((e) => {
|
|
56
|
+ console.log(e)
|
|
57
|
+ })
|
|
58
|
+ },
|
|
59
|
+ async updateStatus({ commit }, status) {
|
|
60
|
+ await axios
|
|
61
|
+ .put('/api/status', status)
|
|
62
|
+ .then((result) => {})
|
|
63
|
+ .catch((e) => {
|
|
64
|
+ console.log(e)
|
|
65
|
+ })
|
|
66
|
+ },
|
|
67
|
+ async deleteStatus({ commit }, id) {
|
|
68
|
+ await axios.delete('/api/status/' + id).then(() => {
|
|
69
|
+ commit('deleteStatus', id)
|
|
70
|
+ })
|
|
71
|
+ },
|
|
72
|
+ clearStatus({ commit }) {
|
|
73
|
+ commit('clearStatus')
|
|
74
|
+ },
|
19
|
75
|
},
|
20
|
|
- deleteStatus(state, id){
|
21
|
|
- var index = state.statusList.findIndex((stat) => stat.id == id)
|
22
|
|
- state.statusList.splice(index, 1)
|
23
|
|
- }
|
24
|
|
- },
|
25
|
|
- getters: {},
|
26
|
|
- actions: {
|
27
|
|
- getStatusList({ commit }) {
|
28
|
|
- axios
|
29
|
|
- .get('/api/status')
|
30
|
|
- .then(result => commit('setStatusList', result.data))
|
31
|
|
- .catch(console.error);
|
32
|
|
- },
|
33
|
|
- async getSingleStatus({commit}, id){
|
34
|
|
- await axios.get('/api/status/'+ id)
|
35
|
|
- .then((result) => {
|
36
|
|
- commit("setSingleStatus", result.data[0])
|
37
|
|
- })
|
38
|
|
- .catch((e) => {
|
39
|
|
- console.log(e.response);
|
40
|
|
- })
|
41
|
|
- },
|
42
|
|
- async createNewStatus({commit}, status){
|
43
|
|
- await axios.post("/api/status", status)
|
44
|
|
- .then((result) => {
|
45
|
|
- commit("addNewStatus", result.data)
|
46
|
|
- })
|
47
|
|
- .catch((e) => {
|
48
|
|
- console.log(e);
|
49
|
|
- })
|
50
|
|
- },
|
51
|
|
- async updateStatus({commit}, status){
|
52
|
|
- await axios.put("/api/status", status)
|
53
|
|
- .then((result) => {
|
54
|
|
-
|
55
|
|
- })
|
56
|
|
- .catch((e) => {
|
57
|
|
- console.log(e);
|
58
|
|
- })
|
59
|
|
- },
|
60
|
|
- async deleteStatus({commit}, id){
|
61
|
|
- await axios.delete('/api/status/'+id)
|
62
|
|
- .then(() => {
|
63
|
|
- commit("deleteStatus", id)
|
64
|
|
- })
|
65
|
|
- }
|
66
|
|
- },
|
67
|
|
-};
|
|
76
|
+}
|