Fix tooltable
Frontend - Removed useless delete buttons & bug fix Backend - fix shanks delete
This commit is contained in:
Binary file not shown.
@@ -136,6 +136,16 @@ namespace Step.Database.Controllers
|
||||
return shank;
|
||||
}
|
||||
|
||||
public List<DbNcShankModel> FindShanksByFamilyId(int familyId)
|
||||
{
|
||||
return dbCtx
|
||||
.Tools
|
||||
.Include("Shank")
|
||||
.Where(x => x.FamilyId == familyId && x.ShankId != null)
|
||||
.Select(x => x.Shank)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<DTONcShankModel> GetShanks()
|
||||
{
|
||||
// Get shank from database
|
||||
|
||||
@@ -230,6 +230,7 @@ namespace Step.Model
|
||||
public const string MAGAZINE_POSITION_OCCUPIED = "error_magazine_position_occupied";
|
||||
public const string TOOL_IS_MOUNTED = "error_tool_mounted";
|
||||
public const string OPTION_NOT_ACTIVE = "error_option_not_active";
|
||||
public const string MAG_POS_DISABLED = "error_mag_pos_disabled";
|
||||
}
|
||||
|
||||
// File paths
|
||||
|
||||
+16
-6
@@ -1488,7 +1488,7 @@ namespace Step.NC
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
if (NcConfig.NcVendor != NC_VENDOR.SIEMENS && NcConfig.NcVendor != NC_VENDOR.DEMO)
|
||||
if (NcConfig.NcVendor != NC_VENDOR.SIEMENS)
|
||||
{
|
||||
config.FamilyOptionActive = true;
|
||||
config.MultitoolOptionActive = true;
|
||||
@@ -1550,8 +1550,13 @@ namespace Step.NC
|
||||
if (!ToolManagerConfig.ReviveOpt)
|
||||
categories.Add("revive");
|
||||
|
||||
config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !categories.Contains(x.Category)).ToList();
|
||||
config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !categories.Contains(x.Category)).ToList();
|
||||
|
||||
// Remove categories from familyConfig
|
||||
config.FamiliesConfiguration.FamilyConfiguration = config.FamiliesConfiguration.FamilyConfiguration.Where(x => !categories.Contains(x.Category)).ToList();
|
||||
// Filter by SUBCATEGORIES because "ReadOnlyFamily" categories are not populated
|
||||
config.FamiliesConfiguration.FamilyReadOnlyConfiguration = config.FamiliesConfiguration.FamilyReadOnlyConfiguration.Where(x => !categories.Contains(x.SubCategory)).ToList();
|
||||
|
||||
config.ShanksConfiguration.ShankConfiguration = config.ShanksConfiguration.ShankConfiguration.Where(x => !categories.Contains(x.Category)).ToList();
|
||||
config.MagazinePosConfiguration = config.MagazinePosConfiguration.Where(x => !categories.Contains(x.Category)).ToList();
|
||||
}
|
||||
@@ -2116,15 +2121,20 @@ namespace Step.NC
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
toolsManager.DeleteFamily(famId);
|
||||
|
||||
// Check if shank opt is disabled
|
||||
if (!ToolManagerConfig.ShankOpt)
|
||||
{
|
||||
// If the relationship is 1:1 (fam:shank) remove shank
|
||||
// If the relationship is 1:1 (tool:shank) i have to remove shanks manually
|
||||
// Tools are deleted thanks to foreign keys constraint
|
||||
toolsManager.DeleteNcShank(famId);
|
||||
List<DbNcShankModel> shanks = toolsManager.FindShanksByFamilyId(famId);
|
||||
foreach(var shank in shanks)
|
||||
{
|
||||
if (shank != null)
|
||||
toolsManager.DeleteNcShank(shank.ShankId);
|
||||
}
|
||||
}
|
||||
|
||||
toolsManager.DeleteFamily(famId);
|
||||
|
||||
// Update Nc families
|
||||
cmsError = UpdateNcFamily(toolsManager);
|
||||
|
||||
@@ -12,6 +12,8 @@ using System.Linq;
|
||||
using System.Web.Http;
|
||||
using static Step.Config.ServerConfig;
|
||||
using static Step.Model.Constants;
|
||||
using static Step.Listeners.SignalRStaticObjects;
|
||||
using Step.Model.DTOModels;
|
||||
|
||||
namespace Step.Controllers.WebApi
|
||||
{
|
||||
@@ -81,6 +83,12 @@ namespace Step.Controllers.WebApi
|
||||
DbNcFamilyModel fam = toolsManager.FindFamily(dtoToolWithFamily.FamilyId);
|
||||
if (fam == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
// Update return data
|
||||
if (ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
dtoToolWithFamily.Name = fam.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -145,6 +153,10 @@ namespace Step.Controllers.WebApi
|
||||
if (tool == null)
|
||||
return NotFound();
|
||||
|
||||
// Check if tool is mounted in spindle
|
||||
if (ToolIsInSpindle(toolId))
|
||||
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
|
||||
|
||||
if (tool.FamilyId != dtoToolWithFamily.FamilyId)
|
||||
{
|
||||
// Check if family exists
|
||||
@@ -204,6 +216,10 @@ namespace Step.Controllers.WebApi
|
||||
if (tool == null)
|
||||
return NotFound();
|
||||
|
||||
// Check if tool is mounted in spindle
|
||||
if (ToolIsInSpindle(toolId))
|
||||
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
@@ -296,6 +312,13 @@ namespace Step.Controllers.WebApi
|
||||
if (shank == null)
|
||||
return NotFound();
|
||||
|
||||
// Check if tools are mounted in spindle
|
||||
foreach (var tool in shank.Tools)
|
||||
{
|
||||
if (ToolIsInSpindle(tool.ToolId))
|
||||
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
@@ -322,6 +345,13 @@ namespace Step.Controllers.WebApi
|
||||
if (shank == null)
|
||||
return NotFound();
|
||||
|
||||
// Check if tools are mounted in spindle
|
||||
foreach (var tool in shank.Tools)
|
||||
{
|
||||
if (ToolIsInSpindle(tool.ToolId))
|
||||
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
@@ -383,6 +413,13 @@ namespace Step.Controllers.WebApi
|
||||
if (family == null)
|
||||
return NotFound();
|
||||
|
||||
// Check if tools are mounted in spindle
|
||||
foreach (var tool in family.Tools)
|
||||
{
|
||||
if (ToolIsInSpindle(tool.ToolId))
|
||||
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
@@ -409,6 +446,13 @@ namespace Step.Controllers.WebApi
|
||||
if (family == null)
|
||||
return NotFound();
|
||||
|
||||
// Check if tools are mounted in spindle
|
||||
foreach (var tool in family.Tools)
|
||||
{
|
||||
if (ToolIsInSpindle(tool.ToolId))
|
||||
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
@@ -547,7 +591,7 @@ namespace Step.Controllers.WebApi
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
// Check if the mag pos is disabled
|
||||
if (magPos.Disabled == true)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
return BadRequest(API_ERROR_KEYS.MAG_POS_DISABLED);
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
@@ -597,13 +641,20 @@ namespace Step.Controllers.WebApi
|
||||
if (shank == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
// Check if tools are mounted in spindle
|
||||
foreach (var tool in shank.Tools)
|
||||
{
|
||||
if (ToolIsInSpindle(tool.ToolId))
|
||||
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
|
||||
}
|
||||
|
||||
// Check if magazine position exists
|
||||
DbNcMagazinePositionModel magPos = toolsManager.FindMagazinePosition(magazineId, positionId);
|
||||
if (magPos == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
// Check if the mag pos is disabled
|
||||
if (magPos.Disabled == true)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
//// Check if the mag pos is disabled
|
||||
//if (magPos.Disabled == true)
|
||||
// return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
// Check if magazine position is not occupied
|
||||
DbNcShankModel shankMounted = toolsManager.FindShanksByPositions(magazineId, positionId);
|
||||
@@ -706,5 +757,21 @@ namespace Step.Controllers.WebApi
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool ToolIsInSpindle(int toolId)
|
||||
{
|
||||
foreach(var head in LastHeadsData.ToList())
|
||||
{
|
||||
if(head is DTOSpindleModel)
|
||||
{
|
||||
var spindle = head as DTOSpindleModel;
|
||||
if (spindle.MountedTool == toolId)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,7 +414,7 @@ export default class depot extends Vue {
|
||||
let error = false
|
||||
// Check if one of the childs is in error
|
||||
shank.childsTools.forEach(tool => {
|
||||
if(this.familyLifeFromId(tool.familyId) && tool.residualLife){
|
||||
if(this.familyLifeFromId(tool.familyId) && tool.residualLife <= 0){
|
||||
error = true
|
||||
}
|
||||
if(tool.disabled || tool.broken){
|
||||
|
||||
@@ -141,6 +141,7 @@ export default class toolingEquipment extends Vue {
|
||||
|
||||
public offsetSelected: any = null;
|
||||
public posSelected: any = null;
|
||||
public toolIsInSpindle: boolean = false
|
||||
|
||||
public maxToolsSiemens(){
|
||||
if (this.tools.length < this.maxTools) {
|
||||
@@ -161,6 +162,7 @@ export default class toolingEquipment extends Vue {
|
||||
}
|
||||
|
||||
async mounted() {
|
||||
console.log("entro nel mount")
|
||||
this.modalBlockMagazine();
|
||||
if(this.isSiemens){
|
||||
awaiter (Promise.all([
|
||||
@@ -176,14 +178,15 @@ export default class toolingEquipment extends Vue {
|
||||
await new ToolingService().GetToolsConfiguration()
|
||||
]));
|
||||
|
||||
this.populateMountedToolsInSplindle()
|
||||
console.log(this.ncTools)
|
||||
|
||||
this.checkIfToolIsMountedInSpindle()
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.toolsConfiguration = (this.$store.state as AppModel).tooling.toolsConfiguration;
|
||||
this.edgeConfiguration = (this.$store.state as AppModel).tooling.edgesConfiguration;
|
||||
let arrayIdFamily = [];
|
||||
|
||||
if(this.isSiemens){
|
||||
await this.maxToolsSiemens();
|
||||
@@ -470,49 +473,24 @@ export default class toolingEquipment extends Vue {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private canEdit = function () {
|
||||
if(this.isSiemens){
|
||||
if(this.selectedTool)
|
||||
return (this.selectedTool.magazineId == 0)
|
||||
return false
|
||||
}
|
||||
else{
|
||||
if(this.selectedTool)
|
||||
return !this.checkIfToolIsMountedInSpindle(this.selectedTool.id)
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public toolMountedInSpindle = null
|
||||
|
||||
// Controllo se l'utensile è un utensile montato nel mandrino
|
||||
public checkIfToolIsMountedInSpindle(toolId) {
|
||||
if(!this.toolMountedInSpindle)
|
||||
this.populateMountedToolsInSplindle()
|
||||
@Watch("selectedTool")
|
||||
public checkIfToolIsMountedInSpindle() {
|
||||
|
||||
for (let i = 0; i < this.toolMountedInSpindle.length; i++) {
|
||||
const head = this.toolMountedInSpindle[i];
|
||||
if(this.selectedTool){
|
||||
const heads = this.$store.state.machineInfo.heads
|
||||
|
||||
if(toolId === head.mountedTool){
|
||||
return head.id
|
||||
for (let i = 0; i < heads.length; i++) {
|
||||
const head = this.getHeadsProperty(heads[i].id)
|
||||
|
||||
if(this.selectedTool.id=== head.mountedTool){
|
||||
this.toolIsInSpindle = true
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Polola gli utensili montati in mandrino
|
||||
public populateMountedToolsInSplindle()
|
||||
{
|
||||
this.toolMountedInSpindle = []
|
||||
const heads = this.$store.state.machineInfo.heads
|
||||
|
||||
for (let i = 0; i < heads.length; i++) {
|
||||
const head = this.getHeadsProperty(heads[i].id)
|
||||
if(head.mountedTool)
|
||||
this.toolMountedInSpindle.push(head)
|
||||
this.toolIsInSpindle = false
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
</div>
|
||||
<div class="box-right-body" v-if="enableParameters">
|
||||
|
||||
<button class="btn deleteElement" :disabled="!canEdit()" @click="deleteTool(selectedTool)"><i class="fa fa-trash"></i></button>
|
||||
<button class="btn deleteElement" v-if="selectedTool.id" :disabled="toolIsInSpindle" @click="deleteTool(selectedTool)"><i class="fa fa-trash"></i></button>
|
||||
<div class="box-right-label-header" v-if="selectedTool.id && isSiemens" >{{'tooling_equipment_editlabel' | localize("Modifica utensile %d",selectedTool.id,selectedTool.familyName)}}</div>
|
||||
<div class="box-right-label-header" v-if="selectedTool.id && !isSiemens" >{{'tooling_equipment_editlabel' | localize("Modifica utensile %d",selectedTool.id)}}</div>
|
||||
<div class="box-right-label-header" v-if="!selectedTool.id" >{{'tooling_equipment_newlabel' | localize("Creazione Nuovo Utensile")}}</div>
|
||||
@@ -103,8 +103,8 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="tooling-equipment-footer">
|
||||
<div v-if="!enableModify && !canEdit()" class="lock-icon"><i class="fa fa-lock"></i></div>
|
||||
<button class="btn" v-if="!enableModify" :disabled="!canEdit()" @click="modify()">{{'tooling_equipment_button_modify' | localize("Modifica")}}</button>
|
||||
<div v-if="!enableModify && toolIsInSpindle" class="lock-icon"><i class="fa fa-lock"></i></div>
|
||||
<button class="btn" v-if="!enableModify" :disabled="toolIsInSpindle" @click="modify()">{{'tooling_equipment_button_modify' | localize("Modifica")}}</button>
|
||||
<button class="btn" v-if="enableModify" @click="cancel()">{{'tooling_equipment_button_cancel' | localize("Annulla")}}</button>
|
||||
<button class="btn blue-reverse" :disabled="!isValid" v-if="enableModify && selectedTool.id" @click="buttonSave(selectedTool, selectedEquipment)">{{'tooling_equipment_button_save' | localize("Salva")}}</button>
|
||||
<button class="btn blue-reverse" :disabled="!isValid" v-if="enableModify && !selectedTool.id" @click="buttonSave(selectedTool, selectedEquipment)">{{'tooling_equipment_button_add' | localize("Aggiungi")}}</button>
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-right-body" v-if="enableParameters">
|
||||
<button class="btn deleteElement" v-if="!(isSiemens) || !isSiemens" @click="deleteFamily(selectedTool)"><i class="fa fa-trash"></i></button>
|
||||
<button class="btn deleteElement" v-if="(!(isSiemens) || !isSiemens) && selectedTool.id" @click="deleteFamily(selectedTool)"><i class="fa fa-trash"></i></button>
|
||||
<div class="box-right-label-header" v-if="selectedTool.name">{{'tooling_families_boxright_editlabel' | localize("Modifica della famiglia %s", selectedTool.name)}}</div>
|
||||
<div class="box-right-label-header" v-if="!selectedTool.name">{{'tooling_families_boxright_newlabel' | localize("Aggiunta nuova famiglia")}}</div>
|
||||
<div class="list-skill-families scrollable">
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-right-body" v-if="enableParameters">
|
||||
<button class="btn deleteElement" @click="deleteShank(selectedTool)"><i class="fa fa-trash"></i></button>
|
||||
<button class="btn deleteElement" v-if="selectedTool.id" @click="deleteShank(selectedTool)"><i class="fa fa-trash"></i></button>
|
||||
<div class="box-right-label-header" v-if="selectedTool.id>0">{{'tooling_shanks_editlabel' | localize("Modifica di Codolo %d",selectedTool.id)}}</div>
|
||||
<div class="box-right-label-header" v-if="!selectedTool.id || selectedTool.id<=0">{{'tooling_shanks_label_new' | localize("Creazione Utensile")}}</div>
|
||||
<div class="list-skill-shanks scrollable">
|
||||
@@ -165,7 +165,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-right-body" v-if="enableParameters">
|
||||
<button class="btn deleteElement" @click="deleteShank(selectedTool)"><i class="fa fa-trash"></i></button>
|
||||
<button class="btn deleteElement" v-if="selectedTool.id" @click="deleteShank(selectedTool)"><i class="fa fa-trash"></i></button>
|
||||
<div class="box-right-label-header" v-if="selectedTool.id>0">{{'tooling_shanks_editlabel' | localize("Modifica di Codolo %d",selectedTool.id)}}</div>
|
||||
<div class="box-right-label-header" v-if="!selectedTool.id || selectedTool.id<=0">{{'tooling_shanks_label_new' | localize("Creazione Utensile")}}</div>
|
||||
<div class="list-skill-shanks scrollable">
|
||||
|
||||
@@ -224,6 +224,8 @@ export const toolingStore = {
|
||||
store.ncTools = Array.from(store._ncTools.values());
|
||||
},
|
||||
UpdateNcTools(store, model: server.ToolNc[]){
|
||||
|
||||
store._ncTools = new Map<number, server.ToolNc>();
|
||||
// populate _ncTools
|
||||
for(var i = 0; i < model.length; i ++){
|
||||
store._ncTools.set(model[i].id, model[i]);
|
||||
|
||||
Reference in New Issue
Block a user