This commit is contained in:
2021-01-15 23:44:35 +00:00
parent 4036794dd3
commit d864ef4bc9
2 changed files with 38 additions and 2 deletions

View File

@@ -130,6 +130,8 @@ export default {
}
},
methods: {
//Get full selection for use on forms where we need the
//full selection including name, active, id
getFullSelectionValue() {
return this.lastSelection;
},

View File

@@ -19,6 +19,15 @@
</v-col>
<v-col cols="12">
<gz-pick-list
v-if="!formState.readOnly"
:ayaType="ayaTypes().Part"
:showEditIcon="true"
:label="$ay.t('Part')"
ref="partId"
data-cy="partId"
@input="addItem()"
></gz-pick-list>
<v-simple-table>
<template v-slot:default>
<thead>
@@ -264,7 +273,8 @@ export default {
serverError: {}
},
rights: window.$gz.role.defaultRightsObject(),
ayaType: window.$gz.type.PartAssembly
ayaType: window.$gz.type.PartAssembly,
selectedPart: null
};
},
//WATCHERS
@@ -302,8 +312,32 @@ export default {
}
},
methods: {
addItem: function() {
let vm = this;
let selected = vm.$refs.partId.getFullSelectionValue();
if (selected == null) {
return;
}
let index = vm.obj.items.findIndex(z => z.partId == selected.id);
if (index != -1) {
//already in the list
return;
}
vm.obj.items.push({
partAssemblyId: vm.obj.id,
partId: selected.id,
partDisplay: selected.name
});
},
removeItem: function(item) {
console.log(item);
let vm = this;
let index = vm.obj.items.findIndex(z => z.partId == item.partId);
if (index == -1) {
return;
}
vm.obj.items.splice(index, 1);
vm.formState.dirty = true;
},
canSave: function() {
return this.formState.valid && this.formState.dirty;