basic functionality pot implemented

This commit is contained in:
2024-02-27 10:31:03 +01:00
parent 3a79ed12fa
commit c327355c8a
30 changed files with 1113 additions and 189 deletions

View File

@ -30,13 +30,97 @@
</tbody>
</table>
</div>
<section v-if="addBool" id="saveNewPOT">
<button :class="[darkMode ? 'saveNewPOT-darkmode' : 'saveNewPOT-lightmode']" @click="addPOT()">Safe</button>
</section>
</template>
<script setup>
import { ref } from 'vue';
import { ref, onMounted } from 'vue';
import Axios from '../axios.config.js';
import clientsideConfig from '../../clientsideConfig.js';
import { useStore } from 'vuex';
import { computed } from 'vue';
const store = useStore();
const addBool = computed(() => store.state.new);
const newNamePOT = computed(() => store.state.newNamePOT);
const newCustomerIDPOT = computed(() => store.state.newCustomerIDPOT);
const newCustomerPOT = computed(() => store.state.newCustomerPOT);
const newLastViewPOT = computed(() => store.state.newLastViewPOT);
const newUserPOT = computed(() => store.state.newUserPOT);
const newDescriptionPOT = computed(() => store.state.newDescriptionPOT);
const newNotesPOT = computed(() => store.state.newNotesPOT);
const darkMode = ref(true)
const productionOrderTemplates = ref([]);
// add new production order template
const addPOT = async () => {
// check if all input data is valid
if (newNamePOT.value.trim() === "") {
alert("Please add a production order template name!");
return;
} else {
var counter = 0;
if (!(productionOrderTemplates.value.length == null)) {
// check if production order template name already exists
productionOrderTemplates.value.forEach(pot => {
if (pot.name === newNamePOT.value) {
counter += 1;
}
});
if (counter == 1) {
alert("This production order template name already exists. Please choose an unique production order template name or modify respectively delete the old one!");
return;
}
}
}
if (newCustomerPOT.value.length === 0) {
alert("Please choose a client!");
return;
}
try {
const response = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/addPOT`,
{
name: newNamePOT.value,
customerID: newCustomerIDPOT.value,
customer: newCustomerPOT.value,
lastView: newLastViewPOT.value,
user: newUserPOT.value,
description: newDescriptionPOT.value,
notes: newNotesPOT.value,
});
store.commit('resetStore');
store.commit('changeToTemplatelist');
} catch (err) {
console.log(err.response.statusText);
}
}
//get all production order templates
const getProductionOrderTemplates = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllProductionOrderTemplates`);
productionOrderTemplates.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
// include delay to avoid 503 error
const triggerBackendCallsWithDelay = async (fetchDataFunc) => {
setTimeout(() => {
fetchDataFunc();
}, 1000);
}
onMounted(() => {
triggerBackendCallsWithDelay(getProductionOrderTemplates);
});
</script>
<script>
@ -183,4 +267,40 @@ th {
.label-lightmode {
color: #000;
}
.saveNewPOT-darkmode {
background: #2c2c2c;
color: #fff;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
border: none;
padding: 1rem 1.875rem;
width: 8%;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.saveNewPOT-lightmode {
background: #EBEBEB;
color: #212121;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
border: none;
padding: 1rem 1.875rem;
width: 8%;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.saveNewPOT-darkmode:hover {
background-color: #444444;
cursor: pointer;
}
.saveNewPOT-lightmode:hover {
background-color: #ACACAC;
cursor: pointer;
}
#saveNewPOT {
text-align: center;
}
</style>