Lines 32-47
import LeftMenu from "../LeftMenu.vue";
Link Here
|
32 |
import Dialog from "../Dialog.vue"; |
32 |
import Dialog from "../Dialog.vue"; |
33 |
import "vue-select/dist/vue-select.css"; |
33 |
import "vue-select/dist/vue-select.css"; |
34 |
import { storeToRefs } from "pinia"; |
34 |
import { storeToRefs } from "pinia"; |
35 |
import { APIClient } from "../../fetch/api-client"; |
|
|
36 |
|
35 |
|
37 |
export default { |
36 |
export default { |
38 |
setup() { |
37 |
setup() { |
39 |
const vendorStore = inject("vendorStore"); |
38 |
const vendorStore = inject("vendorStore"); |
40 |
const { config } = storeToRefs(vendorStore); |
39 |
const { config, authorisedValues } = storeToRefs(vendorStore); |
|
|
40 |
const { loadAuthorisedValues } = vendorStore; |
41 |
|
41 |
|
42 |
const mainStore = inject("mainStore"); |
42 |
const mainStore = inject("mainStore"); |
43 |
const { loading, loaded, setError } = mainStore; |
43 |
const { loading, loaded, setError } = mainStore; |
44 |
const AVStore = inject("AVStore"); |
|
|
45 |
|
44 |
|
46 |
const permissionsStore = inject("permissionsStore"); |
45 |
const permissionsStore = inject("permissionsStore"); |
47 |
const { userPermissions } = storeToRefs(permissionsStore); |
46 |
const { userPermissions } = storeToRefs(permissionsStore); |
Lines 52-112
export default {
Link Here
|
52 |
loading, |
51 |
loading, |
53 |
loaded, |
52 |
loaded, |
54 |
userPermissions, |
53 |
userPermissions, |
55 |
AVStore, |
|
|
56 |
config, |
54 |
config, |
|
|
55 |
loadAuthorisedValues, |
56 |
authorisedValues, |
57 |
}; |
57 |
}; |
58 |
}, |
58 |
}, |
59 |
beforeCreate() { |
59 |
beforeCreate() { |
60 |
this.loading(); |
60 |
this.loading(); |
61 |
|
61 |
|
62 |
const fetchConfig = () => { |
62 |
this.loadAuthorisedValues(this.authorisedValues, this.vendorStore).then( |
63 |
let promises = []; |
63 |
() => { |
64 |
|
64 |
this.userPermissions = userPermissions; |
65 |
const av_client = APIClient.authorised_values; |
65 |
this.config.settings.edifact = edifact; |
66 |
const authorised_values = { |
66 |
this.config.settings.marcOrderAutomation = marcOrderAutomation; |
67 |
av_vendor_types: "VENDOR_TYPE", |
67 |
this.vendorStore.currencies = currencies; |
68 |
av_vendor_interface_types: "VENDOR_INTERFACE_TYPE", |
68 |
this.vendorStore.gstValues = gstValues.map(gv => { |
69 |
}; |
69 |
return { |
70 |
|
70 |
label: `${Number(gv.option * 100).format_price()}%`, |
71 |
let av_cat_array = Object.keys(authorised_values).map( |
71 |
value: gv.option, |
72 |
function (av_cat) { |
72 |
}; |
73 |
return '"' + authorised_values[av_cat] + '"'; |
73 |
}); |
74 |
} |
74 |
this.loaded(); |
75 |
); |
75 |
this.initialized = true; |
76 |
|
76 |
} |
77 |
promises.push( |
77 |
); |
78 |
av_client.values |
|
|
79 |
.getCategoriesWithValues(av_cat_array) |
80 |
.then(av_categories => { |
81 |
Object.entries(authorised_values).forEach( |
82 |
([av_var, av_cat]) => { |
83 |
const av_match = av_categories.find( |
84 |
element => element.category_name == av_cat |
85 |
); |
86 |
this.AVStore[av_var] = |
87 |
av_match.authorised_values; |
88 |
} |
89 |
); |
90 |
}) |
91 |
); |
92 |
|
93 |
return Promise.all(promises); |
94 |
}; |
95 |
|
96 |
fetchConfig().then(() => { |
97 |
this.loaded(); |
98 |
this.userPermissions = userPermissions; |
99 |
this.config.settings.edifact = edifact; |
100 |
this.config.settings.marcOrderAutomation = marcOrderAutomation; |
101 |
this.vendorStore.currencies = currencies; |
102 |
this.vendorStore.gstValues = gstValues.map(gv => { |
103 |
return { |
104 |
label: `${Number(gv.option * 100).format_price()}%`, |
105 |
value: gv.option, |
106 |
}; |
107 |
}); |
108 |
this.initialized = true; |
109 |
}); |
110 |
}, |
78 |
}, |
111 |
data() { |
79 |
data() { |
112 |
return { |
80 |
return { |