diff --git a/Step/wwwroot/src/@types/tooling.d.ts b/Step/wwwroot/src/@types/tooling.d.ts index 02625e44..6fd773f0 100644 --- a/Step/wwwroot/src/@types/tooling.d.ts +++ b/Step/wwwroot/src/@types/tooling.d.ts @@ -87,7 +87,11 @@ declare module server { } export interface EdgesData { - + id: number, + residualLife: number, + nominalLife: number, + preAlmLife: number, + edgeAdditionalParams: Object } export interface Families { diff --git a/Step/wwwroot/src/components/tooling-equipment.ts b/Step/wwwroot/src/components/tooling-equipment.ts index 12e4e707..9d075fc1 100644 --- a/Step/wwwroot/src/components/tooling-equipment.ts +++ b/Step/wwwroot/src/components/tooling-equipment.ts @@ -12,7 +12,7 @@ export default class toolingEquipment extends Vue { public toolsConfiguration: server.ToolsConfiguration[] = null; - public get edgeConfiguration(): server.EdgeConfiguration[] { return (this.$store.state as AppModel).tooling.edgesConfiguration; } + public edgeConfiguration: server.EdgeConfiguration[] = null; public selectedTool: any = null; public selectedEquipment: any = null; @@ -45,6 +45,7 @@ export default class toolingEquipment extends Vue { await new ToolingService().GetEdgeAdditionalParamsConfiguration(); this.toolsConfiguration = (this.$store.state as AppModel).tooling.toolsConfiguration; + this.edgeConfiguration = (this.$store.state as AppModel).tooling.edgesConfiguration; } public selectTool(item){ @@ -78,6 +79,7 @@ export default class toolingEquipment extends Vue { } else if (elem){ this.selectedEquipment = elem; + console.log(this.selectedEquipment); this.enableEquipment = true; this.enableParameters = false; } @@ -103,20 +105,25 @@ export default class toolingEquipment extends Vue { private internalCounter = -1; public addEdge(){ - debugger; + debugger + this.edgeConfiguration = []; var obj = { edgeAdditionalParams:{}}; - for (const key in this.edgeConfiguration) { - const element = this.edgeConfiguration[key]; - obj[element.name] = null; + for (const key in (this.$store.state as AppModel).tooling.edgesConfiguration) { + const element = (this.$store.state as AppModel).tooling.edgesConfiguration[key]; + if (!element.readOnly) { + this.edgeConfiguration.push(element); + } + obj[element.name] = 0; } let fields = this.getDynamicFields(this.selectedTool.toolType); for (const key in fields) { const element = fields[key]; - obj.edgeAdditionalParams[element] = null; + obj.edgeAdditionalParams[element] = 0; } obj["id"] = this.internalCounter--; this.selectedTool.edgesData.push(obj); + console.log(this.selectedTool.edgesData); } async save(item) { @@ -126,13 +133,64 @@ export default class toolingEquipment extends Vue { htmlelement.scrollTop = htmlelement.scrollHeight; this.toolsConfiguration = (this.$store.state as AppModel).tooling.toolsConfiguration; + this.edgeConfiguration = (this.$store.state as AppModel).tooling.edgesConfiguration; }); } async modify(model) { - debugger new ToolingService().UpdateSiemensTool(model).then(response => { this.toolsConfiguration = (this.$store.state as AppModel).tooling.toolsConfiguration; + this.edgeConfiguration = (this.$store.state as AppModel).tooling.edgesConfiguration; + }); + } + + async saveEdge(tool, model){ + debugger + delete model.id; + new ToolingService().SetEdgeData(tool,model).then(response => { + this.selectedEquipment = response; + + this.toolsConfiguration = (this.$store.state as AppModel).tooling.toolsConfiguration; + this.edgeConfiguration = (this.$store.state as AppModel).tooling.edgesConfiguration; + }); + } + + async modifyEdge(tool, model){ + debugger + new ToolingService().UpdateEdgeData(tool,model).then(response => { + this.toolsConfiguration = (this.$store.state as AppModel).tooling.toolsConfiguration; + this.edgeConfiguration = (this.$store.state as AppModel).tooling.edgesConfiguration; + }); + } + + async buttonSave(tool: any, edge: any){ + debugger + if(tool.id){ + if(edge.id >= 0){ + this.modifyEdge(tool, edge); + } + else if (edge.id == -1){ + this.saveEdge(tool, edge); + } + else{ + this.modify(tool); + } + } + else{ + this.save(tool); + } + } + + async deleteTool(model) { + new ToolingService().DeleteTool(model).then(response => { + this.selectedTool = null; + }); + } + + async deleteEdgeData(tool, model){ + debugger + new ToolingService().DeleteEdgeData(tool, model).then(response => { + this.selectedTool = null; }); } diff --git a/Step/wwwroot/src/components/tooling-equipment.vue b/Step/wwwroot/src/components/tooling-equipment.vue index b24c8789..f63fa691 100644 --- a/Step/wwwroot/src/components/tooling-equipment.vue +++ b/Step/wwwroot/src/components/tooling-equipment.vue @@ -34,11 +34,11 @@
- +
- +
Modifica di {{selectedTool.id}} {{selectedTool.familyName}}
@@ -54,14 +54,14 @@
- +
{{'tooling_edgesdata_skill_tools' | localize("Tagliente")}} {{(selectedEquipment.id > 0 ? selectedEquipment.id : "")}}
-
-
{{'tooling_equipment_list_category_' + c | localize(c)}}
+
+
{{'tooling_equipment_list_category_' + ce | localize(ce)}}
@@ -83,7 +83,7 @@
diff --git a/Step/wwwroot/src/services/toolingService.ts b/Step/wwwroot/src/services/toolingService.ts index 43d9a636..67a17357 100644 --- a/Step/wwwroot/src/services/toolingService.ts +++ b/Step/wwwroot/src/services/toolingService.ts @@ -122,14 +122,34 @@ export class ToolingService extends baseRestService { return response; } async UpdateSiemensTool(model: any){ - debugger var response = await this.Put("/api/tool_table/siemens/tool/" + model.id, model); // debo salvare il modello perchè le families non hanno ID e quindi devo utilizzare il vecchio ID che mi genero lato client. toolingActions.updateTool(store, model); return response; } - async DeleteTool(id: any) { - await this.Delete("/api/tool_table/tool/" + id); + async DeleteTool(model: any) { + debugger + var result = await this.Delete("/api/tool_table/tool/" + model.id); + toolingActions.deleteTool(store, model); + return result; + } + async SetEdgeData(tool: any,model: any){ + debugger + var result = await this.Post("/api/tool_table/tool/" + tool.id + "/edge", model); + toolingActions.updateEdgeData(store, result); + return result; + } + async UpdateEdgeData(tool: any, model: any){ + debugger + var result = await this.Put("/api/tool_table/tool/"+ tool.id + "/edge/" + model.id, model); + toolingActions.updateEdgeData(store, model); + return result; + } + async DeleteEdgeData(tool: any, model: any){ + debugger + var result = await this.Delete("/api/tool_table/tool/" + tool.id + "/edge/" + model.id); + toolingActions.deleteEdgeData(store, model); + return result; } async DeleteFamily(model: any) { var result = await this.Delete("/api/tool_table/family/" + model.oldName); diff --git a/Step/wwwroot/src/store/tooling.store.ts b/Step/wwwroot/src/store/tooling.store.ts index b5ece572..16be52ec 100644 --- a/Step/wwwroot/src/store/tooling.store.ts +++ b/Step/wwwroot/src/store/tooling.store.ts @@ -14,6 +14,7 @@ export interface ToolingStoreModel { magazinePosConfiguration: Array edgesConfiguration: Array edgesAdditionalParamsConfiguration: Map> + edgesData: Array } export interface ToolingActions { @@ -43,9 +44,12 @@ export interface ToolingActions { updateEdgeConfiguration(context, model: server.EdgeConfiguration); updateEdgeConfigurations(context, model: server.EdgeConfiguration[]); updateEdgeAdditionalParamsConfiguration(context, model: Map>); + updateEdgeData(context, model: server.EdgesData); deleteFamily(context, familyName: string); deleteShank(context, model: server.Shanks); + deleteTool(context, model: server.Tool); + deleteEdgeData(context, model: server.EdgesData); } export const toolingStore = { @@ -74,7 +78,8 @@ export const toolingStore = { edgesConfiguration: [], _edgesConfiguration: new Map(), edgesAdditionalParamsConfiguration: null, - test: 0 + edgesData: [], + _edgesData: new Map() } as ToolingStoreModel, mutations: { UpdateMagazine(store, model: server.MagazineModel[]) { @@ -83,10 +88,13 @@ export const toolingStore = { } }, UpdateTool(store, model: server.Tool) { - debugger store._tools.set(model.id, model); store.tools = Array.from(store._tools.values()); }, + UpdateEdgeData(store, model: server.EdgesData){ + store._edgesData.set(model.id, model); + store.edgesData = Array.from(store._edgesData.values()); + }, UpdateFamily(store, model: any) { if (!model.uid) model.uid = UUID("-"); @@ -144,6 +152,15 @@ export const toolingStore = { store._shanks.delete(model.id); store.shanks = Array.from(store._shanks.values()); }, + DeleteTool(store, model: server.Tool) { + debugger + store._tools.delete(model.id); + store.tools = Array.from(store._tools.values()); + }, + DeleteEdgeData(store, model: server.EdgesData){ + store._edgesData.delete(model.id); + store.edgesData = Array.from(store._edgesData.values()); + } }, actions: { deleteFamily(context, familyname: string) { @@ -152,6 +169,12 @@ export const toolingStore = { deleteShank(context, model: server.Shanks) { context.commit("DeleteShank", model); }, + deleteTool(context, model: server.Tool){ + context.commit("DeleteTool", model); + }, + deleteEdgeData(context, model: server.EdgesData){ + context.commit("DeleteEdgeData", model); + }, modifyFamily(context, { oldName, model }) { context.commit("ModifyFamily", { oldName, model }); }, @@ -161,6 +184,9 @@ export const toolingStore = { modifyMagPos(context, model: server.MagazinesPositions) { context.commit("ModifyMagPos", model); }, + updateEdgeData(context, model: server.EdgesData){ + context.commit("UpdateEdgeData", model); + }, updateMagazine(context, model: server.MagazineModel[]) { context.commit("UpdateMagazine", model); },