diff --git a/backend/models/masterProductionOrderTodosModel.js b/backend/models/masterProductionOrderTodosModel.js index 10c70cb..77a300c 100644 --- a/backend/models/masterProductionOrderTodosModel.js +++ b/backend/models/masterProductionOrderTodosModel.js @@ -18,8 +18,9 @@ export const getMasterProductionOrderTodoById = async (id, result) => { export const updateMasterProductionOrderTodoById = async (data, result) => { try { const id = data.primaryID; - let sql = `UPDATE masterordertodos SET templateID = ?, asset = ? , task = ?, comment = ? WHERE primaryID = ?`; - const results = await ownConn.query(sql, [data.templateID, data.asset, data.task, data.comment, id]) + let sql = `UPDATE masterordertodos SET templateID = ?, asset = ? , task = ?, comments = ? WHERE primaryID = ?`; + const results = await ownConn.query(sql, [data.templateID, data.asset, data.task, data.comments, id]) + results.insertId = results.insertId.toString(); result(null, results); } catch (err) { @@ -35,6 +36,7 @@ export const deleteMasterProductionOrderTodoById = async (id, result) => { try { let sql = `DELETE FROM masterordertodos WHERE primaryID = ?`; const results = await ownConn.query(sql, [id]) + results.insertId = results.insertId.toString(); result(null, results); } catch (err) { @@ -49,6 +51,7 @@ export const deleteMasterProductionOrderTodoByTemplateId = async (id, result) => try { let sql = `DELETE FROM masterordertodos WHERE templateID = ?`; const results = await ownConn.query(sql, [id]) + results.insertId = results.insertId.toString(); result(null, results); } catch (err) { @@ -79,7 +82,8 @@ export const updateMasterProductionOrderTodos = async (data, result) => { //insert master production order todo to databased export const insertMasterProductionOrderTodo = async (data, result) => { try { - const results = await ownConn.query(`INSERT INTO masterordertodos(templateID, rowID, asset, task, comment) VALUES(?, ?, ?, ?, ?)`, [data.templateID, data.rowID, data.asset, data.task, data.comment]) + const results = await ownConn.query(`INSERT INTO masterordertodos(templateID, rowID, asset, task, comments) VALUES(?, ?, ?, ?, ?)`, [data.templateID, data.rowID, data.asset, data.task, data.comment]) + results.insertId = results.insertId.toString(); result(null, results); } catch (err) { diff --git a/backend/routes/routes.js b/backend/routes/routes.js index 959b39e..95d9644 100644 --- a/backend/routes/routes.js +++ b/backend/routes/routes.js @@ -264,8 +264,8 @@ router.put("/masterProductionOrderTodos", updateMasterProductionOrderTodo); // Delete master production order todo router.delete("/masterProductionOrderTodos/:id", deleteMasterProductionOrderTodo); -// Delete master production order todo by customer id -router.delete("/masterProductionOrderTodosByCustomerid/:id", deleteMasterProductionOrderTodoByTemplateIds); +// Delete master production order todo by template id +router.delete("/masterProductionOrderTodosByTemplateid/:id", deleteMasterProductionOrderTodoByTemplateIds); // Update all master production order todos router.put("/allMasterProductionOrderTodos", updateAllProductionOrderTodos) diff --git a/components/server/ProductionOrdersTemplate.vue b/components/server/ProductionOrdersTemplate.vue index df6ffe9..ebc5253 100644 --- a/components/server/ProductionOrdersTemplate.vue +++ b/components/server/ProductionOrdersTemplate.vue @@ -146,8 +146,12 @@ const confirmDeletePOT = async () => { store.commit('undoDelete'); store.commit('changeToTemplatelist'); } catch (err) { - // console.log(err.response.statusText); - console.log(err); + console.log(err.response.statusText); + } + try { + await Axios.delete(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/deleteTodosPOT/${chosenPOTId.value}`); + } catch (err) { + console.log(err.response.statusText); } } else { store.commit('undoDelete'); @@ -161,9 +165,7 @@ const getProductionOrderTemplates = async () => { const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllProductionOrderTemplates`); productionOrderTemplates.value = response.data; } catch (err) { - // console.log(err.response.statusText); - console.log(err); - + console.log(err.response.statusText); } } @@ -212,6 +214,8 @@ const updateCustomerID = async () => { const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getCustomerByName/${pot.value.customer}`); customer.value = response.data; pot.value.customerID = customer.value.customerID; + store.commit('toggleClientChanged'); + store.commit('toggleClientId', pot.value.customerID); } catch (err) { console.log(err.response.statusText); } @@ -237,6 +241,8 @@ const updateNewCustomerID = async () => { try { const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getCustomerByName/${newCustomer.value}`); newCustomerID.value = response.data.customerID; + store.commit('toggleClientChanged'); + store.commit('toggleClientId', newCustomerID.value) } catch (err) { console.log(err.response.statusText); } diff --git a/components/server/TemplateChecklist.vue b/components/server/TemplateChecklist.vue index 0e9bead..874ac34 100644 --- a/components/server/TemplateChecklist.vue +++ b/components/server/TemplateChecklist.vue @@ -1,5 +1,6 @@